1. Stephen McKamey
  2. duel

Commits

Stephen McKamey  committed 9ef313d

implementing Closure Compiler suggestions

  • Participants
  • Parent commits 00ca6f3
  • Branches default

Comments (0)

Files changed (7)

File duel-js/src/main/javascript/dom.js

View file
  • Ignore whitespace
 	 * @constant
 	 * @type {string}
 	 */
-	var TO_DOM = 'toDOM';
-
-	/**
-	 * @private
-	 * @constant
-	 * @type {string}
-	 */
-	var RELOAD = 'reload';
-
-	/**
-	 * @private
-	 * @constant
-	 * @type {string}
-	 */
 	var INIT = '$init';
 
 	/**
 				delete elem[key];
 			} catch (ex) {
 				// sometimes IE doesn't like deleting from DOM
-				elem[key] = undefined;
+				elem[key] = undef;
 			}
 
 			if (!isFunction(method)) {
 	 * 
 	 * @public
 	 * @this {Result}
-	 * @param {Node|string} elem An optional element or element ID to be replaced or merged
-	 * @param {boolean} merge Optionally merge result into elem
+	 * @param {Node|string=} elem An optional element or element ID to be replaced or merged
+	 * @param {boolean=} merge Optionally merge result into elem
 	 * @return {Node|null}
 	 */
-	Result.prototype[TO_DOM] = Result.prototype.toDOM = function(elem, merge) {
+	Result.prototype.toDOM = function(elem, merge) {
 		// resolve the element ID
 		if (getType(elem) === VAL) {
-			elem = document.getElementById(elem);
+			elem = document.getElementById(
+				// Closure Compiler type cast
+				/** @type{string} */(elem));
 		}
 
 		var view;
 				view = elem;
 				elem = null;
 			}
-			view = patchDOM(view || createElement(this.value[0]), this.value);
+			// Closure Compiler type cast
+			view = patchDOM(/** @type{Node} */(view) || createElement(this.value[0]), this.value);
 
 		} catch (ex) {
 			// handle error with context
 
 		if (elem && elem.parentNode) {
 			// replace existing element with result
-			elem.parentNode.replaceChild(view, elem);
+			// Closure Compiler type cast
+			elem.parentNode.replaceChild(view, /** @type{Node} */(elem));
 		}
 
 		return view;
 	 * @public
 	 * @this {Result}
 	 */
-	Result.prototype[RELOAD] = Result.prototype.reload = function() {
+	Result.prototype.reload = function() {
 		// http://stackoverflow.com/questions/4297877
 		var doc = document;
 		try {

File duel-js/src/main/javascript/factory.js

View file
  • Ignore whitespace
 	/* factory.js --------------------*/
 
 	/**
-	 * @private
-	 * @const
-	 * @type {string}
-	 */
-	var DUEL_EXTERN = 'duel';
-
-	/**
-	 * @private
-	 * @const
-	 * @type {string}
-	 */
-	var RAW_EXTERN = 'raw';
-
-	/**
 	 * Renders an error as text
 	 * 
 	 * @private
 	 * @param {Array|Object|string|number|function(*,number,number):Array|Object|string} view The view template
 	 * @return {Array|Object|string|number}
 	 */
-	var duel = window[DUEL_EXTERN] = function(view) {
+	var duel = function(view) {
 		return (isFunction(view) && isFunction(view.getView)) ? view : factory(view);
 	};
 
 	 * @param {string} value Markup text
 	 * @return {Markup}
 	 */
-	duel[RAW_EXTERN] = duel.raw = function(value) {
+	duel.raw = function(value) {
 		return new Markup(value);
 	};
 

File duel-js/src/main/javascript/intro.js

View file
  • Ignore whitespace
 	/**
 	 * @param {Window} window Window reference
 	 * @param {Document} document Document reference
+	 * @param {*=} undef undefined
 	 */
-	function(window, document) {
+	function(window, document, undef) {
 
 	'use strict';
 

File duel-js/src/main/javascript/render.js

View file
  • Ignore whitespace
 						buffer.append(' ', name);
 						var val = child[name];
 						if (getType(val) !== NUL) {
-							buffer.append('="', attrEncode(val), '"');
+							// Closure Compiler type cast
+							buffer.append('="', /** @type{string} */(attrEncode(val)), '"');
 						}
 					}
 				}
 				renderElem(buffer, child);
 			} else {
 				// encode string literals
-				buffer.append(htmlEncode(child));
+				// Closure Compiler type cast
+				buffer.append(/** @type{string} */(htmlEncode(child)));
 			}
 		}
 
 	 * Immediately writes the resulting value to the document
 	 * 
 	 * @public
-	 * @override
 	 * @this {Result}
 	 * @param {Document} doc optional Document reference
 	 */

File duel-js/src/main/javascript/types.js

View file
  • Ignore whitespace
 	var RAW = 5;
 
 	/**
-	 * @private
-	 * @constant
-	 * @type {string}
-	 */
-	var MSIE = 'ScriptEngineMajorVersion';
-
-	/**
 	 * Wraps a data value to maintain as raw markup in output
 	 * 
 	 * @private
 	}
 
 	/**
+	 * Only IE<9 benefits from Array.join()
+	 * 
 	 * @private
 	 * @constant
 	 * @type {boolean}
 	 */
-	Buffer.FAST = !window[MSIE];
+	Buffer.FAST = !(window.ScriptEngineMajorVersion && window.ScriptEngineMajorVersion() < 9);
 
 	/**
 	 * Appends to the internal value
 	 * 
 	 * @public
 	 * @this {Buffer}
-	 * @param {string} v1
-	 * @param {string} v2
-	 * @param {string} v3
+	 * @param {null|string} v1
+	 * @param {null|string=} v2
+	 * @param {null|string=} v3
 	 */
 	Buffer.prototype.append = function(v1, v2, v3) {
 		if (Buffer.FAST) {
-			this.value += v1;
+			if (v1 !== null) {
+				this.value += v1;
 
-			if (v2 !== null && v2 !== undefined) {
-				this.value += v2;
+				if (v2 !== null && v2 !== undef) {
+					this.value += v2;
 
-				if (v3 !== null && v3 !== undefined) {
-					this.value += v3;
+					if (v3 !== null && v3 !== undef) {
+						this.value += v3;
+					}
 				}
 			}
+
 		} else {
 			this.value.push.apply(
 				// Closure Compiler type cast

File duel-js/target/duel.js

View file
  • Ignore whitespace
 	/**
 	 * @param {Window} window Window reference
 	 * @param {Document} document Document reference
+	 * @param {*=} undef undefined
 	 */
-	function(window, document) {
+	function(window, document, undef) {
 
 	'use strict';
 
 	var RAW = 5;
 
 	/**
-	 * @private
-	 * @constant
-	 * @type {string}
-	 */
-	var MSIE = 'ScriptEngineMajorVersion';
-
-	/**
 	 * Wraps a data value to maintain as raw markup in output
 	 * 
 	 * @private
 	}
 
 	/**
+	 * Only IE<9 benefits from Array.join()
+	 * 
 	 * @private
 	 * @constant
 	 * @type {boolean}
 	 */
-	Buffer.FAST = !window[MSIE];
+	Buffer.FAST = !(window.ScriptEngineMajorVersion && window.ScriptEngineMajorVersion() < 9);
 
 	/**
 	 * Appends to the internal value
 	 * 
 	 * @public
 	 * @this {Buffer}
-	 * @param {string} v1
-	 * @param {string} v2
-	 * @param {string} v3
+	 * @param {null|string} v1
+	 * @param {null|string=} v2
+	 * @param {null|string=} v3
 	 */
 	Buffer.prototype.append = function(v1, v2, v3) {
 		if (Buffer.FAST) {
-			this.value += v1;
+			if (v1 !== null) {
+				this.value += v1;
 
-			if (v2 !== null && v2 !== undefined) {
-				this.value += v2;
+				if (v2 !== null && v2 !== undef) {
+					this.value += v2;
 
-				if (v3 !== null && v3 !== undefined) {
-					this.value += v3;
+					if (v3 !== null && v3 !== undef) {
+						this.value += v3;
+					}
 				}
 			}
+
 		} else {
 			this.value.push.apply(
 				// Closure Compiler type cast
 	/* factory.js --------------------*/
 
 	/**
-	 * @private
-	 * @const
-	 * @type {string}
-	 */
-	var DUEL_EXTERN = 'duel';
-
-	/**
-	 * @private
-	 * @const
-	 * @type {string}
-	 */
-	var RAW_EXTERN = 'raw';
-
-	/**
 	 * Renders an error as text
 	 * 
 	 * @private
 	 * @param {Array|Object|string|number|function(*,number,number):Array|Object|string} view The view template
 	 * @return {Array|Object|string|number}
 	 */
-	var duel = window[DUEL_EXTERN] = function(view) {
+	var duel = function(view) {
 		return (isFunction(view) && isFunction(view.getView)) ? view : factory(view);
 	};
 
 	 * @param {string} value Markup text
 	 * @return {Markup}
 	 */
-	duel[RAW_EXTERN] = duel.raw = function(value) {
+	duel.raw = function(value) {
 		return new Markup(value);
 	};
 
 						buffer.append(' ', name);
 						var val = child[name];
 						if (getType(val) !== NUL) {
-							buffer.append('="', attrEncode(val), '"');
+							// Closure Compiler type cast
+							buffer.append('="', /** @type{string} */(attrEncode(val)), '"');
 						}
 					}
 				}
 				renderElem(buffer, child);
 			} else {
 				// encode string literals
-				buffer.append(htmlEncode(child));
+				// Closure Compiler type cast
+				buffer.append(/** @type{string} */(htmlEncode(child)));
 			}
 		}
 
 	 * Immediately writes the resulting value to the document
 	 * 
 	 * @public
-	 * @override
 	 * @this {Result}
 	 * @param {Document} doc optional Document reference
 	 */
 	 * @constant
 	 * @type {string}
 	 */
-	var TO_DOM = 'toDOM';
-
-	/**
-	 * @private
-	 * @constant
-	 * @type {string}
-	 */
-	var RELOAD = 'reload';
-
-	/**
-	 * @private
-	 * @constant
-	 * @type {string}
-	 */
 	var INIT = '$init';
 
 	/**
 				delete elem[key];
 			} catch (ex) {
 				// sometimes IE doesn't like deleting from DOM
-				elem[key] = undefined;
+				elem[key] = undef;
 			}
 
 			if (!isFunction(method)) {
 	 * 
 	 * @public
 	 * @this {Result}
-	 * @param {Node|string} elem An optional element or element ID to be replaced or merged
-	 * @param {boolean} merge Optionally merge result into elem
+	 * @param {Node|string=} elem An optional element or element ID to be replaced or merged
+	 * @param {boolean=} merge Optionally merge result into elem
 	 * @return {Node|null}
 	 */
-	Result.prototype[TO_DOM] = Result.prototype.toDOM = function(elem, merge) {
+	Result.prototype.toDOM = function(elem, merge) {
 		// resolve the element ID
 		if (getType(elem) === VAL) {
-			elem = document.getElementById(elem);
+			elem = document.getElementById(
+				// Closure Compiler type cast
+				/** @type{string} */(elem));
 		}
 
 		var view;
 				view = elem;
 				elem = null;
 			}
-			view = patchDOM(view || createElement(this.value[0]), this.value);
+			// Closure Compiler type cast
+			view = patchDOM(/** @type{Node} */(view) || createElement(this.value[0]), this.value);
 
 		} catch (ex) {
 			// handle error with context
 
 		if (elem && elem.parentNode) {
 			// replace existing element with result
-			elem.parentNode.replaceChild(view, elem);
+			// Closure Compiler type cast
+			elem.parentNode.replaceChild(view, /** @type{Node} */(elem));
 		}
 
 		return view;
 	 * @public
 	 * @this {Result}
 	 */
-	Result.prototype[RELOAD] = Result.prototype.reload = function() {
+	Result.prototype.reload = function() {
 		// http://stackoverflow.com/questions/4297877
 		var doc = document;
 		try {

File duel-js/target/duel.min.js

View file
  • Ignore whitespace
-var duel=function(A,m){function w(a){this.value=a}function l(a){switch(typeof a){case "object":return!a?0:x(a)?2:a instanceof w?5:a instanceof Date?4:3;case "function":return 1;case "undefined":return 0;default:return 4}}function u(a){return"string"===typeof a}function n(a){return"function"===typeof a}function o(){this.value=o.FAST?"":[]}function p(a){x(a)||(a=["",a]);this.value=a}function q(a,b){switch(l(b)){case 2:if(""===b[0])for(var c=1,f=b.length;c<f;c++)q(a,b[c]);else a.push(b);break;case 3:if(1===
+var duel=function(u,m,x){function y(a){this.value=a}function l(a){switch(typeof a){case "object":return!a?0:z(a)?2:a instanceof y?5:a instanceof Date?4:3;case "function":return 1;case "undefined":return 0;default:return 4}}function v(a){return"string"===typeof a}function n(a){return"function"===typeof a}function o(){this.value=o.FAST?"":[]}function p(a){z(a)||(a=["",a]);this.value=a}function q(a,b){switch(l(b)){case 2:if(""===b[0])for(var c=1,f=b.length;c<f;c++)q(a,b[c]);else a.push(b);break;case 3:if(1===
 a.length)a.push(b);else if(c=a[1],3===l(c))for(f in b)b.hasOwnProperty(f)&&(c[f]=b[f]);else a.splice(1,0,b);break;case 4:""!==b&&(b=""+b,c=a.length-1,0<c&&4===l(a[c])?a[c]+=b:a.push(b));break;case 0:break;default:a.push(b)}}function r(a,b,c,f,d,e){var g=3===l(a[1]);if(a.length===(g?3:2))return k(a[a.length-1],b,c,f,d,e);for(var h=[""],g=g?2:1,j=a.length;g<j;g++)q(h,k(a[g],b,c,f,d,e));return h}function B(a,b,c,f,d,e){for(var g=1,h=a.length;g<h;g++){var j=a[g],i=j[1].test;if(3===l(j[1])&&i&&(n(i)&&
-(i=i(b,c,f,d)),!i))continue;return r(j,b,c,f,d,e)}return null}function J(a){2!==l(a)&&(a=["",a]);var b=function(b,f,d,e){try{var g=k(a,b,isFinite(f)?f:0,isFinite(d)?d:1,u(e)?e:null);return new p(g)}catch(h){return new p("["+h+"]")}};b.getView=function(){return a};return b}function K(a){return!u(a)?a:a.replace(/[&<>]/g,function(a){switch(a){case "&":return"&amp;";case "<":return"&lt;";case ">":return"&gt;";default:return a}})}function L(a){return!u(a)?a:a.replace(/[&<>"]/g,function(a){switch(a){case "&":return"&amp;";
-case "<":return"&lt;";case ">":return"&gt;";case '"':return"&quot;";default:return a}})}function C(a,b){var c=b[0]||"",f=b.length,d=1,e,g=M[c];if("!"===c.charAt(0))"!DOCTYPE"===b[0]?a.append("<!DOCTYPE ",b[1],">"):a.append("<\!--",b[1],"--\>");else{if(c){a.append("<",c);e=b[d];if(3===l(e)){for(var h in e)if(e.hasOwnProperty(h)){a.append(" ",h);var j=e[h];0!==l(j)&&a.append('="',L(j),'"')}d++}g&&a.append(" /");a.append(">")}for(;d<f;d++)e=b[d],x(e)?C(a,e):a.append(K(e));c&&!g&&a.append("</",c,">")}}
-function s(a){if(a){if("!"===a.charAt(0))return m.createComment("!"===a?"":a.substr(1)+" ")}else{if(m.createDocumentFragment)return m.createDocumentFragment();a=""}return"style"===a.toLowerCase()&&m.createStyleSheet?m.createStyleSheet():m.createElement(a)}function v(a,b){if(b){var c=(a.tagName||"").toLowerCase();if(8===a.nodeType)3===b.nodeType&&(a.nodeValue+=b.nodeValue);else if("table"===c&&a.tBodies)if(b.tagName)if((c=b.tagName.toLowerCase())&&"tbody"!==c&&"thead"!==c){var f=0<a.tBodies.length?
-a.tBodies[a.tBodies.length-1]:null;f||(f=s("th"===c?"thead":"tbody"),a.appendChild(f));f.appendChild(b)}else!1!==a.canHaveChildren&&a.appendChild(b);else{if(11===b.nodeType)for(;b.firstChild;)v(a,b.removeChild(b.firstChild))}else if("style"===c&&m.createStyleSheet)a.cssText=b;else if(!1!==a.canHaveChildren)a.appendChild(b);else if("object"===c&&b.tagName&&"param"===b.tagName.toLowerCase()){try{a.appendChild(b)}catch(d){}try{if(a.object)a.object[b.name]=b.value}catch(e){}}}}function D(a,b,c){n(c)?
-a.addEventListener?a.addEventListener("on"===b.substr(0,2)?b.substr(2):b,c,!1):a[b]=c:u(c)&&(a[b]=new Function("event",c))}function E(a){return!!a&&3===a.nodeType&&(!a.nodeValue||!/\S/.exec(a.nodeValue))}function F(a,b){if(a&&3===a.nodeType&&b.exec(a.nodeValue))a.nodeValue=a.nodeValue.replace(b,"")}function y(a){if(a){for(;E(a.firstChild);)a.removeChild(a.firstChild);for(F(a.firstChild,N);E(a.lastChild);)a.removeChild(a.lastChild);F(a.lastChild,O)}}function G(a,b){var c=a[b];if(c){try{delete a[b]}catch(f){a[b]=
-void 0}if(!n(c))try{c=new Function(""+c)}catch(d){c=null}}return c}function H(a){if(a){var b=G(a,"$init");b&&b.call(a);(b=G(a,"$load"))?setTimeout(function(){b.call(a);b=a=null},0):b=a=null}}function I(a,b){for(var c=1,f=b.length;c<f;c++){var d=b[c];switch(l(d)){case 2:var e=d[0],d=I(s(e),d);if("html"===e)return y(d),H(d),d;v(a,d);break;case 4:""!==d&&v(a,m.createTextNode(""+d));break;case 3:if(1===a.nodeType){var e=a,g=d;if(g.name&&m.attachEvent&&!e.parentNode)try{var h=s("<"+e.tagName+' name="'+
-g.name+'">');e.tagName===h.tagName&&(e=h)}catch(j){}d=void 0;for(d in g)if(g.hasOwnProperty(d)){var i=g[d],k=l(i);if(d)0===k&&(i="",k=4),d=P[d.toLowerCase()]||d,"style"===d?"undefined"!==typeof e.style.cssText?e.style.cssText=i:e.style=i:"class"===d?e.className=i:"on"===d.substr(0,2)?(D(e,d,i),t[d]&&D(e,t[d],i)):4===k&&"$"!==d.charAt(0)?(e.setAttribute(d,i),t[d]&&e.setAttribute(t[d],i)):(e[d]=i,t[d]&&(e[t[d]]=i))}a=e}break;case 5:e=v;g=a;i=d;d=s("div");d.innerHTML=""+i;y(d);if(1===d.childNodes.length)d=
-d.firstChild;else{for(i=s("");d.firstChild;)i.appendChild(d.firstChild);d=i}e(g,d)}}y(a);H(a);if(11===a.nodeType&&1===a.childNodes.length)a=a.firstChild;return a}w.prototype.toString=function(){return this.value};var x=Array.isArray||function(a){return a instanceof Array};o.FAST=!A.ScriptEngineMajorVersion;o.prototype.append=function(a,b,c){o.FAST?(this.value+=a,null!==b&&void 0!==b&&(this.value+=b,null!==c&&void 0!==c&&(this.value+=c))):this.value.push.apply(this.value,arguments)};o.prototype.clear=
-function(){this.value=o.FAST?"":[]};o.prototype.toString=function(){return o.FAST?this.value:this.value.join("")};var k;k=function(a,b,c,f,d,e){switch(l(a)){case 1:return a(b,c,f,d);case 2:var g=a[0]||"";switch(g){case "$for":a:{var h=a[1]||{},g=[""],j;if(h.hasOwnProperty("count")){j=h.count;n(j)&&(j=j(b,c,f,d));h.hasOwnProperty("data")?(h=h.data,n(h)&&(h=h(b,c,f,d))):h=b;for(b=0;b<j;b++)q(g,r(a,h,b,j,null,e))}else{if(h.hasOwnProperty("in")){var i=h["in"];n(i)&&(i=i(b,c,f,d));if(3===l(i)){h=[];for(j in i)i.hasOwnProperty(j)&&
-h.push(j);for(b=0,j=h.length;b<j;b++)q(g,r(a,i[h[b]],b,j,h[b],e));a=g;break a}h=i}else h=h.each,n(h)&&(h=h(b,c,f,d));b=l(h);if(2===b)for(b=0,j=h.length;b<j;b++)q(g,r(a,h[b],b,j,null,e));else 0!==b&&(g=r(a,h,0,1,null,e))}a=g}return a;case "$xor":return B(a,b,c,f,d,e);case "$if":return B(["$xor",a],b,c,f,d,e);case "$call":e=a[1]||{};if(e.view){g=k(e.view,b,c,f,d);h=e.hasOwnProperty("data")?k(e.data,b,c,f,d):b;j=e.hasOwnProperty("index")?k(e.index,b,c,f,d):c;i=e.hasOwnProperty("count")?k(e.count,b,c,
-f,d):f;b=e.hasOwnProperty("key")?k(e.key,b,c,f,d):d;c={};for(f=a.length-1;2<=f;f--)d=a[f],e=d[1]||{},e.hasOwnProperty("name")&&(c[e.name]=d);a=g&&n(g.getView)?k(g.getView(),h,j,i,b,c):null}else a=null;return a;case "$part":return g=(a[1]||{}).name||"",g=e&&e.hasOwnProperty(g)?e[g]:a,r(g,b,c,f,d)}g=[g];h=1;for(j=a.length;h<j;h++)q(g,k(a[h],b,c,f,d,e));return g;case 3:e={};for(g in a)a.hasOwnProperty(g)&&(e[g]=k(a[g],b,c,f,d));return e}return a};var z=A.duel=function(a){return n(a)&&n(a.getView)?a:
-J(a)};z.raw=z.raw=function(a){return new w(a)};var M={area:!0,base:!0,basefont:!0,br:!0,col:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,wbr:!0};p.prototype.toString=function(){var a;var b=this.value;try{var c=new o;C(c,b);a=c.toString()}catch(f){a="["+f+"]"}return a};p.prototype.write=function(a){(a||m).write(""+this)};var P={rowspan:"rowSpan",colspan:"colSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",tabindex:"tabIndex",accesskey:"accessKey",
-hidefocus:"hideFocus",usemap:"useMap",maxlength:"maxLength",readonly:"readOnly",contenteditable:"contentEditable"},t={enctype:"encoding",onscroll:"DOMMouseScroll"},N=/^[\r\n]+/,O=/[\r\n]+$/;p.prototype.toDOM=p.prototype.toDOM=function(a,b){4===l(a)&&(a=m.getElementById(a));var c;try{b&&(c=a,a=null),c=I(c||s(this.value[0]),this.value)}catch(f){c=m.createTextNode("["+f+"]")}a&&a.parentNode&&a.parentNode.replaceChild(c,a);return c};p.prototype.reload=p.prototype.reload=function(){var a=m;try{var b=this.toDOM();
-a.replaceChild(b,a.documentElement);if(a.createStyleSheet){for(var c=b.firstChild;c&&"HEAD"!==(c.tagName||"");)c=c.nextSibling;for(var f=c&&c.firstChild;f;){if("LINK"===(f.tagName||""))f.href=f.href;f=f.nextSibling}}}catch(d){a=a.open("text/html"),a.write(this.toString()),a.close()}};return z}(window,document);
+(i=i(b,c,f,d)),!i))continue;return r(j,b,c,f,d,e)}return null}function J(a){2!==l(a)&&(a=["",a]);var b=function(b,f,d,e){try{var g=k(a,b,isFinite(f)?f:0,isFinite(d)?d:1,v(e)?e:null);return new p(g)}catch(h){return new p("["+h+"]")}};b.getView=function(){return a};return b}function K(a){return!v(a)?a:a.replace(/[&<>]/g,function(a){switch(a){case "&":return"&amp;";case "<":return"&lt;";case ">":return"&gt;";default:return a}})}function L(a){return!v(a)?a:a.replace(/[&<>"]/g,function(a){switch(a){case "&":return"&amp;";
+case "<":return"&lt;";case ">":return"&gt;";case '"':return"&quot;";default:return a}})}function C(a,b){var c=b[0]||"",f=b.length,d=1,e,g=M[c];if("!"===c.charAt(0))"!DOCTYPE"===b[0]?a.append("<!DOCTYPE ",b[1],">"):a.append("<\!--",b[1],"--\>");else{if(c){a.append("<",c);e=b[d];if(3===l(e)){for(var h in e)if(e.hasOwnProperty(h)){a.append(" ",h);var j=e[h];0!==l(j)&&a.append('="',L(j),'"')}d++}g&&a.append(" /");a.append(">")}for(;d<f;d++)e=b[d],z(e)?C(a,e):a.append(K(e));c&&!g&&a.append("</",c,">")}}
+function s(a){if(a){if("!"===a.charAt(0))return m.createComment("!"===a?"":a.substr(1)+" ")}else{if(m.createDocumentFragment)return m.createDocumentFragment();a=""}return"style"===a.toLowerCase()&&m.createStyleSheet?m.createStyleSheet():m.createElement(a)}function w(a,b){if(b){var c=(a.tagName||"").toLowerCase();if(8===a.nodeType)3===b.nodeType&&(a.nodeValue+=b.nodeValue);else if("table"===c&&a.tBodies)if(b.tagName)if((c=b.tagName.toLowerCase())&&"tbody"!==c&&"thead"!==c){var f=0<a.tBodies.length?
+a.tBodies[a.tBodies.length-1]:null;f||(f=s("th"===c?"thead":"tbody"),a.appendChild(f));f.appendChild(b)}else!1!==a.canHaveChildren&&a.appendChild(b);else{if(11===b.nodeType)for(;b.firstChild;)w(a,b.removeChild(b.firstChild))}else if("style"===c&&m.createStyleSheet)a.cssText=b;else if(!1!==a.canHaveChildren)a.appendChild(b);else if("object"===c&&b.tagName&&"param"===b.tagName.toLowerCase()){try{a.appendChild(b)}catch(d){}try{if(a.object)a.object[b.name]=b.value}catch(e){}}}}function D(a,b,c){n(c)?
+a.addEventListener?a.addEventListener("on"===b.substr(0,2)?b.substr(2):b,c,!1):a[b]=c:v(c)&&(a[b]=new Function("event",c))}function E(a){return!!a&&3===a.nodeType&&(!a.nodeValue||!/\S/.exec(a.nodeValue))}function F(a,b){if(a&&3===a.nodeType&&b.exec(a.nodeValue))a.nodeValue=a.nodeValue.replace(b,"")}function A(a){if(a){for(;E(a.firstChild);)a.removeChild(a.firstChild);for(F(a.firstChild,N);E(a.lastChild);)a.removeChild(a.lastChild);F(a.lastChild,O)}}function G(a,b){var c=a[b];if(c){try{delete a[b]}catch(f){a[b]=
+x}if(!n(c))try{c=new Function(""+c)}catch(d){c=null}}return c}function H(a){if(a){var b=G(a,"$init");b&&b.call(a);(b=G(a,"$load"))?setTimeout(function(){b.call(a);b=a=null},0):b=a=null}}function I(a,b){for(var c=1,f=b.length;c<f;c++){var d=b[c];switch(l(d)){case 2:var e=d[0],d=I(s(e),d);if("html"===e)return A(d),H(d),d;w(a,d);break;case 4:""!==d&&w(a,m.createTextNode(""+d));break;case 3:if(1===a.nodeType){var e=a,g=d;if(g.name&&m.attachEvent&&!e.parentNode)try{var h=s("<"+e.tagName+' name="'+g.name+
+'">');e.tagName===h.tagName&&(e=h)}catch(j){}d=void 0;for(d in g)if(g.hasOwnProperty(d)){var i=g[d],k=l(i);if(d)0===k&&(i="",k=4),d=P[d.toLowerCase()]||d,"style"===d?"undefined"!==typeof e.style.cssText?e.style.cssText=i:e.style=i:"class"===d?e.className=i:"on"===d.substr(0,2)?(D(e,d,i),t[d]&&D(e,t[d],i)):4===k&&"$"!==d.charAt(0)?(e.setAttribute(d,i),t[d]&&e.setAttribute(t[d],i)):(e[d]=i,t[d]&&(e[t[d]]=i))}a=e}break;case 5:e=w;g=a;i=d;d=s("div");d.innerHTML=""+i;A(d);if(1===d.childNodes.length)d=
+d.firstChild;else{for(i=s("");d.firstChild;)i.appendChild(d.firstChild);d=i}e(g,d)}}A(a);H(a);if(11===a.nodeType&&1===a.childNodes.length)a=a.firstChild;return a}y.prototype.toString=function(){return this.value};var z=Array.isArray||function(a){return a instanceof Array};o.FAST=!(u.ScriptEngineMajorVersion&&9>u.ScriptEngineMajorVersion());o.prototype.append=function(a,b,c){o.FAST?null!==a&&(this.value+=a,null!==b&&b!==x&&(this.value+=b,null!==c&&c!==x&&(this.value+=c))):this.value.push.apply(this.value,
+arguments)};o.prototype.clear=function(){this.value=o.FAST?"":[]};o.prototype.toString=function(){return o.FAST?this.value:this.value.join("")};var k;k=function(a,b,c,f,d,e){switch(l(a)){case 1:return a(b,c,f,d);case 2:var g=a[0]||"";switch(g){case "$for":a:{var h=a[1]||{},g=[""],j;if(h.hasOwnProperty("count")){j=h.count;n(j)&&(j=j(b,c,f,d));h.hasOwnProperty("data")?(h=h.data,n(h)&&(h=h(b,c,f,d))):h=b;for(b=0;b<j;b++)q(g,r(a,h,b,j,null,e))}else{if(h.hasOwnProperty("in")){var i=h["in"];n(i)&&(i=i(b,
+c,f,d));if(3===l(i)){h=[];for(j in i)i.hasOwnProperty(j)&&h.push(j);for(b=0,j=h.length;b<j;b++)q(g,r(a,i[h[b]],b,j,h[b],e));a=g;break a}h=i}else h=h.each,n(h)&&(h=h(b,c,f,d));b=l(h);if(2===b)for(b=0,j=h.length;b<j;b++)q(g,r(a,h[b],b,j,null,e));else 0!==b&&(g=r(a,h,0,1,null,e))}a=g}return a;case "$xor":return B(a,b,c,f,d,e);case "$if":return B(["$xor",a],b,c,f,d,e);case "$call":e=a[1]||{};if(e.view){g=k(e.view,b,c,f,d);h=e.hasOwnProperty("data")?k(e.data,b,c,f,d):b;j=e.hasOwnProperty("index")?k(e.index,
+b,c,f,d):c;i=e.hasOwnProperty("count")?k(e.count,b,c,f,d):f;b=e.hasOwnProperty("key")?k(e.key,b,c,f,d):d;c={};for(f=a.length-1;2<=f;f--)d=a[f],e=d[1]||{},e.hasOwnProperty("name")&&(c[e.name]=d);a=g&&n(g.getView)?k(g.getView(),h,j,i,b,c):null}else a=null;return a;case "$part":return g=(a[1]||{}).name||"",g=e&&e.hasOwnProperty(g)?e[g]:a,r(g,b,c,f,d)}g=[g];h=1;for(j=a.length;h<j;h++)q(g,k(a[h],b,c,f,d,e));return g;case 3:e={};for(g in a)a.hasOwnProperty(g)&&(e[g]=k(a[g],b,c,f,d));return e}return a};
+u=function(a){return n(a)&&n(a.getView)?a:J(a)};u.raw=function(a){return new y(a)};var M={area:!0,base:!0,basefont:!0,br:!0,col:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,wbr:!0};p.prototype.toString=function(){var a;var b=this.value;try{var c=new o;C(c,b);a=c.toString()}catch(f){a="["+f+"]"}return a};p.prototype.write=function(a){(a||m).write(""+this)};var P={rowspan:"rowSpan",colspan:"colSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",tabindex:"tabIndex",
+accesskey:"accessKey",hidefocus:"hideFocus",usemap:"useMap",maxlength:"maxLength",readonly:"readOnly",contenteditable:"contentEditable"},t={enctype:"encoding",onscroll:"DOMMouseScroll"},N=/^[\r\n]+/,O=/[\r\n]+$/;p.prototype.toDOM=function(a,b){4===l(a)&&(a=m.getElementById(a));var c;try{b&&(c=a,a=null),c=I(c||s(this.value[0]),this.value)}catch(f){c=m.createTextNode("["+f+"]")}a&&a.parentNode&&a.parentNode.replaceChild(c,a);return c};p.prototype.reload=function(){var a=m;try{var b=this.toDOM();a.replaceChild(b,
+a.documentElement);if(a.createStyleSheet){for(var c=b.firstChild;c&&"HEAD"!==(c.tagName||"");)c=c.nextSibling;for(var f=c&&c.firstChild;f;){if("LINK"===(f.tagName||""))f.href=f.href;f=f.nextSibling}}}catch(d){a=a.open("text/html"),a.write(this.toString()),a.close()}};return u}(window,document);