rem
stringlengths
0
126k
add
stringlengths
0
441k
context
stringlengths
15
136k
false,F=null,O=null,aa=null,ba=0,ka=false,S=null,ea=null,I={state:0,socket:null},na=(new Date).getTime(),la,fa=0,T={};x.prototype.preload=function(c){var d=new Image;this.images.push(d);d.onload=x.prototype.onload;d.onerror=x.prototype.onload;d.onabort=x.prototype.onload;d.imagePreloader=this;d.src=c};x.prototype.onload=function(){var c=this.imagePreloader;--c.work==0&&c.callback(c.images)};h.history.register(_$_INITIAL_HASH_$_,v);window.onunload=function(){k.emit(k,"Wt-unload");r()};this._p_={ieAlternative:D,
0};var ga=[],y=[],ha=_$_RELATIVE_URL_$_,R=false,ma=false,ja=false,F=null,P=null,aa=null,ba=0,ka=false,S=null,ea=null,I={state:0,socket:null},na=(new Date).getTime(),la,fa=0,T={};x.prototype.preload=function(c){var d=new Image;this.images.push(d);d.onload=x.prototype.onload;d.onerror=x.prototype.onload;d.onabort=x.prototype.onload;d.imagePreloader=this;d.src=c};x.prototype.onload=function(){var c=this.imagePreloader;--c.work==0&&c.callback(c.images)};h.history.register(_$_INITIAL_HASH_$_,v);window.onunload= function(){k.emit(k,"Wt-unload");r()};this._p_={ieAlternative:D,loadScript:O,onJsLoad:K,setTitle:da,update:u,quit:N,setFormObjects:function(c){Z=c},saveDownPos:w,addTimerEvent:J,load:a,handleResponse:o,setServerPush:l,dragStart:ca,dragDrag:V,dragEnd:Q,capture:h.capture,onHashChange:v,setHash:G,ImagePreloader:x,autoJavaScript:function(){_$_AUTO_JAVASCRIPT_$_()},response:B,setCloseMessage:Y};this.WT=_$_WT_CLASS_$_;this.emit=C});window.WtSignalEmit=_$_APP_CLASS_$_.emit;window.WtScriptLoaded=false;
false,F=null,O=null,aa=null,ba=0,ka=false,S=null,ea=null,I={state:0,socket:null},na=(new Date).getTime(),la,fa=0,T={};x.prototype.preload=function(c){var d=new Image;this.images.push(d);d.onload=x.prototype.onload;d.onerror=x.prototype.onload;d.onabort=x.prototype.onload;d.imagePreloader=this;d.src=c};x.prototype.onload=function(){var c=this.imagePreloader;--c.work==0&&c.callback(c.images)};h.history.register(_$_INITIAL_HASH_$_,v);window.onunload=function(){k.emit(k,"Wt-unload");r()};this._p_={ieAlternative:D,
function(){var d=this.imagePreloader;--d.work==0&&d.callback(d.images)};n.history.register(_$_INITIAL_HASH_$_,t);window.onunload=function(){q.emit(q,"Wt-unload");v()};this._p_={ieAlternative:l,loadScript:C,onJsLoad:M,setTitle:b,update:y,quit:Y,setFormObjects:function(d){V=d},saveDownPos:w,addTimerEvent:U,load:f,handleResponse:u,setServerPush:o,dragStart:ca,dragDrag:g,dragEnd:Z,capture:n.capture,onHashChange:t,setHash:D,ImagePreloader:H,autoJavaScript:function(){_$_AUTO_JAVASCRIPT_$_()},response:F,
function(d){var c=new Image;this.images.push(c);c.onload=H.prototype.onload;c.onerror=H.prototype.onload;c.onabort=H.prototype.onload;c.imagePreloader=this;c.src=d};H.prototype.onload=function(){var d=this.imagePreloader;--d.work==0&&d.callback(d.images)};n.history.register(_$_INITIAL_HASH_$_,t);window.onunload=function(){q.emit(q,"Wt-unload");v()};this._p_={ieAlternative:l,loadScript:C,onJsLoad:M,setTitle:b,update:y,quit:Y,setFormObjects:function(d){V=d},saveDownPos:w,addTimerEvent:U,load:f,handleResponse:u,
function(){var d=this.imagePreloader;--d.work==0&&d.callback(d.images)};n.history.register(_$_INITIAL_HASH_$_,t);window.onunload=function(){q.emit(q,"Wt-unload");v()};this._p_={ieAlternative:l,loadScript:C,onJsLoad:M,setTitle:b,update:y,quit:Y,setFormObjects:function(d){V=d},saveDownPos:w,addTimerEvent:U,load:f,handleResponse:u,setServerPush:o,dragStart:ca,dragDrag:g,dragEnd:Z,capture:n.capture,onHashChange:t,setHash:D,ImagePreloader:H,autoJavaScript:function(){_$_AUTO_JAVASCRIPT_$_()},response:F,
if(this.settings.data.async && obj.find("li").size() == 0) { obj.children("a").addClass("loading");
obj.children("ul:eq(0)").remove().end().append("<ul><li class='last'><a class='loading' href='#'><ins>&nbsp;</ins>" + (_this.settings.lang.loading || "Loading ...") + "</a></li></ul>"); obj.removeClass("closed").addClass("open");
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"); //obj.children("ul:eq(0)").remove().end().append("<ul><li class='last'><a class='loading' href='#'><ins>&nbsp;</ins>" + (_this.settings.lang.loading || "Loading ...") + "</a></li></ul>"); //obj.removeClass("closed").addClass("open"); 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; },
this._load_branch(obj, function () { _this.open_branch(obj, disable_animation, callback); }); return;
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:eq(0)").replaceWith($("<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"); _this.open_branch.apply(_this, [obj]); if(callback) callback.call(); }); }); return true;
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"); //obj.children("ul:eq(0)").remove().end().append("<ul><li class='last'><a class='loading' href='#'><ins>&nbsp;</ins>" + (_this.settings.lang.loading || "Loading ...") + "</a></li></ul>"); //obj.removeClass("closed").addClass("open"); 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; },
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","");
else { if(!this.settings.data.async) { 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");
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"); //obj.children("ul:eq(0)").remove().end().append("<ul><li class='last'><a class='loading' href='#'><ins>&nbsp;</ins>" + (_this.settings.lang.loading || "Loading ...") + "</a></li></ul>"); //obj.removeClass("closed").addClass("open"); 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; },
}); } else { obj.removeClass("closed").addClass("open"); if(callback) callback.call();
} this.callback("onopen", [obj.get(0), this]); return true;
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"); //obj.children("ul:eq(0)").remove().end().append("<ul><li class='last'><a class='loading' href='#'><ins>&nbsp;</ins>" + (_this.settings.lang.loading || "Loading ...") + "</a></li></ul>"); //obj.removeClass("closed").addClass("open"); 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; },
this.callback("onopen", [obj.get(0), this]); return true;
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"); //obj.children("ul:eq(0)").remove().end().append("<ul><li class='last'><a class='loading' href='#'><ins>&nbsp;</ins>" + (_this.settings.lang.loading || "Loading ...") + "</a></li></ul>"); //obj.removeClass("closed").addClass("open"); 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; },
}
};
function open_panel() { var menu_item, panel_container = document.createElement("div"); menu_item = document.createElement("input"); menu_item.type = "button"; menu_item.value="close"; menu_item.onclick = function () { close_panel(); } panel_container.appendChild(menu_item); panel.appendChild(panel_container); panel.className = "panel"; panel.style.display = "block"; panel.style.top = -panel.offsetHeight + "px"; panel.style.left = ((window.innerWidth / 2) - (panel.offsetWidth / 2)) + "px"; panel.className = "panel slide"; window.setTimeout(function () { panel.style.top = 0; }, 0); }
if (maskConf) { $.mask.load(overlay, maskConf); }
if (maskConf) { $(overlay).expose(maskConf); }
function Overlay(trigger, conf) { // private variables var self = this, fire = trigger.add(self), w = $(window), closers, overlay, opened, maskConf = $.tools.mask && (conf.mask || conf.expose), uid = Math.random().toString().slice(10); // mask configuration if (maskConf) { if (typeof maskConf == 'string') { maskConf = {color: maskConf}; } maskConf.closeOnClick = maskConf.closeOnEsc = false; } // get overlay and triggerr var jq = conf.target || trigger.attr("rel"); overlay = jq ? $(jq) : null || trigger; // overlay not found. cannot continue if (!overlay.length) { throw "Could not find Overlay: " + jq; } // trigger's click event if (trigger && trigger.index(overlay) == -1) { trigger.click(function(e) { self.load(e); return e.preventDefault(); }); } // API methods $.extend(self, { load: function(e) { // can be opened only once if (self.isOpened()) { return self; } // find the effect var eff = effects[conf.effect]; if (!eff) { throw "Overlay: cannot find effect : \"" + conf.effect + "\""; } // close other instances? if (conf.oneInstance) { $.each(instances, function() { this.close(e); }); } // onBeforeLoad e = e || $.Event(); e.type = "onBeforeLoad"; fire.trigger(e); if (e.isDefaultPrevented()) { return self; } // opened opened = true; // possible mask effect if (maskConf) { $.mask.load(overlay, maskConf); } // position & dimensions var top = conf.top, left = conf.left, oWidth = overlay.outerWidth({margin:true}), oHeight = overlay.outerHeight({margin:true}); if (typeof top == 'string') { top = top == 'center' ? Math.max((w.height() - oHeight) / 2, 0) : parseInt(top, 10) / 100 * w.height(); } if (left == 'center') { left = Math.max((w.width() - oWidth) / 2, 0); } if (!conf.absolute) { top += w.scrollTop(); left += w.scrollLeft(); } // position overlay overlay.css({position: conf.fixed ? 'fixed' : 'absolute'}).css({top: top, left: left}); // load effect eff[0].call(self, function() { if (opened) { e.type = "onLoad"; fire.trigger(e); } }); // mask.click closes overlay if (maskConf) { $.mask.getMask().one("click", self.close); } // when window is clicked outside overlay, we close if (conf.closeOnClick) { $(document).bind("click." + uid, function(e) { if (!$(e.target).parents(overlay).length) { self.close(e); } }); } // keyboard::escape if (conf.closeOnEsc) { // one callback is enough if multiple instances are loaded simultaneously $(document).bind("keydown." + uid, function(e) { if (e.keyCode == 27) { self.close(e); } }); } return self; }, close: function(e) { if (!self.isOpened()) { return self; } e = e || $.Event(); e.type = "onBeforeClose"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } opened = false; // close effect effects[conf.effect][1].call(self, function() { e.type = "onClose"; fire.trigger(e); }); // unbind the keyboard / clicking actions $(document).unbind("click." + uid).unbind("keydown." + uid); if (maskConf) { $.mask.close(); } return self; }, getOverlay: function() { return overlay; }, getTrigger: function() { return trigger; }, getClosers: function() { return closers; }, isOpened: function() { return opened; }, // manipulate start, finish and speeds getConf: function() { return conf; } }); // callbacks $.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // close button closers = overlay.find(conf.close || ".close"); if (!closers.length && !conf.close) { closers = $('<div class="close"></div>'); overlay.prepend(closers); } closers.click(function(e) { self.close(e); }); }
if (!conf.absolute) { top += w.scrollTop(); left += w.scrollLeft(); } overlay.css({position: conf.fixed ? 'fixed' : 'absolute'}).css({top: top, left: left});
function Overlay(trigger, conf) { // private variables var self = this, fire = trigger.add(self), w = $(window), closers, overlay, opened, maskConf = $.tools.mask && (conf.mask || conf.expose), uid = Math.random().toString().slice(10); // mask configuration if (maskConf) { if (typeof maskConf == 'string') { maskConf = {color: maskConf}; } maskConf.closeOnClick = maskConf.closeOnEsc = false; } // get overlay and triggerr var jq = conf.target || trigger.attr("rel"); overlay = jq ? $(jq) : null || trigger; // overlay not found. cannot continue if (!overlay.length) { throw "Could not find Overlay: " + jq; } // trigger's click event if (trigger && trigger.index(overlay) == -1) { trigger.click(function(e) { self.load(e); return e.preventDefault(); }); } // API methods $.extend(self, { load: function(e) { // can be opened only once if (self.isOpened()) { return self; } // find the effect var eff = effects[conf.effect]; if (!eff) { throw "Overlay: cannot find effect : \"" + conf.effect + "\""; } // close other instances? if (conf.oneInstance) { $.each(instances, function() { this.close(e); }); } // onBeforeLoad e = e || $.Event(); e.type = "onBeforeLoad"; fire.trigger(e); if (e.isDefaultPrevented()) { return self; } // opened opened = true; // possible mask effect if (maskConf) { $.mask.load(overlay, maskConf); } // position & dimensions var top = conf.top, left = conf.left, oWidth = overlay.outerWidth({margin:true}), oHeight = overlay.outerHeight({margin:true}); if (typeof top == 'string') { top = top == 'center' ? Math.max((w.height() - oHeight) / 2, 0) : parseInt(top, 10) / 100 * w.height(); } if (left == 'center') { left = Math.max((w.width() - oWidth) / 2, 0); } if (!conf.absolute) { top += w.scrollTop(); left += w.scrollLeft(); } // position overlay overlay.css({position: conf.fixed ? 'fixed' : 'absolute'}).css({top: top, left: left}); // load effect eff[0].call(self, function() { if (opened) { e.type = "onLoad"; fire.trigger(e); } }); // mask.click closes overlay if (maskConf) { $.mask.getMask().one("click", self.close); } // when window is clicked outside overlay, we close if (conf.closeOnClick) { $(document).bind("click." + uid, function(e) { if (!$(e.target).parents(overlay).length) { self.close(e); } }); } // keyboard::escape if (conf.closeOnEsc) { // one callback is enough if multiple instances are loaded simultaneously $(document).bind("keydown." + uid, function(e) { if (e.keyCode == 27) { self.close(e); } }); } return self; }, close: function(e) { if (!self.isOpened()) { return self; } e = e || $.Event(); e.type = "onBeforeClose"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } opened = false; // close effect effects[conf.effect][1].call(self, function() { e.type = "onClose"; fire.trigger(e); }); // unbind the keyboard / clicking actions $(document).unbind("click." + uid).unbind("keydown." + uid); if (maskConf) { $.mask.close(); } return self; }, getOverlay: function() { return overlay; }, getTrigger: function() { return trigger; }, getClosers: function() { return closers; }, isOpened: function() { return opened; }, // manipulate start, finish and speeds getConf: function() { return conf; } }); // callbacks $.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // close button closers = overlay.find(conf.close || ".close"); if (!closers.length && !conf.close) { closers = $('<div class="close"></div>'); overlay.prepend(closers); } closers.click(function(e) { self.close(e); }); }
eff[0].call(self, function() {
eff[0].call(self, {top: top, left: left}, function() {
function Overlay(trigger, conf) { // private variables var self = this, fire = trigger.add(self), w = $(window), closers, overlay, opened, maskConf = $.tools.mask && (conf.mask || conf.expose), uid = Math.random().toString().slice(10); // mask configuration if (maskConf) { if (typeof maskConf == 'string') { maskConf = {color: maskConf}; } maskConf.closeOnClick = maskConf.closeOnEsc = false; } // get overlay and triggerr var jq = conf.target || trigger.attr("rel"); overlay = jq ? $(jq) : null || trigger; // overlay not found. cannot continue if (!overlay.length) { throw "Could not find Overlay: " + jq; } // trigger's click event if (trigger && trigger.index(overlay) == -1) { trigger.click(function(e) { self.load(e); return e.preventDefault(); }); } // API methods $.extend(self, { load: function(e) { // can be opened only once if (self.isOpened()) { return self; } // find the effect var eff = effects[conf.effect]; if (!eff) { throw "Overlay: cannot find effect : \"" + conf.effect + "\""; } // close other instances? if (conf.oneInstance) { $.each(instances, function() { this.close(e); }); } // onBeforeLoad e = e || $.Event(); e.type = "onBeforeLoad"; fire.trigger(e); if (e.isDefaultPrevented()) { return self; } // opened opened = true; // possible mask effect if (maskConf) { $.mask.load(overlay, maskConf); } // position & dimensions var top = conf.top, left = conf.left, oWidth = overlay.outerWidth({margin:true}), oHeight = overlay.outerHeight({margin:true}); if (typeof top == 'string') { top = top == 'center' ? Math.max((w.height() - oHeight) / 2, 0) : parseInt(top, 10) / 100 * w.height(); } if (left == 'center') { left = Math.max((w.width() - oWidth) / 2, 0); } if (!conf.absolute) { top += w.scrollTop(); left += w.scrollLeft(); } // position overlay overlay.css({position: conf.fixed ? 'fixed' : 'absolute'}).css({top: top, left: left}); // load effect eff[0].call(self, function() { if (opened) { e.type = "onLoad"; fire.trigger(e); } }); // mask.click closes overlay if (maskConf) { $.mask.getMask().one("click", self.close); } // when window is clicked outside overlay, we close if (conf.closeOnClick) { $(document).bind("click." + uid, function(e) { if (!$(e.target).parents(overlay).length) { self.close(e); } }); } // keyboard::escape if (conf.closeOnEsc) { // one callback is enough if multiple instances are loaded simultaneously $(document).bind("keydown." + uid, function(e) { if (e.keyCode == 27) { self.close(e); } }); } return self; }, close: function(e) { if (!self.isOpened()) { return self; } e = e || $.Event(); e.type = "onBeforeClose"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } opened = false; // close effect effects[conf.effect][1].call(self, function() { e.type = "onClose"; fire.trigger(e); }); // unbind the keyboard / clicking actions $(document).unbind("click." + uid).unbind("keydown." + uid); if (maskConf) { $.mask.close(); } return self; }, getOverlay: function() { return overlay; }, getTrigger: function() { return trigger; }, getClosers: function() { return closers; }, isOpened: function() { return opened; }, // manipulate start, finish and speeds getConf: function() { return conf; } }); // callbacks $.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // close button closers = overlay.find(conf.close || ".close"); if (!closers.length && !conf.close) { closers = $('<div class="close"></div>'); overlay.prepend(closers); } closers.click(function(e) { self.close(e); }); }
if (maskConf) {
if (maskConf && conf.closeOnClick) {
function Overlay(trigger, conf) { // private variables var self = this, fire = trigger.add(self), w = $(window), closers, overlay, opened, maskConf = $.tools.mask && (conf.mask || conf.expose), uid = Math.random().toString().slice(10); // mask configuration if (maskConf) { if (typeof maskConf == 'string') { maskConf = {color: maskConf}; } maskConf.closeOnClick = maskConf.closeOnEsc = false; } // get overlay and triggerr var jq = conf.target || trigger.attr("rel"); overlay = jq ? $(jq) : null || trigger; // overlay not found. cannot continue if (!overlay.length) { throw "Could not find Overlay: " + jq; } // trigger's click event if (trigger && trigger.index(overlay) == -1) { trigger.click(function(e) { self.load(e); return e.preventDefault(); }); } // API methods $.extend(self, { load: function(e) { // can be opened only once if (self.isOpened()) { return self; } // find the effect var eff = effects[conf.effect]; if (!eff) { throw "Overlay: cannot find effect : \"" + conf.effect + "\""; } // close other instances? if (conf.oneInstance) { $.each(instances, function() { this.close(e); }); } // onBeforeLoad e = e || $.Event(); e.type = "onBeforeLoad"; fire.trigger(e); if (e.isDefaultPrevented()) { return self; } // opened opened = true; // possible mask effect if (maskConf) { $.mask.load(overlay, maskConf); } // position & dimensions var top = conf.top, left = conf.left, oWidth = overlay.outerWidth({margin:true}), oHeight = overlay.outerHeight({margin:true}); if (typeof top == 'string') { top = top == 'center' ? Math.max((w.height() - oHeight) / 2, 0) : parseInt(top, 10) / 100 * w.height(); } if (left == 'center') { left = Math.max((w.width() - oWidth) / 2, 0); } if (!conf.absolute) { top += w.scrollTop(); left += w.scrollLeft(); } // position overlay overlay.css({position: conf.fixed ? 'fixed' : 'absolute'}).css({top: top, left: left}); // load effect eff[0].call(self, function() { if (opened) { e.type = "onLoad"; fire.trigger(e); } }); // mask.click closes overlay if (maskConf) { $.mask.getMask().one("click", self.close); } // when window is clicked outside overlay, we close if (conf.closeOnClick) { $(document).bind("click." + uid, function(e) { if (!$(e.target).parents(overlay).length) { self.close(e); } }); } // keyboard::escape if (conf.closeOnEsc) { // one callback is enough if multiple instances are loaded simultaneously $(document).bind("keydown." + uid, function(e) { if (e.keyCode == 27) { self.close(e); } }); } return self; }, close: function(e) { if (!self.isOpened()) { return self; } e = e || $.Event(); e.type = "onBeforeClose"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } opened = false; // close effect effects[conf.effect][1].call(self, function() { e.type = "onClose"; fire.trigger(e); }); // unbind the keyboard / clicking actions $(document).unbind("click." + uid).unbind("keydown." + uid); if (maskConf) { $.mask.close(); } return self; }, getOverlay: function() { return overlay; }, getTrigger: function() { return trigger; }, getClosers: function() { return closers; }, isOpened: function() { return opened; }, // manipulate start, finish and speeds getConf: function() { return conf; } }); // callbacks $.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // close button closers = overlay.find(conf.close || ".close"); if (!closers.length && !conf.close) { closers = $('<div class="close"></div>'); overlay.prepend(closers); } closers.click(function(e) { self.close(e); }); }
if (conf.load) { self.load(); }
function Overlay(trigger, conf) { // private variables var self = this, fire = trigger.add(self), w = $(window), closers, overlay, opened, maskConf = $.tools.mask && (conf.mask || conf.expose), uid = Math.random().toString().slice(10); // mask configuration if (maskConf) { if (typeof maskConf == 'string') { maskConf = {color: maskConf}; } maskConf.closeOnClick = maskConf.closeOnEsc = false; } // get overlay and triggerr var jq = conf.target || trigger.attr("rel"); overlay = jq ? $(jq) : null || trigger; // overlay not found. cannot continue if (!overlay.length) { throw "Could not find Overlay: " + jq; } // trigger's click event if (trigger && trigger.index(overlay) == -1) { trigger.click(function(e) { self.load(e); return e.preventDefault(); }); } // API methods $.extend(self, { load: function(e) { // can be opened only once if (self.isOpened()) { return self; } // find the effect var eff = effects[conf.effect]; if (!eff) { throw "Overlay: cannot find effect : \"" + conf.effect + "\""; } // close other instances? if (conf.oneInstance) { $.each(instances, function() { this.close(e); }); } // onBeforeLoad e = e || $.Event(); e.type = "onBeforeLoad"; fire.trigger(e); if (e.isDefaultPrevented()) { return self; } // opened opened = true; // possible mask effect if (maskConf) { $.mask.load(overlay, maskConf); } // position & dimensions var top = conf.top, left = conf.left, oWidth = overlay.outerWidth({margin:true}), oHeight = overlay.outerHeight({margin:true}); if (typeof top == 'string') { top = top == 'center' ? Math.max((w.height() - oHeight) / 2, 0) : parseInt(top, 10) / 100 * w.height(); } if (left == 'center') { left = Math.max((w.width() - oWidth) / 2, 0); } if (!conf.absolute) { top += w.scrollTop(); left += w.scrollLeft(); } // position overlay overlay.css({position: conf.fixed ? 'fixed' : 'absolute'}).css({top: top, left: left}); // load effect eff[0].call(self, function() { if (opened) { e.type = "onLoad"; fire.trigger(e); } }); // mask.click closes overlay if (maskConf) { $.mask.getMask().one("click", self.close); } // when window is clicked outside overlay, we close if (conf.closeOnClick) { $(document).bind("click." + uid, function(e) { if (!$(e.target).parents(overlay).length) { self.close(e); } }); } // keyboard::escape if (conf.closeOnEsc) { // one callback is enough if multiple instances are loaded simultaneously $(document).bind("keydown." + uid, function(e) { if (e.keyCode == 27) { self.close(e); } }); } return self; }, close: function(e) { if (!self.isOpened()) { return self; } e = e || $.Event(); e.type = "onBeforeClose"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } opened = false; // close effect effects[conf.effect][1].call(self, function() { e.type = "onClose"; fire.trigger(e); }); // unbind the keyboard / clicking actions $(document).unbind("click." + uid).unbind("keydown." + uid); if (maskConf) { $.mask.close(); } return self; }, getOverlay: function() { return overlay; }, getTrigger: function() { return trigger; }, getClosers: function() { return closers; }, isOpened: function() { return opened; }, // manipulate start, finish and speeds getConf: function() { return conf; } }); // callbacks $.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // close button closers = overlay.find(conf.close || ".close"); if (!closers.length && !conf.close) { closers = $('<div class="close"></div>'); overlay.prepend(closers); } closers.click(function(e) { self.close(e); }); }
maskConf = $.tools.mask && (conf.mask || conf.expose),
maskConf = $.tools.expose && (conf.mask || conf.expose),
function Overlay(trigger, conf) { // private variables var self = this, fire = trigger.add(self), w = $(window), closers, overlay, opened, maskConf = $.tools.mask && (conf.mask || conf.expose), uid = Math.random().toString().slice(10); // mask configuration if (maskConf) { if (typeof maskConf == 'string') { maskConf = {color: maskConf}; } maskConf.closeOnClick = maskConf.closeOnEsc = false; } // get overlay and triggerr var jq = conf.target || trigger.attr("rel"); overlay = jq ? $(jq) : null || trigger; // overlay not found. cannot continue if (!overlay.length) { throw "Could not find Overlay: " + jq; } // trigger's click event if (trigger && trigger.index(overlay) == -1) { trigger.click(function(e) { self.load(e); return e.preventDefault(); }); } // API methods $.extend(self, { load: function(e) { // can be opened only once if (self.isOpened()) { return self; } // find the effect var eff = effects[conf.effect]; if (!eff) { throw "Overlay: cannot find effect : \"" + conf.effect + "\""; } // close other instances? if (conf.oneInstance) { $.each(instances, function() { this.close(e); }); } // onBeforeLoad e = e || $.Event(); e.type = "onBeforeLoad"; fire.trigger(e); if (e.isDefaultPrevented()) { return self; } // opened opened = true; // possible mask effect if (maskConf) { $(overlay).expose(maskConf); } // position & dimensions var top = conf.top, left = conf.left, oWidth = overlay.outerWidth({margin:true}), oHeight = overlay.outerHeight({margin:true}); if (typeof top == 'string') { top = top == 'center' ? Math.max((w.height() - oHeight) / 2, 0) : parseInt(top, 10) / 100 * w.height(); } if (left == 'center') { left = Math.max((w.width() - oWidth) / 2, 0); } // load effect eff[0].call(self, {top: top, left: left}, function() { if (opened) { e.type = "onLoad"; fire.trigger(e); } }); // mask.click closes overlay if (maskConf && conf.closeOnClick) { $.mask.getMask().one("click", self.close); } // when window is clicked outside overlay, we close if (conf.closeOnClick) { $(document).bind("click." + uid, function(e) { if (!$(e.target).parents(overlay).length) { self.close(e); } }); } // keyboard::escape if (conf.closeOnEsc) { // one callback is enough if multiple instances are loaded simultaneously $(document).bind("keydown." + uid, function(e) { if (e.keyCode == 27) { self.close(e); } }); } return self; }, close: function(e) { if (!self.isOpened()) { return self; } e = e || $.Event(); e.type = "onBeforeClose"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } opened = false; // close effect effects[conf.effect][1].call(self, function() { e.type = "onClose"; fire.trigger(e); }); // unbind the keyboard / clicking actions $(document).unbind("click." + uid).unbind("keydown." + uid); if (maskConf) { $.mask.close(); } return self; }, getOverlay: function() { return overlay; }, getTrigger: function() { return trigger; }, getClosers: function() { return closers; }, isOpened: function() { return opened; }, // manipulate start, finish and speeds getConf: function() { return conf; } }); // callbacks $.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // close button closers = overlay.find(conf.close || ".close"); if (!closers.length && !conf.close) { closers = $('<div class="close"></div>'); overlay.prepend(closers); } closers.click(function(e) { self.close(e); }); // autoload if (conf.load) { self.load(); } }
$(self).bind(name, fn);
if (fn) { $(self).bind(name, fn); }
function Overlay(trigger, conf) { // private variables var self = this, fire = trigger.add(self), w = $(window), closers, overlay, opened, maskConf = $.tools.expose && (conf.mask || conf.expose), uid = Math.random().toString().slice(10); // mask configuration if (maskConf) { if (typeof maskConf == 'string') { maskConf = {color: maskConf}; } maskConf.closeOnClick = maskConf.closeOnEsc = false; } // get overlay and triggerr var jq = conf.target || trigger.attr("rel"); overlay = jq ? $(jq) : null || trigger; // overlay not found. cannot continue if (!overlay.length) { throw "Could not find Overlay: " + jq; } // trigger's click event if (trigger && trigger.index(overlay) == -1) { trigger.click(function(e) { self.load(e); return e.preventDefault(); }); } // API methods $.extend(self, { load: function(e) { // can be opened only once if (self.isOpened()) { return self; } // find the effect var eff = effects[conf.effect]; if (!eff) { throw "Overlay: cannot find effect : \"" + conf.effect + "\""; } // close other instances? if (conf.oneInstance) { $.each(instances, function() { this.close(e); }); } // onBeforeLoad e = e || $.Event(); e.type = "onBeforeLoad"; fire.trigger(e); if (e.isDefaultPrevented()) { return self; } // opened opened = true; // possible mask effect if (maskConf) { $(overlay).expose(maskConf); } // position & dimensions var top = conf.top, left = conf.left, oWidth = overlay.outerWidth({margin:true}), oHeight = overlay.outerHeight({margin:true}); if (typeof top == 'string') { top = top == 'center' ? Math.max((w.height() - oHeight) / 2, 0) : parseInt(top, 10) / 100 * w.height(); } if (left == 'center') { left = Math.max((w.width() - oWidth) / 2, 0); } // load effect eff[0].call(self, {top: top, left: left}, function() { if (opened) { e.type = "onLoad"; fire.trigger(e); } }); // mask.click closes overlay if (maskConf && conf.closeOnClick) { $.mask.getMask().one("click", self.close); } // when window is clicked outside overlay, we close if (conf.closeOnClick) { $(document).bind("click." + uid, function(e) { if (!$(e.target).parents(overlay).length) { self.close(e); } }); } // keyboard::escape if (conf.closeOnEsc) { // one callback is enough if multiple instances are loaded simultaneously $(document).bind("keydown." + uid, function(e) { if (e.keyCode == 27) { self.close(e); } }); } return self; }, close: function(e) { if (!self.isOpened()) { return self; } e = e || $.Event(); e.type = "onBeforeClose"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } opened = false; // close effect effects[conf.effect][1].call(self, function() { e.type = "onClose"; fire.trigger(e); }); // unbind the keyboard / clicking actions $(document).unbind("click." + uid).unbind("keydown." + uid); if (maskConf) { $.mask.close(); } return self; }, getOverlay: function() { return overlay; }, getTrigger: function() { return trigger; }, getClosers: function() { return closers; }, isOpened: function() { return opened; }, // manipulate start, finish and speeds getConf: function() { return conf; } }); // callbacks $.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // close button closers = overlay.find(conf.close || ".close"); if (!closers.length && !conf.close) { closers = $('<a class="close"></a>'); overlay.prepend(closers); } closers.click(function(e) { self.close(e); }); // autoload if (conf.load) { self.load(); } }
closers = $('<div class="close"></div>');
closers = $('<a class="close"></a>');
function Overlay(trigger, conf) { // private variables var self = this, fire = trigger.add(self), w = $(window), closers, overlay, opened, maskConf = $.tools.expose && (conf.mask || conf.expose), uid = Math.random().toString().slice(10); // mask configuration if (maskConf) { if (typeof maskConf == 'string') { maskConf = {color: maskConf}; } maskConf.closeOnClick = maskConf.closeOnEsc = false; } // get overlay and triggerr var jq = conf.target || trigger.attr("rel"); overlay = jq ? $(jq) : null || trigger; // overlay not found. cannot continue if (!overlay.length) { throw "Could not find Overlay: " + jq; } // trigger's click event if (trigger && trigger.index(overlay) == -1) { trigger.click(function(e) { self.load(e); return e.preventDefault(); }); } // API methods $.extend(self, { load: function(e) { // can be opened only once if (self.isOpened()) { return self; } // find the effect var eff = effects[conf.effect]; if (!eff) { throw "Overlay: cannot find effect : \"" + conf.effect + "\""; } // close other instances? if (conf.oneInstance) { $.each(instances, function() { this.close(e); }); } // onBeforeLoad e = e || $.Event(); e.type = "onBeforeLoad"; fire.trigger(e); if (e.isDefaultPrevented()) { return self; } // opened opened = true; // possible mask effect if (maskConf) { $(overlay).expose(maskConf); } // position & dimensions var top = conf.top, left = conf.left, oWidth = overlay.outerWidth({margin:true}), oHeight = overlay.outerHeight({margin:true}); if (typeof top == 'string') { top = top == 'center' ? Math.max((w.height() - oHeight) / 2, 0) : parseInt(top, 10) / 100 * w.height(); } if (left == 'center') { left = Math.max((w.width() - oWidth) / 2, 0); } // load effect eff[0].call(self, {top: top, left: left}, function() { if (opened) { e.type = "onLoad"; fire.trigger(e); } }); // mask.click closes overlay if (maskConf && conf.closeOnClick) { $.mask.getMask().one("click", self.close); } // when window is clicked outside overlay, we close if (conf.closeOnClick) { $(document).bind("click." + uid, function(e) { if (!$(e.target).parents(overlay).length) { self.close(e); } }); } // keyboard::escape if (conf.closeOnEsc) { // one callback is enough if multiple instances are loaded simultaneously $(document).bind("keydown." + uid, function(e) { if (e.keyCode == 27) { self.close(e); } }); } return self; }, close: function(e) { if (!self.isOpened()) { return self; } e = e || $.Event(); e.type = "onBeforeClose"; fire.trigger(e); if (e.isDefaultPrevented()) { return; } opened = false; // close effect effects[conf.effect][1].call(self, function() { e.type = "onClose"; fire.trigger(e); }); // unbind the keyboard / clicking actions $(document).unbind("click." + uid).unbind("keydown." + uid); if (maskConf) { $.mask.close(); } return self; }, getOverlay: function() { return overlay; }, getTrigger: function() { return trigger; }, getClosers: function() { return closers; }, isOpened: function() { return opened; }, // manipulate start, finish and speeds getConf: function() { return conf; } }); // callbacks $.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) { // configuration if ($.isFunction(conf[name])) { $(self).bind(name, conf[name]); } // API self[name] = function(fn) { $(self).bind(name, fn); return self; }; }); // close button closers = overlay.find(conf.close || ".close"); if (!closers.length && !conf.close) { closers = $('<div class="close"></div>'); overlay.prepend(closers); } closers.click(function(e) { self.close(e); }); // autoload if (conf.load) { self.load(); } }
},onAttribute:function(q,r,s){var t=this._.attributes[r];if(t){var u=t.filter(s,q,this);if(u===false)return false;if(typeof u!='undefined')return u;}return s;}}});function l(q,r){for(var s=0;q&&s<r.length;s++){var t=r[s];q=q.replace(t[0],t[1]);}return q;};function m(q,r,s){if(typeof r=='function')r=[r];var t,u,v=q.length,w=r&&r.length;if(w){for(t=0;t<v&&q[t].pri<s;t++){}for(u=w-1;u>=0;u--){var x=r[u];if(x){x.pri=s;q.splice(t,0,x);}}}};function n(q,r,s){if(r)for(var t in r){var u=q[t];q[t]=o(u,r[t],s);if(!u)q.$length++;}};function o(q,r,s){if(r){r.pri=s;if(q){if(!q.splice){if(q.pri>s)q=[r,q];else q=[q,r];q.filter=p;}else m(q,r,s);return q;}else{r.filter=r;return r;}}};function p(q){var r=typeof q=='object';for(var s=0;s<this.length;s++){var t=this[s],u=t.apply(window,arguments);if(typeof u!='undefined'){if(u===false)return false;if(r&&u!=q)return u;}}return null;};})();a.htmlParser.basicWriter=e.createClass({$:function(){this._={output:[]};},proto:{openTag:function(l,m){this._.output.push('<',l);},openTagClose:function(l,m){if(m)this._.output.push(' />');else this._.output.push('>');},attribute:function(l,m){if(typeof m=='string')m=e.htmlEncodeAttr(m);this._.output.push(' ',l,'="',m,'"');},closeTag:function(l){this._.output.push('</',l,'>');},text:function(l){this._.output.push(l);},comment:function(l){this._.output.push('<!--',l,'-->');},write:function(l){this._.output.push(l);},reset:function(){this._.output=[];this._.indent=false;},getHtml:function(l){var m=this._.output.join('');if(l)this.reset();return m;}}});delete a.loadFullCore;a.instances={};a.document=new g(document);a.add=function(l){a.instances[l.name]=l;l.on('focus',function(){if(a.currentInstance!=l){a.currentInstance=l;a.fire('currentInstance');}});l.on('blur',function(){if(a.currentInstance==l){a.currentInstance=null;a.fire('currentInstance');}});};a.remove=function(l){delete a.instances[l.name];};a.TRISTATE_ON=1;a.TRISTATE_OFF=2;a.TRISTATE_DISABLED=0;d.comment=e.createClass({base:d.node,$:function(l,m){if(typeof l=='string')l=(m?m.$:document).createComment(l);this.base(l);},proto:{type:8,getOuterHtml:function(){return '<!--'+this.$.nodeValue+'-->';}}});(function(){var l={address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,dd:1},m={body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1},n=function(o){var p=o.getChildren();for(var q=0,r=p.count();q<r;q++){var s=p.getItem(q);if(s.type==1&&f.$block[s.getName()])return true;}return false;};d.elementPath=function(o){var u=this;
return l.length?l.join(';')+';':false;};},elementMigrateFilter:function(h,i){return function(j){var k=i?new CKEDITOR.style(h,i)._.definition:h;j.name=k.element;CKEDITOR.tools.extend(j.attributes,CKEDITOR.tools.clone(k.attributes));j.addStyle(CKEDITOR.style.getStyleText(k));};},styleMigrateFilter:function(h,i){var j=this.elementMigrateFilter;return function(k,l){var m=new CKEDITOR.htmlParser.element(null),n={};n[i]=k;j(h,n)(m);m.children=l.children;l.children=[m];};},bogusAttrFilter:function(h,i){if(i.name.indexOf('cke:')==-1)return false;},applyStyleFilter:null},getRules:function(h){var i=CKEDITOR.dtd,j=CKEDITOR.tools.extend({},i.$block,i.$listItem,i.$tableContent),k=h.config,l=this.filters,m=l.falsyFilter,n=l.stylesFilter,o=l.elementMigrateFilter,p=CKEDITOR.tools.bind(this.filters.styleMigrateFilter,this.filters),q=l.bogusAttrFilter,r=this.utils.createListBulletMarker,s=l.flattenList,t=l.assembleList,u=this.utils.isListBulletIndicator,v=this.utils.isContainingOnlySpaces,w=this.utils.resolveList,x=this.utils.convertToPx,y=this.utils.getStyleComponents,z=this.utils.listDtdParents,A=k.pasteFromWordRemoveFontStyles!==false,B=k.pasteFromWordRemoveStyles!==false;return{elementNames:[[/meta|link|script/,'']],root:function(C){C.filterChildren();t(C);},elements:{'^':function(C){var D;if(CKEDITOR.env.gecko&&(D=l.applyStyleFilter))D(C);},$:function(C){var D=C.name||'',E=C.attributes;if(D in j&&E.style)E.style=n([[/^(:?width|height)$/,null,x]])(E.style)||'';if(D.match(/h\d/)){C.filterChildren();if(w(C))return;o(k['format_'+D])(C);}else if(D in i.$inline){C.filterChildren();if(v(C))delete C.name;}else if(D.indexOf(':')!=-1&&D.indexOf('cke')==-1){C.filterChildren();if(D=='v:imagedata'){var F=C.attributes['o:href'];if(F)C.attributes.src=F;C.name='img';return;}delete C.name;}if(D in z){C.filterChildren();t(C);}},style:function(C){if(CKEDITOR.env.gecko){var D=C.onlyChild().value.match(/\/\* Style Definitions \*\/([\s\S]*?)\/\*/),E=D&&D[1],F={};if(E){E.replace(/[\n\r]/g,'').replace(/(.+?)\{(.+?)\}/g,function(G,H,I){H=H.split(',');var J=H.length,K;for(var L=0;L<J;L++)CKEDITOR.tools.trim(H[L]).replace(/^(\w+)(\.[\w-]+)?$/g,function(M,N,O){N=N||'*';O=O.substring(1,O.length);if(O.match(/MsoNormal/))return;if(!F[N])F[N]={};if(O)F[N][O]=I;else F[N]=I;});});l.applyStyleFilter=function(G){var H=F['*']?'*':G.name,I=G.attributes&&G.attributes['class'],J;if(H in F){J=F[H];if(typeof J=='object')J=J[I];J&&G.addStyle(J,true);}};}}return false;},p:function(C){C.filterChildren();var D=C.attributes,E=C.parent,F=C.children; if(w(C))return;if(k.enterMode==CKEDITOR.ENTER_BR){delete C.name;C.add(new CKEDITOR.htmlParser.element('br'));}else o(k['format_'+(k.enterMode==CKEDITOR.ENTER_P?'p':'div')])(C);},div:function(C){var D=C.onlyChild();if(D&&D.name=='table'){var E=C.attributes;D.attributes=CKEDITOR.tools.extend(D.attributes,E);E.style&&D.addStyle(E.style);var F=new CKEDITOR.htmlParser.element('div');F.addStyle('clear','both');C.add(F);delete C.name;}},td:function(C){if(C.getAncestor('thead'))C.name='th';},ol:s,ul:s,dl:s,font:function(C){if(!CKEDITOR.env.gecko&&u(C.parent)){delete C.name;return;}C.filterChildren();var D=C.attributes,E=D.style,F=C.parent;if('font'==F.name){CKEDITOR.tools.extend(F.attributes,C.attributes);E&&F.addStyle(E);delete C.name;return;}else{E=E||'';if(D.color){D.color!='#000000'&&(E+='color:'+D.color+';');delete D.color;}if(D.face){E+='font-family:'+D.face+';';delete D.face;}if(D.size){E+='font-size:'+(D.size>3?'large':D.size<3?'small':'medium')+';';delete D.size;}C.name='span';C.addStyle(E);}},span:function(C){if(!CKEDITOR.env.gecko&&u(C.parent))return false;C.filterChildren();if(v(C)){delete C.name;return null;}if(!CKEDITOR.env.gecko&&u(C)){var D=C.firstChild(function(K){return K.value||K.name=='img';}),E=D&&(D.value||'l.'),F=E.match(/^([^\s]+?)([.)]?)$/);return r(F,E);}var G=C.children,H=C.attributes,I=H&&H.style,J=G&&G[0];if(I)H.style=n([['line-height'],[/^font-family$/,null,!A?p(k.font_style,'family'):null],[/^font-size$/,null,!A?p(k.fontSize_style,'size'):null],[/^color$/,null,!A?p(k.colorButton_foreStyle,'color'):null],[/^background-color$/,null,!A?p(k.colorButton_backStyle,'color'):null]])(I,C)||'';return null;},b:o(k.coreStyles_bold),i:o(k.coreStyles_italic),u:o(k.coreStyles_underline),s:o(k.coreStyles_strike),sup:o(k.coreStyles_superscript),sub:o(k.coreStyles_subscript),a:function(C){var D=C.attributes;if(D&&!D.href&&D.name)delete C.name;},'cke:listbullet':function(C){if(C.getAncestor(/h\d/)&&!k.pasteFromWordNumberedHeadingToList)delete C.name;}},attributeNames:[[/^onmouse(:?out|over)/,''],[/^onload$/,''],[/(?:v|o):\w+/,''],[/^lang/,'']],attributes:{style:n(B?[[/^margin$|^margin-(?!bottom|top)/,null,function(C,D,E){if(D.name in {p:1,div:1}){var F=k.contentsLangDirection=='ltr'?'margin-left':'margin-right';if(E=='margin')C=y(E,C,[F])[F];else if(E!=F)return null;if(C&&!d.test(C))return[F,C];}return null;}],[/^clear$/],[/^border.*|margin.*|vertical-align|float$/,null,function(C,D){if(D.name=='img')return C;}],[/^width|height$/,null,function(C,D){if(D.name in {table:1,td:1,th:1,img:1})return C;
},onAttribute:function(q,r,s){var t=this._.attributes[r];if(t){var u=t.filter(s,q,this);if(u===false)return false;if(typeof u!='undefined')return u;}return s;}}});function l(q,r){for(var s=0;q&&s<r.length;s++){var t=r[s];q=q.replace(t[0],t[1]);}return q;};function m(q,r,s){if(typeof r=='function')r=[r];var t,u,v=q.length,w=r&&r.length;if(w){for(t=0;t<v&&q[t].pri<s;t++){}for(u=w-1;u>=0;u--){var x=r[u];if(x){x.pri=s;q.splice(t,0,x);}}}};function n(q,r,s){if(r)for(var t in r){var u=q[t];q[t]=o(u,r[t],s);if(!u)q.$length++;}};function o(q,r,s){if(r){r.pri=s;if(q){if(!q.splice){if(q.pri>s)q=[r,q];else q=[q,r];q.filter=p;}else m(q,r,s);return q;}else{r.filter=r;return r;}}};function p(q){var r=typeof q=='object';for(var s=0;s<this.length;s++){var t=this[s],u=t.apply(window,arguments);if(typeof u!='undefined'){if(u===false)return false;if(r&&u!=q)return u;}}return null;};})();a.htmlParser.basicWriter=e.createClass({$:function(){this._={output:[]};},proto:{openTag:function(l,m){this._.output.push('<',l);},openTagClose:function(l,m){if(m)this._.output.push(' />');else this._.output.push('>');},attribute:function(l,m){if(typeof m=='string')m=e.htmlEncodeAttr(m);this._.output.push(' ',l,'="',m,'"');},closeTag:function(l){this._.output.push('</',l,'>');},text:function(l){this._.output.push(l);},comment:function(l){this._.output.push('<!--',l,'-->');},write:function(l){this._.output.push(l);},reset:function(){this._.output=[];this._.indent=false;},getHtml:function(l){var m=this._.output.join('');if(l)this.reset();return m;}}});delete a.loadFullCore;a.instances={};a.document=new g(document);a.add=function(l){a.instances[l.name]=l;l.on('focus',function(){if(a.currentInstance!=l){a.currentInstance=l;a.fire('currentInstance');}});l.on('blur',function(){if(a.currentInstance==l){a.currentInstance=null;a.fire('currentInstance');}});};a.remove=function(l){delete a.instances[l.name];};a.TRISTATE_ON=1;a.TRISTATE_OFF=2;a.TRISTATE_DISABLED=0;d.comment=e.createClass({base:d.node,$:function(l,m){if(typeof l=='string')l=(m?m.$:document).createComment(l);this.base(l);},proto:{type:8,getOuterHtml:function(){return '<!--'+this.$.nodeValue+'-->';}}});(function(){var l={address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,dd:1},m={body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1},n=function(o){var p=o.getChildren();for(var q=0,r=p.count();q<r;q++){var s=p.getItem(q);if(s.type==1&&f.$block[s.getName()])return true;}return false;};d.elementPath=function(o){var u=this;
true;if(typeof i=="number"&&i<k.length){x=i;if(g=k[i])J=g._fireEvent(q,s,D);if(!g||J!==false)J=h._fireEvent(q,s,D,g)}o(w[q],function(){J=this.call(f,i,s);this.cached&&w[q].splice(H,1);if(J===false)return false;H++});return J}}};typeof a=="string"?flashembed.domReady(function(){var g=document.getElementById(a);if(g){a=g;m()}else throw"Flowplayer cannot access element: "+a;}):m()}function E(a){this.length=a.length;this.each=function(b){o(a,b)};this.size=function(){return a.length}}var p=function(a,
true;if(typeof i=="number"&&i<k.length){x=i;if(g=k[i])J=g._fireEvent(q,s,D);if(!g||J!==false)J=h._fireEvent(q,s,D,g)}o(w[q],function(){J=this.call(f,i,s);this.cached&&w[q].splice(I,1);if(J===false)return false;I++});return J}}};typeof a=="string"?flashembed.domReady(function(){var g=document.getElementById(a);if(g){a=g;m()}else throw"Flowplayer cannot access element: "+a;}):m()}function E(a){this.length=a.length;this.each=function(b){o(a,b)};this.size=function(){return a.length}}var p=function(a,
true;if(typeof i=="number"&&i<k.length){x=i;if(g=k[i])J=g._fireEvent(q,s,D);if(!g||J!==false)J=h._fireEvent(q,s,D,g)}o(w[q],function(){J=this.call(f,i,s);this.cached&&w[q].splice(H,1);if(J===false)return false;H++});return J}}};typeof a=="string"?flashembed.domReady(function(){var g=document.getElementById(a);if(g){a=g;m()}else throw"Flowplayer cannot access element: "+a;}):m()}function E(a){this.length=a.length;this.each=function(b){o(a,b)};this.size=function(){return a.length}}var p=function(a,b,c){var m=this,f={},l={};m.index=b;if(typeof a=="string")a={url:a};v(this,a,true);o("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop".split(","),function(){var h="on"+this;if(h.indexOf("*")!=-1){h=h.substring(0,h.length-1);var k="onBefore"+h.substring(2);m[k]=function(r){y(l,k,r);return m}}m[h]=function(r){y(l,h,r);return m};if(b==-1){if(m[k])c[k]=m[k];if(m[h])c[h]=m[h]}});v(this,{onCuepoint:function(h,k){if(arguments.length==1){f.embedded=[null,h];return m}if(typeof h=="number")h=[h];var r=C();f[r]=[h,k];c.isLoaded()&&c._api().fp_addCuepoints(h,b,r);return m},update:function(h){v(m,h);c.isLoaded()&&c._api().fp_updateClip(h,b);var k=c.getConfig();v(b==-1?k.clip:k.playlist[b],h,true)},_fireEvent:function(h,k,r,w){if(h=="onLoad"){o(f,function(u,x){x[0]&&c._api().fp_addCuepoints(x[0],b,u)});return false}w=w||m;if(h=="onCuepoint"){var j=f[k];if(j)return j[1].call(c,w,r)}if(k&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(h)!=-1){v(w,k);if(k.metaData)if(w.duration)w.fullDuration=k.metaData.duration;else w.duration=k.metaData.duration}var n=true;o(l[h],function(){n=this.call(c,w,k,r)});return n}});if(a.onCuepoint){var F=a.onCuepoint;m.onCuepoint.apply(m,typeof F=="function"?[F]:F);delete a.onCuepoint}o(a,function(h,k){if(typeof k=="function"){y(l,h,k);delete a[h]}});if(b==-1)c.onCuepoint=this.onCuepoint},d=function(a,b,c,m){var f={},l=this,F=false;m&&v(f,m);o(b,function(h,k){if(typeof k=="function"){f[h]=k;delete b[h]}});v(this,
WT_DECLARE_WT_MEMBER(2,"StdLayout.prototype.initResize",function(a,s,i){function p(e,k){if(e.offsetWidth>0)return e.offsetWidth;else{e=l.firstChild.rows[0];var m,n,r,u;r=n=0;for(u=e.childNodes.length;n<u;++n){m=e.childNodes[n];if(m.className!="Wt-vrh"){if(r==k)return m.offsetWidth;r+=m.colSpan}}return 0}}function c(e,k){var m=a.getElement(s).firstChild;b(e).style.width=k+"px";var n,r,u,v;r=n=0;for(u=m.rows.length;n<u;n++){v=m.rows[n];if(v.className!="Wt-hrh"){var w,B,D,F;D=B=0;for(F=v.childNodes.length;B<
WT_DECLARE_WT_MEMBER(2,"StdLayout.prototype.initResize",function(a,s,h){function p(e,k){if(e.offsetWidth>0)return e.offsetWidth;else{e=l.firstChild.rows[0];var m,n,r,u;r=n=0;for(u=e.childNodes.length;n<u;++n){m=e.childNodes[n];if(m.className!="Wt-vrh"){if(r==k)return m.offsetWidth;r+=m.colSpan}}return 0}}function c(e,k){var m=a.getElement(s).firstChild;b(e).style.width=k+"px";var n,r,u,v;r=n=0;for(u=m.rows.length;n<u;n++){v=m.rows[n];if(v.className!="Wt-hrh"){var w,B,D,F;D=B=0;for(F=v.childNodes.length;B<
WT_DECLARE_WT_MEMBER(2,"StdLayout.prototype.initResize",function(a,s,i){function p(e,k){if(e.offsetWidth>0)return e.offsetWidth;else{e=l.firstChild.rows[0];var m,n,r,u;r=n=0;for(u=e.childNodes.length;n<u;++n){m=e.childNodes[n];if(m.className!="Wt-vrh"){if(r==k)return m.offsetWidth;r+=m.colSpan}}return 0}}function c(e,k){var m=a.getElement(s).firstChild;b(e).style.width=k+"px";var n,r,u,v;r=n=0;for(u=m.rows.length;n<u;n++){v=m.rows[n];if(v.className!="Wt-hrh"){var w,B,D,F;D=B=0;for(F=v.childNodes.length;B<
C.abort();C=null}if(C==null)if(S==null)S=setTimeout(function(){p()},q.updateDelay);else if(R){clearTimeout(S);p()}}function o(c){Y=c;da._p_.comm.responseReceived(c)}function p(){S=null;if(q.isIEMobile)feedback=false;if(X){if(!ea){if(confirm("The application was quited, do you want to restart?"))document.location=document.location;ea=true}}else{var c,d,e,g="&rand="+Math.round(Math.random(fa)*1E5);if(v.length>0){c=t();d=c.feedback?setTimeout(B,_$_INDICATOR_TIMEOUT_$_):null;e=false}else{c={result:"signal=poll"}; d=null;e=true}C=da._p_.comm.sendUpdate(ga+g,"request=jsupdate&"+c.result+"&ackId="+Y,d,Y,-1);K=e?setTimeout(y,_$_SERVER_PUSH_TIMEOUT_$_):null}}function w(c,d){var e={},g=v.length;e.signal="user";e.id=typeof c==="string"?c:c==_$_APP_CLASS_$_?"app":c.id;if(typeof d==="object"){e.name=d.name;e.object=d.eventObject;e.event=d.event}else{e.name=d;e.object=e.event=null}e.args=[];for(var h=2;h<arguments.length;++h){var i=arguments[h];i=i===false?0:i===true?1:i.toDateString?i.toDateString():i;e.args[h-2]=
C.abort();C=null}if(C==null)if(M==null){M=setTimeout(function(){p()},q.updateDelay);da=(new Date).getTime()}else if(S){clearTimeout(M);p()}else if((new Date).getTime()-da>q.updateDelay){clearTimeout(M);p()}}function o(c){Y=c;ea._p_.comm.responseReceived(c)}function p(){M=null;if(q.isIEMobile)feedback=false;if(X){if(!fa){if(confirm("The application was quited, do you want to restart?"))document.location=document.location;fa=true}}else{var c,d,e,g="&rand="+Math.round(Math.random(ga)*1E5);if(v.length> 0){c=t();d=c.feedback?setTimeout(B,_$_INDICATOR_TIMEOUT_$_):null;e=false}else{c={result:"signal=poll"};d=null;e=true}C=ea._p_.comm.sendUpdate(ha+g,"request=jsupdate&"+c.result+"&ackId="+Y,d,Y,-1);K=e?setTimeout(y,_$_SERVER_PUSH_TIMEOUT_$_):null}}function w(c,d){var e={},g=v.length;e.signal="user";e.id=typeof c==="string"?c:c==_$_APP_CLASS_$_?"app":c.id;if(typeof d==="object"){e.name=d.name;e.object=d.eventObject;e.event=d.event}else{e.name=d;e.object=e.event=null}e.args=[];for(var h=2;h<arguments.length;++h){var i=
C.abort();C=null}if(C==null)if(S==null)S=setTimeout(function(){p()},q.updateDelay);else if(R){clearTimeout(S);p()}}function o(c){Y=c;da._p_.comm.responseReceived(c)}function p(){S=null;if(q.isIEMobile)feedback=false;if(X){if(!ea){if(confirm("The application was quited, do you want to restart?"))document.location=document.location;ea=true}}else{var c,d,e,g="&rand="+Math.round(Math.random(fa)*1E5);if(v.length>0){c=t();d=c.feedback?setTimeout(B,_$_INDICATOR_TIMEOUT_$_):null;e=false}else{c={result:"signal=poll"};d=null;e=true}C=da._p_.comm.sendUpdate(ga+g,"request=jsupdate&"+c.result+"&ackId="+Y,d,Y,-1);K=e?setTimeout(y,_$_SERVER_PUSH_TIMEOUT_$_):null}}function w(c,d){var e={},g=v.length;e.signal="user";e.id=typeof c==="string"?c:c==_$_APP_CLASS_$_?"app":c.id;if(typeof d==="object"){e.name=d.name;e.object=d.eventObject;e.event=d.event}else{e.name=d;e.object=e.event=null}e.args=[];for(var h=2;h<arguments.length;++h){var i=arguments[h];i=i===false?0:i===true?1:i.toDateString?i.toDateString():i;e.args[h-2]=
function I(c){clearTimeout(c);document.body.style.cursor="auto";if(U!=null){try{U()}catch(d){}U=null}}function B(){document.body.style.cursor="wait";U=hideLoadingIndicator;showLoadingIndicator()}function P(c){ca=c}function E(c){with(window){c&&eval(c);_$_APP_CLASS_$_._p_.autoJavaScript()}}function D(c,d,e){if(!X){if(c==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();E(d);_$_$ifnot_DEBUG_$_()}catch(g){alert("Wt internal error: "+g+", code: "+g.code+", description: "+g.description)}_$_$endif_$_();e&&I(e)}else v=
arguments[h];i=i===false?0:i===true?1:i.toDateString?i.toDateString():i;e.args[h-2]=i}e.feedback=true;v[g]=r(e,g);j()}function P(c,d,e){var g=function(){var i=q.getElement(c);if(i){if(e)i.timer=setTimeout(i.tm,d);else{i.timer=null;i.tm=null}i.onclick()}},h=q.getElement(c);h.timer=setTimeout(g,d);h.tm=g}function G(c,d){setTimeout(function(){if(N[c]===true)d();else N[c]=d},20)}function Z(c){if(N[c]!==true){typeof N[c]!=="undefined"&&N[c]();N[c]=true}}function ia(c,d){var e=false;if(d!="")try{e=!eval("typeof "+
function I(c){clearTimeout(c);document.body.style.cursor="auto";if(U!=null){try{U()}catch(d){}U=null}}function B(){document.body.style.cursor="wait";U=hideLoadingIndicator;showLoadingIndicator()}function P(c){ca=c}function E(c){with(window){c&&eval(c);_$_APP_CLASS_$_._p_.autoJavaScript()}}function D(c,d,e){if(!X){if(c==0){_$_$ifnot_DEBUG_$_();try{_$_$endif_$_();E(d);_$_$ifnot_DEBUG_$_()}catch(g){alert("Wt internal error: "+g+", code: "+g.code+", description: "+g.description)}_$_$endif_$_();e&&I(e)}else v=
false}if(f)N(d);else{var m=document.createElement("script");m.setAttribute("src",d);m.onload=function(){N(d)};m.onreadystatechange=function(){if(m.readyState=="complete"||m.readyState=="loaded")N(d)};document.getElementsByTagName("head")[0].appendChild(m)}}function p(d,c){this.callback=c;this.work=d.length;this.images=[];if(d.length==0)c(this.images);else for(c=0;c<d.length;c++)this.preload(d[c])}function r(d){if(d.ieAlternativeExecuted)return"0";y.emit(d.parentNode,"IeAltnernative");d.style.width=
"complete"||h.readyState=="loaded")M(d)};document.getElementsByTagName("head")[0].appendChild(h)}}function p(d,c){this.callback=c;this.work=d.length;this.images=[];if(d.length==0)c(this.images);else for(c=0;c<d.length;c++)this.preload(d[c])}function r(d){if(d.ieAlternativeExecuted)return"0";x.emit(d.parentNode,"IeAltnernative");d.style.width="";d.ieAlternativeExecuted=true;return"0"}var x=this,o=_$_WT_CLASS_$_,G=0,da=0,O=null,Y={object:null,sourceId:null,mimeType:null,dropOffsetX:null,dragOffsetY:null,
false}if(f)N(d);else{var m=document.createElement("script");m.setAttribute("src",d);m.onload=function(){N(d)};m.onreadystatechange=function(){if(m.readyState=="complete"||m.readyState=="loaded")N(d)};document.getElementsByTagName("head")[0].appendChild(m)}}function p(d,c){this.callback=c;this.work=d.length;this.images=[];if(d.length==0)c(this.images);else for(c=0;c<d.length;c++)this.preload(d[c])}function r(d){if(d.ieAlternativeExecuted)return"0";y.emit(d.parentNode,"IeAltnernative");d.style.width=
(function(){var a=1,b=2,c=4,d=8,e=/^\s*(\d+)((px)|\%)?\s*$/i,f=/(^\s*(\d+)((px)|\%)?\s*$)|^$/i,g=/^\d+px$/,h=function(){var q=this.getValue(),r=this.getDialog(),s=q.match(e);if(s){if(s[2]=='%')m(r,false);q=s[1];}if(r.lockRatio){var t=r.originalElement;if(t.getCustomData('isReady')=='true')if(this.id=='txtHeight'){if(q&&q!='0')q=Math.round(t.$.width*(q/t.$.height));if(!isNaN(q))r.setValueOf('info','txtWidth',q);}else{if(q&&q!='0')q=Math.round(t.$.height*(q/t.$.width));if(!isNaN(q))r.setValueOf('info','txtHeight',q);}}i(r);},i=function(q){if(!q.originalElement||!q.preview)return 1;q.commitContent(c,q.preview);return 0;};function j(){var q=arguments,r=this.getContentElement('advanced','txtdlgGenStyle');r&&r.commit.apply(r,q);this.foreach(function(s){if(s.commit&&s.id!='txtdlgGenStyle')s.commit.apply(s,q);});};var k;function l(q){if(k)return;k=1;var r=this.getDialog(),s=r.imageElement;if(s){this.commit(a,s);q=[].concat(q);var t=q.length,u;for(var v=0;v<t;v++){u=r.getContentElement.apply(r,q[v].split(':'));u&&u.setup(a,s);}}k=0;};var m=function(q,r){var s=q.originalElement,t=CKEDITOR.document.getById('btnLockSizes');if(s.getCustomData('isReady')=='true'){if(r=='check'){var u=q.getValueOf('info','txtWidth'),v=q.getValueOf('info','txtHeight'),w=s.$.width*1000/s.$.height,x=u*1000/v;q.lockRatio=false;if(!u&&!v)q.lockRatio=true;else if(!isNaN(w)&&!isNaN(x))if(Math.round(w)==Math.round(x))q.lockRatio=true;}else if(r!=undefined)q.lockRatio=r;else q.lockRatio=!q.lockRatio;}else if(r!='check')q.lockRatio=false;if(q.lockRatio)t.removeClass('cke_btn_unlocked');else t.addClass('cke_btn_unlocked');var y=q._.editor.lang.image,z=y[q.lockRatio?'unlockRatio':'lockRatio'];t.setAttribute('title',z);t.getFirst().setText(z);return q.lockRatio;},n=function(q){var r=q.originalElement;if(r.getCustomData('isReady')=='true'){q.setValueOf('info','txtWidth',r.$.width);q.setValueOf('info','txtHeight',r.$.height);}i(q);},o=function(q,r){if(q!=a)return;function s(x,y){var z=x.match(e);if(z){if(z[2]=='%'){z[1]+='%';m(t,false);}return z[1];}return y;};var t=this.getDialog(),u='',v=this.id=='txtWidth'?'width':'height',w=r.getAttribute(v);if(w)u=s(w,u);u=s(r.getStyle(v),u);this.setValue(u);},p=function(q,r){var s,t=function(){var v=this.originalElement;v.setCustomData('isReady','true');v.removeListener('load',t);v.removeListener('error',u);v.removeListener('abort',u);CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');if(!this.dontResetSize)n(this);if(this.firstLoad)CKEDITOR.tools.setTimeout(function(){m(this,'check'); },0,this);this.firstLoad=false;this.dontResetSize=false;},u=function(){var x=this;var v=x.originalElement;v.removeListener('load',t);v.removeListener('error',u);v.removeListener('abort',u);var w=CKEDITOR.getUrl(q.skinPath+'images/noimage.png');if(x.preview)x.preview.setAttribute('src',w);CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');m(x,false);};return{title:r=='image'?q.lang.image.title:q.lang.image.titleButton,minWidth:420,minHeight:310,onShow:function(){var B=this;B.imageElement=false;B.linkElement=false;B.imageEditMode=false;B.linkEditMode=false;B.lockRatio=true;B.dontResetSize=false;B.firstLoad=true;B.addLink=false;var v=B.getParentEditor(),w=B.getParentEditor().getSelection(),x=w.getSelectedElement(),y=x&&x.getAscendant('a');CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');s=new CKEDITOR.dom.element('img',v.document);B.preview=CKEDITOR.document.getById('previewImage');B.originalElement=v.document.createElement('img');B.originalElement.setAttribute('alt','');B.originalElement.setCustomData('isReady','false');if(y){B.linkElement=y;B.linkEditMode=true;var z=y.getChildren();if(z.count()==1){var A=z.getItem(0).getName();if(A=='img'||A=='input'){B.imageElement=z.getItem(0);if(B.imageElement.getName()=='img')B.imageEditMode='img';else if(B.imageElement.getName()=='input')B.imageEditMode='input';}}if(r=='image')B.setupContent(b,y);}if(x&&x.getName()=='img'&&!x.getAttribute('_cke_realelement')||x&&x.getName()=='input'&&x.getAttribute('type')=='image'){B.imageEditMode=x.getName();B.imageElement=x;}if(B.imageEditMode){B.cleanImageElement=B.imageElement;B.imageElement=B.cleanImageElement.clone(true,true);B.setupContent(a,B.imageElement);m(B,true);}else B.imageElement=v.document.createElement('img');if(!CKEDITOR.tools.trim(B.getValueOf('info','txtUrl'))){B.preview.removeAttribute('src');B.preview.setStyle('display','none');}},onOk:function(){var w=this;if(w.imageEditMode){var v=w.imageEditMode;if(r=='image'&&v=='input'&&confirm(q.lang.image.button2Img)){v='img';w.imageElement=q.document.createElement('img');w.imageElement.setAttribute('alt','');q.insertElement(w.imageElement);}else if(r!='image'&&v=='img'&&confirm(q.lang.image.img2Button)){v='input';w.imageElement=q.document.createElement('input');w.imageElement.setAttributes({type:'image',alt:''});q.insertElement(w.imageElement);}else{w.imageElement=w.cleanImageElement;delete w.cleanImageElement;}}else{if(r=='image')w.imageElement=q.document.createElement('img'); else{w.imageElement=q.document.createElement('input');w.imageElement.setAttribute('type','image');}w.imageElement.setAttribute('alt','');}if(!w.linkEditMode)w.linkElement=q.document.createElement('a');w.commitContent(a,w.imageElement);w.commitContent(b,w.linkElement);if(!w.imageElement.getAttribute('style'))w.imageElement.removeAttribute('style');if(!w.imageEditMode){if(w.addLink){if(!w.linkEditMode){q.insertElement(w.linkElement);w.linkElement.append(w.imageElement,false);}else q.insertElement(w.imageElement);}else q.insertElement(w.imageElement);}else if(!w.linkEditMode&&w.addLink){q.insertElement(w.linkElement);w.imageElement.appendTo(w.linkElement);}else if(w.linkEditMode&&!w.addLink){q.getSelection().selectElement(w.linkElement);q.insertElement(w.imageElement);}},onLoad:function(){var w=this;if(r!='image')w.hidePage('Link');var v=w._.element.getDocument();w.addFocusable(v.getById('btnResetSize'),5);w.addFocusable(v.getById('btnLockSizes'),5);w.commitContent=j;},onHide:function(){var v=this;if(v.preview)v.commitContent(d,v.preview);if(v.originalElement){v.originalElement.removeListener('load',t);v.originalElement.removeListener('error',u);v.originalElement.removeListener('abort',u);v.originalElement.remove();v.originalElement=false;}delete v.imageElement;},contents:[{id:'info',label:q.lang.image.infoTab,accessKey:'I',elements:[{type:'vbox',padding:0,children:[{type:'hbox',widths:['280px','110px'],align:'right',children:[{id:'txtUrl',type:'text',label:q.lang.common.url,required:true,onChange:function(){var v=this.getDialog(),w=this.getValue();if(w.length>0){v=this.getDialog();var x=v.originalElement;v.preview.removeStyle('display');x.setCustomData('isReady','false');var y=CKEDITOR.document.getById('ImagePreviewLoader');if(y)y.setStyle('display','');x.on('load',t,v);x.on('error',u,v);x.on('abort',u,v);x.setAttribute('src',w);s.setAttribute('src',w);v.preview.setAttribute('src',s.$.src);i(v);}else if(v.preview){v.preview.removeAttribute('src');v.preview.setStyle('display','none');}},setup:function(v,w){if(v==a){var x=w.getAttribute('_cke_saved_src')||w.getAttribute('src'),y=this;this.getDialog().dontResetSize=true;y.setValue(x);y.setInitValue();y.focus();}},commit:function(v,w){var x=this;if(v==a&&(x.getValue()||x.isChanged())){w.setAttribute('_cke_saved_src',decodeURI(x.getValue()));w.setAttribute('src',decodeURI(x.getValue()));}else if(v==d){w.setAttribute('src','');w.removeAttribute('src');}},validate:CKEDITOR.dialog.validate.notEmpty(q.lang.image.urlMissing)},{type:'button',id:'browse',style:'display:inline-block;margin-top:10px;',align:'center',label:q.lang.common.browseServer,hidden:true,filebrowser:'info:txtUrl'}]}]},{id:'txtAlt',type:'text',label:q.lang.image.alt,accessKey:'A','default':'',onChange:function(){i(this.getDialog()); },setup:function(v,w){if(v==a)this.setValue(w.getAttribute('alt'));},commit:function(v,w){var x=this;if(v==a){if(x.getValue()||x.isChanged())w.setAttribute('alt',x.getValue());}else if(v==c)w.setAttribute('alt',x.getValue());else if(v==d)w.removeAttribute('alt');}},{type:'hbox',widths:['140px','240px'],children:[{type:'vbox',padding:10,children:[{type:'hbox',widths:['70%','30%'],children:[{type:'vbox',padding:1,children:[{type:'text',width:'40px',id:'txtWidth',labelLayout:'horizontal',label:q.lang.image.width,onKeyUp:h,onChange:function(){l.call(this,'advanced:txtdlgGenStyle');},validate:function(){var v=this.getValue().match(f);if(!v)alert(q.lang.image.validateWidth);return!!v;},setup:o,commit:function(v,w,x){var y=this.getValue();if(v==a){if(y)w.setStyle('width',CKEDITOR.tools.cssLength(y));else if(!y&&this.isChanged())w.removeStyle('width');!x&&w.removeAttribute('width');}else if(v==c){var z=y.match(e);if(!z){var A=this.getDialog().originalElement;if(A.getCustomData('isReady')=='true')w.setStyle('width',A.$.width+'px');}else w.setStyle('width',y+'px');}else if(v==d){w.removeAttribute('width');w.removeStyle('width');}}},{type:'text',id:'txtHeight',width:'40px',labelLayout:'horizontal',label:q.lang.image.height,onKeyUp:h,onChange:function(){l.call(this,'advanced:txtdlgGenStyle');},validate:function(){var v=this.getValue().match(f);if(!v)alert(q.lang.image.validateHeight);return!!v;},setup:o,commit:function(v,w,x){var y=this.getValue();if(v==a){if(y)w.setStyle('height',CKEDITOR.tools.cssLength(y));else if(!y&&this.isChanged())w.removeStyle('height');if(!x&&v==a)w.removeAttribute('height');}else if(v==c){var z=y.match(e);if(!z){var A=this.getDialog().originalElement;if(A.getCustomData('isReady')=='true')w.setStyle('height',A.$.height+'px');}else w.setStyle('height',y+'px');}else if(v==d){w.removeAttribute('height');w.removeStyle('height');}}}]},{type:'html',style:'margin-top:10px;width:40px;height:40px;',onLoad:function(){var v=CKEDITOR.document.getById('btnResetSize'),w=CKEDITOR.document.getById('btnLockSizes');if(v){v.on('click',function(x){n(this);x.data.preventDefault();},this.getDialog());v.on('mouseover',function(){this.addClass('cke_btn_over');},v);v.on('mouseout',function(){this.removeClass('cke_btn_over');},v);}if(w){w.on('click',function(x){var C=this;var y=m(C),z=C.originalElement,A=C.getValueOf('info','txtWidth');if(z.getCustomData('isReady')=='true'&&A){var B=z.$.height/z.$.width*A;if(!isNaN(B)){C.setValueOf('info','txtHeight',Math.round(B));i(C); }}x.data.preventDefault();},this.getDialog());w.on('mouseover',function(){this.addClass('cke_btn_over');},w);w.on('mouseout',function(){this.removeClass('cke_btn_over');},w);}},html:'<div><a href="javascript:void(0)" tabindex="-1" title="'+q.lang.image.unlockRatio+'" class="cke_btn_locked" id="btnLockSizes" role="button"><span class="cke_label">'+q.lang.image.unlockRatio+'</span></a>'+'<a href="javascript:void(0)" tabindex="-1" title="'+q.lang.image.resetSize+'" class="cke_btn_reset" id="btnResetSize" role="button"><span class="cke_label">'+q.lang.image.resetSize+'</span></a>'+'</div>'}]},{type:'vbox',padding:1,children:[{type:'text',id:'txtBorder',width:'60px',labelLayout:'horizontal',label:q.lang.image.border,'default':'',onKeyUp:function(){i(this.getDialog());},onChange:function(){l.call(this,'advanced:txtdlgGenStyle');},validate:CKEDITOR.dialog.validate.integer(q.lang.image.validateBorder),setup:function(v,w){if(v==a){var x,y=w.getStyle('border-width');y=y&&y.match(/^(\d+px)(?: \1 \1 \1)?$/);x=y&&parseInt(y[1],10);isNaN(parseInt(x,10))&&(x=w.getAttribute('border'));this.setValue(x);}},commit:function(v,w,x){var y=parseInt(this.getValue(),10);if(v==a||v==c){if(!isNaN(y)){w.setStyle('border-width',CKEDITOR.tools.cssLength(y));w.setStyle('border-style','solid');}else if(!y&&this.isChanged()){w.removeStyle('border-width');w.removeStyle('border-style');w.removeStyle('border-color');}if(!x&&v==a)w.removeAttribute('border');}else if(v==d){w.removeAttribute('border');w.removeStyle('border-width');w.removeStyle('border-style');w.removeStyle('border-color');}}},{type:'text',id:'txtHSpace',width:'60px',labelLayout:'horizontal',label:q.lang.image.hSpace,'default':'',onKeyUp:function(){i(this.getDialog());},onChange:function(){l.call(this,'advanced:txtdlgGenStyle');},validate:CKEDITOR.dialog.validate.integer(q.lang.image.validateHSpace),setup:function(v,w){if(v==a){var x,y,z,A=w.getStyle('margin-left'),B=w.getStyle('margin-right');A=A&&A.match(g);B=B&&B.match(g);y=parseInt(A,10);z=parseInt(B,10);x=y==z&&y;isNaN(parseInt(x,10))&&(x=w.getAttribute('hspace'));this.setValue(x);}},commit:function(v,w,x){var y=parseInt(this.getValue(),10);if(v==a||v==c){if(!isNaN(y)){w.setStyle('margin-left',CKEDITOR.tools.cssLength(y));w.setStyle('margin-right',CKEDITOR.tools.cssLength(y));}else if(!y&&this.isChanged()){w.removeStyle('margin-left');w.removeStyle('margin-right');}if(!x&&v==a)w.removeAttribute('hspace');}else if(v==d){w.removeAttribute('hspace');w.removeStyle('margin-left'); w.removeStyle('margin-right');}}},{type:'text',id:'txtVSpace',width:'60px',labelLayout:'horizontal',label:q.lang.image.vSpace,'default':'',onKeyUp:function(){i(this.getDialog());},onChange:function(){l.call(this,'advanced:txtdlgGenStyle');},validate:CKEDITOR.dialog.validate.integer(q.lang.image.validateVSpace),setup:function(v,w){if(v==a){var x,y,z,A=w.getStyle('margin-top'),B=w.getStyle('margin-bottom');A=A&&A.match(g);B=B&&B.match(g);y=parseInt(A,10);z=parseInt(B,10);x=y==z&&y;isNaN(parseInt(x,10))&&(x=w.getAttribute('vspace'));this.setValue(x);}},commit:function(v,w,x){var y=parseInt(this.getValue(),10);if(v==a||v==c){if(!isNaN(y)){w.setStyle('margin-top',CKEDITOR.tools.cssLength(y));w.setStyle('margin-bottom',CKEDITOR.tools.cssLength(y));}else if(!y&&this.isChanged()){w.removeStyle('margin-top');w.removeStyle('margin-bottom');}if(!x&&v==a)w.removeAttribute('vspace');}else if(v==d){w.removeAttribute('vspace');w.removeStyle('margin-top');w.removeStyle('margin-bottom');}}},{id:'cmbAlign',type:'select',labelLayout:'horizontal',widths:['35%','65%'],style:'width:90px',label:q.lang.image.align,'default':'',items:[[q.lang.common.notSet,''],[q.lang.image.alignLeft,'left'],[q.lang.image.alignRight,'right']],onChange:function(){i(this.getDialog());l.call(this,'advanced:txtdlgGenStyle');},setup:function(v,w){if(v==a){var x=w.getStyle('float');switch(x){case 'inherit':case 'none':x='';}!x&&(x=(w.getAttribute('align')||'').toLowerCase());this.setValue(x);}},commit:function(v,w,x){var y=this.getValue();if(v==a||v==c){if(y)w.setStyle('float',y);else w.removeStyle('float');if(!x&&v==a){y=(w.getAttribute('align')||'').toLowerCase();switch(y){case 'left':case 'right':w.removeAttribute('align');}}}else if(v==d)w.removeStyle('float');}}]}]},{type:'vbox',height:'250px',children:[{type:'html',style:'width:95%;',html:'<div>'+CKEDITOR.tools.htmlEncode(q.lang.common.preview)+'<br>'+'<div id="ImagePreviewLoader" style="display:none"><div class="loading">&nbsp;</div></div>'+'<div id="ImagePreviewBox"><table><tr><td>'+'<a href="javascript:void(0)" target="_blank" onclick="return false;" id="previewLink">'+'<img id="previewImage" alt="" /></a>'+(q.config.image_previewText||'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus a, commodo non, facilisis vitae, nulla. Aenean dictum lacinia tortor. Nunc iaculis, nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit, tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus, eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris.')+'</td></tr></table></div></div>'}]}]}]},{id:'Link',label:q.lang.link.title,padding:0,elements:[{id:'txtUrl',type:'text',label:q.lang.common.url,style:'width: 100%','default':'',setup:function(v,w){if(v==b){var x=w.getAttribute('_cke_saved_href'); if(!x)x=w.getAttribute('href');this.setValue(x);}},commit:function(v,w){var x=this;if(v==b)if(x.getValue()||x.isChanged()){w.setAttribute('_cke_saved_href',decodeURI(x.getValue()));w.setAttribute('href','javascript:void(0)/*'+CKEDITOR.tools.getNextNumber()+'*/');if(x.getValue()||!q.config.image_removeLinkByEmptyURL)x.getDialog().addLink=true;}}},{type:'button',id:'browse',filebrowser:{action:'Browse',target:'Link:txtUrl',url:q.config.filebrowserImageBrowseLinkUrl||q.config.filebrowserBrowseUrl},style:'float:right',hidden:true,label:q.lang.common.browseServer},{id:'cmbTarget',type:'select',label:q.lang.common.target,'default':'',items:[[q.lang.common.notSet,''],[q.lang.common.targetNew,'_blank'],[q.lang.common.targetTop,'_top'],[q.lang.common.targetSelf,'_self'],[q.lang.common.targetParent,'_parent']],setup:function(v,w){if(v==b)this.setValue(w.getAttribute('target'));},commit:function(v,w){if(v==b)if(this.getValue()||this.isChanged())w.setAttribute('target',this.getValue());}}]},{id:'Upload',hidden:true,filebrowser:'uploadButton',label:q.lang.image.upload,elements:[{type:'file',id:'upload',label:q.lang.image.btnUpload,style:'height:40px',size:38},{type:'fileButton',id:'uploadButton',filebrowser:'info:txtUrl',label:q.lang.image.btnUpload,'for':['Upload','upload']}]},{id:'advanced',label:q.lang.common.advancedTab,elements:[{type:'hbox',widths:['50%','25%','25%'],children:[{type:'text',id:'linkId',label:q.lang.common.id,setup:function(v,w){if(v==a)this.setValue(w.getAttribute('id'));},commit:function(v,w){if(v==a)if(this.getValue()||this.isChanged())w.setAttribute('id',this.getValue());}},{id:'cmbLangDir',type:'select',style:'width : 100px;',label:q.lang.common.langDir,'default':'',items:[[q.lang.common.notSet,''],[q.lang.common.langDirLtr,'ltr'],[q.lang.common.langDirRtl,'rtl']],setup:function(v,w){if(v==a)this.setValue(w.getAttribute('dir'));},commit:function(v,w){if(v==a)if(this.getValue()||this.isChanged())w.setAttribute('dir',this.getValue());}},{type:'text',id:'txtLangCode',label:q.lang.common.langCode,'default':'',setup:function(v,w){if(v==a)this.setValue(w.getAttribute('lang'));},commit:function(v,w){if(v==a)if(this.getValue()||this.isChanged())w.setAttribute('lang',this.getValue());}}]},{type:'text',id:'txtGenLongDescr',label:q.lang.common.longDescr,setup:function(v,w){if(v==a)this.setValue(w.getAttribute('longDesc'));},commit:function(v,w){if(v==a)if(this.getValue()||this.isChanged())w.setAttribute('longDesc',this.getValue());}},{type:'hbox',widths:['50%','50%'],children:[{type:'text',id:'txtGenClass',label:q.lang.common.cssClass,'default':'',setup:function(v,w){if(v==a)this.setValue(w.getAttribute('class')); },commit:function(v,w){if(v==a)if(this.getValue()||this.isChanged())w.setAttribute('class',this.getValue());}},{type:'text',id:'txtGenTitle',label:q.lang.common.advisoryTitle,'default':'',onChange:function(){i(this.getDialog());},setup:function(v,w){if(v==a)this.setValue(w.getAttribute('title'));},commit:function(v,w){var x=this;if(v==a){if(x.getValue()||x.isChanged())w.setAttribute('title',x.getValue());}else if(v==c)w.setAttribute('title',x.getValue());else if(v==d)w.removeAttribute('title');}}]},{type:'text',id:'txtdlgGenStyle',label:q.lang.common.cssStyle,'default':'',setup:function(v,w){if(v==a){var x=w.getAttribute('style');if(!x&&w.$.style.cssText)x=w.$.style.cssText;this.setValue(x);var y=w.$.style.height,z=w.$.style.width,A=(y?y:'').match(e),B=(z?z:'').match(e);this.attributesInStyle={height:!!A,width:!!B};}},onChange:function(){l.call(this,['info:cmbFloat','info:cmbAlign','info:txtVSpace','info:txtHSpace','info:txtBorder','info:txtWidth','info:txtHeight']);i(this);},commit:function(v,w){if(v==a&&(this.getValue()||this.isChanged()))w.setAttribute('style',this.getValue());}}]}]};};CKEDITOR.dialog.add('image',function(q){return p(q,'image');});CKEDITOR.dialog.add('imagebutton',function(q){return p(q,'imagebutton');});})();
(function(){var a=function(b,c){var d=1,e=2,f=4,g=8,h=/^\s*(\d+)((px)|\%)?\s*$/i,i=/(^\s*(\d+)((px)|\%)?\s*$)|^$/i,j=/^\d+px$/,k=function(){var C=this.getValue(),D=this.getDialog(),E=C.match(h);if(E){if(E[2]=='%')p(D,false);C=E[1];}if(D.lockRatio){var F=D.originalElement;if(F.getCustomData('isReady')=='true')if(this.id=='txtHeight'){if(C&&C!='0')C=Math.round(F.$.width*(C/F.$.height));if(!isNaN(C))D.setValueOf('info','txtWidth',C);}else{if(C&&C!='0')C=Math.round(F.$.height*(C/F.$.width));if(!isNaN(C))D.setValueOf('info','txtHeight',C);}}l(D);},l=function(C){if(!C.originalElement||!C.preview)return 1;C.commitContent(f,C.preview);return 0;};function m(){var C=arguments,D=this.getContentElement('advanced','txtdlgGenStyle');D&&D.commit.apply(D,C);this.foreach(function(E){if(E.commit&&E.id!='txtdlgGenStyle')E.commit.apply(E,C);});};var n;function o(C){if(n)return;n=1;var D=this.getDialog(),E=D.imageElement;if(E){this.commit(d,E);C=[].concat(C);var F=C.length,G;for(var H=0;H<F;H++){G=D.getContentElement.apply(D,C[H].split(':'));G&&G.setup(d,E);}}n=0;};var p=function(C,D){var E=C.originalElement;if(!E)return null;var F=CKEDITOR.document.getById(w);if(E.getCustomData('isReady')=='true'){if(D=='check'){var G=C.getValueOf('info','txtWidth'),H=C.getValueOf('info','txtHeight'),I=E.$.width*1000/E.$.height,J=G*1000/H;C.lockRatio=false;if(!G&&!H)C.lockRatio=true;else if(!isNaN(I)&&!isNaN(J))if(Math.round(I)==Math.round(J))C.lockRatio=true;}else if(D!=undefined)C.lockRatio=D;else C.lockRatio=!C.lockRatio;}else if(D!='check')C.lockRatio=false;if(C.lockRatio)F.removeClass('cke_btn_unlocked');else F.addClass('cke_btn_unlocked');var K=C._.editor.lang.image,L=K[C.lockRatio?'unlockRatio':'lockRatio'];F.setAttribute('title',L);F.getFirst().setText(L);return C.lockRatio;},q=function(C){var D=C.originalElement;if(D.getCustomData('isReady')=='true'){C.setValueOf('info','txtWidth',D.$.width);C.setValueOf('info','txtHeight',D.$.height);}l(C);},r=function(C,D){if(C!=d)return;function E(J,K){var L=J.match(h);if(L){if(L[2]=='%'){L[1]+='%';p(F,false);}return L[1];}return K;};var F=this.getDialog(),G='',H=this.id=='txtWidth'?'width':'height',I=D.getAttribute(H);if(I)G=E(I,G);G=E(D.getStyle(H),G);this.setValue(G);},s,t=function(){var C=this.originalElement;C.setCustomData('isReady','true');C.removeListener('load',t);C.removeListener('error',u);C.removeListener('abort',u);CKEDITOR.document.getById(y).setStyle('display','none');if(!this.dontResetSize)q(this);if(this.firstLoad)CKEDITOR.tools.setTimeout(function(){p(this,'check');
(function(){var a=1,b=2,c=4,d=8,e=/^\s*(\d+)((px)|\%)?\s*$/i,f=/(^\s*(\d+)((px)|\%)?\s*$)|^$/i,g=/^\d+px$/,h=function(){var q=this.getValue(),r=this.getDialog(),s=q.match(e);if(s){if(s[2]=='%')m(r,false);q=s[1];}if(r.lockRatio){var t=r.originalElement;if(t.getCustomData('isReady')=='true')if(this.id=='txtHeight'){if(q&&q!='0')q=Math.round(t.$.width*(q/t.$.height));if(!isNaN(q))r.setValueOf('info','txtWidth',q);}else{if(q&&q!='0')q=Math.round(t.$.height*(q/t.$.width));if(!isNaN(q))r.setValueOf('info','txtHeight',q);}}i(r);},i=function(q){if(!q.originalElement||!q.preview)return 1;q.commitContent(c,q.preview);return 0;};function j(){var q=arguments,r=this.getContentElement('advanced','txtdlgGenStyle');r&&r.commit.apply(r,q);this.foreach(function(s){if(s.commit&&s.id!='txtdlgGenStyle')s.commit.apply(s,q);});};var k;function l(q){if(k)return;k=1;var r=this.getDialog(),s=r.imageElement;if(s){this.commit(a,s);q=[].concat(q);var t=q.length,u;for(var v=0;v<t;v++){u=r.getContentElement.apply(r,q[v].split(':'));u&&u.setup(a,s);}}k=0;};var m=function(q,r){var s=q.originalElement,t=CKEDITOR.document.getById('btnLockSizes');if(s.getCustomData('isReady')=='true'){if(r=='check'){var u=q.getValueOf('info','txtWidth'),v=q.getValueOf('info','txtHeight'),w=s.$.width*1000/s.$.height,x=u*1000/v;q.lockRatio=false;if(!u&&!v)q.lockRatio=true;else if(!isNaN(w)&&!isNaN(x))if(Math.round(w)==Math.round(x))q.lockRatio=true;}else if(r!=undefined)q.lockRatio=r;else q.lockRatio=!q.lockRatio;}else if(r!='check')q.lockRatio=false;if(q.lockRatio)t.removeClass('cke_btn_unlocked');else t.addClass('cke_btn_unlocked');var y=q._.editor.lang.image,z=y[q.lockRatio?'unlockRatio':'lockRatio'];t.setAttribute('title',z);t.getFirst().setText(z);return q.lockRatio;},n=function(q){var r=q.originalElement;if(r.getCustomData('isReady')=='true'){q.setValueOf('info','txtWidth',r.$.width);q.setValueOf('info','txtHeight',r.$.height);}i(q);},o=function(q,r){if(q!=a)return;function s(x,y){var z=x.match(e);if(z){if(z[2]=='%'){z[1]+='%';m(t,false);}return z[1];}return y;};var t=this.getDialog(),u='',v=this.id=='txtWidth'?'width':'height',w=r.getAttribute(v);if(w)u=s(w,u);u=s(r.getStyle(v),u);this.setValue(u);},p=function(q,r){var s,t=function(){var v=this.originalElement;v.setCustomData('isReady','true');v.removeListener('load',t);v.removeListener('error',u);v.removeListener('abort',u);CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');if(!this.dontResetSize)n(this);if(this.firstLoad)CKEDITOR.tools.setTimeout(function(){m(this,'check');},0,this);this.firstLoad=false;this.dontResetSize=false;},u=function(){var x=this;var v=x.originalElement;v.removeListener('load',t);v.removeListener('error',u);v.removeListener('abort',u);var w=CKEDITOR.getUrl(q.skinPath+'images/noimage.png');if(x.preview)x.preview.setAttribute('src',w);CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');m(x,false);};return{title:r=='image'?q.lang.image.title:q.lang.image.titleButton,minWidth:420,minHeight:310,onShow:function(){var B=this;B.imageElement=false;B.linkElement=false;B.imageEditMode=false;B.linkEditMode=false;B.lockRatio=true;B.dontResetSize=false;B.firstLoad=true;B.addLink=false;var v=B.getParentEditor(),w=B.getParentEditor().getSelection(),x=w.getSelectedElement(),y=x&&x.getAscendant('a');CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');s=new CKEDITOR.dom.element('img',v.document);B.preview=CKEDITOR.document.getById('previewImage');B.originalElement=v.document.createElement('img');B.originalElement.setAttribute('alt','');B.originalElement.setCustomData('isReady','false');if(y){B.linkElement=y;B.linkEditMode=true;var z=y.getChildren();if(z.count()==1){var A=z.getItem(0).getName();if(A=='img'||A=='input'){B.imageElement=z.getItem(0);if(B.imageElement.getName()=='img')B.imageEditMode='img';else if(B.imageElement.getName()=='input')B.imageEditMode='input';}}if(r=='image')B.setupContent(b,y);}if(x&&x.getName()=='img'&&!x.getAttribute('_cke_realelement')||x&&x.getName()=='input'&&x.getAttribute('type')=='image'){B.imageEditMode=x.getName();B.imageElement=x;}if(B.imageEditMode){B.cleanImageElement=B.imageElement;B.imageElement=B.cleanImageElement.clone(true,true);B.setupContent(a,B.imageElement);m(B,true);}else B.imageElement=v.document.createElement('img');if(!CKEDITOR.tools.trim(B.getValueOf('info','txtUrl'))){B.preview.removeAttribute('src');B.preview.setStyle('display','none');}},onOk:function(){var w=this;if(w.imageEditMode){var v=w.imageEditMode;if(r=='image'&&v=='input'&&confirm(q.lang.image.button2Img)){v='img';w.imageElement=q.document.createElement('img');w.imageElement.setAttribute('alt','');q.insertElement(w.imageElement);}else if(r!='image'&&v=='img'&&confirm(q.lang.image.img2Button)){v='input';w.imageElement=q.document.createElement('input');w.imageElement.setAttributes({type:'image',alt:''});q.insertElement(w.imageElement);}else{w.imageElement=w.cleanImageElement;delete w.cleanImageElement;}}else{if(r=='image')w.imageElement=q.document.createElement('img');else{w.imageElement=q.document.createElement('input');w.imageElement.setAttribute('type','image');}w.imageElement.setAttribute('alt','');}if(!w.linkEditMode)w.linkElement=q.document.createElement('a');w.commitContent(a,w.imageElement);w.commitContent(b,w.linkElement);if(!w.imageElement.getAttribute('style'))w.imageElement.removeAttribute('style');if(!w.imageEditMode){if(w.addLink){if(!w.linkEditMode){q.insertElement(w.linkElement);w.linkElement.append(w.imageElement,false);}else q.insertElement(w.imageElement);}else q.insertElement(w.imageElement);}else if(!w.linkEditMode&&w.addLink){q.insertElement(w.linkElement);w.imageElement.appendTo(w.linkElement);}else if(w.linkEditMode&&!w.addLink){q.getSelection().selectElement(w.linkElement);q.insertElement(w.imageElement);}},onLoad:function(){var w=this;if(r!='image')w.hidePage('Link');var v=w._.element.getDocument();w.addFocusable(v.getById('btnResetSize'),5);w.addFocusable(v.getById('btnLockSizes'),5);w.commitContent=j;},onHide:function(){var v=this;if(v.preview)v.commitContent(d,v.preview);if(v.originalElement){v.originalElement.removeListener('load',t);v.originalElement.removeListener('error',u);v.originalElement.removeListener('abort',u);v.originalElement.remove();v.originalElement=false;}delete v.imageElement;},contents:[{id:'info',label:q.lang.image.infoTab,accessKey:'I',elements:[{type:'vbox',padding:0,children:[{type:'hbox',widths:['280px','110px'],align:'right',children:[{id:'txtUrl',type:'text',label:q.lang.common.url,required:true,onChange:function(){var v=this.getDialog(),w=this.getValue();if(w.length>0){v=this.getDialog();var x=v.originalElement;v.preview.removeStyle('display');x.setCustomData('isReady','false');var y=CKEDITOR.document.getById('ImagePreviewLoader');if(y)y.setStyle('display','');x.on('load',t,v);x.on('error',u,v);x.on('abort',u,v);x.setAttribute('src',w);s.setAttribute('src',w);v.preview.setAttribute('src',s.$.src);i(v);}else if(v.preview){v.preview.removeAttribute('src');v.preview.setStyle('display','none');}},setup:function(v,w){if(v==a){var x=w.getAttribute('_cke_saved_src')||w.getAttribute('src'),y=this;this.getDialog().dontResetSize=true;y.setValue(x);y.setInitValue();y.focus();}},commit:function(v,w){var x=this;if(v==a&&(x.getValue()||x.isChanged())){w.setAttribute('_cke_saved_src',decodeURI(x.getValue()));w.setAttribute('src',decodeURI(x.getValue()));}else if(v==d){w.setAttribute('src','');w.removeAttribute('src');}},validate:CKEDITOR.dialog.validate.notEmpty(q.lang.image.urlMissing)},{type:'button',id:'browse',style:'display:inline-block;margin-top:10px;',align:'center',label:q.lang.common.browseServer,hidden:true,filebrowser:'info:txtUrl'}]}]},{id:'txtAlt',type:'text',label:q.lang.image.alt,accessKey:'A','default':'',onChange:function(){i(this.getDialog());},setup:function(v,w){if(v==a)this.setValue(w.getAttribute('alt'));},commit:function(v,w){var x=this;if(v==a){if(x.getValue()||x.isChanged())w.setAttribute('alt',x.getValue());}else if(v==c)w.setAttribute('alt',x.getValue());else if(v==d)w.removeAttribute('alt');}},{type:'hbox',widths:['140px','240px'],children:[{type:'vbox',padding:10,children:[{type:'hbox',widths:['70%','30%'],children:[{type:'vbox',padding:1,children:[{type:'text',width:'40px',id:'txtWidth',labelLayout:'horizontal',label:q.lang.image.width,onKeyUp:h,onChange:function(){l.call(this,'advanced:txtdlgGenStyle');},validate:function(){var v=this.getValue().match(f);if(!v)alert(q.lang.image.validateWidth);return!!v;},setup:o,commit:function(v,w,x){var y=this.getValue();if(v==a){if(y)w.setStyle('width',CKEDITOR.tools.cssLength(y));else if(!y&&this.isChanged())w.removeStyle('width');!x&&w.removeAttribute('width');}else if(v==c){var z=y.match(e);if(!z){var A=this.getDialog().originalElement;if(A.getCustomData('isReady')=='true')w.setStyle('width',A.$.width+'px');}else w.setStyle('width',y+'px');}else if(v==d){w.removeAttribute('width');w.removeStyle('width');}}},{type:'text',id:'txtHeight',width:'40px',labelLayout:'horizontal',label:q.lang.image.height,onKeyUp:h,onChange:function(){l.call(this,'advanced:txtdlgGenStyle');},validate:function(){var v=this.getValue().match(f);if(!v)alert(q.lang.image.validateHeight);return!!v;},setup:o,commit:function(v,w,x){var y=this.getValue();if(v==a){if(y)w.setStyle('height',CKEDITOR.tools.cssLength(y));else if(!y&&this.isChanged())w.removeStyle('height');if(!x&&v==a)w.removeAttribute('height');}else if(v==c){var z=y.match(e);if(!z){var A=this.getDialog().originalElement;if(A.getCustomData('isReady')=='true')w.setStyle('height',A.$.height+'px');}else w.setStyle('height',y+'px');}else if(v==d){w.removeAttribute('height');w.removeStyle('height');}}}]},{type:'html',style:'margin-top:10px;width:40px;height:40px;',onLoad:function(){var v=CKEDITOR.document.getById('btnResetSize'),w=CKEDITOR.document.getById('btnLockSizes');if(v){v.on('click',function(x){n(this);x.data.preventDefault();},this.getDialog());v.on('mouseover',function(){this.addClass('cke_btn_over');},v);v.on('mouseout',function(){this.removeClass('cke_btn_over');},v);}if(w){w.on('click',function(x){var C=this;var y=m(C),z=C.originalElement,A=C.getValueOf('info','txtWidth');if(z.getCustomData('isReady')=='true'&&A){var B=z.$.height/z.$.width*A;if(!isNaN(B)){C.setValueOf('info','txtHeight',Math.round(B));i(C);}}x.data.preventDefault();},this.getDialog());w.on('mouseover',function(){this.addClass('cke_btn_over');},w);w.on('mouseout',function(){this.removeClass('cke_btn_over');},w);}},html:'<div><a href="javascript:void(0)" tabindex="-1" title="'+q.lang.image.unlockRatio+'" class="cke_btn_locked" id="btnLockSizes" role="button"><span class="cke_label">'+q.lang.image.unlockRatio+'</span></a>'+'<a href="javascript:void(0)" tabindex="-1" title="'+q.lang.image.resetSize+'" class="cke_btn_reset" id="btnResetSize" role="button"><span class="cke_label">'+q.lang.image.resetSize+'</span></a>'+'</div>'}]},{type:'vbox',padding:1,children:[{type:'text',id:'txtBorder',width:'60px',labelLayout:'horizontal',label:q.lang.image.border,'default':'',onKeyUp:function(){i(this.getDialog());},onChange:function(){l.call(this,'advanced:txtdlgGenStyle');},validate:CKEDITOR.dialog.validate.integer(q.lang.image.validateBorder),setup:function(v,w){if(v==a){var x,y=w.getStyle('border-width');y=y&&y.match(/^(\d+px)(?: \1 \1 \1)?$/);x=y&&parseInt(y[1],10);isNaN(parseInt(x,10))&&(x=w.getAttribute('border'));this.setValue(x);}},commit:function(v,w,x){var y=parseInt(this.getValue(),10);if(v==a||v==c){if(!isNaN(y)){w.setStyle('border-width',CKEDITOR.tools.cssLength(y));w.setStyle('border-style','solid');}else if(!y&&this.isChanged()){w.removeStyle('border-width');w.removeStyle('border-style');w.removeStyle('border-color');}if(!x&&v==a)w.removeAttribute('border');}else if(v==d){w.removeAttribute('border');w.removeStyle('border-width');w.removeStyle('border-style');w.removeStyle('border-color');}}},{type:'text',id:'txtHSpace',width:'60px',labelLayout:'horizontal',label:q.lang.image.hSpace,'default':'',onKeyUp:function(){i(this.getDialog());},onChange:function(){l.call(this,'advanced:txtdlgGenStyle');},validate:CKEDITOR.dialog.validate.integer(q.lang.image.validateHSpace),setup:function(v,w){if(v==a){var x,y,z,A=w.getStyle('margin-left'),B=w.getStyle('margin-right');A=A&&A.match(g);B=B&&B.match(g);y=parseInt(A,10);z=parseInt(B,10);x=y==z&&y;isNaN(parseInt(x,10))&&(x=w.getAttribute('hspace'));this.setValue(x);}},commit:function(v,w,x){var y=parseInt(this.getValue(),10);if(v==a||v==c){if(!isNaN(y)){w.setStyle('margin-left',CKEDITOR.tools.cssLength(y));w.setStyle('margin-right',CKEDITOR.tools.cssLength(y));}else if(!y&&this.isChanged()){w.removeStyle('margin-left');w.removeStyle('margin-right');}if(!x&&v==a)w.removeAttribute('hspace');}else if(v==d){w.removeAttribute('hspace');w.removeStyle('margin-left');w.removeStyle('margin-right');}}},{type:'text',id:'txtVSpace',width:'60px',labelLayout:'horizontal',label:q.lang.image.vSpace,'default':'',onKeyUp:function(){i(this.getDialog());},onChange:function(){l.call(this,'advanced:txtdlgGenStyle');},validate:CKEDITOR.dialog.validate.integer(q.lang.image.validateVSpace),setup:function(v,w){if(v==a){var x,y,z,A=w.getStyle('margin-top'),B=w.getStyle('margin-bottom');A=A&&A.match(g);B=B&&B.match(g);y=parseInt(A,10);z=parseInt(B,10);x=y==z&&y;isNaN(parseInt(x,10))&&(x=w.getAttribute('vspace'));this.setValue(x);}},commit:function(v,w,x){var y=parseInt(this.getValue(),10);if(v==a||v==c){if(!isNaN(y)){w.setStyle('margin-top',CKEDITOR.tools.cssLength(y));w.setStyle('margin-bottom',CKEDITOR.tools.cssLength(y));}else if(!y&&this.isChanged()){w.removeStyle('margin-top');w.removeStyle('margin-bottom');}if(!x&&v==a)w.removeAttribute('vspace');}else if(v==d){w.removeAttribute('vspace');w.removeStyle('margin-top');w.removeStyle('margin-bottom');}}},{id:'cmbAlign',type:'select',labelLayout:'horizontal',widths:['35%','65%'],style:'width:90px',label:q.lang.image.align,'default':'',items:[[q.lang.common.notSet,''],[q.lang.image.alignLeft,'left'],[q.lang.image.alignRight,'right']],onChange:function(){i(this.getDialog());l.call(this,'advanced:txtdlgGenStyle');},setup:function(v,w){if(v==a){var x=w.getStyle('float');switch(x){case 'inherit':case 'none':x='';}!x&&(x=(w.getAttribute('align')||'').toLowerCase());this.setValue(x);}},commit:function(v,w,x){var y=this.getValue();if(v==a||v==c){if(y)w.setStyle('float',y);else w.removeStyle('float');if(!x&&v==a){y=(w.getAttribute('align')||'').toLowerCase();switch(y){case 'left':case 'right':w.removeAttribute('align');}}}else if(v==d)w.removeStyle('float');}}]}]},{type:'vbox',height:'250px',children:[{type:'html',style:'width:95%;',html:'<div>'+CKEDITOR.tools.htmlEncode(q.lang.common.preview)+'<br>'+'<div id="ImagePreviewLoader" style="display:none"><div class="loading">&nbsp;</div></div>'+'<div id="ImagePreviewBox"><table><tr><td>'+'<a href="javascript:void(0)" target="_blank" onclick="return false;" id="previewLink">'+'<img id="previewImage" alt="" /></a>'+(q.config.image_previewText||'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus a, commodo non, facilisis vitae, nulla. Aenean dictum lacinia tortor. Nunc iaculis, nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit, tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus, eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris.')+'</td></tr></table></div></div>'}]}]}]},{id:'Link',label:q.lang.link.title,padding:0,elements:[{id:'txtUrl',type:'text',label:q.lang.common.url,style:'width: 100%','default':'',setup:function(v,w){if(v==b){var x=w.getAttribute('_cke_saved_href');if(!x)x=w.getAttribute('href');this.setValue(x);}},commit:function(v,w){var x=this;if(v==b)if(x.getValue()||x.isChanged()){w.setAttribute('_cke_saved_href',decodeURI(x.getValue()));w.setAttribute('href','javascript:void(0)/*'+CKEDITOR.tools.getNextNumber()+'*/');if(x.getValue()||!q.config.image_removeLinkByEmptyURL)x.getDialog().addLink=true;}}},{type:'button',id:'browse',filebrowser:{action:'Browse',target:'Link:txtUrl',url:q.config.filebrowserImageBrowseLinkUrl||q.config.filebrowserBrowseUrl},style:'float:right',hidden:true,label:q.lang.common.browseServer},{id:'cmbTarget',type:'select',label:q.lang.common.target,'default':'',items:[[q.lang.common.notSet,''],[q.lang.common.targetNew,'_blank'],[q.lang.common.targetTop,'_top'],[q.lang.common.targetSelf,'_self'],[q.lang.common.targetParent,'_parent']],setup:function(v,w){if(v==b)this.setValue(w.getAttribute('target'));},commit:function(v,w){if(v==b)if(this.getValue()||this.isChanged())w.setAttribute('target',this.getValue());}}]},{id:'Upload',hidden:true,filebrowser:'uploadButton',label:q.lang.image.upload,elements:[{type:'file',id:'upload',label:q.lang.image.btnUpload,style:'height:40px',size:38},{type:'fileButton',id:'uploadButton',filebrowser:'info:txtUrl',label:q.lang.image.btnUpload,'for':['Upload','upload']}]},{id:'advanced',label:q.lang.common.advancedTab,elements:[{type:'hbox',widths:['50%','25%','25%'],children:[{type:'text',id:'linkId',label:q.lang.common.id,setup:function(v,w){if(v==a)this.setValue(w.getAttribute('id'));},commit:function(v,w){if(v==a)if(this.getValue()||this.isChanged())w.setAttribute('id',this.getValue());}},{id:'cmbLangDir',type:'select',style:'width : 100px;',label:q.lang.common.langDir,'default':'',items:[[q.lang.common.notSet,''],[q.lang.common.langDirLtr,'ltr'],[q.lang.common.langDirRtl,'rtl']],setup:function(v,w){if(v==a)this.setValue(w.getAttribute('dir'));},commit:function(v,w){if(v==a)if(this.getValue()||this.isChanged())w.setAttribute('dir',this.getValue());}},{type:'text',id:'txtLangCode',label:q.lang.common.langCode,'default':'',setup:function(v,w){if(v==a)this.setValue(w.getAttribute('lang'));},commit:function(v,w){if(v==a)if(this.getValue()||this.isChanged())w.setAttribute('lang',this.getValue());}}]},{type:'text',id:'txtGenLongDescr',label:q.lang.common.longDescr,setup:function(v,w){if(v==a)this.setValue(w.getAttribute('longDesc'));},commit:function(v,w){if(v==a)if(this.getValue()||this.isChanged())w.setAttribute('longDesc',this.getValue());}},{type:'hbox',widths:['50%','50%'],children:[{type:'text',id:'txtGenClass',label:q.lang.common.cssClass,'default':'',setup:function(v,w){if(v==a)this.setValue(w.getAttribute('class'));},commit:function(v,w){if(v==a)if(this.getValue()||this.isChanged())w.setAttribute('class',this.getValue());}},{type:'text',id:'txtGenTitle',label:q.lang.common.advisoryTitle,'default':'',onChange:function(){i(this.getDialog());},setup:function(v,w){if(v==a)this.setValue(w.getAttribute('title'));},commit:function(v,w){var x=this;if(v==a){if(x.getValue()||x.isChanged())w.setAttribute('title',x.getValue());}else if(v==c)w.setAttribute('title',x.getValue());else if(v==d)w.removeAttribute('title');}}]},{type:'text',id:'txtdlgGenStyle',label:q.lang.common.cssStyle,'default':'',setup:function(v,w){if(v==a){var x=w.getAttribute('style');if(!x&&w.$.style.cssText)x=w.$.style.cssText;this.setValue(x);var y=w.$.style.height,z=w.$.style.width,A=(y?y:'').match(e),B=(z?z:'').match(e);this.attributesInStyle={height:!!A,width:!!B};}},onChange:function(){l.call(this,['info:cmbFloat','info:cmbAlign','info:txtVSpace','info:txtHSpace','info:txtBorder','info:txtWidth','info:txtHeight']);i(this);},commit:function(v,w){if(v==a&&(this.getValue()||this.isChanged()))w.setAttribute('style',this.getValue());}}]}]};};CKEDITOR.dialog.add('image',function(q){return p(q,'image');});CKEDITOR.dialog.add('imagebutton',function(q){return p(q,'imagebutton');});})();
N.moveChildren(O);N.remove();O.appendTo(M);if(!c)O.appendBogus();}if(L)M.insertBefore(L);else M.appendTo(H);};function r(A,B,C){var D=j.list.listToArray(B.root,C),E=[];for(var F=0;F<B.contents.length;F++){var G=B.contents[F];G=G.getAscendant('li',true);if(!G||G.getCustomData('list_item_processed'))continue;E.push(G);h.setMarker(C,G,'list_item_processed',true);}var H=null;for(F=0;F<E.length;F++){var I=E[F].getCustomData('listarray_index');D[I].indent=-1;H=I;}for(F=H+1;F<D.length;F++){if(D[F].indent>D[F-1].indent+1){var J=D[F-1].indent+1-D[F].indent,K=D[F].indent;while(D[F]&&D[F].indent>=K){D[F].indent+=J;F++;}F--;}}var L=j.list.arrayToList(D,C,null,A.config.enterMode),M=L.listNode,N,O;function P(Q){if((N=M[Q?'getFirst':'getLast']())&&!(N.is&&N.isBlockBoundary())&&(O=B.root[Q?'getPrevious':'getNext'](d.walker.whitespaces(true)))&&!(O.is&&O.isBlockBoundary({br:1})))A.document.createElement('br')[Q?'insertBefore':'insertAfter'](N);};P(true);P();M.replace(B.root);};function s(A,B){this.name=A;this.type=B;};s.prototype={exec:function(A){A.focus();var B=A.document,C=A.getSelection(),D=C&&C.getRanges();if(!D||D.length<1)return;if(this.state==2){var E=B.getBody();E.trim();if(!E.getFirst()){var F=B.createElement(A.config.enterMode==1?'p':A.config.enterMode==3?'div':'br');F.appendTo(E);D=[new d.range(B)];if(F.is('br')){D[0].setStartBefore(F);D[0].setEndAfter(F);}else D[0].selectNodeContents(F);C.selectRanges(D);}else{var G=D.length==1&&D[0],H=G&&G.getEnclosedNode();if(H&&H.is&&this.type==H.getName())n.call(this,A,1);}}var I=C.createBookmarks(true),J=[],K={};while(D.length>0){G=D.shift();var L=G.getBoundaryNodes(),M=L.startNode,N=L.endNode;if(M.type==1&&M.getName()=='td')G.setStartAt(L.startNode,1);if(N.type==1&&N.getName()=='td')G.setEndAt(L.endNode,2);var O=G.createIterator(),P;O.forceBrBreak=this.state==2;while(P=O.getNextParagraph()){var Q=new d.elementPath(P),R=Q.elements,S=R.length,T=null,U=false,V=Q.blockLimit,W;for(var X=S-1;X>=0&&(W=R[X]);X--){if(l[W.getName()]&&V.contains(W)){V.removeCustomData('list_group_object');var Y=W.getCustomData('list_group_object');if(Y)Y.contents.push(P);else{Y={root:W,contents:[P]};J.push(Y);h.setMarker(K,W,'list_group_object',Y);}U=true;break;}}if(U)continue;var Z=V;if(Z.getCustomData('list_group_object'))Z.getCustomData('list_group_object').contents.push(P);else{Y={root:Z,contents:[P]};h.setMarker(K,Z,'list_group_object',Y);J.push(Y);}}}var aa=[];while(J.length>0){Y=J.shift();if(this.state==2){if(l[Y.root.getName()])p.call(this,A,Y,K,aa);
delete R.attributes.contenteditable;},style:function(R){var S=R.children[0];S&&S.value&&(S.value=e.trim(S.value));if(!R.attributes.type)R.attributes.type='text/css';},title:function(R){var S=R.children[0];S&&(S.value=R.attributes._cke_title||'');}},attributes:{'class':function(R,S){return e.ltrim(R.replace(/(?:^|\s+)cke_[^\s]*/g,''))||false;}},comment:function(R){if(R.substr(0,m.length)==m){if(R.substr(m.length,3)=='{C}')R=R.substr(m.length+3);else R=R.substr(m.length);return new a.htmlParser.cdata(decodeURIComponent(R));}return R;}},y={elements:{}};for(u in t)y.elements[u]=r;if(c)x.attributes.style=function(R,S){return R.toLowerCase();};function z(R){R.attributes.contenteditable='false';};function A(R){delete R.attributes.contenteditable;};for(u in {input:1,textarea:1}){v.elements[u]=z;x.elements[u]=A;}var B=/<((?:a|area|img|input)[\s\S]*?\s)((href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))([^>]*)>/gi,C=/\s_cke_saved_src\s*=/,D=/(?:<style(?=[ >])[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,E=/<cke:encoded>([^<]*)<\/cke:encoded>/gi,F=/(<\/?)((?:object|embed|param|html|body|head|title)[^>]*>)/gi,G=/(<\/?)cke:((?:html|body|head|title)[^>]*>)/gi,H=/<cke:(param|embed)([^>]*?)\/?>(?!\s*<\/cke:\1)/gi;function I(R){return R.replace(B,function(S,T,U,V,W){if(V=='src'&&C.test(S))return S;else return '<'+T+U+' _cke_saved_'+U+W+'>';});};function J(R){return R.replace(D,function(S){return '<cke:encoded>'+encodeURIComponent(S)+'</cke:encoded>';});};function K(R){return R.replace(E,function(S,T){return decodeURIComponent(T);});};function L(R){return R.replace(F,'$1cke:$2');};function M(R){return R.replace(G,'$1$2');};function N(R){return R.replace(H,'<cke:$1$2></cke:$1>');};function O(R){return R.replace(/<!--(?!{cke_protected})[\s\S]+?-->/g,function(S){return '<!--'+m+'{C}'+encodeURIComponent(S).replace(/--/g,'%2D%2D')+'-->';});};function P(R){return R.replace(/<!--\{cke_protected\}\{C\}([\s\S]+?)-->/g,function(S,T){return decodeURIComponent(T);});};function Q(R,S){var T=[],U=/<\!--\{cke_temp(comment)?\}(\d*?)-->/g,V=[/<script[\s\S]*?<\/script>/gi,/<noscript[\s\S]*?<\/noscript>/gi].concat(S);R=R.replace(/<!--[\s\S]*?-->/g,function(X){return '<!--{cke_tempcomment}'+(T.push(X)-1)+'-->';});for(var W=0;W<V.length;W++)R=R.replace(V[W],function(X){X=X.replace(U,function(Y,Z,aa){return T[aa];});return '<!--{cke_temp}'+(T.push(X)-1)+'-->';});R=R.replace(U,function(X,Y,Z){return '<!--'+m+(Y?'{C}':'')+encodeURIComponent(T[Z]).replace(/--/g,'%2D%2D')+'-->';
N.moveChildren(O);N.remove();O.appendTo(M);if(!c)O.appendBogus();}if(L)M.insertBefore(L);else M.appendTo(H);};function r(A,B,C){var D=j.list.listToArray(B.root,C),E=[];for(var F=0;F<B.contents.length;F++){var G=B.contents[F];G=G.getAscendant('li',true);if(!G||G.getCustomData('list_item_processed'))continue;E.push(G);h.setMarker(C,G,'list_item_processed',true);}var H=null;for(F=0;F<E.length;F++){var I=E[F].getCustomData('listarray_index');D[I].indent=-1;H=I;}for(F=H+1;F<D.length;F++){if(D[F].indent>D[F-1].indent+1){var J=D[F-1].indent+1-D[F].indent,K=D[F].indent;while(D[F]&&D[F].indent>=K){D[F].indent+=J;F++;}F--;}}var L=j.list.arrayToList(D,C,null,A.config.enterMode),M=L.listNode,N,O;function P(Q){if((N=M[Q?'getFirst':'getLast']())&&!(N.is&&N.isBlockBoundary())&&(O=B.root[Q?'getPrevious':'getNext'](d.walker.whitespaces(true)))&&!(O.is&&O.isBlockBoundary({br:1})))A.document.createElement('br')[Q?'insertBefore':'insertAfter'](N);};P(true);P();M.replace(B.root);};function s(A,B){this.name=A;this.type=B;};s.prototype={exec:function(A){A.focus();var B=A.document,C=A.getSelection(),D=C&&C.getRanges();if(!D||D.length<1)return;if(this.state==2){var E=B.getBody();E.trim();if(!E.getFirst()){var F=B.createElement(A.config.enterMode==1?'p':A.config.enterMode==3?'div':'br');F.appendTo(E);D=[new d.range(B)];if(F.is('br')){D[0].setStartBefore(F);D[0].setEndAfter(F);}else D[0].selectNodeContents(F);C.selectRanges(D);}else{var G=D.length==1&&D[0],H=G&&G.getEnclosedNode();if(H&&H.is&&this.type==H.getName())n.call(this,A,1);}}var I=C.createBookmarks(true),J=[],K={};while(D.length>0){G=D.shift();var L=G.getBoundaryNodes(),M=L.startNode,N=L.endNode;if(M.type==1&&M.getName()=='td')G.setStartAt(L.startNode,1);if(N.type==1&&N.getName()=='td')G.setEndAt(L.endNode,2);var O=G.createIterator(),P;O.forceBrBreak=this.state==2;while(P=O.getNextParagraph()){var Q=new d.elementPath(P),R=Q.elements,S=R.length,T=null,U=false,V=Q.blockLimit,W;for(var X=S-1;X>=0&&(W=R[X]);X--){if(l[W.getName()]&&V.contains(W)){V.removeCustomData('list_group_object');var Y=W.getCustomData('list_group_object');if(Y)Y.contents.push(P);else{Y={root:W,contents:[P]};J.push(Y);h.setMarker(K,W,'list_group_object',Y);}U=true;break;}}if(U)continue;var Z=V;if(Z.getCustomData('list_group_object'))Z.getCustomData('list_group_object').contents.push(P);else{Y={root:Z,contents:[P]};h.setMarker(K,Z,'list_group_object',Y);J.push(Y);}}}var aa=[];while(J.length>0){Y=J.shift();if(this.state==2){if(l[Y.root.getName()])p.call(this,A,Y,K,aa);
break}if(s.nodeType===1){if(!m){s.sizcache=i;s.sizset=n}if(typeof f!=="string"){if(s===f){u=true;break}}else if(p.filter(f,[s]).length>0){u=s;break}}s=s[c]}j[n]=u}}}var g=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,h=0,k=Object.prototype.toString,l=false,q=true;[0,0].sort(function(){q=false;return 0});var p=function(c,f,i,j){i=i||[];var n=f=f||r;if(f.nodeType!==1&&f.nodeType!==9)return[];if(!c||typeof c!=="string")return i; for(var m=[],t,s,u,J,C=true,F=P(f),D=c;(g.exec(""),t=g.exec(D))!==null;){D=t[3];m.push(t[1]);if(t[2]){J=t[3];break}}if(m.length>1&&w.exec(c))if(m.length===2&&o.relative[m[0]])s=ea(m[0]+m[1],f);else for(s=o.relative[m[0]]?[f]:p(m.shift(),f);m.length;){c=m.shift();if(o.relative[c])c+=m.shift();s=ea(c,s)}else{if(!j&&m.length>1&&f.nodeType===9&&!F&&o.match.ID.test(m[0])&&!o.match.ID.test(m[m.length-1])){t=p.find(m.shift(),f,F);f=t.expr?p.filter(t.expr,t.set)[0]:t.set[0]}if(f){t=j?{expr:m.pop(),set:K(j)}: p.find(m.pop(),m.length===1&&(m[0]==="~"||m[0]==="+")&&f.parentNode?f.parentNode:f,F);s=t.expr?p.filter(t.expr,t.set):t.set;if(m.length>0)u=K(s);else C=false;for(;m.length;){var z=m.pop();t=z;if(o.relative[z])t=m.pop();else z="";if(t==null)t=f;o.relative[z](u,t,F)}}else u=[]}u||(u=s);if(!u)throw"Syntax error, unrecognized expression: "+(z||c);if(k.call(u)==="[object Array]")if(C)if(f&&f.nodeType===1)for(c=0;u[c]!=null;c++){if(u[c]&&(u[c]===true||u[c].nodeType===1&&fa(f,u[c])))i.push(s[c])}else for(c= 0;u[c]!=null;c++)u[c]&&u[c].nodeType===1&&i.push(s[c]);else i.push.apply(i,u);else K(u,i);if(J){p(J,n,i,j);p.uniqueSort(i)}return i};p.uniqueSort=function(c){if(L){l=q;c.sort(L);if(l)for(var f=1;f<c.length;f++)c[f]===c[f-1]&&c.splice(f--,1)}return c};p.matches=function(c,f){return p(c,null,null,f)};p.find=function(c,f,i){var j,n;if(!c)return[];for(var m=0,t=o.order.length;m<t;m++){var s=o.order[m];if(n=o.leftMatch[s].exec(c)){var u=n[1];n.splice(1,1);if(u.substr(u.length-1)!=="\\"){n[1]=(n[1]||"").replace(/\\/g,
break}if(s.nodeType===1){if(!m){s.sizcache=i;s.sizset=n}if(typeof g!=="string"){if(s===g){u=true;break}}else if(p.filter(g,[s]).length>0){u=s;break}}s=s[d]}j[n]=u}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,h=0,k=Object.prototype.toString,l=false,q=true;[0,0].sort(function(){q=false;return 0});var p=function(d,g,i,j){i=i||[];var n=g=g||r;if(g.nodeType!==1&&g.nodeType!==9)return[];if(!d||typeof d!=="string")return i; for(var m=[],t,s,u,J,C=true,F=P(g),D=d;(f.exec(""),t=f.exec(D))!==null;){D=t[3];m.push(t[1]);if(t[2]){J=t[3];break}}if(m.length>1&&w.exec(d))if(m.length===2&&o.relative[m[0]])s=ea(m[0]+m[1],g);else for(s=o.relative[m[0]]?[g]:p(m.shift(),g);m.length;){d=m.shift();if(o.relative[d])d+=m.shift();s=ea(d,s)}else{if(!j&&m.length>1&&g.nodeType===9&&!F&&o.match.ID.test(m[0])&&!o.match.ID.test(m[m.length-1])){t=p.find(m.shift(),g,F);g=t.expr?p.filter(t.expr,t.set)[0]:t.set[0]}if(g){t=j?{expr:m.pop(),set:K(j)}: p.find(m.pop(),m.length===1&&(m[0]==="~"||m[0]==="+")&&g.parentNode?g.parentNode:g,F);s=t.expr?p.filter(t.expr,t.set):t.set;if(m.length>0)u=K(s);else C=false;for(;m.length;){var y=m.pop();t=y;if(o.relative[y])t=m.pop();else y="";if(t==null)t=g;o.relative[y](u,t,F)}}else u=[]}u||(u=s);if(!u)throw"Syntax error, unrecognized expression: "+(y||d);if(k.call(u)==="[object Array]")if(C)if(g&&g.nodeType===1)for(d=0;u[d]!=null;d++){if(u[d]&&(u[d]===true||u[d].nodeType===1&&fa(g,u[d])))i.push(s[d])}else for(d= 0;u[d]!=null;d++)u[d]&&u[d].nodeType===1&&i.push(s[d]);else i.push.apply(i,u);else K(u,i);if(J){p(J,n,i,j);p.uniqueSort(i)}return i};p.uniqueSort=function(d){if(L){l=q;d.sort(L);if(l)for(var g=1;g<d.length;g++)d[g]===d[g-1]&&d.splice(g--,1)}return d};p.matches=function(d,g){return p(d,null,null,g)};p.find=function(d,g,i){var j,n;if(!d)return[];for(var m=0,t=o.order.length;m<t;m++){var s=o.order[m];if(n=o.leftMatch[s].exec(d)){var u=n[1];n.splice(1,1);if(u.substr(u.length-1)!=="\\"){n[1]=(n[1]||"").replace(/\\/g,
break}if(s.nodeType===1){if(!m){s.sizcache=i;s.sizset=n}if(typeof f!=="string"){if(s===f){u=true;break}}else if(p.filter(f,[s]).length>0){u=s;break}}s=s[c]}j[n]=u}}}var g=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,h=0,k=Object.prototype.toString,l=false,q=true;[0,0].sort(function(){q=false;return 0});var p=function(c,f,i,j){i=i||[];var n=f=f||r;if(f.nodeType!==1&&f.nodeType!==9)return[];if(!c||typeof c!=="string")return i;for(var m=[],t,s,u,J,C=true,F=P(f),D=c;(g.exec(""),t=g.exec(D))!==null;){D=t[3];m.push(t[1]);if(t[2]){J=t[3];break}}if(m.length>1&&w.exec(c))if(m.length===2&&o.relative[m[0]])s=ea(m[0]+m[1],f);else for(s=o.relative[m[0]]?[f]:p(m.shift(),f);m.length;){c=m.shift();if(o.relative[c])c+=m.shift();s=ea(c,s)}else{if(!j&&m.length>1&&f.nodeType===9&&!F&&o.match.ID.test(m[0])&&!o.match.ID.test(m[m.length-1])){t=p.find(m.shift(),f,F);f=t.expr?p.filter(t.expr,t.set)[0]:t.set[0]}if(f){t=j?{expr:m.pop(),set:K(j)}:p.find(m.pop(),m.length===1&&(m[0]==="~"||m[0]==="+")&&f.parentNode?f.parentNode:f,F);s=t.expr?p.filter(t.expr,t.set):t.set;if(m.length>0)u=K(s);else C=false;for(;m.length;){var z=m.pop();t=z;if(o.relative[z])t=m.pop();else z="";if(t==null)t=f;o.relative[z](u,t,F)}}else u=[]}u||(u=s);if(!u)throw"Syntax error, unrecognized expression: "+(z||c);if(k.call(u)==="[object Array]")if(C)if(f&&f.nodeType===1)for(c=0;u[c]!=null;c++){if(u[c]&&(u[c]===true||u[c].nodeType===1&&fa(f,u[c])))i.push(s[c])}else for(c=0;u[c]!=null;c++)u[c]&&u[c].nodeType===1&&i.push(s[c]);else i.push.apply(i,u);else K(u,i);if(J){p(J,n,i,j);p.uniqueSort(i)}return i};p.uniqueSort=function(c){if(L){l=q;c.sort(L);if(l)for(var f=1;f<c.length;f++)c[f]===c[f-1]&&c.splice(f--,1)}return c};p.matches=function(c,f){return p(c,null,null,f)};p.find=function(c,f,i){var j,n;if(!c)return[];for(var m=0,t=o.order.length;m<t;m++){var s=o.order[m];if(n=o.leftMatch[s].exec(c)){var u=n[1];n.splice(1,1);if(u.substr(u.length-1)!=="\\"){n[1]=(n[1]||"").replace(/\\/g,
}
};
var padding = function(n) { var s = "0" + n.toString(); return s.substr(s.length - 2); }
a.parentNode.nextSibling;for(;a;){b+=a.offsetLeft;f+=a.offsetTop;if(w(a,"position")=="fixed"){b+=document.body.scrollLeft+document.documentElement.scrollLeft;f+=document.body.scrollTop+document.documentElement.scrollTop;break}l=a.offsetParent;if(l==null)a=null;else{do{a=a.parentNode;if(g.hasTag(a,"DIV")){b-=a.scrollLeft;f-=a.scrollTop}}while(a!=null&&a!=l)}}return{x:b,y:f}};this.widgetCoordinates=function(a,b){b=g.pageCoordinates(b);a=g.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates= function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.windowCoordinates=function(a){a=g.pageCoordinates(a);return{x:a.x-document.body.scrollLeft-document.documentElement.scrollLeft,y:a.y-document.body.scrollTop-document.documentElement.scrollTop}};this.wheelDelta=function(a){var b=
a!=l)}}return{x:b,y:f}};this.widgetCoordinates=function(a,b){b=g.pageCoordinates(b);a=g.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.windowCoordinates=function(a){a=g.pageCoordinates(a);return{x:a.x-
a.parentNode.nextSibling;for(;a;){b+=a.offsetLeft;f+=a.offsetTop;if(w(a,"position")=="fixed"){b+=document.body.scrollLeft+document.documentElement.scrollLeft;f+=document.body.scrollTop+document.documentElement.scrollTop;break}l=a.offsetParent;if(l==null)a=null;else{do{a=a.parentNode;if(g.hasTag(a,"DIV")){b-=a.scrollLeft;f-=a.scrollTop}}while(a!=null&&a!=l)}}return{x:b,y:f}};this.widgetCoordinates=function(a,b){b=g.pageCoordinates(b);a=g.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.windowCoordinates=function(a){a=g.pageCoordinates(a);return{x:a.x-document.body.scrollLeft-document.documentElement.scrollLeft,y:a.y-document.body.scrollTop-document.documentElement.scrollTop}};this.wheelDelta=function(a){var b=
for(;a;){b+=a.offsetLeft;f+=a.offsetTop;if(w(a,"position")=="fixed"){b+=document.body.scrollLeft+document.documentElement.scrollLeft;f+=document.body.scrollTop+document.documentElement.scrollTop;break}l=a.offsetParent;if(l==null)a=null;else{do{a=a.parentNode;if(g.hasTag(a,"DIV")){b-=a.scrollLeft;f-=a.scrollTop}}while(a!=null&&a!=l)}}return{x:b,y:f}};this.widgetCoordinates=function(a,b){b=g.pageCoordinates(b);a=g.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a= window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.windowCoordinates=function(a){a=g.pageCoordinates(a);return{x:a.x-document.body.scrollLeft-document.documentElement.scrollLeft,y:a.y-document.body.scrollTop-document.documentElement.scrollTop}};this.wheelDelta=function(a){var b=0;if(a.wheelDelta)b=
a.parentNode.nextSibling;for(;a;){b+=a.offsetLeft;f+=a.offsetTop;if(w(a,"position")=="fixed"){b+=document.body.scrollLeft+document.documentElement.scrollLeft;f+=document.body.scrollTop+document.documentElement.scrollTop;break}l=a.offsetParent;if(l==null)a=null;else{do{a=a.parentNode;if(g.hasTag(a,"DIV")){b-=a.scrollLeft;f-=a.scrollTop}}while(a!=null&&a!=l)}}return{x:b,y:f}};this.widgetCoordinates=function(a,b){b=g.pageCoordinates(b);a=g.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates= function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.windowCoordinates=function(a){a=g.pageCoordinates(a);return{x:a.x-document.body.scrollLeft-document.documentElement.scrollLeft,y:a.y-document.body.scrollTop-document.documentElement.scrollTop}};this.wheelDelta=function(a){var b=
for(;a;){b+=a.offsetLeft;f+=a.offsetTop;if(w(a,"position")=="fixed"){b+=document.body.scrollLeft+document.documentElement.scrollLeft;f+=document.body.scrollTop+document.documentElement.scrollTop;break}l=a.offsetParent;if(l==null)a=null;else{do{a=a.parentNode;if(g.hasTag(a,"DIV")){b-=a.scrollLeft;f-=a.scrollTop}}while(a!=null&&a!=l)}}return{x:b,y:f}};this.widgetCoordinates=function(a,b){b=g.pageCoordinates(b);a=g.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.windowCoordinates=function(a){a=g.pageCoordinates(a);return{x:a.x-document.body.scrollLeft-document.documentElement.scrollLeft,y:a.y-document.body.scrollTop-document.documentElement.scrollTop}};this.wheelDelta=function(a){var b=0;if(a.wheelDelta)b=
if(k==null)a=null;else{do{a=a.parentNode;if(h.hasTag(a,"DIV")){b-=a.scrollLeft;e-=a.scrollTop}}while(a!=null&&a!=k)}}return{x:b,y:e}};this.widgetCoordinates=function(a,b){b=h.pageCoordinates(b);a=h.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,e=0;if(a.pageX||a.pageY){b=a.pageX;e=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;e=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,
if(j==null)a=null;else{do{a=a.parentNode;if(g.hasTag(a,"DIV")){b-=a.scrollLeft;e-=a.scrollTop}}while(a!=null&&a!=j)}}return{x:b,y:e}};this.widgetCoordinates=function(a,b){b=g.pageCoordinates(b);a=g.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,e=0;if(a.pageX||a.pageY){b=a.pageX;e=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;e=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,
if(k==null)a=null;else{do{a=a.parentNode;if(h.hasTag(a,"DIV")){b-=a.scrollLeft;e-=a.scrollTop}}while(a!=null&&a!=k)}}return{x:b,y:e}};this.widgetCoordinates=function(a,b){b=h.pageCoordinates(b);a=h.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,e=0;if(a.pageX||a.pageY){b=a.pageX;e=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;e=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:e}};this.scrollIntoView=function(a){(a=document.getElementById(a))&&a.scrollIntoView&&a.scrollIntoView(true)};this.getSelectionRange=function(a){var b,e;if(a.selectionStart!=undefined){b=a.selectionStart;e=a.selectionEnd}else if(document.selection){a=$(a).val();e=document.selection.createRange().duplicate();e.moveEnd("character",a.length);b=e.text==""?a.length:a.lastIndexOf(e.text);e=document.selection.createRange().duplicate();e.moveStart("character",-a.length);e=e.text.length}return{start:b,end:e}};
function(a,b){b=g.pageCoordinates(b);a=g.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,e=0;if(a.pageX||a.pageY){b=a.pageX;e=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;e=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:e}};this.scrollIntoView=function(a){(a=document.getElementById(a))&&a.scrollIntoView&&a.scrollIntoView(true)};this.getSelectionRange=
function(a,b){b=h.pageCoordinates(b);a=h.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,e=0;if(a.pageX||a.pageY){b=a.pageX;e=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;e=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:e}};this.scrollIntoView=function(a){(a=document.getElementById(a))&&a.scrollIntoView&&a.scrollIntoView(true)};this.getSelectionRange=
function(a,b){b=g.pageCoordinates(b);a=g.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,e=0;if(a.pageX||a.pageY){b=a.pageX;e=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;e=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:e}};this.scrollIntoView=function(a){(a=document.getElementById(a))&&a.scrollIntoView&&a.scrollIntoView(true)};this.getSelectionRange=
function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.scrollIntoView=function(a){(a=document.getElementById(a))&&a.scrollIntoView&&a.scrollIntoView(true)};this.getSelectionRange=function(a){if(document.selection)if(g.hasTag(a,"TEXTAREA")){var b=document.selection.createRange(),
function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.windowCoordinates=function(a){a=g.pageCoordinates(a);return{x:a.x-document.body.scrollLeft-document.documentElement.scrollLeft,y:a.y-document.body.scrollTop-document.documentElement.scrollTop}};this.scrollIntoView=function(a){(a=
a.parentNode.nextSibling;for(;a;){b+=a.offsetLeft;f+=a.offsetTop;if(w(a,"position")=="fixed"){b+=document.body.scrollLeft+document.documentElement.scrollLeft;f+=document.body.scrollTop+document.documentElement.scrollTop;break}h=a.offsetParent;if(h==null)a=null;else{do{a=a.parentNode;if(g.hasTag(a,"DIV")){b-=a.scrollLeft;f-=a.scrollTop}}while(a!=null&&a!=h)}}return{x:b,y:f}};this.widgetCoordinates=function(a,b){b=g.pageCoordinates(b);a=g.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.scrollIntoView=function(a){(a=document.getElementById(a))&&a.scrollIntoView&&a.scrollIntoView(true)};this.getSelectionRange=function(a){if(document.selection)if(g.hasTag(a,"TEXTAREA")){var b=document.selection.createRange(),
function(a,b){b=k.pageCoordinates(b);a=k.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.scrollIntoView=function(a){(a=document.getElementById(a))&&a.scrollIntoView&&a.scrollIntoView(true)};this.getSelectionRange=
if(m==null)a=null;else{do{a=a.parentNode;if(k.hasTag(a,"DIV")){b-=a.scrollLeft;f-=a.scrollTop}}while(a!=null&&a!=m)}}return{x:b,y:f}};this.widgetCoordinates=function(a,b){b=k.pageCoordinates(b);a=k.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b, y:f}};this.scrollIntoView=function(a){(a=document.getElementById(a))&&a.scrollIntoView&&a.scrollIntoView(true)};this.getSelectionRange=function(a){if(document.selection){var b=document.selection.createRange(),f=b.duplicate();f.moveToElementText(a);f.setEndPoint("EndToEnd",b);a=f.text.length-b.text.length;return{start:a,end:a+b.text.length}}else return{start:a.selectionStart,end:a.selectionEnd}};this.setSelectionRange=function(a,b,f){if(a.createTextRange){a=a.createTextRange();a.collapse(true);a.moveEnd("character",
function(a,b){b=k.pageCoordinates(b);a=k.widgetPageCoordinates(a);return{x:b.x-a.x,y:b.y-a.y}};this.pageCoordinates=function(a){if(!a)a=window.event;var b=0,f=0;if(a.pageX||a.pageY){b=a.pageX;f=a.pageY}else if(a.clientX||a.clientY){b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;f=a.clientY+document.body.scrollTop+document.documentElement.scrollTop}return{x:b,y:f}};this.scrollIntoView=function(a){(a=document.getElementById(a))&&a.scrollIntoView&&a.scrollIntoView(true)};this.getSelectionRange=
d.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return d.dir(a,"parentNode")},parentsUntil:function(a,b,e){return d.dir(a,"parentNode",e)},next:function(a){return d.nth(a,2,"nextSibling")},prev:function(a){return d.nth(a,2,"previousSibling")},nextAll:function(a){return d.dir(a,"nextSibling")},prevAll:function(a){return d.dir(a,"previousSibling")},nextUntil:function(a,b,e){return d.dir(a,"nextSibling",e)},prevUntil:function(a,b,e){return d.dir(a,"previousSibling",
parent: function(a){return a.firstChild;},
d.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return d.dir(a,"parentNode")},parentsUntil:function(a,b,e){return d.dir(a,"parentNode",e)},next:function(a){return d.nth(a,2,"nextSibling")},prev:function(a){return d.nth(a,2,"previousSibling")},nextAll:function(a){return d.dir(a,"nextSibling")},prevAll:function(a){return d.dir(a,"previousSibling")},nextUntil:function(a,b,e){return d.dir(a,"nextSibling",e)},prevUntil:function(a,b,e){return d.dir(a,"previousSibling",
strTune = strTune.gsub('\x12\n', '\n'); strTune = strTune.gsub('\x12', '\n');
strTune = strTune.gsub('\r\n', '\n'); strTune = strTune.gsub('\r', '\n');
this.parse = function(strTune) { tune.reset(); multilineVars.reset(); // Take care of whatever line endings come our way strTune = strTune.gsub('\x12\n', '\n'); strTune = strTune.gsub('\x12', '\n'); strTune += '\n'; // Tacked on temporarily to make the last line continuation work strTune = strTune.replace(/\\([ \t]*)\n/g, "$1 \x12"); // take care of line continuations right away, but keep the same number of characters var lines = strTune.split('\n'); if (lines.last().length === 0) // remove the blank line we added above. lines.pop(); lines.each( function(line) { if (multilineVars.is_in_history) { if (line[1] === ':') { multilineVars.is_in_history = false; parseLine(line); } else tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line))); } else parseLine(line); multilineVars.iChar += line.length + 1; }); tune.cleanUp(); };
} else if (multilineVars.inTextBlock) { if (line.startsWith("%%endtext")) { tune.addMetaText("textBlock", multilineVars.textBlock); multilineVars.inTextBlock = false; } else multilineVars.textBlock += ' ' + line;
this.parse = function(strTune) { tune.reset(); multilineVars.reset(); // Take care of whatever line endings come our way strTune = strTune.gsub('\x12\n', '\n'); strTune = strTune.gsub('\x12', '\n'); strTune += '\n'; // Tacked on temporarily to make the last line continuation work strTune = strTune.replace(/\\([ \t]*)\n/g, "$1 \x12"); // take care of line continuations right away, but keep the same number of characters var lines = strTune.split('\n'); if (lines.last().length === 0) // remove the blank line we added above. lines.pop(); lines.each( function(line) { if (multilineVars.is_in_history) { if (line[1] === ':') { multilineVars.is_in_history = false; parseLine(line); } else tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line))); } else parseLine(line); multilineVars.iChar += line.length + 1; }); tune.cleanUp(); };
tune.reset(); multilineVars.reset(); strTune = strTune.gsub('\r\n', '\n'); strTune = strTune.gsub('\r', '\n'); strTune += '\n'; strTune = strTune.replace(/\n\\.*\n/g, "\n"); strTune = strTune.replace(/\\([ \t]*)\n/g, "$1 \x12"); var lines = strTune.split('\n'); if (lines.last().length === 0) lines.pop(); lines.each( function(line) { if (multilineVars.is_in_history) { if (line[1] === ':') { multilineVars.is_in_history = false; parseLine(line); } else tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line))); } else if (multilineVars.inTextBlock) { if (line.startsWith("%%endtext")) { tune.addMetaText("textBlock", multilineVars.textBlock); multilineVars.inTextBlock = false; } else multilineVars.textBlock += ' ' + line;
tune.reset(); multilineVars.reset(); strTune = strTune.gsub('\r\n', '\n'); strTune = strTune.gsub('\r', '\n'); strTune += '\n'; strTune = strTune.replace(/\n\\.*\n/g, "\n"); strTune = strTune.replace(/\\([ \t]*)\n/g, "$1 \x12"); var lines = strTune.split('\n'); if (lines.last().length === 0) lines.pop(); lines.each( function(line) { if (multilineVars.is_in_history) { if (line[1] === ':') { multilineVars.is_in_history = false; parseLine(line);
this.parse = function(strTune) { tune.reset(); multilineVars.reset(); // Take care of whatever line endings come our way strTune = strTune.gsub('\r\n', '\n'); strTune = strTune.gsub('\r', '\n'); strTune += '\n'; // Tacked on temporarily to make the last line continuation work strTune = strTune.replace(/\n\\.*\n/g, "\n"); // get rid of latex commands. strTune = strTune.replace(/\\([ \t]*)\n/g, "$1 \x12"); // take care of line continuations right away, but keep the same number of characters var lines = strTune.split('\n'); if (lines.last().length === 0) // remove the blank line we added above. lines.pop(); lines.each( function(line) { if (multilineVars.is_in_history) { if (line[1] === ':') { multilineVars.is_in_history = false; parseLine(line); } else tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line))); } else if (multilineVars.inTextBlock) { if (line.startsWith("%%endtext")) { tune.addMetaText("textBlock", multilineVars.textBlock); multilineVars.inTextBlock = false; } else multilineVars.textBlock += ' ' + line; } else parseLine(line); multilineVars.iChar += line.length + 1; }); tune.cleanUp(); };
parseLine(line); multilineVars.iChar += line.length + 1; }); tune.cleanUp(); };
tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line))); } else if (multilineVars.inTextBlock) { if (line.startsWith("%%endtext")) { tune.addMetaText("textBlock", multilineVars.textBlock); multilineVars.inTextBlock = false; } else multilineVars.textBlock += ' ' + line; } else parseLine(line); multilineVars.iChar += line.length + 1; }); tune.cleanUp(); };
this.parse = function(strTune) { tune.reset(); multilineVars.reset(); // Take care of whatever line endings come our way strTune = strTune.gsub('\r\n', '\n'); strTune = strTune.gsub('\r', '\n'); strTune += '\n'; // Tacked on temporarily to make the last line continuation work strTune = strTune.replace(/\n\\.*\n/g, "\n"); // get rid of latex commands. strTune = strTune.replace(/\\([ \t]*)\n/g, "$1 \x12"); // take care of line continuations right away, but keep the same number of characters var lines = strTune.split('\n'); if (lines.last().length === 0) // remove the blank line we added above. lines.pop(); lines.each( function(line) { if (multilineVars.is_in_history) { if (line[1] === ':') { multilineVars.is_in_history = false; parseLine(line); } else tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line))); } else if (multilineVars.inTextBlock) { if (line.startsWith("%%endtext")) { tune.addMetaText("textBlock", multilineVars.textBlock); multilineVars.inTextBlock = false; } else multilineVars.textBlock += ' ' + line; } else parseLine(line); multilineVars.iChar += line.length + 1; }); tune.cleanUp(); };
if (lines.last().length === 0) lines.pop();
this.parse = function(strTune) { tune.reset(); multilineVars.reset(); // Take care of whatever line endings come our way strTune = strTune.gsub('\x12\n', '\n'); strTune = strTune.gsub('\x12', '\n'); strTune = strTune.replace(/\\([ \t]*)\n/g, "$1 \x12"); // take care of line continuations right away, but keep the same number of characters var lines = strTune.split('\n'); lines.each( function(line) { if (multilineVars.is_in_history) { if (line[1] === ':') { multilineVars.is_in_history = false; parseLine(line); } else tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line))); } else parseLine(line); multilineVars.iChar += line.length + 1; }); tune.cleanUp(); };
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(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();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(!z&&m[y])u[y]=y;else u[y]=z;}A.onTagOpen(p,u,x);if(!r&&f.$cdata[p])r=[];continue;}if(p=o[2])A.onComment(p);}if(n.length>q)A.onText(n.substring(q,n.length));}};})();a.htmlParser.comment=function(l){this.value=l;this._={isBlockLike:false};};a.htmlParser.comment.prototype={type:8,writeHtml:function(l,m){var n=this.value;if(m){if(!(n=m.onComment(n,this)))return;if(typeof n!='string'){n.parent=this.parent;n.writeHtml(l,m);return;}}l.comment(n);}};(function(){var l=/[\t\r\n ]{2,}|[\t\r\n]/g;a.htmlParser.text=function(m){this.value=m;this._={isBlockLike:false};};a.htmlParser.text.prototype={type:3,writeHtml:function(m,n){var o=this.value;if(n&&!(o=n.onText(o,this)))return;m.text(o);}};})();(function(){a.htmlParser.cdata=function(l){this.value=l;};a.htmlParser.cdata.prototype={type:3,writeHtml:function(l){l.write(this.value);}};})();a.htmlParser.fragment=function(){this.children=[];this.parent=null;this._={isBlockLike:true,hasInlineStarted:false};};(function(){var l={colgroup:1,dd:1,dt:1,li:1,option:1,p:1,td:1,tfoot:1,th:1,thead:1,tr:1},m=e.extend({table:1,ul:1,ol:1,dl:1},f.table,f.ul,f.ol,f.dl),n=f.$list,o=f.$listItem;a.htmlParser.fragment.fromHtml=function(p,q){var r=new a.htmlParser(),s=[],t=new a.htmlParser.fragment(),u=[],v=[],w=t,x=false,y;function z(E){var F;if(u.length>0)for(var G=0;G<u.length;G++){var H=u[G],I=H.name,J=f[I],K=w.name&&f[w.name];if((!K||K[I])&&(!E||!J||J[E]||!f[E])){if(!F){A();F=1;}H=H.clone();H.parent=w;w=H;u.splice(G,1);G--;}}};function A(){while(v.length)w.add(v.shift());};function B(E,F,G){F=F||w||t;if(q&&!F.type){var H,I;if(E.attributes&&(I=E.attributes._cke_real_element_type))H=I;else H=E.name;if(H&&!(H in f.$body)&&!(H in f.$nonBodyContent)){var J=w;w=F;r.onTagOpen(q,{});F=w;if(G)w=J;}}if(E._.isBlockLike&&E.name!='pre'){var K=E.children.length,L=E.children[K-1],M;if(L&&L.type==3)if(!(M=e.rtrim(L.value)))E.children.length=K-1;else L.value=M;}F.add(E);if(E.returnPoint){w=E.returnPoint;delete E.returnPoint;}};r.onTagOpen=function(E,F,G){var H=new a.htmlParser.element(E,F);if(H.isUnknown&&G)H.isEmpty=true;if(f.$removeEmpty[E]){u.push(H);return;}else if(E=='pre')x=true;else if(E=='br'&&x){w.add(new a.htmlParser.text('\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(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(!z&&m[y])u[y]=y;else u[y]=z;}A.onTagOpen(p,u,x);if(!r&&f.$cdata[p])r=[];continue;}if(p=o[2])A.onComment(p);}if(n.length>q)A.onText(n.substring(q,n.length));}};})();a.htmlParser.comment=function(l){this.value=l;this._={isBlockLike:false};};a.htmlParser.comment.prototype={type:8,writeHtml:function(l,m){var n=this.value;if(m){if(!(n=m.onComment(n,this)))return;if(typeof n!='string'){n.parent=this.parent;n.writeHtml(l,m);return;}}l.comment(n);}};(function(){var l=/[\t\r\n ]{2,}|[\t\r\n]/g;a.htmlParser.text=function(m){this.value=m;this._={isBlockLike:false};};a.htmlParser.text.prototype={type:3,writeHtml:function(m,n){var o=this.value;if(n&&!(o=n.onText(o,this)))return;m.text(o);}};})();(function(){a.htmlParser.cdata=function(l){this.value=l;};a.htmlParser.cdata.prototype={type:3,writeHtml:function(l){l.write(this.value);}};})();a.htmlParser.fragment=function(){this.children=[];this.parent=null;this._={isBlockLike:true,hasInlineStarted:false};};(function(){var l={colgroup:1,dd:1,dt:1,li:1,option:1,p:1,td:1,tfoot:1,th:1,thead:1,tr:1},m=e.extend({table:1,ul:1,ol:1,dl:1},f.table,f.ul,f.ol,f.dl),n=f.$list,o=f.$listItem;a.htmlParser.fragment.fromHtml=function(p,q){var r=new a.htmlParser(),s=[],t=new a.htmlParser.fragment(),u=[],v=[],w=t,x=false,y;function z(E){var F;if(u.length>0)for(var G=0;G<u.length;G++){var H=u[G],I=H.name,J=f[I],K=w.name&&f[w.name];if((!K||K[I])&&(!E||!J||J[E]||!f[E])){if(!F){A();F=1;}H=H.clone();H.parent=w;w=H;u.splice(G,1);G--;}}};function A(E){while(v.length-(E||0)>0)w.add(v.shift());};function B(E,F,G){F=F||w||t;if(q&&!F.type){var H,I;if(E.attributes&&(I=E.attributes._cke_real_element_type))H=I;else H=E.name;if(H&&!(H in f.$body)&&!(H in f.$nonBodyContent)){var J=w;w=F;r.onTagOpen(q,{});F=w;if(G)w=J;}}if(E._.isBlockLike&&E.name!='pre'){var K=E.children.length,L=E.children[K-1],M;if(L&&L.type==3)if(!(M=e.rtrim(L.value)))E.children.length=K-1;else L.value=M;}F.add(E);if(E.returnPoint){w=E.returnPoint;delete E.returnPoint;}};r.onTagOpen=function(E,F,G){var H=new a.htmlParser.element(E,F);if(H.isUnknown&&G)H.isEmpty=true;if(f.$removeEmpty[E]){u.push(H);return;}else if(E=='pre')x=true;else if(E=='br'&&x){w.add(new a.htmlParser.text('\n'));return;}if(E=='br'){v.push(H);return;}var I=w.name,J=I&&(f[I]||(w._.isBlockLike?f.div:f.span));if(J&&!H.isUnknown&&!w.isUnknown&&!J[E]){var K=false,L;if(E in n&&I in n){var M=w.children,N=M[M.length-1];if(!(N&&N.name in o))B(N=new a.htmlParser.element('li'),w);y=w,L=N;}else if(E==I)B(w,w.parent);else{if(m[I]){if(!y)y=w;
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(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();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(!z&&m[y])u[y]=y;else u[y]=z;}A.onTagOpen(p,u,x);if(!r&&f.$cdata[p])r=[];continue;}if(p=o[2])A.onComment(p);}if(n.length>q)A.onText(n.substring(q,n.length));}};})();a.htmlParser.comment=function(l){this.value=l;this._={isBlockLike:false};};a.htmlParser.comment.prototype={type:8,writeHtml:function(l,m){var n=this.value;if(m){if(!(n=m.onComment(n,this)))return;if(typeof n!='string'){n.parent=this.parent;n.writeHtml(l,m);return;}}l.comment(n);}};(function(){var l=/[\t\r\n ]{2,}|[\t\r\n]/g;a.htmlParser.text=function(m){this.value=m;this._={isBlockLike:false};};a.htmlParser.text.prototype={type:3,writeHtml:function(m,n){var o=this.value;if(n&&!(o=n.onText(o,this)))return;m.text(o);}};})();(function(){a.htmlParser.cdata=function(l){this.value=l;};a.htmlParser.cdata.prototype={type:3,writeHtml:function(l){l.write(this.value);}};})();a.htmlParser.fragment=function(){this.children=[];this.parent=null;this._={isBlockLike:true,hasInlineStarted:false};};(function(){var l={colgroup:1,dd:1,dt:1,li:1,option:1,p:1,td:1,tfoot:1,th:1,thead:1,tr:1},m=e.extend({table:1,ul:1,ol:1,dl:1},f.table,f.ul,f.ol,f.dl),n=f.$list,o=f.$listItem;a.htmlParser.fragment.fromHtml=function(p,q){var r=new a.htmlParser(),s=[],t=new a.htmlParser.fragment(),u=[],v=[],w=t,x=false,y;function z(E){var F;if(u.length>0)for(var G=0;G<u.length;G++){var H=u[G],I=H.name,J=f[I],K=w.name&&f[w.name];if((!K||K[I])&&(!E||!J||J[E]||!f[E])){if(!F){A();F=1;}H=H.clone();H.parent=w;w=H;u.splice(G,1);G--;}}};function A(){while(v.length)w.add(v.shift());};function B(E,F,G){F=F||w||t;if(q&&!F.type){var H,I;if(E.attributes&&(I=E.attributes._cke_real_element_type))H=I;else H=E.name;if(H&&!(H in f.$body)&&!(H in f.$nonBodyContent)){var J=w;w=F;r.onTagOpen(q,{});F=w;if(G)w=J;}}if(E._.isBlockLike&&E.name!='pre'){var K=E.children.length,L=E.children[K-1],M;if(L&&L.type==3)if(!(M=e.rtrim(L.value)))E.children.length=K-1;else L.value=M;}F.add(E);if(E.returnPoint){w=E.returnPoint;delete E.returnPoint;}};r.onTagOpen=function(E,F,G){var H=new a.htmlParser.element(E,F);if(H.isUnknown&&G)H.isEmpty=true;if(f.$removeEmpty[E]){u.push(H);return;}else if(E=='pre')x=true;else if(E=='br'&&x){w.add(new a.htmlParser.text('\n'));
var year, month, day, hour, min, sec = null;
I18n.parseDate = function(d) { var matches, date; var year, month, day, hour, min, sec = null; if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) { // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ for (var i = 1; i <= 6; i++) { matches[i] = matches[i] == undefined? 0 : parseInt(matches[i], 10); } // month starts on 0 matches[2] -= 1; if (matches[7]) { date = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6])); } else { date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]); } } else if (typeof(d) == "number") { // UNIX timestamp date = new Date(); date.setTime(d); } else { // an arbitrary javascript string date = new Date(); date.setTime(Date.parse(d)); } return date;};
matches[i] = matches[i] == undefined? 0 : parseInt(matches[i], 10);
matches[i] = parseInt(matches[i], 10) || 0;
I18n.parseDate = function(d) { var matches, date; var year, month, day, hour, min, sec = null; if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) { // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ for (var i = 1; i <= 6; i++) { matches[i] = matches[i] == undefined? 0 : parseInt(matches[i], 10); } // month starts on 0 matches[2] -= 1; if (matches[7]) { date = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6])); } else { date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]); } } else if (typeof(d) == "number") { // UNIX timestamp date = new Date(); date.setTime(d); } else { // an arbitrary javascript string date = new Date(); date.setTime(Date.parse(d)); } return date;};
date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]);
date = new Date(matches[1], matches[2], matches[3]);
I18n.parseDate = function(d) { var matches, date; var year, month, day, hour, min, sec = null; if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) { // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ for (var i = 1; i <= 6; i++) { matches[i] = matches[i] == undefined? 0 : parseInt(matches[i], 10); } // month starts on 0 matches[2] = matches[2] - 1; if (matches[7]) { date = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6])); } else { date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]); } } else if (typeof(d) == "number") { // UNIX timestamp date = new Date(); date.setTime(d); } else { // an arbitrary javascript string date = new Date(); date.setTime(Date.parse(d)); } return date;};
} else if (matches[4]) {
} else {
I18n.parseDate = function(d) { var matches, date; var year, month, day, hour, min, sec = null; if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) { // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ for (var i = 1; i <= 6; i++) { matches[i] = matches[i] == undefined? 0 : parseInt(matches[i], 10); } // month starts on 0 matches[2] = matches[2] - 1; if (matches[7]) { date = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6])); } else if (matches[4]) { date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]); } else { date = new Date(matches[1], matches[2], matches[3]); } } else if (typeof(d) == "number") { // UNIX timestamp date = new Date(); date.setTime(d); } else { // an arbitrary javascript string date = new Date(); date.setTime(Date.parse(d)); } return date;};
} else { date = new Date(matches[1], matches[2], matches[3]);
I18n.parseDate = function(d) { var matches, date; var year, month, day, hour, min, sec = null; if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) { // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ for (var i = 1; i <= 6; i++) { matches[i] = matches[i] == undefined? 0 : parseInt(matches[i], 10); } // month starts on 0 matches[2] = matches[2] - 1; if (matches[7]) { date = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6])); } else if (matches[4]) { date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]); } else { date = new Date(matches[1], matches[2], matches[3]); } } else if (typeof(d) == "number") { // UNIX timestamp date = new Date(); date.setTime(d); } else { // an arbitrary javascript string date = new Date(); date.setTime(Date.parse(d)); } return date;};
if (matches[7]) {
if (matches[7] === undefined) {
I18n.parseDate = function(d) { var matches, date; var year, month, day, hour, min, sec = null; if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) { // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ for (var i = 1; i <= 6; i++) { matches[i] = matches[i] == undefined? 0 : parseInt(matches[i], 10); } // month starts on 0 matches[2] = matches[2] - 1; if (matches[7]) { date = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6])); } else if (matches[4]) { date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]); } else { date = new Date(matches[1], matches[2], matches[3]); } } else if (typeof(d) == "number") { // UNIX timestamp date = new Date(); date.setTime(d); } else { // an arbitrary javascript string date = new Date(); date.setTime(Date.parse(d)); } return date;};
} else if (matches[4]) {
} else if (matches[4] === undefined) {
I18n.parseDate = function(d) { var matches, date; var year, month, day, hour, min, sec = null; if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) { // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ for (var i = 1; i <= 6; i++) { matches[i] = matches[i] == undefined? 0 : parseInt(matches[i], 10); } // month starts on 0 matches[2] = matches[2] - 1; if (matches[7]) { date = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6])); } else if (matches[4]) { date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]); } else { date = new Date(matches[1], matches[2], matches[3]); } } else if (typeof(d) == "number") { // UNIX timestamp date = new Date(); date.setTime(d); } else { // an arbitrary javascript string date = new Date(); date.setTime(Date.parse(d)); } return date;};
if (matches[7] === undefined) {
if (matches[7]) {
I18n.parseDate = function(d) { var matches, date; var year, month, day, hour, min, sec = null; if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) { // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ for (var i = 1; i <= 6; i++) { matches[i] = matches[i] == undefined? 0 : parseInt(matches[i], 10); } // month starts on 0 matches[2] = matches[2] - 1; if (matches[7] === undefined) { date = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6])); } else if (matches[4] === undefined) { date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]); } else { date = new Date(matches[1], matches[2], matches[3]); } } else if (typeof(d) == "number") { // UNIX timestamp date = new Date(); date.setTime(d); } else { // an arbitrary javascript string date = new Date(); date.setTime(Date.parse(d)); } return date;};
} else if (matches[4] === undefined) {
} else if (matches[4]) {
I18n.parseDate = function(d) { var matches, date; var year, month, day, hour, min, sec = null; if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) { // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ for (var i = 1; i <= 6; i++) { matches[i] = matches[i] == undefined? 0 : parseInt(matches[i], 10); } // month starts on 0 matches[2] = matches[2] - 1; if (matches[7] === undefined) { date = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6])); } else if (matches[4] === undefined) { date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]); } else { date = new Date(matches[1], matches[2], matches[3]); } } else if (typeof(d) == "number") { // UNIX timestamp date = new Date(); date.setTime(d); } else { // an arbitrary javascript string date = new Date(); date.setTime(Date.parse(d)); } return date;};
if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) {
matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/); if (matches) {
I18n.parseDate = function(d) { var matches, date; if (matches = d.toString().match(/(\d{4})-(\d{2})-(\d{2})(?:[ |T](\d{2}):(\d{2}):(\d{2}))?(Z)?/)) { // date/time strings: yyyy-mm-dd hh:mm:ss or yyyy-mm-dd or yyyy-mm-ddThh:mm:ssZ for (var i = 1; i <= 6; i++) { matches[i] = parseInt(matches[i], 10) || 0; } // month starts on 0 matches[2] -= 1; if (matches[7]) { date = new Date(Date.UTC(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6])); } else { date = new Date(matches[1], matches[2], matches[3], matches[4], matches[5], matches[6]); } } else if (typeof(d) == "number") { // UNIX timestamp date = new Date(); date.setTime(d); } else { // an arbitrary javascript string date = new Date(); date.setTime(Date.parse(d)); } return date;};
if (!/^\d+$/.test(val)) { return; }
if (!/^-?\d+$/.test(val)) { return; }
function parseDate(val) { if (!val) { return; } if (val.constructor == Date) { return val; } if (typeof val == 'string') { // rfc3339? var els = val.split("-"); if (els.length == 3) { return new Date(integer(els[0]), integer(els[1]) -1, integer(els[2])); } // invalid offset if (!/^\d+$/.test(val)) { return; } // convert to integer val = integer(val); } var date = new Date(); date.setDate(date.getDate() + val); return date; }
if (line.startsWith('%%')) { var err = this.addDirective(line.substring(2)); if (err) warn(err, line, 2);
if (line.startsWith('%%')) { var err = this.addDirective(line.substring(2)); if (err) warn(err, line, 2); return {}; } line = tokenizer.stripComment(line); if (line.length === 0) return {}; if (line.length >= 2) { if (line[1] === ':') { var nextLine = ""; if (line.indexOf('\x12') >= 0 && line[0] !== 'w') { nextLine = line.substring(line.indexOf('\x12')+1); line = line.substring(0, line.indexOf('\x12')); } var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return {}; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': this.resolveTempo(); var result = this.parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, multilineVars.clef); if (result.foundKey) tune.appendStartingElement('key', -1, -1, this.fixKey(multilineVars.clef, multilineVars.key)); } multilineVars.is_in_header = false; break; case 'L': this.setDefaultLength(line, 2, line.length); break; case 'M': multilineVars.origMeter = multilineVars.meter = this.setMeter(line.substring(2)); break; case 'P': if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': var tempo = this.setTempo(line, 2, line.length); if (tempo.type === 'delaySet') multilineVars.tempo = tempo.tempo; else if (tempo.type === 'immediate') tune.metaText.tempo = tempo.tempo; break; case 'T': this.setTitle(line.substring(2)); break; case 'U': this.addUserDefinition(line, 2, line.length); break; case 'V': this.parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) return { newline: true }; break; case 'w': return { words: true }; case 'X': break; case 'E': case 'm': warn("Ignored header", line, 0); break; default: if (nextLine.length) nextLine = "\x12" + nextLine; return { regular: true, str: line+nextLine }; } } if (nextLine.length > 0) return { recurse: true, str: nextLine };
this.parseHeader = function(line) { if (line.startsWith('%%')) { var err = this.addDirective(line.substring(2)); if (err) warn(err, line, 2); return {}; } line = tokenizer.stripComment(line); if (line.length === 0) return {}; if (line.length >= 2) { if (line[1] === ':') { var nextLine = ""; if (line.indexOf('\x12') >= 0 && line[0] !== 'w') { // w: is the only header field that can have a continuation. nextLine = line.substring(line.indexOf('\x12')+1); line = line.substring(0, line.indexOf('\x12')); //This handles a continuation mark on a header field } var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return {}; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': // since the key is the last thing that can happen in the header, we can resolve the tempo now this.resolveTempo(); var result = this.parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, multilineVars.clef); if (result.foundKey) tune.appendStartingElement('key', -1, -1, this.fixKey(multilineVars.clef, multilineVars.key)); } multilineVars.is_in_header = false; // The first key signifies the end of the header. break; case 'L': this.setDefaultLength(line, 2, line.length); break; case 'M': multilineVars.origMeter = multilineVars.meter = this.setMeter(line.substring(2)); break; case 'P': // TODO-PER: There is more to do with parts, but the writer doesn't care. if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': var tempo = this.setTempo(line, 2, line.length); if (tempo.type === 'delaySet') multilineVars.tempo = tempo.tempo; else if (tempo.type === 'immediate') tune.metaText.tempo = tempo.tempo; break; case 'T': this.setTitle(line.substring(2)); break; case 'U': this.addUserDefinition(line, 2, line.length); break; case 'V': this.parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) return { newline: true }; break; case 'w': return { words: true }; break; case 'X': break; case 'E': case 'm': warn("Ignored header", line, 0); break; default: // It wasn't a recognized header value, so parse it as music. if (nextLine.length) nextLine = "\x12" + nextLine; //parseRegularMusicLine(line+nextLine); //nextLine = ""; return { regular: true, str: line+nextLine }; } } if (nextLine.length > 0) return { recurse: true, str: nextLine }; return {}; } } // If we got this far, we have a regular line of mulsic return { regular: true, str: line }; };
line = tokenizer.stripComment(line); if (line.length === 0) return {};
}
this.parseHeader = function(line) { if (line.startsWith('%%')) { var err = this.addDirective(line.substring(2)); if (err) warn(err, line, 2); return {}; } line = tokenizer.stripComment(line); if (line.length === 0) return {}; if (line.length >= 2) { if (line[1] === ':') { var nextLine = ""; if (line.indexOf('\x12') >= 0 && line[0] !== 'w') { // w: is the only header field that can have a continuation. nextLine = line.substring(line.indexOf('\x12')+1); line = line.substring(0, line.indexOf('\x12')); //This handles a continuation mark on a header field } var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return {}; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': // since the key is the last thing that can happen in the header, we can resolve the tempo now this.resolveTempo(); var result = this.parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, multilineVars.clef); if (result.foundKey) tune.appendStartingElement('key', -1, -1, this.fixKey(multilineVars.clef, multilineVars.key)); } multilineVars.is_in_header = false; // The first key signifies the end of the header. break; case 'L': this.setDefaultLength(line, 2, line.length); break; case 'M': multilineVars.origMeter = multilineVars.meter = this.setMeter(line.substring(2)); break; case 'P': // TODO-PER: There is more to do with parts, but the writer doesn't care. if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': var tempo = this.setTempo(line, 2, line.length); if (tempo.type === 'delaySet') multilineVars.tempo = tempo.tempo; else if (tempo.type === 'immediate') tune.metaText.tempo = tempo.tempo; break; case 'T': this.setTitle(line.substring(2)); break; case 'U': this.addUserDefinition(line, 2, line.length); break; case 'V': this.parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) return { newline: true }; break; case 'w': return { words: true }; break; case 'X': break; case 'E': case 'm': warn("Ignored header", line, 0); break; default: // It wasn't a recognized header value, so parse it as music. if (nextLine.length) nextLine = "\x12" + nextLine; //parseRegularMusicLine(line+nextLine); //nextLine = ""; return { regular: true, str: line+nextLine }; } } if (nextLine.length > 0) return { recurse: true, str: nextLine }; return {}; } } // If we got this far, we have a regular line of mulsic return { regular: true, str: line }; };
if (line.length >= 2) { if (line[1] === ':') { var nextLine = ""; if (line.indexOf('\x12') >= 0 && line[0] !== 'w') { nextLine = line.substring(line.indexOf('\x12')+1); line = line.substring(0, line.indexOf('\x12')); } var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return {}; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': this.resolveTempo(); var result = this.parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, multilineVars.clef); if (result.foundKey) tune.appendStartingElement('key', -1, -1, this.fixKey(multilineVars.clef, multilineVars.key)); } multilineVars.is_in_header = false; break; case 'L': this.setDefaultLength(line, 2, line.length); break; case 'M': multilineVars.origMeter = multilineVars.meter = this.setMeter(line.substring(2)); break; case 'P': if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': var tempo = this.setTempo(line, 2, line.length); if (tempo.type === 'delaySet') multilineVars.tempo = tempo.tempo; else if (tempo.type === 'immediate') tune.metaText.tempo = tempo.tempo; break; case 'T': this.setTitle(line.substring(2)); break; case 'U': this.addUserDefinition(line, 2, line.length); break; case 'V': this.parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) return { newline: true }; break; case 'w': return { words: true }; break; case 'X': break; case 'E': case 'm': warn("Ignored header", line, 0); break; default: if (nextLine.length) nextLine = "\x12" + nextLine; return { regular: true, str: line+nextLine }; } } if (nextLine.length > 0) return { recurse: true, str: nextLine }; return {}; } } return { regular: true, str: line }; };
return { regular: true, str: line }; };
this.parseHeader = function(line) { if (line.startsWith('%%')) { var err = this.addDirective(line.substring(2)); if (err) warn(err, line, 2); return {}; } line = tokenizer.stripComment(line); if (line.length === 0) return {}; if (line.length >= 2) { if (line[1] === ':') { var nextLine = ""; if (line.indexOf('\x12') >= 0 && line[0] !== 'w') { // w: is the only header field that can have a continuation. nextLine = line.substring(line.indexOf('\x12')+1); line = line.substring(0, line.indexOf('\x12')); //This handles a continuation mark on a header field } var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return {}; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': // since the key is the last thing that can happen in the header, we can resolve the tempo now this.resolveTempo(); var result = this.parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, multilineVars.clef); if (result.foundKey) tune.appendStartingElement('key', -1, -1, this.fixKey(multilineVars.clef, multilineVars.key)); } multilineVars.is_in_header = false; // The first key signifies the end of the header. break; case 'L': this.setDefaultLength(line, 2, line.length); break; case 'M': multilineVars.origMeter = multilineVars.meter = this.setMeter(line.substring(2)); break; case 'P': // TODO-PER: There is more to do with parts, but the writer doesn't care. if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': var tempo = this.setTempo(line, 2, line.length); if (tempo.type === 'delaySet') multilineVars.tempo = tempo.tempo; else if (tempo.type === 'immediate') tune.metaText.tempo = tempo.tempo; break; case 'T': this.setTitle(line.substring(2)); break; case 'U': this.addUserDefinition(line, 2, line.length); break; case 'V': this.parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) return { newline: true }; break; case 'w': return { words: true }; break; case 'X': break; case 'E': case 'm': warn("Ignored header", line, 0); break; default: // It wasn't a recognized header value, so parse it as music. if (nextLine.length) nextLine = "\x12" + nextLine; //parseRegularMusicLine(line+nextLine); //nextLine = ""; return { regular: true, str: line+nextLine }; } } if (nextLine.length > 0) return { recurse: true, str: nextLine }; return {}; } } // If we got this far, we have a regular line of mulsic return { regular: true, str: line }; };
ret.accidentals = []; keys[key].each(function(k) { ret.accidentals.push(Object.clone(k)); });
ret = this.deepCopyKey(keys[key]);
this.parseKey = function(str) // (and clef) { var origStr = str; // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.verticalPos = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = { type: retClef.token, verticalPos: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret.accidentals = []; keys[key].each(function(k) { ret.accidentals.push(Object.clone(k)); }); } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.accidentals = []; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.accidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.accidentals = []; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.accidentals) ret.accidentals = []; ret.accidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = { type: retClef.token, verticalPos: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); } } if (ret.accidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.accidentals !== undefined) { multilineVars.key = ret; result.foundKey = true; } return result; };
var setMiddle = function(str) {
var setClefMiddle = function(str) {
this.parseKey = function(str) // (and clef) { str = tokenizer.stripComment(str); var origStr = str; if (str.length === 0) { // an empty K: field is the same as K:none str = 'none'; } // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. // TODO: The above description does not seem to be valid as key names rather than indexes are used -- GD var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.verticalPos = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; //TODO multilinevars.key is not set - is this normal? -- GD } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret = this.deepCopyKey({accidentals: keys[key]}); ret.root = retPitch.token; ret.acc = retAcc.token || ""; ret.mode = retMode.token || ""; } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.accidentals = []; ret.root = "HP"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.accidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); ret.root = "Hp"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.accidentals = []; ret.root = "none"; ret.acc = ""; ret.mode = ""; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.accidentals) ret.accidentals = []; ret.accidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); } } if (ret.accidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.accidentals !== undefined) { // Adjust the octave of the accidentals, if necessary ret.accidentals.each(function(acc) { if (retClef.token === 'bass') { //if (acc.note === 'A') acc.note = 'a'; //if (acc.note === 'B') acc.note = 'b'; if (acc.note === 'C') acc.note = 'c'; if (acc.note === 'D' && acc.acc !== 'flat') acc.note = 'd'; if (acc.note === 'E' && acc.acc !== 'flat') acc.note = 'e'; if (acc.note === 'F' && acc.acc !== 'flat') acc.note = 'f'; if (acc.note === 'G' && acc.acc !== 'flat') acc.note = 'g'; } else { if (acc.note === 'a') acc.note = 'A'; if (acc.note === 'b') acc.note = 'B'; if (acc.note === 'C') acc.note = 'c'; } }); multilineVars.key = ret; result.foundKey = true; } return result; };
setMiddle(str);
setClefMiddle(str);
this.parseKey = function(str) // (and clef) { str = tokenizer.stripComment(str); var origStr = str; if (str.length === 0) { // an empty K: field is the same as K:none str = 'none'; } // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. // TODO: The above description does not seem to be valid as key names rather than indexes are used -- GD var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.verticalPos = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; //TODO multilinevars.key is not set - is this normal? -- GD } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret = this.deepCopyKey({accidentals: keys[key]}); ret.root = retPitch.token; ret.acc = retAcc.token || ""; ret.mode = retMode.token || ""; } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.accidentals = []; ret.root = "HP"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.accidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); ret.root = "Hp"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.accidentals = []; ret.root = "none"; ret.acc = ""; ret.mode = ""; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.accidentals) ret.accidentals = []; ret.accidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); } } if (ret.accidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.accidentals !== undefined) { // Adjust the octave of the accidentals, if necessary ret.accidentals.each(function(acc) { if (retClef.token === 'bass') { //if (acc.note === 'A') acc.note = 'a'; //if (acc.note === 'B') acc.note = 'b'; if (acc.note === 'C') acc.note = 'c'; if (acc.note === 'D' && acc.acc !== 'flat') acc.note = 'd'; if (acc.note === 'E' && acc.acc !== 'flat') acc.note = 'e'; if (acc.note === 'F' && acc.acc !== 'flat') acc.note = 'f'; if (acc.note === 'G' && acc.acc !== 'flat') acc.note = 'g'; } else { if (acc.note === 'a') acc.note = 'A'; if (acc.note === 'b') acc.note = 'B'; if (acc.note === 'C') acc.note = 'c'; } }); multilineVars.key = ret; result.foundKey = true; } return result; };
var ret = {};
var ret = { root: 'none', acc: '', mode: '' };
this.parseKey = function(str) // (and clef) { str = tokenizer.stripComment(str); var origStr = str; if (str.length === 0) { // an empty K: field is the same as K:none str = 'none'; } // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. // TODO: The above description does not seem to be valid as key names rather than indexes are used -- GD var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.verticalPos = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; //TODO multilinevars.key is not set - is this normal? -- GD } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret = this.deepCopyKey({accidentals: keys[key]}); ret.root = retPitch.token; ret.acc = retAcc.token || ""; ret.mode = retMode.token || ""; } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.accidentals = []; ret.root = "HP"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.accidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); ret.root = "Hp"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.accidentals = []; ret.root = "none"; ret.acc = ""; ret.mode = ""; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.accidentals) ret.accidentals = []; ret.accidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); } } if (ret.accidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.accidentals !== undefined) { // Adjust the octave of the accidentals, if necessary ret.accidentals.each(function(acc) { if (retClef.token === 'bass') { //if (acc.note === 'A') acc.note = 'a'; //if (acc.note === 'B') acc.note = 'b'; if (acc.note === 'C') acc.note = 'c'; if (acc.note === 'D' && acc.acc !== 'flat') acc.note = 'd'; if (acc.note === 'E' && acc.acc !== 'flat') acc.note = 'e'; if (acc.note === 'F' && acc.acc !== 'flat') acc.note = 'f'; if (acc.note === 'G' && acc.acc !== 'flat') acc.note = 'g'; } else { if (acc.note === 'a') acc.note = 'A'; if (acc.note === 'b') acc.note = 'B'; if (acc.note === 'C') acc.note = 'c'; } }); multilineVars.key = ret; result.foundKey = true; } return result; };
ret.root = "HP"; ret.acc = ""; ret.mode = "";
ret.root = "HP";
this.parseKey = function(str) // (and clef) { str = tokenizer.stripComment(str); var origStr = str; if (str.length === 0) { // an empty K: field is the same as K:none str = 'none'; } // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. // TODO: The above description does not seem to be valid as key names rather than indexes are used -- GD var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.verticalPos = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; //TODO multilinevars.key is not set - is this normal? -- GD } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret = this.deepCopyKey({accidentals: keys[key]}); ret.root = retPitch.token; ret.acc = retAcc.token || ""; ret.mode = retMode.token || ""; } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.accidentals = []; ret.root = "HP"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.accidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); ret.root = "Hp"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.accidentals = []; ret.root = "none"; ret.acc = ""; ret.mode = ""; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.accidentals) ret.accidentals = []; ret.accidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); } } if (ret.accidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.accidentals !== undefined) { // Adjust the octave of the accidentals, if necessary ret.accidentals.each(function(acc) { if (retClef.token === 'bass') { //if (acc.note === 'A') acc.note = 'a'; //if (acc.note === 'B') acc.note = 'b'; if (acc.note === 'C') acc.note = 'c'; if (acc.note === 'D' && acc.acc !== 'flat') acc.note = 'd'; if (acc.note === 'E' && acc.acc !== 'flat') acc.note = 'e'; if (acc.note === 'F' && acc.acc !== 'flat') acc.note = 'f'; if (acc.note === 'G' && acc.acc !== 'flat') acc.note = 'g'; } else { if (acc.note === 'a') acc.note = 'A'; if (acc.note === 'b') acc.note = 'B'; if (acc.note === 'C') acc.note = 'c'; } }); multilineVars.key = ret; result.foundKey = true; } return result; };
ret.root = "Hp"; ret.acc = ""; ret.mode = "";
ret.root = "Hp";
this.parseKey = function(str) // (and clef) { str = tokenizer.stripComment(str); var origStr = str; if (str.length === 0) { // an empty K: field is the same as K:none str = 'none'; } // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. // TODO: The above description does not seem to be valid as key names rather than indexes are used -- GD var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.verticalPos = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; //TODO multilinevars.key is not set - is this normal? -- GD } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret = this.deepCopyKey({accidentals: keys[key]}); ret.root = retPitch.token; ret.acc = retAcc.token || ""; ret.mode = retMode.token || ""; } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.accidentals = []; ret.root = "HP"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.accidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); ret.root = "Hp"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.accidentals = []; ret.root = "none"; ret.acc = ""; ret.mode = ""; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.accidentals) ret.accidentals = []; ret.accidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); } } if (ret.accidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.accidentals !== undefined) { // Adjust the octave of the accidentals, if necessary ret.accidentals.each(function(acc) { if (retClef.token === 'bass') { //if (acc.note === 'A') acc.note = 'a'; //if (acc.note === 'B') acc.note = 'b'; if (acc.note === 'C') acc.note = 'c'; if (acc.note === 'D' && acc.acc !== 'flat') acc.note = 'd'; if (acc.note === 'E' && acc.acc !== 'flat') acc.note = 'e'; if (acc.note === 'F' && acc.acc !== 'flat') acc.note = 'f'; if (acc.note === 'G' && acc.acc !== 'flat') acc.note = 'g'; } else { if (acc.note === 'a') acc.note = 'A'; if (acc.note === 'b') acc.note = 'B'; if (acc.note === 'C') acc.note = 'c'; } }); multilineVars.key = ret; result.foundKey = true; } return result; };
ret.root = "none"; ret.acc = ""; ret.mode = "";
this.parseKey = function(str) // (and clef) { str = tokenizer.stripComment(str); var origStr = str; if (str.length === 0) { // an empty K: field is the same as K:none str = 'none'; } // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. // TODO: The above description does not seem to be valid as key names rather than indexes are used -- GD var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.verticalPos = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; //TODO multilinevars.key is not set - is this normal? -- GD } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret = this.deepCopyKey({accidentals: keys[key]}); ret.root = retPitch.token; ret.acc = retAcc.token || ""; ret.mode = retMode.token || ""; } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.accidentals = []; ret.root = "HP"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.accidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); ret.root = "Hp"; ret.acc = ""; ret.mode = ""; multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.accidentals = []; ret.root = "none"; ret.acc = ""; ret.mode = ""; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.accidentals) ret.accidentals = []; ret.accidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); } } if (ret.accidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.accidentals !== undefined) { // Adjust the octave of the accidentals, if necessary ret.accidentals.each(function(acc) { if (retClef.token === 'bass') { //if (acc.note === 'A') acc.note = 'a'; //if (acc.note === 'B') acc.note = 'b'; if (acc.note === 'C') acc.note = 'c'; if (acc.note === 'D' && acc.acc !== 'flat') acc.note = 'd'; if (acc.note === 'E' && acc.acc !== 'flat') acc.note = 'e'; if (acc.note === 'F' && acc.acc !== 'flat') acc.note = 'f'; if (acc.note === 'G' && acc.acc !== 'flat') acc.note = 'g'; } else { if (acc.note === 'a') acc.note = 'A'; if (acc.note === 'b') acc.note = 'B'; if (acc.note === 'C') acc.note = 'c'; } }); multilineVars.key = ret; result.foundKey = true; } return result; };
var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.middle = parseMiddle(str);
var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.middle = parseMiddle(str); } }; var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { multilineVars.clef = { type: retClef.token, middle: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } ret.extraAccidentals = []; keys[key].each(function(k) { ret.extraAccidentals.push(Object.clone(k)); }); } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.extraAccidentals = []; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.extraAccidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { ret.extraAccidentals = []; str = str.substring(retNone); } } var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.extraAccidentals) ret.extraAccidentals = []; ret.extraAccidentals.push(retExtra.token);
this.parseKey = function(str) // (and clef) { var origStr = str; // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.middle = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = { type: retClef.token, middle: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret.extraAccidentals = []; keys[key].each(function(k) { ret.extraAccidentals.push(Object.clone(k)); }); } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.extraAccidentals = []; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.extraAccidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.extraAccidentals = []; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.extraAccidentals) ret.extraAccidentals = []; ret.extraAccidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = { type: retClef.token, middle: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); } } if (ret.regularKey === undefined && ret.extraAccidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); //ret.regularKey = keys.C; return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.regularKey !== undefined || ret.extraAccidentals !== undefined) { multilineVars.key = ret; result.foundKey = true; } return result; };
}; var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) {
} } retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else {
this.parseKey = function(str) // (and clef) { var origStr = str; // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.middle = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = { type: retClef.token, middle: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret.extraAccidentals = []; keys[key].each(function(k) { ret.extraAccidentals.push(Object.clone(k)); }); } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.extraAccidentals = []; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.extraAccidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.extraAccidentals = []; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.extraAccidentals) ret.extraAccidentals = []; ret.extraAccidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = { type: retClef.token, middle: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); } } if (ret.regularKey === undefined && ret.extraAccidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); //ret.regularKey = keys.C; return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.regularKey !== undefined || ret.extraAccidentals !== undefined) { multilineVars.key = ret; result.foundKey = true; } return result; };
return {foundClef: true};
this.parseKey = function(str) // (and clef) { var origStr = str; // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.middle = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = { type: retClef.token, middle: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret.extraAccidentals = []; keys[key].each(function(k) { ret.extraAccidentals.push(Object.clone(k)); }); } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.extraAccidentals = []; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.extraAccidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.extraAccidentals = []; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.extraAccidentals) ret.extraAccidentals = []; ret.extraAccidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = { type: retClef.token, middle: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); } } if (ret.regularKey === undefined && ret.extraAccidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); //ret.regularKey = keys.C; return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.regularKey !== undefined || ret.extraAccidentals !== undefined) { multilineVars.key = ret; result.foundKey = true; } return result; };
var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } ret.extraAccidentals = []; keys[key].each(function(k) { ret.extraAccidentals.push(Object.clone(k)); }); } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.extraAccidentals = []; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.extraAccidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { ret.extraAccidentals = []; str = str.substring(retNone); } } var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.extraAccidentals) ret.extraAccidentals = []; ret.extraAccidentals.push(retExtra.token); } } } retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { multilineVars.clef = { type: retClef.token, middle: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); } } if (ret.regularKey === undefined && ret.extraAccidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.regularKey !== undefined || ret.extraAccidentals !== undefined) { multilineVars.key = ret; result.foundKey = true; } return result; };
if (ret.regularKey === undefined && ret.extraAccidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.regularKey !== undefined || ret.extraAccidentals !== undefined) { multilineVars.key = ret; result.foundKey = true; } return result; };
this.parseKey = function(str) // (and clef) { var origStr = str; // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.middle = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = { type: retClef.token, middle: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret.extraAccidentals = []; keys[key].each(function(k) { ret.extraAccidentals.push(Object.clone(k)); }); } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.extraAccidentals = []; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.extraAccidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.extraAccidentals = []; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.extraAccidentals) ret.extraAccidentals = []; ret.extraAccidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = { type: retClef.token, middle: calcMiddle(retClef.token, 0) }; str = str.substring(retClef.len); setMiddle(str); } } if (ret.regularKey === undefined && ret.extraAccidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); //ret.regularKey = keys.C; return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.regularKey !== undefined || ret.extraAccidentals !== undefined) { multilineVars.key = ret; result.foundKey = true; } return result; };
if (str.length === 0) { str = 'none'; }
this.parseKey = function(str) // (and clef) { var origStr = str; // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. var setMiddle = function(str) { var i = tokenizer.skipWhiteSpace(str); str = str.substring(i); if (str.startsWith('m=') || str.startsWith('middle=')) { str = str.substring(str.indexOf('=')+1); multilineVars.clef.verticalPos = parseMiddle(str); } }; // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); return {foundClef: true}; } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } // We need to do a deep copy because we are going to modify it ret = this.deepCopyKey(keys[key]); } else if (str.startsWith('HP')) { this.addDirective("bagpipes"); ret.accidentals = []; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.accidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; this.addDirective("bagpipes"); multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.accidentals = []; str = str.substring(retNone); } } // There are two special cases of deprecated syntax. Ignore them if they occur var j = tokenizer.skipWhiteSpace(str); str = str.substring(j); if (str.startsWith('exp') || str.startsWith('oct')) str = str.substring(3); // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) warn("error parsing extra accidentals:", origStr, 0); else { if (!ret.accidentals) ret.accidentals = []; ret.accidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) warn("error parsing clef:" + retClef.warn, origStr, 0); else { //ret.clef = retClef.token; multilineVars.clef = {type: retClef.token, verticalPos: calcMiddle(retClef.token, 0)}; str = str.substring(retClef.len); setMiddle(str); } } if (ret.accidentals === undefined && retClef.token === undefined) { warn("error parsing key: ", origStr, 0); return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.accidentals !== undefined) { multilineVars.key = ret; result.foundKey = true; } return result; };
multilineVars.clef = retClef.token;
multilineVars.clef = { type: retClef.token }; str = str.substring(retClef.len); setMiddle(str);
var parseKey = function(str) // (and clef) { var origStr = str; // The format is: // [space][tonic[#|b][ ][3-letter-mode][ignored-chars][space]][ accidentals...][ clef=treble|bass|bass3|tenor|alto|alto2|alto1|none [+8|-8]] // -- or -- the key can be "none" // First get the key letter: turn that into a index into the key array (0-11) // Then see if there is a sharp or flat. Increment or decrement. // Then see if there is a mode modifier. Add or subtract to the index. // Then do a mod 12 on the index and return the key. // TODO: This may leave unparsed characters at the end after something reasonable was found. // check first to see if there is only a clef. If so, just take that, but ignore an error after that. var retClef = tokenizer.getClef(str); if (retClef.token !== undefined && (retClef.explicit === true || retClef.token !== 'none')) { // none is the only ambiguous marking. We need to assume that's a key multilineVars.clef = retClef.token; return {foundClef: true}; } var ret = {}; var retPitch = tokenizer.getKeyPitch(str); if (retPitch.len > 0) { var key = retPitch.token; str = str.substring(retPitch.len); // We got a pitch to start with, so we might also have an accidental and a mode var retAcc = tokenizer.getSharpFlat(str); if (retAcc.len > 0) { key += retAcc.token; str = str.substring(retAcc.len); } var retMode = tokenizer.getMode(str); if (retMode.len > 0) { key += retMode.token; str = str.substring(retMode.len); } ret.regularKey = keys[key]; } else if (str.startsWith('HP')) { addDirective("bagpipes"); ret.regularKey = keys.C; multilineVars.key = ret; return {foundKey: true}; } else if (str.startsWith('Hp')) { ret.extraAccidentals = [ {acc: 'natural', note: 'g'}, {acc: 'sharp', note: 'f'}, {acc: 'sharp', note: 'c'} ]; addDirective("bagpipes"); multilineVars.key = ret; return {foundKey: true}; } else { var retNone = tokenizer.isMatch(str, 'none'); if (retNone > 0) { // we got the none key - that's the same as C to us ret.regularKey = keys.C; str = str.substring(retNone); } } // now see if there are extra accidentals var done = false; while (!done) { var retExtra = tokenizer.getKeyAccidental(str); if (retExtra.len === 0) done = true; else { str = str.substring(retExtra.len); if (retExtra.warn) addWarning("error parsing extra accidentals:" + origStr); else { if (!ret.extraAccidentals) ret.extraAccidentals = []; ret.extraAccidentals.push(retExtra.token); } } } // now see if there is a clef retClef = tokenizer.getClef(str); if (retClef.len > 0) { if (retClef.warn) addWarning("error parsing clef:" + retClef.warn); else { //ret.clef = retClef.token; multilineVars.clef = retClef.token; } } if (ret.regularKey === undefined && ret.extraAccidentals === undefined && retClef.token === undefined) { addWarning("error parsing key: " + origStr); //ret.regularKey = keys.C; return {}; } var result = {}; if (retClef.token !== undefined) result.foundClef = true; if (ret.regularKey !== undefined || ret.extraAccidentals !== undefined) { multilineVars.key = ret; result.foundKey = true; } return result; };
tune.appendStartingElement('clef', -1, -1, {type: multilineVars.clef});
tune.appendStartingElement('clef', -1, -1, multilineVars.clef);
var parseLine = function(line) { if (line.startsWith('%%')) { var err = addDirective(line.substring(2)); if (err) warn(err, line, 2); return; } line = tokenizer.stripComment(line); if (line.length === 0) return; if (line.length >= 2) { if (line[1] === ':') { var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': // since the key is the last thing that can happen in the header, we can resolve the tempo now resolveTempo(); var result = parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, {type: multilineVars.clef}); if (result.foundKey) tune.appendStartingElement('key', -1, -1, multilineVars.key); } multilineVars.is_in_header = false; // The first key signifies the end of the header. break; case 'L': var len = line.substring(2).gsub(" ", ""); var len_arr = len.split('/'); if (len_arr.length === 2) { var n = parseInt(len_arr[0]); var d = parseInt(len_arr[1]); if (d > 0) { var q = n / d; multilineVars.default_length = q*8; // an eighth note is 1 multilineVars.havent_set_length = false; } } break; case 'M': setMeter(line.substring(2)); break; case 'P': // TODO-PER: There is more to do with parts, but the writer doesn't care. if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': setTempo(line, 2, line.length); break; case 'T': setTitle(line.substring(2)); break; case 'U': addUserDefinition(line, 2, line.length); break; case 'V': parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) startNewLine(); break; case 'w': addWords(tune.getCurrentVoice(), line.substring(2)); break; case 'X': case 'E': break; default: // It wasn't a recognized header value, so parse it as music. parseRegularMusicLine(line); } } return; } } // If we got this far, we have a regular line of mulsic parseRegularMusicLine(line); };
var len = line.substring(2).gsub(" ", ""); var len_arr = len.split('/'); if (len_arr.length === 2) { var n = parseInt(len_arr[0]); var d = parseInt(len_arr[1]); if (d > 0) { var q = n / d; multilineVars.default_length = q*8; multilineVars.havent_set_length = false; } }
setDefaultLength(line, 2, line.length);
var parseLine = function(line) { if (line.startsWith('%%')) { var err = addDirective(line.substring(2)); if (err) warn(err, line, 2); return; } line = tokenizer.stripComment(line); if (line.length === 0) return; if (line.length >= 2) { if (line[1] === ':') { var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': // since the key is the last thing that can happen in the header, we can resolve the tempo now resolveTempo(); var result = parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, {type: multilineVars.clef}); if (result.foundKey) tune.appendStartingElement('key', -1, -1, multilineVars.key); } multilineVars.is_in_header = false; // The first key signifies the end of the header. break; case 'L': var len = line.substring(2).gsub(" ", ""); var len_arr = len.split('/'); if (len_arr.length === 2) { var n = parseInt(len_arr[0]); var d = parseInt(len_arr[1]); if (d > 0) { var q = n / d; multilineVars.default_length = q*8; // an eighth note is 1 multilineVars.havent_set_length = false; } } break; case 'M': setMeter(line.substring(2)); break; case 'P': // TODO-PER: There is more to do with parts, but the writer doesn't care. if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': setTempo(line, 2, line.length); break; case 'T': setTitle(line.substring(2)); break; case 'U': addUserDefinition(line, 2, line.length); break; case 'V': parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) startNewLine(); break; case 'w': addWords(tune.getCurrentVoice(), line.substring(2)); break; case 'X': case 'E': break; default: // It wasn't a recognized header value, so parse it as music. parseRegularMusicLine(line); } } return; } } // If we got this far, we have a regular line of mulsic parseRegularMusicLine(line); };
parseRegularMusicLine(line);
if (nextLine.length) nextLine = "\x12" + nextLine; parseRegularMusicLine(line+nextLine); nextLine = "";
var parseLine = function(line) { if (line.startsWith('%%')) { var err = addDirective(line.substring(2)); if (err) warn(err, line, 2); return; } line = tokenizer.stripComment(line); if (line.length === 0) return; if (line.length >= 2) { if (line[1] === ':') { var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': // since the key is the last thing that can happen in the header, we can resolve the tempo now resolveTempo(); var result = parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, {type: multilineVars.clef}); if (result.foundKey) tune.appendStartingElement('key', -1, -1, multilineVars.key); } multilineVars.is_in_header = false; // The first key signifies the end of the header. break; case 'L': var len = line.substring(2).gsub(" ", ""); var len_arr = len.split('/'); if (len_arr.length === 2) { var n = parseInt(len_arr[0]); var d = parseInt(len_arr[1]); if (d > 0) { var q = n / d; multilineVars.default_length = q*8; // an eighth note is 1 multilineVars.havent_set_length = false; } } break; case 'M': setMeter(line.substring(2)); break; case 'P': // TODO-PER: There is more to do with parts, but the writer doesn't care. if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': setTempo(line, 2, line.length); break; case 'T': setTitle(line.substring(2)); break; case 'U': addUserDefinition(line, 2, line.length); break; case 'V': parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) startNewLine(); break; case 'w': addWords(tune.getCurrentVoice(), line.substring(2)); break; case 'X': case 'E': break; default: // It wasn't a recognized header value, so parse it as music. parseRegularMusicLine(line); } } return; } } // If we got this far, we have a regular line of mulsic parseRegularMusicLine(line); };
if (nextLine.length > 0) parseLine(nextLine);
var parseLine = function(line) { if (line.startsWith('%%')) { var err = addDirective(line.substring(2)); if (err) warn(err, line, 2); return; } line = tokenizer.stripComment(line); if (line.length === 0) return; if (line.length >= 2) { if (line[1] === ':') { var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': // since the key is the last thing that can happen in the header, we can resolve the tempo now resolveTempo(); var result = parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, {type: multilineVars.clef}); if (result.foundKey) tune.appendStartingElement('key', -1, -1, multilineVars.key); } multilineVars.is_in_header = false; // The first key signifies the end of the header. break; case 'L': var len = line.substring(2).gsub(" ", ""); var len_arr = len.split('/'); if (len_arr.length === 2) { var n = parseInt(len_arr[0]); var d = parseInt(len_arr[1]); if (d > 0) { var q = n / d; multilineVars.default_length = q*8; // an eighth note is 1 multilineVars.havent_set_length = false; } } break; case 'M': setMeter(line.substring(2)); break; case 'P': // TODO-PER: There is more to do with parts, but the writer doesn't care. if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': setTempo(line, 2, line.length); break; case 'T': setTitle(line.substring(2)); break; case 'U': addUserDefinition(line, 2, line.length); break; case 'V': parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) startNewLine(); break; case 'w': addWords(tune.getCurrentVoice(), line.substring(2)); break; case 'X': case 'E': break; default: // It wasn't a recognized header value, so parse it as music. parseRegularMusicLine(line); } } return; } } // If we got this far, we have a regular line of mulsic parseRegularMusicLine(line); };
setTempo(line, 2, line.length);
var tempo = setTempo(line, 2, line.length); if (tempo.type === 'delaySet') multilineVars.tempo = tempo.tempo; else if (tempo.type === 'immediate') tune.metaText.tempo = tempo.tempo;
var parseLine = function(line) { if (line.startsWith('%%')) { var err = addDirective(line.substring(2)); if (err) warn(err, line, 2); return; } line = tokenizer.stripComment(line); if (line.length === 0) return; if (line.length >= 2) { if (line[1] === ':') { var nextLine = ""; if (line.indexOf('\x12') >= 0) { nextLine = line.substring(line.indexOf('\x12')+1); line = line.substring(0, line.indexOf('\x12')); //This handles a continuation mark on a header field } var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': // since the key is the last thing that can happen in the header, we can resolve the tempo now resolveTempo(); var result = parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, multilineVars.clef); if (result.foundKey) tune.appendStartingElement('key', -1, -1, multilineVars.key); } multilineVars.is_in_header = false; // The first key signifies the end of the header. break; case 'L': setDefaultLength(line, 2, line.length); break; case 'M': setMeter(line.substring(2)); break; case 'P': // TODO-PER: There is more to do with parts, but the writer doesn't care. if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': setTempo(line, 2, line.length); break; case 'T': setTitle(line.substring(2)); break; case 'U': addUserDefinition(line, 2, line.length); break; case 'V': parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) startNewLine(); break; case 'w': addWords(tune.getCurrentVoice(), line.substring(2)); break; case 'X': case 'E': break; default: // It wasn't a recognized header value, so parse it as music. if (nextLine.length) nextLine = "\x12" + nextLine; parseRegularMusicLine(line+nextLine); nextLine = ""; } } if (nextLine.length > 0) parseLine(nextLine); return; } } // If we got this far, we have a regular line of mulsic parseRegularMusicLine(line); };
case 'm': warn("Unknown header", line, 0);
var parseLine = function(line) { if (line.startsWith('%%')) { var err = addDirective(line.substring(2)); if (err) warn(err, line, 2); return; } line = tokenizer.stripComment(line); if (line.length === 0) return; if (line.length >= 2) { if (line[1] === ':') { var nextLine = ""; if (line.indexOf('\x12') >= 0) { nextLine = line.substring(line.indexOf('\x12')+1); line = line.substring(0, line.indexOf('\x12')); //This handles a continuation mark on a header field } var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': // since the key is the last thing that can happen in the header, we can resolve the tempo now resolveTempo(); var result = parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, multilineVars.clef); if (result.foundKey) tune.appendStartingElement('key', -1, -1, multilineVars.key); } multilineVars.is_in_header = false; // The first key signifies the end of the header. break; case 'L': setDefaultLength(line, 2, line.length); break; case 'M': setMeter(line.substring(2)); break; case 'P': // TODO-PER: There is more to do with parts, but the writer doesn't care. if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': setTempo(line, 2, line.length); break; case 'T': setTitle(line.substring(2)); break; case 'U': addUserDefinition(line, 2, line.length); break; case 'V': parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) startNewLine(); break; case 'w': addWords(tune.getCurrentVoice(), line.substring(2)); break; case 'X': case 'E': break; default: // It wasn't a recognized header value, so parse it as music. if (nextLine.length) nextLine = "\x12" + nextLine; parseRegularMusicLine(line+nextLine); nextLine = ""; } } if (nextLine.length > 0) parseLine(nextLine); return; } } // If we got this far, we have a regular line of mulsic parseRegularMusicLine(line); };
case 'U': addUserDefinition(line, 2, line.length); break;
var parseLine = function(line) { if (line.startsWith('%%')) { var err = addDirective(line.substring(2)); if (err) warn(err, line, 2); return; } line = tokenizer.stripComment(line); if (line.length === 0) return; if (line.length >= 2) { if (line[1] === ':') { var field = metaTextHeaders[line[0]]; if (field !== undefined) { tune.addMetaText(field, tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); return; } else { switch(line[0]) { case 'H': tune.addMetaText("history", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); multilineVars.is_in_history = true; break; case 'K': // since the key is the last thing that can happen in the header, we can resolve the tempo now resolveTempo(); var result = parseKey(line.substring(2)); if (!multilineVars.is_in_header && tune.hasBeginMusic()) { if (result.foundClef) tune.appendStartingElement('clef', -1, -1, {type: multilineVars.clef}); if (result.foundKey) tune.appendStartingElement('key', -1, -1, multilineVars.key); } multilineVars.is_in_header = false; // The first key signifies the end of the header. break; case 'L': var len = line.substring(2).gsub(" ", ""); var len_arr = len.split('/'); if (len_arr.length === 2) { var n = parseInt(len_arr[0]); var d = parseInt(len_arr[1]); if (d > 0) { var q = n / d; multilineVars.default_length = q*8; // an eighth note is 1 multilineVars.havent_set_length = false; } } break; case 'M': setMeter(line.substring(2)); break; case 'P': // TODO-PER: There is more to do with parts, but the writer doesn't care. if (multilineVars.is_in_header) tune.addMetaText("partOrder", tokenizer.translateString(tokenizer.stripComment(line.substring(2)))); else multilineVars.partForNextLine = tokenizer.translateString(tokenizer.stripComment(line.substring(2))); break; case 'Q': setTempo(line, 2, line.length); break; case 'T': setTitle(line.substring(2)); break; case 'V': parseVoice(line, 2, line.length); if (!multilineVars.is_in_header) startNewLine(); break; case 'w': addWords(tune.getCurrentVoice(), line.substring(2)); break; case 'X': case 'E': break; default: // It wasn't a recognized header value, so parse it as music. parseRegularMusicLine(line); } } return; } } // If we got this far, we have a regular line of mulsic parseRegularMusicLine(line); };
var mid = pitches[str[0]]; for (i = 1; i < str.length; i++) { if (str[i] === ',') mid -= 7; else if (str[i] === ',') mid += 7; } return mid; };
var mid = pitches[str[0]]; for (var i = 1; i < str.length; i++) { if (str[i] === ',') mid -= 7; else if (str[i] === ',') mid += 7; } return mid; };
var parseMiddle = function(str) { var mid = pitches[str[0]]; for (i = 1; i < str.length; i++) { if (str[i] === ',') mid -= 7; else if (str[i] === ',') mid += 7; } return mid; };
var tok = tokens.shift(); if (tok.token === '(') tok = tokens.shift(); while (1) { if (tok.type !== 'number') throw "Expected top number of meter"; ret.value += parseInt(tok.token); ret.num += tok.token;
var tok = tokens.shift(); if (tok.token === '(') tok = tokens.shift(); while (1) { if (tok.type !== 'number') throw "Expected top number of meter"; ret.value += parseInt(tok.token); ret.num += tok.token; if (tokens.length === 0 || tokens[0].token === '/') return ret; tok = tokens.shift(); if (tok.token === ')') {
var parseNum = function() { // handles this much: [open_paren] decimal [ plus|dot decimal ]... [close_paren] var ret = { value: 0, num: "" }; var tok = tokens.shift(); if (tok.token === '(') tok = tokens.shift(); while (1) { if (tok.type !== 'number') throw "Expected top number of meter"; ret.value += parseInt(tok.token); ret.num += tok.token; if (tokens.length === 0 || tokens[0].token === '/') return ret; tok = tokens.shift(); if (tok.token === ')') { if (tokens.length === 0 || tokens[0].token === '/') return ret; throw "Unexpected paren in meter"; } if (tok.token !== '.' && tok.token !== '+') throw "Expected top number of meter"; ret.num += tok.token; if (tokens.length === 0) throw "Expected top number of meter"; tok = tokens.shift(); } return ret; // just to suppress warning };
tok = tokens.shift(); if (tok.token === ')') { if (tokens.length === 0 || tokens[0].token === '/') return ret; throw "Unexpected paren in meter"; } if (tok.token !== '.' && tok.token !== '+') throw "Expected top number of meter"; ret.num += tok.token; if (tokens.length === 0) throw "Expected top number of meter"; tok = tokens.shift();
throw "Unexpected paren in meter";
var parseNum = function() { // handles this much: [open_paren] decimal [ plus|dot decimal ]... [close_paren] var ret = { value: 0, num: "" }; var tok = tokens.shift(); if (tok.token === '(') tok = tokens.shift(); while (1) { if (tok.type !== 'number') throw "Expected top number of meter"; ret.value += parseInt(tok.token); ret.num += tok.token; if (tokens.length === 0 || tokens[0].token === '/') return ret; tok = tokens.shift(); if (tok.token === ')') { if (tokens.length === 0 || tokens[0].token === '/') return ret; throw "Unexpected paren in meter"; } if (tok.token !== '.' && tok.token !== '+') throw "Expected top number of meter"; ret.num += tok.token; if (tokens.length === 0) throw "Expected top number of meter"; tok = tokens.shift(); } return ret; // just to suppress warning };
return ret; };
if (tok.token !== '.' && tok.token !== '+') throw "Expected top number of meter"; ret.num += tok.token; if (tokens.length === 0) throw "Expected top number of meter"; tok = tokens.shift(); } return ret; };
var parseNum = function() { // handles this much: [open_paren] decimal [ plus|dot decimal ]... [close_paren] var ret = { value: 0, num: "" }; var tok = tokens.shift(); if (tok.token === '(') tok = tokens.shift(); while (1) { if (tok.type !== 'number') throw "Expected top number of meter"; ret.value += parseInt(tok.token); ret.num += tok.token; if (tokens.length === 0 || tokens[0].token === '/') return ret; tok = tokens.shift(); if (tok.token === ')') { if (tokens.length === 0 || tokens[0].token === '/') return ret; throw "Unexpected paren in meter"; } if (tok.token !== '.' && tok.token !== '+') throw "Expected top number of meter"; ret.num += tok.token; if (tokens.length === 0) throw "Expected top number of meter"; tok = tokens.shift(); } return ret; // just to suppress warning };
multilineVars.havent_set_length = false;
var parseRegularMusicLine = function(line) { resolveTempo(); multilineVars.havent_set_length = false; // To late to set this now. multilineVars.is_in_header = false; // We should have gotten a key header by now, but just in case, this is definitely out of the header. var i = 0; var startOfLine = multilineVars.iChar; // see if there is nothing but a comment on this line. If so, just ignore it. A full line comment is optional white space followed by % while (tokenizer.isWhiteSpace(line[i]) && i < line.length) i++; if (i === line.length || line[i] === '%') return; // Start with the standard staff, clef and key symbols on each line if (multilineVars.start_new_line) { startNewLine(); } multilineVars.start_new_line = true; var tripletNotesLeft = 0; //var tripletMultiplier = 0; var inTie = false; var inTieChord = {}; // See if the line starts with a header field var retHeader = letter_to_body_header(line, i); if (retHeader[0] > 0) { i += retHeader[0]; // TODO-PER: Handle inline headers } var el = { }; while (i < line.length) { var startI = i; if (line[i] === '%') break; var retInlineHeader = letter_to_inline_header(line, i); if (retInlineHeader[0] > 0) { i += retInlineHeader[0]; // TODO-PER: Handle inline headers //multilineVars.start_new_line = false; } else {// var el = { }; // We need to decide if the following characters are a bar-marking or a note-group. // Unfortunately, that is ambiguous. Both can contain chord symbols and decorations. // If there is a grace note either before or after the chord symbols and decorations, then it is definitely a note-group. // If there is a bar marker, it is definitely a bar-marking. // If there is either a core-note or chord, it is definitely a note-group. // So, loop while we find grace-notes, chords-symbols, or decorations. [It is an error to have more than one grace-note group in a row; the others can be multiple] // Then, if there is a grace-note, we know where to go. // Else see if we have a chord, core-note, slur, triplet, or bar. while (1) { var ret = tokenizer.eatWhiteSpace(line, i); if (ret > 0) { i += ret; } if (i > 0 && line[i-1] === '\x12') { // there is one case where a line continuation isn't the same as being on the same line, and that is if the next character after it is a header. ret = letter_to_body_header(line, i); if (ret[0] > 0) { // TODO: insert header here i += ret[0]; multilineVars.start_new_line = false; } } // gather all the grace notes, chord symbols and decorations ret = letter_to_spacer(line, i); if (ret[0] > 0) { i += ret[0]; } ret = letter_to_chord(line, i); if (ret[0] > 0) { // TODO-PER: There could be more than one chord here if they have different positions. el.chord = {name: tokenizer.translateString(ret[1]), position: ret[2]}; i += ret[0]; i += tokenizer.skipWhiteSpace(line.substring(i)); } else { ret = letter_to_accent(line, i); if (ret[0] > 0) { if (ret[1] === null) { if (i+1 < line.length) startNewLine(); // There was a ! in the middle of the line. Start a new line if there is anything after it. } else if (ret[1].length > 0) { if (el.decoration === undefined) el.decoration = []; el.decoration.push(ret[1]); } i += ret[0]; } else { ret = letter_to_grace(line, i); // TODO-PER: Be sure there aren't already grace notes defined. That is an error. if (ret[0] > 0) { el.gracenotes = ret[1]; i += ret[0]; } else break; } } } ret = letter_to_bar(line, i); if (ret[0] > 0) { // This is definitely a bar if (el.gracenote !== undefined) warn("Can't have a grace note before a barline", line, i); var bar = {type: ret[1]}; if (bar.type.length === 0) warn("Unknown bar type", line, i); else { if (ret[2]) bar.number = ret[2]; if (el.decoration !== undefined) bar.decoration = el.decoration; if (el.chord !== undefined) bar.chord = el.chord; tune.appendElement('bar', startOfLine+i, startOfLine+i+ret[0], bar); el = {}; } i += ret[0]; } else { // This is definitely a note group // // Look for as many open slurs and triplets as there are. (Note: only the first triplet is valid.) ret = letter_to_open_slurs_and_triplets(line, i); if (ret.consumed > 0) { if (ret.startSlur !== undefined) el.startSlur = ret.startSlur; if (ret.triplet !== undefined) { if (tripletNotesLeft > 0) warn("Can't nest triplets", line, i); else { el.startTriplet = ret.triplet; tripletNotesLeft = ret.num_notes === undefined ? ret.triplet : ret.num_notes; } } i += ret.consumed; } // handle chords. if (line[i] === '[') { i++; var chordDuration = null; var done = false; while (!done) { var chordNote = getCoreNote(line, i, {}, false); if (chordNote !== null) { if (el.pitches === undefined) el.pitches = [ chordNote ]; else el.pitches.push(chordNote); if (inTieChord[el.pitches.length]) { chordNote.endTie = true; inTieChord[el.pitches.length] = undefined; } if (chordNote.startTie) inTieChord[el.pitches.length] = true; i = chordNote.endChar; } else if (line[i] === ' ') { // Spaces are not allowed in chords, but we can recover from it by ignoring it. warn("Spaces are not allowed in chords", line, i); i++; } else { if (i < line.length && line[i] === ']') { // consume the close bracket i++; if (multilineVars.next_note_duration !== 0) { el.pitches.each(function(p) { p.duration = p.duration * multilineVars.next_note_duration; }); multilineVars.next_note_duration = 0; } if (inTie) { el.endTie = true; inTie = false; } if (tripletNotesLeft > 0) { tripletNotesLeft--; if (tripletNotesLeft === 0) { el.endTriplet = true; } } var postChordDone = false; while (i < line.length && !postChordDone) { switch (line[i]) { case ' ': case '\t': addEndBeam(el); break; case ')': if (el.endSlur === undefined) el.endSlur = 1; else el.endSlur++; break; case '-': if (el.startTie === true) // can only have one of these postChordDone = true; else { el.startTie = true; inTie = true; } break; case '>': case '<': var br2 = getBrokenRhythm(line, i); i += br2[0] - 1; // index gets incremented below, so we'll let that happen multilineVars.next_note_duration = br2[2]; chordDuration = br2[1]; break; default: postChordDone = true; break; } if (!postChordDone) { i++; } } } else warn("Expected ']' to end the chords", line, i); if (el.pitches !== undefined) { if (chordDuration !== null) { el.pitches.each(function(p) { p.duration = p.duration * chordDuration; }); } tune.appendElement('note', startOfLine+i, startOfLine+i, el); el = {}; } done = true; } } } else { // Single pitch var core = getCoreNote(line, i, el, true); if (core !== null) { el = core; if (inTie) { el.endTie = true; inTie = false; } if (el.startTie) inTie = true; i = el.endChar; if (tripletNotesLeft > 0) { tripletNotesLeft--; if (tripletNotesLeft === 0) { el.endTriplet = true; } } if (ret.end_beam) addEndBeam(el); tune.appendElement('note', startOfLine+i, startOfLine+1, el); el = {}; } } if (i === startI) { // don't know what this is, so ignore it. if (line[i] !== ' ' && line[i] !== '`') warn("Unknown character ignored", line, i); i++; } } } } };
bar.number = ret[2];
bar.ending = ret[2];
var parseRegularMusicLine = function(line) { resolveTempo(); multilineVars.havent_set_length = false; // To late to set this now. multilineVars.is_in_header = false; // We should have gotten a key header by now, but just in case, this is definitely out of the header. var i = 0; var startOfLine = multilineVars.iChar; // see if there is nothing but a comment on this line. If so, just ignore it. A full line comment is optional white space followed by % while (tokenizer.isWhiteSpace(line[i]) && i < line.length) i++; if (i === line.length || line[i] === '%') return; // Start with the standard staff, clef and key symbols on each line if (multilineVars.start_new_line) { startNewLine(); } multilineVars.start_new_line = true; var tripletNotesLeft = 0; //var tripletMultiplier = 0; var inTie = false; var inTieChord = {}; // See if the line starts with a header field var retHeader = letter_to_body_header(line, i); if (retHeader[0] > 0) { i += retHeader[0]; // TODO-PER: Handle inline headers } var el = { }; while (i < line.length) { var startI = i; if (line[i] === '%') break; var retInlineHeader = letter_to_inline_header(line, i); if (retInlineHeader[0] > 0) { i += retInlineHeader[0]; // TODO-PER: Handle inline headers //multilineVars.start_new_line = false; } else {// var el = { }; // We need to decide if the following characters are a bar-marking or a note-group. // Unfortunately, that is ambiguous. Both can contain chord symbols and decorations. // If there is a grace note either before or after the chord symbols and decorations, then it is definitely a note-group. // If there is a bar marker, it is definitely a bar-marking. // If there is either a core-note or chord, it is definitely a note-group. // So, loop while we find grace-notes, chords-symbols, or decorations. [It is an error to have more than one grace-note group in a row; the others can be multiple] // Then, if there is a grace-note, we know where to go. // Else see if we have a chord, core-note, slur, triplet, or bar. while (1) { var ret = tokenizer.eatWhiteSpace(line, i); if (ret > 0) { i += ret; } if (i > 0 && line[i-1] === '\x12') { // there is one case where a line continuation isn't the same as being on the same line, and that is if the next character after it is a header. ret = letter_to_body_header(line, i); if (ret[0] > 0) { // TODO: insert header here i += ret[0]; multilineVars.start_new_line = false; } } // gather all the grace notes, chord symbols and decorations ret = letter_to_spacer(line, i); if (ret[0] > 0) { i += ret[0]; } ret = letter_to_chord(line, i); if (ret[0] > 0) { // TODO-PER: There could be more than one chord here if they have different positions. el.chord = {name: tokenizer.translateString(ret[1]), position: ret[2]}; i += ret[0]; i += tokenizer.skipWhiteSpace(line.substring(i)); } else { ret = letter_to_accent(line, i); if (ret[0] > 0) { if (ret[1] === null) { if (i+1 < line.length) startNewLine(); // There was a ! in the middle of the line. Start a new line if there is anything after it. } else if (ret[1].length > 0) { if (el.decoration === undefined) el.decoration = []; el.decoration.push(ret[1]); } i += ret[0]; } else { ret = letter_to_grace(line, i); // TODO-PER: Be sure there aren't already grace notes defined. That is an error. if (ret[0] > 0) { el.gracenotes = ret[1]; i += ret[0]; } else break; } } } ret = letter_to_bar(line, i); if (ret[0] > 0) { // This is definitely a bar if (el.gracenote !== undefined) warn("Can't have a grace note before a barline", line, i); var bar = {type: ret[1]}; if (bar.type.length === 0) warn("Unknown bar type", line, i); else { if (ret[2]) bar.number = ret[2]; if (el.decoration !== undefined) bar.decoration = el.decoration; if (el.chord !== undefined) bar.chord = el.chord; tune.appendElement('bar', startOfLine+i, startOfLine+i+ret[0], bar); el = {}; } i += ret[0]; } else { // This is definitely a note group // // Look for as many open slurs and triplets as there are. (Note: only the first triplet is valid.) ret = letter_to_open_slurs_and_triplets(line, i); if (ret.consumed > 0) { if (ret.startSlur !== undefined) el.startSlur = ret.startSlur; if (ret.triplet !== undefined) { if (tripletNotesLeft > 0) warn("Can't nest triplets", line, i); else { el.startTriplet = ret.triplet; tripletNotesLeft = ret.num_notes === undefined ? ret.triplet : ret.num_notes; } } i += ret.consumed; } // handle chords. if (line[i] === '[') { i++; var chordDuration = null; var done = false; while (!done) { var chordNote = getCoreNote(line, i, {}, false); if (chordNote !== null) { if (el.pitches === undefined) el.pitches = [ chordNote ]; else el.pitches.push(chordNote); if (inTieChord[el.pitches.length]) { chordNote.endTie = true; inTieChord[el.pitches.length] = undefined; } if (chordNote.startTie) inTieChord[el.pitches.length] = true; i = chordNote.endChar; } else if (line[i] === ' ') { // Spaces are not allowed in chords, but we can recover from it by ignoring it. warn("Spaces are not allowed in chords", line, i); i++; } else { if (i < line.length && line[i] === ']') { // consume the close bracket i++; if (multilineVars.next_note_duration !== 0) { el.pitches.each(function(p) { p.duration = p.duration * multilineVars.next_note_duration; }); multilineVars.next_note_duration = 0; } if (inTie) { el.endTie = true; inTie = false; } if (tripletNotesLeft > 0) { tripletNotesLeft--; if (tripletNotesLeft === 0) { el.endTriplet = true; } } var postChordDone = false; while (i < line.length && !postChordDone) { switch (line[i]) { case ' ': case '\t': addEndBeam(el); break; case ')': if (el.endSlur === undefined) el.endSlur = 1; else el.endSlur++; break; case '-': if (el.startTie === true) // can only have one of these postChordDone = true; else { el.startTie = true; inTie = true; } break; case '>': case '<': var br2 = getBrokenRhythm(line, i); i += br2[0] - 1; // index gets incremented below, so we'll let that happen multilineVars.next_note_duration = br2[2]; chordDuration = br2[1]; break; default: postChordDone = true; break; } if (!postChordDone) { i++; } } } else warn("Expected ']' to end the chords", line, i); if (el.pitches !== undefined) { if (chordDuration !== null) { el.pitches.each(function(p) { p.duration = p.duration * chordDuration; }); } tune.appendElement('note', startOfLine+i, startOfLine+i, el); el = {}; } done = true; } } } else { // Single pitch var core = getCoreNote(line, i, el, true); if (core !== null) { el = core; if (inTie) { el.endTie = true; inTie = false; } if (el.startTie) inTie = true; i = el.endChar; if (tripletNotesLeft > 0) { tripletNotesLeft--; if (tripletNotesLeft === 0) { el.endTriplet = true; } } if (ret.end_beam) addEndBeam(el); tune.appendElement('note', startOfLine+i, startOfLine+1, el); el = {}; } } if (i === startI) { // don't know what this is, so ignore it. if (line[i] !== ' ' && line[i] !== '`') warn("Unknown character ignored", line, i); i++; } } } } };
if (multilineVars.barNumOnNextNote) { el.barNumber = multilineVars.barNumOnNextNote; multilineVars.barNumOnNextNote = null; }
var parseRegularMusicLine = function(line) { resolveTempo(); multilineVars.havent_set_length = false; // To late to set this now. multilineVars.is_in_header = false; // We should have gotten a key header by now, but just in case, this is definitely out of the header. var i = 0; var startOfLine = multilineVars.iChar; // see if there is nothing but a comment on this line. If so, just ignore it. A full line comment is optional white space followed by % while (tokenizer.isWhiteSpace(line[i]) && i < line.length) i++; if (i === line.length || line[i] === '%') return; // Start with the standard staff, clef and key symbols on each line if (multilineVars.start_new_line) { startNewLine(); } multilineVars.start_new_line = true; var tripletNotesLeft = 0; //var tripletMultiplier = 0; var inTie = false; var inTieChord = {}; // See if the line starts with a header field var retHeader = letter_to_body_header(line, i); if (retHeader[0] > 0) { i += retHeader[0]; // TODO-PER: Handle inline headers } var el = { }; while (i < line.length) { var startI = i; if (line[i] === '%') break; var retInlineHeader = letter_to_inline_header(line, i); if (retInlineHeader[0] > 0) { i += retInlineHeader[0]; // TODO-PER: Handle inline headers //multilineVars.start_new_line = false; } else {// var el = { }; // We need to decide if the following characters are a bar-marking or a note-group. // Unfortunately, that is ambiguous. Both can contain chord symbols and decorations. // If there is a grace note either before or after the chord symbols and decorations, then it is definitely a note-group. // If there is a bar marker, it is definitely a bar-marking. // If there is either a core-note or chord, it is definitely a note-group. // So, loop while we find grace-notes, chords-symbols, or decorations. [It is an error to have more than one grace-note group in a row; the others can be multiple] // Then, if there is a grace-note, we know where to go. // Else see if we have a chord, core-note, slur, triplet, or bar. while (1) { var ret = tokenizer.eatWhiteSpace(line, i); if (ret > 0) { i += ret; } if (i > 0 && line[i-1] === '\x12') { // there is one case where a line continuation isn't the same as being on the same line, and that is if the next character after it is a header. ret = letter_to_body_header(line, i); if (ret[0] > 0) { // TODO: insert header here i += ret[0]; multilineVars.start_new_line = false; } } // gather all the grace notes, chord symbols and decorations ret = letter_to_spacer(line, i); if (ret[0] > 0) { i += ret[0]; } ret = letter_to_chord(line, i); if (ret[0] > 0) { // TODO-PER: There could be more than one chord here if they have different positions. el.chord = {name: tokenizer.translateString(ret[1]), position: ret[2]}; i += ret[0]; i += tokenizer.skipWhiteSpace(line.substring(i)); } else { ret = letter_to_accent(line, i); if (ret[0] > 0) { if (ret[1] === null) { if (i+1 < line.length) startNewLine(); // There was a ! in the middle of the line. Start a new line if there is anything after it. } else if (ret[1].length > 0) { if (el.decoration === undefined) el.decoration = []; el.decoration.push(ret[1]); } i += ret[0]; } else { ret = letter_to_grace(line, i); // TODO-PER: Be sure there aren't already grace notes defined. That is an error. if (ret[0] > 0) { el.gracenotes = ret[1]; i += ret[0]; } else break; } } } ret = letter_to_bar(line, i); if (ret[0] > 0) { // This is definitely a bar if (el.gracenote !== undefined) warn("Can't have a grace note before a barline", line, i); var bar = {type: ret[1]}; if (bar.type.length === 0) warn("Unknown bar type", line, i); else { if (ret[2]) bar.number = ret[2]; if (el.decoration !== undefined) bar.decoration = el.decoration; if (el.chord !== undefined) bar.chord = el.chord; tune.appendElement('bar', startOfLine+i, startOfLine+i+ret[0], bar); el = {}; } i += ret[0]; } else { // This is definitely a note group // // Look for as many open slurs and triplets as there are. (Note: only the first triplet is valid.) ret = letter_to_open_slurs_and_triplets(line, i); if (ret.consumed > 0) { if (ret.startSlur !== undefined) el.startSlur = ret.startSlur; if (ret.triplet !== undefined) { if (tripletNotesLeft > 0) warn("Can't nest triplets", line, i); else { el.startTriplet = ret.triplet; tripletNotesLeft = ret.num_notes === undefined ? ret.triplet : ret.num_notes; } } i += ret.consumed; } // handle chords. if (line[i] === '[') { i++; var chordDuration = null; var done = false; while (!done) { var chordNote = getCoreNote(line, i, {}, false); if (chordNote !== null) { if (el.pitches === undefined) el.pitches = [ chordNote ]; else el.pitches.push(chordNote); if (inTieChord[el.pitches.length]) { chordNote.endTie = true; inTieChord[el.pitches.length] = undefined; } if (chordNote.startTie) inTieChord[el.pitches.length] = true; i = chordNote.endChar; } else if (line[i] === ' ') { // Spaces are not allowed in chords, but we can recover from it by ignoring it. warn("Spaces are not allowed in chords", line, i); i++; } else { if (i < line.length && line[i] === ']') { // consume the close bracket i++; if (multilineVars.next_note_duration !== 0) { el.pitches.each(function(p) { p.duration = p.duration * multilineVars.next_note_duration; }); multilineVars.next_note_duration = 0; } if (inTie) { el.endTie = true; inTie = false; } if (tripletNotesLeft > 0) { tripletNotesLeft--; if (tripletNotesLeft === 0) { el.endTriplet = true; } } var postChordDone = false; while (i < line.length && !postChordDone) { switch (line[i]) { case ' ': case '\t': addEndBeam(el); break; case ')': if (el.endSlur === undefined) el.endSlur = 1; else el.endSlur++; break; case '-': if (el.startTie === true) // can only have one of these postChordDone = true; else { el.startTie = true; inTie = true; } break; case '>': case '<': var br2 = getBrokenRhythm(line, i); i += br2[0] - 1; // index gets incremented below, so we'll let that happen multilineVars.next_note_duration = br2[2]; chordDuration = br2[1]; break; default: postChordDone = true; break; } if (!postChordDone) { i++; } } } else warn("Expected ']' to end the chords", line, i); if (el.pitches !== undefined) { if (chordDuration !== null) { el.pitches.each(function(p) { p.duration = p.duration * chordDuration; }); } tune.appendElement('note', startOfLine+i, startOfLine+i, el); el = {}; } done = true; } } } else { // Single pitch var core = getCoreNote(line, i, el, true); if (core !== null) { el = core; if (inTie) { el.endTie = true; inTie = false; } if (el.startTie) inTie = true; i = el.endChar; if (tripletNotesLeft > 0) { tripletNotesLeft--; if (tripletNotesLeft === 0) { el.endTriplet = true; } } if (ret.end_beam) addEndBeam(el); tune.appendElement('note', startOfLine+i, startOfLine+1, el); el = {}; } } if (i === startI) { // don't know what this is, so ignore it. if (line[i] !== ' ' && line[i] !== '`') warn("Unknown character ignored", line, i); i++; } } } } };
i += ret[0];
i = ret[0];
var parseRegularMusicLine = function(line) { resolveTempo(); //multilineVars.havent_set_length = false; // To late to set this now. multilineVars.is_in_header = false; // We should have gotten a key header by now, but just in case, this is definitely out of the header. var i = 0; var startOfLine = multilineVars.iChar; // see if there is nothing but a comment on this line. If so, just ignore it. A full line comment is optional white space followed by % while (tokenizer.isWhiteSpace(line[i]) && i < line.length) i++; if (i === line.length || line[i] === '%') return; // Start with the standard staff, clef and key symbols on each line if (multilineVars.start_new_line) { startNewLine(); } multilineVars.start_new_line = true; var tripletNotesLeft = 0; //var tripletMultiplier = 0; var inTie = false; var inTieChord = {}; // See if the line starts with a header field var retHeader = letter_to_body_header(line, i); if (retHeader[0] > 0) { i += retHeader[0]; // TODO-PER: Handle inline headers } var el = { }; while (i < line.length) { var startI = i; if (line[i] === '%') break; var retInlineHeader = letter_to_inline_header(line, i); if (retInlineHeader[0] > 0) { i += retInlineHeader[0]; // TODO-PER: Handle inline headers //multilineVars.start_new_line = false; } else {// var el = { }; // We need to decide if the following characters are a bar-marking or a note-group. // Unfortunately, that is ambiguous. Both can contain chord symbols and decorations. // If there is a grace note either before or after the chord symbols and decorations, then it is definitely a note-group. // If there is a bar marker, it is definitely a bar-marking. // If there is either a core-note or chord, it is definitely a note-group. // So, loop while we find grace-notes, chords-symbols, or decorations. [It is an error to have more than one grace-note group in a row; the others can be multiple] // Then, if there is a grace-note, we know where to go. // Else see if we have a chord, core-note, slur, triplet, or bar. while (1) { var ret = tokenizer.eatWhiteSpace(line, i); if (ret > 0) { i += ret; } if (i > 0 && line[i-1] === '\x12') { // there is one case where a line continuation isn't the same as being on the same line, and that is if the next character after it is a header. ret = letter_to_body_header(line, i); if (ret[0] > 0) { // TODO: insert header here i += ret[0]; multilineVars.start_new_line = false; } } // gather all the grace notes, chord symbols and decorations ret = letter_to_spacer(line, i); if (ret[0] > 0) { i += ret[0]; } ret = letter_to_chord(line, i); if (ret[0] > 0) { // TODO-PER: There could be more than one chord here if they have different positions. el.chord = {name: tokenizer.translateString(ret[1]), position: ret[2]}; i += ret[0]; i += tokenizer.skipWhiteSpace(line.substring(i)); } else { ret = letter_to_accent(line, i); if (ret[0] > 0) { if (ret[1] === null) { if (i+1 < line.length) startNewLine(); // There was a ! in the middle of the line. Start a new line if there is anything after it. } else if (ret[1].length > 0) { if (el.decoration === undefined) el.decoration = []; el.decoration.push(ret[1]); } i += ret[0]; } else { ret = letter_to_grace(line, i); // TODO-PER: Be sure there aren't already grace notes defined. That is an error. if (ret[0] > 0) { el.gracenotes = ret[1]; i += ret[0]; } else break; } } } ret = letter_to_bar(line, i); if (ret[0] > 0) { // This is definitely a bar if (el.gracenote !== undefined) warn("Can't have a grace note before a barline", line, i); var bar = {type: ret[1]}; if (bar.type.length === 0) warn("Unknown bar type", line, i); else { if (ret[2]) bar.ending = ret[2]; if (el.decoration !== undefined) bar.decoration = el.decoration; if (el.chord !== undefined) bar.chord = el.chord; if (bar.type !== 'bar_invisible') { multilineVars.currBarNumber++; if (multilineVars.barNumbers && multilineVars.currBarNumber % multilineVars.barNumbers === 0) multilineVars.barNumOnNextNote = multilineVars.currBarNumber; } tune.appendElement('bar', startOfLine+i, startOfLine+i+ret[0], bar); el = {}; } i += ret[0]; } else { // This is definitely a note group // // Look for as many open slurs and triplets as there are. (Note: only the first triplet is valid.) ret = letter_to_open_slurs_and_triplets(line, i); if (ret.consumed > 0) { if (ret.startSlur !== undefined) el.startSlur = ret.startSlur; if (ret.triplet !== undefined) { if (tripletNotesLeft > 0) warn("Can't nest triplets", line, i); else { el.startTriplet = ret.triplet; tripletNotesLeft = ret.num_notes === undefined ? ret.triplet : ret.num_notes; } } i += ret.consumed; } // handle chords. if (line[i] === '[') { i++; var chordDuration = null; var done = false; while (!done) { var chordNote = getCoreNote(line, i, {}, false); if (chordNote !== null) { if (el.pitches === undefined) el.pitches = [ chordNote ]; else el.pitches.push(chordNote); if (inTieChord[el.pitches.length]) { chordNote.endTie = true; inTieChord[el.pitches.length] = undefined; } if (chordNote.startTie) inTieChord[el.pitches.length] = true; i = chordNote.endChar; } else if (line[i] === ' ') { // Spaces are not allowed in chords, but we can recover from it by ignoring it. warn("Spaces are not allowed in chords", line, i); i++; } else { if (i < line.length && line[i] === ']') { // consume the close bracket i++; if (multilineVars.next_note_duration !== 0) { el.pitches.each(function(p) { p.duration = p.duration * multilineVars.next_note_duration; }); multilineVars.next_note_duration = 0; } if (inTie) { el.endTie = true; inTie = false; } if (tripletNotesLeft > 0) { tripletNotesLeft--; if (tripletNotesLeft === 0) { el.endTriplet = true; } } var postChordDone = false; while (i < line.length && !postChordDone) { switch (line[i]) { case ' ': case '\t': addEndBeam(el); break; case ')': if (el.endSlur === undefined) el.endSlur = 1; else el.endSlur++; break; case '-': if (el.startTie === true) // can only have one of these postChordDone = true; else { el.startTie = true; inTie = true; } break; case '>': case '<': var br2 = getBrokenRhythm(line, i); i += br2[0] - 1; // index gets incremented below, so we'll let that happen multilineVars.next_note_duration = br2[2]; chordDuration = br2[1]; break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '/': var fraction = tokenizer.getFraction(line, i); chordDuration = fraction.value; i = fraction.index; default: postChordDone = true; break; } if (!postChordDone) { i++; } } } else warn("Expected ']' to end the chords", line, i); if (el.pitches !== undefined) { if (chordDuration !== null) { el.pitches.each(function(p) { p.duration = p.duration * chordDuration; }); } if (multilineVars.barNumOnNextNote) { el.barNumber = multilineVars.barNumOnNextNote; multilineVars.barNumOnNextNote = null; } tune.appendElement('note', startOfLine+i, startOfLine+i, el); el = {}; } done = true; } } } else { // Single pitch var core = getCoreNote(line, i, el, true); if (core !== null) { el = core; if (inTie) { el.endTie = true; inTie = false; } if (el.startTie) inTie = true; i = el.endChar; if (tripletNotesLeft > 0) { tripletNotesLeft--; if (tripletNotesLeft === 0) { el.endTriplet = true; } } if (ret.end_beam) addEndBeam(el); if (multilineVars.barNumOnNextNote) { el.barNumber = multilineVars.barNumOnNextNote; multilineVars.barNumOnNextNote = null; } tune.appendElement('note', startOfLine+i, startOfLine+1, el); el = {}; } } if (i === startI) { // don't know what this is, so ignore it. if (line[i] !== ' ' && line[i] !== '`') warn("Unknown character ignored", line, i); i++; } } } } };
if (el.gracenote !== undefined) warn("Can't have a grace note before a barline", line, i);
if (el.gracenotes !== undefined) { el.pitch = null; el.rest_type = 'spacer'; tune.appendElement('note', -1, -1, el); el = {}; }
var parseRegularMusicLine = function(line) { resolveTempo(); //multilineVars.havent_set_length = false; // To late to set this now. multilineVars.is_in_header = false; // We should have gotten a key header by now, but just in case, this is definitely out of the header. var i = 0; var startOfLine = multilineVars.iChar; // see if there is nothing but a comment on this line. If so, just ignore it. A full line comment is optional white space followed by % while (tokenizer.isWhiteSpace(line[i]) && i < line.length) i++; if (i === line.length || line[i] === '%') return; // Start with the standard staff, clef and key symbols on each line if (multilineVars.start_new_line) { startNewLine(); } multilineVars.start_new_line = true; var tripletNotesLeft = 0; //var tripletMultiplier = 0; var inTie = false; var inTieChord = {}; // See if the line starts with a header field var retHeader = letter_to_body_header(line, i); if (retHeader[0] > 0) { i += retHeader[0]; // TODO-PER: Handle inline headers } var el = { }; while (i < line.length) { var startI = i; if (line[i] === '%') break; var retInlineHeader = letter_to_inline_header(line, i); if (retInlineHeader[0] > 0) { i += retInlineHeader[0]; // TODO-PER: Handle inline headers //multilineVars.start_new_line = false; } else {// var el = { }; // We need to decide if the following characters are a bar-marking or a note-group. // Unfortunately, that is ambiguous. Both can contain chord symbols and decorations. // If there is a grace note either before or after the chord symbols and decorations, then it is definitely a note-group. // If there is a bar marker, it is definitely a bar-marking. // If there is either a core-note or chord, it is definitely a note-group. // So, loop while we find grace-notes, chords-symbols, or decorations. [It is an error to have more than one grace-note group in a row; the others can be multiple] // Then, if there is a grace-note, we know where to go. // Else see if we have a chord, core-note, slur, triplet, or bar. while (1) { var ret = tokenizer.eatWhiteSpace(line, i); if (ret > 0) { i += ret; } if (i > 0 && line[i-1] === '\x12') { // there is one case where a line continuation isn't the same as being on the same line, and that is if the next character after it is a header. ret = letter_to_body_header(line, i); if (ret[0] > 0) { // TODO: insert header here i += ret[0]; multilineVars.start_new_line = false; } } // gather all the grace notes, chord symbols and decorations ret = letter_to_spacer(line, i); if (ret[0] > 0) { i += ret[0]; } ret = letter_to_chord(line, i); if (ret[0] > 0) { // TODO-PER: There could be more than one chord here if they have different positions. el.chord = {name: tokenizer.translateString(ret[1]), position: ret[2]}; i += ret[0]; i += tokenizer.skipWhiteSpace(line.substring(i)); } else { ret = letter_to_accent(line, i); if (ret[0] > 0) { if (ret[1] === null) { if (i+1 < line.length) startNewLine(); // There was a ! in the middle of the line. Start a new line if there is anything after it. } else if (ret[1].length > 0) { if (el.decoration === undefined) el.decoration = []; el.decoration.push(ret[1]); } i += ret[0]; } else { ret = letter_to_grace(line, i); // TODO-PER: Be sure there aren't already grace notes defined. That is an error. if (ret[0] > 0) { el.gracenotes = ret[1]; i += ret[0]; } else break; } } } ret = letter_to_bar(line, i); if (ret[0] > 0) { // This is definitely a bar if (el.gracenote !== undefined) warn("Can't have a grace note before a barline", line, i); var bar = {type: ret[1]}; if (bar.type.length === 0) warn("Unknown bar type", line, i); else { if (ret[2]) bar.ending = ret[2]; if (el.decoration !== undefined) bar.decoration = el.decoration; if (el.chord !== undefined) bar.chord = el.chord; if (bar.type !== 'bar_invisible') { multilineVars.currBarNumber++; if (multilineVars.barNumbers && multilineVars.currBarNumber % multilineVars.barNumbers === 0) multilineVars.barNumOnNextNote = multilineVars.currBarNumber; } tune.appendElement('bar', startOfLine+i, startOfLine+i+ret[0], bar); el = {}; } i += ret[0]; } else { // This is definitely a note group // // Look for as many open slurs and triplets as there are. (Note: only the first triplet is valid.) ret = letter_to_open_slurs_and_triplets(line, i); if (ret.consumed > 0) { if (ret.startSlur !== undefined) el.startSlur = ret.startSlur; if (ret.triplet !== undefined) { if (tripletNotesLeft > 0) warn("Can't nest triplets", line, i); else { el.startTriplet = ret.triplet; tripletNotesLeft = ret.num_notes === undefined ? ret.triplet : ret.num_notes; } } i += ret.consumed; } // handle chords. if (line[i] === '[') { i++; var chordDuration = null; var done = false; while (!done) { var chordNote = getCoreNote(line, i, {}, false); if (chordNote !== null) { if (el.pitches === undefined) el.pitches = [ chordNote ]; else el.pitches.push(chordNote); if (inTieChord[el.pitches.length]) { chordNote.endTie = true; inTieChord[el.pitches.length] = undefined; } if (chordNote.startTie) inTieChord[el.pitches.length] = true; i = chordNote.endChar; } else if (line[i] === ' ') { // Spaces are not allowed in chords, but we can recover from it by ignoring it. warn("Spaces are not allowed in chords", line, i); i++; } else { if (i < line.length && line[i] === ']') { // consume the close bracket i++; if (multilineVars.next_note_duration !== 0) { el.pitches.each(function(p) { p.duration = p.duration * multilineVars.next_note_duration; }); multilineVars.next_note_duration = 0; } if (inTie) { el.endTie = true; inTie = false; } if (tripletNotesLeft > 0) { tripletNotesLeft--; if (tripletNotesLeft === 0) { el.endTriplet = true; } } var postChordDone = false; while (i < line.length && !postChordDone) { switch (line[i]) { case ' ': case '\t': addEndBeam(el); break; case ')': if (el.endSlur === undefined) el.endSlur = 1; else el.endSlur++; break; case '-': if (el.startTie === true) // can only have one of these postChordDone = true; else { el.startTie = true; inTie = true; } break; case '>': case '<': var br2 = getBrokenRhythm(line, i); i += br2[0] - 1; // index gets incremented below, so we'll let that happen multilineVars.next_note_duration = br2[2]; chordDuration = br2[1]; break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '/': var fraction = tokenizer.getFraction(line, i); chordDuration = fraction.value; i = fraction.index; default: postChordDone = true; break; } if (!postChordDone) { i++; } } } else warn("Expected ']' to end the chords", line, i); if (el.pitches !== undefined) { if (chordDuration !== null) { el.pitches.each(function(p) { p.duration = p.duration * chordDuration; }); } if (multilineVars.barNumOnNextNote) { el.barNumber = multilineVars.barNumOnNextNote; multilineVars.barNumOnNextNote = null; } tune.appendElement('note', startOfLine+i, startOfLine+i, el); el = {}; } done = true; } } } else { // Single pitch var core = getCoreNote(line, i, el, true); if (core !== null) { el = core; if (inTie) { el.endTie = true; inTie = false; } if (el.startTie) inTie = true; i = el.endChar; if (tripletNotesLeft > 0) { tripletNotesLeft--; if (tripletNotesLeft === 0) { el.endTriplet = true; } } if (ret.end_beam) addEndBeam(el); if (multilineVars.barNumOnNextNote) { el.barNumber = multilineVars.barNumOnNextNote; multilineVars.barNumOnNextNote = null; } tune.appendElement('note', startOfLine+i, startOfLine+1, el); el = {}; } } if (i === startI) { // don't know what this is, so ignore it. if (line[i] !== ' ' && line[i] !== '`') warn("Unknown character ignored", line, i); i++; } } } } };
staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', '');
if (staffInfo.clef !== undefined) { staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', ''); } staffInfo.middle = calcMiddle(staffInfo.clef, oct);
this.parseVoice = function(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; if (multilineVars.score_is_present) warn("Can't have an unknown V: id when the %score directive is present", line, i); } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); // TODO-PER: check for a legal clef; do octavizing var oct = 0;// for (var ii = 0; ii < staffInfo.clef.length; ii++) {// if (staffInfo.clef[ii] === ',') oct -= 7;// else if (staffInfo.clef[ii] === "'") oct += 7;// } staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', ''); } staffInfo.middle = calcMiddle(staffInfo.clef, oct); break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': // TODO-PER: handle the octave indicators on the clef by changing the middle property var oct2 = 0;// for (var iii = 0; iii < token.token.length; iii++) {// if (token.token[iii] === ',') oct2 -= 7;// else if (token.token[iii] === "'") oct2 += 7;// } staffInfo.clef = token.token.replace(/[',]/g, ""); staffInfo.middle = calcMiddle(staffInfo.clef, oct2); break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); staffInfo.middle = parseMiddle(staffInfo.middle); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length, meter: multilineVars.origMeter }); if (!multilineVars.score_is_present) multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.voices[id].staffNum]; if (!multilineVars.score_is_present) s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.subname.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} this.setCurrentVoice(id); };
staffInfo.middle = calcMiddle(staffInfo.clef, oct);
this.parseVoice = function(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; if (multilineVars.score_is_present) warn("Can't have an unknown V: id when the %score directive is present", line, i); } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); // TODO-PER: check for a legal clef; do octavizing var oct = 0;// for (var ii = 0; ii < staffInfo.clef.length; ii++) {// if (staffInfo.clef[ii] === ',') oct -= 7;// else if (staffInfo.clef[ii] === "'") oct += 7;// } staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', ''); } staffInfo.middle = calcMiddle(staffInfo.clef, oct); break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': // TODO-PER: handle the octave indicators on the clef by changing the middle property var oct2 = 0;// for (var iii = 0; iii < token.token.length; iii++) {// if (token.token[iii] === ',') oct2 -= 7;// else if (token.token[iii] === "'") oct2 += 7;// } staffInfo.clef = token.token.replace(/[',]/g, ""); staffInfo.middle = calcMiddle(staffInfo.clef, oct2); break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); staffInfo.middle = parseMiddle(staffInfo.middle); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length, meter: multilineVars.origMeter }); if (!multilineVars.score_is_present) multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.voices[id].staffNum]; if (!multilineVars.score_is_present) s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.subname.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} this.setCurrentVoice(id); };
if (staffInfo.clef !== undefined) { staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', ''); } staffInfo.middle = calcMiddle(staffInfo.clef, oct);
if (staffInfo.clef !== undefined) { staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') !== -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', '');
this.parseVoice = function(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; if (multilineVars.score_is_present) warn("Can't have an unknown V: id when the %score directive is present", line, i); } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); // TODO-PER: check for a legal clef; do octavizing var oct = 0;// for (var ii = 0; ii < staffInfo.clef.length; ii++) {// if (staffInfo.clef[ii] === ',') oct -= 7;// else if (staffInfo.clef[ii] === "'") oct += 7;// } if (staffInfo.clef !== undefined) { staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', ''); } staffInfo.middle = calcMiddle(staffInfo.clef, oct); } break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': // TODO-PER: handle the octave indicators on the clef by changing the middle property var oct2 = 0;// for (var iii = 0; iii < token.token.length; iii++) {// if (token.token[iii] === ',') oct2 -= 7;// else if (token.token[iii] === "'") oct2 += 7;// } staffInfo.clef = token.token.replace(/[',]/g, ""); staffInfo.middle = calcMiddle(staffInfo.clef, oct2); break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); staffInfo.middle = parseMiddle(staffInfo.middle); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length, meter: multilineVars.origMeter }); if (!multilineVars.score_is_present) multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.voices[id].staffNum]; if (!multilineVars.score_is_present) s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.subname.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} this.setCurrentVoice(id); };
break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': var oct2 = 0;
staffInfo.middle = calcMiddle(staffInfo.clef, oct); } break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': var oct2 = 0;
this.parseVoice = function(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; if (multilineVars.score_is_present) warn("Can't have an unknown V: id when the %score directive is present", line, i); } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); // TODO-PER: check for a legal clef; do octavizing var oct = 0;// for (var ii = 0; ii < staffInfo.clef.length; ii++) {// if (staffInfo.clef[ii] === ',') oct -= 7;// else if (staffInfo.clef[ii] === "'") oct += 7;// } if (staffInfo.clef !== undefined) { staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', ''); } staffInfo.middle = calcMiddle(staffInfo.clef, oct); } break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': // TODO-PER: handle the octave indicators on the clef by changing the middle property var oct2 = 0;// for (var iii = 0; iii < token.token.length; iii++) {// if (token.token[iii] === ',') oct2 -= 7;// else if (token.token[iii] === "'") oct2 += 7;// } staffInfo.clef = token.token.replace(/[',]/g, ""); staffInfo.middle = calcMiddle(staffInfo.clef, oct2); break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); staffInfo.middle = parseMiddle(staffInfo.middle); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length, meter: multilineVars.origMeter }); if (!multilineVars.score_is_present) multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.voices[id].staffNum]; if (!multilineVars.score_is_present) s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.subname.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} this.setCurrentVoice(id); };
staffInfo.clef = token.token.replace(/[',]/g, ""); staffInfo.middle = calcMiddle(staffInfo.clef, oct2); break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); staffInfo.middle = parseMiddle(staffInfo.middle); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; }
staffInfo.clef = token.token.replace(/[',]/g, ""); staffInfo.middle = calcMiddle(staffInfo.clef, oct2); break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); staffInfo.middle = parseMiddle(staffInfo.middle); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break;
this.parseVoice = function(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; if (multilineVars.score_is_present) warn("Can't have an unknown V: id when the %score directive is present", line, i); } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); // TODO-PER: check for a legal clef; do octavizing var oct = 0;// for (var ii = 0; ii < staffInfo.clef.length; ii++) {// if (staffInfo.clef[ii] === ',') oct -= 7;// else if (staffInfo.clef[ii] === "'") oct += 7;// } if (staffInfo.clef !== undefined) { staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', ''); } staffInfo.middle = calcMiddle(staffInfo.clef, oct); } break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': // TODO-PER: handle the octave indicators on the clef by changing the middle property var oct2 = 0;// for (var iii = 0; iii < token.token.length; iii++) {// if (token.token[iii] === ',') oct2 -= 7;// else if (token.token[iii] === "'") oct2 += 7;// } staffInfo.clef = token.token.replace(/[',]/g, ""); staffInfo.middle = calcMiddle(staffInfo.clef, oct2); break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); staffInfo.middle = parseMiddle(staffInfo.middle); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length, meter: multilineVars.origMeter }); if (!multilineVars.score_is_present) multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.voices[id].staffNum]; if (!multilineVars.score_is_present) s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.subname.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} this.setCurrentVoice(id); };
start += tokenizer.eatWhiteSpace(line, start);
this.parseVoice = function(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; if (multilineVars.score_is_present) warn("Can't have an unknown V: id when the %score directive is present", line, i); } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); // TODO-PER: check for a legal clef; do octavizing var oct = 0;// for (var ii = 0; ii < staffInfo.clef.length; ii++) {// if (staffInfo.clef[ii] === ',') oct -= 7;// else if (staffInfo.clef[ii] === "'") oct += 7;// } if (staffInfo.clef !== undefined) { staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', ''); } staffInfo.middle = calcMiddle(staffInfo.clef, oct); } break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': // TODO-PER: handle the octave indicators on the clef by changing the middle property var oct2 = 0;// for (var iii = 0; iii < token.token.length; iii++) {// if (token.token[iii] === ',') oct2 -= 7;// else if (token.token[iii] === "'") oct2 += 7;// } staffInfo.clef = token.token.replace(/[',]/g, ""); staffInfo.middle = calcMiddle(staffInfo.clef, oct2); break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); staffInfo.middle = parseMiddle(staffInfo.middle); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length, meter: multilineVars.origMeter }); if (!multilineVars.score_is_present) multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.voices[id].staffNum]; if (!multilineVars.score_is_present) s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.subname.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} this.setCurrentVoice(id); };
if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length, meter: multilineVars.origMeter }); if (!multilineVars.score_is_present) multilineVars.staves[multilineVars.staves.length-1].numVoices = 0;
if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length, meter: multilineVars.origMeter }); if (!multilineVars.score_is_present) multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; }
this.parseVoice = function(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; if (multilineVars.score_is_present) warn("Can't have an unknown V: id when the %score directive is present", line, i); } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); // TODO-PER: check for a legal clef; do octavizing var oct = 0;// for (var ii = 0; ii < staffInfo.clef.length; ii++) {// if (staffInfo.clef[ii] === ',') oct -= 7;// else if (staffInfo.clef[ii] === "'") oct += 7;// } if (staffInfo.clef !== undefined) { staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', ''); } staffInfo.middle = calcMiddle(staffInfo.clef, oct); } break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': // TODO-PER: handle the octave indicators on the clef by changing the middle property var oct2 = 0;// for (var iii = 0; iii < token.token.length; iii++) {// if (token.token[iii] === ',') oct2 -= 7;// else if (token.token[iii] === "'") oct2 += 7;// } staffInfo.clef = token.token.replace(/[',]/g, ""); staffInfo.middle = calcMiddle(staffInfo.clef, oct2); break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); staffInfo.middle = parseMiddle(staffInfo.middle); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length, meter: multilineVars.origMeter }); if (!multilineVars.score_is_present) multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.voices[id].staffNum]; if (!multilineVars.score_is_present) s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.subname.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} this.setCurrentVoice(id); };
if (multilineVars.voices[id].staffNum === undefined) { multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.voices[id].staffNum]; if (!multilineVars.score_is_present) s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle;
multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.voices[id].staffNum]; if (!multilineVars.score_is_present) s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle;
this.parseVoice = function(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; if (multilineVars.score_is_present) warn("Can't have an unknown V: id when the %score directive is present", line, i); } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); // TODO-PER: check for a legal clef; do octavizing var oct = 0;// for (var ii = 0; ii < staffInfo.clef.length; ii++) {// if (staffInfo.clef[ii] === ',') oct -= 7;// else if (staffInfo.clef[ii] === "'") oct += 7;// } if (staffInfo.clef !== undefined) { staffInfo.clef = staffInfo.clef.replace(/[',]/g, ""); if (staffInfo.clef.indexOf('+16') != -1) { oct += 14; staffInfo.clef = staffInfo.clef.replace('+16', ''); } staffInfo.middle = calcMiddle(staffInfo.clef, oct); } break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': // TODO-PER: handle the octave indicators on the clef by changing the middle property var oct2 = 0;// for (var iii = 0; iii < token.token.length; iii++) {// if (token.token[iii] === ',') oct2 -= 7;// else if (token.token[iii] === "'") oct2 += 7;// } staffInfo.clef = token.token.replace(/[',]/g, ""); staffInfo.middle = calcMiddle(staffInfo.clef, oct2); break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); staffInfo.middle = parseMiddle(staffInfo.middle); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length, meter: multilineVars.origMeter }); if (!multilineVars.score_is_present) multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.voices[id].staffNum]; if (!multilineVars.score_is_present) s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.subname.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} this.setCurrentVoice(id); };
else if (attr.token.length === 0)
else if (attr.token.length === 0 && line[start] !== '"')
function parseVoice(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0) warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': staffInfo.clef = token.token; break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length }); // TODO-PER: For now, the entire collection is bracketted. Refine this later. if (multilineVars.staves.length > 1) { multilineVars.staves[0].bracket = 'start'; for (var b = 1; b < multilineVars.staves.length-1; b++) multilineVars.staves[b].bracket = "continue"; multilineVars.staves[multilineVars.staves.length-1].bracket = 'end'; } multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.staves.length-1]; s.numVoices++; if (staffInfo.clef) s.clef = staffInfo.clef; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.name.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} setCurrentVoice(id); }
if (staffInfo.clef) s.clef = staffInfo.clef;
if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle };
function parseVoice(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0) warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': staffInfo.clef = token.token; break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length }); // TODO-PER: For now, the entire collection is bracketted. Refine this later. if (multilineVars.staves.length > 1) { multilineVars.staves[0].bracket = 'start'; for (var b = 1; b < multilineVars.staves.length-1; b++) multilineVars.staves[b].bracket = "continue"; multilineVars.staves[multilineVars.staves.length-1].bracket = 'end'; } multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.staves.length-1]; s.numVoices++; if (staffInfo.clef) s.clef = staffInfo.clef; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.name.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} setCurrentVoice(id); }
if (multilineVars.staves.length > 1) { multilineVars.staves[0].bracket = 'start'; for (var b = 1; b < multilineVars.staves.length-1; b++) multilineVars.staves[b].bracket = "continue"; multilineVars.staves[multilineVars.staves.length-1].bracket = 'end'; }
function parseVoice(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': staffInfo.clef = token.token; break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length }); // TODO-PER: For now, the entire collection is bracketted. Refine this later. if (multilineVars.staves.length > 1) { multilineVars.staves[0].bracket = 'start'; for (var b = 1; b < multilineVars.staves.length-1; b++) multilineVars.staves[b].bracket = "continue"; multilineVars.staves[multilineVars.staves.length-1].bracket = 'end'; } multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.staves.length-1]; s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.name.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} setCurrentVoice(id); }
var s = multilineVars.staves[multilineVars.staves.length-1];
var s = multilineVars.staves[multilineVars.voices[id].staffNum];
function parseVoice(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': staffInfo.clef = token.token; break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length }); // TODO-PER: For now, the entire collection is bracketted. Refine this later. if (multilineVars.staves.length > 1) { multilineVars.staves[0].bracket = 'start'; for (var b = 1; b < multilineVars.staves.length-1; b++) multilineVars.staves[b].bracket = "continue"; multilineVars.staves[multilineVars.staves.length-1].bracket = 'end'; } multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.staves.length-1]; s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.name.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} setCurrentVoice(id); }
if (staffInfo.subname) {if (s.subname) s.name.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];}
if (staffInfo.subname) {if (s.subname) s.subname.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];}
function parseVoice(line, i, e) { //First truncate the string to the first non-space character after V: through either the //end of the line or a % character. Then remove trailing spaces, too. var ret = tokenizer.getMeat(line, i, e); var start = ret.start; var end = ret.end; //The first thing on the line is the ID. It can be any non-space string and terminates at the //first space. var id = tokenizer.getToken(line, start, end); if (id.length === 0) { warn("Expected a voice id", line, start); return; } var isNew = false; if (multilineVars.voices[id] === undefined) { multilineVars.voices[id] = {}; isNew = true; } start += id.length; start += tokenizer.eatWhiteSpace(line, start); var staffInfo = {startStaff: isNew}; var addNextTokenToStaffInfo = function(name) { var attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for " + name + " in voice: " + attr.warn, line, start); else if (attr.token.length === 0 && line[start] !== '"') warn("Expected value for " + name + " in voice", line, start); else staffInfo[name] = attr.token; start += attr.len; }; //Then the following items can occur in any order: while (start < end) { var token = tokenizer.getVoiceToken(line, start, end); start += token.len; if (token.warn) { warn("Error parsing voice: " + token.warn, line, start); } else { var attr = null; switch (token.token) { case 'clef': case 'cl': addNextTokenToStaffInfo('clef'); break; case 'treble': case 'bass': case 'tenor': case 'alto': case 'none': case 'treble\'': case 'bass\'': case 'tenor\'': case 'alto\'': case 'none\'': case 'treble\'\'': case 'bass\'\'': case 'tenor\'\'': case 'alto\'\'': case 'none\'\'': case 'treble,': case 'bass,': case 'tenor,': case 'alto,': case 'none,': case 'treble,,': case 'bass,,': case 'tenor,,': case 'alto,,': case 'none,,': staffInfo.clef = token.token; break; case 'staves': case 'stave': case 'stv': addNextTokenToStaffInfo('staves'); break; case 'brace': case 'brc': addNextTokenToStaffInfo('brace'); break; case 'bracket': case 'brk': addNextTokenToStaffInfo('bracket'); break; case 'name': case 'nm': addNextTokenToStaffInfo('name'); break; case 'subname': case 'sname': case 'snm': addNextTokenToStaffInfo('subname'); break; case 'merge': staffInfo.startStaff = false; break; case 'stems': attr = tokenizer.getVoiceToken(line, start, end); if (attr.warn !== undefined) warn("Expected value for stems in voice: " + attr.warn, line, start); else if (attr.token === 'up' || attr.token === 'down') multilineVars.voices[id].stem = attr.token; else warn("Expected up or down for voice stem", line, start); start += attr.len; break; case 'up': case 'down': multilineVars.voices[id].stem = token.token; break; case 'middle': case 'm': addNextTokenToStaffInfo('middle'); break; case 'gchords': case 'gch': multilineVars.voices[id].suppressChords = true; break; case 'space': case 'spc': addNextTokenToStaffInfo('spacing'); break; } } start += tokenizer.eatWhiteSpace(line, start); } // now we've filled up staffInfo, figure out what to do with this voice // TODO-PER: It is unclear from the standard and the examples what to do with brace, bracket, and staves, so they are ignored for now. if (staffInfo.startStaff || multilineVars.staves.length === 0) { multilineVars.staves.push({ index: multilineVars.staves.length }); // TODO-PER: For now, the entire collection is bracketted. Refine this later. if (multilineVars.staves.length > 1) { multilineVars.staves[0].bracket = 'start'; for (var b = 1; b < multilineVars.staves.length-1; b++) multilineVars.staves[b].bracket = "continue"; multilineVars.staves[multilineVars.staves.length-1].bracket = 'end'; } multilineVars.staves[multilineVars.staves.length-1].numVoices = 0; } if (multilineVars.voices[id].staffNum === undefined) { // store where to write this for quick access later. multilineVars.voices[id].staffNum = multilineVars.staves.length-1; var vi = 0; for(var v in multilineVars.voices) { if(multilineVars.voices.hasOwnProperty(v)) { if (multilineVars.voices[v].staffNum === multilineVars.voices[id].staffNum) vi++; } } multilineVars.voices[id].index = vi-1; } var s = multilineVars.staves[multilineVars.staves.length-1]; s.numVoices++; if (staffInfo.clef) s.clef = { type: staffInfo.clef, middle: staffInfo.middle }; if (staffInfo.spacing) s.spacing_below_offset = staffInfo.spacing; if (staffInfo.middle) s.middle = staffInfo.middle; if (staffInfo.name) {if (s.name) s.name.push(staffInfo.name); else s.name = [ staffInfo.name ];} if (staffInfo.subname) {if (s.subname) s.name.push(staffInfo.subname); else s.subname = [ staffInfo.subname ];} setCurrentVoice(id); }
if (isLeaf) htmlText += xmlDocNode.textContent; else
if (isLeaf) { var textContent = xmlDocNode.textContent ? xmlDocNode.textContent : xmlDocNode.text; htmlText += textContent; } else {
var parseXmlToHtml = function(xmlDocNode, indent) { var htmlText; var isLeaf = isLeafNode(xmlDocNode); // Create opening tag with attributes htmlText = indent + '<span class="tag">&lt;' + xmlDocNode.tagName; for ( var i = 0; i < xmlDocNode.attributes.length; i++) { htmlText += ' ' + xmlDocNode.attributes[i].nodeName + '=&quot;' + xmlDocNode.attributes[i].value + '&quot;'; } htmlText += '&gt;</span>'; if (isLeaf) htmlText += xmlDocNode.textContent; else htmlText += '<br/>'; // Write any children Ext.each(xmlDocNode.childNodes, function(docNodeChild) { if (docNodeChild.nodeType == XML_NODE_ELEMENT) { htmlText += parseXmlToHtml(docNodeChild, indent + ' '); } }, this); // Write closing tag htmlText += '<span class="tag">' + (isLeaf ? '' : indent) + '&lt;/' + xmlDocNode.tagName + '&gt;</span><br/>'; return htmlText; };
}
var parseXmlToHtml = function(xmlDocNode, indent) { var htmlText; var isLeaf = isLeafNode(xmlDocNode); // Create opening tag with attributes htmlText = indent + '<span class="tag">&lt;' + xmlDocNode.tagName; for ( var i = 0; i < xmlDocNode.attributes.length; i++) { htmlText += ' ' + xmlDocNode.attributes[i].nodeName + '=&quot;' + xmlDocNode.attributes[i].value + '&quot;'; } htmlText += '&gt;</span>'; if (isLeaf) htmlText += xmlDocNode.textContent; else htmlText += '<br/>'; // Write any children Ext.each(xmlDocNode.childNodes, function(docNodeChild) { if (docNodeChild.nodeType == XML_NODE_ELEMENT) { htmlText += parseXmlToHtml(docNodeChild, indent + ' '); } }, this); // Write closing tag htmlText += '<span class="tag">' + (isLeaf ? '' : indent) + '&lt;/' + xmlDocNode.tagName + '&gt;</span><br/>'; return htmlText; };
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);
if(!root) var a = this.moved(tree_component.cut_copy.copy_nodes,obj.children("a:eq(0)"),"inside", false, true); else var a = this.moved(tree_component.cut_copy.copy_nodes,this.container.children("ul:eq(0)"),"inside", false, true);
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; } },
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);
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", false, true);
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; } },
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);
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", false, true);
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; } },