").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(n.unit=o,n.start=+a||+r||0,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);a.finish=function(){t.stop(!0)},(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.cur&&i.cur.finish&&i.cur.finish.call(this),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
+/**
+ * jQuery JSON plugin 2.4.0
+ *
+ * @author Brantley Harris, 2009-2011
+ * @author Timo Tijhof, 2011-2012
+ * @source This plugin is heavily influenced by MochiKit's serializeJSON, which is
+ * copyrighted 2005 by Bob Ippolito.
+ * @source Brantley Harris wrote this plugin. It is based somewhat on the JSON.org
+ * website's http://www.json.org/json2.js, which proclaims:
+ * "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
+ * I uphold.
+ * @license MIT License
+ */
+(function ($) {
+ 'use strict';
+
+ var escape = /["\\\x00-\x1f\x7f-\x9f]/g,
+ meta = {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ hasOwn = Object.prototype.hasOwnProperty;
+
+ /**
+ * jQuery.toJSON
+ * Converts the given argument into a JSON representation.
+ *
+ * @param o {Mixed} The json-serializable *thing* to be converted
+ *
+ * If an object has a toJSON prototype, that will be used to get the representation.
+ * Non-integer/string keys are skipped in the object, as are keys that point to a
+ * function.
+ *
+ */
+ $.toJSON = typeof JSON === 'object' && JSON.stringify ? JSON.stringify : function (o) {
+ if (o === null) {
+ return 'null';
+ }
+
+ var pairs, k, name, val,
+ type = $.type(o);
+
+ if (type === 'undefined') {
+ return undefined;
+ }
+
+ // Also covers instantiated Number and Boolean objects,
+ // which are typeof 'object' but thanks to $.type, we
+ // catch them here. I don't know whether it is right
+ // or wrong that instantiated primitives are not
+ // exported to JSON as an {"object":..}.
+ // We choose this path because that's what the browsers did.
+ if (type === 'number' || type === 'boolean') {
+ return String(o);
+ }
+ if (type === 'string') {
+ return $.quoteString(o);
+ }
+ if (typeof o.toJSON === 'function') {
+ return $.toJSON(o.toJSON());
+ }
+ if (type === 'date') {
+ var month = o.getUTCMonth() + 1,
+ day = o.getUTCDate(),
+ year = o.getUTCFullYear(),
+ hours = o.getUTCHours(),
+ minutes = o.getUTCMinutes(),
+ seconds = o.getUTCSeconds(),
+ milli = o.getUTCMilliseconds();
+
+ if (month < 10) {
+ month = '0' + month;
+ }
+ if (day < 10) {
+ day = '0' + day;
+ }
+ if (hours < 10) {
+ hours = '0' + hours;
+ }
+ if (minutes < 10) {
+ minutes = '0' + minutes;
+ }
+ if (seconds < 10) {
+ seconds = '0' + seconds;
+ }
+ if (milli < 100) {
+ milli = '0' + milli;
+ }
+ if (milli < 10) {
+ milli = '0' + milli;
+ }
+ return '"' + year + '-' + month + '-' + day + 'T' +
+ hours + ':' + minutes + ':' + seconds +
+ '.' + milli + 'Z"';
+ }
+
+ pairs = [];
+
+ if ($.isArray(o)) {
+ for (k = 0; k < o.length; k++) {
+ pairs.push($.toJSON(o[k]) || 'null');
+ }
+ return '[' + pairs.join(',') + ']';
+ }
+
+ // Any other object (plain object, RegExp, ..)
+ // Need to do typeof instead of $.type, because we also
+ // want to catch non-plain objects.
+ if (typeof o === 'object') {
+ for (k in o) {
+ // Only include own properties,
+ // Filter out inherited prototypes
+ if (hasOwn.call(o, k)) {
+ // Keys must be numerical or string. Skip others
+ type = typeof k;
+ if (type === 'number') {
+ name = '"' + k + '"';
+ } else if (type === 'string') {
+ name = $.quoteString(k);
+ } else {
+ continue;
+ }
+ type = typeof o[k];
+
+ // Invalid values like these return undefined
+ // from toJSON, however those object members
+ // shouldn't be included in the JSON string at all.
+ if (type !== 'function' && type !== 'undefined') {
+ val = $.toJSON(o[k]);
+ pairs.push(name + ':' + val);
+ }
+ }
+ }
+ return '{' + pairs.join(',') + '}';
+ }
+ };
+
+ /**
+ * jQuery.evalJSON
+ * Evaluates a given json string.
+ *
+ * @param str {String}
+ */
+ $.evalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
+ /*jshint evil: true */
+ return eval('(' + str + ')');
+ };
+
+ /**
+ * jQuery.secureEvalJSON
+ * Evals JSON in a way that is *more* secure.
+ *
+ * @param str {String}
+ */
+ $.secureEvalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
+ var filtered =
+ str
+ .replace(/\\["\\\/bfnrtu]/g, '@')
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, '');
+
+ if (/^[\],:{}\s]*$/.test(filtered)) {
+ /*jshint evil: true */
+ return eval('(' + str + ')');
+ }
+ throw new SyntaxError('Error parsing JSON, source is not valid.');
+ };
+
+ /**
+ * jQuery.quoteString
+ * Returns a string-repr of a string, escaping quotes intelligently.
+ * Mostly a support function for toJSON.
+ * Examples:
+ * >>> jQuery.quoteString('apple')
+ * "apple"
+ *
+ * >>> jQuery.quoteString('"Where are we going?", she asked.')
+ * "\"Where are we going?\", she asked."
+ */
+ $.quoteString = function (str) {
+ if (str.match(escape)) {
+ return '"' + str.replace(escape, function (a) {
+ var c = meta[a];
+ if (typeof c === 'string') {
+ return c;
+ }
+ c = a.charCodeAt();
+ return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
+ }) + '"';
+ }
+ return '"' + str + '"';
+ };
+
+}(jQuery));
+/*!
+
+ handlebars v1.1.2
+
+Copyright (C) 2011 by Yehuda Katz
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+@license
+*/
+var Handlebars = (function() {
+// handlebars/safe-string.js
+var __module4__ = (function() {
+ "use strict";
+ var __exports__;
+ // Build out our basic SafeString type
+ function SafeString(string) {
+ this.string = string;
+ }
+
+ SafeString.prototype.toString = function() {
+ return "" + this.string;
+ };
+
+ __exports__ = SafeString;
+ return __exports__;
+})();
+
+// handlebars/utils.js
+var __module3__ = (function(__dependency1__) {
+ "use strict";
+ var __exports__ = {};
+ var SafeString = __dependency1__;
+
+ var escape = {
+ "&": "&",
+ "<": "<",
+ ">": ">",
+ '"': """,
+ "'": "'",
+ "`": "`"
+ };
+
+ var badChars = /[&<>"'`]/g;
+ var possible = /[&<>"'`]/;
+
+ function escapeChar(chr) {
+ return escape[chr] || "&";
+ }
+
+ function extend(obj, value) {
+ for(var key in value) {
+ if(value.hasOwnProperty(key)) {
+ obj[key] = value[key];
+ }
+ }
+ }
+
+ __exports__.extend = extend;var toString = Object.prototype.toString;
+ __exports__.toString = toString;
+ // Sourced from lodash
+ // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
+ var isFunction = function(value) {
+ return typeof value === 'function';
+ };
+ // fallback for older versions of Chrome and Safari
+ if (isFunction(/x/)) {
+ isFunction = function(value) {
+ return typeof value === 'function' && toString.call(value) === '[object Function]';
+ };
+ }
+ var isFunction;
+ __exports__.isFunction = isFunction;
+ var isArray = Array.isArray || function(value) {
+ return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
+ };
+ __exports__.isArray = isArray;
+
+ function escapeExpression(string) {
+ // don't escape SafeStrings, since they're already safe
+ if (string instanceof SafeString) {
+ return string.toString();
+ } else if (!string && string !== 0) {
+ return "";
+ }
+
+ // Force a string conversion as this will be done by the append regardless and
+ // the regex test will do this transparently behind the scenes, causing issues if
+ // an object's to string has escaped characters in it.
+ string = "" + string;
+
+ if(!possible.test(string)) { return string; }
+ return string.replace(badChars, escapeChar);
+ }
+
+ __exports__.escapeExpression = escapeExpression;function isEmpty(value) {
+ if (!value && value !== 0) {
+ return true;
+ } else if (isArray(value) && value.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ __exports__.isEmpty = isEmpty;
+ return __exports__;
+})(__module4__);
+
+// handlebars/exception.js
+var __module5__ = (function() {
+ "use strict";
+ var __exports__;
+
+ var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
+
+ function Exception(/* message */) {
+ var tmp = Error.prototype.constructor.apply(this, arguments);
+
+ // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
+ for (var idx = 0; idx < errorProps.length; idx++) {
+ this[errorProps[idx]] = tmp[errorProps[idx]];
+ }
+ }
+
+ Exception.prototype = new Error();
+
+ __exports__ = Exception;
+ return __exports__;
+})();
+
+// handlebars/base.js
+var __module2__ = (function(__dependency1__, __dependency2__) {
+ "use strict";
+ var __exports__ = {};
+ /*globals Exception, Utils */
+ var Utils = __dependency1__;
+ var Exception = __dependency2__;
+
+ var VERSION = "1.1.2";
+ __exports__.VERSION = VERSION;var COMPILER_REVISION = 4;
+ __exports__.COMPILER_REVISION = COMPILER_REVISION;
+ var REVISION_CHANGES = {
+ 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it
+ 2: '== 1.0.0-rc.3',
+ 3: '== 1.0.0-rc.4',
+ 4: '>= 1.0.0'
+ };
+ __exports__.REVISION_CHANGES = REVISION_CHANGES;
+ var isArray = Utils.isArray,
+ isFunction = Utils.isFunction,
+ toString = Utils.toString,
+ objectType = '[object Object]';
+
+ function HandlebarsEnvironment(helpers, partials) {
+ this.helpers = helpers || {};
+ this.partials = partials || {};
+
+ registerDefaultHelpers(this);
+ }
+
+ __exports__.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = {
+ constructor: HandlebarsEnvironment,
+
+ logger: logger,
+ log: log,
+
+ registerHelper: function(name, fn, inverse) {
+ if (toString.call(name) === objectType) {
+ if (inverse || fn) { throw new Exception('Arg not supported with multiple helpers'); }
+ Utils.extend(this.helpers, name);
+ } else {
+ if (inverse) { fn.not = inverse; }
+ this.helpers[name] = fn;
+ }
+ },
+
+ registerPartial: function(name, str) {
+ if (toString.call(name) === objectType) {
+ Utils.extend(this.partials, name);
+ } else {
+ this.partials[name] = str;
+ }
+ }
+ };
+
+ function registerDefaultHelpers(instance) {
+ instance.registerHelper('helperMissing', function(arg) {
+ if(arguments.length === 2) {
+ return undefined;
+ } else {
+ throw new Error("Missing helper: '" + arg + "'");
+ }
+ });
+
+ instance.registerHelper('blockHelperMissing', function(context, options) {
+ var inverse = options.inverse || function() {}, fn = options.fn;
+
+ if (isFunction(context)) { context = context.call(this); }
+
+ if(context === true) {
+ return fn(this);
+ } else if(context === false || context == null) {
+ return inverse(this);
+ } else if (isArray(context)) {
+ if(context.length > 0) {
+ return instance.helpers.each(context, options);
+ } else {
+ return inverse(this);
+ }
+ } else {
+ return fn(context);
+ }
+ });
+
+ instance.registerHelper('each', function(context, options) {
+ var fn = options.fn, inverse = options.inverse;
+ var i = 0, ret = "", data;
+
+ if (isFunction(context)) { context = context.call(this); }
+
+ if (options.data) {
+ data = createFrame(options.data);
+ }
+
+ if(context && typeof context === 'object') {
+ if (isArray(context)) {
+ for(var j = context.length; i 0) { throw new Exception("Invalid path: " + original); }
+ else if (part === "..") { depth++; }
+ else { this.isScoped = true; }
+ }
+ else { dig.push(part); }
+ }
+
+ this.original = original;
+ this.parts = dig;
+ this.string = dig.join('.');
+ this.depth = depth;
+
+ // an ID is simple if it only has one part, and that part is not
+ // `..` or `this`.
+ this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
+
+ this.stringModeValue = this.string;
+ }
+
+ __exports__.IdNode = IdNode;function PartialNameNode(name) {
+ this.type = "PARTIAL_NAME";
+ this.name = name.original;
+ }
+
+ __exports__.PartialNameNode = PartialNameNode;function DataNode(id) {
+ this.type = "DATA";
+ this.id = id;
+ }
+
+ __exports__.DataNode = DataNode;function StringNode(string) {
+ this.type = "STRING";
+ this.original =
+ this.string =
+ this.stringModeValue = string;
+ }
+
+ __exports__.StringNode = StringNode;function IntegerNode(integer) {
+ this.type = "INTEGER";
+ this.original =
+ this.integer = integer;
+ this.stringModeValue = Number(integer);
+ }
+
+ __exports__.IntegerNode = IntegerNode;function BooleanNode(bool) {
+ this.type = "BOOLEAN";
+ this.bool = bool;
+ this.stringModeValue = bool === "true";
+ }
+
+ __exports__.BooleanNode = BooleanNode;function CommentNode(comment) {
+ this.type = "comment";
+ this.comment = comment;
+ }
+
+ __exports__.CommentNode = CommentNode;
+ return __exports__;
+})(__module5__);
+
+// handlebars/compiler/parser.js
+var __module9__ = (function() {
+ "use strict";
+ var __exports__;
+ /* Jison generated parser */
+ var handlebars = (function(){
+ var parser = {trace: function trace() { },
+ yy: {},
+ symbols_: {"error":2,"root":3,"statements":4,"EOF":5,"program":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"CLOSE_UNESCAPED":24,"OPEN_PARTIAL":25,"partialName":26,"partial_option0":27,"inMustache_repetition0":28,"inMustache_option0":29,"dataName":30,"param":31,"STRING":32,"INTEGER":33,"BOOLEAN":34,"hash":35,"hash_repetition_plus0":36,"hashSegment":37,"ID":38,"EQUALS":39,"DATA":40,"pathSegments":41,"SEP":42,"$accept":0,"$end":1},
+ terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"CLOSE_UNESCAPED",25:"OPEN_PARTIAL",32:"STRING",33:"INTEGER",34:"BOOLEAN",38:"ID",39:"EQUALS",40:"DATA",42:"SEP"},
+ productions_: [0,[3,2],[3,1],[6,2],[6,3],[6,2],[6,1],[6,1],[6,0],[4,1],[4,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,4],[7,2],[17,3],[17,1],[31,1],[31,1],[31,1],[31,1],[31,1],[35,1],[37,3],[26,1],[26,1],[26,1],[30,2],[21,1],[41,3],[41,1],[27,0],[27,1],[28,0],[28,2],[29,0],[29,1],[36,1],[36,2]],
+ performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
+
+ var $0 = $$.length - 1;
+ switch (yystate) {
+ case 1: return new yy.ProgramNode($$[$0-1]);
+ break;
+ case 2: return new yy.ProgramNode([]);
+ break;
+ case 3:this.$ = new yy.ProgramNode([], $$[$0-1], $$[$0]);
+ break;
+ case 4:this.$ = new yy.ProgramNode($$[$0-2], $$[$0-1], $$[$0]);
+ break;
+ case 5:this.$ = new yy.ProgramNode($$[$0-1], $$[$0], []);
+ break;
+ case 6:this.$ = new yy.ProgramNode($$[$0]);
+ break;
+ case 7:this.$ = new yy.ProgramNode([]);
+ break;
+ case 8:this.$ = new yy.ProgramNode([]);
+ break;
+ case 9:this.$ = [$$[$0]];
+ break;
+ case 10: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
+ break;
+ case 11:this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0]);
+ break;
+ case 12:this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0]);
+ break;
+ case 13:this.$ = $$[$0];
+ break;
+ case 14:this.$ = $$[$0];
+ break;
+ case 15:this.$ = new yy.ContentNode($$[$0]);
+ break;
+ case 16:this.$ = new yy.CommentNode($$[$0]);
+ break;
+ case 17:this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], $$[$0-2], stripFlags($$[$0-2], $$[$0]));
+ break;
+ case 18:this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], $$[$0-2], stripFlags($$[$0-2], $$[$0]));
+ break;
+ case 19:this.$ = {path: $$[$0-1], strip: stripFlags($$[$0-2], $$[$0])};
+ break;
+ case 20:this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], $$[$0-2], stripFlags($$[$0-2], $$[$0]));
+ break;
+ case 21:this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], $$[$0-2], stripFlags($$[$0-2], $$[$0]));
+ break;
+ case 22:this.$ = new yy.PartialNode($$[$0-2], $$[$0-1], stripFlags($$[$0-3], $$[$0]));
+ break;
+ case 23:this.$ = stripFlags($$[$0-1], $$[$0]);
+ break;
+ case 24:this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
+ break;
+ case 25:this.$ = [[$$[$0]], null];
+ break;
+ case 26:this.$ = $$[$0];
+ break;
+ case 27:this.$ = new yy.StringNode($$[$0]);
+ break;
+ case 28:this.$ = new yy.IntegerNode($$[$0]);
+ break;
+ case 29:this.$ = new yy.BooleanNode($$[$0]);
+ break;
+ case 30:this.$ = $$[$0];
+ break;
+ case 31:this.$ = new yy.HashNode($$[$0]);
+ break;
+ case 32:this.$ = [$$[$0-2], $$[$0]];
+ break;
+ case 33:this.$ = new yy.PartialNameNode($$[$0]);
+ break;
+ case 34:this.$ = new yy.PartialNameNode(new yy.StringNode($$[$0]));
+ break;
+ case 35:this.$ = new yy.PartialNameNode(new yy.IntegerNode($$[$0]));
+ break;
+ case 36:this.$ = new yy.DataNode($$[$0]);
+ break;
+ case 37:this.$ = new yy.IdNode($$[$0]);
+ break;
+ case 38: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2];
+ break;
+ case 39:this.$ = [{part: $$[$0]}];
+ break;
+ case 42:this.$ = [];
+ break;
+ case 43:$$[$0-1].push($$[$0]);
+ break;
+ case 46:this.$ = [$$[$0]];
+ break;
+ case 47:$$[$0-1].push($$[$0]);
+ break;
+ }
+ },
+ table: [{3:1,4:2,5:[1,3],8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],25:[1,15]},{1:[3]},{5:[1,16],8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],25:[1,15]},{1:[2,2]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],25:[2,9]},{4:20,6:18,7:19,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,8],22:[1,13],23:[1,14],25:[1,15]},{4:20,6:22,7:19,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,8],22:[1,13],23:[1,14],25:[1,15]},{5:[2,13],14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],25:[2,13]},{5:[2,14],14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],25:[2,14]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],25:[2,15]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],25:[2,16]},{17:23,21:24,30:25,38:[1,28],40:[1,27],41:26},{17:29,21:24,30:25,38:[1,28],40:[1,27],41:26},{17:30,21:24,30:25,38:[1,28],40:[1,27],41:26},{17:31,21:24,30:25,38:[1,28],40:[1,27],41:26},{21:33,26:32,32:[1,34],33:[1,35],38:[1,28],41:26},{1:[2,1]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],25:[2,10]},{10:36,20:[1,37]},{4:38,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,7],22:[1,13],23:[1,14],25:[1,15]},{7:39,8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,6],22:[1,13],23:[1,14],25:[1,15]},{17:23,18:[1,40],21:24,30:25,38:[1,28],40:[1,27],41:26},{10:41,20:[1,37]},{18:[1,42]},{18:[2,42],24:[2,42],28:43,32:[2,42],33:[2,42],34:[2,42],38:[2,42],40:[2,42]},{18:[2,25],24:[2,25]},{18:[2,37],24:[2,37],32:[2,37],33:[2,37],34:[2,37],38:[2,37],40:[2,37],42:[1,44]},{21:45,38:[1,28],41:26},{18:[2,39],24:[2,39],32:[2,39],33:[2,39],34:[2,39],38:[2,39],40:[2,39],42:[2,39]},{18:[1,46]},{18:[1,47]},{24:[1,48]},{18:[2,40],21:50,27:49,38:[1,28],41:26},{18:[2,33],38:[2,33]},{18:[2,34],38:[2,34]},{18:[2,35],38:[2,35]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],25:[2,11]},{21:51,38:[1,28],41:26},{8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,3],22:[1,13],23:[1,14],25:[1,15]},{4:52,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,5],22:[1,13],23:[1,14],25:[1,15]},{14:[2,23],15:[2,23],16:[2,23],19:[2,23],20:[2,23],22:[2,23],23:[2,23],25:[2,23]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],25:[2,12]},{14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],25:[2,18]},{18:[2,44],21:56,24:[2,44],29:53,30:60,31:54,32:[1,57],33:[1,58],34:[1,59],35:55,36:61,37:62,38:[1,63],40:[1,27],41:26},{38:[1,64]},{18:[2,36],24:[2,36],32:[2,36],33:[2,36],34:[2,36],38:[2,36],40:[2,36]},{14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],25:[2,17]},{5:[2,20],14:[2,20],15:[2,20],16:[2,20],19:[2,20],20:[2,20],22:[2,20],23:[2,20],25:[2,20]},{5:[2,21],14:[2,21],15:[2,21],16:[2,21],19:[2,21],20:[2,21],22:[2,21],23:[2,21],25:[2,21]},{18:[1,65]},{18:[2,41]},{18:[1,66]},{8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],25:[1,15]},{18:[2,24],24:[2,24]},{18:[2,43],24:[2,43],32:[2,43],33:[2,43],34:[2,43],38:[2,43],40:[2,43]},{18:[2,45],24:[2,45]},{18:[2,26],24:[2,26],32:[2,26],33:[2,26],34:[2,26],38:[2,26],40:[2,26]},{18:[2,27],24:[2,27],32:[2,27],33:[2,27],34:[2,27],38:[2,27],40:[2,27]},{18:[2,28],24:[2,28],32:[2,28],33:[2,28],34:[2,28],38:[2,28],40:[2,28]},{18:[2,29],24:[2,29],32:[2,29],33:[2,29],34:[2,29],38:[2,29],40:[2,29]},{18:[2,30],24:[2,30],32:[2,30],33:[2,30],34:[2,30],38:[2,30],40:[2,30]},{18:[2,31],24:[2,31],37:67,38:[1,68]},{18:[2,46],24:[2,46],38:[2,46]},{18:[2,39],24:[2,39],32:[2,39],33:[2,39],34:[2,39],38:[2,39],39:[1,69],40:[2,39],42:[2,39]},{18:[2,38],24:[2,38],32:[2,38],33:[2,38],34:[2,38],38:[2,38],40:[2,38],42:[2,38]},{5:[2,22],14:[2,22],15:[2,22],16:[2,22],19:[2,22],20:[2,22],22:[2,22],23:[2,22],25:[2,22]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],25:[2,19]},{18:[2,47],24:[2,47],38:[2,47]},{39:[1,69]},{21:56,30:60,31:70,32:[1,57],33:[1,58],34:[1,59],38:[1,28],40:[1,27],41:26},{18:[2,32],24:[2,32],38:[2,32]}],
+ defaultActions: {3:[2,2],16:[2,1],50:[2,41]},
+ parseError: function parseError(str, hash) {
+ throw new Error(str);
+ },
+ parse: function parse(input) {
+ var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
+ this.lexer.setInput(input);
+ this.lexer.yy = this.yy;
+ this.yy.lexer = this.lexer;
+ this.yy.parser = this;
+ if (typeof this.lexer.yylloc == "undefined")
+ this.lexer.yylloc = {};
+ var yyloc = this.lexer.yylloc;
+ lstack.push(yyloc);
+ var ranges = this.lexer.options && this.lexer.options.ranges;
+ if (typeof this.yy.parseError === "function")
+ this.parseError = this.yy.parseError;
+ function popStack(n) {
+ stack.length = stack.length - 2 * n;
+ vstack.length = vstack.length - n;
+ lstack.length = lstack.length - n;
+ }
+ function lex() {
+ var token;
+ token = self.lexer.lex() || 1;
+ if (typeof token !== "number") {
+ token = self.symbols_[token] || token;
+ }
+ return token;
+ }
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
+ while (true) {
+ state = stack[stack.length - 1];
+ if (this.defaultActions[state]) {
+ action = this.defaultActions[state];
+ } else {
+ if (symbol === null || typeof symbol == "undefined") {
+ symbol = lex();
+ }
+ action = table[state] && table[state][symbol];
+ }
+ if (typeof action === "undefined" || !action.length || !action[0]) {
+ var errStr = "";
+ if (!recovering) {
+ expected = [];
+ for (p in table[state])
+ if (this.terminals_[p] && p > 2) {
+ expected.push("'" + this.terminals_[p] + "'");
+ }
+ if (this.lexer.showPosition) {
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
+ } else {
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'");
+ }
+ this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
+ }
+ }
+ if (action[0] instanceof Array && action.length > 1) {
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
+ }
+ switch (action[0]) {
+ case 1:
+ stack.push(symbol);
+ vstack.push(this.lexer.yytext);
+ lstack.push(this.lexer.yylloc);
+ stack.push(action[1]);
+ symbol = null;
+ if (!preErrorSymbol) {
+ yyleng = this.lexer.yyleng;
+ yytext = this.lexer.yytext;
+ yylineno = this.lexer.yylineno;
+ yyloc = this.lexer.yylloc;
+ if (recovering > 0)
+ recovering--;
+ } else {
+ symbol = preErrorSymbol;
+ preErrorSymbol = null;
+ }
+ break;
+ case 2:
+ len = this.productions_[action[1]][1];
+ yyval.$ = vstack[vstack.length - len];
+ yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column};
+ if (ranges) {
+ yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];
+ }
+ r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
+ if (typeof r !== "undefined") {
+ return r;
+ }
+ if (len) {
+ stack = stack.slice(0, -1 * len * 2);
+ vstack = vstack.slice(0, -1 * len);
+ lstack = lstack.slice(0, -1 * len);
+ }
+ stack.push(this.productions_[action[1]][0]);
+ vstack.push(yyval.$);
+ lstack.push(yyval._$);
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
+ stack.push(newState);
+ break;
+ case 3:
+ return true;
+ }
+ }
+ return true;
+ }
+ };
+
+
+ function stripFlags(open, close) {
+ return {
+ left: open[2] === '~',
+ right: close[0] === '~' || close[1] === '~'
+ };
+ }
+
+ /* Jison generated lexer */
+ var lexer = (function(){
+ var lexer = ({EOF:1,
+ parseError:function parseError(str, hash) {
+ if (this.yy.parser) {
+ this.yy.parser.parseError(str, hash);
+ } else {
+ throw new Error(str);
+ }
+ },
+ setInput:function (input) {
+ this._input = input;
+ this._more = this._less = this.done = false;
+ this.yylineno = this.yyleng = 0;
+ this.yytext = this.matched = this.match = '';
+ this.conditionStack = ['INITIAL'];
+ this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
+ if (this.options.ranges) this.yylloc.range = [0,0];
+ this.offset = 0;
+ return this;
+ },
+ input:function () {
+ var ch = this._input[0];
+ this.yytext += ch;
+ this.yyleng++;
+ this.offset++;
+ this.match += ch;
+ this.matched += ch;
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
+ if (lines) {
+ this.yylineno++;
+ this.yylloc.last_line++;
+ } else {
+ this.yylloc.last_column++;
+ }
+ if (this.options.ranges) this.yylloc.range[1]++;
+
+ this._input = this._input.slice(1);
+ return ch;
+ },
+ unput:function (ch) {
+ var len = ch.length;
+ var lines = ch.split(/(?:\r\n?|\n)/g);
+
+ this._input = ch + this._input;
+ this.yytext = this.yytext.substr(0, this.yytext.length-len-1);
+ //this.yyleng -= len;
+ this.offset -= len;
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
+ this.match = this.match.substr(0, this.match.length-1);
+ this.matched = this.matched.substr(0, this.matched.length-1);
+
+ if (lines.length-1) this.yylineno -= lines.length-1;
+ var r = this.yylloc.range;
+
+ this.yylloc = {first_line: this.yylloc.first_line,
+ last_line: this.yylineno+1,
+ first_column: this.yylloc.first_column,
+ last_column: lines ?
+ (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length:
+ this.yylloc.first_column - len
+ };
+
+ if (this.options.ranges) {
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
+ }
+ return this;
+ },
+ more:function () {
+ this._more = true;
+ return this;
+ },
+ less:function (n) {
+ this.unput(this.match.slice(n));
+ },
+ pastInput:function () {
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
+ return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
+ },
+ upcomingInput:function () {
+ var next = this.match;
+ if (next.length < 20) {
+ next += this._input.substr(0, 20-next.length);
+ }
+ return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
+ },
+ showPosition:function () {
+ var pre = this.pastInput();
+ var c = new Array(pre.length + 1).join("-");
+ return pre + this.upcomingInput() + "\n" + c+"^";
+ },
+ next:function () {
+ if (this.done) {
+ return this.EOF;
+ }
+ if (!this._input) this.done = true;
+
+ var token,
+ match,
+ tempMatch,
+ index,
+ col,
+ lines;
+ if (!this._more) {
+ this.yytext = '';
+ this.match = '';
+ }
+ var rules = this._currentRules();
+ for (var i=0;i < rules.length; i++) {
+ tempMatch = this._input.match(this.rules[rules[i]]);
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
+ match = tempMatch;
+ index = i;
+ if (!this.options.flex) break;
+ }
+ }
+ if (match) {
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
+ if (lines) this.yylineno += lines.length;
+ this.yylloc = {first_line: this.yylloc.last_line,
+ last_line: this.yylineno+1,
+ first_column: this.yylloc.last_column,
+ last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length};
+ this.yytext += match[0];
+ this.match += match[0];
+ this.matches = match;
+ this.yyleng = this.yytext.length;
+ if (this.options.ranges) {
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
+ }
+ this._more = false;
+ this._input = this._input.slice(match[0].length);
+ this.matched += match[0];
+ token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
+ if (this.done && this._input) this.done = false;
+ if (token) return token;
+ else return;
+ }
+ if (this._input === "") {
+ return this.EOF;
+ } else {
+ return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
+ {text: "", token: null, line: this.yylineno});
+ }
+ },
+ lex:function lex() {
+ var r = this.next();
+ if (typeof r !== 'undefined') {
+ return r;
+ } else {
+ return this.lex();
+ }
+ },
+ begin:function begin(condition) {
+ this.conditionStack.push(condition);
+ },
+ popState:function popState() {
+ return this.conditionStack.pop();
+ },
+ _currentRules:function _currentRules() {
+ return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
+ },
+ topState:function () {
+ return this.conditionStack[this.conditionStack.length-2];
+ },
+ pushState:function begin(condition) {
+ this.begin(condition);
+ }});
+ lexer.options = {};
+ lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
+
+
+ function strip(start, end) {
+ return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng-end);
+ }
+
+
+ var YYSTATE=YY_START
+ switch($avoiding_name_collisions) {
+ case 0:
+ if(yy_.yytext.slice(-2) === "\\\\") {
+ strip(0,1);
+ this.begin("mu");
+ } else if(yy_.yytext.slice(-1) === "\\") {
+ strip(0,1);
+ this.begin("emu");
+ } else {
+ this.begin("mu");
+ }
+ if(yy_.yytext) return 14;
+
+ break;
+ case 1:return 14;
+ break;
+ case 2:
+ if(yy_.yytext.slice(-1) !== "\\") this.popState();
+ if(yy_.yytext.slice(-1) === "\\") strip(0,1);
+ return 14;
+
+ break;
+ case 3:strip(0,4); this.popState(); return 15;
+ break;
+ case 4:return 25;
+ break;
+ case 5:return 16;
+ break;
+ case 6:return 20;
+ break;
+ case 7:return 19;
+ break;
+ case 8:return 19;
+ break;
+ case 9:return 23;
+ break;
+ case 10:return 22;
+ break;
+ case 11:this.popState(); this.begin('com');
+ break;
+ case 12:strip(3,5); this.popState(); return 15;
+ break;
+ case 13:return 22;
+ break;
+ case 14:return 39;
+ break;
+ case 15:return 38;
+ break;
+ case 16:return 38;
+ break;
+ case 17:return 42;
+ break;
+ case 18:/*ignore whitespace*/
+ break;
+ case 19:this.popState(); return 24;
+ break;
+ case 20:this.popState(); return 18;
+ break;
+ case 21:yy_.yytext = strip(1,2).replace(/\\"/g,'"'); return 32;
+ break;
+ case 22:yy_.yytext = strip(1,2).replace(/\\'/g,"'"); return 32;
+ break;
+ case 23:return 40;
+ break;
+ case 24:return 34;
+ break;
+ case 25:return 34;
+ break;
+ case 26:return 33;
+ break;
+ case 27:return 38;
+ break;
+ case 28:yy_.yytext = strip(1,2); return 38;
+ break;
+ case 29:return 'INVALID';
+ break;
+ case 30:return 5;
+ break;
+ }
+ };
+ lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s])))/,/^(?:false(?=([~}\s])))/,/^(?:-?[0-9]+(?=([~}\s])))/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/];
+ lexer.conditions = {"mu":{"rules":[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[3],"inclusive":false},"INITIAL":{"rules":[0,1,30],"inclusive":true}};
+ return lexer;})()
+ parser.lexer = lexer;
+ function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser;
+ return new Parser;
+ })();__exports__ = handlebars;
+ return __exports__;
+})();
+
+// handlebars/compiler/base.js
+var __module8__ = (function(__dependency1__, __dependency2__) {
+ "use strict";
+ var __exports__ = {};
+ var parser = __dependency1__;
+ var AST = __dependency2__;
+
+ __exports__.parser = parser;
+
+ function parse(input) {
+ // Just return if an already-compile AST was passed in.
+ if(input.constructor === AST.ProgramNode) { return input; }
+
+ parser.yy = AST;
+ return parser.parse(input);
+ }
+
+ __exports__.parse = parse;
+ return __exports__;
+})(__module9__, __module7__);
+
+// handlebars/compiler/javascript-compiler.js
+var __module11__ = (function(__dependency1__) {
+ "use strict";
+ var __exports__;
+ var COMPILER_REVISION = __dependency1__.COMPILER_REVISION;
+ var REVISION_CHANGES = __dependency1__.REVISION_CHANGES;
+ var log = __dependency1__.log;
+
+ function Literal(value) {
+ this.value = value;
+ }
+
+ function JavaScriptCompiler() {}
+
+ JavaScriptCompiler.prototype = {
+ // PUBLIC API: You can override these methods in a subclass to provide
+ // alternative compiled forms for name lookup and buffering semantics
+ nameLookup: function(parent, name /* , type*/) {
+ var wrap,
+ ret;
+ if (parent.indexOf('depth') === 0) {
+ wrap = true;
+ }
+
+ if (/^[0-9]+$/.test(name)) {
+ ret = parent + "[" + name + "]";
+ } else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
+ ret = parent + "." + name;
+ }
+ else {
+ ret = parent + "['" + name + "']";
+ }
+
+ if (wrap) {
+ return '(' + parent + ' && ' + ret + ')';
+ } else {
+ return ret;
+ }
+ },
+
+ appendToBuffer: function(string) {
+ if (this.environment.isSimple) {
+ return "return " + string + ";";
+ } else {
+ return {
+ appendToBuffer: true,
+ content: string,
+ toString: function() { return "buffer += " + string + ";"; }
+ };
+ }
+ },
+
+ initializeBuffer: function() {
+ return this.quotedString("");
+ },
+
+ namespace: "Handlebars",
+ // END PUBLIC API
+
+ compile: function(environment, options, context, asObject) {
+ this.environment = environment;
+ this.options = options || {};
+
+ log('debug', this.environment.disassemble() + "\n\n");
+
+ this.name = this.environment.name;
+ this.isChild = !!context;
+ this.context = context || {
+ programs: [],
+ environments: [],
+ aliases: { }
+ };
+
+ this.preamble();
+
+ this.stackSlot = 0;
+ this.stackVars = [];
+ this.registers = { list: [] };
+ this.compileStack = [];
+ this.inlineStack = [];
+
+ this.compileChildren(environment, options);
+
+ var opcodes = environment.opcodes, opcode;
+
+ this.i = 0;
+
+ for(var l=opcodes.length; this.i 0) {
+ this.source[1] = this.source[1] + ", " + locals.join(", ");
+ }
+
+ // Generate minimizer alias mappings
+ if (!this.isChild) {
+ for (var alias in this.context.aliases) {
+ if (this.context.aliases.hasOwnProperty(alias)) {
+ this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
+ }
+ }
+ }
+
+ if (this.source[1]) {
+ this.source[1] = "var " + this.source[1].substring(2) + ";";
+ }
+
+ // Merge children
+ if (!this.isChild) {
+ this.source[1] += '\n' + this.context.programs.join('\n') + '\n';
+ }
+
+ if (!this.environment.isSimple) {
+ this.pushSource("return buffer;");
+ }
+
+ var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"];
+
+ for(var i=0, l=this.environment.depths.list.length; i this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); }
+ return this.topStackName();
+ },
+ topStackName: function() {
+ return "stack" + this.stackSlot;
+ },
+ flushInline: function() {
+ var inlineStack = this.inlineStack;
+ if (inlineStack.length) {
+ this.inlineStack = [];
+ for (var i = 0, len = inlineStack.length; i < len; i++) {
+ var entry = inlineStack[i];
+ if (entry instanceof Literal) {
+ this.compileStack.push(entry);
+ } else {
+ this.pushStack(entry);
+ }
+ }
+ }
+ },
+ isInline: function() {
+ return this.inlineStack.length;
+ },
+
+ popStack: function(wrapped) {
+ var inline = this.isInline(),
+ item = (inline ? this.inlineStack : this.compileStack).pop();
+
+ if (!wrapped && (item instanceof Literal)) {
+ return item.value;
+ } else {
+ if (!inline) {
+ this.stackSlot--;
+ }
+ return item;
+ }
+ },
+
+ topStack: function(wrapped) {
+ var stack = (this.isInline() ? this.inlineStack : this.compileStack),
+ item = stack[stack.length - 1];
+
+ if (!wrapped && (item instanceof Literal)) {
+ return item.value;
+ } else {
+ return item;
+ }
+ },
+
+ quotedString: function(str) {
+ return '"' + str
+ .replace(/\\/g, '\\\\')
+ .replace(/"/g, '\\"')
+ .replace(/\n/g, '\\n')
+ .replace(/\r/g, '\\r')
+ .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4
+ .replace(/\u2029/g, '\\u2029') + '"';
+ },
+
+ setupHelper: function(paramSize, name, missingParams) {
+ var params = [];
+ this.setupParams(paramSize, params, missingParams);
+ var foundHelper = this.nameLookup('helpers', name, 'helper');
+
+ return {
+ params: params,
+ name: foundHelper,
+ callParams: ["depth0"].concat(params).join(", "),
+ helperMissingParams: missingParams && ["depth0", this.quotedString(name)].concat(params).join(", ")
+ };
+ },
+
+ // the params and contexts arguments are passed in arrays
+ // to fill in
+ setupParams: function(paramSize, params, useRegister) {
+ var options = [], contexts = [], types = [], param, inverse, program;
+
+ options.push("hash:" + this.popStack());
+
+ inverse = this.popStack();
+ program = this.popStack();
+
+ // Avoid setting fn and inverse if neither are set. This allows
+ // helpers to do a check for `if (options.fn)`
+ if (program || inverse) {
+ if (!program) {
+ this.context.aliases.self = "this";
+ program = "self.noop";
+ }
+
+ if (!inverse) {
+ this.context.aliases.self = "this";
+ inverse = "self.noop";
+ }
+
+ options.push("inverse:" + inverse);
+ options.push("fn:" + program);
+ }
+
+ for(var i=0; i 0) {
+ context.keepAlive = data.getElementsByTagName("keepAlive")[0].childNodes[0].nodeValue;
+ }
+ context.pingTimer =
+ setTimeout(
+ function () {
+ context.ping();
+ },
+ context.keepAlive
+ );
+ if ( context.initCallback )
+ context.initCallback();
+ }
+ else
+ context.throwError('Init failed. Malformed WS resonse.',
+ 110);
+ }
+ );
+ // when through proxy no need to init
+ } else {
+ this.initStatusOK = true;
+ }
+ },
+ // no need to ping explicitly
+ ping: function ()
+ {
+ // pinging only makes sense when using pazpar2 directly
+ if( !this.initStatusOK || !this.useSessions )
+ throw new Error(
+ 'Pz2.js: Ping not allowed (proxy mode) or session not initialized.'
+ );
+ var context = this;
+
+ clearTimeout(context.pingTimer);
+
+ var request = new pzHttpRequest(this.pz2String, this.errorHandler);
+ request.safeGet(
+ { "command": "ping", "session": this.sessionID, "windowid" : window.name },
+ function(data) {
+ if ( data.getElementsByTagName("status")[0]
+ .childNodes[0].nodeValue == "OK" ) {
+ context.pingStatusOK = true;
+ context.pingTimer =
+ setTimeout(
+ function () {
+ context.ping();
+ },
+ context.keepAlive
+ );
+ }
+ else
+ context.throwError('Ping failed. Malformed WS resonse.',
+ 111);
+ }
+ );
+ },
+ search: function (query, num, sort, filter, showfrom, addParamsArr)
+ {
+ clearTimeout(this.statTimer);
+ clearTimeout(this.showTimer);
+ clearTimeout(this.termTimer);
+ clearTimeout(this.bytargetTimer);
+
+ this.showCounter = 0;
+ this.termCounter = 0;
+ this.bytargetCounter = 0;
+ this.statCounter = 0;
+ this.activeClients = 1;
+
+ // no proxy mode
+ if( !this.initStatusOK )
+ throw new Error('Pz2.js: session not initialized.');
+
+ if( query !== undefined )
+ this.currQuery = query;
+ else
+ throw new Error("Pz2.js: no query supplied to the search command.");
+
+ if ( showfrom !== undefined )
+ var start = showfrom;
+ else
+ var start = 0;
+
+ var searchParams = {
+ "command": "search",
+ "query": this.currQuery,
+ "session": this.sessionID,
+ "windowid" : window.name
+ };
+
+ if( sort !== undefined ) {
+ this.currentSort = sort;
+ searchParams["sort"] = sort;
+ }
+ if (filter !== undefined) searchParams["filter"] = filter;
+ if (this.mergekey) searchParams["mergekey"] = this.mergekey;
+ if (this.rank) searchParams["rank"] = this.rank;
+
+ // copy additional parmeters, do not overwrite
+ if (addParamsArr != undefined) {
+ for (var prop in addParamsArr) {
+ if (!searchParams.hasOwnProperty(prop))
+ searchParams[prop] = addParamsArr[prop];
+ }
+ }
+
+ var context = this;
+ var request = new pzHttpRequest(this.pz2String, this.errorHandler);
+ request.safeGet(
+ searchParams,
+ function(data) {
+ if ( data.getElementsByTagName("status")[0]
+ .childNodes[0].nodeValue == "OK" ) {
+ context.searchStatusOK = true;
+ //piggyback search
+ context.show(start, num, sort);
+ if (context.statCallback)
+ context.stat();
+ if (context.termlistCallback)
+ context.termlist();
+ if (context.bytargetCallback)
+ context.bytarget();
+ }
+ else
+ context.throwError('Search failed. Malformed WS resonse.',
+ 112);
+ }
+ );
+ },
+ stat: function()
+ {
+ if( !this.initStatusOK )
+ throw new Error('Pz2.js: session not initialized.');
+
+ // if called explicitly takes precedence
+ clearTimeout(this.statTimer);
+
+ var context = this;
+ var request = new pzHttpRequest(this.pz2String, this.errorHandler);
+ request.safeGet(
+ { "command": "stat", "session": this.sessionID, "windowid" : window.name },
+ function(data) {
+ if ( data.getElementsByTagName("stat") ) {
+ var activeClients =
+ Number( data.getElementsByTagName("activeclients")[0]
+ .childNodes[0].nodeValue );
+ context.activeClients = activeClients;
+
+ var stat = Element_parseChildNodes(data.documentElement);
+
+ context.statCounter++;
+ var delay = context.statTime
+ + context.statCounter * context.dumpFactor;
+
+ if ( activeClients > 0 )
+ context.statTimer =
+ setTimeout(
+ function () {
+ context.stat();
+ },
+ delay
+ );
+ context.statCallback(stat);
+ }
+ else
+ context.throwError('Stat failed. Malformed WS resonse.',
+ 113);
+ }
+ );
+ },
+ show: function(start, num, sort, query_state)
+ {
+ if( !this.searchStatusOK && this.useSessions )
+ throw new Error(
+ 'Pz2.js: show command has to be preceded with a search command.'
+ );
+
+ // if called explicitly takes precedence
+ clearTimeout(this.showTimer);
+
+ if( sort !== undefined )
+ this.currentSort = sort;
+ if( start !== undefined )
+ this.currentStart = Number( start );
+ if( num !== undefined )
+ this.currentNum = Number( num );
+
+ var context = this;
+ var request = new pzHttpRequest(this.pz2String, this.errorHandler);
+ var requestParameters =
+ {
+ "command": "show",
+ "session": this.sessionID,
+ "start": this.currentStart,
+ "num": this.currentNum,
+ "sort": this.currentSort,
+ "block": 1,
+ "type": this.showResponseType,
+ "windowid" : window.name
+ };
+ if (query_state)
+ requestParameters["query-state"] = query_state;
+ if (this.version && this.version > 0)
+ requestParameters["version"] = this.version;
+ request.safeGet(
+ requestParameters,
+ function(data, type) {
+ var show = null;
+ var activeClients = 0;
+ if (type === "json") {
+ show = {};
+ activeClients = Number(data.activeclients[0]);
+ show.activeclients = activeClients;
+ show.merged = Number(data.merged[0]);
+ show.total = Number(data.total[0]);
+ show.start = Number(data.start[0]);
+ show.num = Number(data.num[0]);
+ show.hits = data.hit;
+ } else if (data.getElementsByTagName("status")[0]
+ .childNodes[0].nodeValue == "OK") {
+ // first parse the status data send along with records
+ // this is strictly bound to the format
+ activeClients =
+ Number(data.getElementsByTagName("activeclients")[0]
+ .childNodes[0].nodeValue);
+ show = {
+ "activeclients": activeClients,
+ "merged":
+ Number( data.getElementsByTagName("merged")[0]
+ .childNodes[0].nodeValue ),
+ "total":
+ Number( data.getElementsByTagName("total")[0]
+ .childNodes[0].nodeValue ),
+ "start":
+ Number( data.getElementsByTagName("start")[0]
+ .childNodes[0].nodeValue ),
+ "num":
+ Number( data.getElementsByTagName("num")[0]
+ .childNodes[0].nodeValue ),
+ "hits": []
+ };
+ // parse all the first-level nodes for all tags
+ var hits = data.getElementsByTagName("hit");
+ for (i = 0; i < hits.length; i++)
+ show.hits[i] = Element_parseChildNodes(hits[i]);
+ } else {
+ context.throwError('Show failed. Malformed WS resonse.',
+ 114);
+ };
+
+ var approxNode = data.getElementsByTagName("approximation");
+ if (approxNode && approxNode[0] && approxNode[0].childNodes[0] && approxNode[0].childNodes[0].nodeValue)
+ show['approximation'] =
+ Number( approxNode[0].childNodes[0].nodeValue);
+
+
+ data.getElementsByTagName("")
+ context.activeClients = activeClients;
+ context.showCounter++;
+ var delay = context.showTime;
+ if (context.showCounter > context.showFastCount)
+ delay += context.showCounter * context.dumpFactor;
+ if ( activeClients > 0 )
+ context.showTimer = setTimeout(
+ function () {
+ context.show();
+ },
+ delay);
+ context.showCallback(show);
+ }
+ );
+ },
+ record: function(id, offset, syntax, handler)
+ {
+ // we may call record with no previous search if in proxy mode
+ if(!this.searchStatusOK && this.useSessions)
+ throw new Error(
+ 'Pz2.js: record command has to be preceded with a search command.'
+ );
+
+ if( id !== undefined )
+ this.currRecID = id;
+
+ var recordParams = {
+ "command": "record",
+ "session": this.sessionID,
+ "id": this.currRecID,
+ "windowid" : window.name
+ };
+
+ this.currRecOffset = null;
+ if (offset != undefined) {
+ recordParams["offset"] = offset;
+ this.currRecOffset = offset;
+ }
+
+ if (syntax != undefined)
+ recordParams['syntax'] = syntax;
+
+ //overwrite default callback id needed
+ var callback = this.recordCallback;
+ var args = undefined;
+ if (handler != undefined) {
+ callback = handler['callback'];
+ args = handler['args'];
+ }
+
+ var context = this;
+ var request = new pzHttpRequest(this.pz2String, this.errorHandler);
+
+ request.safeGet(
+ recordParams,
+ function(data) {
+ var recordNode;
+ var record;
+ //raw record
+ if (context.currRecOffset !== null) {
+ record = new Array();
+ record['xmlDoc'] = data;
+ record['offset'] = context.currRecOffset;
+ callback(record, args);
+ //pz2 record
+ } else if ( recordNode =
+ data.getElementsByTagName("record")[0] ) {
+ // if stylesheet was fetched do not parse the response
+ if ( context.xslDoc ) {
+ record = new Array();
+ record['xmlDoc'] = data;
+ record['xslDoc'] = context.xslDoc;
+ record['recid'] =
+ recordNode.getElementsByTagName("recid")[0]
+ .firstChild.nodeValue;
+ //parse record
+ } else {
+ record = Element_parseChildNodes(recordNode);
+ }
+ var activeClients =
+ Number( data.getElementsByTagName("activeclients")[0]
+ .childNodes[0].nodeValue );
+ context.activeClients = activeClients;
+ context.recordCounter++;
+ var delay = context.recordTime + context.recordCounter * context.dumpFactor;
+ if ( activeClients > 0 )
+ context.recordTimer =
+ setTimeout (
+ function() {
+ context.record(id, offset, syntax, handler);
+ },
+ delay
+ );
+ callback(record, args);
+ }
+ else
+ context.throwError('Record failed. Malformed WS resonse.',
+ 115);
+ }
+ );
+ },
+
+ termlist: function()
+ {
+ if( !this.searchStatusOK && this.useSessions )
+ throw new Error(
+ 'Pz2.js: termlist command has to be preceded with a search command.'
+ );
+
+ // if called explicitly takes precedence
+ clearTimeout(this.termTimer);
+
+ var context = this;
+ var request = new pzHttpRequest(this.pz2String, this.errorHandler);
+ request.safeGet(
+ {
+ "command": "termlist",
+ "session": this.sessionID,
+ "name": this.termKeys,
+ "windowid" : window.name,
+ "version" : this.version
+
+ },
+ function(data) {
+ if ( data.getElementsByTagName("termlist") ) {
+ var activeClients =
+ Number( data.getElementsByTagName("activeclients")[0]
+ .childNodes[0].nodeValue );
+ context.activeClients = activeClients;
+ var termList = { "activeclients": activeClients };
+ var termLists = data.getElementsByTagName("list");
+ //for each termlist
+ for (i = 0; i < termLists.length; i++) {
+ var listName = termLists[i].getAttribute('name');
+ termList[listName] = new Array();
+ var terms = termLists[i].getElementsByTagName('term');
+ //for each term in the list
+ for (j = 0; j < terms.length; j++) {
+ var term = {
+ "name":
+ (terms[j].getElementsByTagName("name")[0]
+ .childNodes.length
+ ? terms[j].getElementsByTagName("name")[0]
+ .childNodes[0].nodeValue
+ : 'ERROR'),
+ "freq":
+ terms[j]
+ .getElementsByTagName("frequency")[0]
+ .childNodes[0].nodeValue || 'ERROR'
+ };
+
+ // Only for xtargets: id, records, filtered
+ var termIdNode =
+ terms[j].getElementsByTagName("id");
+ if(terms[j].getElementsByTagName("id").length)
+ term["id"] =
+ termIdNode[0].childNodes[0].nodeValue;
+ termList[listName][j] = term;
+
+ var recordsNode = terms[j].getElementsByTagName("records");
+ if (recordsNode && recordsNode.length)
+ term["records"] = recordsNode[0].childNodes[0].nodeValue;
+
+ var filteredNode = terms[j].getElementsByTagName("filtered");
+ if (filteredNode && filteredNode.length)
+ term["filtered"] = filteredNode[0].childNodes[0].nodeValue;
+
+ }
+ }
+
+ context.termCounter++;
+ var delay = context.termTime
+ + context.termCounter * context.dumpFactor;
+ if ( activeClients > 0 )
+ context.termTimer =
+ setTimeout(
+ function () {
+ context.termlist();
+ },
+ delay
+ );
+
+ context.termlistCallback(termList);
+ }
+ else
+ context.throwError('Termlist failed. Malformed WS resonse.',
+ 116);
+ }
+ );
+
+ },
+ bytarget: function()
+ {
+ if( !this.initStatusOK && this.useSessions )
+ throw new Error(
+ 'Pz2.js: bytarget command has to be preceded with a search command.'
+ );
+
+ // no need to continue
+ if( !this.searchStatusOK )
+ return;
+
+ // if called explicitly takes precedence
+ clearTimeout(this.bytargetTimer);
+
+ var context = this;
+ var request = new pzHttpRequest(this.pz2String, this.errorHandler);
+ request.safeGet(
+ {
+ "command": "bytarget",
+ "session": this.sessionID,
+ "block": 1,
+ "windowid" : window.name,
+ "version" : this.version
+ },
+ function(data) {
+ if ( data.getElementsByTagName("status")[0]
+ .childNodes[0].nodeValue == "OK" ) {
+ var targetNodes = data.getElementsByTagName("target");
+ var bytarget = new Array();
+ for ( i = 0; i < targetNodes.length; i++) {
+ bytarget[i] = new Array();
+ for( j = 0; j < targetNodes[i].childNodes.length; j++ ) {
+ if ( targetNodes[i].childNodes[j].nodeType
+ == Node.ELEMENT_NODE ) {
+ var nodeName =
+ targetNodes[i].childNodes[j].nodeName;
+ if (targetNodes[i].childNodes[j].firstChild != null)
+ {
+ var nodeText = targetNodes[i].childNodes[j]
+ .firstChild.nodeValue;
+ bytarget[i][nodeName] = nodeText;
+ }
+ else {
+ bytarget[i][nodeName] = "";
+ }
+
+
+ }
+ }
+ if (bytarget[i]["state"]=="Client_Disconnected") {
+ bytarget[i]["hits"] = "Error";
+ } else if (bytarget[i]["state"]=="Client_Error") {
+ bytarget[i]["hits"] = "Error";
+ } else if (bytarget[i]["state"]=="Client_Working") {
+ bytarget[i]["hits"] = "...";
+ }
+ if (bytarget[i].diagnostic == "1") {
+ bytarget[i].diagnostic = "Permanent system error";
+ } else if (bytarget[i].diagnostic == "2") {
+ bytarget[i].diagnostic = "Temporary system error";
+ }
+ var targetsSuggestions = targetNodes[i].getElementsByTagName("suggestions");
+ if (targetsSuggestions != undefined && targetsSuggestions.length>0) {
+ var suggestions = targetsSuggestions[0];
+ bytarget[i]["suggestions"] = Element_parseChildNodes(suggestions);
+ }
+ }
+
+ context.bytargetCounter++;
+ var delay = context.bytargetTime
+ + context.bytargetCounter * context.dumpFactor;
+ if ( context.activeClients > 0 )
+ context.bytargetTimer =
+ setTimeout(
+ function () {
+ context.bytarget();
+ },
+ delay
+ );
+
+ context.bytargetCallback(bytarget);
+ }
+ else
+ context.throwError('Bytarget failed. Malformed WS resonse.',
+ 117);
+ }
+ );
+ },
+
+ // just for testing, probably shouldn't be here
+ showNext: function(page)
+ {
+ var step = page || 1;
+ this.show( ( step * this.currentNum ) + this.currentStart );
+ },
+
+ showPrev: function(page)
+ {
+ if (this.currentStart == 0 )
+ return false;
+ var step = page || 1;
+ var newStart = this.currentStart - (step * this.currentNum );
+ this.show( newStart > 0 ? newStart : 0 );
+ },
+
+ showPage: function(pageNum)
+ {
+ //var page = pageNum || 1;
+ this.show(pageNum * this.currentNum);
+ }
+};
+
+/*
+********************************************************************************
+** AJAX HELPER CLASS ***********************************************************
+********************************************************************************
+*/
+var pzHttpRequest = function (url, errorHandler, cookieDomain) {
+ this.maxUrlLength = 2048;
+ this.request = null;
+ this.url = url;
+ this.errorHandler = errorHandler || null;
+ this.async = true;
+ this.requestHeaders = {};
+ this.isXDomain = false;
+ this.domainRegex = /https?:\/\/([^:/]+).*/;
+ this.cookieDomain = cookieDomain || null;
+
+ var xhr = new XMLHttpRequest();
+ if ("withCredentials" in xhr) {
+ // XHR for Chrome/Firefox/Opera/Safari.
+ } else if (typeof XDomainRequest != "undefined") {
+ // XDomainRequest for IE.
+ xhr = new XDomainRequest();
+ this.isXDomain = true;
+ } else {
+ // CORS not supported.
+ }
+ this.request = xhr;
+};
+
+
+pzHttpRequest.prototype =
+{
+ safeGet: function ( params, callback )
+ {
+ var encodedParams = this.encodeParams(params);
+ var url = this._urlAppendParams(encodedParams);
+ if (url.length >= this.maxUrlLength) {
+ this.requestHeaders["Content-Type"]
+ = "application/x-www-form-urlencoded";
+ this._send( 'POST', this.url, encodedParams, callback );
+ } else {
+ this._send( 'GET', url, '', callback );
+ }
+ },
+
+ get: function ( params, callback )
+ {
+ this._send( 'GET', this._urlAppendParams(this.encodeParams(params)),
+ '', callback );
+ },
+
+ post: function ( params, data, callback )
+ {
+ this._send( 'POST', this._urlAppendParams(this.encodeParams(params)),
+ data, callback );
+ },
+
+ load: function ()
+ {
+ this.async = false;
+ this.request.open( 'GET', this.url, this.async );
+ this.request.send('');
+ if ( this.request.status == 200 )
+ return this.request.responseXML;
+ },
+
+ encodeParams: function (params)
+ {
+ var sep = "";
+ var encoded = "";
+ for (var key in params) {
+ if (params[key] != null) {
+ encoded += sep + key + '=' + encodeURIComponent(params[key]);
+ sep = '&';
+ }
+ }
+ return encoded;
+ },
+
+ _getDomainFromUrl: function (url)
+ {
+ if (this.cookieDomain) return this.cookieDomain; //explicit cookie domain
+ var m = this.domainRegex.exec(url);
+ return (m && m.length > 1) ? m[1] : null;
+ },
+
+ _strEndsWith: function (str, suffix)
+ {
+ return str.indexOf(suffix, str.length - suffix.length) !== -1;
+ },
+
+ _isCrossDomain: function (domain)
+ {
+ if (this.cookieDomain) return true; //assume xdomain is cookie domain set
+ return !this._strEndsWith(domain, document.domain);
+ },
+
+ getCookie: function (sKey) {
+ return decodeURI(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"
+ + encodeURI(sKey).replace(/[\-\.\+\*]/g, "\\$&")
+ + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
+ },
+
+ setCookie: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
+ if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) {
+ return false;
+ }
+ var sExpires = "";
+ if (vEnd) {
+ switch (vEnd.constructor) {
+ case Number:
+ sExpires = vEnd === Infinity
+ ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT"
+ : "; max-age=" + vEnd;
+ break;
+ case String:
+ sExpires = "; expires=" + vEnd;
+ break;
+ case Date:
+ sExpires = "; expires=" + vEnd.toGMTString();
+ break;
+ }
+ }
+ document.cookie = encodeURI(sKey) + "=" + encodeURI(sValue)
+ + sExpires
+ + (sDomain ? "; domain=" + sDomain : "")
+ + (sPath ? "; path=" + sPath : "")
+ + (bSecure ? "; secure" : "");
+ return true;
+ },
+
+ _send: function ( type, url, data, callback)
+ {
+ var context = this;
+ this.callback = callback;
+ this.async = true;
+ //we never do withCredentials, so if it's CORS and we have
+ //session cookie, resend it
+ var domain = this._getDomainFromUrl(url);
+ if (domain && this._isCrossDomain(domain) &&
+ this.getCookie(domain+":SESSID")) {
+ //rewrite the URL
+ var sessparam = ';jsessionid=' + this.getCookie(domain+":SESSID");
+ var q = url.indexOf('?');
+ if (q == -1) {
+ url += sessparam;
+ } else {
+ url = url.substring(0, q) + sessparam + url.substring(q);
+ }
+ }
+ this.request.open( type, url, this.async );
+ if (!this.isXDomain) {
+ //setting headers is only allowed with XHR
+ for (var key in this.requestHeaders)
+ this.request.setRequestHeader(key, this.requestHeaders[key]);
+ }
+ if (this.isXDomain) {
+ this.request.onload = function () {
+ //fake XHR props
+ context.request.status = 200;
+ context.request.readyState = 4;
+ //handle
+ context._handleResponse(url);
+ }
+ this.request.onerror = function () {
+ //fake XHR props
+ context.request.status = 417; //not really, but what can we do
+ context.request.readyState = 4;
+ //handle
+ context._handleResponse(url);
+ }
+ } else {
+ this.request.onreadystatechange = function () {
+ context._handleResponse(url); /// url used ONLY for error reporting
+ }
+ }
+ this.request.send(data);
+ },
+
+ _urlAppendParams: function (encodedParams)
+ {
+ if (encodedParams)
+ return this.url + "?" + encodedParams;
+ else
+ return this.url;
+ },
+
+ _handleResponse: function (requestUrl)
+ {
+ if ( this.request.readyState == 4 ) {
+ // pick up appplication errors first
+ var errNode = null;
+ // xdomainreq does not have responseXML
+ if (this.isXDomain) {
+ if (this.request.contentType.match(/\/xml/)){
+ var dom = new ActiveXObject('Microsoft.XMLDOM');
+ dom.async = false;
+ dom.loadXML(this.request.responseText);
+ this.request.responseXML = dom;
+ } else {
+ this.request.responseXML = null;
+ }
+ }
+ if (this.request.responseXML &&
+ (errNode = this.request.responseXML.documentElement)
+ && errNode.nodeName == 'error') {
+ var errMsg = errNode.getAttribute("msg");
+ var errCode = errNode.getAttribute("code");
+ var errAddInfo = '';
+ if (errNode.childNodes.length)
+ errAddInfo = ': ' + errNode.childNodes[0].nodeValue;
+
+ var err = new Error(errMsg + errAddInfo);
+ err.code = errCode;
+
+ if (this.errorHandler) {
+ this.errorHandler(err);
+ }
+ else {
+ throw err;
+ }
+ }
+ else if (this.request.status == 200 &&
+ this.request.responseXML === null) {
+ if (this.request.responseText !== null) {
+ //assume JSON
+ var json = null;
+ var text = this.request.responseText;
+ if (typeof window.JSON == "undefined") {
+ json = eval("(" + text + ")");
+ } else {
+ try {
+ json = JSON.parse(text);
+ } catch (e) {
+ }
+ }
+ this.callback(json, "json");
+ } else {
+ var err = new Error("XML/Text response is empty but no error " +
+ "for " + requestUrl);
+ err.code = -1;
+ if (this.errorHandler) {
+ this.errorHandler(err);
+ } else {
+ throw err;
+ }
+ }
+ } else if (this.request.status == 200) {
+ //set cookie manually only if cross-domain
+ var domain = this._getDomainFromUrl(requestUrl);
+ if (domain && this._isCrossDomain(domain)) {
+ var jsessionId = this.request.responseXML
+ .documentElement.getAttribute('jsessionId');
+ if (jsessionId)
+ this.setCookie(domain+":SESSID", jsessionId);
+ }
+ this.callback(this.request.responseXML);
+ } else {
+ var err = new Error("HTTP response not OK: "
+ + this.request.status + " - "
+ + this.request.statusText );
+ err.code = '00' + this.request.status;
+ if (this.errorHandler) {
+ this.errorHandler(err);
+ }
+ else {
+ throw err;
+ }
+ }
+ }
+ }
+};
+
+/*
+********************************************************************************
+** XML HELPER FUNCTIONS ********************************************************
+********************************************************************************
+*/
+
+// DOMDocument
+
+if ( window.ActiveXObject) {
+ var DOMDoc = document;
+} else {
+ var DOMDoc = Document.prototype;
+}
+
+DOMDoc.newXmlDoc = function ( root )
+{
+ var doc;
+
+ if (document.implementation && document.implementation.createDocument) {
+ doc = document.implementation.createDocument('', root, null);
+ } else if ( window.ActiveXObject ) {
+ doc = new ActiveXObject("MSXML2.DOMDocument");
+ doc.loadXML('<' + root + '/>');
+ } else {
+ throw new Error ('No XML support in this browser');
+ }
+
+ return doc;
+}
+
+
+DOMDoc.parseXmlFromString = function ( xmlString )
+{
+ var doc;
+
+ if ( window.DOMParser ) {
+ var parser = new DOMParser();
+ doc = parser.parseFromString( xmlString, "text/xml");
+ } else if ( window.ActiveXObject ) {
+ doc = new ActiveXObject("MSXML2.DOMDocument");
+ doc.loadXML( xmlString );
+ } else {
+ throw new Error ("No XML parsing support in this browser.");
+ }
+
+ return doc;
+}
+
+DOMDoc.transformToDoc = function (xmlDoc, xslDoc)
+{
+ if ( window.XSLTProcessor ) {
+ var proc = new XSLTProcessor();
+ proc.importStylesheet( xslDoc );
+ return proc.transformToDocument(xmlDoc);
+ } else if ( window.ActiveXObject ) {
+ return document.parseXmlFromString(xmlDoc.transformNode(xslDoc));
+ } else {
+ alert( 'Unable to perform XSLT transformation in this browser' );
+ }
+}
+
+// DOMElement
+
+Element_removeFromDoc = function (DOM_Element)
+{
+ DOM_Element.parentNode.removeChild(DOM_Element);
+}
+
+Element_emptyChildren = function (DOM_Element)
+{
+ while( DOM_Element.firstChild ) {
+ DOM_Element.removeChild( DOM_Element.firstChild )
+ }
+}
+
+Element_appendTransformResult = function ( DOM_Element, xmlDoc, xslDoc )
+{
+ if ( window.XSLTProcessor ) {
+ var proc = new XSLTProcessor();
+ proc.importStylesheet( xslDoc );
+ var docFrag = false;
+ docFrag = proc.transformToFragment( xmlDoc, DOM_Element.ownerDocument );
+ DOM_Element.appendChild(docFrag);
+ } else if ( window.ActiveXObject ) {
+ DOM_Element.innerHTML = xmlDoc.transformNode( xslDoc );
+ } else {
+ alert( 'Unable to perform XSLT transformation in this browser' );
+ }
+}
+
+Element_appendTextNode = function (DOM_Element, tagName, textContent )
+{
+ var node = DOM_Element.ownerDocument.createElement(tagName);
+ var text = DOM_Element.ownerDocument.createTextNode(textContent);
+
+ DOM_Element.appendChild(node);
+ node.appendChild(text);
+
+ return node;
+}
+
+Element_setTextContent = function ( DOM_Element, textContent )
+{
+ if (typeof DOM_Element.textContent !== "undefined") {
+ DOM_Element.textContent = textContent;
+ } else if (typeof DOM_Element.innerText !== "undefined" ) {
+ DOM_Element.innerText = textContent;
+ } else {
+ throw new Error("Cannot set text content of the node, no such method.");
+ }
+}
+
+Element_getTextContent = function (DOM_Element)
+{
+ if ( typeof DOM_Element.textContent != 'undefined' ) {
+ return DOM_Element.textContent;
+ } else if (typeof DOM_Element.text != 'undefined') {
+ return DOM_Element.text;
+ } else {
+ throw new Error("Cannot get text content of the node, no such method.");
+ }
+}
+
+Element_parseChildNodes = function (node)
+{
+ var parsed = {};
+ var hasChildElems = false;
+ var textContent = '';
+
+ if (node.hasChildNodes()) {
+ var children = node.childNodes;
+ for (var i = 0; i < children.length; i++) {
+ var child = children[i];
+ switch (child.nodeType) {
+ case Node.ELEMENT_NODE:
+ hasChildElems = true;
+ var nodeName = child.nodeName;
+ if (!(nodeName in parsed))
+ parsed[nodeName] = [];
+ parsed[nodeName].push(Element_parseChildNodes(child));
+ break;
+ case Node.TEXT_NODE:
+ textContent += child.nodeValue;
+ break;
+ case Node.CDATA_SECTION_NODE:
+ textContent += child.nodeValue;
+ break;
+ }
+ }
+ }
+
+ var attrs = node.attributes;
+ for (var i = 0; i < attrs.length; i++) {
+ hasChildElems = true;
+ var attrName = '@' + attrs[i].nodeName;
+ var attrValue = attrs[i].nodeValue;
+ parsed[attrName] = attrValue;
+ }
+
+ // if no nested elements/attrs set value to text
+ if (hasChildElems)
+ parsed['#text'] = textContent;
+ else
+ parsed = textContent;
+
+ return parsed;
+}
+
+/* do not remove trailing bracket */
+}
+/*! MKWS, the MasterKey Widget Set. Copyright (C) 2013, Index Data */
+
+"use strict"; // HTML5: disable for debug_level >= 2
+
+// Set up namespace and some state.
+var mkws = {
+ sort: 'relevance',
+ authenticated: false,
+ filters: []
+};
+
+/*
+ * global config object: mkws_config
+ *
+ * Needs to be defined in the HTML header before including this JS file.
+ * Define empty mkws_config for simple applications that don't define it.
+ */
+if (!mkws_config)
+ var mkws_config = {};
+
+// Wrapper for jQuery
+(function ($) {
+
+mkws.locale_lang = {
+ "de": {
+ "Authors": "Autoren",
+ "Subjects": "Schlagwörter",
+ "Sources": "Daten und Quellen",
+ "Termlists": "Termlisten",
+ "Next": "Weiter",
+ "Prev": "Zurück",
+ "Search": "Suche",
+ "Sort by": "Sortieren nach",
+ "and show": "und zeige",
+ "per page": "pro Seite",
+ "Displaying": "Zeige",
+ "to": "von",
+ "of": "aus",
+ "found": "gefunden",
+ "Title": "Titel",
+ "Author": "Autor",
+ "Date": "Datum",
+ "Subject": "Schlagwort",
+ "Location": "Ort",
+ // ### to add: Records, Targets
+
+ "dummy": "dummy"
+ },
+
+ "da": {
+ "Authors": "Forfattere",
+ "Subjects": "Emner",
+ "Sources": "Kilder",
+ "Termlists": "Termlists",
+ "Next": "Næste",
+ "Prev": "Forrige",
+ "Search": "Søg",
+ "Sort by": "Sorter efter",
+ "and show": "og vis",
+ "per page": "per side",
+ "Displaying": "Viser",
+ "to": "til",
+ "of": "ud af",
+ "found": "fandt",
+ "Title": "Title",
+ "Author": "Forfatter",
+ "Date": "Dato",
+ "Subject": "Emneord",
+ "Location": "Lokation",
+ // ### to add: Records, Targets
+
+ "dummy": "dummy"
+ }
+};
+
+// keep time state for debugging
+mkws.debug_time = {
+ "start": $.now(),
+ "last": $.now()
+};
+
+mkws.debug_function = function (string) {
+ if (!mkws.debug_level)
+ return;
+
+ if (typeof console === "undefined" || typeof console.log === "undefined") { /* ARGH!!! old IE */
+ return;
+ }
+
+ var now = $.now();
+ var timestamp = ((now - mkws.debug_time.start)/1000).toFixed(3) + " (+" + ((now - mkws.debug_time.last)/1000).toFixed(3) + ") "
+ mkws.debug_time.last = now;
+
+ // you need to disable use strict at the top of the file!!!
+ if (mkws.debug_level >= 3) {
+ console.log(timestamp + arguments.callee.caller);
+ } else if (mkws.debug_level >= 2) {
+ console.log(timestamp + ">>> called from function " + arguments.callee.caller.name + ' <<<');
+ }
+ console.log(timestamp + string);
+}
+var debug = mkws.debug_function; // local alias
+
+
+Handlebars.registerHelper('json', function(obj) {
+ return $.toJSON(obj);
+});
+
+
+// We need {{attr '@name'}} because Handlebars can't parse {{@name}}
+Handlebars.registerHelper('attr', function(attrName) {
+ return this[attrName];
+});
+
+
+/*
+ * Use as follows: {{#if-any NAME1 having="NAME2"}}
+ * Applicable when NAME1 is the name of an array
+ * The guarded code runs only if at least one element of the NAME1
+ * array has a subelement called NAME2.
+ */
+Handlebars.registerHelper('if-any', function(items, options) {
+ var having = options.hash.having;
+ for (var i in items) {
+ var item = items[i]
+ if (!having || item[having]) {
+ return options.fn(this);
+ }
+ }
+ return "";
+});
+
+
+Handlebars.registerHelper('first', function(items, options) {
+ var having = options.hash.having;
+ for (var i in items) {
+ var item = items[i]
+ if (!having || item[having]) {
+ return options.fn(item);
+ }
+ }
+ return "";
+});
+
+
+Handlebars.registerHelper('commaList', function(items, options) {
+ var out = "";
+
+ for (var i in items) {
+ if (i > 0) out += ", ";
+ out += options.fn(items[i])
+ }
+
+ return out;
+});
+
+
+{
+ /* default mkws config */
+ var config_default = {
+ use_service_proxy: true,
+ pazpar2_url: "http://mkws.indexdata.com/service-proxy/",
+ service_proxy_auth: "http://mkws.indexdata.com/service-proxy-auth",
+ lang: "",
+ sort_options: [["relevance"], ["title:1", "title"], ["date:0", "newest"], ["date:1", "oldest"]],
+ perpage_options: [10, 20, 30, 50],
+ sort_default: "relevance",
+ perpage_default: 20,
+ query_width: 50,
+ show_lang: true, /* show/hide language menu */
+ show_sort: true, /* show/hide sort menu */
+ show_perpage: true, /* show/hide perpage menu */
+ lang_options: [], /* display languages links for given languages, [] for all */
+ facets: ["sources", "subjects", "authors"], /* display facets, in this order, [] for none */
+ responsive_design_width: undefined, /* a page with less pixel width considered as narrow */
+ debug_level: 1, /* debug level for development: 0..2 */
+
+ dummy: "dummy"
+ };
+
+ /* set global debug_level flag early */
+ if (typeof mkws_config.debug_level !== 'undefined') {
+ mkws.debug_level = mkws_config.debug_level;
+ } else if (typeof config_default.debug_level !== 'undefined') {
+ mkws.debug_level = config_default.debug_level;
+ }
+
+ /* override standard config values by function parameters */
+ for (var k in config_default) {
+ if (typeof mkws_config[k] === 'undefined')
+ mkws_config[k] = config_default[k];
+ debug("Set config: " + k + ' => ' + mkws_config[k]);
+ }
+}
+
+mkws.sort = mkws_config.sort_default;
+debug("copied mkws_config.sort_default '" + mkws_config.sort_default + "' to mkws.sort");
+
+mkws.usesessions = mkws_config.use_service_proxy ? false : true;
+
+if (mkws_config.query_width < 5 || mkws_config.query_width > 150) {
+ debug("Reset query width: " + mkws_config.query_width);
+ mkws_config.query_width = 50;
+}
+
+for (var key in mkws_config) {
+ if (mkws_config.hasOwnProperty(key)) {
+ if (key.match(/^language_/)) {
+ var lang = key.replace(/^language_/, "");
+ // Copy custom languages into list
+ mkws.locale_lang[lang] = mkws_config[key];
+ debug("Added locally configured language '" + lang + "'");
+ }
+ }
+}
+
+
+// create a parameters array and pass it to the pz2's constructor
+// then register the form submit event with the pz2.search function
+// autoInit is set to true on default
+var my_paz = new pz2( { "onshow": my_onshow,
+ "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way
+ "pazpar2path": mkws_config.pazpar2_url,
+ "oninit": my_oninit,
+ "onstat": my_onstat,
+ "onterm": my_onterm,
+ "termlist": "xtargets,subject,author",
+ "onbytarget": my_onbytarget,
+ "usesessions" : mkws.usesessions,
+ "showResponseType": '', // or "json" (for debugging?)
+ "onrecord": my_onrecord } );
+
+mkws.my_paz = my_paz; // export
+
+// some state vars
+var curPage = 1;
+var recPerPage = 20;
+var totalRec = 0;
+var curDetRecId = '';
+var curDetRecData = null;
+var submitted = false;
+var SourceMax = 16;
+var SubjectMax = 10;
+var AuthorMax = 10;
+
+//
+// pz2.js event handlers:
+//
+function my_oninit() {
+ my_paz.stat();
+ my_paz.bytarget();
+}
+
+function my_onshow(data) {
+ totalRec = data.merged;
+ // move it out
+ var pager = document.getElementById("mkwsPager");
+ if (pager) {
+ pager.innerHTML = "";
+ pager.innerHTML +='' + M('Displaying') + ': '
+ + (data.start + 1) + ' ' + M('to') + ' ' + (data.start + data.num) +
+ ' ' + M('of') + ' ' + data.merged + ' (' + M('found') + ': '
+ + data.total + ')
';
+ drawPager(pager);
+ }
+
+ // navi
+ var results = document.getElementById("mkwsRecords");
+
+ var html = [];
+ for (var i = 0; i < data.hits.length; i++) {
+ var hit = data.hits[i];
+ html.push('',
+ renderSummary(hit),
+ '
');
+ if (hit.recid == curDetRecId) {
+ html.push(renderDetails(curDetRecData));
+ }
+ }
+ replaceHtml(results, html.join(''));
+}
+
+
+function renderSummary(hit)
+{
+ if (mkws.templateSummary === undefined) {
+ loadTemplate("Summary");
+ }
+
+ hit._id = "mkwsRec_" + hit.recid;
+ hit._onclick = "mkws.showDetails(this.id);return false;"
+ return mkws.templateSummary(hit);
+}
+
+
+function my_onstat(data) {
+ var stat = document.getElementById("mkwsStat");
+ if (stat == null)
+ return;
+
+ stat.innerHTML = '' + M('Status info') + ' ' +
+ ' -- ' +
+ '' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + ' ' +
+ ' -- ' +
+ '' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + ' ';
+}
+
+function my_onterm(data) {
+ // no facets
+ if (!mkws_config.facets || mkws_config.facets.length == 0) {
+ $("#mkwsTermlists").hide();
+ return;
+ }
+
+ // display if we first got results
+ $("#mkwsTermlists").show();
+
+ var acc = [];
+ acc.push('' + M('Termlists') + '
');
+ var facets = mkws_config.facets;
+
+ for(var i = 0; i < facets.length; i++) {
+ if (facets[i] == "sources") {
+ add_single_facet(acc, "Sources", data.xtargets, SourceMax, null);
+ } else if (facets[i] == "subjects") {
+ add_single_facet(acc, "Subjects", data.subject, SubjectMax, "subject");
+ } else if (facets[i] == "authors") {
+ add_single_facet(acc, "Authors", data.author, AuthorMax, "author");
+ } else {
+ alert("bad facet configuration: '" + facets[i] + "'");
+ }
+ }
+
+ var termlist = document.getElementById("mkwsTermlists");
+ if (termlist)
+ replaceHtml(termlist, acc.join(''));
+}
+
+function add_single_facet(acc, caption, data, max, pzIndex) {
+ acc.push('');
+ acc.push('
' + M(caption) + '
');
+ for (var i = 0; i < data.length && i < max; i++ ) {
+ acc.push('
');
+ }
+ acc.push('
');
+}
+
+function my_onrecord(data) {
+ // FIXME: record is async!!
+ clearTimeout(my_paz.recordTimer);
+ // in case on_show was faster to redraw element
+ var detRecordDiv = document.getElementById('mkwsDet_'+data.recid);
+ if (detRecordDiv) return;
+ curDetRecData = data;
+ var recordDiv = document.getElementById('mkwsRecdiv_'+curDetRecData.recid);
+ var html = renderDetails(curDetRecData);
+ recordDiv.innerHTML += html;
+}
+
+function my_onbytarget(data) {
+ var targetDiv = document.getElementById("mkwsBytarget");
+ if (!targetDiv) {
+ // No mkwsTargets div.
+ return;
+ }
+
+ var table ='' +
+ '' + M('Target ID') + ' ' +
+ '' + M('Hits') + ' ' +
+ '' + M('Diags') + ' ' +
+ '' + M('Records') + ' ' +
+ '' + M('State') + ' ' +
+ ' ';
+
+ for (var i = 0; i < data.length; i++ ) {
+ table += "" + data[i].id +
+ " " + data[i].hits +
+ " " + data[i].diagnostic +
+ " " + data[i].records +
+ " " + data[i].state + " ";
+ }
+
+ table += '
';
+ targetDiv.innerHTML = table;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+// wait until the DOM is ready
+function domReady ()
+{
+ document.mkwsSearchForm.onsubmit = onFormSubmitEventHandler;
+ document.mkwsSearchForm.mkwsQuery.value = '';
+ if (document.mkwsSelect) {
+ if (document.mkwsSelect.mkwsSort)
+ document.mkwsSelect.mkwsSort.onchange = onSelectDdChange;
+ if (document.mkwsSelect.mkwsPerpage)
+ document.mkwsSelect.mkwsPerpage.onchange = onSelectDdChange;
+ }
+}
+
+// when search button pressed
+function onFormSubmitEventHandler()
+{
+ newSearch(document.mkwsSearchForm.mkwsQuery.value);
+ return false;
+}
+
+function newSearch(query, sort, targets)
+{
+ debug("newSearch: " + query);
+
+ if (mkws_config.use_service_proxy && !mkws.authenticated) {
+ alert("searching before authentication");
+ return;
+ }
+
+ mkws.filters = []
+ redraw_navi();
+ resetPage();
+ loadSelect();
+ triggerSearch(query, sort, targets);
+ mkws.switchView('records'); // In case it's configured to start off as hidden
+ submitted = true;
+}
+
+function onSelectDdChange()
+{
+ if (!submitted) return false;
+ resetPage();
+ loadSelect();
+ my_paz.show(0, recPerPage, mkws.sort);
+ return false;
+}
+
+function resetPage()
+{
+ curPage = 1;
+ totalRec = 0;
+}
+
+function triggerSearch (query, sort, targets)
+{
+ var pp2filter = "";
+ var pp2limit = "";
+
+ // Re-use previous query/sort if new ones are not specified
+ if (query) {
+ mkws.query = query;
+ }
+ if (sort) {
+ mkws.sort = sort;
+ }
+ if (targets) {
+ // ### should support multiple |-separated targets
+ mkws.filters.push({ id: targets, name: targets });
+ }
+
+ for (var i in mkws.filters) {
+ var filter = mkws.filters[i];
+ if (filter.id) {
+ if (pp2filter)
+ pp2filter += ",";
+ if (filter.id.match(/^[a-z:]+[=~]/)) {
+ debug("filter '" + filter.id + "' already begins with SETTING OP");
+ } else {
+ filter.id = 'pz:id=' + filter.id;
+ }
+ pp2filter += filter.id;
+ } else {
+ if (pp2limit)
+ pp2limit += ",";
+ pp2limit += filter.field + "=" + filter.value.replace(/[\\|,]/g, '\\$&');
+ }
+ }
+
+ debug("triggerSearch(" + mkws.query + "): filters = " + $.toJSON(mkws.filters) + ", pp2filter = " + pp2filter + ", pp2limit = " + pp2limit);
+ my_paz.search(mkws.query, recPerPage, mkws.sort, pp2filter, undefined, { limit: pp2limit });
+}
+
+function loadSelect ()
+{
+ if (document.mkwsSelect) {
+ if (document.mkwsSelect.mkwsSort)
+ mkws.sort = document.mkwsSelect.mkwsSort.value;
+ if (document.mkwsSelect.mkwsPerpage)
+ recPerPage = document.mkwsSelect.mkwsPerpage.value;
+ }
+}
+
+// limit the query after clicking the facet
+mkws.limitQuery = function (field, value)
+{
+ debug("limitQuery(field=" + field + ", value=" + value + ")");
+ mkws.filters.push({ field: field, value: value });
+ redraw_navi();
+ resetPage();
+ loadSelect();
+ triggerSearch();
+ return false;
+}
+
+// limit by target functions
+mkws.limitTarget = function (id, name)
+{
+ debug("limitTarget(id=" + id + ", name=" + name + ")");
+ mkws.filters.push({ id: id, name: name });
+ redraw_navi();
+ resetPage();
+ loadSelect();
+ triggerSearch();
+ return false;
+}
+
+mkws.delimitQuery = function (field, value)
+{
+ debug("delimitQuery(field=" + field + ", value=" + value + ")");
+ var newFilters = [];
+ for (var i in mkws.filters) {
+ var filter = mkws.filters[i];
+ if (filter.field &&
+ field == filter.field &&
+ value == filter.value) {
+ debug("delimitTarget() removing filter " + $.toJSON(filter));
+ } else {
+ debug("delimitTarget() keeping filter " + $.toJSON(filter));
+ newFilters.push(filter);
+ }
+ }
+ mkws.filters = newFilters;
+
+ redraw_navi();
+ resetPage();
+ loadSelect();
+ triggerSearch();
+ return false;
+}
+
+
+mkws.delimitTarget = function (id)
+{
+ debug("delimitTarget(id=" + id + ")");
+ var newFilters = [];
+ for (var i in mkws.filters) {
+ var filter = mkws.filters[i];
+ if (filter.id) {
+ debug("delimitTarget() removing filter " + $.toJSON(filter));
+ } else {
+ debug("delimitTarget() keeping filter " + $.toJSON(filter));
+ newFilters.push(filter);
+ }
+ }
+ mkws.filters = newFilters;
+
+ redraw_navi();
+ resetPage();
+ loadSelect();
+ triggerSearch();
+ return false;
+}
+
+
+function redraw_navi ()
+{
+ var navi = document.getElementById('mkwsNavi');
+ if (!navi) return;
+
+ var text = "";
+ for (var i in mkws.filters) {
+ if (text) {
+ text += " | ";
+ }
+ var filter = mkws.filters[i];
+ if (filter.id) {
+ text += 'Source: ' + filter.name + ' ';
+ } else {
+ text += filter.field + ': ' + filter.value + ' ';
+ }
+ }
+
+ navi.innerHTML = text;
+}
+
+
+function drawPager (pagerDiv)
+{
+ //client indexes pages from 1 but pz2 from 0
+ var onsides = 6;
+ var pages = Math.ceil(totalRec / recPerPage);
+
+ var firstClkbl = ( curPage - onsides > 0 )
+ ? curPage - onsides
+ : 1;
+
+ var lastClkbl = firstClkbl + 2*onsides < pages
+ ? firstClkbl + 2*onsides
+ : pages;
+
+ var prev = '<< ' + M('Prev') + ' | ';
+ if (curPage > 1)
+ prev = ''
+ +'<< ' + M('Prev') + ' | ';
+
+ var middle = '';
+ for(var i = firstClkbl; i <= lastClkbl; i++) {
+ var numLabel = i;
+ if(i == curPage)
+ numLabel = '' + i + ' ';
+
+ middle += ' '
+ + numLabel + ' ';
+ }
+
+ var next = ' | ' + M('Next') + ' >> ';
+ if (pages - curPage > 0)
+ next = ' | '
+ + M('Next') + ' >> ';
+
+ var predots = '';
+ if (firstClkbl > 1)
+ predots = '...';
+
+ var postdots = '';
+ if (lastClkbl < pages)
+ postdots = '...';
+
+ pagerDiv.innerHTML += ''
+ + prev + predots + middle + postdots + next + '
';
+}
+
+mkws.showPage = function (pageNum)
+{
+ curPage = pageNum;
+ my_paz.showPage( curPage - 1 );
+}
+
+// simple paging functions
+
+mkws.pagerNext = function () {
+ if ( totalRec - recPerPage*curPage > 0) {
+ my_paz.showNext();
+ curPage++;
+ }
+}
+
+mkws.pagerPrev = function () {
+ if ( my_paz.showPrev() != false )
+ curPage--;
+}
+
+// switching view between targets and records
+
+mkws.switchView = function(view) {
+ debug("switchView: " + view);
+
+ var targets = document.getElementById('mkwsTargets');
+ var results = document.getElementById('mkwsResults') ||
+ document.getElementById('mkwsRecords');
+ var blanket = document.getElementById('mkwsBlanket');
+ var motd = document.getElementById('mkwsMOTD');
+
+ switch(view) {
+ case 'targets':
+ if (targets) targets.style.display = "block";
+ if (results) results.style.display = "none";
+ if (blanket) blanket.style.display = "none";
+ if (motd) motd.style.display = "none";
+ break;
+ case 'records':
+ if (targets) targets.style.display = "none";
+ if (results) results.style.display = "block";
+ if (blanket) blanket.style.display = "block";
+ if (motd) motd.style.display = "none";
+ break;
+ case 'none':
+ if (targets) targets.style.display = "none";
+ if (results) results.style.display = "none";
+ if (blanket) blanket.style.display = "none";
+ if (motd) motd.style.display = "none";
+ break;
+ default:
+ alert("Unknown view '" + view + "'");
+ }
+}
+
+// detailed record drawing
+mkws.showDetails = function (prefixRecId) {
+ var recId = prefixRecId.replace('mkwsRec_', '');
+ var oldRecId = curDetRecId;
+ curDetRecId = recId;
+
+ // remove current detailed view if any
+ var detRecordDiv = document.getElementById('mkwsDet_'+oldRecId);
+ // lovin DOM!
+ if (detRecordDiv)
+ detRecordDiv.parentNode.removeChild(detRecordDiv);
+
+ // if the same clicked, just hide
+ if (recId == oldRecId) {
+ curDetRecId = '';
+ curDetRecData = null;
+ return;
+ }
+ // request the record
+ my_paz.record(recId);
+}
+
+function replaceHtml(el, html) {
+ var oldEl = typeof el === "string" ? document.getElementById(el) : el;
+ /*@cc_on // Pure innerHTML is slightly faster in IE
+ oldEl.innerHTML = html;
+ return oldEl;
+ @*/
+ var newEl = oldEl.cloneNode(false);
+ newEl.innerHTML = html;
+ oldEl.parentNode.replaceChild(newEl, oldEl);
+ /* Since we just removed the old element from the DOM, return a reference
+ to the new element, which can be used to restore variable references. */
+ return newEl;
+};
+
+function renderDetails(data, marker)
+{
+ if (mkws.templateRecord === undefined) {
+ loadTemplate("Record");
+ }
+
+ var template = mkws.templateRecord;
+ var details = template(data);
+ return '' + details + '
';
+}
+
+
+function loadTemplate(name)
+{
+ var source = $("#mkwsTemplate" + name).html();
+ if (!source) {
+ source = defaultTemplate(name);
+ }
+
+ var template = Handlebars.compile(source);
+ debug("compiled template '" + name + "'");
+ mkws['template' + name] = template;
+}
+
+
+function defaultTemplate(name)
+{
+ if (name === 'Record') {
+ return '\
+ \
+ \
+ Title \
+ \
+ {{md-title}}\
+ {{#if md-title-remainder}}\
+ ({{md-title-remainder}})\
+ {{/if}}\
+ {{#if md-title-responsibility}}\
+ {{md-title-responsibility}} \
+ {{/if}}\
+ \
+ \
+ {{#if md-date}}\
+ \
+ Date \
+ {{md-date}} \
+ \
+ {{/if}}\
+ {{#if md-author}}\
+ \
+ Author \
+ {{md-author}} \
+ \
+ {{/if}}\
+ {{#if md-electronic-url}}\
+ \
+ URL \
+ \
+ {{#each md-electronic-url}}\
+ {{this}} \
+ {{/each}}\
+ \
+ \
+ {{/if}}\
+ {{#if-any location having="md-subject"}}\
+ \
+ Subject \
+ \
+ {{#first location having="md-subject"}}\
+ {{#if md-subject}}\
+ {{md-subject}}\
+ {{/if}}\
+ {{/first}}\
+ \
+ \
+ {{/if-any}}\
+ \
+ Locations \
+ \
+ {{#commaList location}}\
+ {{attr "@name"}}{{/commaList}}\
+ \
+ \
+
\
+';
+ } else if (name === "Summary") {
+ return '\
+ \
+ {{md-title}} \
+ \
+ {{#if md-title-remainder}}\
+ {{md-title-remainder}} \
+ {{/if}}\
+ {{#if md-title-responsibility}}\
+ {{md-title-responsibility}} \
+ {{/if}}\
+';
+ }
+
+ var s = "There is no default '" + name +"' template!";
+ alert(s);
+ return s;
+}
+
+
+/*
+ * All the HTML stuff to render the search forms and
+ * result pages.
+ */
+function mkws_html_all() {
+ mkws_set_lang();
+ if (mkws_config.show_lang)
+ mkws_html_lang();
+
+ // For some reason, doing this programmatically results in
+ // document.mkwsSearchForm.mkwsQuery being undefined, hence the raw HTML.
+ debug("HTML search form");
+ $("#mkwsSearch").html('\
+ ');
+
+ debug("HTML records");
+ // If the application has an #mkwsResults, populate it in the
+ // usual way. If not, assume that it's a smarter application that
+ // defines its own subcomponents:
+ // #mkwsTermlists
+ // #mkwsRanking
+ // #mkwsPager
+ // #mkwsNavi
+ // #mkwsRecords
+ if ($("#mkwsResults").length) {
+ $("#mkwsResults").html('\
+ \
+ \
+ \
+
\
+ \
+ \
+
\
+ \
+
\
+
\
+ \
+ \
+ \
+ \
+
\
+ \
+ \
+
');
+ }
+
+ if ($("#mkwsRanking").length) {
+ var ranking_data = '';
+ ranking_data += '';
+
+ $("#mkwsRanking").html(ranking_data);
+ }
+
+ mkws_html_switch();
+
+ if (mkws_config.use_service_proxy) {
+ mkws_service_proxy_auth(mkws_config.service_proxy_auth,
+ mkws_config.service_proxy_auth_domain,
+ mkws_config.pazpar2_url);
+ } else {
+ // raw pp2
+ run_auto_searches();
+ }
+
+ if (mkws_config.responsive_design_width) {
+ // Responsive web design - change layout on the fly based on
+ // current screen width. Required for mobile devices.
+ $(window).resize( function(e) { mkws_resize_page() });
+ // initial check after page load
+ $(document).ready(function() { mkws_resize_page() });
+ }
+
+ domReady();
+
+ // on first page, hide the termlist
+ $(document).ready(function() { $("#mkwsTermlists").hide(); } );
+ var motd = document.getElementById("mkwsMOTD");
+ var container = document.getElementById("mkwsMOTDContainer");
+ if (motd && container) {
+ // Move the MOTD from the provided element down into the container
+ motd.parentNode.removeChild(motd);
+ container.appendChild(motd);
+ }
+}
+
+
+function run_auto_searches() {
+ debug("run auto searches");
+
+ var node = $('#mkwsRecords');
+ if (node.attr('autosearch')) {
+ var query = node.attr('autosearch');
+ var sort = node.attr('sort');
+ var targets = node.attr('targets');
+ var s = "running auto search: '" + query + "'";
+ if (sort) s += " sorted by '" + sort + "'";
+ if (targets) s += " in targets '" + targets + "'";
+ debug(s);
+ newSearch(query, sort, targets);
+ }
+}
+
+
+function mkws_set_lang() {
+ var lang = $.parseQuerystring().lang || mkws_config.lang;
+ if (!lang || !mkws.locale_lang[lang]) {
+ mkws_config.lang = ""
+ } else {
+ mkws_config.lang = lang;
+ }
+
+ debug("Locale language: " + (mkws_config.lang ? mkws_config.lang : "none"));
+ return mkws_config.lang;
+}
+
+function mkws_html_switch() {
+ debug("HTML switch");
+
+ $("#mkwsSwitch").append($('' + M('Records') + ' '));
+ $("#mkwsSwitch").append($(" ", { text: " | " }));
+ $("#mkwsSwitch").append($('' + M('Targets') + ' '));
+
+ debug("HTML targets");
+ $("#mkwsTargets").html('\
+ \
+ No information available yet.\
+
');
+ $("#mkwsTargets").css("display", "none");
+}
+
+function mkws_html_sort() {
+ debug("HTML sort, mkws.sort = '" + mkws.sort + "'");
+ var sort_html = '';
+
+ for(var i = 0; i < mkws_config.sort_options.length; i++) {
+ var opt = mkws_config.sort_options[i];
+ var key = opt[0];
+ var val = opt.length == 1 ? opt[0] : opt[1];
+
+ sort_html += '' + M(val) + ' ';
+ }
+ sort_html += ' ';
+
+ return sort_html;
+}
+
+function mkws_html_perpage() {
+ debug("HTML perpage");
+ var perpage_html = '';
+
+ for(var i = 0; i < mkws_config.perpage_options.length; i++) {
+ var key = mkws_config.perpage_options[i];
+
+ perpage_html += '' + key + ' ';
+ }
+ perpage_html += ' ';
+
+ return perpage_html;
+}
+
+/*
+ * Run service-proxy authentication in background (after page load).
+ * The username/password is configured in the apache config file
+ * for the site.
+ */
+function mkws_service_proxy_auth(auth_url, auth_domain, pp2_url) {
+ debug("Run service proxy auth URL: " + auth_url);
+
+ if (!auth_domain) {
+ auth_domain = pp2_url.replace(/^http:\/\/(.*?)\/.*/, '$1');
+ debug("guessed auth_domain '" + auth_domain + "' from pp2_url '" + pp2_url + "'");
+ }
+
+ var request = new pzHttpRequest(auth_url, function(err) {
+ alert("HTTP call for authentication failed: " + err)
+ return;
+ }, auth_domain);
+
+ request.get(null, function(data) {
+ if (!$.isXMLDoc(data)) {
+ alert("service proxy auth response document is not valid XML document, give up!");
+ return;
+ }
+ var status = $(data).find("status");
+ if (status.text() != "OK") {
+ alert("service proxy auth repsonse status: " + status.text() + ", give up!");
+ return;
+ }
+
+ debug("Service proxy auth successfully done");
+ mkws.authenticated = true;
+ run_auto_searches();
+ });
+}
+
+/* create locale language menu */
+function mkws_html_lang() {
+ var lang_default = "en";
+ var lang = mkws_config.lang || lang_default;
+ var list = [];
+
+ /* display a list of configured languages, or all */
+ var lang_options = mkws_config.lang_options || [];
+ var hash = {};
+ for (var i = 0; i < lang_options.length; i++) {
+ hash[lang_options[i]] = 1;
+ }
+
+ for (var k in mkws.locale_lang) {
+ if (hash[k] == 1 || lang_options.length == 0)
+ list.push(k);
+ }
+
+ // add english link
+ if (lang_options.length == 0 || hash[lang_default] == 1)
+ list.push(lang_default);
+
+ debug("Language menu for: " + list.join(", "));
+
+ /* the HTML part */
+ var data = "";
+ for(var i = 0; i < list.length; i++) {
+ var l = list[i];
+
+ if (data)
+ data += ' | ';
+
+ if (lang == l) {
+ data += ' ' + l + ' ';
+ } else {
+ data += ' ' + l + ' '
+ }
+ }
+
+ $("#mkwsLang").html(data);
+}
+
+function mkws_resize_page () {
+ var list = ["mkwsSwitch"];
+
+ var width = mkws_config.responsive_design_width;
+ var parentId = $("#mkwsTermlists").parent().attr('id');
+
+ if ($(window).width() <= width &&
+ parentId === "mkwsTermlistContainer1") {
+ debug("changing from wide to narrow: " + $(window).width());
+ $("#mkwsTermlists").appendTo($("#mkwsTermlistContainer2"));
+ $("#mkwsTermlistContainer1").hide();
+ $("#mkwsTermlistContainer2").show();
+ for(var i = 0; i < list.length; i++) {
+ $("#" + list[i]).hide();
+ }
+ } else if ($(window).width() > width &&
+ parentId === "mkwsTermlistContainer2") {
+ debug("changing from narrow to wide: " + $(window).width());
+ $("#mkwsTermlists").appendTo($("#mkwsTermlistContainer1"));
+ $("#mkwsTermlistContainer1").show();
+ $("#mkwsTermlistContainer2").hide();
+ for(var i = 0; i < list.length; i++) {
+ $("#" + list[i]).show();
+ }
+ }
+};
+
+/* locale */
+function M(word) {
+ var lang = mkws_config.lang;
+
+ if (!lang || !mkws.locale_lang[lang])
+ return word;
+
+ return mkws.locale_lang[lang][word] || word;
+}
+
+/*
+ * implement jQuery plugins
+ */
+$.extend({
+ // implement $.parseQuerystring() for parsing URL parameters
+ parseQuerystring: function() {
+ var nvpair = {};
+ var qs = window.location.search.replace('?', '');
+ var pairs = qs.split('&');
+ $.each(pairs, function(i, v){
+ var pair = v.split('=');
+ nvpair[pair[0]] = pair[1];
+ });
+ return nvpair;
+ },
+
+ debug2: function(string) { // delayed debug, internal variables are set after dom ready
+ setTimeout(function() { debug(string); }, 500);
+ },
+
+ // service-proxy or pazpar2
+ pazpar2: function(config) {
+ var id_popup = config.id_popup || "#mkwsPopup";
+ id_popup = id_popup.replace(/^#/, "");
+
+ // simple layout
+ var div = '
\
+
\
+
\
+
\
+
\
+
';
+
+ // new table layout
+ var table = '\
+ \
+ \
+ \
+ \
+ \
+
\
+
\
+
\
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+ \
+
\
+ \
+ \
+
';
+
+ var popup = '\
+
\
+ '
+
+ if (config && config.layout == 'div') {
+ this.debug2("jquery plugin layout: div");
+ document.write(div);
+ } else if (config && config.layout == 'popup') {
+ this.debug2("jquery plugin layout: popup with id: " + id_popup);
+ document.write(popup);
+ $(document).ready( function() { init_popup(config); } );
+ } else {
+ this.debug2("jquery plugin layout: table");
+ document.write(table);
+ }
+ }
+});
+
+function init_popup(obj) {
+ var config = obj ? obj : {};
+
+ var height = config.height || 760;
+ var width = config.width || 880;
+ var id_button = config.id_button || "input#mkwsButton";
+ var id_popup = config.id_popup || "#mkwsPopup";
+
+ debug("popup height: " + height + ", width: " + width);
+
+ // make sure that jquery-ui was loaded afte jQuery core lib, e.g.:
+ //
+ if (!$.ui) {
+ debug("Error: jquery-ui.js is missing, did you included it after jquery core in the HTML file?");
+ return;
+ }
+
+ $(id_popup).dialog({
+ closeOnEscape: true,
+ autoOpen: false,
+ height: height,
+ width: width,
+ modal: true,
+ resizable: true,
+ buttons: {
+ Cancel: function() {
+ $(this).dialog("close");
+ }
+ },
+ close: function() { }
+ });
+
+ $(id_button)
+ .button()
+ .click(function() {
+ $(id_popup).dialog("open");
+ });
+};
+
+
+
+
+/* magic */
+$(document).ready(function() {
+ try {
+ mkws_html_all()
+ }
+
+ catch (e) {
+ mkws_config.error = e.message;
+ // alert(e.message);
+ }
+});
+
+})(jQuery);