rem
stringlengths
0
126k
add
stringlengths
0
441k
context
stringlengths
15
136k
var dur = multilineVars.default_length ? multilineVars.default_length : 1;
var dur = 1/4; if (multilineVars.meter && multilineVars.meter.type === 'specified') { dur = 1 / parseInt(multilineVars.meter.value[0].den); } else if (multilineVars.origMeter && multilineVars.origMeter.type === 'specified') { dur = 1 / parseInt(multilineVars.origMeter.value[0].den); }
this.calcTempo = function(relTempo) { var dur = multilineVars.default_length ? multilineVars.default_length : 1; for (var i = 0; i < relTempo.duration; i++) relTempo.duration[i] = dur * relTempo.duration[i]; return relTempo; };
$('#url').val(utils.string.urlise(title)); $('#generatedUrl').html(utils.string.urlise(title));
if(typeof pageID == 'undefined' || pageID != 1) { $('#url').val(utils.string.urlise(title)); $('#generatedUrl').html(utils.string.urlise(title)); }
function calculateMeta(evt, element) { if(typeof element != 'undefined') var title = element.val(); else var title = $(this).val(); if($('#pageTitle').length > 0 && $('#pageTitleOverwrite').length > 0) { if(!$('#pageTitleOverwrite').is(':checked')) { $('#pageTitle').val(title); } } if($('#navigationTitle').length > 0 && $('#navigationTitleOverwrite').length > 0) { if(!$('#navigationTitleOverwrite').is(':checked')) { $('#navigationTitle').val(title); } } if(!$('#metaDescriptionOverwrite').is(':checked')) { $('#metaDescription').val(title); } if(!$('#metaKeywordsOverwrite').is(':checked')) { $('#metaKeywords').val(title); } if(!$('#urlOverwrite').is(':checked')) { $('#url').val(utils.string.urlise(title)); $('#generatedUrl').html(utils.string.urlise(title)); } }
return utils.string.trim(utils.string.trim($('#name').val()) +' '+ utils.string.trim($('#surname').val()));
var maxLength = parseInt($('#nickname').attr('maxlength')); if(maxLength == 0) maxLength = 255; return utils.string.trim(utils.string.trim($('#name').val()) +' '+ utils.string.trim($('#surname').val())).substring(0, maxLength);
calculateNick: function() { return utils.string.trim(utils.string.trim($('#name').val()) +' '+ utils.string.trim($('#surname').val())); },
var availSvrs = Sonatype.config.installedServers; for (var srv in availSvrs) { if (availSvrs[srv] && typeof(Sonatype[srv]) != 'undefined') { Sonatype[srv][Sonatype.utils.capitalize(srv)].statusComplete(respObj); } }
callback : function(options, success, response) { var baseUrlMismatch = false; Sonatype.view.historyDisabled = true; if (success) { var respObj = Ext.decode(response.responseText); Sonatype.utils.edition = respObj.data.editionLong; Sonatype.utils.editionShort = respObj.data.editionShort; Sonatype.utils.formattedAppName = Sonatype.utils.parseFormattedAppName(respObj.data.formattedAppName); Ext.get('logo').update('<span>' + Sonatype.utils.formattedAppName + '</span>'); Sonatype.view.headerPanel.doLayout(); Sonatype.user.curr.repoServer = respObj.data.clientPermissions.permissions; Sonatype.user.curr.isLoggedIn = respObj.data.clientPermissions.loggedIn; Sonatype.user.curr.username = respObj.data.clientPermissions.loggedInUsername; Sonatype.user.curr.loggedInUserSource = respObj.data.clientPermissions.loggedInUserSource; var availSvrs = Sonatype.config.installedServers; for (var srv in availSvrs) { if (availSvrs[srv] && typeof(Sonatype[srv]) != 'undefined') { Sonatype[srv][Sonatype.utils.capitalize(srv)].statusComplete(respObj); } } var baseUrl = respObj.data.baseUrl; baseUrlMismatch = (baseUrl.toLowerCase() != window.location.href.substring(0, baseUrl.length).toLowerCase()); } else { Sonatype.utils.edition = ''; Sonatype.user.curr.repoServer = null; Sonatype.user.curr.isLoggedIn = null; Sonatype.user.curr.username = null; Sonatype.user.curr.loggedInUserSource = null; } Sonatype.Events.fireEvent('initHeadLinks'); Sonatype.view.serverTabPanel.doLayout(); if (baseUrlMismatch && Sonatype.lib.Permissions.checkPermission('nexus:settings', Sonatype.lib.Permissions.READ)) { Sonatype.utils.postWelcomePageAlert('<b>WARNING:</b> ' + 'Base URL setting of <a href="' + baseUrl + '">' + baseUrl + '</a> ' + 'does not match your actual URL! ' + 'If you\'re running Apache mod_proxy, here\'s ' + '<a href="http://nexus.sonatype.org/about/faq.html#' + 'QHowcanIintegrateNexuswithApacheHttpdandModProxy">' + 'more information</a> on configuring Nexus with it.'); } Sonatype.Events.fireEvent('nexusStatus'); Sonatype.view.historyDisabled = false; var token = Ext.History.getToken(); if (Sonatype.view.loginSuccessfulToken) { token = Sonatype.view.loginSuccessfulToken; Sonatype.view.loginSuccessfulToken = null; } Sonatype.utils.onHistoryChange(token); Sonatype.utils.updateHistory(); Sonatype.view.justLoggedOut = false; }
} var availSvrs = Sonatype.config.installedServers; for (var srv in availSvrs) { if (availSvrs[srv] && typeof(Sonatype[srv]) != 'undefined') { Sonatype[srv][Sonatype.utils.capitalize(srv)].statusComplete(respObj); }
callback : function(options, success, response) { var baseUrlMismatch = false; Sonatype.view.historyDisabled = true; if (success) { var respObj = Ext.decode(response.responseText); Sonatype.utils.edition = respObj.data.editionLong; Sonatype.utils.editionShort = respObj.data.editionShort; Sonatype.utils.formattedAppName = Sonatype.utils.parseFormattedAppName(respObj.data.formattedAppName); Ext.get('logo').update('<span>' + Sonatype.utils.formattedAppName + '</span>'); Sonatype.view.headerPanel.doLayout(); Sonatype.user.curr.repoServer = respObj.data.clientPermissions.permissions; Sonatype.user.curr.isLoggedIn = respObj.data.clientPermissions.loggedIn; Sonatype.user.curr.username = respObj.data.clientPermissions.loggedInUsername; Sonatype.user.curr.loggedInUserSource = respObj.data.clientPermissions.loggedInUserSource; var availSvrs = Sonatype.config.installedServers; for (var srv in availSvrs) { if (availSvrs[srv] && typeof(Sonatype[srv]) != 'undefined') { Sonatype[srv][Sonatype.utils.capitalize(srv)].statusComplete(respObj); } } var baseUrl = respObj.data.baseUrl; baseUrlMismatch = (baseUrl.toLowerCase() != window.location.href.substring(0, baseUrl.length).toLowerCase()); } else { Sonatype.utils.edition = ''; Sonatype.user.curr.repoServer = null; Sonatype.user.curr.isLoggedIn = null; Sonatype.user.curr.username = null; Sonatype.user.curr.loggedInUserSource = null; } Sonatype.Events.fireEvent('initHeadLinks'); Sonatype.view.serverTabPanel.doLayout(); if (baseUrlMismatch && Sonatype.lib.Permissions.checkPermission('nexus:settings', Sonatype.lib.Permissions.READ)) { Sonatype.utils.postWelcomePageAlert('<b>WARNING:</b> ' + 'Base URL setting of <a href="' + baseUrl + '">' + baseUrl + '</a> ' + 'does not match your actual URL! ' + 'If you\'re running Apache mod_proxy, here\'s ' + '<a href="http://nexus.sonatype.org/about/faq.html#' + 'QHowcanIintegrateNexuswithApacheHttpdandModProxy">' + 'more information</a> on configuring Nexus with it.'); } Sonatype.Events.fireEvent('nexusStatus'); Sonatype.view.historyDisabled = false; var token = Ext.History.getToken(); if (Sonatype.view.loginSuccessfulToken) { token = Sonatype.view.loginSuccessfulToken; Sonatype.view.loginSuccessfulToken = null; } Sonatype.utils.onHistoryChange(token); Sonatype.utils.updateHistory(); Sonatype.view.justLoggedOut = false; }
panel.show();
callback : function(options, isSuccess, response) { if (isSuccess) { artifactContainer.tabPanel.unhideTabStripItem( panel ); panel.show(); var infoResp = Ext.decode(response.responseText); panel.showArtifact(infoResp.data); } else { if( response.stats = 404 ) { artifactContainer.tabPanel.hideTabStripItem( panel ); panel.hide(); // this hides the panel but leaves it white // FIXME: tried these... //artifactContainer.tabPanel.doLayout(); //artifactContainer.doLayout(); } else { Sonatype.utils.connectionError(response, 'Unable to retrieve Maven information.'); } } },
panel.hide();
artifactContainer.tabPanel.setActiveTab(1);
callback : function(options, isSuccess, response) { if (isSuccess) { artifactContainer.tabPanel.unhideTabStripItem( panel ); panel.show(); var infoResp = Ext.decode(response.responseText); panel.showArtifact(infoResp.data); } else { if( response.stats = 404 ) { artifactContainer.tabPanel.hideTabStripItem( panel ); panel.hide(); // this hides the panel but leaves it white // FIXME: tried these... //artifactContainer.tabPanel.doLayout(); //artifactContainer.doLayout(); } else { Sonatype.utils.connectionError(response, 'Unable to retrieve Maven information.'); } } },
Ext.Ajax.timeout = 30000;
Ext.Ajax.timeout = 60000;
callback : function(options, success, response) { if (success) { var dec = Ext.decode(response.responseText); Ext.Ajax.timeout = dec.data.uiTimeout * 1000; } else { Ext.Ajax.timeout = 30000; Sonatype.utils.connectionError(response, 'Error retrieving rest timeout'); } }
var resourceURI = Sonatype.config.servicePath + '/repositories/' + options.cbPassThru.node.attributes.repositoryId + '/archive' + json.data.repositoryPath;
var resourceURI = Sonatype.config.servicePath + '/repositories/' + options.cbPassThru.node.attributes.repositoryId + '/content' + json.data.repositoryPath;
callback : function(options, isSuccess, response) { if (isSuccess) { var json = Ext.decode(response.responseText); var resourceURI = Sonatype.config.servicePath + '/repositories/' + options.cbPassThru.node.attributes.repositoryId + '/archive' + json.data.repositoryPath; options.cbPassThru.container.artifactContainer.updateArtifact({ leaf : true, resourceURI : resourceURI, groupId : options.cbPassThru.node.attributes.groupId, artifactId : options.cbPassThru.node.attributes.artifactId, version : options.cbPassThru.node.attributes.version, repoId : options.cbPassThru.node.attributes.repositoryId, classifier : options.cbPassThru.node.attributes.classifier, extension : options.cbPassThru.node.attributes.extension, artifactLink : options.cbPassThru.node.attributes.artifactUri, pomLink : options.cbPassThru.node.attributes.pomUri, nodeName : options.cbPassThru.node.attributes.nodeName }); } },
if(typeof p == "function") return p.apply(this, args);
if(typeof p == "function") return p.apply(null, args);
callback : function (cb, args) { var p = false; var r = null; for(var i in this.settings.plugins) { if(typeof $.tree.plugins[i] != "object") continue; p = $.tree.plugins[i]; if(p.callbacks && typeof p.callbacks[cb] == "function") r = p.callbacks[cb].apply(this, args); if(typeof r !== "undefined" && r !== null) { if(cb == "ondata" || cb == "onparse") args[0] = r; // keep the chain if data or parse else return r; } } p = this.settings.callback[cb]; if(typeof p == "function") return p.apply(this, args); },
cswRecordStore.load({callback : function() { knownLayersStore.fireEvent('datachanged');
knownLayersStore.load({callback : function() { cswRecordStore.fireEvent('datachanged');
cswRecordStore.load({callback : function() { knownLayersStore.fireEvent('datachanged'); }});
CallBackToKeeFoxJS: function(sig) { keeFoxInst._KFLog.debug("Signal received by CallBackToKeeFoxJS (" + sig + ")");
CallBackToKeeFoxJS: function(sig) { var sigTime = Date(); keeFoxInst._KFLog.debug("Signal received by CallBackToKeeFoxJS (" + sig + ") @" + sigTime); var executeNow = false; var pause = false; var refresh = false;
CallBackToKeeFoxJS: function(sig) { keeFoxInst._KFLog.debug("Signal received by CallBackToKeeFoxJS (" + sig + ")"); switch (sig) { // deprecated case "0": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now disabled."); keeFoxInst._pauseKeeFox(); break; // deprecated case "1": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now enabled."); break; // deprecated case "2": keeFoxInst._KFLog.info("KeeICE callbacks from KeePass to KeeFox XPCOM are now enabled."); break; case "3": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be opened."); break; case "4": keeFoxInst._KFLog.info("KeePass' currently active DB has just been opened."); keeFoxInst._refreshKPDB(); break; case "5": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be closed."); break; case "6": keeFoxInst._KFLog.info("KeePass' currently active DB has just been closed."); keeFoxInst._refreshKPDB(); break; case "7": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be saved."); break; case "8": keeFoxInst._KFLog.info("KeePass' currently active DB has just been saved."); keeFoxInst._refreshKPDB(); break; case "9": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be deleted."); break; case "10": keeFoxInst._KFLog.info("KeePass' currently active DB has just been deleted."); break; case "11": keeFoxInst._KFLog.info("KeePass' active DB has been changed/selected."); keeFoxInst._refreshKPDB(); break; case "12": keeFoxInst._KFLog.info("KeePass is shutting down."); keeFoxInst._pauseKeeFox(); break; default: keeFoxInst._KFLog.error("Invalid signal received by CallBackToKeeFoxJS (" + sig + ")"); break; } },
case "4": keeFoxInst._KFLog.info("KeePass' currently active DB has just been opened."); keeFoxInst._refreshKPDB(); break;
case "4": keeFoxInst._KFLog.info("KeePass' currently active DB has just been opened."); refresh = true; break;
CallBackToKeeFoxJS: function(sig) { keeFoxInst._KFLog.debug("Signal received by CallBackToKeeFoxJS (" + sig + ")"); switch (sig) { // deprecated case "0": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now disabled."); keeFoxInst._pauseKeeFox(); break; // deprecated case "1": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now enabled."); break; // deprecated case "2": keeFoxInst._KFLog.info("KeeICE callbacks from KeePass to KeeFox XPCOM are now enabled."); break; case "3": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be opened."); break; case "4": keeFoxInst._KFLog.info("KeePass' currently active DB has just been opened."); keeFoxInst._refreshKPDB(); break; case "5": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be closed."); break; case "6": keeFoxInst._KFLog.info("KeePass' currently active DB has just been closed."); keeFoxInst._refreshKPDB(); break; case "7": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be saved."); break; case "8": keeFoxInst._KFLog.info("KeePass' currently active DB has just been saved."); keeFoxInst._refreshKPDB(); break; case "9": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be deleted."); break; case "10": keeFoxInst._KFLog.info("KeePass' currently active DB has just been deleted."); break; case "11": keeFoxInst._KFLog.info("KeePass' active DB has been changed/selected."); keeFoxInst._refreshKPDB(); break; case "12": keeFoxInst._KFLog.info("KeePass is shutting down."); keeFoxInst._pauseKeeFox(); break; default: keeFoxInst._KFLog.error("Invalid signal received by CallBackToKeeFoxJS (" + sig + ")"); break; } },
case "6": keeFoxInst._KFLog.info("KeePass' currently active DB has just been closed."); keeFoxInst._refreshKPDB(); break;
case "6": keeFoxInst._KFLog.info("KeePass' currently active DB has just been closed."); refresh = true; break;
CallBackToKeeFoxJS: function(sig) { keeFoxInst._KFLog.debug("Signal received by CallBackToKeeFoxJS (" + sig + ")"); switch (sig) { // deprecated case "0": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now disabled."); keeFoxInst._pauseKeeFox(); break; // deprecated case "1": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now enabled."); break; // deprecated case "2": keeFoxInst._KFLog.info("KeeICE callbacks from KeePass to KeeFox XPCOM are now enabled."); break; case "3": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be opened."); break; case "4": keeFoxInst._KFLog.info("KeePass' currently active DB has just been opened."); keeFoxInst._refreshKPDB(); break; case "5": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be closed."); break; case "6": keeFoxInst._KFLog.info("KeePass' currently active DB has just been closed."); keeFoxInst._refreshKPDB(); break; case "7": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be saved."); break; case "8": keeFoxInst._KFLog.info("KeePass' currently active DB has just been saved."); keeFoxInst._refreshKPDB(); break; case "9": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be deleted."); break; case "10": keeFoxInst._KFLog.info("KeePass' currently active DB has just been deleted."); break; case "11": keeFoxInst._KFLog.info("KeePass' active DB has been changed/selected."); keeFoxInst._refreshKPDB(); break; case "12": keeFoxInst._KFLog.info("KeePass is shutting down."); keeFoxInst._pauseKeeFox(); break; default: keeFoxInst._KFLog.error("Invalid signal received by CallBackToKeeFoxJS (" + sig + ")"); break; } },
case "8": keeFoxInst._KFLog.info("KeePass' currently active DB has just been saved."); keeFoxInst._refreshKPDB(); break;
case "8": keeFoxInst._KFLog.info("KeePass' currently active DB has just been saved."); refresh = true; break;
CallBackToKeeFoxJS: function(sig) { keeFoxInst._KFLog.debug("Signal received by CallBackToKeeFoxJS (" + sig + ")"); switch (sig) { // deprecated case "0": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now disabled."); keeFoxInst._pauseKeeFox(); break; // deprecated case "1": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now enabled."); break; // deprecated case "2": keeFoxInst._KFLog.info("KeeICE callbacks from KeePass to KeeFox XPCOM are now enabled."); break; case "3": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be opened."); break; case "4": keeFoxInst._KFLog.info("KeePass' currently active DB has just been opened."); keeFoxInst._refreshKPDB(); break; case "5": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be closed."); break; case "6": keeFoxInst._KFLog.info("KeePass' currently active DB has just been closed."); keeFoxInst._refreshKPDB(); break; case "7": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be saved."); break; case "8": keeFoxInst._KFLog.info("KeePass' currently active DB has just been saved."); keeFoxInst._refreshKPDB(); break; case "9": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be deleted."); break; case "10": keeFoxInst._KFLog.info("KeePass' currently active DB has just been deleted."); break; case "11": keeFoxInst._KFLog.info("KeePass' active DB has been changed/selected."); keeFoxInst._refreshKPDB(); break; case "12": keeFoxInst._KFLog.info("KeePass is shutting down."); keeFoxInst._pauseKeeFox(); break; default: keeFoxInst._KFLog.error("Invalid signal received by CallBackToKeeFoxJS (" + sig + ")"); break; } },
case "11": keeFoxInst._KFLog.info("KeePass' active DB has been changed/selected."); keeFoxInst._refreshKPDB(); break; case "12": keeFoxInst._KFLog.info("KeePass is shutting down."); keeFoxInst._pauseKeeFox(); break;
case "11": keeFoxInst._KFLog.info("KeePass' active DB has been changed/selected."); refresh = true; break; case "12": keeFoxInst._KFLog.info("KeePass is shutting down."); pause = true; break;
CallBackToKeeFoxJS: function(sig) { keeFoxInst._KFLog.debug("Signal received by CallBackToKeeFoxJS (" + sig + ")"); switch (sig) { // deprecated case "0": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now disabled."); keeFoxInst._pauseKeeFox(); break; // deprecated case "1": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now enabled."); break; // deprecated case "2": keeFoxInst._KFLog.info("KeeICE callbacks from KeePass to KeeFox XPCOM are now enabled."); break; case "3": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be opened."); break; case "4": keeFoxInst._KFLog.info("KeePass' currently active DB has just been opened."); keeFoxInst._refreshKPDB(); break; case "5": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be closed."); break; case "6": keeFoxInst._KFLog.info("KeePass' currently active DB has just been closed."); keeFoxInst._refreshKPDB(); break; case "7": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be saved."); break; case "8": keeFoxInst._KFLog.info("KeePass' currently active DB has just been saved."); keeFoxInst._refreshKPDB(); break; case "9": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be deleted."); break; case "10": keeFoxInst._KFLog.info("KeePass' currently active DB has just been deleted."); break; case "11": keeFoxInst._KFLog.info("KeePass' active DB has been changed/selected."); keeFoxInst._refreshKPDB(); break; case "12": keeFoxInst._KFLog.info("KeePass is shutting down."); keeFoxInst._pauseKeeFox(); break; default: keeFoxInst._KFLog.error("Invalid signal received by CallBackToKeeFoxJS (" + sig + ")"); break; } },
if (!pause && !refresh) return; var now = (new Date()).getTime(); if (!keeFoxInst.processingCallback && keeFoxInst.pendingCallback == "") { keeFoxInst._KFLog.debug("Signal executing now. @" + sigTime); keeFoxInst.processingCallback = true; executeNow = true; } if (pause) { if (executeNow) keeFoxInst._pauseKeeFox(); else keeFoxInst.pendingCallback = "_pauseKeeFox"; } if (refresh) { if (executeNow) {keeFoxInst.lastKeePassRPCRefresh = now; keeFoxInst._refreshKPDB();} else keeFoxInst.pendingCallback = "_refreshKPDB"; } keeFoxInst._KFLog.info("Signal handled or queued. @" + sigTime); if (executeNow) { if (keeFoxInst.pendingCallback=="_pauseKeeFox") keeFoxInst._pauseKeeFox(); else if (keeFoxInst.pendingCallback=="_refreshKPDB") keeFoxInst._refreshKPDB(); else keeFoxInst._KFLog.info("A pending signal was found and handled."); keeFoxInst.pendingCallback = ""; keeFoxInst.processingCallback = false; keeFoxInst._KFLog.info("Signal handled. @" + sigTime); }
CallBackToKeeFoxJS: function(sig) { keeFoxInst._KFLog.debug("Signal received by CallBackToKeeFoxJS (" + sig + ")"); switch (sig) { // deprecated case "0": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now disabled."); keeFoxInst._pauseKeeFox(); break; // deprecated case "1": keeFoxInst._KFLog.info("Javascript callbacks from KeeFox XPCOM DLL are now enabled."); break; // deprecated case "2": keeFoxInst._KFLog.info("KeeICE callbacks from KeePass to KeeFox XPCOM are now enabled."); break; case "3": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be opened."); break; case "4": keeFoxInst._KFLog.info("KeePass' currently active DB has just been opened."); keeFoxInst._refreshKPDB(); break; case "5": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be closed."); break; case "6": keeFoxInst._KFLog.info("KeePass' currently active DB has just been closed."); keeFoxInst._refreshKPDB(); break; case "7": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be saved."); break; case "8": keeFoxInst._KFLog.info("KeePass' currently active DB has just been saved."); keeFoxInst._refreshKPDB(); break; case "9": keeFoxInst._KFLog.info("KeePass' currently active DB is about to be deleted."); break; case "10": keeFoxInst._KFLog.info("KeePass' currently active DB has just been deleted."); break; case "11": keeFoxInst._KFLog.info("KeePass' active DB has been changed/selected."); keeFoxInst._refreshKPDB(); break; case "12": keeFoxInst._KFLog.info("KeePass is shutting down."); keeFoxInst._pauseKeeFox(); break; default: keeFoxInst._KFLog.error("Invalid signal received by CallBackToKeeFoxJS (" + sig + ")"); break; } },
var form = el.up('form');
var form = null, pn = el.parentNode; while (pn.tagName !== 'body' && pn.tagName !== 'BODY') { if (pn.tagName === 'form' || pn.tagName === 'FORM') { form = pn; break; } else { pn = pn.parentNode; } }
callDependencies: function(url, el) { var form = el.up('form'); if (form == null) return; var elements = Form.getElements(form); var queryComponents = new Array(); for (var i = 0; i < elements.length; i++) { if (elements[i].name && elements[i].name.substring(0, 3) != 'atk') { if (elements[i].className=='shuttle_select') { if (elements[i].name.substring(elements[i].name.length-4) != '_sel') { var queryComponent = this.serializeShuttle(elements[i]); } else { var queryComponent = null; } } else { var queryComponent = Form.Element.serialize(elements[i]); } if (queryComponent) queryComponents.push(queryComponent); } } atkErrorFields.each(function(field) { var queryComponent = $H({ 'atkerrorfields[]': field }).toQueryString(); queryComponents.push(queryComponent); }); var params = queryComponents.join('&'); var func = function(transport) { transport.responseText.evalScripts(); if (form == 'dialogform' && ATK.Dialog && ATK.Dialog.getCurrent() != null) { ATK.Dialog.getCurrent().delayedResize(); } }; new Ajax.Request(url, { method: 'post', parameters: params, evalScripts: true, onComplete: func }); },
})-1;},removeFunction:function(f){e[f]=null;},callFunction:function(f){var g=e[f];return g&&g.apply(window,Array.prototype.slice.call(arguments,1));},cssLength:(function(){var f=/^\d+(?:\.\d+)?$/;return function(g){return g+(f.test(g)?'px':'');};})(),repeat:function(f,g){return new Array(g+1).join(f);},tryThese:function(){var f;for(var g=0,h=arguments.length;g<h;g++){var i=arguments[g];try{f=i();break;}catch(j){}}return f;}};})();var e=a.tools;a.dtd=(function(){var f=e.extend,g={isindex:1,fieldset:1},h={input:1,button:1,select:1,textarea:1,label:1},i=f({a:1},h),j=f({iframe:1},i),k={hr:1,ul:1,menu:1,div:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1},l={ins:1,del:1,script:1,style:1},m=f({b:1,acronym:1,bdo:1,'var':1,'#':1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1},l),n=f({sub:1,img:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1},m),o=f({p:1},n),p=f({iframe:1},n,h),q={img:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,'#':1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,'var':1,div:1,object:1,sup:1,strike:1,dir:1,map:1,dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1},r=f({a:1},p),s={tr:1},t={'#':1},u=f({param:1},q),v=f({form:1},g,j,k,o),w={li:1},x={style:1,script:1},y={base:1,link:1,meta:1,title:1},z=f(y,x),A={head:1,body:1},B={html:1},C={address:1,blockquote:1,center:1,dir:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,isindex:1,menu:1,noframes:1,ol:1,p:1,pre:1,table:1,ul:1};return{$nonBodyContent:f(B,A,y),$block:C,$blockLimit:{body:1,div:1,td:1,th:1,caption:1,form:1},$inline:r,$body:f({script:1,style:1},C),$cdata:{script:1,style:1},$empty:{area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1},$listItem:{dd:1,dt:1,li:1},$list:{ul:1,ol:1,dl:1},$nonEditable:{applet:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,script:1,textarea:1,param:1},$removeEmpty:{abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1},$tabIndex:{a:1,area:1,button:1,input:1,object:1,select:1,textarea:1},$tableContent:{caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1},html:A,head:z,style:t,script:t,body:v,base:{},link:{},meta:{},title:t,col:{},tr:{td:1,th:1},img:{},colgroup:{col:1},noscript:v,td:v,br:{},th:v,center:v,kbd:r,button:f(o,k),basefont:{},h5:r,h4:r,samp:r,h6:r,ol:w,h1:r,h3:r,option:t,h2:r,form:f(g,j,k,o),select:{optgroup:1,option:1},font:r,ins:r,menu:w,abbr:r,label:r,table:{thead:1,col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1},code:r,script:t,tfoot:s,cite:r,li:v,input:{},iframe:v,strong:r,textarea:t,noframes:v,big:r,small:r,span:r,hr:{},dt:r,sub:r,optgroup:{option:1},param:{},bdo:r,'var':r,div:v,object:u,sup:r,dd:v,strike:r,area:{},dir:w,map:f({area:1,form:1,p:1},g,l,k),applet:u,dl:{dt:1,dd:1},del:r,isindex:{},fieldset:f({legend:1},q),thead:s,ul:w,acronym:r,b:r,a:p,blockquote:v,caption:r,i:r,u:r,tbody:s,s:r,address:f(j,o),tt:r,legend:r,q:r,pre:f(m,i),p:r,em:r,dfn:r};
if(k)this.extend(g,k,true);return g;},addFunction:function(f,g){return e.push(function(){f.apply(g||this,arguments);})-1;},removeFunction:function(f){e[f]=null;},callFunction:function(f){var g=e[f];return g&&g.apply(window,Array.prototype.slice.call(arguments,1));},cssLength:(function(){var f=/^\d+(?:\.\d+)?$/;return function(g){return g+(f.test(g)?'px':'');};})(),repeat:function(f,g){return new Array(g+1).join(f);},tryThese:function(){var f;for(var g=0,h=arguments.length;g<h;g++){var i=arguments[g];try{f=i();break;}catch(j){}}return f;},genKey:function(){return Array.prototype.slice.call(arguments).join('-');}};})();var e=a.tools;a.dtd=(function(){var f=e.extend,g={isindex:1,fieldset:1},h={input:1,button:1,select:1,textarea:1,label:1},i=f({a:1},h),j=f({iframe:1},i),k={hr:1,ul:1,menu:1,div:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1},l={ins:1,del:1,script:1,style:1},m=f({b:1,acronym:1,bdo:1,'var':1,'#':1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1},l),n=f({sub:1,img:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1},m),o=f({p:1},n),p=f({iframe:1},n,h),q={img:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,'#':1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,'var':1,div:1,object:1,sup:1,strike:1,dir:1,map:1,dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1},r=f({a:1},p),s={tr:1},t={'#':1},u=f({param:1},q),v=f({form:1},g,j,k,o),w={li:1},x={style:1,script:1},y={base:1,link:1,meta:1,title:1},z=f(y,x),A={head:1,body:1},B={html:1},C={address:1,blockquote:1,center:1,dir:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,isindex:1,menu:1,noframes:1,ol:1,p:1,pre:1,table:1,ul:1};return{$nonBodyContent:f(B,A,y),$block:C,$blockLimit:{body:1,div:1,td:1,th:1,caption:1,form:1},$inline:r,$body:f({script:1,style:1},C),$cdata:{script:1,style:1},$empty:{area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1},$listItem:{dd:1,dt:1,li:1},$list:{ul:1,ol:1,dl:1},$nonEditable:{applet:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,script:1,textarea:1,param:1},$removeEmpty:{abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1},$tabIndex:{a:1,area:1,button:1,input:1,object:1,select:1,textarea:1},$tableContent:{caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1},html:A,head:z,style:t,script:t,body:v,base:{},link:{},meta:{},title:t,col:{},tr:{td:1,th:1},img:{},colgroup:{col:1},noscript:v,td:v,br:{},th:v,center:v,kbd:r,button:f(o,k),basefont:{},h5:r,h4:r,samp:r,h6:r,ol:w,h1:r,h3:r,option:t,h2:r,form:f(g,j,k,o),select:{optgroup:1,option:1},font:r,ins:r,menu:w,abbr:r,label:r,table:{thead:1,col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1},code:r,script:t,tfoot:s,cite:r,li:v,input:{},iframe:v,strong:r,textarea:t,noframes:v,big:r,small:r,span:r,hr:{},dt:r,sub:r,optgroup:{option:1},param:{},bdo:r,'var':r,div:v,object:u,sup:r,dd:v,strike:r,area:{},dir:w,map:f({area:1,form:1,p:1},g,l,k),applet:u,dl:{dt:1,dd:1},del:r,isindex:{},fieldset:f({legend:1},q),thead:s,ul:w,acronym:r,b:r,a:p,blockquote:v,caption:r,i:r,u:r,tbody:s,s:r,address:f(j,o),tt:r,legend:r,q:r,pre:f(m,i),p:r,em:r,dfn:r};
})-1;},removeFunction:function(f){e[f]=null;},callFunction:function(f){var g=e[f];return g&&g.apply(window,Array.prototype.slice.call(arguments,1));},cssLength:(function(){var f=/^\d+(?:\.\d+)?$/;return function(g){return g+(f.test(g)?'px':'');};})(),repeat:function(f,g){return new Array(g+1).join(f);},tryThese:function(){var f;for(var g=0,h=arguments.length;g<h;g++){var i=arguments[g];try{f=i();break;}catch(j){}}return f;}};})();var e=a.tools;a.dtd=(function(){var f=e.extend,g={isindex:1,fieldset:1},h={input:1,button:1,select:1,textarea:1,label:1},i=f({a:1},h),j=f({iframe:1},i),k={hr:1,ul:1,menu:1,div:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1},l={ins:1,del:1,script:1,style:1},m=f({b:1,acronym:1,bdo:1,'var':1,'#':1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1},l),n=f({sub:1,img:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1},m),o=f({p:1},n),p=f({iframe:1},n,h),q={img:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,'#':1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,'var':1,div:1,object:1,sup:1,strike:1,dir:1,map:1,dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1},r=f({a:1},p),s={tr:1},t={'#':1},u=f({param:1},q),v=f({form:1},g,j,k,o),w={li:1},x={style:1,script:1},y={base:1,link:1,meta:1,title:1},z=f(y,x),A={head:1,body:1},B={html:1},C={address:1,blockquote:1,center:1,dir:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,isindex:1,menu:1,noframes:1,ol:1,p:1,pre:1,table:1,ul:1};return{$nonBodyContent:f(B,A,y),$block:C,$blockLimit:{body:1,div:1,td:1,th:1,caption:1,form:1},$inline:r,$body:f({script:1,style:1},C),$cdata:{script:1,style:1},$empty:{area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1},$listItem:{dd:1,dt:1,li:1},$list:{ul:1,ol:1,dl:1},$nonEditable:{applet:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,script:1,textarea:1,param:1},$removeEmpty:{abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1},$tabIndex:{a:1,area:1,button:1,input:1,object:1,select:1,textarea:1},$tableContent:{caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1},html:A,head:z,style:t,script:t,body:v,base:{},link:{},meta:{},title:t,col:{},tr:{td:1,th:1},img:{},colgroup:{col:1},noscript:v,td:v,br:{},th:v,center:v,kbd:r,button:f(o,k),basefont:{},h5:r,h4:r,samp:r,h6:r,ol:w,h1:r,h3:r,option:t,h2:r,form:f(g,j,k,o),select:{optgroup:1,option:1},font:r,ins:r,menu:w,abbr:r,label:r,table:{thead:1,col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1},code:r,script:t,tfoot:s,cite:r,li:v,input:{},iframe:v,strong:r,textarea:t,noframes:v,big:r,small:r,span:r,hr:{},dt:r,sub:r,optgroup:{option:1},param:{},bdo:r,'var':r,div:v,object:u,sup:r,dd:v,strike:r,area:{},dir:w,map:f({area:1,form:1,p:1},g,l,k),applet:u,dl:{dt:1,dd:1},del:r,isindex:{},fieldset:f({legend:1},q),thead:s,ul:w,acronym:r,b:r,a:p,blockquote:v,caption:r,i:r,u:r,tbody:s,s:r,address:f(j,o),tt:r,legend:r,q:r,pre:f(m,i),p:r,em:r,dfn:r};
if(b.mergeAttributes){b.mergeAttributes(a,false);b.src=a.src}else if(a.attributes&&a.attributes.length>0){var f,l;f=0;for(l=a.attributes.length;f<l;f++){var n=a.attributes[f].nodeName;n!="type"&&n!="name"&&b.setAttribute(n,a.getAttribute(n))}}a.parentNode.replaceChild(b,a)}}};var N=false;this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){if(!N){b=b===undefined?g.CancelAll:b;if(b&g.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue= false;if(b&g.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;try{document.activeElement&&document.activeElement.blur&&g.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}catch(f){}}}};this.getElement=function(a){var b=document.getElementById(a);if(!b)for(var f=0;f<window.frames.length;++f)try{if(b=window.frames[f].document.getElementById(a))return b}catch(l){}return b};this.widgetPageCoordinates=function(a){var b=0,f=0,l;if(g.hasTag(a,"AREA"))a=
3;this.cancelEvent=function(a,b){if(!N){b=b===undefined?g.CancelAll:b;if(b&g.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&g.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;try{document.activeElement&&document.activeElement.blur&&g.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}catch(f){}}}};this.getElement=function(a){var b=document.getElementById(a);if(!b)for(var f=0;f<window.frames.length;++f)try{if(b=
if(b.mergeAttributes){b.mergeAttributes(a,false);b.src=a.src}else if(a.attributes&&a.attributes.length>0){var f,l;f=0;for(l=a.attributes.length;f<l;f++){var n=a.attributes[f].nodeName;n!="type"&&n!="name"&&b.setAttribute(n,a.getAttribute(n))}}a.parentNode.replaceChild(b,a)}}};var N=false;this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){if(!N){b=b===undefined?g.CancelAll:b;if(b&g.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&g.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;try{document.activeElement&&document.activeElement.blur&&g.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}catch(f){}}}};this.getElement=function(a){var b=document.getElementById(a);if(!b)for(var f=0;f<window.frames.length;++f)try{if(b=window.frames[f].document.getElementById(a))return b}catch(l){}return b};this.widgetPageCoordinates=function(a){var b=0,f=0,l;if(g.hasTag(a,"AREA"))a=
if (delegating) return;
this.cancelEvent = function(e, cancelType) { var ct = cancelType === undefined ? WT.CancelAll : cancelType; if (ct & WT.CancelDefaultAction) if (e.preventDefault) e.preventDefault(); else e.returnValue=false; if (ct & WT.CancelPropagate) { if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble=true; try { if (document.activeElement && document.activeElement.blur) if (WT.hasTag(document.activeElement, "TEXTAREA")) document.activeElement.blur(); } catch(e) { } }};
if(b.mergeAttributes){b.mergeAttributes(a,false);b.src=a.src}else if(a.attributes&&a.attributes.length>0){var f,l;f=0;for(l=a.attributes.length;f<l;f++){var n=a.attributes[f].nodeName;n!="type"&&n!="name"&&b.setAttribute(n,a.getAttribute(n))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?g.CancelAll:b;if(b&g.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b& g.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;try{document.activeElement&&document.activeElement.blur&&g.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}catch(f){}}};this.getElement=function(a){var b=document.getElementById(a);if(!b)for(var f=0;f<window.frames.length;++f)try{if(b=window.frames[f].document.getElementById(a))return b}catch(l){}return b};this.widgetPageCoordinates=function(a){var b=0,f=0,l;if(g.hasTag(a,"AREA"))a=a.parentNode.nextSibling;
if(b.mergeAttributes){b.mergeAttributes(a,false);b.src=a.src}else if(a.attributes&&a.attributes.length>0){var f,l;f=0;for(l=a.attributes.length;f<l;f++){var n=a.attributes[f].nodeName;n!="type"&&n!="name"&&b.setAttribute(n,a.getAttribute(n))}}a.parentNode.replaceChild(b,a)}}};var N=false;this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){if(!N){b=b===undefined?g.CancelAll:b;if(b&g.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue= false;if(b&g.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;try{document.activeElement&&document.activeElement.blur&&g.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}catch(f){}}}};this.getElement=function(a){var b=document.getElementById(a);if(!b)for(var f=0;f<window.frames.length;++f)try{if(b=window.frames[f].document.getElementById(a))return b}catch(l){}return b};this.widgetPageCoordinates=function(a){var b=0,f=0,l;if(g.hasTag(a,"AREA"))a=
if(b.mergeAttributes){b.mergeAttributes(a,false);b.src=a.src}else if(a.attributes&&a.attributes.length>0){var f,l;f=0;for(l=a.attributes.length;f<l;f++){var n=a.attributes[f].nodeName;n!="type"&&n!="name"&&b.setAttribute(n,a.getAttribute(n))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?g.CancelAll:b;if(b&g.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&g.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;try{document.activeElement&&document.activeElement.blur&&g.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}catch(f){}}};this.getElement=function(a){var b=document.getElementById(a);if(!b)for(var f=0;f<window.frames.length;++f)try{if(b=window.frames[f].document.getElementById(a))return b}catch(l){}return b};this.widgetPageCoordinates=function(a){var b=0,f=0,l;if(g.hasTag(a,"AREA"))a=a.parentNode.nextSibling;
i!="type"&&i!="name"&&b.setAttribute(i,a.getAttribute(i))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?h.CancelAll:b;if(b&h.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&h.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;document.activeElement&&document.activeElement.blur&&h.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}};
i!="type"&&i!="name"&&b.setAttribute(i,a.getAttribute(i))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?g.CancelAll:b;if(b&g.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&g.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;document.activeElement&&document.activeElement.blur&&g.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}};
i!="type"&&i!="name"&&b.setAttribute(i,a.getAttribute(i))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?h.CancelAll:b;if(b&h.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&h.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;document.activeElement&&document.activeElement.blur&&h.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}};
i!="type"&&i!="name"&&b.setAttribute(i,a.getAttribute(i))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?g.CancelAll:b;if(b&g.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&g.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;document.activeElement&&document.activeElement.blur&&g.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}};
i!="type"&&i!="name"&&b.setAttribute(i,a.getAttribute(i))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?h.CancelAll:b;if(b&h.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&h.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;document.activeElement&&document.activeElement.blur&&h.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}};
i!="type"&&i!="name"&&b.setAttribute(i,a.getAttribute(i))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?g.CancelAll:b;if(b&g.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&g.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;document.activeElement&&document.activeElement.blur&&g.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}};
l!="type"&&l!="name"&&b.setAttribute(l,a.getAttribute(l))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?k.CancelAll:b;if(b&k.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&k.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;document.activeElement&&document.activeElement.blur&&k.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}};
false);b.src=a.src}else if(a.attributes&&a.attributes.length>0){var f,m;f=0;for(m=a.attributes.length;f<m;f++){var l=a.attributes[f].nodeName;l!="type"&&l!="name"&&b.setAttribute(l,a.getAttribute(l))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?k.CancelAll:b;if(b&k.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&k.CancelPropagate){if(a.stopPropagation)a.stopPropagation(); else a.cancelBubble=true;document.activeElement&&document.activeElement.blur&&k.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}};this.getElement=function(a){var b=document.getElementById(a);if(!b)for(var f=0;f<window.frames.length;++f)try{if(b=window.frames[f].document.getElementById(a))return b}catch(m){}return b};this.widgetPageCoordinates=function(a){var b=0,f=0,m;if(k.hasTag(a,"AREA"))a=a.parentNode.nextSibling;for(;a;){b+=a.offsetLeft;f+=a.offsetTop;m=a.offsetParent;
l!="type"&&l!="name"&&b.setAttribute(l,a.getAttribute(l))}}a.parentNode.replaceChild(b,a)}}};this.CancelPropagate=1;this.CancelDefaultAction=2;this.CancelAll=3;this.cancelEvent=function(a,b){b=b===undefined?k.CancelAll:b;if(b&k.CancelDefaultAction)if(a.preventDefault)a.preventDefault();else a.returnValue=false;if(b&k.CancelPropagate){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true;document.activeElement&&document.activeElement.blur&&k.hasTag(document.activeElement,"TEXTAREA")&&document.activeElement.blur()}};
function(a){return g.firedTarget||a.target||a.srcElement};var da=false;this.capture=function(a){W();if(!(z&&a)){z=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){z&&a==z&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=
"block"};this.show=function(a){g.getElement(a).style.display=""};var z=null;this.firedTarget=null;this.target=function(a){return g.firedTarget||a.target||a.srcElement};var da=false;this.capture=function(a){W();if(!(z&&a)){z=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart= ""}}};this.checkReleaseCapture=function(a,b){z&&a==z&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var f=[],l,n=0,o=b.length;n<o;n++){l=b[n];l.className.indexOf(a)!=-1&&f.push(l)}return f}};this.addCss=function(a,b){var f=document.styleSheets[0];f.insertRule(a+" { "+b+" }",f.cssRules.length)};this.addCssText=function(a){var b=document.getElementById("Wt-inline-css");
function(a){return g.firedTarget||a.target||a.srcElement};var da=false;this.capture=function(a){W();if(!(z&&a)){z=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){z&&a==z&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=
""};var B=null;this.firedTarget=null;this.target=function(a){return g.firedTarget||a.target||a.srcElement};var S=false,Y=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==
""};var B=null;this.firedTarget=null;this.target=function(a){return g.firedTarget||a.target||a.srcElement};var S=false,U=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==
""};var B=null;this.firedTarget=null;this.target=function(a){return g.firedTarget||a.target||a.srcElement};var S=false,Y=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==
a.target||a.srcElement};var P=false,da=false;this.capture=function(a){W();if(!(z&&a)){z=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){z&&a==z&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,
function(a){return g.firedTarget||a.target||a.srcElement};var da=false;this.capture=function(a){W();if(!(z&&a)){z=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){z&&a==z&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=
a.target||a.srcElement};var P=false,da=false;this.capture=function(a){W();if(!(z&&a)){z=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){z&&a==z&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,
2?i[1]:"0")?parseFloat(i):0;e=(i=(i=/^\s*(-?\d+(?:\.\d+)?)\s*\%\s*$/.exec(e))&&i.length==2?i[1]:"100000")?parseFloat(i):1E5;return k<b?b-1:k>e?e+1:a.style.styleFloat!=""?b-1:"auto"}else return"auto"};this.hide=function(a){h.getElement(a).style.display="none"};this.inline=function(a){h.getElement(a).style.display="inline"};this.block=function(a){h.getElement(a).style.display="block"};this.show=function(a){h.getElement(a).style.display=""};var C=null,T=false;this.capture=function(a){ba();if(!(C&&a)){C= a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){C&&a==C&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");
2?i[1]:"0")?parseFloat(i):0;e=(i=(i=/^\s*(-?\d+(?:\.\d+)?)\s*\%\s*$/.exec(e))&&i.length==2?i[1]:"100000")?parseFloat(i):1E5;return j<b?b-1:j>e?e+1:a.style.styleFloat!=""?b-1:"auto"}else return"auto"};this.hide=function(a){g.getElement(a).style.display="none"};this.inline=function(a){g.getElement(a).style.display="inline"};this.block=function(a){g.getElement(a).style.display="block"};this.show=function(a){g.getElement(a).style.display=""};var B=null,S=false;this.capture=function(a){aa();if(!(B&&a)){B= a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==B&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");
2?i[1]:"0")?parseFloat(i):0;e=(i=(i=/^\s*(-?\d+(?:\.\d+)?)\s*\%\s*$/.exec(e))&&i.length==2?i[1]:"100000")?parseFloat(i):1E5;return k<b?b-1:k>e?e+1:a.style.styleFloat!=""?b-1:"auto"}else return"auto"};this.hide=function(a){h.getElement(a).style.display="none"};this.inline=function(a){h.getElement(a).style.display="inline"};this.block=function(a){h.getElement(a).style.display="block"};this.show=function(a){h.getElement(a).style.display=""};var C=null,T=false;this.capture=function(a){ba();if(!(C&&a)){C=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){C&&a==C&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");
""?b-1:"auto"}else return"auto"};this.hide=function(a){g.getElement(a).style.display="none"};this.inline=function(a){g.getElement(a).style.display="inline"};this.block=function(a){g.getElement(a).style.display="block"};this.show=function(a){g.getElement(a).style.display=""};var C=null,T=false;this.capture=function(a){ba();if(!(C&&a)){C=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart=
""?b-1:"auto"}else return"auto"};this.hide=function(a){h.getElement(a).style.display="none"};this.inline=function(a){h.getElement(a).style.display="inline"};this.block=function(a){h.getElement(a).style.display="block"};this.show=function(a){h.getElement(a).style.display=""};var C=null,T=false;this.capture=function(a){ba();if(!(C&&a)){C=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart=
""?b-1:"auto"}else return"auto"};this.hide=function(a){g.getElement(a).style.display="none"};this.inline=function(a){g.getElement(a).style.display="inline"};this.block=function(a){g.getElement(a).style.display="block"};this.show=function(a){g.getElement(a).style.display=""};var C=null,T=false;this.capture=function(a){ba();if(!(C&&a)){C=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){C&&a==C&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var e=[],k,i=0,n=b.length;i<n;i++){k=b[i];k.className.indexOf(a)!=-1&&e.push(k)}return e}};this.addCss=function(a,b){var e=document.styleSheets[0];e.insertRule(a+
""};var B=null,S=false,Y=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==B&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);
"none"};this.inline=function(a){g.getElement(a).style.display="inline"};this.block=function(a){g.getElement(a).style.display="block"};this.show=function(a){g.getElement(a).style.display=""};var B=null,S=false,Y=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable", "off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==B&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var f=[],h,k=0,o=b.length;k<o;k++){h=b[k];h.className.indexOf(a)!=-1&&f.push(h)}return f}};this.addCss=function(a,b){var f=document.styleSheets[0];f.insertRule(a+" { "+b+" }",f.cssRules.length)};this.addCssText=function(a){var b=document.getElementById("Wt-inline-css");
""};var B=null,S=false,Y=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==B&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);
this.hide=function(a){k.getElement(a).style.display="none"};this.inline=function(a){k.getElement(a).style.display="inline"};this.block=function(a){k.getElement(a).style.display="block"};this.show=function(a){k.getElement(a).style.display=""};var G=null,P=false;this.capture=function(a){F();G=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){b.className="unselectable";b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{b.className="";b.setAttribute("unselectable", "off");b.onselectstart=""}};this.checkReleaseCapture=function(a,b){G&&a==G&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var f=[],m,l=0,o=b.length;l<o;l++){m=b[l];m.className.indexOf(a)!=-1&&f.push(m)}return f}};this.addCss=function(a,b){var f=document.styleSheets[0];f.insertRule(a+" { "+b+" }",f.cssRules.length)};this.addCssText=function(a){var b=document.getElementById("Wt-inline-css");
"inline"};this.block=function(a){k.getElement(a).style.display="block"};this.show=function(a){k.getElement(a).style.display=""};var D=null,R=false;this.capture=function(a){Y();D=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){b.className="unselectable";b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{b.className="";b.setAttribute("unselectable","off");b.onselectstart=""}};this.checkReleaseCapture=function(a,b){D&&a==D&&b.type=="mouseup"&&
this.hide=function(a){k.getElement(a).style.display="none"};this.inline=function(a){k.getElement(a).style.display="inline"};this.block=function(a){k.getElement(a).style.display="block"};this.show=function(a){k.getElement(a).style.display=""};var G=null,P=false;this.capture=function(a){F();G=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){b.className="unselectable";b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{b.className="";b.setAttribute("unselectable","off");b.onselectstart=""}};this.checkReleaseCapture=function(a,b){G&&a==G&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var f=[],m,l=0,o=b.length;l<o;l++){m=b[l];m.className.indexOf(a)!=-1&&f.push(m)}return f}};this.addCss=function(a,b){var f=document.styleSheets[0];f.insertRule(a+" { "+b+" }",f.cssRules.length)};this.addCssText=function(a){var b=document.getElementById("Wt-inline-css");
'mpaa': 'MPAA',
function captureStartState() { imdbQueue = []; imdbQueueIndex = 0; totalPages = 0; maxPageNum = 0; totalRatings = 0; maxRatingNum = 0; stop = false; timer = null; startTime = (new Date()).getTime(); // Get checkbox options. GET_IMDB_DATA = document.getElementById('getImdbData').checked; if (SHOW_BEST_EFFORT_MATCH_OPTION) { BEST_EFFORT_MATCH = document.getElementById( 'bestEffortMatch').checked; } if (GET_IMDB_DATA) { // Let the user know the output will not come immediately. alert('Extracting Netflix ratings first, then getting IMDB ' + 'details.\nOutput will start once Netflix data has been ' + 'extracted.'); } // Write out column titles. saveRating( { 'id': 'ID', 'title': 'Title', 'alt': 'Alternate Title', 'year': 'Year', 'mpaa': 'MPAA', 'genre': 'Genre', 'rating': 'Rating', 'imdb_id': 'IMDB ID', 'imdb_title': 'IMDB Title', 'imdb_year': 'IMDB Year' } ); }
null){b=e=null;this.centerDialog=function(){}}else if(b.style.display!="none"){if(!j){var a=c.windowSize(),f=b.offsetWidth,d=b.offsetHeight;b.style.left=Math.round((a.x-f)/2+(c.isIE6?document.documentElement.scrollLeft:0))+"px";b.style.top=Math.round((a.y-d)/2+(c.isIE6?document.documentElement.scrollTop:0))+"px";b.style.marginLeft="0px";b.style.marginTop="0px";b.style.width!=null&&b.style.height!=null&&l.wtResize(b,f,d)}b.style.visibility="visible"}};this.wtResize=function(a,f,d){d-=2;f-=2;a.style.height=
f.onmouseup=function(){f.onmousemove=null;d.capture(null)}}this.centerDialog=function(){if(b.parentNode==null){b=f=null;this.centerDialog=function(){}}else if(b.style.display!="none"){if(!j){var a=d.windowSize(),c=b.offsetWidth,e=b.offsetHeight;b.style.left=Math.round((a.x-c)/2+(d.isIE6?document.documentElement.scrollLeft:0))+"px";b.style.top=Math.round((a.y-e)/2+(d.isIE6?document.documentElement.scrollTop:0))+"px";b.style.marginLeft="0px";b.style.marginTop="0px";b.style.width!=null&&b.style.height!=
null){b=e=null;this.centerDialog=function(){}}else if(b.style.display!="none"){if(!j){var a=c.windowSize(),f=b.offsetWidth,d=b.offsetHeight;b.style.left=Math.round((a.x-f)/2+(c.isIE6?document.documentElement.scrollLeft:0))+"px";b.style.top=Math.round((a.y-d)/2+(c.isIE6?document.documentElement.scrollTop:0))+"px";b.style.marginLeft="0px";b.style.marginTop="0px";b.style.width!=null&&b.style.height!=null&&l.wtResize(b,f,d)}b.style.visibility="visible"}};this.wtResize=function(a,f,d){d-=2;f-=2;a.style.height=
f.onmouseup=function(){f.onmousemove=null;d.capture(null)}}this.centerDialog=function(){if(b.parentNode==null){b=f=null;this.centerDialog=function(){}}else if(b.style.display!="none"){if(!j){var a=d.windowSize(),c=b.offsetWidth,e=b.offsetHeight;b.style.left=Math.round((a.x-c)/2+(d.isIE6?document.documentElement.scrollLeft:0))+"px";b.style.top=Math.round((a.y-e)/2+(d.isIE6?document.documentElement.scrollTop:0))+"px";b.style.marginLeft="0px";b.style.marginTop="0px";b.style.width!=null&&b.style.height!=
i=a.x;j=a.y;f.onmousemove=k};f.onmouseup=function(){f.onmousemove=null;d.capture(null)}}this.centerDialog=function(){if(b.parentNode==null){b=f=null;this.centerDialog=function(){}}else if(b.style.display!="none"){if(!h){var a=d.windowSize(),c=b.offsetWidth,e=b.offsetHeight;b.style.left=Math.round((a.x-c)/2+(d.isIE6?document.documentElement.scrollLeft:0))+"px";b.style.top=Math.round((a.y-e)/2+(d.isIE6?document.documentElement.scrollTop:0))+"px";b.style.marginLeft="0px";b.style.marginTop="0px";b.style.width!=
f.onmouseup=function(){f.onmousemove=null;d.capture(null)}}this.centerDialog=function(){if(b.parentNode==null){b=f=null;this.centerDialog=function(){}}else if(b.style.display!="none"){if(!j){var a=d.windowSize(),c=b.offsetWidth,e=b.offsetHeight;b.style.left=Math.round((a.x-c)/2+(d.isIE6?document.documentElement.scrollLeft:0))+"px";b.style.top=Math.round((a.y-e)/2+(d.isIE6?document.documentElement.scrollTop:0))+"px";b.style.marginLeft="0px";b.style.marginTop="0px";b.style.width!=null&&b.style.height!=
this.syncRequest(this, "ChangeDatabase", [fileName, closeCurrent]);
this.request(this, "ChangeDatabase", [fileName, closeCurrent], null, ++this.requestId);
this.changeDB = function(fileName, closeCurrent) { this.syncRequest(this, "ChangeDatabase", [fileName, closeCurrent]); return; }
$('.contentTitle .inputDropdown').each(function() {
$('.contentTitle .select').each(function() {
changeExtra: function(evt) { // find element with a block selected var element = $('.contentTitle option[rel=block]:selected'); // nothing selected, so free all other elements if(element.length == 0) $('.contentTitle option').attr('disabled', ''); // disable all other elements else $('.contentTitle option[rel=block]:not(:selected)').attr('disabled', 'disabled'); // loop all $('.contentTitle .inputDropdown').each(function() { // get selected value var val = $(this).val(); var id = $(this).attr('id'); var index = id.replace('blockExtraId', ''); var data = (val !== 'html') ? extraData[val] : null; // no real data, show editor if(data == null) { $('#blockContentHTML-'+ index).show(); $('#blockContentExtra-'+ index).hide(); $('#blockContentExtra-'+ index + ' p').html('&nbsp;'); } else { if(data.type == 'block') { // build html var html = '{$msgModuleAttached}'.replace('{url}', data.data.url) .replace('{name}', data.label); } else { // build html var html = '{$msgWidgetAttached}'; } $('#blockContentHTML-'+ index).hide(); $('#blockContentExtra-'+ index).show(); $('#blockContentExtra-'+ index + ' p').html(html); } }); },
$('#blockContentModule-'+ selectedBlock +' p span').html(extrasById[selectedExtraId].message); $('#blockContentModule-'+ selectedBlock +' p a').attr('href', extrasById[selectedExtraId].data.url);
$('#blockContentModule-'+ selectedBlock +' .oneLiner span').html(extrasById[selectedExtraId].message); $('#blockContentModule-'+ selectedBlock +' .oneLiner a').attr('href', extrasById[selectedExtraId].data.url);
changeExtra: function(selectedExtraId, selectedBlock) { // if their are no arguments passed we should grab them if(!selectedExtraId && !selectedBlock) { // init vars var selectedExtraId = $('#extraExtraId').val(); var selectedBlock = $('#extraForBlock').val(); } // something is really fucked up if(selectedBlock == '') return false; // store $('#blockExtraId'+ selectedBlock).val(selectedExtraId); // empty the extraForBlock $('#extraForBlock').val(''); if($('#templateBlock-'+ selectedBlock).length > 0) { if(typeof extrasById != 'undefined' && typeof extrasById[selectedExtraId] != 'undefined') { // set description $('#templateBlock-'+ selectedBlock +' .templateBlockCurrentType').html(extrasById[selectedExtraId].human_name); // hide block $('#blockContentModule-'+ selectedBlock).hide(); $('#blockContentWidget-'+ selectedBlock).hide(); $('#blockContentHTML-'+ selectedBlock).hide(); if(extrasById[selectedExtraId].type == 'block') { $('#blockContentModule-'+ selectedBlock +' p span').html(extrasById[selectedExtraId].message); $('#blockContentModule-'+ selectedBlock +' p a').attr('href', extrasById[selectedExtraId].data.url); $('#blockContentModule-'+ selectedBlock).show(); } if(extrasById[selectedExtraId].type == 'widget') { $('#blockContentWidget-'+ selectedBlock +' p span').html(extrasById[selectedExtraId].message); if(typeof extrasById[selectedExtraId].data.edit_url == 'undefined' || extrasById[selectedExtraId].data.edit_url == '') $('#blockContentWidget-'+ selectedBlock +' p a').hide(); else $('#blockContentWidget-'+ selectedBlock +' p a').attr('href', extrasById[selectedExtraId].data.edit_url).show(); $('#blockContentWidget-'+ selectedBlock).show(); } } else { // set description $('#templateBlock-'+ selectedBlock +' .templateBlockCurrentType').html('{$lblEditor|ucfirst}'); // show and hide $('#blockContentModule-'+ selectedBlock).hide(); $('#blockContentWidget-'+ selectedBlock).hide(); $('#blockContentHTML-'+ selectedBlock).show(); } } },
$('#blockContentWidget-'+ selectedBlock +' p span').html(extrasById[selectedExtraId].message); if(typeof extrasById[selectedExtraId].data.edit_url == 'undefined' || extrasById[selectedExtraId].data.edit_url == '') $('#blockContentWidget-'+ selectedBlock +' p a').hide(); else $('#blockContentWidget-'+ selectedBlock +' p a').attr('href', extrasById[selectedExtraId].data.edit_url).show();
$('#blockContentWidget-'+ selectedBlock +' .oneLiner span').html(extrasById[selectedExtraId].message); if(typeof extrasById[selectedExtraId].data.edit_url == 'undefined' || extrasById[selectedExtraId].data.edit_url == '') $('#blockContentWidget-'+ selectedBlock +' .oneLiner a').hide(); else $('#blockContentWidget-'+ selectedBlock +' .oneLiner a').attr('href', extrasById[selectedExtraId].data.edit_url).show();
changeExtra: function(selectedExtraId, selectedBlock) { // if their are no arguments passed we should grab them if(!selectedExtraId && !selectedBlock) { // init vars var selectedExtraId = $('#extraExtraId').val(); var selectedBlock = $('#extraForBlock').val(); } // something is really fucked up if(selectedBlock == '') return false; // store $('#blockExtraId'+ selectedBlock).val(selectedExtraId); // empty the extraForBlock $('#extraForBlock').val(''); if($('#templateBlock-'+ selectedBlock).length > 0) { if(typeof extrasById != 'undefined' && typeof extrasById[selectedExtraId] != 'undefined') { // set description $('#templateBlock-'+ selectedBlock +' .templateBlockCurrentType').html(extrasById[selectedExtraId].human_name); // hide block $('#blockContentModule-'+ selectedBlock).hide(); $('#blockContentWidget-'+ selectedBlock).hide(); $('#blockContentHTML-'+ selectedBlock).hide(); if(extrasById[selectedExtraId].type == 'block') { $('#blockContentModule-'+ selectedBlock +' p span').html(extrasById[selectedExtraId].message); $('#blockContentModule-'+ selectedBlock +' p a').attr('href', extrasById[selectedExtraId].data.url); $('#blockContentModule-'+ selectedBlock).show(); } if(extrasById[selectedExtraId].type == 'widget') { $('#blockContentWidget-'+ selectedBlock +' p span').html(extrasById[selectedExtraId].message); if(typeof extrasById[selectedExtraId].data.edit_url == 'undefined' || extrasById[selectedExtraId].data.edit_url == '') $('#blockContentWidget-'+ selectedBlock +' p a').hide(); else $('#blockContentWidget-'+ selectedBlock +' p a').attr('href', extrasById[selectedExtraId].data.edit_url).show(); $('#blockContentWidget-'+ selectedBlock).show(); } } else { // set description $('#templateBlock-'+ selectedBlock +' .templateBlockCurrentType').html('{$lblEditor|ucfirst}'); // show and hide $('#blockContentModule-'+ selectedBlock).hide(); $('#blockContentWidget-'+ selectedBlock).hide(); $('#blockContentHTML-'+ selectedBlock).show(); } } },
$('#blockContentModule-'+ selectedBlock +' .oneLiner a').attr('href', extrasById[selectedExtraId].data.url);
if(extrasById[selectedExtraId].data.url == '') $('#blockContentModule-'+ selectedBlock +' .oneLiner a').hide(); else { $('#blockContentModule-'+ selectedBlock +' .oneLiner a').show() .attr('href', extrasById[selectedExtraId].data.url); }
changeExtra: function(selectedExtraId, selectedBlock) { // if their are no arguments passed we should grab them if(!selectedExtraId && !selectedBlock) { // init vars var selectedExtraId = $('#extraExtraId').val(); var selectedBlock = $('#extraForBlock').val(); } // something is really fucked up if(selectedBlock == '') return false; // store $('#blockExtraId'+ selectedBlock).val(selectedExtraId); // empty the extraForBlock $('#extraForBlock').val(''); if($('#templateBlock-'+ selectedBlock).length > 0) { if(typeof extrasById != 'undefined' && typeof extrasById[selectedExtraId] != 'undefined') { // set description $('#templateBlock-'+ selectedBlock +' .templateBlockCurrentType').html(extrasById[selectedExtraId].human_name); // hide block $('#blockContentModule-'+ selectedBlock).hide(); $('#blockContentWidget-'+ selectedBlock).hide(); $('#blockContentHTML-'+ selectedBlock).hide(); if(extrasById[selectedExtraId].type == 'block') { $('#blockContentModule-'+ selectedBlock +' .oneLiner span').html(extrasById[selectedExtraId].message); $('#blockContentModule-'+ selectedBlock +' .oneLiner a').attr('href', extrasById[selectedExtraId].data.url); $('#blockContentModule-'+ selectedBlock).show(); } if(extrasById[selectedExtraId].type == 'widget') { $('#blockContentWidget-'+ selectedBlock +' .oneLiner span').html(extrasById[selectedExtraId].message); if(typeof extrasById[selectedExtraId].data.edit_url == 'undefined' || extrasById[selectedExtraId].data.edit_url == '') $('#blockContentWidget-'+ selectedBlock +' .oneLiner a').hide(); else $('#blockContentWidget-'+ selectedBlock +' .oneLiner a').attr('href', extrasById[selectedExtraId].data.edit_url).show(); $('#blockContentWidget-'+ selectedBlock).show(); } } else { // set description $('#templateBlock-'+ selectedBlock +' .templateBlockCurrentType').html('{$lblEditor|ucfirst}'); // show and hide $('#blockContentModule-'+ selectedBlock).hide(); $('#blockContentWidget-'+ selectedBlock).hide(); $('#blockContentHTML-'+ selectedBlock).show(); } } },
var increaseNumbering = isIncreasing
var increaseNumbering = isIncreasing;
function changeRowNumbering(row, isIncreasing, creatingNewRow) { // Change row label contents var rowLabelElt = row.find("label"); var curRowNum = rowLabelElt.html(); var rowQstIdAttr = rowLabelElt.attr("for"); // Update row label if(isIncreasing) { curRowNum++; } else { curRowNum--; } rowLabelElt.html(curRowNum); // Update question input var rowQstInputElt = row.find("input#"+rowQstIdAttr); //var increaseNumbering = true; //steve talk to me about this change var increaseNumbering = isIncreasing var newRowQstIdAttr = changeNumInString(rowQstIdAttr, increaseNumbering); var newRowQstNameAttr = changeNumInString(rowQstInputElt.attr("name"), increaseNumbering); rowLabelElt.attr("for",newRowQstIdAttr); rowQstInputElt.attr("id",newRowQstIdAttr); rowQstInputElt.attr("name",newRowQstNameAttr); // Update answer input var rowAnsInputElt = row.find("input:last"); var newRowIdAttr = changeNumInString(rowAnsInputElt.attr("id"), increaseNumbering); var newRowNameAttr = changeNumInString(rowAnsInputElt.attr("name"), increaseNumbering); rowAnsInputElt.attr("id",newRowIdAttr); rowAnsInputElt.attr("name",newRowNameAttr); // Update Order value var rowOrderInputElt = row.find("input[name$='[order]']"); var rowOrderIdAttr = rowOrderInputElt.attr("id"); var rowOrderValueAttr = parseFloat(rowOrderInputElt.attr("value")); var newRowOrderIdAttr = changeNumInString(rowOrderIdAttr, increaseNumbering); var newRowOrderNameAttr = changeNumInString(rowOrderInputElt.attr("name"), increaseNumbering); rowOrderInputElt.attr("id",newRowOrderIdAttr); rowOrderInputElt.attr("name",newRowOrderNameAttr); if(increaseNumbering) { newRowOrderValueAttr = rowOrderValueAttr + 1; } else { newRowOrderValueAttr = rowOrderValueAttr - 1; } rowOrderInputElt.attr("value",newRowOrderValueAttr); // Update Id value var rowIdInputElt = row.find("input[name$='[id]']"); var rowIdIdAttr = rowIdInputElt.attr("id"); var newRowIdIdAttr = changeNumInString(rowIdIdAttr, increaseNumbering); var newRowIdNameAttr = changeNumInString(rowIdInputElt.attr("name"), increaseNumbering); rowIdInputElt.attr("id",newRowIdIdAttr); rowIdInputElt.attr("name",newRowIdNameAttr); //alert(rowIdInputElt.attr("value") + " " + rowIdIdAttr +" " + newRowIdNameAttr); // Clear the field values if row is new if(creatingNewRow) { rowQstInputElt.attr("value",""); rowAnsInputElt.attr("value",""); rowIdInputElt.attr("value",""); }}
var newRowIdIdAttr = changeNumInString(rowIdIdAttr, increaseNumbering); var newRowIdNameAttr = changeNumInString(rowIdInputElt.attr("name"), increaseNumbering); rowIdInputElt.attr("id",newRowIdIdAttr); rowIdInputElt.attr("name",newRowIdNameAttr);
if (rowIdIdAttr != null) { var newRowIdIdAttr = changeNumInString(rowIdIdAttr, increaseNumbering); var newRowIdNameAttr = changeNumInString(rowIdInputElt.attr("name"), increaseNumbering); rowIdInputElt.attr("id",newRowIdIdAttr); rowIdInputElt.attr("name",newRowIdNameAttr); }
function changeRowNumbering(row, isIncreasing, creatingNewRow) { // Change row label contents var rowLabelElt = row.find("label"); var curRowNum = rowLabelElt.html(); var rowQstIdAttr = rowLabelElt.attr("for"); // Update row label if(isIncreasing) { curRowNum++; } else { curRowNum--; } rowLabelElt.html(curRowNum); // Update question input var rowQstInputElt = row.find("input#"+rowQstIdAttr); //var increaseNumbering = true; //steve talk to me about this change var increaseNumbering = isIncreasing var newRowQstIdAttr = changeNumInString(rowQstIdAttr, increaseNumbering); var newRowQstNameAttr = changeNumInString(rowQstInputElt.attr("name"), increaseNumbering); rowLabelElt.attr("for",newRowQstIdAttr); rowQstInputElt.attr("id",newRowQstIdAttr); rowQstInputElt.attr("name",newRowQstNameAttr); // Update answer input var rowAnsInputElt = row.find("input:last"); var newRowIdAttr = changeNumInString(rowAnsInputElt.attr("id"), increaseNumbering); var newRowNameAttr = changeNumInString(rowAnsInputElt.attr("name"), increaseNumbering); rowAnsInputElt.attr("id",newRowIdAttr); rowAnsInputElt.attr("name",newRowNameAttr); // Update Order value var rowOrderInputElt = row.find("input[name$='[order]']"); var rowOrderIdAttr = rowOrderInputElt.attr("id"); var rowOrderValueAttr = parseFloat(rowOrderInputElt.attr("value")); var newRowOrderIdAttr = changeNumInString(rowOrderIdAttr, increaseNumbering); var newRowOrderNameAttr = changeNumInString(rowOrderInputElt.attr("name"), increaseNumbering); rowOrderInputElt.attr("id",newRowOrderIdAttr); rowOrderInputElt.attr("name",newRowOrderNameAttr); if(increaseNumbering) { newRowOrderValueAttr = rowOrderValueAttr + 1; } else { newRowOrderValueAttr = rowOrderValueAttr - 1; } rowOrderInputElt.attr("value",newRowOrderValueAttr); // Update Id value var rowIdInputElt = row.find("input[name$='[id]']"); var rowIdIdAttr = rowIdInputElt.attr("id"); var newRowIdIdAttr = changeNumInString(rowIdIdAttr, increaseNumbering); var newRowIdNameAttr = changeNumInString(rowIdInputElt.attr("name"), increaseNumbering); rowIdInputElt.attr("id",newRowIdIdAttr); rowIdInputElt.attr("name",newRowIdNameAttr); //alert(rowIdInputElt.attr("value") + " " + rowIdIdAttr +" " + newRowIdNameAttr); // Clear the field values if row is new if(creatingNewRow) { rowQstInputElt.attr("value",""); rowAnsInputElt.attr("value",""); rowIdInputElt.attr("value",""); }}
if(typeof current.data.default_extras != 'undefined' && (typeof extraId == 'undefined'))
if(typeof current.data.default_extras != 'undefined' && (typeof extraId == 'undefined' || extraId == ''))
changeTemplate: function() { // get checked var selected = $('#templateList input:radio:checked').val(); // get current template var current = templates[selected]; var i = 0; // hide unneeded blocks $('.contentBlock').each(function() { // hide if needed if(i >= current.num_blocks) $(this).hide(); // show the block and set the name else { $(this).show(); $('.blockName', this).html(current.data.names[i]); } // increment i++; }); // set HTML for the visual representation of the template $('#templateVisual').html(current.html); $('#templateVisualLarge').html(current.htmlLarge); $('#templateId').val(selected); $('#templateLabel, #tabTemplateLabel').html(current.label); // loop blocks and set extra's, to initialize the page $('.contentBlock').each(function() { var index = $(this).attr('id').replace('block-', ''); var extraId = $('#blockExtraId'+ index).val(); // no extra specified, we should grab the default if(typeof current.data.default_extras != 'undefined' && (typeof extraId == 'undefined')) { if(current.data.default_extras[index] != 'editor') { extraId = parseInt(current.data.default_extras[index]); } } // change the extra jsBackend.pages.extras.changeExtra(extraId, index); }); },
$('#templateLabel, #tabTemplateLabel').html(current.label);
changeTemplate: function() { // get checked var selected = $('#templateList input:radio:checked').val(); // get current template var current = templates[selected]; var i = 0; // hide unneeded blocks $('.contentBlock').each(function() { // hide if needed if(i >= current.num_blocks) $(this).hide(); // show the block and set the name else { $(this).show(); $('.blockName', this).html(current.data.names[i]); } // increment i++; }); // set HTML for the viual representation of the template $('#templateVisual').html(current.html); $('#templateVisualLarge').html(current.htmlLarge); $('#templateId').val(selected); // loop blocks and set extra's, to initialize the page $('.contentBlock').each(function() { var index = $(this).attr('id').replace('block-', ''); var extraId = $('#block_extra_id_'+ index).val(); jsBackend.pages.extras.changeExtra(extraId, index); }); },
$('#templateId').val(selected);
changeTemplate: function() { // get checked var selected = $('#templateList input:radio:checked').val(); // get current template var current = templates[selected]; var i = 0; // hide unneeded blocks $('.contentBlock').each(function() { // hide if needed if(i >= current.num_blocks) $(this).hide(); // show the block and set the name else { $(this).show(); $('.blockName', this).html(current.data.names[i]); } // increment i++; }); // set HTML for the viual representation of the template $('#templateVisual').html(current.html); $('#templateVisualLarge').html(current.htmlLarge); // loop blocks and set extra's, to initialize the page $('.contentBlock').each(function() { var index = $(this).attr('id').replace('block-', ''); var extraId = $('#block_extra_id_'+ index).val(); jsBackend.pages.extras.changeExtra(extraId, index); }); },
check : function (rule, obj) { if(this.locked) return false; var v = false; if(obj === -1) { if(typeof this.settings.rules[rule] != "undefined") v = this.settings.rules[rule]; } else { obj = !obj ? this.selected : this.get_node(obj); if(!obj) return; var t = this.get_type(obj); if(typeof this.settings.types[t] != "undefined" && typeof this.settings.types[t][rule] != "undefined") v = this.settings.types[t][rule]; else if(typeof this.settings.types["default"] != "undefined" && typeof this.settings.types["default"][rule] != "undefined") v = this.settings.types["default"][rule]; } if(typeof v == "function") v = v.call(null, obj, this); v = this.callback("check", [rule, obj, v, this]); return v; },
(function($){$.tree={datastores:{},plugins:{},defaults:{data:{async:false,type:"html",opts:{method:"GET",url:false}},selected:false,opened:[],languages:[],ui:{dots:true,animation:0,scroll_spd:4,theme_path:false,theme_name:"default",selected_parent_close:"select_parent",selected_delete:"select_previous"},types:{"default":{clickable:true,renameable:true,deletable:true,creatable:true,draggable:true,max_children:-1,max_depth:-1,valid_children:"all",icon:{image:false,position:false}}},rules:{multiple:false,multitree:"none",type_attr:"rel",createat:"bottom",drag_copy:"ctrl",drag_button:"left",use_max_children:true,use_max_depth:true,max_children:-1,max_depth:-1,valid_children:"all"},lang:{new_node:"New folder",loading:"Loading ..."},callback:{beforechange:function(NODE){return true},beforeopen:function(NODE){return true},beforeclose:function(NODE){return true},beforemove:function(data){return true},beforecopy:function(data){return true},beforecreate:function(data){return true},beforerename:function(data){return true},beforedelete:function(data){return true},beforedata:function(NODE){return{id:$(NODE).attr("id")||0}},ondata:function(DATA){return DATA},onparse:function(STR){return STR},onhover:function(NODE){},onselect:function(NODE){},ondeselect:function(NODE){},onchange:function(NODE){},onrename:function(data){},onmove:function(data){},oncopy:function(data){},oncreate:function(data){},ondelete:function(data){},onopen:function(NODE){},onopen_all:function(){},onclose_all:function(){},onclose:function(NODE){},error:function(TEXT){},ondblclk:function(data){this.toggle_branch(data.node);this.select_branch(data.node)},onrgtclk:function(data){},onload:function(){},oninit:function(){},onfocus:function(){},ondestroy:function(){},onsearch:function(NODES){NODES.addClass("search")},ondrop:function(data){},check:function(RULE,NODE,VALUE,TREE_OBJ){return VALUE},check_move:function(NODE,REF_NODE,TYPE,TREE_OBJ){return true}},plugins:{}},create:function(){return new tree_component()},focused:function(){return tree_component.inst[tree_component.focused]},reference:function(obj){var o=$(obj);if(!o.size())o=$("#"+obj);if(!o.size())return null;o=(o.is(".tree"))?o.attr("id"):o.parents(".tree:eq(0)").attr("id");return tree_component.inst[o]||null},rollback:function(data){for(var i in data){if(!data.hasOwnProperty(i))continue;var tmp=tree_component.inst[i];var lock=!tmp.locked;if(lock)tmp.lock(true);tmp.inp=false;tmp.container.html(data[i].html).find(".dragged").removeClass("dragged").end().find(".hover").removeClass("hover");if(data[i].selected){tmp.selected=$("#"+data[i].selected);tmp.selected_arr=[];tmp.container.find("a.clicked").each(function(){tmp.selected_arr.push(tmp.get_node(this))})}if(lock)tmp.lock(false);delete lock;delete tmp}},drop_mode:function(opts){opts=$.extend(opts,{show:false,type:"default",str:"Foreign node"});tree_component.drag_drop.foreign=true;tree_component.drag_drop.isdown=true;tree_component.drag_drop.moving=true;tree_component.drag_drop.appended=false;tree_component.drag_drop.f_type=opts.type;tree_component.drag_drop.f_data=opts;if(!opts.show){tree_component.drag_drop.drag_help=false;tree_component.drag_drop.drag_node=false}else{tree_component.drag_drop.drag_help=$("<div id='jstree-dragged' class='tree tree-default'><ul><li class='last dragged foreign'><a href='#'><ins>&nbsp;</ins>"+opts.str+"</a></li></ul></div>");tree_component.drag_drop.drag_node=tree_component.drag_drop.drag_help.find("li:eq(0)")}if($.tree.drag_start!==false)$.tree.drag_start.call(null,false)},drag_start:false,drag:false,drag_end:false};$.fn.tree=function(opts){return this.each(function(){var conf=$.extend({},opts);if(tree_component.inst&&tree_component.inst[$(this).attr('id')])tree_component.inst[$(this).attr('id')].destroy();if(conf!==false)new tree_component().init(this,conf)})};function tree_component(){return{cntr:++tree_component.cntr,settings:$.extend({},$.tree.defaults),init:function(elem,conf){var _this=this;this.container=$(elem);if(this.container.size==0)return false;tree_component.inst[this.cntr]=this;if(!this.container.attr("id"))this.container.attr("id","jstree_"+this.cntr);tree_component.inst[this.container.attr("id")]=tree_component.inst[this.cntr];tree_component.focused=this.cntr;this.settings=$.extend(true,{},this.settings,conf);if(this.settings.languages&&this.settings.languages.length){this.current_lang=this.settings.languages[0];var st=false;var id="#"+this.container.attr("id");for(var ln=0;ln<this.settings.languages.length;ln++){st=tree_component.add_css(id+" ."+this.settings.languages[ln]);if(st!==false)st.style.display=(this.settings.languages[ln]==this.current_lang)?"":"none"}}else this.current_lang=false;this.container.addClass("tree");if(this.settings.ui.theme_name!==false){if(this.settings.ui.theme_path===false){$("script").each(function(){if(this.src.toString().match(/jquery\.tree.*?js$/)){_this.settings.ui.theme_path=this.src.toString().replace(/jquery\.tree.*?js$/,"")+"themes/"+_this.settings.ui.theme_name+"/style.css";return false}})}else this.settings.ui.theme_path=this.settings.ui.theme_path.replace(/\/$/,"")+'/'+this.settings.ui.theme_name+'/style.css';if(this.settings.ui.theme_path!=""&&$.inArray(this.settings.ui.theme_path,tree_component.themes)==-1){tree_component.add_sheet({url:this.settings.ui.theme_path});tree_component.themes.push(this.settings.ui.theme_path)}this.container.addClass("tree-"+this.settings.ui.theme_name)}var type_icons="";for(var t in this.settings.types){if(!this.settings.types.hasOwnProperty(t))continue;if(!this.settings.types[t].icon)continue;if(this.settings.types[t].icon.image||this.settings.types[t].icon.position){if(t=="default")type_icons+='#'+this.container.attr("id")+' li > a ins { ';else type_icons+='#'+this.container.attr("id")+' li[rel='+t+'] > a ins { ';if(this.settings.types[t].icon.image)type_icons+=' background-image:url('+this.settings.types[t].icon.image+'); ';if(this.settings.types[t].icon.position)type_icons+=' background-position:'+this.settings.types[t].icon.position+'; ';type_icons+='} '}}if(type_icons!="")tree_component.add_sheet({str:type_icons});if(this.settings.rules.multiple)this.selected_arr=[];this.offset=false;this.hovered=false;this.locked=false;if(tree_component.drag_drop.marker===false)tree_component.drag_drop.marker=$("<div>").attr({id:"jstree-marker"}).hide().appendTo("body");this.callback("oninit",[this]);this.refresh();this.attach_events();this.focus()},refresh:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;if(obj&&!this.settings.data.async)obj=false;this.is_partial_refresh=obj?true:false;this.opened=Array();if(this.settings.opened!=false){$.each(this.settings.opened,function(i,item){if(this.replace(/^#/,"").length>0){_this.opened.push("#"+this.replace(/^#/,""))}});this.settings.opened=false}else{this.container.find("li.open").each(function(i){if(this.id){_this.opened.push("#"+this.id)}})}if(this.selected){this.settings.selected=Array();if(obj){$(obj).find("li:has(a.clicked)").each(function(){if(this.id)_this.settings.selected.push("#"+this.id)})}else{if(this.selected_arr){$.each(this.selected_arr,function(){if(this.attr("id"))_this.settings.selected.push("#"+this.attr("id"))})}else{if(this.selected.attr("id"))this.settings.selected.push("#"+this.selected.attr("id"))}}}else if(this.settings.selected!==false){var tmp=Array();if((typeof this.settings.selected).toLowerCase()=="object"){$.each(this.settings.selected,function(){if(this.replace(/^#/,"").length>0)tmp.push("#"+this.replace(/^#/,""))})}else{if(this.settings.selected.replace(/^#/,"").length>0)tmp.push("#"+this.settings.selected.replace(/^#/,""))}this.settings.selected=tmp}if(obj&&this.settings.data.async){this.opened=Array();obj=this.get_node(obj);obj.find("li.open").each(function(i){_this.opened.push("#"+this.id)});if(obj.hasClass("open"))obj.removeClass("open").addClass("closed");if(obj.hasClass("leaf"))obj.removeClass("leaf");obj.children("ul:eq(0)").html("");return this.open_branch(obj,true,function(){_this.reselect.apply(_this)})}var _this=this;var _datastore=new $.tree.datastores[this.settings.data.type]();if(this.container.children("ul").size()==0){this.container.html("<ul class='ltr' style='direction:ltr;'><li class='last'><a class='loading' href='#'><ins>&nbsp;</ins>"+(this.settings.lang.loading||"Loading ...")+"</a></li></ul>")}_datastore.load(this.callback("beforedata",[false,this]),this,this.settings.data.opts,function(data){data=_this.callback("ondata",[data,_this]);_datastore.parse(data,_this,_this.settings.data.opts,function(str){str=_this.callback("onparse",[str,_this]);_this.container.empty().append($("<ul class='ltr'>").html(str));_this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");_this.container.find("li").not(".open").not(".closed").addClass("leaf");_this.reselect()})})},reselect:function(is_callback){var _this=this;if(!is_callback)this.cl_count=0;else this.cl_count--;if(this.opened&&this.opened.length){var opn=false;for(var j=0;this.opened&&j<this.opened.length;j++){if(this.settings.data.async){var tmp=this.get_node(this.opened[j]);if(tmp.size()&&tmp.hasClass("closed")>0){opn=true;var tmp=this.opened[j].toString().replace('/','\\/');delete this.opened[j];this.open_branch(tmp,true,function(){_this.reselect.apply(_this,[true])});this.cl_count++}}else this.open_branch(this.opened[j],true)}if(this.settings.data.async&&opn)return;if(this.cl_count>0)return;delete this.opened}if(this.cl_count>0)return;this.container.css("direction","ltr").children("ul:eq(0)").addClass("ltr");if(this.settings.ui.dots==false)this.container.children("ul:eq(0)").addClass("no_dots");if(this.scrtop){this.container.scrollTop(_this.scrtop);delete this.scrtop}if(this.settings.selected!==false){$.each(this.settings.selected,function(i){if(_this.is_partial_refresh)_this.select_branch($(_this.settings.selected[i].toString().replace('/','\\/'),_this.container),(_this.settings.rules.multiple!==false));else _this.select_branch($(_this.settings.selected[i].toString().replace('/','\\/'),_this.container),(_this.settings.rules.multiple!==false&&i>0))});this.settings.selected=false}this.callback("onload",[_this])},get:function(obj,format,opts){if(!format)format=this.settings.data.type;if(!opts)opts=this.settings.data.opts;return new $.tree.datastores[format]().get(obj,this,opts)},attach_events:function(){var _this=this;this.container.bind("mousedown.jstree",function(event){if(tree_component.drag_drop.isdown){tree_component.drag_drop.move_type=false;event.preventDefault();event.stopPropagation();event.stopImmediatePropagation();return false}}).bind("mouseup.jstree",function(event){setTimeout(function(){_this.focus.apply(_this)},5)}).bind("click.jstree",function(event){return true});$("li",this.container[0]).live("click",function(event){if(event.target.tagName!="LI")return true;_this.off_height();if(event.pageY-$(event.target).offset().top>_this.li_height)return true;_this.toggle_branch.apply(_this,[event.target]);event.stopPropagation();return false});$("a",this.container[0]).live("click",function(event){if(event.which&&event.which==3)return true;if(_this.locked){event.preventDefault();event.target.blur();return _this.error("LOCKED")}_this.select_branch.apply(_this,[event.target,(event.ctrlKey||event.metaKey)||_this.settings.rules.multiple=="on"]);if(_this.inp){_this.inp.blur()}event.preventDefault();event.target.blur();return false}).live("dblclick",function(event){if(_this.locked){event.preventDefault();event.stopPropagation();event.target.blur();return _this.error("LOCKED")}_this.callback("ondblclk",[_this.get_node(event.target).get(0),_this]);event.preventDefault();event.stopPropagation();event.target.blur()}).live("contextmenu",function(event){if(_this.locked){event.target.blur();return _this.error("LOCKED")}return _this.callback("onrgtclk",[_this.get_node(event.target).get(0),_this,event])}).live("mouseover",function(event){if(_this.locked){event.preventDefault();event.stopPropagation();return _this.error("LOCKED")}if(_this.hovered!==false&&(event.target.tagName=="A"||event.target.tagName=="INS")){_this.hovered.children("a").removeClass("hover");_this.hovered=false}_this.callback("onhover",[_this.get_node(event.target).get(0),_this])}).live("mousedown",function(event){if(_this.settings.rules.drag_button=="left"&&event.which&&event.which!=1)return true;if(_this.settings.rules.drag_button=="right"&&event.which&&event.which!=3)return true;_this.focus.apply(_this);if(_this.locked)return _this.error("LOCKED");var obj=_this.get_node(event.target);if(_this.settings.rules.multiple!=false&&_this.selected_arr.length>1&&obj.children("a:eq(0)").hasClass("clicked")){var counter=0;for(var i in _this.selected_arr){if(!_this.selected_arr.hasOwnProperty(i))continue;if(_this.check("draggable",_this.selected_arr[i])){_this.selected_arr[i].addClass("dragged");tree_component.drag_drop.origin_tree=_this;counter++}}if(counter>0){if(_this.check("draggable",obj))tree_component.drag_drop.drag_node=obj;else tree_component.drag_drop.drag_node=_this.container.find("li.dragged:eq(0)");tree_component.drag_drop.isdown=true;tree_component.drag_drop.drag_help=$("<div id='jstree-dragged' class='tree "+(_this.settings.ui.theme_name!=""?" tree-"+_this.settings.ui.theme_name:"")+"' />").append("<ul class='"+_this.container.children("ul:eq(0)").get(0).className+"' />");var tmp=tree_component.drag_drop.drag_node.clone();if(_this.settings.languages.length>0)tmp.find("a").not("."+_this.current_lang).hide();tree_component.drag_drop.drag_help.children("ul:eq(0)").append(tmp);tree_component.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last").children("a").html("<ins>&nbsp;</ins>Multiple selection").end().children("ul").remove();tree_component.drag_drop.dragged=_this.container.find("li.dragged")}}else{if(_this.check("draggable",obj)){tree_component.drag_drop.drag_node=obj;tree_component.drag_drop.drag_help=$("<div id='jstree-dragged' class='tree "+(_this.settings.ui.theme_name!=""?" tree-"+_this.settings.ui.theme_name:"")+"' />").append("<ul class='"+_this.container.children("ul:eq(0)").get(0).className+"' />");var tmp=obj.clone();if(_this.settings.languages.length>0)tmp.find("a").not("."+_this.current_lang).hide();tree_component.drag_drop.drag_help.children("ul:eq(0)").append(tmp);tree_component.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last");tree_component.drag_drop.isdown=true;tree_component.drag_drop.foreign=false;tree_component.drag_drop.origin_tree=_this;obj.addClass("dragged");tree_component.drag_drop.dragged=_this.container.find("li.dragged")}}tree_component.drag_drop.init_x=event.pageX;tree_component.drag_drop.init_y=event.pageY;obj.blur();event.preventDefault();event.stopPropagation();return false})},focus:function(){if(this.locked)return false;if(tree_component.focused!=this.cntr){tree_component.focused=this.cntr;this.callback("onfocus",[this])}},off_height:function(){if(this.offset===false){this.container.css({position:"relative"});this.offset=this.container.offset();var tmp=0;tmp=parseInt($.curCSS(this.container.get(0),"paddingTop",true),10);if(tmp)this.offset.top+=tmp;tmp=parseInt($.curCSS(this.container.get(0),"borderTopWidth",true),10);if(tmp)this.offset.top+=tmp;this.container.css({position:""})}if(!this.li_height){var tmp=this.container.find("ul li.closed, ul li.leaf").eq(0);this.li_height=tmp.height();if(tmp.children("ul:eq(0)").size())this.li_height-=tmp.children("ul:eq(0)").height();if(!this.li_height)this.li_height=18}},scroll_check:function(x,y){var _this=this;var cnt=_this.container;var off=_this.container.offset();var st=cnt.scrollTop();var sl=cnt.scrollLeft();var h_cor=(cnt.get(0).scrollWidth>cnt.width())?40:20;if(y-off.top<20)cnt.scrollTop(Math.max((st-_this.settings.ui.scroll_spd),0));if(cnt.height()-(y-off.top)<h_cor)cnt.scrollTop(st+_this.settings.ui.scroll_spd);if(x-off.left<20)cnt.scrollLeft(Math.max((sl-_this.settings.ui.scroll_spd),0));if(cnt.width()-(x-off.left)<40)cnt.scrollLeft(sl+_this.settings.ui.scroll_spd);if(cnt.scrollLeft()!=sl||cnt.scrollTop()!=st){tree_component.drag_drop.move_type=false;tree_component.drag_drop.ref_node=false;tree_component.drag_drop.marker.hide()}tree_component.drag_drop.scroll_time=setTimeout(function(){_this.scroll_check(x,y)},50)},scroll_into_view:function(obj){obj=obj?this.get_node(obj):this.selected;if(!obj)return false;var off_t=obj.offset().top;var beg_t=this.container.offset().top;var end_t=beg_t+this.container.height();var h_cor=(this.container.get(0).scrollWidth>this.container.width())?40:20;if(off_t+5<beg_t)this.container.scrollTop(this.container.scrollTop()-(beg_t-off_t+5));if(off_t+h_cor>end_t)this.container.scrollTop(this.container.scrollTop()+(off_t+h_cor-end_t))},get_node:function(obj){return $(obj).closest("li")},get_type:function(obj){obj=!obj?this.selected:this.get_node(obj);if(!obj)return;var tmp=obj.attr(this.settings.rules.type_attr);return tmp||"default"},set_type:function(str,obj){obj=!obj?this.selected:this.get_node(obj);if(!obj||!str)return;obj.attr(this.settings.rules.type_attr,str)},get_text:function(obj,lang){obj=this.get_node(obj);if(!obj||obj.size()==0)return"";if(this.settings.languages&&this.settings.languages.length){lang=lang?lang:this.current_lang;obj=obj.children("a."+lang)}else obj=obj.children("a:visible");var val="";obj.contents().each(function(){if(this.nodeType==3){val=this.data;return false}});return val},check:function(rule,obj){if(this.locked)return false;var v=false;if(obj===-1){if(typeof this.settings.rules[rule]!="undefined")v=this.settings.rules[rule]}else{obj=!obj?this.selected:this.get_node(obj);if(!obj)return;var t=this.get_type(obj);if(typeof this.settings.types[t]!="undefined"&&typeof this.settings.types[t][rule]!="undefined")v=this.settings.types[t][rule];else if(typeof this.settings.types["default"]!="undefined"&&typeof this.settings.types["default"][rule]!="undefined")v=this.settings.types["default"][rule]}if(typeof v=="function")v=v.call(null,obj,this);v=this.callback("check",[rule,obj,v,this]);return v},check_move:function(nod,ref_node,how){if(this.locked)return false;if($(ref_node).closest("li.dragged").size())return false;var tree1=nod.parents(".tree:eq(0)").get(0);var tree2=ref_node===-1?this.container.get(0):ref_node.parents(".tree:eq(0)").get(0);if(tree1&&tree1!=tree2){var m=$.tree.reference(tree2.id).settings.rules.multitree;if(typeof m=="object")m=$.makeArray(m);if(m=="none"||($.isArray(m)&&$.inArray(tree1.id,m)==-1))return false}var p=(how!="inside")?this.parent(ref_node):this.get_node(ref_node);if(ref_node===-1)p=-1;nod=this.get_node(nod);if(p==false)return false;var r={max_depth:this.settings.rules.use_max_depth?this.check("max_depth",p):-1,max_children:this.settings.rules.use_max_children?this.check("max_children",p):-1,valid_children:this.check("valid_children",p)};var nod_type=(typeof nod=="string")?nod:this.get_type(nod);if(typeof r.valid_children!="undefined"&&(r.valid_children=="none"||(typeof r.valid_children=="object"&&$.inArray(nod_type,$.makeArray(r.valid_children))==-1)))return false;if(this.settings.rules.use_max_children){if(typeof r.max_children!="undefined"&&r.max_children!=-1){if(r.max_children==0)return false;var c_count=1;if(tree_component.drag_drop.moving==true&&tree_component.drag_drop.foreign==false){c_count=tree_component.drag_drop.dragged.size();c_count=c_count-p.find('> ul > li.dragged').size()}if(r.max_children<p.find('> ul > li').size()+c_count)return false}}if(this.settings.rules.use_max_depth){if(typeof r.max_depth!="undefined"&&r.max_depth===0)return this.error("MOVE: MAX-DEPTH REACHED");var mx=(r.max_depth>0)?r.max_depth:false;var i=0;var t=p;while(t!==-1){t=this.parent(t);i++;var m=this.check("max_depth",t);if(m>=0){mx=(mx===false)?(m-i):Math.min(mx,m-i)}if(mx!==false&&mx<=0)return this.error("MOVE: MAX-DEPTH REACHED")}if(mx!==false&&mx<=0)return this.error("MOVE: MAX-DEPTH REACHED");if(mx!==false){var incr=1;if(typeof nod!="string"){var t=nod;while(t.size()>0){if(mx-incr<0)return this.error("MOVE: MAX-DEPTH REACHED");t=t.children("ul").children("li");incr++}}}}if(this.callback("check_move",[nod,ref_node,how,this])==false)return false;return true},hover_branch:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;var obj=_this.get_node(obj);if(!obj.size())return this.error("HOVER: NOT A VALID NODE");if(!_this.check("clickable",obj))return this.error("SELECT: NODE NOT SELECTABLE");if(this.hovered)this.hovered.children("A").removeClass("hover");this.hovered=obj;this.hovered.children("a").addClass("hover");this.scroll_into_view(this.hovered)},select_branch:function(obj,multiple){if(this.locked)return this.error("LOCKED");if(!obj&&this.hovered!==false)obj=this.hovered;var _this=this;obj=_this.get_node(obj);if(!obj.size())return this.error("SELECT: NOT A VALID NODE");obj.children("a").removeClass("hover");if(!_this.check("clickable",obj))return this.error("SELECT: NODE NOT SELECTABLE");if(_this.callback("beforechange",[obj.get(0),_this])===false)return this.error("SELECT: STOPPED BY USER");if(this.settings.rules.multiple!=false&&multiple&&obj.children("a.clicked").size()>0){return this.deselect_branch(obj)}if(this.settings.rules.multiple!=false&&multiple){this.selected_arr.push(obj)}if(this.settings.rules.multiple!=false&&!multiple){for(var i in this.selected_arr){if(!this.selected_arr.hasOwnProperty(i))continue;this.selected_arr[i].children("A").removeClass("clicked");this.callback("ondeselect",[this.selected_arr[i].get(0),_this])}this.selected_arr=[];this.selected_arr.push(obj);if(this.selected&&this.selected.children("A").hasClass("clicked")){this.selected.children("A").removeClass("clicked");this.callback("ondeselect",[this.selected.get(0),_this])}}if(!this.settings.rules.multiple){if(this.selected){this.selected.children("A").removeClass("clicked");this.callback("ondeselect",[this.selected.get(0),_this])}}this.selected=obj;if(this.hovered!==false){this.hovered.children("A").removeClass("hover");this.hovered=obj}this.selected.children("a").addClass("clicked").end().parents("li.closed").each(function(){_this.open_branch(this,true)});this.scroll_into_view(this.selected);this.callback("onselect",[this.selected.get(0),_this]);this.callback("onchange",[this.selected.get(0),_this])},deselect_branch:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;var obj=this.get_node(obj);if(obj.children("a.clicked").size()==0)return this.error("DESELECT: NODE NOT SELECTED");obj.children("a").removeClass("clicked");this.callback("ondeselect",[obj.get(0),_this]);if(this.settings.rules.multiple!=false&&this.selected_arr.length>1){this.selected_arr=[];this.container.find("a.clicked").filter(":first-child").parent().each(function(){_this.selected_arr.push($(this))});if(obj.get(0)==this.selected.get(0)){this.selected=this.selected_arr[0]}}else{if(this.settings.rules.multiple!=false)this.selected_arr=[];this.selected=false}this.callback("onchange",[obj.get(0),_this])},toggle_branch:function(obj){if(this.locked)return this.error("LOCKED");var obj=this.get_node(obj);if(obj.hasClass("closed"))return this.open_branch(obj);if(obj.hasClass("open"))return this.close_branch(obj)},open_branch:function(obj,disable_animation,callback){var _this=this;if(this.locked)return this.error("LOCKED");var obj=this.get_node(obj);if(!obj.size())return this.error("OPEN: NO SUCH NODE");if(obj.hasClass("leaf"))return this.error("OPEN: OPENING LEAF NODE");if(this.settings.data.async&&obj.find("li").size()==0){obj.children("a").addClass("loading");this._load_branch(obj,function(){_this.open_branch(obj,disable_animation,callback)});return}obj.children("a").removeClass("loading");if(this.callback("beforeopen",[obj.get(0),this])===false)return this.error("OPEN: STOPPED BY USER");if(parseInt(this.settings.ui.animation)>0&&!disable_animation){obj.children("ul:eq(0)").css("display","none");obj.removeClass("closed").addClass("open");obj.children("ul:eq(0)").slideDown(parseInt(this.settings.ui.animation),function(){$(this).css("display","");if(callback)callback.call()})}else{obj.removeClass("closed").addClass("open");if(callback)callback.call()}this.callback("onopen",[obj.get(0),this]);return true},close_branch:function(obj,disable_animation){if(this.locked)return this.error("LOCKED");var _this=this;var obj=this.get_node(obj);if(!obj.size())return this.error("CLOSE: NO SUCH NODE");if(_this.callback("beforeclose",[obj.get(0),_this])===false)return this.error("CLOSE: STOPPED BY USER");if(parseInt(this.settings.ui.animation)>0&&!disable_animation&&obj.children("ul:eq(0)").size()==1){obj.children("ul:eq(0)").slideUp(parseInt(this.settings.ui.animation),function(){if(obj.hasClass("open"))obj.removeClass("open").addClass("closed");$(this).css("display","");_this.callback("onclose",[obj.get(0),_this])})}else{if(obj.hasClass("open"))obj.removeClass("open").addClass("closed");this.callback("onclose",[obj.get(0),this])}if(this.selected&&this.settings.ui.selected_parent_close!==false&&obj.children("ul:eq(0)").find("a.clicked").size()>0){obj.find("li:has(a.clicked)").each(function(){_this.deselect_branch(this)});if(this.settings.ui.selected_parent_close=="select_parent"&&obj.children("a.clicked").size()==0)this.select_branch(obj,(this.settings.rules.multiple!=false&&this.selected_arr.length>0))}},open_all:function(obj,callback){if(this.locked)return this.error("LOCKED");var _this=this;obj=obj?this.get_node(obj):this.container;var s=obj.find("li.closed").size();if(!callback)this.cl_count=0;else this.cl_count--;if(s>0){this.cl_count+=s;obj.find("li.closed").each(function(){var __this=this;_this.open_branch.apply(_this,[this,true,function(){_this.open_all.apply(_this,[__this,true])}])})}else if(this.cl_count==0)this.callback("onopen_all",[this])},close_all:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;obj=obj?this.get_node(obj):this.container;obj.find("li.open").each(function(){_this.close_branch(this,true)});this.callback("onclose_all",[this])},set_lang:function(i){if(!$.isArray(this.settings.languages)||this.settings.languages.length==0)return false;if(this.locked)return this.error("LOCKED");if(!$.inArray(i,this.settings.languages)&&typeof this.settings.languages[i]!="undefined")i=this.settings.languages[i];if(typeof i=="undefined")return false;if(i==this.current_lang)return true;var st=false;var id="#"+this.container.attr("id");st=tree_component.get_css(id+" ."+this.current_lang);if(st!==false)st.style.display="none";st=tree_component.get_css(id+" ."+i);if(st!==false)st.style.display="";this.current_lang=i;return true},get_lang:function(){if(!$.isArray(this.settings.languages)||this.settings.languages.length==0)return false;return this.current_lang},_load_branch:function(obj,callback){var _this=this;var obj=this.get_node(obj);if(!obj.size())return this.error("LOAD: NO SUCH NODE");if(this.settings.data.async){var _datastore=new $.tree.datastores[this.settings.data.type]();_datastore.load(this.callback("beforedata",[obj,this]),this,this.settings.data.opts,function(data){data=_this.callback("ondata",[data,_this]);if(!data||data.length==0){obj.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove();if(callback)callback.call();return}_datastore.parse(data,_this,_this.settings.data.opts,function(str){str=_this.callback("onparse",[str,_this]);obj.children("ul").remove();obj.append($("<ul>").html(str));obj.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");obj.find("li").not(".open").not(".closed").addClass("leaf");if(callback)callback.call()})})}},_create:function(obj,ref_node,position,supress_callback){if(ref_node!=-1)ref_node=this.get_node(ref_node);if(typeof position=="undefined")position="inside";if(ref_node!=-1&&position!="after"&&position!="before"&&ref_node.hasClass("closed")&&this.settings.data.async&&ref_node.children("ul").size()==0){var _this=this;return this._load_branch(ref_node,function(){_this._create.apply(_this,[obj,ref_node,position,supress_callback])})}switch(position){case"before":position=ref_node.parent().children().index(ref_node);ref_node=this.parent(ref_node);break;case"after":position=ref_node.parent().children().index(ref_node)+1;ref_node=this.parent(ref_node);break;case"inside":position=(this.settings.rules.createat=="top")?0:this.children(ref_node).size();break;default:break}var ref_dom=(ref_node==-1)?this.container:ref_node;var $ul=false;if(ref_dom.children("ul").size()==0){if(ref_node!=-1&&!ref_node.hasClass("open closed"))ref_node.removeClass("leaf").addClass("closed");$ul=$("<ul>");ref_dom.append($ul)}else{$ul=ref_dom.children("ul:eq(0)")}if(obj instanceof jQuery){$li=obj}else{obj=this.callback("ondata",[obj,this]);var obj_s=$.tree.datastores.json().parse(obj,this);obj_s=this.callback("onparse",[obj_s,this]);var $li=$(obj_s)}if($li.children("ul").size()){if(!$li.is(".open")){$li.addClass("closed")}}else{$li.addClass("leaf")}$li.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");$li.find("li").not(".open").not(".closed").addClass("leaf");var $ref_li=$ul.children("li:nth-child("+(position+1)+")");if($ref_li.size()){$ref_li.before($li)}else{$ul.append($li)}$ul.children(".last").removeClass("last").end().children("li:last-child").addClass("last");if(!supress_callback){this.callback("oncreate",[{'node':$li.get(0),'parent':ref_node==-1?-1:ref_node.get(0),'position':position,'is_ui':false}])}return $li},create:function(obj,ref_node,position){if(this.locked)return this.error("LOCKED");if(ref_node!=-1)ref_node=ref_node?this.get_node(ref_node):this.selected;if(ref_node!=-1&&(!ref_node||!ref_node.size()))return this.error("CREATE: NO NODE SELECTED");if(typeof position=="undefined")position="inside";if(ref_node!=-1&&position!="after"&&position!="before"&&ref_node.hasClass("closed")){if(this.settings.data.async&&ref_node.children("ul").size()==0){var _this=this;return this.open_branch(ref_node,true,function(){_this.create.apply(_this,[obj,ref_node,position])})}else{this.open_branch(ref_node,true)}}switch(position){case"before":position=ref_node.parent().children().index(ref_node);ref_node=this.parent(ref_node);break;case"after":position=ref_node.parent().children().index(ref_node)+1;ref_node=this.parent(ref_node);break;case"inside":position=(this.settings.rules.createat=="top")?0:this.children(ref_node).size();break;default:break}if(!this.check("creatable",ref_node))return this.error("CREATE: CANNOT CREATE IN NODE");var torename=false;if(!obj)obj={};else obj=$.extend(true,{},obj);if(!obj.attributes)obj.attributes={};if(!obj.attributes[this.settings.rules.type_attr])obj.attributes[this.settings.rules.type_attr]=this.get_type(ref_node)||"default";if(this.settings.languages.length){if(!obj.data){obj.data={};torename=true}for(var i=0;i<this.settings.languages.length;i++){if(!obj.data[this.settings.languages[i]])obj.data[this.settings.languages[i]]=((typeof this.settings.lang.new_node).toLowerCase()!="string"&&this.settings.lang.new_node[i])?this.settings.lang.new_node[i]:this.settings.lang.new_node}}else{if(!obj.data){obj.data=this.settings.lang.new_node;torename=true}}obj=this.callback("ondata",[obj,this]);var obj_s=$.tree.datastores.json().parse(obj,this);obj_s=this.callback("onparse",[obj_s,this]);var $li=$(obj_s);var r={max_depth:this.settings.rules.use_max_depth?this.check("max_depth",ref_node):-1,max_children:this.settings.rules.use_max_children?this.check("max_children",ref_node):-1,valid_children:this.check("valid_children",ref_node)};if(this.settings.rules.use_max_children){if(typeof r.max_children!="undefined"&&r.max_children!=-1&&r.max_children>=this.children(ref_node).size())return this.error("CREATE: MAX_CHILDREN REACHED")}if(this.settings.rules.use_max_depth){if(typeof r.max_depth!="undefined"&&r.max_depth===0)return this.error("CREATE: MAX-DEPTH REACHED");var mx=(r.max_depth>0)?r.max_depth:false;var i=0;var t=ref_node;while(t!==-1){t=this.parent(t);i++;var m=this.check("max_depth",t);if(m>=0){mx=(mx===false)?(m-i):Math.min(mx,m-i)}if(mx!==false&&mx<=0)return this.error("CREATE: MAX-DEPTH REACHED")}if(mx!==false&&mx<=0)return this.error("CREATE: MAX-DEPTH REACHED");if(mx!==false){var incr=1;var t=$li;while(t.size()>0){if(mx-incr<0)return this.error("CREATE: MAX-DEPTH REACHED");t=t.children("ul").children("li");incr++}}}if(!this.callback("beforecreate",[{'node':$li.get(0),'parent':ref_node==-1?-1:ref_node.get(0),'position':position}]))return this.error("CREATE: STOPPED");var rb={};rb[this.container.attr("id")]=this.get_rollback();$li=this._create($li,ref_node,position,true);this.select_branch($li.children("a:eq(0)"));this.rename(false,true,rb);return $li},_rename:function(obj,new_name,lang,supress_callback){obj=this.get_node(obj);if(!obj||!obj.size())return false;if(lang)obj=obj.find("a."+lang);else if(this.current_lang)obj=obj.find("a."+this.current_lang);else obj=obj.find("a:first");var icn=obj.children("ins").clone();obj.text(new_name).prepend(icn);if(!supress_callback){this.callback("onrename",[{'node':this.get_node(obj).get(0),'new_name':new_name,'lang':lang?lang:this.get_lang(),'is_ui':false}])}},rename:function(obj,is_create,create_rb){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.selected;var _this=this;if(!obj||!obj.size())return this.error("RENAME: NO NODE SELECTED");if(!this.check("renameable",obj))return this.error("RENAME: NODE NOT RENAMABLE");if(!this.callback("beforerename",[{node:obj.get(0),lang:_this.current_lang}]))return this.error("RENAME: STOPPED BY USER");obj.parents("li.closed").each(function(){_this.open_branch(this)});var rb={};rb[this.container.attr("id")]=this.get_rollback();var a=obj.children("a:visible");var last_value="";a.contents().each(function(){if(this.nodeType==3){last_value=this.data;return false}});_this.inp=$("<input type='text' autocomplete='off' />");_this.inp.val(last_value.replace(/&amp;/g,"&").replace(/&gt;/g,">").replace(/&lt;/g,"<")).bind("mousedown",function(event){event.stopPropagation()}).bind("mouseup",function(event){event.stopPropagation()}).bind("click",function(event){event.stopPropagation()}).bind("keyup",function(event){var key=event.keyCode||event.which;if(key==27){this.value=last_value;this.blur();return}if(key==13){this.blur();return}});_this.inp.blur(function(event){if(this.value=="")this.value=last_value;_this._rename(obj,this.value,false,true);a.get(0).style.display="";a.prevAll("span").remove();_this.inp=false;if(is_create){var par=_this.parent(a);_this.callback("oncreate",[{'node':_this.get_node(a).get(0),'parent':par==-1?-1:par.get(0),'new_name':this.value,'lang':_this.get_lang(),'is_ui':true,'rollback':create_rb}])}else{_this.callback("onrename",[{'node':_this.get_node(obj).get(0),'new_name':this.value,'lang':_this.get_lang(),'is_ui':true,'last_name':last_value,'rollback':rb}])}});var spn=$("<span />").addClass(obj.attr("class")).append(a.children("ins").clone()).append(_this.inp);a.get(0).style.display="none";obj.prepend(spn);_this.inp.get(0).focus();_this.inp.get(0).select()},_remove:function(obj,supress_callback){obj=this.get_node(obj);if(!obj.size())return false;var _this=this;var $parent=obj.parent();var rebuild_selected_arr=obj.find("a.clicked").size()?true:false;var reset_selected=(obj.get(0)==this.selected||obj.find("li").index(this.selected)!=-1)?true:false;obj=obj.remove();$parent.children("li:last").addClass("last");if($parent.children("li").size()==0){$li=$parent.parents("li:eq(0)");$li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove()}if(rebuild_selected_arr){this.selected_arr=[];this.container.find("a.clicked").filter(":first-child").parent().each(function(){_this.selected_arr.push($(this))})}if(reset_selected){this.selected=this.selected_arr[0]||false}$parent=this.get_node($parent);if(!supress_callback){this.callback("ondelete",[{'node':objs[i].get(0),'parent':$parent==-1?$parent:$parent.get(0),'is_ui':false}])}return obj},remove:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;var rb={};rb[this.container.attr("id")]=this.get_rollback();var objs=[];if(obj)objs.push(this.get_node(obj));else{if(!this.selected)return this.error("DELETE: NO NODE SELECTED");if(this.selected_arr)objs=$.makeArray(this.selected_arr);else objs.push(this.selected);var to_select=this.settings.ui.selected_delete=="select_previous"?this.prev(this.selected):false}for(var i=0;i<objs.length;i++){if(!this.check("deletable",objs[i])){this.error("DELETE: NODE NOT DELETABLE");continue}if(!this.callback("beforedelete",[{node:objs[i]}])){this.error("DELETE: STOPPED BY USER");continue}var $parent=_this.parent(objs[i]);var tmp=this._remove(objs[i],true);this.callback("ondelete",[{'node':tmp.get(0),'parent':$parent==-1?$parent:$parent.get(0),'is_ui':true,'rollback':rb}])}if(to_select)this.select_branch(to_select)},_move:function(obj,ref_node,position,is_copy,supress_callback){obj=this.get_node(obj);if(ref_node!=-1)ref_node=this.get_node(ref_node);if(typeof position=="undefined")position="inside";if(ref_node!=-1&&position!="after"&&position!="before"&&ref_node.hasClass("closed")&&this.settings.data.async&&ref_node.children("ul").size()==0){var _this=this;return this._load_branch(ref_node,function(){_this._move.apply(_this,[obj,ref_node,position,is_copy,supress_callback])})}switch(position){case"before":position=ref_node.parent().children().index(ref_node);ref_node=this.parent(ref_node);break;case"after":position=ref_node.parent().children().index(ref_node)+1;ref_node=this.parent(ref_node);break;case"inside":position=(this.settings.rules.createat=="top")?0:this.children(ref_node).size();break;default:break}var new_parent=(ref_node==-1)?this.container:ref_node;var old_parent=this.parent(obj);var _obj=obj;if(is_copy){_obj=obj.clone();_obj.each(function(i){this.id=this.id+"_copy";$(this).find("li").each(function(){this.id=this.id+"_copy"});$(this).removeClass("dragged").find("a.clicked").removeClass("clicked").end().find("li.dragged").removeClass("dragged")})}var tree_1=$.tree.reference(obj);var tree_2=ref_node==-1?this:$.tree.reference(ref_node);if(tree_1.cntr!=tree_2.cntr){var res=[];if(tree_1.settings.languages.length&&tree_2.settings.languages.length){res=jQuery.map(tree_2.settings.languages,function(n,i){return('.'+n.toUpperCase())});_obj.find("a").not(res.join(",")).remove();if(!obj.find("a:eq(0)").size())return this.error("MOVE: NO COMMON LANGUAGES")}else if(tree_1.settings.languages.length){var t1cl=tree_1.get_lang();_obj.find("a").not("."+t1cl).remove();_obj.find("a").removeClass(t1cl)}else if(tree_2.settings.languages.length){var t2cl=tree_2.get_lang();_obj.find("a").addClass(t2cl)}_obj.find("a.clicked").removeClass("clicked")}var $ul=false;if(new_parent.children("ul").size()==0){if(ref_node!=-1&&!new_parent.hasClass("open closed"))new_parent.removeClass("leaf").addClass("closed");$ul=$("<ul>");new_parent.append($ul)}else{$ul=new_parent.children("ul:eq(0)")}var $ref_li=$ul.children("li:nth-child("+(position+1)+")");if($ref_li.size()){$ref_li.before(_obj.removeClass("last"))}else{$ul.append(_obj.removeClass("last"))}$ul.children(".last").removeClass("last").end().children("li:last-child").addClass("last");if(old_parent===-1)old_parent=tree_1.container;old_parent.children("ul").children(".last").removeClass("last").end().children("li:last-child").addClass("last");if(!supress_callback){this.callback((is_copy?"onmove":"oncopy"),[{'node':_obj.get(0),'parent':ref_node==-1?-1:ref_node.get(0),'position':position,'is_ui':false,'old_parent':old_parent.get(0),'origin_tree':tree_1,'receiving_tree':tree_2,}])}return _obj},moved:function(obj,ref_node,position,is_copy,rb){if(ref_node!=-1)ref_node=this.get_node(ref_node);if(typeof position=="undefined")position="inside";if(ref_node!=-1&&position!="after"&&position!="before"&&ref_node.hasClass("closed")&&this.settings.data.async&&ref_node.children("ul").size()==0){var _this=this;return this.open_branch(ref_node,true,function(){_this.moved.apply(_this,[obj,ref_node,position,is_copy,rb])})}if($(obj).size()>1){var _this=this;var tmp=this.moved(obj.eq(0),ref_node,position,is_copy,rb);obj.each(function(i){if(i==0)return;if(tmp){tmp=_this.moved(this,tmp,"after",is_copy,rb)}});return obj}if(!this.check_move(obj,ref_node,position))return false;obj=this.get_node(obj);switch(position){case"before":position=ref_node.parent().children().index(ref_node);ref_node=this.parent(ref_node);break;case"after":position=ref_node.parent().children().index(ref_node)+1;ref_node=this.parent(ref_node);break;case"inside":position=(this.settings.rules.createat=="top")?0:this.children(ref_node).size();break;default:break}var new_parent=(ref_node==-1)?this.container:ref_node;var old_parent=this.parent(obj);var tree_1=$.tree.reference(obj);var tree_2=ref_node==-1?this:$.tree.reference(ref_node);if(!this.callback((is_copy?"beforecopy":"beforemove"),[{'node':obj.get(0),'parent':ref_node==-1?-1:ref_node.get(0),'position':position,'is_ui':false,'old_parent':old_parent==-1?-1:old_parent.get(0),'origin_tree':tree_1,'receiving_tree':tree_2}]))return false;if(!rb){var rb={};rb[tree_1.container.attr("id")]=tree_1.get_rollback();rb[tree_2.container.attr("id")]=tree_2.get_rollback()}var _obj=this._move(obj,ref_node,position,is_copy,true);if(_obj) { var _this = this; _obj.parents(".closed").each(function () { _this.open_branch(this); }); }this.callback((is_copy?"oncopy":"onmove"),[{'node':_obj.get(0),'parent':ref_node==-1?-1:ref_node.get(0),'position':position,'is_ui':true,'old_parent':old_parent==-1?-1:old_parent.get(0),'origin_tree':tree_1,'receiving_tree':tree_2}]);return _obj},next:function(obj,strict){obj=this.get_node(obj);if(!obj.size())return false;if(strict)return(obj.nextAll("li").size()>0)?obj.nextAll("li:eq(0)"):false;if(obj.hasClass("open"))return obj.find("li:eq(0)");else if(obj.nextAll("li").size()>0)return obj.nextAll("li:eq(0)");else return obj.parents("li").next("li").eq(0)},prev:function(obj,strict){obj=this.get_node(obj);if(!obj.size())return false;if(strict)return(obj.prevAll("li").size()>0)?obj.prevAll("li:eq(0)"):false;if(obj.prev("li").size()){var obj=obj.prev("li").eq(0);while(obj.hasClass("open"))obj=obj.children("ul:eq(0)").children("li:last");return obj}else return obj.parents("li:eq(0)").size()?obj.parents("li:eq(0)"):false},parent:function(obj){obj=this.get_node(obj);if(!obj.size())return false;return obj.parents("li:eq(0)").size()?obj.parents("li:eq(0)"):-1},children:function(obj){if(obj===-1)return this.container.children("ul:eq(0)").children("li");obj=this.get_node(obj);if(!obj.size())return false;return obj.children("ul:eq(0)").children("li")},toggle_dots:function(){if(this.settings.ui.dots){this.settings.ui.dots=false;this.container.children("ul:eq(0)").addClass("no_dots")}else{this.settings.ui.dots=true;this.container.children("ul:eq(0)").removeClass("no_dots")}},callback:function(cb,args){var p=false;var r=null;for(var i in this.settings.plugins){if(typeof $.tree.plugins[i]!="object")continue;p=$.tree.plugins[i];if(p.callbacks&&typeof p.callbacks[cb]=="function")r=p.callbacks[cb].apply(this,args);if(typeof r!=="undefined"&&r!==null){if(cb=="ondata"||cb=="onparse")args[0]=r;else return r}}p=this.settings.callback[cb];if(typeof p=="function")return p.apply(this,args)},get_rollback:function(){var rb={};rb.html=this.container.html();rb.selected=this.selected?this.selected.attr("id"):false;return rb},error:function(code){this.callback("error",[code,this]);return false},lock:function(state){this.locked=state;if(this.locked)this.container.children("ul:eq(0)").addClass("locked");else this.container.children("ul:eq(0)").removeClass("locked")},cut:function(obj){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.container.find("a.clicked").filter(":first-child").parent();if(!obj||!obj.size())return this.error("CUT: NO NODE SELECTED");tree_component.cut_copy.copy_nodes=false;tree_component.cut_copy.cut_nodes=obj},copy:function(obj){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.container.find("a.clicked").filter(":first-child").parent();if(!obj||!obj.size())return this.error("COPY: NO NODE SELECTED");tree_component.cut_copy.copy_nodes=obj;tree_component.cut_copy.cut_nodes=false},paste:function(obj,position){if(this.locked)return this.error("LOCKED");var root=false;if(obj==-1){root=true;obj=this.container}else obj=obj?this.get_node(obj):this.selected;if(!root&&(!obj||!obj.size()))return this.error("PASTE: NO NODE SELECTED");if(!tree_component.cut_copy.copy_nodes&&!tree_component.cut_copy.cut_nodes)return this.error("PASTE: NOTHING TO DO");var _this=this;var pos=position;if(position=="before"){position=obj.parent().children().index(obj);obj=obj.parents("li:eq(0)")}else if(position=="after"){position=obj.parent().children().index(obj)+1;obj=obj.parents("li:eq(0)")}else if((typeof position).toLowerCase()=="undefined"||position=="inside"){position=(this.settings.rules.createat=="top")?0:obj.children("ul:eq(0)").children("li").size()}if(!root&&obj.size()==0){root=true;obj=this.container}if(tree_component.cut_copy.copy_nodes&&tree_component.cut_copy.copy_nodes.size()){var ok=true;if(!root&&!this.check_move(tree_component.cut_copy.copy_nodes,obj.children("a:eq(0)"),"inside"))return false;if(obj.children("ul").size()==0||(root==true&&obj.children("ul").children("li").size()==0)){if(!root)var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("a:eq(0)"),"inside",true);else var a=this.moved(tree_component.cut_copy.copy_nodes,this.container.children("ul:eq(0)"),"inside",true)}else if(pos=="before"&&obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",true);else if(pos=="after"&&obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").size())var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").children("a:eq(0)"),"after",true);else if(obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",true);else var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",true);tree_component.cut_copy.copy_nodes=false}if(tree_component.cut_copy.cut_nodes&&tree_component.cut_copy.cut_nodes.size()){var ok=true;obj.parents().andSelf().each(function(){if(tree_component.cut_copy.cut_nodes.index(this)!=-1){ok=false;return false}});if(!ok)return this.error("Invalid paste");if(!root&&!this.check_move(tree_component.cut_copy.cut_nodes,obj.children("a:eq(0)"),"inside"))return false;if(obj.children("ul").size()==0||(root==true&&obj.children("ul").children("li").size()==0)){if(!root)var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("a:eq(0)"),"inside");else var a=this.moved(tree_component.cut_copy.cut_nodes,this.container.children("ul:eq(0)"),"inside")}else if(pos=="before"&&obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before");else if(pos=="after"&&obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").size())var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").children("a:eq(0)"),"after");else if(obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before");else var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after");tree_component.cut_copy.cut_nodes=false}},search:function(str,func){var _this=this;if(!str||(this.srch&&str!=this.srch)){this.srch="";this.srch_opn=false;this.container.find("a.search").removeClass("search")}this.srch=str;if(!str)return;if(!func)func="contains";if(this.settings.data.async){if(!this.srch_opn){var dd=$.extend({"search":str},this.callback("beforedata",[false,this]));$.ajax({type:this.settings.data.opts.method,url:this.settings.data.opts.url,data:dd,dataType:"text",success:function(data){_this.srch_opn=$.unique(data.split(","));_this.search.apply(_this,[str,func])}})}else if(this.srch_opn.length){if(this.srch_opn&&this.srch_opn.length){var opn=false;for(var j=0;j<this.srch_opn.length;j++){if(this.get_node("#"+this.srch_opn[j]).size()>0){opn=true;var tmp="#"+this.srch_opn[j];delete this.srch_opn[j];this.open_branch(tmp,true,function(){_this.search.apply(_this,[str,func])})}}if(!opn){this.srch_opn=[];_this.search.apply(_this,[str,func])}}}else{this.srch_opn=false;var selector="a";if(this.settings.languages.length)selector+="."+this.current_lang;this.callback("onsearch",[this.container.find(selector+":"+func+"('"+str+"')"),this])}}else{var selector="a";if(this.settings.languages.length)selector+="."+this.current_lang;var nn=this.container.find(selector+":"+func+"('"+str+"')");nn.parents("li.closed").each(function(){_this.open_branch(this,true)});this.callback("onsearch",[nn,this])}},add_sheet:tree_component.add_sheet,destroy:function(){this.callback("ondestroy",[this]);this.container.unbind(".jstree");$("#"+this.container.attr("id")).die("click.jstree").die("dblclick.jstree").die("mouseover.jstree").die("mouseout.jstree").die("mousedown.jstree");this.container.removeClass("tree ui-widget ui-widget-content tree-default tree-"+this.settings.ui.theme_name).children("ul").removeClass("no_dots ltr locked").find("li").removeClass("leaf").removeClass("open").removeClass("closed").removeClass("last").children("a").removeClass("clicked hover search");if(this.cntr==tree_component.focused){for(var i in tree_component.inst){if(i!=this.cntr&&i!=this.container.attr("id")){tree_component.inst[i].focus();break}}}tree_component.inst[this.cntr]=false;tree_component.inst[this.container.attr("id")]=false;delete tree_component.inst[this.cntr];delete tree_component.inst[this.container.attr("id")];tree_component.cntr--}}};tree_component.cntr=0;tree_component.inst={};tree_component.themes=[];tree_component.drag_drop={isdown:false,drag_node:false,drag_help:false,dragged:false,init_x:false,init_y:false,moving:false,origin_tree:false,marker:false,move_type:false,ref_node:false,appended:false,foreign:false,droppable:[],open_time:false,scroll_time:false};tree_component.mouseup=function(event){var tmp=tree_component.drag_drop;if(tmp.open_time)clearTimeout(tmp.open_time);if(tmp.scroll_time)clearTimeout(tmp.scroll_time);if(tmp.moving&&$.tree.drag_end!==false)$.tree.drag_end.call(null,event,tmp);if(tmp.foreign===false&&tmp.drag_node&&tmp.drag_node.size()){tmp.drag_help.remove();if(tmp.move_type){var tree1=tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")];if(tree1)tree1.moved(tmp.dragged,tmp.ref_node,tmp.move_type,(tmp.origin_tree.settings.rules.drag_copy=="on"||(tmp.origin_tree.settings.rules.drag_copy=="ctrl"&&(event.ctrlKey||event.metaKey))))}tmp.move_type=false;tmp.ref_node=false}if(tmp.foreign!==false){if(tmp.drag_help)tmp.drag_help.remove();if(tmp.move_type){var tree1=tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")];if(tree1)tree1.callback("ondrop",[tmp.f_data,tree1.get_node(tmp.ref_node).get(0),tmp.move_type,tree1])}tmp.foreign=false;tmp.move_type=false;tmp.ref_node=false}if(tree_component.drag_drop.marker)tree_component.drag_drop.marker.hide();if(tmp.dragged&&tmp.dragged.size())tmp.dragged.removeClass("dragged");tmp.dragged=false;tmp.drag_help=false;tmp.drag_node=false;tmp.f_type=false;tmp.f_data=false;tmp.init_x=false;tmp.init_y=false;tmp.moving=false;tmp.appended=false;tmp.origin_tree=false;if(tmp.isdown){tmp.isdown=false;event.preventDefault();event.stopPropagation();return false}};tree_component.mousemove=function(event){var tmp=tree_component.drag_drop;var is_start=false;if(tmp.isdown){if(!tmp.moving&&Math.abs(tmp.init_x-event.pageX)<5&&Math.abs(tmp.init_y-event.pageY)<5){event.preventDefault();event.stopPropagation();return false}else{if(!tmp.moving){tree_component.drag_drop.moving=true;is_start=true}}if(tmp.open_time)clearTimeout(tmp.open_time);if(tmp.drag_help!==false){if(!tmp.appended){if(tmp.foreign!==false)tmp.origin_tree=$.tree.focused();$("body").append(tmp.drag_help);tmp.w=tmp.drag_help.width();tmp.appended=true}tmp.drag_help.css({"left":(event.pageX+5),"top":(event.pageY+15)})}if(is_start&&$.tree.drag_start!==false)$.tree.drag_start.call(null,event,tmp);if($.tree.drag!==false)$.tree.drag.call(null,event,tmp);if(event.target.tagName=="DIV"&&event.target.id=="jstree-marker")return false;var et=$(event.target);if(et.is("ins"))et=et.parent();var cnt=et.is(".tree")?et:et.parents(".tree:eq(0)");if(cnt.size()==0||!tree_component.inst[cnt.attr("id")]){if(tmp.scroll_time)clearTimeout(tmp.scroll_time);if(tmp.drag_help!==false)tmp.drag_help.find("li:eq(0) ins").addClass("forbidden");tmp.move_type=false;tmp.ref_node=false;tree_component.drag_drop.marker.hide();return false}var tree2=tree_component.inst[cnt.attr("id")];tree2.off_height();if(tmp.scroll_time)clearTimeout(tmp.scroll_time);tmp.scroll_time=setTimeout(function(){tree2.scroll_check(event.pageX,event.pageY)},50);var mov=false;var st=cnt.scrollTop();if(event.target.tagName=="A"||event.target.tagName=="INS"){if(et.is("#jstree-dragged"))return false;if(tree2.get_node(event.target).hasClass("closed")){tmp.open_time=setTimeout(function(){tree2.open_branch(et)},500)}var et_off=et.offset();var goTo={x:(et_off.left-1),y:(event.pageY-et_off.top)};var arr=[];if(goTo.y<tree2.li_height/3+1)arr=["before","inside","after"];else if(goTo.y>tree2.li_height*2/3-1)arr=["after","inside","before"];else{if(goTo.y<tree2.li_height/2)arr=["inside","before","after"];else arr=["inside","after","before"]}var ok=false;var nn=(tmp.foreign==false)?tmp.origin_tree.container.find("li.dragged"):tmp.f_type;$.each(arr,function(i,val){if(tree2.check_move(nn,et,val)){mov=val;ok=true;return false}});if(ok){switch(mov){case"before":goTo.y=et_off.top-2;tree_component.drag_drop.marker.attr("class","marker");break;case"after":goTo.y=et_off.top-2+tree2.li_height;tree_component.drag_drop.marker.attr("class","marker");break;case"inside":goTo.x-=2;goTo.y=et_off.top-2+tree2.li_height/2;tree_component.drag_drop.marker.attr("class","marker_plus");break}tmp.move_type=mov;tmp.ref_node=$(event.target);if(tmp.drag_help!==false)tmp.drag_help.find(".forbidden").removeClass("forbidden");tree_component.drag_drop.marker.css({"left":goTo.x,"top":goTo.y}).show()}}if((et.is(".tree")||et.is("ul"))&&et.find("li:eq(0)").size()==0){var et_off=et.offset();tmp.move_type="inside";tmp.ref_node=cnt.children("ul:eq(0)");if(tmp.drag_help!==false)tmp.drag_help.find(".forbidden").removeClass("forbidden");tree_component.drag_drop.marker.attr("class","marker_plus");tree_component.drag_drop.marker.css({"left":(et_off.left+10),"top":et_off.top+15}).show()}else if((event.target.tagName!="A"&&event.target.tagName!="INS")||!ok){if(tmp.drag_help!==false)tmp.drag_help.find("li:eq(0) ins").addClass("forbidden");tmp.move_type=false;tmp.ref_node=false;tree_component.drag_drop.marker.hide()}event.preventDefault();event.stopPropagation();return false}return true};$(function(){$(document).bind("mousemove.jstree",tree_component.mousemove);$(document).bind("mouseup.jstree",tree_component.mouseup)});tree_component.cut_copy={copy_nodes:false,cut_nodes:false};tree_component.css=false;tree_component.get_css=function(rule_name,delete_flag){rule_name=rule_name.toLowerCase();var css_rules=tree_component.css.cssRules||tree_component.css.rules;var j=0;do{if(css_rules.length&&j>css_rules.length+5)return false;if(css_rules[j].selectorText&&css_rules[j].selectorText.toLowerCase()==rule_name){if(delete_flag==true){if(tree_component.css.removeRule)document.styleSheets[i].removeRule(j);if(tree_component.css.deleteRule)document.styleSheets[i].deleteRule(j);return true}else return css_rules[j]}}while(css_rules[++j]);return false};tree_component.add_css=function(rule_name){if(tree_component.get_css(rule_name))return false;(tree_component.css.insertRule)?tree_component.css.insertRule(rule_name+' { }',0):tree_component.css.addRule(rule_name,null,0);return tree_component.get_css(rule_name)};tree_component.remove_css=function(rule_name){return tree_component.get_css(rule_name,true)};tree_component.add_sheet=function(opts){if(opts.str){var tmp=document.createElement("style");tmp.setAttribute('type',"text/css");if(tmp.styleSheet){document.getElementsByTagName("head")[0].appendChild(tmp);tmp.styleSheet.cssText=opts.str}else{tmp.appendChild(document.createTextNode(opts.str));document.getElementsByTagName("head")[0].appendChild(tmp)}return tmp.sheet||tmp.styleSheet}if(opts.url){if(document.createStyleSheet){try{document.createStyleSheet(opts.url)}catch(e){}}else{var newSS=document.createElement('link');newSS.rel='stylesheet';newSS.type='text/css';newSS.media="all";newSS.href=opts.url;document.getElementsByTagName("head")[0].appendChild(newSS);return newSS.styleSheet}}};$(function(){var u=navigator.userAgent.toLowerCase();var v=(u.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,'0'])[1];var css='/* TREE LAYOUT */ .tree ul { margin:0 0 0 5px; padding:0 0 0 0; list-style-type:none; } .tree li { display:block; min-height:18px; line-height:18px; padding:0 0 0 15px; margin:0 0 0 0; /* Background fix */ clear:both; } .tree li ul { display:none; } .tree li a, .tree li span { display:inline-block;line-height:16px;height:16px;color:black;white-space:nowrap;text-decoration:none;padding:1px 4px 1px 4px;margin:0; } .tree li a:focus { outline: none; } .tree li a input, .tree li span input { margin:0;padding:0 0;display:inline-block;height:12px !important;border:1px solid white;background:white;font-size:10px;font-family:Verdana; } .tree li a input:not([class="xxx"]), .tree li span input:not([class="xxx"]) { padding:1px 0; } /* FOR DOTS */ .tree .ltr li.last { float:left; } .tree > ul li.last { overflow:visible; } /* OPEN OR CLOSE */ .tree li.open ul { display:block; } .tree li.closed ul { display:none !important; } /* FOR DRAGGING */ #jstree-dragged { position:absolute; top:-10px; left:-10px; margin:0; padding:0; } #jstree-dragged ul ul ul { display:none; } #jstree-marker { padding:0; margin:0; line-height:5px; font-size:1px; overflow:hidden; height:5px; position:absolute; left:-45px; top:-30px; z-index:1000; background-color:transparent; background-repeat:no-repeat; display:none; } #jstree-marker.marker { width:45px; background-position:-32px top; } #jstree-marker.marker_plus { width:5px; background-position:right top; } /* BACKGROUND DOTS */ .tree li li { overflow:hidden; } .tree > .ltr > li { display:table; } /* ICONS */ .tree ul ins { display:inline-block; text-decoration:none; width:16px; height:16px; } .tree .ltr ins { margin:0 4px 0 0px; } ';if(/msie/.test(u)&&!/opera/.test(u)){if(parseInt(v)==6)css+='.tree li { height:18px; zoom:1; } .tree li li { overflow:visible; } .tree .ltr li.last { margin-top: expression( (this.previousSibling && /open/.test(this.previousSibling.className) ) ? "-2px" : "0"); } .marker { width:45px; background-position:-32px top; } .marker_plus { width:5px; background-position:right top; }';if(parseInt(v)==7)css+='.tree li li { overflow:visible; } .tree .ltr li.last { margin-top: expression( (this.previousSibling && /open/.test(this.previousSibling.className) ) ? "-2px" : "0"); }'}if(/opera/.test(u))css+='.tree > ul > li.last:after { content:"."; display: block; height:1px; clear:both; visibility:hidden; }';if(/mozilla/.test(u)&&!/(compatible|webkit)/.test(u)&&v.indexOf("1.8")==0)css+='.tree .ltr li a { display:inline; float:left; } .tree li ul { clear:both; }';tree_component.css=tree_component.add_sheet({str:css})})})(jQuery);(function($){$.extend($.tree.datastores,{"html":function(){return{get:function(obj,tree,opts){return obj&&$(obj).size()?$('<div>').append(tree.get_node(obj).clone()).html():tree.container.children("ul:eq(0)").html()},parse:function(data,tree,opts,callback){if(callback)callback.call(null,data);return data},load:function(data,tree,opts,callback){if(opts.url){$.ajax({'type':opts.method,'url':opts.url,'data':data,'dataType':"html",'success':function(d,textStatus){callback.call(null,d)},'error':function(xhttp,textStatus,errorThrown){callback.call(null,false);tree.error(errorThrown+" "+textStatus)}})}else{callback.call(null,opts.staticData||tree.container.children("ul:eq(0)").html())}}}},"json":function(){return{get:function(obj,tree,opts){var _this=this;if(!obj||$(obj).size()==0)obj=tree.container.children("ul").children("li");else obj=$(obj);if(!opts)opts={};if(!opts.outer_attrib)opts.outer_attrib=["id","rel","class"];if(!opts.inner_attrib)opts.inner_attrib=[];if(obj.size()>1){var arr=[];obj.each(function(){arr.push(_this.get(this,tree,opts))});return arr}if(obj.size()==0)return[];var json={attributes:{},data:{}};if(obj.hasClass("open"))json.state="open";if(obj.hasClass("closed"))json.state="closed";for(var i in opts.outer_attrib){if(!opts.outer_attrib.hasOwnProperty(i))continue;var val=(opts.outer_attrib[i]=="class")?obj.attr(opts.outer_attrib[i]).replace(/(^| )last( |$)/ig," ").replace(/(^| )(leaf|closed|open)( |$)/ig," "):obj.attr(opts.outer_attrib[i]);if(typeof val!="undefined"&&val.toString().replace(" ","").length>0)json.attributes[opts.outer_attrib[i]]=val;delete val}if(tree.settings.languages.length){for(var i in tree.settings.languages){if(!tree.settings.languages.hasOwnProperty(i))continue;var a=obj.children("a."+tree.settings.languages[i]);if(opts.force||opts.inner_attrib.length||a.children("ins").get(0).style.backgroundImage.toString().length||a.children("ins").get(0).className.length){json.data[tree.settings.languages[i]]={};json.data[tree.settings.languages[i]].title=tree.get_text(obj,tree.settings.languages[i]);if(a.children("ins").get(0).style.className.length){json.data[tree.settings.languages[i]].icon=a.children("ins").get(0).style.className}if(a.children("ins").get(0).style.backgroundImage.length){json.data[tree.settings.languages[i]].icon=a.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","")}if(opts.inner_attrib.length){json.data[tree.settings.languages[i]].attributes={};for(var j in opts.inner_attrib){if(!opts.inner_attrib.hasOwnProperty(j))continue;var val=a.attr(opts.inner_attrib[j]);if(typeof val!="undefined"&&val.toString().replace(" ","").length>0)json.data[tree.settings.languages[i]].attributes[opts.inner_attrib[j]]=val;delete val}}}else{json.data[tree.settings.languages[i]]=tree.get_text(obj,tree.settings.languages[i])}}}else{var a=obj.children("a");json.data.title=tree.get_text(obj);if(a.children("ins").size()&&a.children("ins").get(0).className.length){json.data.icon=a.children("ins").get(0).className}if(a.children("ins").size()&&a.children("ins").get(0).style.backgroundImage.length){json.data.icon=a.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","")}if(opts.inner_attrib.length){json.data.attributes={};for(var j in opts.inner_attrib){if(!opts.inner_attrib.hasOwnProperty(j))continue;var val=a.attr(opts.inner_attrib[j]);if(typeof val!="undefined"&&val.toString().replace(" ","").length>0)json.data.attributes[opts.inner_attrib[j]]=val;delete val}}}if(obj.children("ul").size()>0){json.children=[];obj.children("ul").children("li").each(function(){json.children.push(_this.get(this,tree,opts))})}return json},parse:function(data,tree,opts,callback){if(Object.prototype.toString.apply(data)==="[object Array]"){var str='';for(var i=0;i<data.length;i++){if(typeof data[i]=="function")continue;str+=this.parse(data[i],tree,opts)}if(callback)callback.call(null,str);return str}if(!data||!data.data){if(callback)callback.call(null,false);return""}var str='';str+="<li ";var cls=false;if(data.attributes){for(var i in data.attributes){if(!data.attributes.hasOwnProperty(i))continue;if(i=="class"){str+=" class='"+data.attributes[i]+" ";if(data.state=="closed"||data.state=="open")str+=" "+data.state+" ";str+="' ";cls=true}else str+=" "+i+"='"+data.attributes[i]+"' "}}if(!cls&&(data.state=="closed"||data.state=="open"))str+=" class='"+data.state+"' ";str+=">";if(tree.settings.languages.length){for(var i=0;i<tree.settings.languages.length;i++){var attr={};attr["href"]="";attr["style"]="";attr["class"]=tree.settings.languages[i];if(data.data[tree.settings.languages[i]]&&(typeof data.data[tree.settings.languages[i]].attributes).toLowerCase()!="undefined"){for(var j in data.data[tree.settings.languages[i]].attributes){if(!data.data[tree.settings.languages[i]].attributes.hasOwnProperty(j))continue;if(j=="style"||j=="class")attr[j]+=" "+data.data[tree.settings.languages[i]].attributes[j];else attr[j]=data.data[tree.settings.languages[i]].attributes[j]}}str+="<a";for(var j in attr){if(!attr.hasOwnProperty(j))continue;str+=' '+j+'="'+attr[j]+'" '}str+=">";if(data.data[tree.settings.languages[i]]&&data.data[tree.settings.languages[i]].icon){str+="<ins "+(data.data[tree.settings.languages[i]].icon.indexOf("/")==-1?" class='"+data.data[tree.settings.languages[i]].icon+"' ":" style='background-image:url(\""+data.data[tree.settings.languages[i]].icon+"\");' ")+">&nbsp;</ins>"}else str+="<ins>&nbsp;</ins>";str+=((typeof data.data[tree.settings.languages[i]].title).toLowerCase()!="undefined"?data.data[tree.settings.languages[i]].title:data.data[tree.settings.languages[i]])+"</a>"}}else{var attr={};attr["href"]="";attr["style"]="";attr["class"]="";if((typeof data.data.attributes).toLowerCase()!="undefined"){for(var i in data.data.attributes){if(!data.data.attributes.hasOwnProperty(i))continue;if(i=="style"||i=="class")attr[i]+=" "+data.data.attributes[i];else attr[i]=data.data.attributes[i]}}str+="<a";for(var i in attr){if(!attr.hasOwnProperty(i))continue;str+=' '+i+'="'+attr[i]+'" '}str+=">";if(data.data.icon){str+="<ins "+(data.data.icon.indexOf("/")==-1?" class='"+data.data.icon+"' ":" style='background-image:url(\""+data.data.icon+"\");' ")+">&nbsp;</ins>"}else str+="<ins>&nbsp;</ins>";str+=((typeof data.data.title).toLowerCase()!="undefined"?data.data.title:data.data)+"</a>"}if(data.children&&data.children.length){str+='<ul>';for(var i=0;i<data.children.length;i++){str+=this.parse(data.children[i],tree,opts)}str+='</ul>'}str+="</li>";if(callback)callback.call(null,str);return str},load:function(data,tree,opts,callback){if(opts.staticData){callback.call(null,opts.staticData)}else{$.ajax({'type':opts.method,'url':opts.url,'data':data,'dataType':"json",'success':function(d,textStatus){callback.call(null,d)},'error':function(xhttp,textStatus,errorThrown){callback.call(null,false);tree.error(errorThrown+" "+textStatus)}})}}}}})})(jQuery);
check : function (rule, obj) { if(this.locked) return false; var v = false; // if root node if(obj === -1) { if(typeof this.settings.rules[rule] != "undefined") v = this.settings.rules[rule]; } else { obj = !obj ? this.selected : this.get_node(obj); if(!obj) return; var t = this.get_type(obj); if(typeof this.settings.types[t] != "undefined" && typeof this.settings.types[t][rule] != "undefined") v = this.settings.types[t][rule]; else if(typeof this.settings.types["default"] != "undefined" && typeof this.settings.types["default"][rule] != "undefined") v = this.settings.types["default"][rule]; } if(typeof v == "function") v = v.call(null, obj, this); v = this.callback("check", [rule, obj, v, this]); return v; },
chkboxes[i].checked = is_checked;
if (!chkboxes[i].disabled) { chkboxes[i].checked = is_checked; }
function check_boxes(form_name, element_name, is_checked){ var chkboxes = document.forms[form_name].elements[element_name]; var count = chkboxes.length; if (count) { for (var i = 0; i < count; i++) { chkboxes[i].checked = is_checked; } } else { chkboxes.checked = is_checked; } return true;}
chkboxes.checked = is_checked;
if (!chkboxes.disabled) { chkboxes.checked = is_checked; }
function check_boxes(form_name, element_name, is_checked){ var chkboxes = document.forms[form_name].elements[element_name]; var count = chkboxes.length; if (count) { for (var i = 0; i < count; i++) { chkboxes[i].checked = is_checked; } } else { chkboxes.checked = is_checked; } return true;}
check_move : function (nod, ref_node, how) { if(this.locked) return false; if($(ref_node).closest("li.dragged").size()) return false; var tree1 = nod.parents(".tree:eq(0)").get(0); var tree2 = ref_node === -1 ? this.container.get(0) : ref_node.parents(".tree:eq(0)").get(0); if(tree1 && tree1 != tree2) { var m = $.tree.reference(tree2.id).settings.rules.multitree; if(typeof m == "object") m = $.makeArray(m); if(m == "none" || ($.isArray(m) && $.inArray(tree1.id, m) == -1)) return false; } var p = (how != "inside") ? this.parent(ref_node) : this.get_node(ref_node); if(ref_node === -1) p = -1; nod = this.get_node(nod); if(p == false) return false; var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", p) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", p) : -1, valid_children : this.check("valid_children", p) }; var nod_type = (typeof nod == "string") ? nod : this.get_type(nod); if(typeof r.valid_children != "undefined" && (r.valid_children == "none" || (typeof r.valid_children == "object" && $.inArray(nod_type, $.makeArray(r.valid_children)) == -1))) return false; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1) { if(r.max_children == 0) return false; var c_count = 1; if(tree_component.drag_drop.moving == true && tree_component.drag_drop.foreign == false) { c_count = tree_component.drag_drop.dragged.size(); c_count = c_count - p.find('> ul > li.dragged').size(); } if(r.max_children < p.find('> ul > li').size() + c_count) return false; } } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("MOVE: MAX-DEPTH REACHED"); var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = p; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("MOVE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("MOVE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; if(typeof nod != "string") { var t = nod; while(t.size() > 0) { if(mx - incr < 0) return this.error("MOVE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } } if(this.callback("check_move", [nod, ref_node, how, this]) == false) return false; return true; },
(function($){$.tree={datastores:{},plugins:{},defaults:{data:{async:false,type:"html",opts:{method:"GET",url:false}},selected:false,opened:[],languages:[],ui:{dots:true,animation:0,scroll_spd:4,theme_path:false,theme_name:"default",selected_parent_close:"select_parent",selected_delete:"select_previous"},types:{"default":{clickable:true,renameable:true,deletable:true,creatable:true,draggable:true,max_children:-1,max_depth:-1,valid_children:"all",icon:{image:false,position:false}}},rules:{multiple:false,multitree:"none",type_attr:"rel",createat:"bottom",drag_copy:"ctrl",drag_button:"left",use_max_children:true,use_max_depth:true,max_children:-1,max_depth:-1,valid_children:"all"},lang:{new_node:"New folder",loading:"Loading ..."},callback:{beforechange:function(NODE){return true},beforeopen:function(NODE){return true},beforeclose:function(NODE){return true},beforemove:function(data){return true},beforecopy:function(data){return true},beforecreate:function(data){return true},beforerename:function(data){return true},beforedelete:function(data){return true},beforedata:function(NODE){return{id:$(NODE).attr("id")||0}},ondata:function(DATA){return DATA},onparse:function(STR){return STR},onhover:function(NODE){},onselect:function(NODE){},ondeselect:function(NODE){},onchange:function(NODE){},onrename:function(data){},onmove:function(data){},oncopy:function(data){},oncreate:function(data){},ondelete:function(data){},onopen:function(NODE){},onopen_all:function(){},onclose_all:function(){},onclose:function(NODE){},error:function(TEXT){},ondblclk:function(data){this.toggle_branch(data.node);this.select_branch(data.node)},onrgtclk:function(data){},onload:function(){},oninit:function(){},onfocus:function(){},ondestroy:function(){},onsearch:function(NODES){NODES.addClass("search")},ondrop:function(data){},check:function(RULE,NODE,VALUE,TREE_OBJ){return VALUE},check_move:function(NODE,REF_NODE,TYPE,TREE_OBJ){return true}},plugins:{}},create:function(){return new tree_component()},focused:function(){return tree_component.inst[tree_component.focused]},reference:function(obj){var o=$(obj);if(!o.size())o=$("#"+obj);if(!o.size())return null;o=(o.is(".tree"))?o.attr("id"):o.parents(".tree:eq(0)").attr("id");return tree_component.inst[o]||null},rollback:function(data){for(var i in data){if(!data.hasOwnProperty(i))continue;var tmp=tree_component.inst[i];var lock=!tmp.locked;if(lock)tmp.lock(true);tmp.inp=false;tmp.container.html(data[i].html).find(".dragged").removeClass("dragged").end().find(".hover").removeClass("hover");if(data[i].selected){tmp.selected=$("#"+data[i].selected);tmp.selected_arr=[];tmp.container.find("a.clicked").each(function(){tmp.selected_arr.push(tmp.get_node(this))})}if(lock)tmp.lock(false);delete lock;delete tmp}},drop_mode:function(opts){opts=$.extend(opts,{show:false,type:"default",str:"Foreign node"});tree_component.drag_drop.foreign=true;tree_component.drag_drop.isdown=true;tree_component.drag_drop.moving=true;tree_component.drag_drop.appended=false;tree_component.drag_drop.f_type=opts.type;tree_component.drag_drop.f_data=opts;if(!opts.show){tree_component.drag_drop.drag_help=false;tree_component.drag_drop.drag_node=false}else{tree_component.drag_drop.drag_help=$("<div id='jstree-dragged' class='tree tree-default'><ul><li class='last dragged foreign'><a href='#'><ins>&nbsp;</ins>"+opts.str+"</a></li></ul></div>");tree_component.drag_drop.drag_node=tree_component.drag_drop.drag_help.find("li:eq(0)")}if($.tree.drag_start!==false)$.tree.drag_start.call(null,false)},drag_start:false,drag:false,drag_end:false};$.fn.tree=function(opts){return this.each(function(){var conf=$.extend({},opts);if(tree_component.inst&&tree_component.inst[$(this).attr('id')])tree_component.inst[$(this).attr('id')].destroy();if(conf!==false)new tree_component().init(this,conf)})};function tree_component(){return{cntr:++tree_component.cntr,settings:$.extend({},$.tree.defaults),init:function(elem,conf){var _this=this;this.container=$(elem);if(this.container.size==0)return false;tree_component.inst[this.cntr]=this;if(!this.container.attr("id"))this.container.attr("id","jstree_"+this.cntr);tree_component.inst[this.container.attr("id")]=tree_component.inst[this.cntr];tree_component.focused=this.cntr;this.settings=$.extend(true,{},this.settings,conf);if(this.settings.languages&&this.settings.languages.length){this.current_lang=this.settings.languages[0];var st=false;var id="#"+this.container.attr("id");for(var ln=0;ln<this.settings.languages.length;ln++){st=tree_component.add_css(id+" ."+this.settings.languages[ln]);if(st!==false)st.style.display=(this.settings.languages[ln]==this.current_lang)?"":"none"}}else this.current_lang=false;this.container.addClass("tree");if(this.settings.ui.theme_name!==false){if(this.settings.ui.theme_path===false){$("script").each(function(){if(this.src.toString().match(/jquery\.tree.*?js$/)){_this.settings.ui.theme_path=this.src.toString().replace(/jquery\.tree.*?js$/,"")+"themes/"+_this.settings.ui.theme_name+"/style.css";return false}})}else this.settings.ui.theme_path=this.settings.ui.theme_path.replace(/\/$/,"")+'/'+this.settings.ui.theme_name+'/style.css';if(this.settings.ui.theme_path!=""&&$.inArray(this.settings.ui.theme_path,tree_component.themes)==-1){tree_component.add_sheet({url:this.settings.ui.theme_path});tree_component.themes.push(this.settings.ui.theme_path)}this.container.addClass("tree-"+this.settings.ui.theme_name)}var type_icons="";for(var t in this.settings.types){if(!this.settings.types.hasOwnProperty(t))continue;if(!this.settings.types[t].icon)continue;if(this.settings.types[t].icon.image||this.settings.types[t].icon.position){if(t=="default")type_icons+='#'+this.container.attr("id")+' li > a ins { ';else type_icons+='#'+this.container.attr("id")+' li[rel='+t+'] > a ins { ';if(this.settings.types[t].icon.image)type_icons+=' background-image:url('+this.settings.types[t].icon.image+'); ';if(this.settings.types[t].icon.position)type_icons+=' background-position:'+this.settings.types[t].icon.position+'; ';type_icons+='} '}}if(type_icons!="")tree_component.add_sheet({str:type_icons});if(this.settings.rules.multiple)this.selected_arr=[];this.offset=false;this.hovered=false;this.locked=false;if(tree_component.drag_drop.marker===false)tree_component.drag_drop.marker=$("<div>").attr({id:"jstree-marker"}).hide().appendTo("body");this.callback("oninit",[this]);this.refresh();this.attach_events();this.focus()},refresh:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;if(obj&&!this.settings.data.async)obj=false;this.is_partial_refresh=obj?true:false;this.opened=Array();if(this.settings.opened!=false){$.each(this.settings.opened,function(i,item){if(this.replace(/^#/,"").length>0){_this.opened.push("#"+this.replace(/^#/,""))}});this.settings.opened=false}else{this.container.find("li.open").each(function(i){if(this.id){_this.opened.push("#"+this.id)}})}if(this.selected){this.settings.selected=Array();if(obj){$(obj).find("li:has(a.clicked)").each(function(){if(this.id)_this.settings.selected.push("#"+this.id)})}else{if(this.selected_arr){$.each(this.selected_arr,function(){if(this.attr("id"))_this.settings.selected.push("#"+this.attr("id"))})}else{if(this.selected.attr("id"))this.settings.selected.push("#"+this.selected.attr("id"))}}}else if(this.settings.selected!==false){var tmp=Array();if((typeof this.settings.selected).toLowerCase()=="object"){$.each(this.settings.selected,function(){if(this.replace(/^#/,"").length>0)tmp.push("#"+this.replace(/^#/,""))})}else{if(this.settings.selected.replace(/^#/,"").length>0)tmp.push("#"+this.settings.selected.replace(/^#/,""))}this.settings.selected=tmp}if(obj&&this.settings.data.async){this.opened=Array();obj=this.get_node(obj);obj.find("li.open").each(function(i){_this.opened.push("#"+this.id)});if(obj.hasClass("open"))obj.removeClass("open").addClass("closed");if(obj.hasClass("leaf"))obj.removeClass("leaf");obj.children("ul:eq(0)").html("");return this.open_branch(obj,true,function(){_this.reselect.apply(_this)})}var _this=this;var _datastore=new $.tree.datastores[this.settings.data.type]();if(this.container.children("ul").size()==0){this.container.html("<ul class='ltr' style='direction:ltr;'><li class='last'><a class='loading' href='#'><ins>&nbsp;</ins>"+(this.settings.lang.loading||"Loading ...")+"</a></li></ul>")}_datastore.load(this.callback("beforedata",[false,this]),this,this.settings.data.opts,function(data){data=_this.callback("ondata",[data,_this]);_datastore.parse(data,_this,_this.settings.data.opts,function(str){str=_this.callback("onparse",[str,_this]);_this.container.empty().append($("<ul class='ltr'>").html(str));_this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");_this.container.find("li").not(".open").not(".closed").addClass("leaf");_this.reselect()})})},reselect:function(is_callback){var _this=this;if(!is_callback)this.cl_count=0;else this.cl_count--;if(this.opened&&this.opened.length){var opn=false;for(var j=0;this.opened&&j<this.opened.length;j++){if(this.settings.data.async){var tmp=this.get_node(this.opened[j]);if(tmp.size()&&tmp.hasClass("closed")>0){opn=true;var tmp=this.opened[j].toString().replace('/','\\/');delete this.opened[j];this.open_branch(tmp,true,function(){_this.reselect.apply(_this,[true])});this.cl_count++}}else this.open_branch(this.opened[j],true)}if(this.settings.data.async&&opn)return;if(this.cl_count>0)return;delete this.opened}if(this.cl_count>0)return;this.container.css("direction","ltr").children("ul:eq(0)").addClass("ltr");if(this.settings.ui.dots==false)this.container.children("ul:eq(0)").addClass("no_dots");if(this.scrtop){this.container.scrollTop(_this.scrtop);delete this.scrtop}if(this.settings.selected!==false){$.each(this.settings.selected,function(i){if(_this.is_partial_refresh)_this.select_branch($(_this.settings.selected[i].toString().replace('/','\\/'),_this.container),(_this.settings.rules.multiple!==false));else _this.select_branch($(_this.settings.selected[i].toString().replace('/','\\/'),_this.container),(_this.settings.rules.multiple!==false&&i>0))});this.settings.selected=false}this.callback("onload",[_this])},get:function(obj,format,opts){if(!format)format=this.settings.data.type;if(!opts)opts=this.settings.data.opts;return new $.tree.datastores[format]().get(obj,this,opts)},attach_events:function(){var _this=this;this.container.bind("mousedown.jstree",function(event){if(tree_component.drag_drop.isdown){tree_component.drag_drop.move_type=false;event.preventDefault();event.stopPropagation();event.stopImmediatePropagation();return false}}).bind("mouseup.jstree",function(event){setTimeout(function(){_this.focus.apply(_this)},5)}).bind("click.jstree",function(event){return true});$("li",this.container[0]).live("click",function(event){if(event.target.tagName!="LI")return true;_this.off_height();if(event.pageY-$(event.target).offset().top>_this.li_height)return true;_this.toggle_branch.apply(_this,[event.target]);event.stopPropagation();return false});$("a",this.container[0]).live("click",function(event){if(event.which&&event.which==3)return true;if(_this.locked){event.preventDefault();event.target.blur();return _this.error("LOCKED")}_this.select_branch.apply(_this,[event.target,(event.ctrlKey||event.metaKey)||_this.settings.rules.multiple=="on"]);if(_this.inp){_this.inp.blur()}event.preventDefault();event.target.blur();return false}).live("dblclick",function(event){if(_this.locked){event.preventDefault();event.stopPropagation();event.target.blur();return _this.error("LOCKED")}_this.callback("ondblclk",[_this.get_node(event.target).get(0),_this]);event.preventDefault();event.stopPropagation();event.target.blur()}).live("contextmenu",function(event){if(_this.locked){event.target.blur();return _this.error("LOCKED")}return _this.callback("onrgtclk",[_this.get_node(event.target).get(0),_this,event])}).live("mouseover",function(event){if(_this.locked){event.preventDefault();event.stopPropagation();return _this.error("LOCKED")}if(_this.hovered!==false&&(event.target.tagName=="A"||event.target.tagName=="INS")){_this.hovered.children("a").removeClass("hover");_this.hovered=false}_this.callback("onhover",[_this.get_node(event.target).get(0),_this])}).live("mousedown",function(event){if(_this.settings.rules.drag_button=="left"&&event.which&&event.which!=1)return true;if(_this.settings.rules.drag_button=="right"&&event.which&&event.which!=3)return true;_this.focus.apply(_this);if(_this.locked)return _this.error("LOCKED");var obj=_this.get_node(event.target);if(_this.settings.rules.multiple!=false&&_this.selected_arr.length>1&&obj.children("a:eq(0)").hasClass("clicked")){var counter=0;for(var i in _this.selected_arr){if(!_this.selected_arr.hasOwnProperty(i))continue;if(_this.check("draggable",_this.selected_arr[i])){_this.selected_arr[i].addClass("dragged");tree_component.drag_drop.origin_tree=_this;counter++}}if(counter>0){if(_this.check("draggable",obj))tree_component.drag_drop.drag_node=obj;else tree_component.drag_drop.drag_node=_this.container.find("li.dragged:eq(0)");tree_component.drag_drop.isdown=true;tree_component.drag_drop.drag_help=$("<div id='jstree-dragged' class='tree "+(_this.settings.ui.theme_name!=""?" tree-"+_this.settings.ui.theme_name:"")+"' />").append("<ul class='"+_this.container.children("ul:eq(0)").get(0).className+"' />");var tmp=tree_component.drag_drop.drag_node.clone();if(_this.settings.languages.length>0)tmp.find("a").not("."+_this.current_lang).hide();tree_component.drag_drop.drag_help.children("ul:eq(0)").append(tmp);tree_component.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last").children("a").html("<ins>&nbsp;</ins>Multiple selection").end().children("ul").remove();tree_component.drag_drop.dragged=_this.container.find("li.dragged")}}else{if(_this.check("draggable",obj)){tree_component.drag_drop.drag_node=obj;tree_component.drag_drop.drag_help=$("<div id='jstree-dragged' class='tree "+(_this.settings.ui.theme_name!=""?" tree-"+_this.settings.ui.theme_name:"")+"' />").append("<ul class='"+_this.container.children("ul:eq(0)").get(0).className+"' />");var tmp=obj.clone();if(_this.settings.languages.length>0)tmp.find("a").not("."+_this.current_lang).hide();tree_component.drag_drop.drag_help.children("ul:eq(0)").append(tmp);tree_component.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last");tree_component.drag_drop.isdown=true;tree_component.drag_drop.foreign=false;tree_component.drag_drop.origin_tree=_this;obj.addClass("dragged");tree_component.drag_drop.dragged=_this.container.find("li.dragged")}}tree_component.drag_drop.init_x=event.pageX;tree_component.drag_drop.init_y=event.pageY;obj.blur();event.preventDefault();event.stopPropagation();return false})},focus:function(){if(this.locked)return false;if(tree_component.focused!=this.cntr){tree_component.focused=this.cntr;this.callback("onfocus",[this])}},off_height:function(){if(this.offset===false){this.container.css({position:"relative"});this.offset=this.container.offset();var tmp=0;tmp=parseInt($.curCSS(this.container.get(0),"paddingTop",true),10);if(tmp)this.offset.top+=tmp;tmp=parseInt($.curCSS(this.container.get(0),"borderTopWidth",true),10);if(tmp)this.offset.top+=tmp;this.container.css({position:""})}if(!this.li_height){var tmp=this.container.find("ul li.closed, ul li.leaf").eq(0);this.li_height=tmp.height();if(tmp.children("ul:eq(0)").size())this.li_height-=tmp.children("ul:eq(0)").height();if(!this.li_height)this.li_height=18}},scroll_check:function(x,y){var _this=this;var cnt=_this.container;var off=_this.container.offset();var st=cnt.scrollTop();var sl=cnt.scrollLeft();var h_cor=(cnt.get(0).scrollWidth>cnt.width())?40:20;if(y-off.top<20)cnt.scrollTop(Math.max((st-_this.settings.ui.scroll_spd),0));if(cnt.height()-(y-off.top)<h_cor)cnt.scrollTop(st+_this.settings.ui.scroll_spd);if(x-off.left<20)cnt.scrollLeft(Math.max((sl-_this.settings.ui.scroll_spd),0));if(cnt.width()-(x-off.left)<40)cnt.scrollLeft(sl+_this.settings.ui.scroll_spd);if(cnt.scrollLeft()!=sl||cnt.scrollTop()!=st){tree_component.drag_drop.move_type=false;tree_component.drag_drop.ref_node=false;tree_component.drag_drop.marker.hide()}tree_component.drag_drop.scroll_time=setTimeout(function(){_this.scroll_check(x,y)},50)},scroll_into_view:function(obj){obj=obj?this.get_node(obj):this.selected;if(!obj)return false;var off_t=obj.offset().top;var beg_t=this.container.offset().top;var end_t=beg_t+this.container.height();var h_cor=(this.container.get(0).scrollWidth>this.container.width())?40:20;if(off_t+5<beg_t)this.container.scrollTop(this.container.scrollTop()-(beg_t-off_t+5));if(off_t+h_cor>end_t)this.container.scrollTop(this.container.scrollTop()+(off_t+h_cor-end_t))},get_node:function(obj){return $(obj).closest("li")},get_type:function(obj){obj=!obj?this.selected:this.get_node(obj);if(!obj)return;var tmp=obj.attr(this.settings.rules.type_attr);return tmp||"default"},set_type:function(str,obj){obj=!obj?this.selected:this.get_node(obj);if(!obj||!str)return;obj.attr(this.settings.rules.type_attr,str)},get_text:function(obj,lang){obj=this.get_node(obj);if(!obj||obj.size()==0)return"";if(this.settings.languages&&this.settings.languages.length){lang=lang?lang:this.current_lang;obj=obj.children("a."+lang)}else obj=obj.children("a:visible");var val="";obj.contents().each(function(){if(this.nodeType==3){val=this.data;return false}});return val},check:function(rule,obj){if(this.locked)return false;var v=false;if(obj===-1){if(typeof this.settings.rules[rule]!="undefined")v=this.settings.rules[rule]}else{obj=!obj?this.selected:this.get_node(obj);if(!obj)return;var t=this.get_type(obj);if(typeof this.settings.types[t]!="undefined"&&typeof this.settings.types[t][rule]!="undefined")v=this.settings.types[t][rule];else if(typeof this.settings.types["default"]!="undefined"&&typeof this.settings.types["default"][rule]!="undefined")v=this.settings.types["default"][rule]}if(typeof v=="function")v=v.call(null,obj,this);v=this.callback("check",[rule,obj,v,this]);return v},check_move:function(nod,ref_node,how){if(this.locked)return false;if($(ref_node).closest("li.dragged").size())return false;var tree1=nod.parents(".tree:eq(0)").get(0);var tree2=ref_node===-1?this.container.get(0):ref_node.parents(".tree:eq(0)").get(0);if(tree1&&tree1!=tree2){var m=$.tree.reference(tree2.id).settings.rules.multitree;if(typeof m=="object")m=$.makeArray(m);if(m=="none"||($.isArray(m)&&$.inArray(tree1.id,m)==-1))return false}var p=(how!="inside")?this.parent(ref_node):this.get_node(ref_node);if(ref_node===-1)p=-1;nod=this.get_node(nod);if(p==false)return false;var r={max_depth:this.settings.rules.use_max_depth?this.check("max_depth",p):-1,max_children:this.settings.rules.use_max_children?this.check("max_children",p):-1,valid_children:this.check("valid_children",p)};var nod_type=(typeof nod=="string")?nod:this.get_type(nod);if(typeof r.valid_children!="undefined"&&(r.valid_children=="none"||(typeof r.valid_children=="object"&&$.inArray(nod_type,$.makeArray(r.valid_children))==-1)))return false;if(this.settings.rules.use_max_children){if(typeof r.max_children!="undefined"&&r.max_children!=-1){if(r.max_children==0)return false;var c_count=1;if(tree_component.drag_drop.moving==true&&tree_component.drag_drop.foreign==false){c_count=tree_component.drag_drop.dragged.size();c_count=c_count-p.find('> ul > li.dragged').size()}if(r.max_children<p.find('> ul > li').size()+c_count)return false}}if(this.settings.rules.use_max_depth){if(typeof r.max_depth!="undefined"&&r.max_depth===0)return this.error("MOVE: MAX-DEPTH REACHED");var mx=(r.max_depth>0)?r.max_depth:false;var i=0;var t=p;while(t!==-1){t=this.parent(t);i++;var m=this.check("max_depth",t);if(m>=0){mx=(mx===false)?(m-i):Math.min(mx,m-i)}if(mx!==false&&mx<=0)return this.error("MOVE: MAX-DEPTH REACHED")}if(mx!==false&&mx<=0)return this.error("MOVE: MAX-DEPTH REACHED");if(mx!==false){var incr=1;if(typeof nod!="string"){var t=nod;while(t.size()>0){if(mx-incr<0)return this.error("MOVE: MAX-DEPTH REACHED");t=t.children("ul").children("li");incr++}}}}if(this.callback("check_move",[nod,ref_node,how,this])==false)return false;return true},hover_branch:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;var obj=_this.get_node(obj);if(!obj.size())return this.error("HOVER: NOT A VALID NODE");if(!_this.check("clickable",obj))return this.error("SELECT: NODE NOT SELECTABLE");if(this.hovered)this.hovered.children("A").removeClass("hover");this.hovered=obj;this.hovered.children("a").addClass("hover");this.scroll_into_view(this.hovered)},select_branch:function(obj,multiple){if(this.locked)return this.error("LOCKED");if(!obj&&this.hovered!==false)obj=this.hovered;var _this=this;obj=_this.get_node(obj);if(!obj.size())return this.error("SELECT: NOT A VALID NODE");obj.children("a").removeClass("hover");if(!_this.check("clickable",obj))return this.error("SELECT: NODE NOT SELECTABLE");if(_this.callback("beforechange",[obj.get(0),_this])===false)return this.error("SELECT: STOPPED BY USER");if(this.settings.rules.multiple!=false&&multiple&&obj.children("a.clicked").size()>0){return this.deselect_branch(obj)}if(this.settings.rules.multiple!=false&&multiple){this.selected_arr.push(obj)}if(this.settings.rules.multiple!=false&&!multiple){for(var i in this.selected_arr){if(!this.selected_arr.hasOwnProperty(i))continue;this.selected_arr[i].children("A").removeClass("clicked");this.callback("ondeselect",[this.selected_arr[i].get(0),_this])}this.selected_arr=[];this.selected_arr.push(obj);if(this.selected&&this.selected.children("A").hasClass("clicked")){this.selected.children("A").removeClass("clicked");this.callback("ondeselect",[this.selected.get(0),_this])}}if(!this.settings.rules.multiple){if(this.selected){this.selected.children("A").removeClass("clicked");this.callback("ondeselect",[this.selected.get(0),_this])}}this.selected=obj;if(this.hovered!==false){this.hovered.children("A").removeClass("hover");this.hovered=obj}this.selected.children("a").addClass("clicked").end().parents("li.closed").each(function(){_this.open_branch(this,true)});this.scroll_into_view(this.selected);this.callback("onselect",[this.selected.get(0),_this]);this.callback("onchange",[this.selected.get(0),_this])},deselect_branch:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;var obj=this.get_node(obj);if(obj.children("a.clicked").size()==0)return this.error("DESELECT: NODE NOT SELECTED");obj.children("a").removeClass("clicked");this.callback("ondeselect",[obj.get(0),_this]);if(this.settings.rules.multiple!=false&&this.selected_arr.length>1){this.selected_arr=[];this.container.find("a.clicked").filter(":first-child").parent().each(function(){_this.selected_arr.push($(this))});if(obj.get(0)==this.selected.get(0)){this.selected=this.selected_arr[0]}}else{if(this.settings.rules.multiple!=false)this.selected_arr=[];this.selected=false}this.callback("onchange",[obj.get(0),_this])},toggle_branch:function(obj){if(this.locked)return this.error("LOCKED");var obj=this.get_node(obj);if(obj.hasClass("closed"))return this.open_branch(obj);if(obj.hasClass("open"))return this.close_branch(obj)},open_branch:function(obj,disable_animation,callback){var _this=this;if(this.locked)return this.error("LOCKED");var obj=this.get_node(obj);if(!obj.size())return this.error("OPEN: NO SUCH NODE");if(obj.hasClass("leaf"))return this.error("OPEN: OPENING LEAF NODE");if(this.settings.data.async&&obj.find("li").size()==0){obj.children("a").addClass("loading");this._load_branch(obj,function(){_this.open_branch(obj,disable_animation,callback)});return}obj.children("a").removeClass("loading");if(this.callback("beforeopen",[obj.get(0),this])===false)return this.error("OPEN: STOPPED BY USER");if(parseInt(this.settings.ui.animation)>0&&!disable_animation){obj.children("ul:eq(0)").css("display","none");obj.removeClass("closed").addClass("open");obj.children("ul:eq(0)").slideDown(parseInt(this.settings.ui.animation),function(){$(this).css("display","");if(callback)callback.call()})}else{obj.removeClass("closed").addClass("open");if(callback)callback.call()}this.callback("onopen",[obj.get(0),this]);return true},close_branch:function(obj,disable_animation){if(this.locked)return this.error("LOCKED");var _this=this;var obj=this.get_node(obj);if(!obj.size())return this.error("CLOSE: NO SUCH NODE");if(_this.callback("beforeclose",[obj.get(0),_this])===false)return this.error("CLOSE: STOPPED BY USER");if(parseInt(this.settings.ui.animation)>0&&!disable_animation&&obj.children("ul:eq(0)").size()==1){obj.children("ul:eq(0)").slideUp(parseInt(this.settings.ui.animation),function(){if(obj.hasClass("open"))obj.removeClass("open").addClass("closed");$(this).css("display","");_this.callback("onclose",[obj.get(0),_this])})}else{if(obj.hasClass("open"))obj.removeClass("open").addClass("closed");this.callback("onclose",[obj.get(0),this])}if(this.selected&&this.settings.ui.selected_parent_close!==false&&obj.children("ul:eq(0)").find("a.clicked").size()>0){obj.find("li:has(a.clicked)").each(function(){_this.deselect_branch(this)});if(this.settings.ui.selected_parent_close=="select_parent"&&obj.children("a.clicked").size()==0)this.select_branch(obj,(this.settings.rules.multiple!=false&&this.selected_arr.length>0))}},open_all:function(obj,callback){if(this.locked)return this.error("LOCKED");var _this=this;obj=obj?this.get_node(obj):this.container;var s=obj.find("li.closed").size();if(!callback)this.cl_count=0;else this.cl_count--;if(s>0){this.cl_count+=s;obj.find("li.closed").each(function(){var __this=this;_this.open_branch.apply(_this,[this,true,function(){_this.open_all.apply(_this,[__this,true])}])})}else if(this.cl_count==0)this.callback("onopen_all",[this])},close_all:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;obj=obj?this.get_node(obj):this.container;obj.find("li.open").each(function(){_this.close_branch(this,true)});this.callback("onclose_all",[this])},set_lang:function(i){if(!$.isArray(this.settings.languages)||this.settings.languages.length==0)return false;if(this.locked)return this.error("LOCKED");if(!$.inArray(i,this.settings.languages)&&typeof this.settings.languages[i]!="undefined")i=this.settings.languages[i];if(typeof i=="undefined")return false;if(i==this.current_lang)return true;var st=false;var id="#"+this.container.attr("id");st=tree_component.get_css(id+" ."+this.current_lang);if(st!==false)st.style.display="none";st=tree_component.get_css(id+" ."+i);if(st!==false)st.style.display="";this.current_lang=i;return true},get_lang:function(){if(!$.isArray(this.settings.languages)||this.settings.languages.length==0)return false;return this.current_lang},_load_branch:function(obj,callback){var _this=this;var obj=this.get_node(obj);if(!obj.size())return this.error("LOAD: NO SUCH NODE");if(this.settings.data.async){var _datastore=new $.tree.datastores[this.settings.data.type]();_datastore.load(this.callback("beforedata",[obj,this]),this,this.settings.data.opts,function(data){data=_this.callback("ondata",[data,_this]);if(!data||data.length==0){obj.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove();if(callback)callback.call();return}_datastore.parse(data,_this,_this.settings.data.opts,function(str){str=_this.callback("onparse",[str,_this]);obj.children("ul").remove();obj.append($("<ul>").html(str));obj.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");obj.find("li").not(".open").not(".closed").addClass("leaf");if(callback)callback.call()})})}},_create:function(obj,ref_node,position,supress_callback){if(ref_node!=-1)ref_node=this.get_node(ref_node);if(typeof position=="undefined")position="inside";if(ref_node!=-1&&position!="after"&&position!="before"&&ref_node.hasClass("closed")&&this.settings.data.async&&ref_node.children("ul").size()==0){var _this=this;return this._load_branch(ref_node,function(){_this._create.apply(_this,[obj,ref_node,position,supress_callback])})}switch(position){case"before":position=ref_node.parent().children().index(ref_node);ref_node=this.parent(ref_node);break;case"after":position=ref_node.parent().children().index(ref_node)+1;ref_node=this.parent(ref_node);break;case"inside":position=(this.settings.rules.createat=="top")?0:this.children(ref_node).size();break;default:break}var ref_dom=(ref_node==-1)?this.container:ref_node;var $ul=false;if(ref_dom.children("ul").size()==0){if(ref_node!=-1&&!ref_node.hasClass("open closed"))ref_node.removeClass("leaf").addClass("closed");$ul=$("<ul>");ref_dom.append($ul)}else{$ul=ref_dom.children("ul:eq(0)")}if(obj instanceof jQuery){$li=obj}else{obj=this.callback("ondata",[obj,this]);var obj_s=$.tree.datastores.json().parse(obj,this);obj_s=this.callback("onparse",[obj_s,this]);var $li=$(obj_s)}if($li.children("ul").size()){if(!$li.is(".open")){$li.addClass("closed")}}else{$li.addClass("leaf")}$li.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");$li.find("li").not(".open").not(".closed").addClass("leaf");var $ref_li=$ul.children("li:nth-child("+(position+1)+")");if($ref_li.size()){$ref_li.before($li)}else{$ul.append($li)}$ul.children(".last").removeClass("last").end().children("li:last-child").addClass("last");if(!supress_callback){this.callback("oncreate",[{'node':$li.get(0),'parent':ref_node==-1?-1:ref_node.get(0),'position':position,'is_ui':false}])}return $li},create:function(obj,ref_node,position){if(this.locked)return this.error("LOCKED");if(ref_node!=-1)ref_node=ref_node?this.get_node(ref_node):this.selected;if(ref_node!=-1&&(!ref_node||!ref_node.size()))return this.error("CREATE: NO NODE SELECTED");if(typeof position=="undefined")position="inside";if(ref_node!=-1&&position!="after"&&position!="before"&&ref_node.hasClass("closed")){if(this.settings.data.async&&ref_node.children("ul").size()==0){var _this=this;return this.open_branch(ref_node,true,function(){_this.create.apply(_this,[obj,ref_node,position])})}else{this.open_branch(ref_node,true)}}switch(position){case"before":position=ref_node.parent().children().index(ref_node);ref_node=this.parent(ref_node);break;case"after":position=ref_node.parent().children().index(ref_node)+1;ref_node=this.parent(ref_node);break;case"inside":position=(this.settings.rules.createat=="top")?0:this.children(ref_node).size();break;default:break}if(!this.check("creatable",ref_node))return this.error("CREATE: CANNOT CREATE IN NODE");var torename=false;if(!obj)obj={};else obj=$.extend(true,{},obj);if(!obj.attributes)obj.attributes={};if(!obj.attributes[this.settings.rules.type_attr])obj.attributes[this.settings.rules.type_attr]=this.get_type(ref_node)||"default";if(this.settings.languages.length){if(!obj.data){obj.data={};torename=true}for(var i=0;i<this.settings.languages.length;i++){if(!obj.data[this.settings.languages[i]])obj.data[this.settings.languages[i]]=((typeof this.settings.lang.new_node).toLowerCase()!="string"&&this.settings.lang.new_node[i])?this.settings.lang.new_node[i]:this.settings.lang.new_node}}else{if(!obj.data){obj.data=this.settings.lang.new_node;torename=true}}obj=this.callback("ondata",[obj,this]);var obj_s=$.tree.datastores.json().parse(obj,this);obj_s=this.callback("onparse",[obj_s,this]);var $li=$(obj_s);var r={max_depth:this.settings.rules.use_max_depth?this.check("max_depth",ref_node):-1,max_children:this.settings.rules.use_max_children?this.check("max_children",ref_node):-1,valid_children:this.check("valid_children",ref_node)};if(this.settings.rules.use_max_children){if(typeof r.max_children!="undefined"&&r.max_children!=-1&&r.max_children>=this.children(ref_node).size())return this.error("CREATE: MAX_CHILDREN REACHED")}if(this.settings.rules.use_max_depth){if(typeof r.max_depth!="undefined"&&r.max_depth===0)return this.error("CREATE: MAX-DEPTH REACHED");var mx=(r.max_depth>0)?r.max_depth:false;var i=0;var t=ref_node;while(t!==-1){t=this.parent(t);i++;var m=this.check("max_depth",t);if(m>=0){mx=(mx===false)?(m-i):Math.min(mx,m-i)}if(mx!==false&&mx<=0)return this.error("CREATE: MAX-DEPTH REACHED")}if(mx!==false&&mx<=0)return this.error("CREATE: MAX-DEPTH REACHED");if(mx!==false){var incr=1;var t=$li;while(t.size()>0){if(mx-incr<0)return this.error("CREATE: MAX-DEPTH REACHED");t=t.children("ul").children("li");incr++}}}if(!this.callback("beforecreate",[{'node':$li.get(0),'parent':ref_node==-1?-1:ref_node.get(0),'position':position}]))return this.error("CREATE: STOPPED");var rb={};rb[this.container.attr("id")]=this.get_rollback();$li=this._create($li,ref_node,position,true);this.select_branch($li.children("a:eq(0)"));this.rename(false,true,rb);return $li},_rename:function(obj,new_name,lang,supress_callback){obj=this.get_node(obj);if(!obj||!obj.size())return false;if(lang)obj=obj.find("a."+lang);else if(this.current_lang)obj=obj.find("a."+this.current_lang);else obj=obj.find("a:first");var icn=obj.children("ins").clone();obj.text(new_name).prepend(icn);if(!supress_callback){this.callback("onrename",[{'node':this.get_node(obj).get(0),'new_name':new_name,'lang':lang?lang:this.get_lang(),'is_ui':false}])}},rename:function(obj,is_create,create_rb){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.selected;var _this=this;if(!obj||!obj.size())return this.error("RENAME: NO NODE SELECTED");if(!this.check("renameable",obj))return this.error("RENAME: NODE NOT RENAMABLE");if(!this.callback("beforerename",[{node:obj.get(0),lang:_this.current_lang}]))return this.error("RENAME: STOPPED BY USER");obj.parents("li.closed").each(function(){_this.open_branch(this)});var rb={};rb[this.container.attr("id")]=this.get_rollback();var a=obj.children("a:visible");var last_value="";a.contents().each(function(){if(this.nodeType==3){last_value=this.data;return false}});_this.inp=$("<input type='text' autocomplete='off' />");_this.inp.val(last_value.replace(/&amp;/g,"&").replace(/&gt;/g,">").replace(/&lt;/g,"<")).bind("mousedown",function(event){event.stopPropagation()}).bind("mouseup",function(event){event.stopPropagation()}).bind("click",function(event){event.stopPropagation()}).bind("keyup",function(event){var key=event.keyCode||event.which;if(key==27){this.value=last_value;this.blur();return}if(key==13){this.blur();return}});_this.inp.blur(function(event){if(this.value=="")this.value=last_value;_this._rename(obj,this.value,false,true);a.get(0).style.display="";a.prevAll("span").remove();_this.inp=false;if(is_create){var par=_this.parent(a);_this.callback("oncreate",[{'node':_this.get_node(a).get(0),'parent':par==-1?-1:par.get(0),'new_name':this.value,'lang':_this.get_lang(),'is_ui':true,'rollback':create_rb}])}else{_this.callback("onrename",[{'node':_this.get_node(obj).get(0),'new_name':this.value,'lang':_this.get_lang(),'is_ui':true,'last_name':last_value,'rollback':rb}])}});var spn=$("<span />").addClass(obj.attr("class")).append(a.children("ins").clone()).append(_this.inp);a.get(0).style.display="none";obj.prepend(spn);_this.inp.get(0).focus();_this.inp.get(0).select()},_remove:function(obj,supress_callback){obj=this.get_node(obj);if(!obj.size())return false;var _this=this;var $parent=obj.parent();var rebuild_selected_arr=obj.find("a.clicked").size()?true:false;var reset_selected=(obj.get(0)==this.selected||obj.find("li").index(this.selected)!=-1)?true:false;obj=obj.remove();$parent.children("li:last").addClass("last");if($parent.children("li").size()==0){$li=$parent.parents("li:eq(0)");$li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove()}if(rebuild_selected_arr){this.selected_arr=[];this.container.find("a.clicked").filter(":first-child").parent().each(function(){_this.selected_arr.push($(this))})}if(reset_selected){this.selected=this.selected_arr[0]||false}$parent=this.get_node($parent);if(!supress_callback){this.callback("ondelete",[{'node':objs[i].get(0),'parent':$parent==-1?$parent:$parent.get(0),'is_ui':false}])}return obj},remove:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;var rb={};rb[this.container.attr("id")]=this.get_rollback();var objs=[];if(obj)objs.push(this.get_node(obj));else{if(!this.selected)return this.error("DELETE: NO NODE SELECTED");if(this.selected_arr)objs=$.makeArray(this.selected_arr);else objs.push(this.selected);var to_select=this.settings.ui.selected_delete=="select_previous"?this.prev(this.selected):false}for(var i=0;i<objs.length;i++){if(!this.check("deletable",objs[i])){this.error("DELETE: NODE NOT DELETABLE");continue}if(!this.callback("beforedelete",[{node:objs[i]}])){this.error("DELETE: STOPPED BY USER");continue}var $parent=_this.parent(objs[i]);var tmp=this._remove(objs[i],true);this.callback("ondelete",[{'node':tmp.get(0),'parent':$parent==-1?$parent:$parent.get(0),'is_ui':true,'rollback':rb}])}if(to_select)this.select_branch(to_select)},_move:function(obj,ref_node,position,is_copy,supress_callback){obj=this.get_node(obj);if(ref_node!=-1)ref_node=this.get_node(ref_node);if(typeof position=="undefined")position="inside";if(ref_node!=-1&&position!="after"&&position!="before"&&ref_node.hasClass("closed")&&this.settings.data.async&&ref_node.children("ul").size()==0){var _this=this;return this._load_branch(ref_node,function(){_this._move.apply(_this,[obj,ref_node,position,is_copy,supress_callback])})}switch(position){case"before":position=ref_node.parent().children().index(ref_node);ref_node=this.parent(ref_node);break;case"after":position=ref_node.parent().children().index(ref_node)+1;ref_node=this.parent(ref_node);break;case"inside":position=(this.settings.rules.createat=="top")?0:this.children(ref_node).size();break;default:break}var new_parent=(ref_node==-1)?this.container:ref_node;var old_parent=this.parent(obj);var _obj=obj;if(is_copy){_obj=obj.clone();_obj.each(function(i){this.id=this.id+"_copy";$(this).find("li").each(function(){this.id=this.id+"_copy"});$(this).removeClass("dragged").find("a.clicked").removeClass("clicked").end().find("li.dragged").removeClass("dragged")})}var tree_1=$.tree.reference(obj);var tree_2=ref_node==-1?this:$.tree.reference(ref_node);if(tree_1.cntr!=tree_2.cntr){var res=[];if(tree_1.settings.languages.length&&tree_2.settings.languages.length){res=jQuery.map(tree_2.settings.languages,function(n,i){return('.'+n.toUpperCase())});_obj.find("a").not(res.join(",")).remove();if(!obj.find("a:eq(0)").size())return this.error("MOVE: NO COMMON LANGUAGES")}else if(tree_1.settings.languages.length){var t1cl=tree_1.get_lang();_obj.find("a").not("."+t1cl).remove();_obj.find("a").removeClass(t1cl)}else if(tree_2.settings.languages.length){var t2cl=tree_2.get_lang();_obj.find("a").addClass(t2cl)}_obj.find("a.clicked").removeClass("clicked")}var $ul=false;if(new_parent.children("ul").size()==0){if(ref_node!=-1&&!new_parent.hasClass("open closed"))new_parent.removeClass("leaf").addClass("closed");$ul=$("<ul>");new_parent.append($ul)}else{$ul=new_parent.children("ul:eq(0)")}var $ref_li=$ul.children("li:nth-child("+(position+1)+")");if($ref_li.size()){$ref_li.before(_obj.removeClass("last"))}else{$ul.append(_obj.removeClass("last"))}$ul.children(".last").removeClass("last").end().children("li:last-child").addClass("last");if(old_parent===-1)old_parent=tree_1.container;old_parent.children("ul").children(".last").removeClass("last").end().children("li:last-child").addClass("last");if(!supress_callback){this.callback((is_copy?"onmove":"oncopy"),[{'node':_obj.get(0),'parent':ref_node==-1?-1:ref_node.get(0),'position':position,'is_ui':false,'old_parent':old_parent.get(0),'origin_tree':tree_1,'receiving_tree':tree_2,}])}return _obj},moved:function(obj,ref_node,position,is_copy,rb){if(ref_node!=-1)ref_node=this.get_node(ref_node);if(typeof position=="undefined")position="inside";if(ref_node!=-1&&position!="after"&&position!="before"&&ref_node.hasClass("closed")&&this.settings.data.async&&ref_node.children("ul").size()==0){var _this=this;return this.open_branch(ref_node,true,function(){_this.moved.apply(_this,[obj,ref_node,position,is_copy,rb])})}if($(obj).size()>1){var _this=this;var tmp=this.moved(obj.eq(0),ref_node,position,is_copy,rb);obj.each(function(i){if(i==0)return;if(tmp){tmp=_this.moved(this,tmp,"after",is_copy,rb)}});return obj}if(!this.check_move(obj,ref_node,position))return false;obj=this.get_node(obj);switch(position){case"before":position=ref_node.parent().children().index(ref_node);ref_node=this.parent(ref_node);break;case"after":position=ref_node.parent().children().index(ref_node)+1;ref_node=this.parent(ref_node);break;case"inside":position=(this.settings.rules.createat=="top")?0:this.children(ref_node).size();break;default:break}var new_parent=(ref_node==-1)?this.container:ref_node;var old_parent=this.parent(obj);var tree_1=$.tree.reference(obj);var tree_2=ref_node==-1?this:$.tree.reference(ref_node);if(!this.callback((is_copy?"beforecopy":"beforemove"),[{'node':obj.get(0),'parent':ref_node==-1?-1:ref_node.get(0),'position':position,'is_ui':false,'old_parent':old_parent==-1?-1:old_parent.get(0),'origin_tree':tree_1,'receiving_tree':tree_2}]))return false;if(!rb){var rb={};rb[tree_1.container.attr("id")]=tree_1.get_rollback();rb[tree_2.container.attr("id")]=tree_2.get_rollback()}var _obj=this._move(obj,ref_node,position,is_copy,true);if(_obj) { var _this = this; _obj.parents(".closed").each(function () { _this.open_branch(this); }); }this.callback((is_copy?"oncopy":"onmove"),[{'node':_obj.get(0),'parent':ref_node==-1?-1:ref_node.get(0),'position':position,'is_ui':true,'old_parent':old_parent==-1?-1:old_parent.get(0),'origin_tree':tree_1,'receiving_tree':tree_2}]);return _obj},next:function(obj,strict){obj=this.get_node(obj);if(!obj.size())return false;if(strict)return(obj.nextAll("li").size()>0)?obj.nextAll("li:eq(0)"):false;if(obj.hasClass("open"))return obj.find("li:eq(0)");else if(obj.nextAll("li").size()>0)return obj.nextAll("li:eq(0)");else return obj.parents("li").next("li").eq(0)},prev:function(obj,strict){obj=this.get_node(obj);if(!obj.size())return false;if(strict)return(obj.prevAll("li").size()>0)?obj.prevAll("li:eq(0)"):false;if(obj.prev("li").size()){var obj=obj.prev("li").eq(0);while(obj.hasClass("open"))obj=obj.children("ul:eq(0)").children("li:last");return obj}else return obj.parents("li:eq(0)").size()?obj.parents("li:eq(0)"):false},parent:function(obj){obj=this.get_node(obj);if(!obj.size())return false;return obj.parents("li:eq(0)").size()?obj.parents("li:eq(0)"):-1},children:function(obj){if(obj===-1)return this.container.children("ul:eq(0)").children("li");obj=this.get_node(obj);if(!obj.size())return false;return obj.children("ul:eq(0)").children("li")},toggle_dots:function(){if(this.settings.ui.dots){this.settings.ui.dots=false;this.container.children("ul:eq(0)").addClass("no_dots")}else{this.settings.ui.dots=true;this.container.children("ul:eq(0)").removeClass("no_dots")}},callback:function(cb,args){var p=false;var r=null;for(var i in this.settings.plugins){if(typeof $.tree.plugins[i]!="object")continue;p=$.tree.plugins[i];if(p.callbacks&&typeof p.callbacks[cb]=="function")r=p.callbacks[cb].apply(this,args);if(typeof r!=="undefined"&&r!==null){if(cb=="ondata"||cb=="onparse")args[0]=r;else return r}}p=this.settings.callback[cb];if(typeof p=="function")return p.apply(this,args)},get_rollback:function(){var rb={};rb.html=this.container.html();rb.selected=this.selected?this.selected.attr("id"):false;return rb},error:function(code){this.callback("error",[code,this]);return false},lock:function(state){this.locked=state;if(this.locked)this.container.children("ul:eq(0)").addClass("locked");else this.container.children("ul:eq(0)").removeClass("locked")},cut:function(obj){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.container.find("a.clicked").filter(":first-child").parent();if(!obj||!obj.size())return this.error("CUT: NO NODE SELECTED");tree_component.cut_copy.copy_nodes=false;tree_component.cut_copy.cut_nodes=obj},copy:function(obj){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.container.find("a.clicked").filter(":first-child").parent();if(!obj||!obj.size())return this.error("COPY: NO NODE SELECTED");tree_component.cut_copy.copy_nodes=obj;tree_component.cut_copy.cut_nodes=false},paste:function(obj,position){if(this.locked)return this.error("LOCKED");var root=false;if(obj==-1){root=true;obj=this.container}else obj=obj?this.get_node(obj):this.selected;if(!root&&(!obj||!obj.size()))return this.error("PASTE: NO NODE SELECTED");if(!tree_component.cut_copy.copy_nodes&&!tree_component.cut_copy.cut_nodes)return this.error("PASTE: NOTHING TO DO");var _this=this;var pos=position;if(position=="before"){position=obj.parent().children().index(obj);obj=obj.parents("li:eq(0)")}else if(position=="after"){position=obj.parent().children().index(obj)+1;obj=obj.parents("li:eq(0)")}else if((typeof position).toLowerCase()=="undefined"||position=="inside"){position=(this.settings.rules.createat=="top")?0:obj.children("ul:eq(0)").children("li").size()}if(!root&&obj.size()==0){root=true;obj=this.container}if(tree_component.cut_copy.copy_nodes&&tree_component.cut_copy.copy_nodes.size()){var ok=true;if(!root&&!this.check_move(tree_component.cut_copy.copy_nodes,obj.children("a:eq(0)"),"inside"))return false;if(obj.children("ul").size()==0||(root==true&&obj.children("ul").children("li").size()==0)){if(!root)var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("a:eq(0)"),"inside",true);else var a=this.moved(tree_component.cut_copy.copy_nodes,this.container.children("ul:eq(0)"),"inside",true)}else if(pos=="before"&&obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",true);else if(pos=="after"&&obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").size())var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").children("a:eq(0)"),"after",true);else if(obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",true);else var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",true);tree_component.cut_copy.copy_nodes=false}if(tree_component.cut_copy.cut_nodes&&tree_component.cut_copy.cut_nodes.size()){var ok=true;obj.parents().andSelf().each(function(){if(tree_component.cut_copy.cut_nodes.index(this)!=-1){ok=false;return false}});if(!ok)return this.error("Invalid paste");if(!root&&!this.check_move(tree_component.cut_copy.cut_nodes,obj.children("a:eq(0)"),"inside"))return false;if(obj.children("ul").size()==0||(root==true&&obj.children("ul").children("li").size()==0)){if(!root)var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("a:eq(0)"),"inside");else var a=this.moved(tree_component.cut_copy.cut_nodes,this.container.children("ul:eq(0)"),"inside")}else if(pos=="before"&&obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before");else if(pos=="after"&&obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").size())var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").children("a:eq(0)"),"after");else if(obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before");else var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after");tree_component.cut_copy.cut_nodes=false}},search:function(str,func){var _this=this;if(!str||(this.srch&&str!=this.srch)){this.srch="";this.srch_opn=false;this.container.find("a.search").removeClass("search")}this.srch=str;if(!str)return;if(!func)func="contains";if(this.settings.data.async){if(!this.srch_opn){var dd=$.extend({"search":str},this.callback("beforedata",[false,this]));$.ajax({type:this.settings.data.opts.method,url:this.settings.data.opts.url,data:dd,dataType:"text",success:function(data){_this.srch_opn=$.unique(data.split(","));_this.search.apply(_this,[str,func])}})}else if(this.srch_opn.length){if(this.srch_opn&&this.srch_opn.length){var opn=false;for(var j=0;j<this.srch_opn.length;j++){if(this.get_node("#"+this.srch_opn[j]).size()>0){opn=true;var tmp="#"+this.srch_opn[j];delete this.srch_opn[j];this.open_branch(tmp,true,function(){_this.search.apply(_this,[str,func])})}}if(!opn){this.srch_opn=[];_this.search.apply(_this,[str,func])}}}else{this.srch_opn=false;var selector="a";if(this.settings.languages.length)selector+="."+this.current_lang;this.callback("onsearch",[this.container.find(selector+":"+func+"('"+str+"')"),this])}}else{var selector="a";if(this.settings.languages.length)selector+="."+this.current_lang;var nn=this.container.find(selector+":"+func+"('"+str+"')");nn.parents("li.closed").each(function(){_this.open_branch(this,true)});this.callback("onsearch",[nn,this])}},add_sheet:tree_component.add_sheet,destroy:function(){this.callback("ondestroy",[this]);this.container.unbind(".jstree");$("#"+this.container.attr("id")).die("click.jstree").die("dblclick.jstree").die("mouseover.jstree").die("mouseout.jstree").die("mousedown.jstree");this.container.removeClass("tree ui-widget ui-widget-content tree-default tree-"+this.settings.ui.theme_name).children("ul").removeClass("no_dots ltr locked").find("li").removeClass("leaf").removeClass("open").removeClass("closed").removeClass("last").children("a").removeClass("clicked hover search");if(this.cntr==tree_component.focused){for(var i in tree_component.inst){if(i!=this.cntr&&i!=this.container.attr("id")){tree_component.inst[i].focus();break}}}tree_component.inst[this.cntr]=false;tree_component.inst[this.container.attr("id")]=false;delete tree_component.inst[this.cntr];delete tree_component.inst[this.container.attr("id")];tree_component.cntr--}}};tree_component.cntr=0;tree_component.inst={};tree_component.themes=[];tree_component.drag_drop={isdown:false,drag_node:false,drag_help:false,dragged:false,init_x:false,init_y:false,moving:false,origin_tree:false,marker:false,move_type:false,ref_node:false,appended:false,foreign:false,droppable:[],open_time:false,scroll_time:false};tree_component.mouseup=function(event){var tmp=tree_component.drag_drop;if(tmp.open_time)clearTimeout(tmp.open_time);if(tmp.scroll_time)clearTimeout(tmp.scroll_time);if(tmp.moving&&$.tree.drag_end!==false)$.tree.drag_end.call(null,event,tmp);if(tmp.foreign===false&&tmp.drag_node&&tmp.drag_node.size()){tmp.drag_help.remove();if(tmp.move_type){var tree1=tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")];if(tree1)tree1.moved(tmp.dragged,tmp.ref_node,tmp.move_type,(tmp.origin_tree.settings.rules.drag_copy=="on"||(tmp.origin_tree.settings.rules.drag_copy=="ctrl"&&(event.ctrlKey||event.metaKey))))}tmp.move_type=false;tmp.ref_node=false}if(tmp.foreign!==false){if(tmp.drag_help)tmp.drag_help.remove();if(tmp.move_type){var tree1=tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")];if(tree1)tree1.callback("ondrop",[tmp.f_data,tree1.get_node(tmp.ref_node).get(0),tmp.move_type,tree1])}tmp.foreign=false;tmp.move_type=false;tmp.ref_node=false}if(tree_component.drag_drop.marker)tree_component.drag_drop.marker.hide();if(tmp.dragged&&tmp.dragged.size())tmp.dragged.removeClass("dragged");tmp.dragged=false;tmp.drag_help=false;tmp.drag_node=false;tmp.f_type=false;tmp.f_data=false;tmp.init_x=false;tmp.init_y=false;tmp.moving=false;tmp.appended=false;tmp.origin_tree=false;if(tmp.isdown){tmp.isdown=false;event.preventDefault();event.stopPropagation();return false}};tree_component.mousemove=function(event){var tmp=tree_component.drag_drop;var is_start=false;if(tmp.isdown){if(!tmp.moving&&Math.abs(tmp.init_x-event.pageX)<5&&Math.abs(tmp.init_y-event.pageY)<5){event.preventDefault();event.stopPropagation();return false}else{if(!tmp.moving){tree_component.drag_drop.moving=true;is_start=true}}if(tmp.open_time)clearTimeout(tmp.open_time);if(tmp.drag_help!==false){if(!tmp.appended){if(tmp.foreign!==false)tmp.origin_tree=$.tree.focused();$("body").append(tmp.drag_help);tmp.w=tmp.drag_help.width();tmp.appended=true}tmp.drag_help.css({"left":(event.pageX+5),"top":(event.pageY+15)})}if(is_start&&$.tree.drag_start!==false)$.tree.drag_start.call(null,event,tmp);if($.tree.drag!==false)$.tree.drag.call(null,event,tmp);if(event.target.tagName=="DIV"&&event.target.id=="jstree-marker")return false;var et=$(event.target);if(et.is("ins"))et=et.parent();var cnt=et.is(".tree")?et:et.parents(".tree:eq(0)");if(cnt.size()==0||!tree_component.inst[cnt.attr("id")]){if(tmp.scroll_time)clearTimeout(tmp.scroll_time);if(tmp.drag_help!==false)tmp.drag_help.find("li:eq(0) ins").addClass("forbidden");tmp.move_type=false;tmp.ref_node=false;tree_component.drag_drop.marker.hide();return false}var tree2=tree_component.inst[cnt.attr("id")];tree2.off_height();if(tmp.scroll_time)clearTimeout(tmp.scroll_time);tmp.scroll_time=setTimeout(function(){tree2.scroll_check(event.pageX,event.pageY)},50);var mov=false;var st=cnt.scrollTop();if(event.target.tagName=="A"||event.target.tagName=="INS"){if(et.is("#jstree-dragged"))return false;if(tree2.get_node(event.target).hasClass("closed")){tmp.open_time=setTimeout(function(){tree2.open_branch(et)},500)}var et_off=et.offset();var goTo={x:(et_off.left-1),y:(event.pageY-et_off.top)};var arr=[];if(goTo.y<tree2.li_height/3+1)arr=["before","inside","after"];else if(goTo.y>tree2.li_height*2/3-1)arr=["after","inside","before"];else{if(goTo.y<tree2.li_height/2)arr=["inside","before","after"];else arr=["inside","after","before"]}var ok=false;var nn=(tmp.foreign==false)?tmp.origin_tree.container.find("li.dragged"):tmp.f_type;$.each(arr,function(i,val){if(tree2.check_move(nn,et,val)){mov=val;ok=true;return false}});if(ok){switch(mov){case"before":goTo.y=et_off.top-2;tree_component.drag_drop.marker.attr("class","marker");break;case"after":goTo.y=et_off.top-2+tree2.li_height;tree_component.drag_drop.marker.attr("class","marker");break;case"inside":goTo.x-=2;goTo.y=et_off.top-2+tree2.li_height/2;tree_component.drag_drop.marker.attr("class","marker_plus");break}tmp.move_type=mov;tmp.ref_node=$(event.target);if(tmp.drag_help!==false)tmp.drag_help.find(".forbidden").removeClass("forbidden");tree_component.drag_drop.marker.css({"left":goTo.x,"top":goTo.y}).show()}}if((et.is(".tree")||et.is("ul"))&&et.find("li:eq(0)").size()==0){var et_off=et.offset();tmp.move_type="inside";tmp.ref_node=cnt.children("ul:eq(0)");if(tmp.drag_help!==false)tmp.drag_help.find(".forbidden").removeClass("forbidden");tree_component.drag_drop.marker.attr("class","marker_plus");tree_component.drag_drop.marker.css({"left":(et_off.left+10),"top":et_off.top+15}).show()}else if((event.target.tagName!="A"&&event.target.tagName!="INS")||!ok){if(tmp.drag_help!==false)tmp.drag_help.find("li:eq(0) ins").addClass("forbidden");tmp.move_type=false;tmp.ref_node=false;tree_component.drag_drop.marker.hide()}event.preventDefault();event.stopPropagation();return false}return true};$(function(){$(document).bind("mousemove.jstree",tree_component.mousemove);$(document).bind("mouseup.jstree",tree_component.mouseup)});tree_component.cut_copy={copy_nodes:false,cut_nodes:false};tree_component.css=false;tree_component.get_css=function(rule_name,delete_flag){rule_name=rule_name.toLowerCase();var css_rules=tree_component.css.cssRules||tree_component.css.rules;var j=0;do{if(css_rules.length&&j>css_rules.length+5)return false;if(css_rules[j].selectorText&&css_rules[j].selectorText.toLowerCase()==rule_name){if(delete_flag==true){if(tree_component.css.removeRule)document.styleSheets[i].removeRule(j);if(tree_component.css.deleteRule)document.styleSheets[i].deleteRule(j);return true}else return css_rules[j]}}while(css_rules[++j]);return false};tree_component.add_css=function(rule_name){if(tree_component.get_css(rule_name))return false;(tree_component.css.insertRule)?tree_component.css.insertRule(rule_name+' { }',0):tree_component.css.addRule(rule_name,null,0);return tree_component.get_css(rule_name)};tree_component.remove_css=function(rule_name){return tree_component.get_css(rule_name,true)};tree_component.add_sheet=function(opts){if(opts.str){var tmp=document.createElement("style");tmp.setAttribute('type',"text/css");if(tmp.styleSheet){document.getElementsByTagName("head")[0].appendChild(tmp);tmp.styleSheet.cssText=opts.str}else{tmp.appendChild(document.createTextNode(opts.str));document.getElementsByTagName("head")[0].appendChild(tmp)}return tmp.sheet||tmp.styleSheet}if(opts.url){if(document.createStyleSheet){try{document.createStyleSheet(opts.url)}catch(e){}}else{var newSS=document.createElement('link');newSS.rel='stylesheet';newSS.type='text/css';newSS.media="all";newSS.href=opts.url;document.getElementsByTagName("head")[0].appendChild(newSS);return newSS.styleSheet}}};$(function(){var u=navigator.userAgent.toLowerCase();var v=(u.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,'0'])[1];var css='/* TREE LAYOUT */ .tree ul { margin:0 0 0 5px; padding:0 0 0 0; list-style-type:none; } .tree li { display:block; min-height:18px; line-height:18px; padding:0 0 0 15px; margin:0 0 0 0; /* Background fix */ clear:both; } .tree li ul { display:none; } .tree li a, .tree li span { display:inline-block;line-height:16px;height:16px;color:black;white-space:nowrap;text-decoration:none;padding:1px 4px 1px 4px;margin:0; } .tree li a:focus { outline: none; } .tree li a input, .tree li span input { margin:0;padding:0 0;display:inline-block;height:12px !important;border:1px solid white;background:white;font-size:10px;font-family:Verdana; } .tree li a input:not([class="xxx"]), .tree li span input:not([class="xxx"]) { padding:1px 0; } /* FOR DOTS */ .tree .ltr li.last { float:left; } .tree > ul li.last { overflow:visible; } /* OPEN OR CLOSE */ .tree li.open ul { display:block; } .tree li.closed ul { display:none !important; } /* FOR DRAGGING */ #jstree-dragged { position:absolute; top:-10px; left:-10px; margin:0; padding:0; } #jstree-dragged ul ul ul { display:none; } #jstree-marker { padding:0; margin:0; line-height:5px; font-size:1px; overflow:hidden; height:5px; position:absolute; left:-45px; top:-30px; z-index:1000; background-color:transparent; background-repeat:no-repeat; display:none; } #jstree-marker.marker { width:45px; background-position:-32px top; } #jstree-marker.marker_plus { width:5px; background-position:right top; } /* BACKGROUND DOTS */ .tree li li { overflow:hidden; } .tree > .ltr > li { display:table; } /* ICONS */ .tree ul ins { display:inline-block; text-decoration:none; width:16px; height:16px; } .tree .ltr ins { margin:0 4px 0 0px; } ';if(/msie/.test(u)&&!/opera/.test(u)){if(parseInt(v)==6)css+='.tree li { height:18px; zoom:1; } .tree li li { overflow:visible; } .tree .ltr li.last { margin-top: expression( (this.previousSibling && /open/.test(this.previousSibling.className) ) ? "-2px" : "0"); } .marker { width:45px; background-position:-32px top; } .marker_plus { width:5px; background-position:right top; }';if(parseInt(v)==7)css+='.tree li li { overflow:visible; } .tree .ltr li.last { margin-top: expression( (this.previousSibling && /open/.test(this.previousSibling.className) ) ? "-2px" : "0"); }'}if(/opera/.test(u))css+='.tree > ul > li.last:after { content:"."; display: block; height:1px; clear:both; visibility:hidden; }';if(/mozilla/.test(u)&&!/(compatible|webkit)/.test(u)&&v.indexOf("1.8")==0)css+='.tree .ltr li a { display:inline; float:left; } .tree li ul { clear:both; }';tree_component.css=tree_component.add_sheet({str:css})})})(jQuery);(function($){$.extend($.tree.datastores,{"html":function(){return{get:function(obj,tree,opts){return obj&&$(obj).size()?$('<div>').append(tree.get_node(obj).clone()).html():tree.container.children("ul:eq(0)").html()},parse:function(data,tree,opts,callback){if(callback)callback.call(null,data);return data},load:function(data,tree,opts,callback){if(opts.url){$.ajax({'type':opts.method,'url':opts.url,'data':data,'dataType':"html",'success':function(d,textStatus){callback.call(null,d)},'error':function(xhttp,textStatus,errorThrown){callback.call(null,false);tree.error(errorThrown+" "+textStatus)}})}else{callback.call(null,opts.staticData||tree.container.children("ul:eq(0)").html())}}}},"json":function(){return{get:function(obj,tree,opts){var _this=this;if(!obj||$(obj).size()==0)obj=tree.container.children("ul").children("li");else obj=$(obj);if(!opts)opts={};if(!opts.outer_attrib)opts.outer_attrib=["id","rel","class"];if(!opts.inner_attrib)opts.inner_attrib=[];if(obj.size()>1){var arr=[];obj.each(function(){arr.push(_this.get(this,tree,opts))});return arr}if(obj.size()==0)return[];var json={attributes:{},data:{}};if(obj.hasClass("open"))json.state="open";if(obj.hasClass("closed"))json.state="closed";for(var i in opts.outer_attrib){if(!opts.outer_attrib.hasOwnProperty(i))continue;var val=(opts.outer_attrib[i]=="class")?obj.attr(opts.outer_attrib[i]).replace(/(^| )last( |$)/ig," ").replace(/(^| )(leaf|closed|open)( |$)/ig," "):obj.attr(opts.outer_attrib[i]);if(typeof val!="undefined"&&val.toString().replace(" ","").length>0)json.attributes[opts.outer_attrib[i]]=val;delete val}if(tree.settings.languages.length){for(var i in tree.settings.languages){if(!tree.settings.languages.hasOwnProperty(i))continue;var a=obj.children("a."+tree.settings.languages[i]);if(opts.force||opts.inner_attrib.length||a.children("ins").get(0).style.backgroundImage.toString().length||a.children("ins").get(0).className.length){json.data[tree.settings.languages[i]]={};json.data[tree.settings.languages[i]].title=tree.get_text(obj,tree.settings.languages[i]);if(a.children("ins").get(0).style.className.length){json.data[tree.settings.languages[i]].icon=a.children("ins").get(0).style.className}if(a.children("ins").get(0).style.backgroundImage.length){json.data[tree.settings.languages[i]].icon=a.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","")}if(opts.inner_attrib.length){json.data[tree.settings.languages[i]].attributes={};for(var j in opts.inner_attrib){if(!opts.inner_attrib.hasOwnProperty(j))continue;var val=a.attr(opts.inner_attrib[j]);if(typeof val!="undefined"&&val.toString().replace(" ","").length>0)json.data[tree.settings.languages[i]].attributes[opts.inner_attrib[j]]=val;delete val}}}else{json.data[tree.settings.languages[i]]=tree.get_text(obj,tree.settings.languages[i])}}}else{var a=obj.children("a");json.data.title=tree.get_text(obj);if(a.children("ins").size()&&a.children("ins").get(0).className.length){json.data.icon=a.children("ins").get(0).className}if(a.children("ins").size()&&a.children("ins").get(0).style.backgroundImage.length){json.data.icon=a.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","")}if(opts.inner_attrib.length){json.data.attributes={};for(var j in opts.inner_attrib){if(!opts.inner_attrib.hasOwnProperty(j))continue;var val=a.attr(opts.inner_attrib[j]);if(typeof val!="undefined"&&val.toString().replace(" ","").length>0)json.data.attributes[opts.inner_attrib[j]]=val;delete val}}}if(obj.children("ul").size()>0){json.children=[];obj.children("ul").children("li").each(function(){json.children.push(_this.get(this,tree,opts))})}return json},parse:function(data,tree,opts,callback){if(Object.prototype.toString.apply(data)==="[object Array]"){var str='';for(var i=0;i<data.length;i++){if(typeof data[i]=="function")continue;str+=this.parse(data[i],tree,opts)}if(callback)callback.call(null,str);return str}if(!data||!data.data){if(callback)callback.call(null,false);return""}var str='';str+="<li ";var cls=false;if(data.attributes){for(var i in data.attributes){if(!data.attributes.hasOwnProperty(i))continue;if(i=="class"){str+=" class='"+data.attributes[i]+" ";if(data.state=="closed"||data.state=="open")str+=" "+data.state+" ";str+="' ";cls=true}else str+=" "+i+"='"+data.attributes[i]+"' "}}if(!cls&&(data.state=="closed"||data.state=="open"))str+=" class='"+data.state+"' ";str+=">";if(tree.settings.languages.length){for(var i=0;i<tree.settings.languages.length;i++){var attr={};attr["href"]="";attr["style"]="";attr["class"]=tree.settings.languages[i];if(data.data[tree.settings.languages[i]]&&(typeof data.data[tree.settings.languages[i]].attributes).toLowerCase()!="undefined"){for(var j in data.data[tree.settings.languages[i]].attributes){if(!data.data[tree.settings.languages[i]].attributes.hasOwnProperty(j))continue;if(j=="style"||j=="class")attr[j]+=" "+data.data[tree.settings.languages[i]].attributes[j];else attr[j]=data.data[tree.settings.languages[i]].attributes[j]}}str+="<a";for(var j in attr){if(!attr.hasOwnProperty(j))continue;str+=' '+j+'="'+attr[j]+'" '}str+=">";if(data.data[tree.settings.languages[i]]&&data.data[tree.settings.languages[i]].icon){str+="<ins "+(data.data[tree.settings.languages[i]].icon.indexOf("/")==-1?" class='"+data.data[tree.settings.languages[i]].icon+"' ":" style='background-image:url(\""+data.data[tree.settings.languages[i]].icon+"\");' ")+">&nbsp;</ins>"}else str+="<ins>&nbsp;</ins>";str+=((typeof data.data[tree.settings.languages[i]].title).toLowerCase()!="undefined"?data.data[tree.settings.languages[i]].title:data.data[tree.settings.languages[i]])+"</a>"}}else{var attr={};attr["href"]="";attr["style"]="";attr["class"]="";if((typeof data.data.attributes).toLowerCase()!="undefined"){for(var i in data.data.attributes){if(!data.data.attributes.hasOwnProperty(i))continue;if(i=="style"||i=="class")attr[i]+=" "+data.data.attributes[i];else attr[i]=data.data.attributes[i]}}str+="<a";for(var i in attr){if(!attr.hasOwnProperty(i))continue;str+=' '+i+'="'+attr[i]+'" '}str+=">";if(data.data.icon){str+="<ins "+(data.data.icon.indexOf("/")==-1?" class='"+data.data.icon+"' ":" style='background-image:url(\""+data.data.icon+"\");' ")+">&nbsp;</ins>"}else str+="<ins>&nbsp;</ins>";str+=((typeof data.data.title).toLowerCase()!="undefined"?data.data.title:data.data)+"</a>"}if(data.children&&data.children.length){str+='<ul>';for(var i=0;i<data.children.length;i++){str+=this.parse(data.children[i],tree,opts)}str+='</ul>'}str+="</li>";if(callback)callback.call(null,str);return str},load:function(data,tree,opts,callback){if(opts.staticData){callback.call(null,opts.staticData)}else{$.ajax({'type':opts.method,'url':opts.url,'data':data,'dataType':"json",'success':function(d,textStatus){callback.call(null,d)},'error':function(xhttp,textStatus,errorThrown){callback.call(null,false);tree.error(errorThrown+" "+textStatus)}})}}}}})})(jQuery);
check_move : function (nod, ref_node, how) { if(this.locked) return false; if($(ref_node).closest("li.dragged").size()) return false; var tree1 = nod.parents(".tree:eq(0)").get(0); var tree2 = ref_node === -1 ? this.container.get(0) : ref_node.parents(".tree:eq(0)").get(0); // if different trees if(tree1 && tree1 != tree2) { var m = $.tree.reference(tree2.id).settings.rules.multitree; if(typeof m == "object") m = $.makeArray(m); if(m == "none" || ($.isArray(m) && $.inArray(tree1.id, m) == -1)) return false; } var p = (how != "inside") ? this.parent(ref_node) : this.get_node(ref_node); if(ref_node === -1) p = -1; nod = this.get_node(nod); if(p == false) return false; var r = { max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", p) : -1, max_children : this.settings.rules.use_max_children ? this.check("max_children", p) : -1, valid_children : this.check("valid_children", p) }; var nod_type = (typeof nod == "string") ? nod : this.get_type(nod); if(typeof r.valid_children != "undefined" && (r.valid_children == "none" || (typeof r.valid_children == "object" && $.inArray(nod_type, $.makeArray(r.valid_children)) == -1))) return false; if(this.settings.rules.use_max_children) { if(typeof r.max_children != "undefined" && r.max_children != -1) { if(r.max_children == 0) return false; var c_count = 1; if(tree_component.drag_drop.moving == true && tree_component.drag_drop.foreign == false) { c_count = tree_component.drag_drop.dragged.size(); c_count = c_count - p.find('> ul > li.dragged').size(); } if(r.max_children < p.find('> ul > li').size() + c_count) return false; } } if(this.settings.rules.use_max_depth) { if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("MOVE: MAX-DEPTH REACHED"); // check for max_depth up the chain var mx = (r.max_depth > 0) ? r.max_depth : false; var i = 0; var t = p; while(t !== -1) { t = this.parent(t); i ++; var m = this.check("max_depth",t); if(m >= 0) { mx = (mx === false) ? (m - i) : Math.min(mx, m - i); } if(mx !== false && mx <= 0) return this.error("MOVE: MAX-DEPTH REACHED"); } if(mx !== false && mx <= 0) return this.error("MOVE: MAX-DEPTH REACHED"); if(mx !== false) { var incr = 1; if(typeof nod != "string") { var t = nod; // possible async problem - when nodes are not all loaded down the chain while(t.size() > 0) { if(mx - incr < 0) return this.error("MOVE: MAX-DEPTH REACHED"); t = t.children("ul").children("li"); incr ++; } } } } if(this.callback("check_move", [nod, ref_node, how, this]) == false) return false; return true; },
x.optimizeBookmark();x.trim(false,true);var u=x.startContainer,v=x.startOffset,w=u.getChild(v);if(w)t.insertBefore(w);else u.append(t);if(t.getParent().equals(x.endContainer))x.endOffset++;x.setStartBefore(t);},moveToPosition:function(t,u){this.setStartAt(t,u);this.collapse(true);},selectNodeContents:function(t){this.setStart(t,0);this.setEnd(t,t.type==3?t.getLength():t.getChildCount());},setStart:function(t,u){var v=this;v.startContainer=t;v.startOffset=u;if(!v.endContainer){v.endContainer=t;v.endOffset=u;}l(v);},setEnd:function(t,u){var v=this;v.endContainer=t;v.endOffset=u;if(!v.startContainer){v.startContainer=t;v.startOffset=u;}l(v);},setStartAfter:function(t){this.setStart(t.getParent(),t.getIndex()+1);},setStartBefore:function(t){this.setStart(t.getParent(),t.getIndex());},setEndAfter:function(t){this.setEnd(t.getParent(),t.getIndex()+1);},setEndBefore:function(t){this.setEnd(t.getParent(),t.getIndex());},setStartAt:function(t,u){var v=this;switch(u){case 1:v.setStart(t,0);break;case 2:if(t.type==3)v.setStart(t,t.getLength());else v.setStart(t,t.getChildCount());break;case 3:v.setStartBefore(t);break;case 4:v.setStartAfter(t);}l(v);},setEndAt:function(t,u){var v=this;switch(u){case 1:v.setEnd(t,0);break;case 2:if(t.type==3)v.setEnd(t,t.getLength());else v.setEnd(t,t.getChildCount());break;case 3:v.setEndBefore(t);break;case 4:v.setEndAfter(t);}l(v);},fixBlock:function(t,u){var x=this;var v=x.createBookmark(),w=x.document.createElement(u);x.collapse(t);x.enlarge(2);x.extractContents().appendTo(w);w.trim();if(!c)w.appendBogus();x.insertNode(w);x.moveToBookmark(v);return w;},splitBlock:function(t){var D=this;var u=new d.elementPath(D.startContainer),v=new d.elementPath(D.endContainer),w=u.blockLimit,x=v.blockLimit,y=u.block,z=v.block,A=null;if(!w.equals(x))return null;if(t!='br'){if(!y){y=D.fixBlock(true,t);z=new d.elementPath(D.endContainer).block;}if(!z)z=D.fixBlock(false,t);}var B=y&&D.checkStartOfBlock(),C=z&&D.checkEndOfBlock();D.deleteContents();if(y&&y.equals(z))if(C){A=new d.elementPath(D.startContainer);D.moveToPosition(z,4);z=null;}else if(B){A=new d.elementPath(D.startContainer);D.moveToPosition(y,3);y=null;}else{z=D.splitElement(y);if(!c&&!y.is('ul','ol'))y.appendBogus();}return{previousBlock:y,nextBlock:z,wasStartOfBlock:B,wasEndOfBlock:C,elementPath:A};},splitElement:function(t){var w=this;if(!w.collapsed)return null;w.setEndAt(t,2);var u=w.extractContents(),v=t.clone(false);u.appendTo(v);v.insertAfter(t);w.moveToPosition(t,4);return v;},checkBoundaryOfElement:function(t,u){var v=this.clone(); v[u==1?'setStartAt':'setEndAt'](t,u==1?1:2);var w=new d.walker(v),x=false;w.evaluator=p;return w[u==1?'checkBackward':'checkForward']();},checkStartOfBlock:function(){var z=this;var t=z.startContainer,u=z.startOffset;if(u&&t.type==3){var v=e.ltrim(t.substring(0,u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.startContainer),x=z.clone();x.collapse(true);x.setStartAt(w.block||w.blockLimit,1);var y=new d.walker(x);y.evaluator=o(true);return y.checkBackward();},checkEndOfBlock:function(){var z=this;var t=z.endContainer,u=z.endOffset;if(t.type==3){var v=e.rtrim(t.substring(u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.endContainer),x=z.clone();x.collapse(false);x.setEndAt(w.block||w.blockLimit,2);var y=new d.walker(x);y.evaluator=o(false);return y.checkForward();},moveToElementEditablePosition:function(t,u){var v;if(f.$empty[t.getName()])return false;while(t&&t.type==1){v=t.isEditable();if(v)this.moveToPosition(t,u?2:1);else if(f.$inline[t.getName()]){this.moveToPosition(t,u?4:3);return true;}if(f.$empty[t.getName()])t=t[u?'getPrevious':'getNext'](s);else t=t[u?'getLast':'getFirst'](s);if(t&&t.type==3){this.moveToPosition(t,u?4:3);return true;}}return v;},moveToElementEditStart:function(t){return this.moveToElementEditablePosition(t);},moveToElementEditEnd:function(t){return this.moveToElementEditablePosition(t,true);},getEnclosedNode:function(){var t=this.clone(),u=new d.walker(t),v=d.walker.bookmark(true),w=d.walker.whitespaces(true),x=function(z){return w(z)&&v(z);};t.evaluator=x;var y=u.next();u.reset();return y&&y.equals(u.previous())?y:null;},getTouchedStartNode:function(){var t=this.startContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.startOffset)||t;},getTouchedEndNode:function(){var t=this.endContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.endOffset-1)||t;}};})();a.POSITION_AFTER_START=1;a.POSITION_BEFORE_END=2;a.POSITION_BEFORE_START=3;a.POSITION_AFTER_END=4;a.ENLARGE_ELEMENT=1;a.ENLARGE_BLOCK_CONTENTS=2;a.ENLARGE_LIST_ITEM_CONTENTS=3;a.START=1;a.END=2;a.STARTEND=3;a.SHRINK_ELEMENT=1;a.SHRINK_TEXT=2;(function(){if(b.webkit){b.hc=false;return;}var l=c&&b.version<7,m=c&&b.version==7,n=l?a.basePath+'images/spacer.gif':m?'about:blank':'data:image/png;base64,',o=h.createFromHtml('<div style="width:0px;height:0px;position:absolute;left:-10000px;background-image:url('+n+')"></div>',a.document);o.appendTo(a.document.getHead());try{b.hc=o.getComputedStyle('background-image')=='none';
var u=w.extractContents(),v=t.clone(false);u.appendTo(v);v.insertAfter(t);w.moveToPosition(t,4);return v;},checkBoundaryOfElement:function(t,u){var v=u==1,w=this.clone();w.collapse(v);w[v?'setStartAt':'setEndAt'](t,v?1:2);var x=new d.walker(w);x.evaluator=p;return x[v?'checkBackward':'checkForward']();},checkStartOfBlock:function(){var z=this;var t=z.startContainer,u=z.startOffset;if(u&&t.type==3){var v=e.ltrim(t.substring(0,u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.startContainer),x=z.clone();x.collapse(true);x.setStartAt(w.block||w.blockLimit,1);var y=new d.walker(x);y.evaluator=o(true);return y.checkBackward();},checkEndOfBlock:function(){var z=this;var t=z.endContainer,u=z.endOffset;if(t.type==3){var v=e.rtrim(t.substring(u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.endContainer),x=z.clone();x.collapse(false);x.setEndAt(w.block||w.blockLimit,2);var y=new d.walker(x);y.evaluator=o(false);return y.checkForward();},moveToElementEditablePosition:function(t,u){var v;if(f.$empty[t.getName()])return false;while(t&&t.type==1){v=t.isEditable();if(v)this.moveToPosition(t,u?2:1);else if(f.$inline[t.getName()]){this.moveToPosition(t,u?4:3);return true;}if(f.$empty[t.getName()])t=t[u?'getPrevious':'getNext'](s);else t=t[u?'getLast':'getFirst'](s);if(t&&t.type==3){this.moveToPosition(t,u?4:3);return true;}}return v;},moveToElementEditStart:function(t){return this.moveToElementEditablePosition(t);},moveToElementEditEnd:function(t){return this.moveToElementEditablePosition(t,true);},getEnclosedNode:function(){var t=this.clone();t.optimize();if(t.startContainer.type!=1||t.endContainer.type!=1)return null;var u=new d.walker(t),v=d.walker.bookmark(true),w=d.walker.whitespaces(true),x=function(z){return w(z)&&v(z);};t.evaluator=x;var y=u.next();u.reset();return y&&y.equals(u.previous())?y:null;},getTouchedStartNode:function(){var t=this.startContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.startOffset)||t;},getTouchedEndNode:function(){var t=this.endContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.endOffset-1)||t;}};})();a.POSITION_AFTER_START=1;a.POSITION_BEFORE_END=2;a.POSITION_BEFORE_START=3;a.POSITION_AFTER_END=4;a.ENLARGE_ELEMENT=1;a.ENLARGE_BLOCK_CONTENTS=2;a.ENLARGE_LIST_ITEM_CONTENTS=3;a.START=1;a.END=2;a.STARTEND=3;a.SHRINK_ELEMENT=1;a.SHRINK_TEXT=2;(function(){d.rangeList=function(n){if(n instanceof d.rangeList)return n;if(!n)n=[];else if(n instanceof d.range)n=[n];return e.extend(n,l);
x.optimizeBookmark();x.trim(false,true);var u=x.startContainer,v=x.startOffset,w=u.getChild(v);if(w)t.insertBefore(w);else u.append(t);if(t.getParent().equals(x.endContainer))x.endOffset++;x.setStartBefore(t);},moveToPosition:function(t,u){this.setStartAt(t,u);this.collapse(true);},selectNodeContents:function(t){this.setStart(t,0);this.setEnd(t,t.type==3?t.getLength():t.getChildCount());},setStart:function(t,u){var v=this;v.startContainer=t;v.startOffset=u;if(!v.endContainer){v.endContainer=t;v.endOffset=u;}l(v);},setEnd:function(t,u){var v=this;v.endContainer=t;v.endOffset=u;if(!v.startContainer){v.startContainer=t;v.startOffset=u;}l(v);},setStartAfter:function(t){this.setStart(t.getParent(),t.getIndex()+1);},setStartBefore:function(t){this.setStart(t.getParent(),t.getIndex());},setEndAfter:function(t){this.setEnd(t.getParent(),t.getIndex()+1);},setEndBefore:function(t){this.setEnd(t.getParent(),t.getIndex());},setStartAt:function(t,u){var v=this;switch(u){case 1:v.setStart(t,0);break;case 2:if(t.type==3)v.setStart(t,t.getLength());else v.setStart(t,t.getChildCount());break;case 3:v.setStartBefore(t);break;case 4:v.setStartAfter(t);}l(v);},setEndAt:function(t,u){var v=this;switch(u){case 1:v.setEnd(t,0);break;case 2:if(t.type==3)v.setEnd(t,t.getLength());else v.setEnd(t,t.getChildCount());break;case 3:v.setEndBefore(t);break;case 4:v.setEndAfter(t);}l(v);},fixBlock:function(t,u){var x=this;var v=x.createBookmark(),w=x.document.createElement(u);x.collapse(t);x.enlarge(2);x.extractContents().appendTo(w);w.trim();if(!c)w.appendBogus();x.insertNode(w);x.moveToBookmark(v);return w;},splitBlock:function(t){var D=this;var u=new d.elementPath(D.startContainer),v=new d.elementPath(D.endContainer),w=u.blockLimit,x=v.blockLimit,y=u.block,z=v.block,A=null;if(!w.equals(x))return null;if(t!='br'){if(!y){y=D.fixBlock(true,t);z=new d.elementPath(D.endContainer).block;}if(!z)z=D.fixBlock(false,t);}var B=y&&D.checkStartOfBlock(),C=z&&D.checkEndOfBlock();D.deleteContents();if(y&&y.equals(z))if(C){A=new d.elementPath(D.startContainer);D.moveToPosition(z,4);z=null;}else if(B){A=new d.elementPath(D.startContainer);D.moveToPosition(y,3);y=null;}else{z=D.splitElement(y);if(!c&&!y.is('ul','ol'))y.appendBogus();}return{previousBlock:y,nextBlock:z,wasStartOfBlock:B,wasEndOfBlock:C,elementPath:A};},splitElement:function(t){var w=this;if(!w.collapsed)return null;w.setEndAt(t,2);var u=w.extractContents(),v=t.clone(false);u.appendTo(v);v.insertAfter(t);w.moveToPosition(t,4);return v;},checkBoundaryOfElement:function(t,u){var v=this.clone();v[u==1?'setStartAt':'setEndAt'](t,u==1?1:2);var w=new d.walker(v),x=false;w.evaluator=p;return w[u==1?'checkBackward':'checkForward']();},checkStartOfBlock:function(){var z=this;var t=z.startContainer,u=z.startOffset;if(u&&t.type==3){var v=e.ltrim(t.substring(0,u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.startContainer),x=z.clone();x.collapse(true);x.setStartAt(w.block||w.blockLimit,1);var y=new d.walker(x);y.evaluator=o(true);return y.checkBackward();},checkEndOfBlock:function(){var z=this;var t=z.endContainer,u=z.endOffset;if(t.type==3){var v=e.rtrim(t.substring(u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.endContainer),x=z.clone();x.collapse(false);x.setEndAt(w.block||w.blockLimit,2);var y=new d.walker(x);y.evaluator=o(false);return y.checkForward();},moveToElementEditablePosition:function(t,u){var v;if(f.$empty[t.getName()])return false;while(t&&t.type==1){v=t.isEditable();if(v)this.moveToPosition(t,u?2:1);else if(f.$inline[t.getName()]){this.moveToPosition(t,u?4:3);return true;}if(f.$empty[t.getName()])t=t[u?'getPrevious':'getNext'](s);else t=t[u?'getLast':'getFirst'](s);if(t&&t.type==3){this.moveToPosition(t,u?4:3);return true;}}return v;},moveToElementEditStart:function(t){return this.moveToElementEditablePosition(t);},moveToElementEditEnd:function(t){return this.moveToElementEditablePosition(t,true);},getEnclosedNode:function(){var t=this.clone(),u=new d.walker(t),v=d.walker.bookmark(true),w=d.walker.whitespaces(true),x=function(z){return w(z)&&v(z);};t.evaluator=x;var y=u.next();u.reset();return y&&y.equals(u.previous())?y:null;},getTouchedStartNode:function(){var t=this.startContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.startOffset)||t;},getTouchedEndNode:function(){var t=this.endContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.endOffset-1)||t;}};})();a.POSITION_AFTER_START=1;a.POSITION_BEFORE_END=2;a.POSITION_BEFORE_START=3;a.POSITION_AFTER_END=4;a.ENLARGE_ELEMENT=1;a.ENLARGE_BLOCK_CONTENTS=2;a.ENLARGE_LIST_ITEM_CONTENTS=3;a.START=1;a.END=2;a.STARTEND=3;a.SHRINK_ELEMENT=1;a.SHRINK_TEXT=2;(function(){if(b.webkit){b.hc=false;return;}var l=c&&b.version<7,m=c&&b.version==7,n=l?a.basePath+'images/spacer.gif':m?'about:blank':'data:image/png;base64,',o=h.createFromHtml('<div style="width:0px;height:0px;position:absolute;left:-10000px;background-image:url('+n+')"></div>',a.document);o.appendTo(a.document.getHead());try{b.hc=o.getComputedStyle('background-image')=='none';
if(q.index)k.button._.instances[q.index]=null;}}}if(r.contextMenu)e.removeFunction(r.contextMenu._.functionId);if(r._.filebrowserFn)e.removeFunction(r._.filebrowserFn);r.fire('destroy');a.remove(r);a.fire('instanceDestroyed',null,r);},execCommand:function(l,m){var n=this.getCommand(l),o={name:l,commandData:m,command:n};if(n&&n.state!=0)if(this.fire('beforeCommandExec',o)!==true){o.returnValue=n.exec(o.commandData);if(!n.async&&this.fire('afterCommandExec',o)!==true)return o.returnValue;}return false;},getCommand:function(l){return this._.commands[l];},getData:function(){var n=this;n.fire('beforeGetData');var l=n._.data;if(typeof l!='string'){var m=n.element;if(m&&n.elementMode==1)l=m.is('textarea')?m.getValue():m.getHtml();else l='';}l={dataValue:l};n.fire('getData',l);return l.dataValue;},getSnapshot:function(){var l=this.fire('getSnapshot');if(typeof l!='string'){var m=this.element;if(m&&this.elementMode==1)l=m.is('textarea')?m.getValue():m.getHtml();}return l;},loadSnapshot:function(l){this.fire('loadSnapshot',l);},setData:function(l,m){if(m)this.on('dataReady',function(o){o.removeListener();m.call(o.editor);});var n={dataValue:l};this.fire('setData',n);this._.data=n.dataValue;this.fire('afterSetData',n);},insertHtml:function(l){this.fire('insertHtml',l);},insertElement:function(l){this.fire('insertElement',l);},checkDirty:function(){return this.mayBeDirty&&this._.previousValue!==this.getSnapshot();},resetDirty:function(){if(this.mayBeDirty)this._.previousValue=this.getSnapshot();},updateElement:function(){var n=this;var l=n.element;if(l&&n.elementMode==1){var m=n.getData();if(n.config.htmlEncodeOutput)m=e.htmlEncode(m);if(l.is('textarea'))l.setValue(m);else l.setHtml(m);}}});a.on('loaded',function(){var l=a.editor._pending;if(l){delete a.editor._pending;for(var m=0;m<l.length;m++)l[m]._init();}});a.htmlParser=function(){this._={htmlPartsRegex:new RegExp("<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:[^\"'>]+)|(?:\"[^\"]*\")|(?:'[^']*'))*)\\/?>))",'g')};};(function(){var l=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,m={checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1};a.htmlParser.prototype={onTagOpen:function(){},onTagClose:function(){},onText:function(){},onCDATA:function(){},onComment:function(){},parse:function(n){var A=this;var o,p,q=0,r;while(o=A._.htmlPartsRegex.exec(n)){var s=o.index;if(s>q){var t=n.substring(q,s);
if(n&&n.state!=0)if(this.fire('beforeCommandExec',o)!==true){o.returnValue=n.exec(o.commandData);if(!n.async&&this.fire('afterCommandExec',o)!==true)return o.returnValue;}return false;},getCommand:function(l){return this._.commands[l];},getData:function(){var n=this;n.fire('beforeGetData');var l=n._.data;if(typeof l!='string'){var m=n.element;if(m&&n.elementMode==1)l=m.is('textarea')?m.getValue():m.getHtml();else l='';}l={dataValue:l};n.fire('getData',l);return l.dataValue;},getSnapshot:function(){var l=this.fire('getSnapshot');if(typeof l!='string'){var m=this.element;if(m&&this.elementMode==1)l=m.is('textarea')?m.getValue():m.getHtml();}return l;},loadSnapshot:function(l){this.fire('loadSnapshot',l);},setData:function(l,m){if(m)this.on('dataReady',function(o){o.removeListener();m.call(o.editor);});var n={dataValue:l};this.fire('setData',n);this._.data=n.dataValue;this.fire('afterSetData',n);},insertHtml:function(l){this.fire('insertHtml',l);},insertElement:function(l){this.fire('insertElement',l);},checkDirty:function(){return this.mayBeDirty&&this._.previousValue!==this.getSnapshot();},resetDirty:function(){if(this.mayBeDirty)this._.previousValue=this.getSnapshot();},updateElement:function(){var n=this;var l=n.element;if(l&&n.elementMode==1){var m=n.getData();if(n.config.htmlEncodeOutput)m=e.htmlEncode(m);if(l.is('textarea'))l.setValue(m);else l.setHtml(m);}}});a.on('loaded',function(){var l=a.editor._pending;if(l){delete a.editor._pending;for(var m=0;m<l.length;m++)l[m]._init();}});a.htmlParser=function(){this._={htmlPartsRegex:new RegExp("<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:[^\"'>]+)|(?:\"[^\"]*\")|(?:'[^']*'))*)\\/?>))",'g')};};(function(){var l=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,m={checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1};a.htmlParser.prototype={onTagOpen:function(){},onTagClose:function(){},onText:function(){},onCDATA:function(){},onComment:function(){},parse:function(n){var A=this;var o,p,q=0,r;while(o=A._.htmlPartsRegex.exec(n)){var s=o.index;if(s>q){var t=n.substring(q,s);if(r)r.push(t);else A.onText(t);}q=A._.htmlPartsRegex.lastIndex;if(p=o[1]){p=p.toLowerCase();if(r&&f.$cdata[p]){A.onCDATA(r.join(''));r=null;}if(!r){A.onTagClose(p);continue;}}if(r){r.push(o[0]);continue;}if(p=o[3]){p=p.toLowerCase();if(/="/.test(p))continue;var u={},v,w=o[4],x=!!(w&&w.charAt(w.length-1)=='/');if(w)while(v=l.exec(w)){var y=v[1].toLowerCase(),z=v[2]||v[3]||v[4]||'';
if(q.index)k.button._.instances[q.index]=null;}}}if(r.contextMenu)e.removeFunction(r.contextMenu._.functionId);if(r._.filebrowserFn)e.removeFunction(r._.filebrowserFn);r.fire('destroy');a.remove(r);a.fire('instanceDestroyed',null,r);},execCommand:function(l,m){var n=this.getCommand(l),o={name:l,commandData:m,command:n};if(n&&n.state!=0)if(this.fire('beforeCommandExec',o)!==true){o.returnValue=n.exec(o.commandData);if(!n.async&&this.fire('afterCommandExec',o)!==true)return o.returnValue;}return false;},getCommand:function(l){return this._.commands[l];},getData:function(){var n=this;n.fire('beforeGetData');var l=n._.data;if(typeof l!='string'){var m=n.element;if(m&&n.elementMode==1)l=m.is('textarea')?m.getValue():m.getHtml();else l='';}l={dataValue:l};n.fire('getData',l);return l.dataValue;},getSnapshot:function(){var l=this.fire('getSnapshot');if(typeof l!='string'){var m=this.element;if(m&&this.elementMode==1)l=m.is('textarea')?m.getValue():m.getHtml();}return l;},loadSnapshot:function(l){this.fire('loadSnapshot',l);},setData:function(l,m){if(m)this.on('dataReady',function(o){o.removeListener();m.call(o.editor);});var n={dataValue:l};this.fire('setData',n);this._.data=n.dataValue;this.fire('afterSetData',n);},insertHtml:function(l){this.fire('insertHtml',l);},insertElement:function(l){this.fire('insertElement',l);},checkDirty:function(){return this.mayBeDirty&&this._.previousValue!==this.getSnapshot();},resetDirty:function(){if(this.mayBeDirty)this._.previousValue=this.getSnapshot();},updateElement:function(){var n=this;var l=n.element;if(l&&n.elementMode==1){var m=n.getData();if(n.config.htmlEncodeOutput)m=e.htmlEncode(m);if(l.is('textarea'))l.setValue(m);else l.setHtml(m);}}});a.on('loaded',function(){var l=a.editor._pending;if(l){delete a.editor._pending;for(var m=0;m<l.length;m++)l[m]._init();}});a.htmlParser=function(){this._={htmlPartsRegex:new RegExp("<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:[^\"'>]+)|(?:\"[^\"]*\")|(?:'[^']*'))*)\\/?>))",'g')};};(function(){var l=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,m={checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1};a.htmlParser.prototype={onTagOpen:function(){},onTagClose:function(){},onText:function(){},onCDATA:function(){},onComment:function(){},parse:function(n){var A=this;var o,p,q=0,r;while(o=A._.htmlPartsRegex.exec(n)){var s=o.index;if(s>q){var t=n.substring(q,s);
v[u==1?'setStartAt':'setEndAt'](t,u==1?1:2);var w=new d.walker(v),x=false;w.evaluator=p;return w[u==1?'checkBackward':'checkForward']();},checkStartOfBlock:function(){var z=this;var t=z.startContainer,u=z.startOffset;if(u&&t.type==3){var v=e.ltrim(t.substring(0,u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.startContainer),x=z.clone();x.collapse(true);x.setStartAt(w.block||w.blockLimit,1);var y=new d.walker(x);y.evaluator=o(true);return y.checkBackward();},checkEndOfBlock:function(){var z=this;var t=z.endContainer,u=z.endOffset;if(t.type==3){var v=e.rtrim(t.substring(u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.endContainer),x=z.clone();x.collapse(false);x.setEndAt(w.block||w.blockLimit,2);var y=new d.walker(x);y.evaluator=o(false);return y.checkForward();},moveToElementEditablePosition:function(t,u){var v;if(f.$empty[t.getName()])return false;while(t&&t.type==1){v=t.isEditable();if(v)this.moveToPosition(t,u?2:1);else if(f.$inline[t.getName()]){this.moveToPosition(t,u?4:3);return true;}if(f.$empty[t.getName()])t=t[u?'getPrevious':'getNext'](s);else t=t[u?'getLast':'getFirst'](s);if(t&&t.type==3){this.moveToPosition(t,u?4:3);return true;}}return v;},moveToElementEditStart:function(t){return this.moveToElementEditablePosition(t);},moveToElementEditEnd:function(t){return this.moveToElementEditablePosition(t,true);},getEnclosedNode:function(){var t=this.clone(),u=new d.walker(t),v=d.walker.bookmark(true),w=d.walker.whitespaces(true),x=function(z){return w(z)&&v(z);};t.evaluator=x;var y=u.next();u.reset();return y&&y.equals(u.previous())?y:null;},getTouchedStartNode:function(){var t=this.startContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.startOffset)||t;},getTouchedEndNode:function(){var t=this.endContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.endOffset-1)||t;}};})();a.POSITION_AFTER_START=1;a.POSITION_BEFORE_END=2;a.POSITION_BEFORE_START=3;a.POSITION_AFTER_END=4;a.ENLARGE_ELEMENT=1;a.ENLARGE_BLOCK_CONTENTS=2;a.ENLARGE_LIST_ITEM_CONTENTS=3;a.START=1;a.END=2;a.STARTEND=3;a.SHRINK_ELEMENT=1;a.SHRINK_TEXT=2;(function(){if(b.webkit){b.hc=false;return;}var l=c&&b.version<7,m=c&&b.version==7,n=l?a.basePath+'images/spacer.gif':m?'about:blank':'data:image/png;base64,',o=h.createFromHtml('<div style="width:0px;height:0px;position:absolute;left:-10000px;background-image:url('+n+')"></div>',a.document);o.appendTo(a.document.getHead());try{b.hc=o.getComputedStyle('background-image')=='none';
var u=w.extractContents(),v=t.clone(false);u.appendTo(v);v.insertAfter(t);w.moveToPosition(t,4);return v;},checkBoundaryOfElement:function(t,u){var v=u==1,w=this.clone();w.collapse(v);w[v?'setStartAt':'setEndAt'](t,v?1:2);var x=new d.walker(w);x.evaluator=p;return x[v?'checkBackward':'checkForward']();},checkStartOfBlock:function(){var z=this;var t=z.startContainer,u=z.startOffset;if(u&&t.type==3){var v=e.ltrim(t.substring(0,u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.startContainer),x=z.clone();x.collapse(true);x.setStartAt(w.block||w.blockLimit,1);var y=new d.walker(x);y.evaluator=o(true);return y.checkBackward();},checkEndOfBlock:function(){var z=this;var t=z.endContainer,u=z.endOffset;if(t.type==3){var v=e.rtrim(t.substring(u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.endContainer),x=z.clone();x.collapse(false);x.setEndAt(w.block||w.blockLimit,2);var y=new d.walker(x);y.evaluator=o(false);return y.checkForward();},moveToElementEditablePosition:function(t,u){var v;if(f.$empty[t.getName()])return false;while(t&&t.type==1){v=t.isEditable();if(v)this.moveToPosition(t,u?2:1);else if(f.$inline[t.getName()]){this.moveToPosition(t,u?4:3);return true;}if(f.$empty[t.getName()])t=t[u?'getPrevious':'getNext'](s);else t=t[u?'getLast':'getFirst'](s);if(t&&t.type==3){this.moveToPosition(t,u?4:3);return true;}}return v;},moveToElementEditStart:function(t){return this.moveToElementEditablePosition(t);},moveToElementEditEnd:function(t){return this.moveToElementEditablePosition(t,true);},getEnclosedNode:function(){var t=this.clone();t.optimize();if(t.startContainer.type!=1||t.endContainer.type!=1)return null;var u=new d.walker(t),v=d.walker.bookmark(true),w=d.walker.whitespaces(true),x=function(z){return w(z)&&v(z);};t.evaluator=x;var y=u.next();u.reset();return y&&y.equals(u.previous())?y:null;},getTouchedStartNode:function(){var t=this.startContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.startOffset)||t;},getTouchedEndNode:function(){var t=this.endContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.endOffset-1)||t;}};})();a.POSITION_AFTER_START=1;a.POSITION_BEFORE_END=2;a.POSITION_BEFORE_START=3;a.POSITION_AFTER_END=4;a.ENLARGE_ELEMENT=1;a.ENLARGE_BLOCK_CONTENTS=2;a.ENLARGE_LIST_ITEM_CONTENTS=3;a.START=1;a.END=2;a.STARTEND=3;a.SHRINK_ELEMENT=1;a.SHRINK_TEXT=2;(function(){d.rangeList=function(n){if(n instanceof d.rangeList)return n;if(!n)n=[];else if(n instanceof d.range)n=[n];return e.extend(n,l);
v[u==1?'setStartAt':'setEndAt'](t,u==1?1:2);var w=new d.walker(v),x=false;w.evaluator=p;return w[u==1?'checkBackward':'checkForward']();},checkStartOfBlock:function(){var z=this;var t=z.startContainer,u=z.startOffset;if(u&&t.type==3){var v=e.ltrim(t.substring(0,u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.startContainer),x=z.clone();x.collapse(true);x.setStartAt(w.block||w.blockLimit,1);var y=new d.walker(x);y.evaluator=o(true);return y.checkBackward();},checkEndOfBlock:function(){var z=this;var t=z.endContainer,u=z.endOffset;if(t.type==3){var v=e.rtrim(t.substring(u));if(v.length)return false;}z.trim();var w=new d.elementPath(z.endContainer),x=z.clone();x.collapse(false);x.setEndAt(w.block||w.blockLimit,2);var y=new d.walker(x);y.evaluator=o(false);return y.checkForward();},moveToElementEditablePosition:function(t,u){var v;if(f.$empty[t.getName()])return false;while(t&&t.type==1){v=t.isEditable();if(v)this.moveToPosition(t,u?2:1);else if(f.$inline[t.getName()]){this.moveToPosition(t,u?4:3);return true;}if(f.$empty[t.getName()])t=t[u?'getPrevious':'getNext'](s);else t=t[u?'getLast':'getFirst'](s);if(t&&t.type==3){this.moveToPosition(t,u?4:3);return true;}}return v;},moveToElementEditStart:function(t){return this.moveToElementEditablePosition(t);},moveToElementEditEnd:function(t){return this.moveToElementEditablePosition(t,true);},getEnclosedNode:function(){var t=this.clone(),u=new d.walker(t),v=d.walker.bookmark(true),w=d.walker.whitespaces(true),x=function(z){return w(z)&&v(z);};t.evaluator=x;var y=u.next();u.reset();return y&&y.equals(u.previous())?y:null;},getTouchedStartNode:function(){var t=this.startContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.startOffset)||t;},getTouchedEndNode:function(){var t=this.endContainer;if(this.collapsed||t.type!=1)return t;return t.getChild(this.endOffset-1)||t;}};})();a.POSITION_AFTER_START=1;a.POSITION_BEFORE_END=2;a.POSITION_BEFORE_START=3;a.POSITION_AFTER_END=4;a.ENLARGE_ELEMENT=1;a.ENLARGE_BLOCK_CONTENTS=2;a.ENLARGE_LIST_ITEM_CONTENTS=3;a.START=1;a.END=2;a.STARTEND=3;a.SHRINK_ELEMENT=1;a.SHRINK_TEXT=2;(function(){if(b.webkit){b.hc=false;return;}var l=c&&b.version<7,m=c&&b.version==7,n=l?a.basePath+'images/spacer.gif':m?'about:blank':'data:image/png;base64,',o=h.createFromHtml('<div style="width:0px;height:0px;position:absolute;left:-10000px;background-image:url('+n+')"></div>',a.document);o.appendTo(a.document.getHead());try{b.hc=o.getComputedStyle('background-image')=='none';
Zotero.debug("FORMATS"); Zotero.debug(foundFormat);
function checkFormats(text) { text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""); var xml = new XML(text); var foundFormat = new Object(); // this is such an ugly, disgusting hack, and I hate how Mozilla decided to neuter an ECMA standard for each(var format in xml.format) { var name = [email protected](); var lowerName = name.toLowerCase(); if(format.@namespace_uri == "http://www.loc.gov/mods/v3" || lowerName == "mods" || format.@docs == "http://www.loc.gov/standards/mods/") { if(!foundFormat["mods"] || lowerName.indexOf("full") != -1) { foundFormat["mods"] = escape(name); } } else if(lowerName.match(/^marc\b/)) { if(!foundFormat["marc"] || lowerName.indexOf("utf8") != -1) { foundFormat["marc"] = escape(name); } } else if(lowerName == "rdf_dc") { foundFormat["rdf"] = escape(name); } else if([email protected]() == "http://www.refman.com/support/risformat_intro.asp" || lowerName.match(/^ris\b/)) { if(!foundFormat["ris"] || lowerName.indexOf("utf8") != -1) { foundFormat["ris"] = escape(name); } } else if(lowerName == "bibtex") { foundFormat["bibtex"] = escape(name); } else if(lowerName == "endnote") { foundFormat["endnote"] = escape(name); } } Zotero.debug("FORMATS"); Zotero.debug(foundFormat); // loop through again, this time respecting preferences for each(var format in RECOGNIZABLE_FORMATS) { if(foundFormat[format]) return [format, foundFormat[format]]; } return false;}
if(instance.hasOwnProperty(i)) {
if(instance.hasOwnProperty(i) && typeof instance[i] !== 'function') {
function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; }
errors.push({property:path+' '+i,message:(typeof i) + " The property " + i +
errors.push({property:path+' '+i,message:(typeof instance[i]) + " The property " + i +
function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; }
if(string.length <= 4) return 'none';
if(string.length == 0) return 'none'; if(string.length <= 4) return 'weak';
checkPassword: function(string) { // init vars var score = 0; var uniqueChars = []; // less then 4 chars isn't a valid password if(string.length <= 4) return 'none'; // loop chars and add unique chars for(var i = 0; i<string.length; i++) { if($.inArray(string.charAt(i), uniqueChars) == -1) { uniqueChars.push(string.charAt(i)); } } // less then 3 unique chars is just weak if(uniqueChars.length < 3) return 'weak'; // more then 6 chars is good if(string.length >= 6) score++; // more then 8 is beter if(string.length >= 8) score++; // upper and lowercase? if((string.match(/[a-z]/)) && string.match(/[A-Z]/)) score += 2; // number? if(string.match(/\d+/)) score++; // special char? if(string.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) score++; // strong password if(score >= 4) return 'strong'; // ok if(score >= 2) return 'ok'; // fallback return 'weak'; },
path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i;
path += path ? typeof i === 'number' ? '[' + i + ']' : typeof i === 'undefined' ? '' : '.' + i : i;
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){
if((typeof schema !== 'object' || schema instanceof Array) && (path || typeof schema !== 'function')){ if(typeof schema === 'function'){
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){
if(typeof type === 'string' && type !== 'any' && (type === 'null' ? value !== null : typeof value !== type) && !(value instanceof Array && type === 'array') && !(type === 'integer' && value%1===0)){
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
}else if(typeof type == 'object'){
}else if(typeof type === 'object'){
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
if(value.hasOwnProperty(i)) {
if(value.hasOwnProperty(i) && typeof value[i] !== 'function') {
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
addError((typeof i) + " The property " + i +
addError((typeof value[i]) + " The property " + i +
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){
if(schema.pattern && typeof value === 'string' && !value.match(schema.pattern)){
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){
if(schema.maxLength && typeof value === 'string' && value.length > schema.maxLength){
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){
if(schema.minLength && typeof value === 'string' && value.length < schema.minLength){
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum &&
if(typeof schema.minimum !== undefined && typeof value === typeof schema.minimum &&
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum &&
if(typeof schema.maximum !== undefined && typeof value === typeof schema.maximum &&
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
if(schema['Enum']){ var enumer = schema['Enum'];
if(schema.Enum){ var enumer = schema.Enum;
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
if(typeof schema.maxDecimal == 'number' &&
if(typeof schema.maxDecimal === 'number' &&
function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; }
document.stopObserving('readystatechange', checkReadyState);
document.detachEvent('readystatechange', checkReadyState);
function checkReadyState() { if (document.readyState === 'complete') { document.stopObserving('readystatechange', checkReadyState); fireContentLoadedEvent(); } }
function(a){return g.firedTarget||a.target||a.srcElement};var da=false;this.capture=function(a){W();if(!(z&&a)){z=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){z&&a==z&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=
""}}};this.checkReleaseCapture=function(a,b){z&&a==z&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var f=[],l,n=0,o=b.length;n<o;n++){l=b[n];l.className.indexOf(a)!=-1&&f.push(l)}return f}};this.addCss=function(a,b){var f=document.styleSheets[0];f.insertRule(a+" { "+b+" }",f.cssRules.length)};this.addCssText=function(a){var b=document.getElementById("Wt-inline-css");
function(a){return g.firedTarget||a.target||a.srcElement};var da=false;this.capture=function(a){W();if(!(z&&a)){z=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){z&&a==z&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=
""};var B=null;this.firedTarget=null;this.target=function(a){return g.firedTarget||a.target||a.srcElement};var S=false,Y=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==
""};var B=null;this.firedTarget=null;this.target=function(a){return g.firedTarget||a.target||a.srcElement};var S=false,U=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==
""};var B=null;this.firedTarget=null;this.target=function(a){return g.firedTarget||a.target||a.srcElement};var S=false,Y=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==B&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var f=[],k,h=0,o=b.length;h<o;h++){k=b[h];k.className.indexOf(a)!=-1&&f.push(k)}return f}};this.addCss=function(a,b){var f=document.styleSheets[0];f.insertRule(a+" { "+b+" }",f.cssRules.length)};this.addCssText=function(a){var b=document.getElementById("Wt-inline-css");if(!b){b=document.createElement("style");
a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){C&&a==C&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");
a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==B&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");
a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){C&&a==C&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");
""};var B=null,S=false,Y=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==B&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);
"off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==B&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var f=[],h,k=0,o=b.length;k<o;k++){h=b[k];h.className.indexOf(a)!=-1&&f.push(h)}return f}};this.addCss=function(a,b){var f=document.styleSheets[0];f.insertRule(a+" { "+b+" }",f.cssRules.length)};this.addCssText=function(a){var b=document.getElementById("Wt-inline-css");
""};var B=null,S=false,Y=false;this.capture=function(a){ca();if(!(B&&a)){B=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){$(b).addClass("unselectable");b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{$(b).removeClass("unselectable");b.setAttribute("unselectable","off");b.onselectstart=""}}};this.checkReleaseCapture=function(a,b){B&&a==B&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);
"off");b.onselectstart=""}};this.checkReleaseCapture=function(a,b){G&&a==G&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var f=[],m,l=0,o=b.length;l<o;l++){m=b[l];m.className.indexOf(a)!=-1&&f.push(m)}return f}};this.addCss=function(a,b){var f=document.styleSheets[0];f.insertRule(a+" { "+b+" }",f.cssRules.length)};this.addCssText=function(a){var b=document.getElementById("Wt-inline-css");
"inline"};this.block=function(a){k.getElement(a).style.display="block"};this.show=function(a){k.getElement(a).style.display=""};var D=null,R=false;this.capture=function(a){Y();D=a;var b=document.body;if(b.setCapture)a!=null?b.setCapture():b.releaseCapture();if(a!=null){b.className="unselectable";b.setAttribute("unselectable","on");b.onselectstart="return false;"}else{b.className="";b.setAttribute("unselectable","off");b.onselectstart=""}};this.checkReleaseCapture=function(a,b){D&&a==D&&b.type=="mouseup"&& this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var f=[],m,l=0,n=b.length;l<n;l++){m=b[l];m.className.indexOf(a)!=-1&&f.push(m)}return f}};this.addCss=function(a,b){var f=document.styleSheets[0];f.insertRule(a+" { "+b+" }",f.cssRules.length)};this.addCssText=function(a){var b=document.getElementById("Wt-inline-css");if(!b){b=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(b)}if(b.styleSheet){var f=
"off");b.onselectstart=""}};this.checkReleaseCapture=function(a,b){G&&a==G&&b.type=="mouseup"&&this.capture(null)};this.getElementsByClassName=function(a,b){if(document.getElementsByClassName)return b.getElementsByClassName(a);else{b=b.getElementsByTagName("*");for(var f=[],m,l=0,o=b.length;l<o;l++){m=b[l];m.className.indexOf(a)!=-1&&f.push(m)}return f}};this.addCss=function(a,b){var f=document.styleSheets[0];f.insertRule(a+" { "+b+" }",f.cssRules.length)};this.addCssText=function(a){var b=document.getElementById("Wt-inline-css");
if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){
if(typeof type === 'string' && type !== 'any' && (type === 'null' ? value !== null : typeof value !== type) && !(value instanceof Array && type === 'array') && !(type === 'integer' && value%1===0)){
function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; }
}else if(typeof type == 'object'){
}else if(typeof type === 'object'){
function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; }
el.bind(event, function(e) {
el.bind(el.is(":date") ? "onHide" : event, function(e) {
checkValidity: function(els, e) { els = els || inputs; els = els.not(":disabled"); if (!els.length) { return true; } e = e || $.Event(); // onBeforeValidate e.type = "onBeforeValidate"; fire.trigger(e, [els]); if (e.isDefaultPrevented()) { return e.result; } var errs = [], event = conf.errorInputEvent + ".v"; // loop trough the inputs els.not(":radio:not(:checked)").each(function() { // field and it's error message container var msgs = [], el = $(this).unbind(event).data("messages", msgs); // loop all validator functions $.each(fns, function() { var fn = this, match = fn[0]; // match found if (el.filter(match).length) { // execute a validator function var returnValue = fn[1].call(self, el, el.val()); // validation failed. multiple substitutions can be returned with an array if (returnValue !== true) { // onBeforeFail e.type = "onBeforeFail"; fire.trigger(e, [el, match]); if (e.isDefaultPrevented()) { return false; } // overridden custom message var msg = el.attr(conf.messageAttr); if (msg) { msgs = [msg]; return false; } else { pushMessage(msgs, match, returnValue); } } } }); if (msgs.length) { errs.push({input: el, messages: msgs}); // trigger HTML5 ininvalid event el.trigger("OI", [msgs]); // begin validating upon error event type (such as keyup) if (conf.errorInputEvent) { el.bind(event, function(e) { self.checkValidity(el, e); }); } } if (conf.singleError && errs.length) { return false; } }); // validation done. now check that we have a proper effect at hand var eff = effects[conf.effect]; if (!eff) { throw "Validator: cannot find effect \"" + conf.effect + "\""; } // errors found if (errs.length) { self.invalidate(errs, e); return false; // no errors } else { // call the effect eff[1].call(self, els, e); // onSuccess callback e.type = "onSuccess"; fire.trigger(e, [els]); els.unbind(event); } return true; }
el.bind(event, function() { self.checkValidity(el);
el.bind(event, function(e) { self.checkValidity(el, e);
checkValidity: function(els, e) { els = els || inputs; els = els.not(":disabled"); if (!els.length) { return true; } e = e || $.Event(); // onBeforeValidate e.type = "onBeforeValidate"; fire.trigger(e, [els]); if (e.isDefaultPrevented()) { return e.result; } var errs = [], event = conf.errorInputEvent + ".v"; // loop trough the inputs els.each(function() { // field and it's error message container var msgs = [], el = $(this).unbind(event).data("messages", msgs); // loop all validator functions $.each(fns, function() { var fn = this, match = fn[0]; // match found if (el.filter(match).length) { // execute a validator function var returnValue = fn[1].call(self, el, el.val()); // validation failed. multiple substitutions can be returned with an array if (returnValue !== true) { // onBeforeFail e.type = "onBeforeFail"; fire.trigger(e, [el, match]); if (e.isDefaultPrevented()) { return false; } // overridden custom message var msg = el.attr(conf.messageAttr); if (msg) { msgs = [msg]; return false; } else { pushMessage(msgs, match, returnValue); } } } }); if (msgs.length) { errs.push({input: el, messages: msgs}); // trigger HTML5 ininvalid event el.trigger("oninvalid", [msgs]); // begin validating upon error event type (such as keyup) if (conf.errorInputEvent) { el.bind(event, function() { self.checkValidity(el); }); } } if (conf.singleError && errs.length) { return false; } }); // validation done. now check that we have a proper effect at hand var eff = effects[conf.effect]; if (!eff) { throw "Validator: cannot find effect \"" + conf.effect + "\""; } // errors found if (errs.length) { // onFail callback e.type = "onFail"; fire.trigger(e, [errs]); // call the effect if (!e.isDefaultPrevented()) { eff[0].call(self, errs); } return false; // no errors } else { // call the effect eff[1].call(self, els); // onSuccess callback e.type = "onSuccess"; fire.trigger(e); els.unbind(event); } return true; }
if (errs.length) { e.type = "onFail"; fire.trigger(e, [errs]); if (!e.isDefaultPrevented()) { eff[0].call(self, errs); }
if (errs.length) { self.invalidate(errs, e);
checkValidity: function(els, e) { els = els || inputs; els = els.not(":disabled"); if (!els.length) { return true; } e = e || $.Event(); // onBeforeValidate e.type = "onBeforeValidate"; fire.trigger(e, [els]); if (e.isDefaultPrevented()) { return e.result; } var errs = [], event = conf.errorInputEvent + ".v"; // loop trough the inputs els.each(function() { // field and it's error message container var msgs = [], el = $(this).unbind(event).data("messages", msgs); // loop all validator functions $.each(fns, function() { var fn = this, match = fn[0]; // match found if (el.filter(match).length) { // execute a validator function var returnValue = fn[1].call(self, el, el.val()); // validation failed. multiple substitutions can be returned with an array if (returnValue !== true) { // onBeforeFail e.type = "onBeforeFail"; fire.trigger(e, [el, match]); if (e.isDefaultPrevented()) { return false; } // overridden custom message var msg = el.attr(conf.messageAttr); if (msg) { msgs = [msg]; return false; } else { pushMessage(msgs, match, returnValue); } } } }); if (msgs.length) { errs.push({input: el, messages: msgs}); // trigger HTML5 ininvalid event el.trigger("oninvalid", [msgs]); // begin validating upon error event type (such as keyup) if (conf.errorInputEvent) { el.bind(event, function() { self.checkValidity(el); }); } } if (conf.singleError && errs.length) { return false; } }); // validation done. now check that we have a proper effect at hand var eff = effects[conf.effect]; if (!eff) { throw "Validator: cannot find effect \"" + conf.effect + "\""; } // errors found if (errs.length) { // onFail callback e.type = "onFail"; fire.trigger(e, [errs]); // call the effect if (!e.isDefaultPrevented()) { eff[0].call(self, errs); } return false; // no errors } else { // call the effect eff[1].call(self, els); // onSuccess callback e.type = "onSuccess"; fire.trigger(e); els.unbind(event); } return true; }
eff[1].call(self, els);
eff[1].call(self, els, e);
checkValidity: function(els, e) { els = els || inputs; els = els.not(":disabled"); if (!els.length) { return true; } e = e || $.Event(); // onBeforeValidate e.type = "onBeforeValidate"; fire.trigger(e, [els]); if (e.isDefaultPrevented()) { return e.result; } var errs = [], event = conf.errorInputEvent + ".v"; // loop trough the inputs els.each(function() { // field and it's error message container var msgs = [], el = $(this).unbind(event).data("messages", msgs); // loop all validator functions $.each(fns, function() { var fn = this, match = fn[0]; // match found if (el.filter(match).length) { // execute a validator function var returnValue = fn[1].call(self, el, el.val()); // validation failed. multiple substitutions can be returned with an array if (returnValue !== true) { // onBeforeFail e.type = "onBeforeFail"; fire.trigger(e, [el, match]); if (e.isDefaultPrevented()) { return false; } // overridden custom message var msg = el.attr(conf.messageAttr); if (msg) { msgs = [msg]; return false; } else { pushMessage(msgs, match, returnValue); } } } }); if (msgs.length) { errs.push({input: el, messages: msgs}); // trigger HTML5 ininvalid event el.trigger("oninvalid", [msgs]); // begin validating upon error event type (such as keyup) if (conf.errorInputEvent) { el.bind(event, function() { self.checkValidity(el); }); } } if (conf.singleError && errs.length) { return false; } }); // validation done. now check that we have a proper effect at hand var eff = effects[conf.effect]; if (!eff) { throw "Validator: cannot find effect \"" + conf.effect + "\""; } // errors found if (errs.length) { // onFail callback e.type = "onFail"; fire.trigger(e, [errs]); // call the effect if (!e.isDefaultPrevented()) { eff[0].call(self, errs); } return false; // no errors } else { // call the effect eff[1].call(self, els); // onSuccess callback e.type = "onSuccess"; fire.trigger(e); els.unbind(event); } return true; }
fire.trigger(e);
fire.trigger(e, [els]);
checkValidity: function(els, e) { els = els || inputs; els = els.not(":disabled"); if (!els.length) { return true; } e = e || $.Event(); // onBeforeValidate e.type = "onBeforeValidate"; fire.trigger(e, [els]); if (e.isDefaultPrevented()) { return e.result; } var errs = [], event = conf.errorInputEvent + ".v"; // loop trough the inputs els.each(function() { // field and it's error message container var msgs = [], el = $(this).unbind(event).data("messages", msgs); // loop all validator functions $.each(fns, function() { var fn = this, match = fn[0]; // match found if (el.filter(match).length) { // execute a validator function var returnValue = fn[1].call(self, el, el.val()); // validation failed. multiple substitutions can be returned with an array if (returnValue !== true) { // onBeforeFail e.type = "onBeforeFail"; fire.trigger(e, [el, match]); if (e.isDefaultPrevented()) { return false; } // overridden custom message var msg = el.attr(conf.messageAttr); if (msg) { msgs = [msg]; return false; } else { pushMessage(msgs, match, returnValue); } } } }); if (msgs.length) { errs.push({input: el, messages: msgs}); // trigger HTML5 ininvalid event el.trigger("oninvalid", [msgs]); // begin validating upon error event type (such as keyup) if (conf.errorInputEvent) { el.bind(event, function() { self.checkValidity(el); }); } } if (conf.singleError && errs.length) { return false; } }); // validation done. now check that we have a proper effect at hand var eff = effects[conf.effect]; if (!eff) { throw "Validator: cannot find effect \"" + conf.effect + "\""; } // errors found if (errs.length) { // onFail callback e.type = "onFail"; fire.trigger(e, [errs]); // call the effect if (!e.isDefaultPrevented()) { eff[0].call(self, errs); } return false; // no errors } else { // call the effect eff[1].call(self, els); // onSuccess callback e.type = "onSuccess"; fire.trigger(e); els.unbind(event); } return true; }
el.trigger("oninvalid", [msgs]);
el.trigger("OI", [msgs]);
checkValidity: function(els, e) { els = els || inputs; els = els.not(":disabled"); if (!els.length) { return true; } e = e || $.Event(); // onBeforeValidate e.type = "onBeforeValidate"; fire.trigger(e, [els]); if (e.isDefaultPrevented()) { return e.result; } var errs = [], event = conf.errorInputEvent + ".v"; // loop trough the inputs els.each(function() { // field and it's error message container var msgs = [], el = $(this).unbind(event).data("messages", msgs); // loop all validator functions $.each(fns, function() { var fn = this, match = fn[0]; // match found if (el.filter(match).length) { // execute a validator function var returnValue = fn[1].call(self, el, el.val()); // validation failed. multiple substitutions can be returned with an array if (returnValue !== true) { // onBeforeFail e.type = "onBeforeFail"; fire.trigger(e, [el, match]); if (e.isDefaultPrevented()) { return false; } // overridden custom message var msg = el.attr(conf.messageAttr); if (msg) { msgs = [msg]; return false; } else { pushMessage(msgs, match, returnValue); } } } }); if (msgs.length) { errs.push({input: el, messages: msgs}); // trigger HTML5 ininvalid event el.trigger("oninvalid", [msgs]); // begin validating upon error event type (such as keyup) if (conf.errorInputEvent) { el.bind(event, function(e) { self.checkValidity(el, e); }); } } if (conf.singleError && errs.length) { return false; } }); // validation done. now check that we have a proper effect at hand var eff = effects[conf.effect]; if (!eff) { throw "Validator: cannot find effect \"" + conf.effect + "\""; } // errors found if (errs.length) { self.invalidate(errs, e); return false; // no errors } else { // call the effect eff[1].call(self, els, e); // onSuccess callback e.type = "onSuccess"; fire.trigger(e, [els]); els.unbind(event); } return true; }
e)},siblings:function(a){return d.sibling(a.parentNode.firstChild,a)},children:function(a){return d.sibling(a.firstChild)},contents:function(a){return d.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:d.makeArray(a.childNodes)}},function(a,b){d.fn[a]=function(e,g){var h=d.map(this,b,e);Ba.test(a)||(g=e);if(g&&typeof g==="string")h=d.filter(g,h);h=this.length>1?d.unique(h):h;if((this.length>1||Da.test(g))&&Ca.test(a))h=h.reverse();return this.pushStack(h,a,I.call(arguments).join(","))}});
"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,e){return c.dir(a,"nextSibling",e)},prevUntil:function(a,b,e){return c.dir(a,"previousSibling",e)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(e,f){var h=c.map(this,b,e);Ba.test(a)||
e)},siblings:function(a){return d.sibling(a.parentNode.firstChild,a)},children:function(a){return d.sibling(a.firstChild)},contents:function(a){return d.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:d.makeArray(a.childNodes)}},function(a,b){d.fn[a]=function(e,g){var h=d.map(this,b,e);Ba.test(a)||(g=e);if(g&&typeof g==="string")h=d.filter(g,h);h=this.length>1?d.unique(h):h;if((this.length>1||Da.test(g))&&Ca.test(a))h=h.reverse();return this.pushStack(h,a,I.call(arguments).join(","))}});
if(console && console.log)console.log("hotlinkr >> type = " + seed[index]);
if(typeof(console) !== 'undefined' && typeof(console.log) !== 'undefined') console.log("hotlinkr >> type = " + seed[index]);
function chooseRandomly(obj,seed) { var index = -1, item = null; if( !seed ) { seed=[]; for(var key in obj){ if(obj.hasOwnProperty(key)) seed.push(key); } } index=Math.floor(Math.random() * seed.length); if(console && console.log)console.log("hotlinkr >> type = " + seed[index]); return obj[seed[index]]; }
(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:
t.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(i,n,m){if(typeof n.getElementsByClassName!=="undefined"&&!m)return n.getElementsByClassName(i[1])};g=null}}})();k.contains=t.documentElement.contains?function(g,i){return g!==i&&(g.contains?g.contains(i):true)}:t.documentElement.compareDocumentPosition?
(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:
0)){p=function(j,n,m,t){n=n||r;if(!t&&n.nodeType===9&&!P(n))try{return K(n.querySelectorAll(j),m)}catch(s){}return c(j,n,m,t)};for(var i in c)p[i]=c[i];f=null}}();(function(){var c=r.createElement("div");c.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!c.getElementsByClassName||c.getElementsByClassName("e").length===0)){c.lastChild.className="e";if(c.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(f,i,j){if(typeof i.getElementsByClassName!== "undefined"&&!j)return i.getElementsByClassName(f[1])};c=null}}})();var fa=r.compareDocumentPosition?function(c,f){return c.compareDocumentPosition(f)&16}:function(c,f){return c!==f&&(c.contains?c.contains(f):true)},P=function(c){return(c=(c?c.ownerDocument||c:0).documentElement)?c.nodeName!=="HTML":false},ea=function(c,f){var i=[],j="",n;for(f=f.nodeType?[f]:f;n=o.match.PSEUDO.exec(c);){j+=n[0];c=c.replace(o.match.PSEUDO,"")}c=o.relative[c]?c+"*":c;n=0;for(var m=f.length;n<m;n++)p(c,f[n],i);return p.filter(j,
"string"&&!/\W/.test(f)){var m=f=f.toLowerCase();n=b}n("previousSibling",f,j,c,m,i)}},find:{ID:function(c,f,i){if(typeof f.getElementById!=="undefined"&&!i)return(c=f.getElementById(c[1]))?[c]:[]},NAME:function(c,f){if(typeof f.getElementsByName!=="undefined"){var i=[];f=f.getElementsByName(c[1]);for(var j=0,n=f.length;j<n;j++)f[j].getAttribute("name")===c[1]&&i.push(f[j]);return i.length===0?null:i}},TAG:function(c,f){return f.getElementsByTagName(c[1])}},preFilter:{CLASS:function(c,f,i,j,n,m){c= " "+c[1].replace(/\\/g,"")+" ";if(m)return c;m=0;for(var t;(t=f[m])!=null;m++)if(t)if(n^(t.className&&(" "+t.className+" ").replace(/[\t\n]/g," ").indexOf(c)>=0))i||j.push(t);else if(i)f[m]=false;return false},ID:function(c){return c[1].replace(/\\/g,"")},TAG:function(c){return c[1].toLowerCase()},CHILD:function(c){if(c[1]==="nth"){var f=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(c[2]==="even"&&"2n"||c[2]==="odd"&&"2n+1"||!/\D/.test(c[2])&&"0n+"+c[2]||c[2]);c[2]=f[1]+(f[2]||1)-0;c[3]=f[3]-0}c[0]=h++;return c},
0)){p=function(j,n,m,t){n=n||r;if(!t&&n.nodeType===9&&!P(n))try{return K(n.querySelectorAll(j),m)}catch(s){}return c(j,n,m,t)};for(var i in c)p[i]=c[i];f=null}}();(function(){var c=r.createElement("div");c.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!c.getElementsByClassName||c.getElementsByClassName("e").length===0)){c.lastChild.className="e";if(c.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(f,i,j){if(typeof i.getElementsByClassName!=="undefined"&&!j)return i.getElementsByClassName(f[1])};c=null}}})();var fa=r.compareDocumentPosition?function(c,f){return c.compareDocumentPosition(f)&16}:function(c,f){return c!==f&&(c.contains?c.contains(f):true)},P=function(c){return(c=(c?c.ownerDocument||c:0).documentElement)?c.nodeName!=="HTML":false},ea=function(c,f){var i=[],j="",n;for(f=f.nodeType?[f]:f;n=o.match.PSEUDO.exec(c);){j+=n[0];c=c.replace(o.match.PSEUDO,"")}c=o.relative[c]?c+"*":c;n=0;for(var m=f.length;n<m;n++)p(c,f[n],i);return p.filter(j,
empty:function(){for(this.nodeType===1&&M(this.getElementsByTagName("*"));this.firstChild;)this.removeChild(this.firstChild)}},function(a,b){d.fn[a]=function(){return this.each(b,arguments)}});d.extend({clean:function(a,b,e,g){b=b||r;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||r;var h=[];d.each(a,function(k,l){if(typeof l==="number")l+="";if(l){if(typeof l==="string"&&!Ma.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Ja,Na);var q=(la.exec(l)|| ["",""])[1].toLowerCase(),p=y[q]||y._default,o=p[0];k=b.createElement("div");for(k.innerHTML=p[1]+l+p[2];o--;)k=k.lastChild;if(!d.support.tbody){o=La.test(l);q=q==="table"&&!o?k.firstChild&&k.firstChild.childNodes:p[1]==="<table>"&&!o?k.childNodes:[];for(p=q.length-1;p>=0;--p)d.nodeName(q[p],"tbody")&&!q[p].childNodes.length&&q[p].parentNode.removeChild(q[p])}!d.support.leadingWhitespace&&R.test(l)&&k.insertBefore(b.createTextNode(R.exec(l)[0]),k.firstChild);l=d.makeArray(k.childNodes)}if(l.nodeType)h.push(l); else h=d.merge(h,l)}});if(e)for(a=0;h[a];a++)if(g&&d.nodeName(h[a],"script")&&(!h[a].type||h[a].type.toLowerCase()==="text/javascript"))g.push(h[a].parentNode?h[a].parentNode.removeChild(h[a]):h[a]);else{h[a].nodeType===1&&h.splice.apply(h,[a+1,0].concat(d.makeArray(h[a].getElementsByTagName("script"))));e.appendChild(h[a])}return h}});d.fn.offset="getBoundingClientRect"in r.documentElement?function(a){var b=this[0];if(!b||!b.ownerDocument)return null;if(a)return this.each(function(h){d.offset.setOffset(this,
[this]).length){if(!b&&this.nodeType===1){M(this.getElementsByTagName("*"));M([this])}this.parentNode&&this.parentNode.removeChild(this)}},empty:function(){for(this.nodeType===1&&M(this.getElementsByTagName("*"));this.firstChild;)this.removeChild(this.firstChild)}},function(a,b){c.fn[a]=function(){return this.each(b,arguments)}});c.extend({clean:function(a,b,e,f){b=b||r;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||r;var h=[];c.each(a,function(k,l){if(typeof l=== "number")l+="";if(l){if(typeof l==="string"&&!Ma.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Ja,Na);var q=(la.exec(l)||["",""])[1].toLowerCase(),p=z[q]||z._default,o=p[0];k=b.createElement("div");for(k.innerHTML=p[1]+l+p[2];o--;)k=k.lastChild;if(!c.support.tbody){o=La.test(l);q=q==="table"&&!o?k.firstChild&&k.firstChild.childNodes:p[1]==="<table>"&&!o?k.childNodes:[];for(p=q.length-1;p>=0;--p)c.nodeName(q[p],"tbody")&&!q[p].childNodes.length&&q[p].parentNode.removeChild(q[p])}!c.support.leadingWhitespace&& R.test(l)&&k.insertBefore(b.createTextNode(R.exec(l)[0]),k.firstChild);l=c.makeArray(k.childNodes)}if(l.nodeType)h.push(l);else h=c.merge(h,l)}});if(e)for(a=0;h[a];a++)if(f&&c.nodeName(h[a],"script")&&(!h[a].type||h[a].type.toLowerCase()==="text/javascript"))f.push(h[a].parentNode?h[a].parentNode.removeChild(h[a]):h[a]);else{h[a].nodeType===1&&h.splice.apply(h,[a+1,0].concat(c.makeArray(h[a].getElementsByTagName("script"))));e.appendChild(h[a])}return h}});c.fn.offset="getBoundingClientRect"in r.documentElement?
empty:function(){for(this.nodeType===1&&M(this.getElementsByTagName("*"));this.firstChild;)this.removeChild(this.firstChild)}},function(a,b){d.fn[a]=function(){return this.each(b,arguments)}});d.extend({clean:function(a,b,e,g){b=b||r;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||r;var h=[];d.each(a,function(k,l){if(typeof l==="number")l+="";if(l){if(typeof l==="string"&&!Ma.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Ja,Na);var q=(la.exec(l)||["",""])[1].toLowerCase(),p=y[q]||y._default,o=p[0];k=b.createElement("div");for(k.innerHTML=p[1]+l+p[2];o--;)k=k.lastChild;if(!d.support.tbody){o=La.test(l);q=q==="table"&&!o?k.firstChild&&k.firstChild.childNodes:p[1]==="<table>"&&!o?k.childNodes:[];for(p=q.length-1;p>=0;--p)d.nodeName(q[p],"tbody")&&!q[p].childNodes.length&&q[p].parentNode.removeChild(q[p])}!d.support.leadingWhitespace&&R.test(l)&&k.insertBefore(b.createTextNode(R.exec(l)[0]),k.firstChild);l=d.makeArray(k.childNodes)}if(l.nodeType)h.push(l);else h=d.merge(h,l)}});if(e)for(a=0;h[a];a++)if(g&&d.nodeName(h[a],"script")&&(!h[a].type||h[a].type.toLowerCase()==="text/javascript"))g.push(h[a].parentNode?h[a].parentNode.removeChild(h[a]):h[a]);else{h[a].nodeType===1&&h.splice.apply(h,[a+1,0].concat(d.makeArray(h[a].getElementsByTagName("script"))));e.appendChild(h[a])}return h}});d.fn.offset="getBoundingClientRect"in r.documentElement?function(a){var b=this[0];if(!b||!b.ownerDocument)return null;if(a)return this.each(function(h){d.offset.setOffset(this,
} if (!document.getElementById('col_mpaa').checked) { delete detail.mpaa;
function cleanDetail(detail) { if (!document.getElementById('col_id').checked) { delete detail.id; } if (!document.getElementById('col_title').checked) { delete detail.title; } if (!document.getElementById('col_alttitle').checked) { delete detail.alt; } if (!document.getElementById('col_year').checked) { delete detail.year; } if (!document.getElementById('col_mpaa').checked) { delete detail.mpaa; } if (!document.getElementById('col_genre').checked) { delete detail.genre; } if (!document.getElementById('col_rating').checked) { delete detail.rating; } if (!document.getElementById('col_imdb_id').checked) { delete detail.imdb_id; } if (!document.getElementById('col_imdb_title').checked) { delete detail.imdb_title; } if (!document.getElementById('col_imdb_year').checked) { delete detail.imdb_year; } return detail; }
addEndSlur(el, x, 1);
addEndSlur(el, x, 0);
this.cleanUp = function(defWidth, defLength) { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = []; var x; var addEndSlur = function(obj, num, chordPos) { obj.endSlur = []; if (currSlur[chordPos] === undefined) { // There isn't an exact match for note position, but we'll take any other open slur. for (x = 0; x < currSlur.length; x++) { if (currSlur[x] !== undefined) { chordPos = x; break; } } if (currSlur[chordPos] === undefined) currSlur[chordPos] = [chordPos*100]; } var slurNum = currSlur[chordPos].pop(); for (var i = 0; i < num; i++) { obj.endSlur.push(slurNum); } if (currSlur[chordPos].length === 0) delete currSlur[chordPos]; return slurNum; }; var addStartSlur = function(obj, num, chordPos, usedNums) { obj.startSlur = []; if (currSlur[chordPos] === undefined) { currSlur[chordPos] = []; } var nextNum = chordPos*100+1; for (var i = 0; i < num; i++) { if (usedNums) { usedNums.each(function(x) { if (nextNum === x) ++nextNum; }) } currSlur[chordPos].push(nextNum); obj.startSlur.push(nextNum); nextNum++; } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x, 1); } } for (g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x, 1); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x, 1); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x, 1); } if (el.pitches) { var usedNums = []; for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; var slurNum = addEndSlur(el.pitches[p], x, p+1); usedNums.push(slurNum); } } for (p = 0; p < el.pitches.length; p++) { if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x, p+1, usedNums); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'treble+8': case 'treble-8': break; case 'bass': case 'bass+8': case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'tenor': case 'tenor+8': case 'tenor-8': el.verticalPos = - el.verticalPos; min = -40; max = 40;// el.verticalPos+=2; min += 6; max += 6; break; case 'alto': case 'alto+8': case 'alto-8': el.verticalPos = - el.verticalPos; min = -40; max = 40;// el.verticalPos-=2; min += 4; max += 4; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } if (!this.formatting.pagewidth) this.formatting.pagewidth = defWidth; if (!this.formatting.pageheight) this.formatting.pageheight = defLength; // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };
addStartSlur(el, x, 1);
addStartSlur(el, x, 0);
this.cleanUp = function(defWidth, defLength) { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = []; var x; var addEndSlur = function(obj, num, chordPos) { obj.endSlur = []; if (currSlur[chordPos] === undefined) { // There isn't an exact match for note position, but we'll take any other open slur. for (x = 0; x < currSlur.length; x++) { if (currSlur[x] !== undefined) { chordPos = x; break; } } if (currSlur[chordPos] === undefined) currSlur[chordPos] = [chordPos*100]; } var slurNum = currSlur[chordPos].pop(); for (var i = 0; i < num; i++) { obj.endSlur.push(slurNum); } if (currSlur[chordPos].length === 0) delete currSlur[chordPos]; return slurNum; }; var addStartSlur = function(obj, num, chordPos, usedNums) { obj.startSlur = []; if (currSlur[chordPos] === undefined) { currSlur[chordPos] = []; } var nextNum = chordPos*100+1; for (var i = 0; i < num; i++) { if (usedNums) { usedNums.each(function(x) { if (nextNum === x) ++nextNum; }) } currSlur[chordPos].push(nextNum); obj.startSlur.push(nextNum); nextNum++; } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x, 1); } } for (g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x, 1); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x, 1); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x, 1); } if (el.pitches) { var usedNums = []; for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; var slurNum = addEndSlur(el.pitches[p], x, p+1); usedNums.push(slurNum); } } for (p = 0; p < el.pitches.length; p++) { if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x, p+1, usedNums); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'treble+8': case 'treble-8': break; case 'bass': case 'bass+8': case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'tenor': case 'tenor+8': case 'tenor-8': el.verticalPos = - el.verticalPos; min = -40; max = 40;// el.verticalPos+=2; min += 6; max += 6; break; case 'alto': case 'alto+8': case 'alto-8': el.verticalPos = - el.verticalPos; min = -40; max = 40;// el.verticalPos-=2; min += 4; max += 4; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } if (!this.formatting.pagewidth) this.formatting.pagewidth = defWidth; if (!this.formatting.pageheight) this.formatting.pageheight = defLength; // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };
var currSlur = 0;
var currSlur = [];
this.cleanUp = function() { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = 0; var x; var addEndSlur = function(obj, num) { obj.endSlur = []; for (var i = 0; i < num; i++) { obj.endSlur.push(currSlur); if (currSlur > 0) --currSlur; } }; var addStartSlur = function(obj, num) { obj.startSlur = []; for (var i = 0; i < num; i++) { ++currSlur; obj.startSlur.push(currSlur); } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x); } if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x); } if (el.pitches) { for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; addEndSlur(el.pitches[p], x); } if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'tenor': el.verticalPos+=2; min += 6; max += 6; break; case 'bass': el.verticalPos--; min += 6; max += 6; break; case 'alto': el.verticalPos-=2; min += 4; max += 4; break; case 'treble+8': break; case 'tenor+8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass+8': el.verticalPos--; min += 6; max += 6; break; case 'alto+8': el.verticalPos-=2; min += 4; max += 4; break; case 'treble-8': break; case 'tenor-8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'alto-8': el.verticalPos-=2; min += 4; max += 4; break; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };
var addEndSlur = function(obj, num) {
var addEndSlur = function(obj, num, chordPos) {
this.cleanUp = function() { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = 0; var x; var addEndSlur = function(obj, num) { obj.endSlur = []; for (var i = 0; i < num; i++) { obj.endSlur.push(currSlur); if (currSlur > 0) --currSlur; } }; var addStartSlur = function(obj, num) { obj.startSlur = []; for (var i = 0; i < num; i++) { ++currSlur; obj.startSlur.push(currSlur); } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x); } if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x); } if (el.pitches) { for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; addEndSlur(el.pitches[p], x); } if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'tenor': el.verticalPos+=2; min += 6; max += 6; break; case 'bass': el.verticalPos--; min += 6; max += 6; break; case 'alto': el.verticalPos-=2; min += 4; max += 4; break; case 'treble+8': break; case 'tenor+8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass+8': el.verticalPos--; min += 6; max += 6; break; case 'alto+8': el.verticalPos-=2; min += 4; max += 4; break; case 'treble-8': break; case 'tenor-8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'alto-8': el.verticalPos-=2; min += 4; max += 4; break; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };
obj.endSlur.push(currSlur); if (currSlur > 0) --currSlur;
obj.endSlur.push(currSlur[chordPos]); if (currSlur[chordPos] > 0) --currSlur[chordPos];
this.cleanUp = function() { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = 0; var x; var addEndSlur = function(obj, num) { obj.endSlur = []; for (var i = 0; i < num; i++) { obj.endSlur.push(currSlur); if (currSlur > 0) --currSlur; } }; var addStartSlur = function(obj, num) { obj.startSlur = []; for (var i = 0; i < num; i++) { ++currSlur; obj.startSlur.push(currSlur); } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x); } if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x); } if (el.pitches) { for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; addEndSlur(el.pitches[p], x); } if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'tenor': el.verticalPos+=2; min += 6; max += 6; break; case 'bass': el.verticalPos--; min += 6; max += 6; break; case 'alto': el.verticalPos-=2; min += 4; max += 4; break; case 'treble+8': break; case 'tenor+8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass+8': el.verticalPos--; min += 6; max += 6; break; case 'alto+8': el.verticalPos-=2; min += 4; max += 4; break; case 'treble-8': break; case 'tenor-8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'alto-8': el.verticalPos-=2; min += 4; max += 4; break; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };
var addStartSlur = function(obj, num) {
var addStartSlur = function(obj, num, chordPos) {
this.cleanUp = function() { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = 0; var x; var addEndSlur = function(obj, num) { obj.endSlur = []; for (var i = 0; i < num; i++) { obj.endSlur.push(currSlur); if (currSlur > 0) --currSlur; } }; var addStartSlur = function(obj, num) { obj.startSlur = []; for (var i = 0; i < num; i++) { ++currSlur; obj.startSlur.push(currSlur); } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x); } if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x); } if (el.pitches) { for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; addEndSlur(el.pitches[p], x); } if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'tenor': el.verticalPos+=2; min += 6; max += 6; break; case 'bass': el.verticalPos--; min += 6; max += 6; break; case 'alto': el.verticalPos-=2; min += 4; max += 4; break; case 'treble+8': break; case 'tenor+8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass+8': el.verticalPos--; min += 6; max += 6; break; case 'alto+8': el.verticalPos-=2; min += 4; max += 4; break; case 'treble-8': break; case 'tenor-8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'alto-8': el.verticalPos-=2; min += 4; max += 4; break; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };
++currSlur; obj.startSlur.push(currSlur);
++currSlur[chordPos]; obj.startSlur.push(currSlur[chordPos]);
this.cleanUp = function() { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = 0; var x; var addEndSlur = function(obj, num) { obj.endSlur = []; for (var i = 0; i < num; i++) { obj.endSlur.push(currSlur); if (currSlur > 0) --currSlur; } }; var addStartSlur = function(obj, num) { obj.startSlur = []; for (var i = 0; i < num; i++) { ++currSlur; obj.startSlur.push(currSlur); } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x); } if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x); } if (el.pitches) { for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; addEndSlur(el.pitches[p], x); } if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'tenor': el.verticalPos+=2; min += 6; max += 6; break; case 'bass': el.verticalPos--; min += 6; max += 6; break; case 'alto': el.verticalPos-=2; min += 4; max += 4; break; case 'treble+8': break; case 'tenor+8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass+8': el.verticalPos--; min += 6; max += 6; break; case 'alto+8': el.verticalPos-=2; min += 4; max += 4; break; case 'treble-8': break; case 'tenor-8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'alto-8': el.verticalPos-=2; min += 4; max += 4; break; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };
addEndSlur(el.gracenotes[g], x);
addEndSlur(el.gracenotes[g], x, 1);
this.cleanUp = function() { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = 0; var x; var addEndSlur = function(obj, num) { obj.endSlur = []; for (var i = 0; i < num; i++) { obj.endSlur.push(currSlur); if (currSlur > 0) --currSlur; } }; var addStartSlur = function(obj, num) { obj.startSlur = []; for (var i = 0; i < num; i++) { ++currSlur; obj.startSlur.push(currSlur); } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x); } if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x); } if (el.pitches) { for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; addEndSlur(el.pitches[p], x); } if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'tenor': el.verticalPos+=2; min += 6; max += 6; break; case 'bass': el.verticalPos--; min += 6; max += 6; break; case 'alto': el.verticalPos-=2; min += 4; max += 4; break; case 'treble+8': break; case 'tenor+8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass+8': el.verticalPos--; min += 6; max += 6; break; case 'alto+8': el.verticalPos-=2; min += 4; max += 4; break; case 'treble-8': break; case 'tenor-8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'alto-8': el.verticalPos-=2; min += 4; max += 4; break; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };
addStartSlur(el.gracenotes[g], x);
addStartSlur(el.gracenotes[g], x, 1);
this.cleanUp = function() { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = 0; var x; var addEndSlur = function(obj, num) { obj.endSlur = []; for (var i = 0; i < num; i++) { obj.endSlur.push(currSlur); if (currSlur > 0) --currSlur; } }; var addStartSlur = function(obj, num) { obj.startSlur = []; for (var i = 0; i < num; i++) { ++currSlur; obj.startSlur.push(currSlur); } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x); } if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x); } if (el.pitches) { for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; addEndSlur(el.pitches[p], x); } if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'tenor': el.verticalPos+=2; min += 6; max += 6; break; case 'bass': el.verticalPos--; min += 6; max += 6; break; case 'alto': el.verticalPos-=2; min += 4; max += 4; break; case 'treble+8': break; case 'tenor+8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass+8': el.verticalPos--; min += 6; max += 6; break; case 'alto+8': el.verticalPos-=2; min += 4; max += 4; break; case 'treble-8': break; case 'tenor-8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'alto-8': el.verticalPos-=2; min += 4; max += 4; break; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };
addEndSlur(el, x);
addEndSlur(el, x, 1);
this.cleanUp = function() { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = 0; var x; var addEndSlur = function(obj, num) { obj.endSlur = []; for (var i = 0; i < num; i++) { obj.endSlur.push(currSlur); if (currSlur > 0) --currSlur; } }; var addStartSlur = function(obj, num) { obj.startSlur = []; for (var i = 0; i < num; i++) { ++currSlur; obj.startSlur.push(currSlur); } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x); } if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x); } if (el.pitches) { for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; addEndSlur(el.pitches[p], x); } if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'tenor': el.verticalPos+=2; min += 6; max += 6; break; case 'bass': el.verticalPos--; min += 6; max += 6; break; case 'alto': el.verticalPos-=2; min += 4; max += 4; break; case 'treble+8': break; case 'tenor+8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass+8': el.verticalPos--; min += 6; max += 6; break; case 'alto+8': el.verticalPos-=2; min += 4; max += 4; break; case 'treble-8': break; case 'tenor-8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'alto-8': el.verticalPos-=2; min += 4; max += 4; break; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };
addStartSlur(el, x);
addStartSlur(el, x, 1);
this.cleanUp = function() { this.closeLine(); // Close the last line. // Remove any blank lines var anyDeleted = false; for (var i = 0; i < this.lines.length; i++) { if (this.lines[i].staff !== undefined) { var hasAny = false; for (var s = 0; s < this.lines[i].staff.length; s++) { if (this.lines[i].staff[s] === undefined) { anyDeleted = true; this.lines[i].staff[s] = null; //this.lines[i].staff[s] = { voices: []}; // TODO-PER: There was a part missing in the abc music. How should we recover? } else { for (var v = 0; v < this.lines[i].staff[s].voices.length; v++) { if (this.lines[i].staff[s].voices[v] === undefined) this.lines[i].staff[s].voices[v] = []; // TODO-PER: There was a part missing in the abc music. How should we recover? else if (this.containsNotes(this.lines[i].staff[s].voices[v])) hasAny = true; } } } if (!hasAny) { this.lines[i] = null; anyDeleted = true; } } } if (anyDeleted) { this.lines = this.lines.compact(); this.lines.each(function(line) { if (line.staff) line.staff = line.staff.compact(); }); } function cleanUpSlursInLine(line) { var currSlur = 0; var x; var addEndSlur = function(obj, num) { obj.endSlur = []; for (var i = 0; i < num; i++) { obj.endSlur.push(currSlur); if (currSlur > 0) --currSlur; } }; var addStartSlur = function(obj, num) { obj.startSlur = []; for (var i = 0; i < num; i++) { ++currSlur; obj.startSlur.push(currSlur); } }; for (var i = 0; i < line.length; i++) { var el = line[i]; if (el.el_type === 'note') { if (el.gracenotes) { for (var g = 0; g < el.gracenotes.length; g++) { if (el.gracenotes[g].endSlur) { x = el.gracenotes[g].endSlur; addEndSlur(el.gracenotes[g], x); } if (el.gracenotes[g].startSlur) { x = el.gracenotes[g].startSlur; addStartSlur(el.gracenotes[g], x); } } } if (el.endSlur) { x = el.endSlur; addEndSlur(el, x); } if (el.startSlur) { x = el.startSlur; addStartSlur(el, x); } if (el.pitches) { for (var p = 0; p < el.pitches.length; p++) { if (el.pitches[p].endSlur) { x = el.pitches[p].endSlur; addEndSlur(el.pitches[p], x); } if (el.pitches[p].startSlur) { x = el.pitches[p].startSlur; addStartSlur(el.pitches[p], x); } } } } } } // TODO-PER: This could be done faster as we go instead of as the last step. function fixClefPlacement(el) { //if (el.el_type === 'clef') { var min = -2; var max = 5; switch(el.type) { case 'tenor': el.verticalPos+=2; min += 6; max += 6; break; case 'bass': el.verticalPos--; min += 6; max += 6; break; case 'alto': el.verticalPos-=2; min += 4; max += 4; break; case 'treble+8': break; case 'tenor+8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass+8': el.verticalPos--; min += 6; max += 6; break; case 'alto+8': el.verticalPos-=2; min += 4; max += 4; break; case 'treble-8': break; case 'tenor-8': el.verticalPos+=2; min += 6; max += 6; break; case 'bass-8': el.verticalPos--; min += 6; max += 6; break; case 'alto-8': el.verticalPos-=2; min += 4; max += 4; break; } if (el.verticalPos < min) { while (el.verticalPos < min) el.verticalPos += 7; } else if (el.verticalPos > max) { while (el.verticalPos > max) el.verticalPos -= 7; } //} } for (this.lineNum = 0; this.lineNum < this.lines.length; this.lineNum++) { if (this.lines[this.lineNum].staff) for (this.staffNum = 0; this.staffNum < this.lines[this.lineNum].staff.length; this.staffNum++) { if (this.lines[this.lineNum].staff[this.staffNum].clef) fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].clef); for (this.voiceNum = 0; this.voiceNum < this.lines[this.lineNum].staff[this.staffNum].voices.length; this.voiceNum++) {// var el = this.getLastNote();// if (el) el.end_beam = true; cleanUpSlursInLine(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum]); for (var j = 0; j < this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum].length; j++) if (this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j].el_type === 'clef') fixClefPlacement(this.lines[this.lineNum].staff[this.staffNum].voices[this.voiceNum][j]); } } } // Remove temporary variables that the outside doesn't need to know about delete this.staffNum; delete this.voiceNum; delete this.lineNum; delete this.potentialStartBeam; delete this.potentialEndBeam; };