Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add v1.0.0.2

  • Loading branch information...
commit 42e064408e73e0f8f05624f6d2c67c7ecd394925 1 parent 446f387
Doga Armangil authored
View
90 ajax/libs/qworum.js/1.0.0.2/qworum.min.js
@@ -0,0 +1,90 @@
+// Qworum.js 1.0.0.2
+// http://www.qworum.com/
+// This software is released under the MIT license (http://opensource.org/licenses/MIT).
+document.addEventListener("DOMContentLoaded",function(){console.log("Qworum.js v1.0.0.2");var a=document.getElementById(qworumButtonId("tocontentscript"));null==a&&(a=document.createElement("button"),a.setAttribute("id",qworumButtonId("tocontentscript")),a.setAttribute("style","display:none"),document.body.appendChild(a));a.setAttribute("data-event","page loaded");qworumWebCallback(a)});
+var qworum={config:{},_configDefaults:{singlePageService:!0,replaceState:!0,navigate:null},my:{stack:[{}],data:{}},eval:function(a){var c=document.getElementById(this.state._idToContentScript);try{a=JSON.stringify(a)}catch(b){a=JSON.stringify(["fault","message"])}c.setAttribute("data-event","eval");c.setAttribute("data-message",a);console.log("------------");console.log("> event: "+c.getAttribute("data-event"));console.log("> message: "+c.getAttribute("data-message"));qworumWebCallback(c)},
+state:{_stack:[{}],_idToContentScript:"qworum-tocontentscript-c046fc737747d09f02cddfc3d0b3a72ecbf4b3a8",_idFromContentScript:"qworum-fromcontentscript-c046fc737747d09f02cddfc3d0b3a72ecbf4b3a8",_idForm:"qworum-form-c046fc737747d09f02cddfc3d0b3a72ecbf4b3a8",_json_ns:"http://qworum.net/json",_ns:"http://qworum.net/",_serializer:new XMLSerializer,_parser:new DOMParser,_contentScriptCallback:function(a){var c=null;a instanceof HTMLElement||(a=document.getElementById(qworum.state._idFromContentScript));
+c=a.getAttribute("data-event");console.log("------------");console.log("< event: "+c);if("eval"==c){console.log("< callReturns: "+a.getAttribute("data-callReturns"));console.log("< currentCallVarsChanged: "+a.getAttribute("data-currentCallVarsChanged"));console.log("< newCallVars: "+a.getAttribute("data-newCallVars"));console.log("< url: "+a.getAttribute("data-url"));console.log("< query: "+a.getAttribute("data-query"));c=
+{callReturns:JSON.parse(a.getAttribute("data-callReturns")),currentCallVarsChanged:JSON.parse(a.getAttribute("data-currentCallVarsChanged")),newCallVars:JSON.parse(a.getAttribute("data-newCallVars")),url:document.createElement("a"),query:JSON.parse(a.getAttribute("data-query"))};for(c.url.href=a.getAttribute("data-url");;){a=document.createElement("a");a.href=document.URL;if(a.protocol!=c.url.protocol)break;if(a.host!=c.url.host)break;if(!(null==qworum.config.singlePageService?qworum._configDefaults.singlePageService:
+qworum.config.singlePageService))break;if(c.callReturns>=qworum.state._stack.length)break;for(var b=c.callReturns;0<b;b--)qworum.state._stack.shift(),qworum.my.stack.shift();for(var e in c.currentCallVarsChanged)qworum.state._stack[0][e]=qworum.state._parser.parseFromString(c.currentCallVarsChanged[e],"application/xml");if(null!=c.newCallVars){for(e in c.newCallVars)c.newCallVars[e]=qworum.state._parser.parseFromString(c.newCallVars[e],"application/xml");qworum.state._stack.unshift(c.newCallVars);
+qworum.my.stack.unshift({})}if(a.pathname==c.url.pathname&&a.search==c.url.search)"function"===typeof qworum.config.navigate?qworum.config.navigate(c.url.pathname,c.url.search,c.url.hash):window.location.replace(c.url.pathname+c.url.search+c.url.hash);else{if(!(null==qworum.config.replaceState?qworum._configDefaults.replaceState:qworum.config.replaceState))break;"function"===typeof qworum.config.navigate?qworum.config.navigate(c.url.pathname,c.url.search,c.url.hash):window.history.replaceState(null,
+null,c.url.pathname+c.url.search+c.url.hash)}return}c.query?(e=document.createElement("form"),e.setAttribute("id",qworum.state._idForm),e.setAttribute("action",c.url.href),e.setAttribute("method","POST"),a=document.createElement("input"),a.setAttribute("name","qworum"),a.setAttribute("value",c.query),e.setAttribute("style","display:none"),e.appendChild(a),document.body.appendChild(e),document.forms[qworum.state._idForm].submit()):window.location=c.url.href}},set:function(a,c){var b=document.getElementById(this._idToContentScript);
+if(null!=a&&"string"==typeof a){if(c instanceof Document||c instanceof Element)c=this._parser.parseFromString(this._serializer.serializeToString(c),"application/xml");else try{var e=this._parser.parseFromString("<data xmlns='"+this._json_ns+"' />","application/xml");e.documentElement.appendChild(e.createTextNode(JSON.stringify(c)));c=e}catch(d){return}this._stack[0][a]=c;b.setAttribute("data-event","state.set");b.setAttribute("data-key",a);b.setAttribute("data-value",this._serializer.serializeToString(c));
+qworumWebCallback(b)}},get:function(a){a=this._stack[0][a];return null==a?a:a.documentElement.namespaceURI==this._json_ns?JSON.parse(a.documentElement.textContent):a.documentElement.namespaceURI==this._ns&&"nil"==a.documentElement.localName?null:this._parser.parseFromString(this._serializer.serializeToString(a),"application/xml")}}};
+function qworumWebCallback(a){a instanceof HTMLElement||(a=document.getElementById(qworumButtonId("tocontentscript")));var c=a.getAttribute("data-event");console.log("> "+c);"state.set"==c?(console.log("------------"),console.log(">> event: set variable"),console.log(">> name: "+a.getAttribute("data-key")),console.log(">> value: "+a.getAttribute("data-value")),qworumContentScriptCallback({event:"set variable",name:a.getAttribute("data-key"),value:a.getAttribute("data-value")},function(){})):
+"eval"==c?(console.log("------------"),console.log(">> event: message"),console.log(">> xml: "+qworumMessageToXml(a.getAttribute("data-message"))),console.log(">> url: "+document.URL),qworumContentScriptCallback({event:"message",xml:qworumMessageToXml(a.getAttribute("data-message")),url:""+document.URL,referrer:document.URL},function(b){console.log("------------");console.log("<< url: "+b.url);console.log("<< callReturns: "+b.callReturns);console.log("<< currentCallVarsChanged: "+
+JSON.stringify(b.currentCallVarsChanged));console.log("<< newCallVars: "+JSON.stringify(b.newCallVars));a=document.getElementById(qworumButtonId("fromcontentscript"));a.setAttribute("data-event","eval");a.setAttribute("data-callReturns",b.callReturns);a.setAttribute("data-currentCallVarsChanged",JSON.stringify(b.currentCallVarsChanged));a.setAttribute("data-newCallVars",JSON.stringify(b.newCallVars));a.setAttribute("data-url",b.url);a.setAttribute("data-query",JSON.stringify(b.query));
+qworum.state._contentScriptCallback(a)})):"page loaded"==c&&(a=document.createElement("button"),a.setAttribute("id",qworumButtonId("fromcontentscript")),a.setAttribute("style","display:none"),document.body.appendChild(a))}
+function qworumMessageToXml(a){var c=new DOMParser,b=c.parseFromString("<dummy />","application/xml");try{b.replaceChild(qworumStatementToElement(["sequence",JSON.parse(a)],b,c,"http://qworum.net/"),b.documentElement)}catch(e){b.replaceChild(qworumStatementToElement(["fault","message",e],b,c,"http://qworum.net/"),b.documentElement)}return(new XMLSerializer).serializeToString(b)}
+function qworumStatementToElement(a,c,b,e){if(a instanceof Array){var d=a.shift();if("string"!=typeof d)throw"Statement name must be string.";if("fault"==d){b=a.shift();if(null!=b&&"string"!=typeof b)throw"Fault type must be string.";a=a.shift();if(null!=a&&"string"!=typeof a)throw"Fault title must be string.";var f=c.createElementNS(e,"qrm:"+d);null!=b&&f.setAttribute("type",b);null!=a&&(e=c.createElementNS(e,"title"),e.appendChild(c.createTextNode(a)),f.appendChild(e));return f}if("call"==d||"goto"==
+d){f=c.createElementNS(e,"qrm:"+d);d=a.shift();if(null!=d){if("string"!=typeof d)throw"Phase URL must be string.";f.setAttribute("href",d)}d=a.shift();null!=d&&(d=qworumStatementToElement(d,c,b,e),f.appendChild(d));a=a.shift();if(null!=a){if("string"!=typeof a)throw"Phase title must be string.";e=c.createElementNS(e,"title");e.appendChild(c.createTextNode(a));f.appendChild(e)}return f}if("if"==d){f=c.createElementNS(e,"qrm:"+d);d=a.shift();if(null==d)throw"If must have a condition statement.";d=qworumStatementToElement(d,
+c,b,e);f.appendChild(d);d=a.shift();if(null==d)throw"If must have a then statement.";d=qworumStatementToElement(d,c,b,e);f.appendChild(d);a=a.shift();null!=a&&(a=qworumStatementToElement(a,c,b,e),f.appendChild(a));return f}if("nil"==d)return c.createElementNS(e,"nil");if("return"==d)return f=c.createElementNS(e,"qrm:"+d),d=a.shift(),null!=d&&(d=qworumStatementToElement(d,c,b,e),f.appendChild(d)),f;if("transient"==d||"variable"==d){var f=c.createElementNS(e,"qrm:"+d),i=a.shift();if(null==i)throw"Name required for "+
+d+".";if("string"!=typeof i)throw"Name must be string for "+d+".";f.setAttribute("name",i);d=a.shift();null!=d&&(d=qworumStatementToElement(d,c,b,e),f.appendChild(d));return f}if("select"==d){f=c.createElementNS(e,"qrm:"+d);d=a.shift();if(null==d)throw"XPath required for select.";if("string"!=typeof d)throw"Select XPath must be string.";f.setAttribute("xpath",d);d=a.shift();if(null!=d){if("string"!=typeof d)throw"Select namespaces must be string.";f.setAttribute("namespaces",d)}d=a.shift();null!=
+d&&(d=qworumStatementToElement(d,c,b,e),f.appendChild(d));return f}if("sequence"==d){for(f=c.createElementNS(e,"qrm:"+d);;){d=a.shift();if(null==d)break;f.appendChild(qworumStatementToElement(d,c,b,e))}return f}if("transform"==d){f=c.createElementNS(e,"qrm:"+d);d=a.shift();if(null==d)throw"XSL required for transform.";if("string"!=typeof d)throw"Transform XSL must be string.";d=qworumStatementToElement(d,c,b,e);f.appendChild(d);d=a.shift();if(null==d)throw"Statement required for transform.";d=qworumStatementToElement(d,
+c,b,e);f.appendChild(d);return f}if("try"==d){f=c.createElementNS(e,"qrm:"+d);d=a.shift();if(null==d)throw"Tried statement required for try.";d=qworumStatementToElement(d,c,b,e);f.appendChild(d);for(d=a.shift();;){if(null==d)throw"Try must have a catch clause.";if(!(d instanceof Array))throw"Catch clause must be array.";i=c.createElementNS(e,"catch");f.appendChild(i);var l=d.shift();if(null!=l){if("string"!=typeof l)throw"Caught types must be string.";i.setAttribute("types",l)}for(;;){l=d.shift();
+if(null==l)break;l=qworumStatementToElement(l,c,b,e);i.appendChild(l)}d=a.shift();if(null==d)break}return f}if("json"==d){f=c.createElementNS(e+d,"data");try{f.appendChild(c.createTextNode(JSON.stringify(a.shift())))}catch(g){throw"Data must be serializable to JSON.";}return f}throw"Unknown statement.";}if("string"==typeof a)try{return f=b.parseFromString(a,"application/xml"),c.adoptNode(f.documentElement)}catch(k){throw"String is not XML.";}else throw"Statement must be array or string.";}
+function qworumButtonId(a){return"qworum-"+a+"-c046fc737747d09f02cddfc3d0b3a72ecbf4b3a8"}var qworumState=new QworumInterpreter;
+function qworumContentScriptCallback(a,c){var b=qworumState;if("page loaded"==a.event)c(b.inSession);else if("set variable"==a.event)null==a.value&&(a.value="<nil xmlns='"+QWORUM_NAMESPACE+"'/>"),b.currentFrame().setVariable(a.name,new QworumXML(a.value)),console.log(b.toString());else if("web page"==a.event)try{c(b.currentFrame().variablesToSerializable())}catch(e){}else if("message"==a.event){var d=a,f=new QworumURI(d.url),i=new QworumXML(d.xml);i.findDescendent(i.getRoot(),function(a){return"http://www.w3.org/1999/xhtml"==
+a.namespaceURI&&"parsererror"==a.localName})&&(i=new QworumXML("<fault type='message' xmlns='"+QWORUM_NAMESPACE+"'><title>XML is not well-formed.</title></fault>"));console.log(b.toString());d=new QworumMessage(i,f);console.log("interpreting message: "+d.toString());console.log();i=null;try{i=b.eval(d)}catch(l){console.log("Error: "+l)}console.log(b.toString());if(i.result){if(i.result.data)f=["Session finished with:"],148<i.result.data.length?f.push(i.result.data.substring(0,148)+" ..."):f.push(i.result.data);
+else{f=["Session finished with '"+i.result.fault.type+"' fault."];f.push("");if(0<i.result.fault.titles.length){f.push("Title:");for(b=0;b<i.result.fault.titles.length;b++)f.push(i.result.fault.titles[b].text);f.push("")}f.push("Stack trace:");for(b=i.result.fault.trace.length-1;0<b;b--)f.push("Phase "+i.result.fault.trace[b][1]),f.push(" in call "+i.result.fault.trace[b][0]+",");f.push("Phase "+i.result.fault.trace[0][1]);f.push(" in main call. ")}console.log(f.join("\n"));console.log("State reset.");
+qworumState=new QworumInterpreter}else f=i.phase.href.toString(),b=null,i.phase.parameter&&(b=i.phase.parameter.toString().replace("\n"," ")),c({url:f,query:b,callReturns:i.callReturns,currentCallVarsChanged:i.currentCallVarsChanged,newCallVars:i.newCallVars})}}function QworumInterpreter(){this.stack=[];this.stack.push(new QworumCallFrame);this.inSession=!1}QworumInterpreter.prototype.init=function(){this.stack=[];this.stack.push(new QworumCallFrame)};
+QworumInterpreter.prototype.currentFrame=function(){return 0==this.stack.length?null:this.stack[this.stack.length-1]};
+QworumInterpreter.prototype.eval=function(a){0==this.stack.length&&(this.stack.push(new QworumCallFrame),this.result=null);this.inSession=!0;for(var c=null,b=null,e=null,d=null,f=0,i={},l=null;0<this.stack.length;){c=this.stack.pop();this.stack.push(c);null!=a&&(c.message=a,a=null);var g=null;null!=b&&(g=c.message.pop(),b.element=g.element.ownerDocument.importNode(b.element,!0),g.element.parentNode.replaceChild(b.element,g.element),g.element=b.element,g.type=b.type,g.trace=b.trace,g.titles=b.titles,
+g.statements=[],c.message.push(g));for(;0<c.message.executionStack.length;){for(var k=0;k<c.message.executionStack.length;k++);b=c.message.pop();g=null;0<c.message.executionStack.length&&(g=c.message.executionStack.pop(),c.message.executionStack.push(g));if(b.element.namespaceURI!=QWORUM_NAMESPACE||"nil"==b.element.localName&&b.element.namespaceURI==QWORUM_NAMESPACE){if(null==g)break;if(g.element.namespaceURI!=QWORUM_NAMESPACE)0<g.statements.length&&c.message.push(g.statements.shift());else if("return"==
+g.element.localName)break;else if("sequence"==g.element.localName||"catch"==g.element.localName)0==g.statements.length?(g.element.parentNode.replaceChild(b.element,g.element),g.element=b.element):c.message.push(g.statements.shift());else if("transform"==g.element.localName){var h=new QworumXML(b.element),j=null,j=k=null;try{var m=new XSLTProcessor,n=new QworumXML(g.stylesheet);m.importStylesheet(n.getDocument());try{j=m.transformToFragment(h.getDocument(),g.element.ownerDocument),null!=j&&(0==j.childNodes.length?
+j=null:j.childNodes[0]instanceof Element||(j=null))}catch(p){}}catch(q){k="XSL stylesheet is not valid. "}null==k?(j=null==j?b.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,"nil"):j.childNodes[0],g.element.parentNode.replaceChild(j,g.element),g.element=j,g.statements=[]):(h=b.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,"fault"),h.setAttribute("type","message"),j=b.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,"title"),h.appendChild(j),j.appendChild(b.element.ownerDocument.createTextNode(k)),
+b.element.parentNode.replaceChild(h,b.element),b.element=h,j={},j.text=k,b.titles=[j],b.statements=[],b.type=h.getAttribute("type"),c.message.push(b))}else if("if"==g.element.localName)0==g.statements.length?(g.element.parentNode.replaceChild(b.element,g.element),g.element=b.element):b.element.namespaceURI==QWORUM_NAMESPACE?1==g.statements.length?(g.element.parentNode.replaceChild(b.element,g.element),g.element=b.element):(g.statements.shift(),c.message.push(g.statements.shift())):(c.message.push(g.statements.shift()),
+g.statements.shift());else if("select"==g.element.localName){h=new QworumXML(b.element);k=j=null;try{j=h.find(g.xpath,g.namespaces)}catch(r){k="XPath expression is malformed."}null==k?(j=null==j?g.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,"nil"):g.element.ownerDocument.importNode(j,!0),g.element.parentNode.replaceChild(j,g.element),g.element=j,g.statements=[]):(h=b.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,"fault"),h.setAttribute("type","message"),j=b.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,
+"title"),h.appendChild(j),j.appendChild(b.element.ownerDocument.createTextNode(k)),b.element.parentNode.replaceChild(h,b.element),b.element=h,j={},j.text=k,b.titles=[j],b.statements=[],b.type=h.getAttribute("type"),c.message.push(b))}else if("try"==g.element.localName)g.element.parentNode.replaceChild(b.element,g.element),g.element=b.element,g.statements=[];else if("variable"==g.element.localName||"transient"==g.element.localName)"variable"==g.element.localName?(k=g.element.getAttribute("name"),h=
+new QworumXML(b.element),c.setVariable(k,h),i[k]=h.toString()):c.message.setTransient(g.element.getAttribute("name"),new QworumXML(b.element)),g.statements=[];else if("call"==g.element.localName||"goto"==g.element.localName)d=new QworumXML(b.element)}else if("variable"==b.element.localName||"transient"==b.element.localName)g=null,g="variable"==b.element.localName?c.getVariable(b.element.getAttribute("name")):c.message.getTransient(b.element.getAttribute("name")),null==g?g=b.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,
+"nil"):(g=g.getRoot(),g=g.cloneNode(!0),g=b.element.ownerDocument.importNode(g,!0)),b.element.parentNode.replaceChild(g,b.element),b.element=g,c.message.push(b);else if("fault"==b.element.localName){if(null==b.trace){b.trace=[];for(k=0;k<this.stack.length;k++)b.trace.push([null==this.stack[k].uri?null:this.stack[k].uri.toString(),""+this.stack[k].message.uri.toString()])}if(null==g)break;if("try"==g.element.localName&&g.element.namespaceURI==QWORUM_NAMESPACE){for(h=null;0<g.statements.length;){h=
+g.statements.shift();j=!0;if(null!=h.types){j=!1;for(k=0;k<h.types.length&&!("service"==h.types[k]&&"*"==b.type.substring(0,1)&&(j=!0),"extension"==h.types[k]&&"*"==b.type.substring(0,1)&&(j=!0),"service"==h.types[k]&&"extension"==b.type&&(j=!0),"service"==h.types[k]&&"message"==b.type&&(j=!0),"user agent"==h.types[k]&&"authorization"==b.type&&(j=!0),b.type==h.types[k]&&(j=!0),j);k++);}if(j)break;h=null}g.statements=[];null!=h?(g.element.parentNode.replaceChild(h.element,g.element),g.element=h.element,
+g.titles=h.titles,g.type=h.type,g.trace=h.trace,g.statements=h.statements,c.message.push(h.statements.shift())):(g.element.parentNode.replaceChild(b.element,g.element),g.element=b.element,g.titles=b.titles,g.type=b.type,g.trace=b.trace)}else"catch"==g.element.localName&&g.element.namespaceURI==QWORUM_NAMESPACE?(c.message.executionStack.pop(),c.message.executionStack.push(b)):(g.element.parentNode.replaceChild(b.element,g.element),g.element=b.element,g.titles=b.titles,g.statements=[],g.type=b.type,
+g.trace=b.trace)}else if("call"==b.element.localName){g=null;k=c.message.uri;h=c.message.href(b.element);k.host.isLocal?h.host.isLocal||h.host.isPrivate||(g="The intranet is not subscribed to the service "+h.toString()+"."):k.host.isPrivate?h.host.isLocal||h.host.isPrivate||(g="The intranet is not subscribed to the service "+h.toString()+"."):h.host.isLocal?g="Internet website may not call an intranet service.":h.host.isPrivate?g="Internet website may not call an intranet service.":k.host.equals(h.host)||
+(g="Internet website may not call specified internet service.");if(null==g){e=c.message.href(b.element);c.message.push(b);c=new QworumCallFrame(e);l={};null!=d&&(c.setVariable("call parameter",d.clone()),l["call parameter"]=d.toString());this.stack.push(c);break}d=null;h=b.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,"fault");h.setAttribute("type","authorization");j=b.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,"title");h.appendChild(j);j.appendChild(b.element.ownerDocument.createTextNode(g));
+b.element.parentNode.replaceChild(h,b.element);b.element=h;j={};j.text=g;b.titles=[j];b.statements=[];b.type=h.getAttribute("type");c.message.push(b)}else if("goto"==b.element.localName){g=null;k=c.message.uri;h=c.message.href(b.element);!k.host.isPrivate&&h.host.isPrivate&&(g="Internet service may not redirect to intranet service");k.host.isLocal?h.host.isLocal||h.host.isPrivate||(g="The intranet is not subscribed to the service "+h.toString()+"."):k.host.isPrivate?h.host.isLocal||h.host.isPrivate||
+(g="The intranet is not subscribed to the service "+h.toString()+"."):h.host.isLocal?g="Internet website may not call an intranet service.":h.host.isPrivate?g="Internet website may not call an intranet service.":k.host.equals(h.host)||(g="Internet website may not call specified internet service.");if(null==g){e=c.message.href(b.element);c.message=null;break}d=null;h=b.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,"fault");h.setAttribute("type","authorization");j=b.element.ownerDocument.createElementNS(QWORUM_NAMESPACE,
+"title");h.appendChild(j);j.appendChild(b.element.ownerDocument.createTextNode(g));b.element.parentNode.replaceChild(h,b.element);b.element=h;j={};j.text=g;b.titles=[j];b.statements=[];b.type=h.getAttribute("type");c.message.push(b)}}if(null!=e)break;this.stack.pop();f+=1;i={}}return 0==this.stack.length?b.element.namespaceURI==QWORUM_NAMESPACE&&"fault"==b.element.localName?{result:{fault:{type:b.type,titles:b.titles,trace:b.trace}}}:{result:{data:(new XMLSerializer).serializeToString(b.element)}}:
+{phase:{href:e.toString(),parameter:null==d?null:d.toString(),titles:b.titles},callReturns:f,currentCallVarsChanged:i,newCallVars:l}};QworumInterpreter.prototype.toString=function(){for(var a="Tab state:\n",c=this.stack.length-1;0<=c;c--)a+=this.stack[c].toString();return a};
+function QworumMessage(a,c){if(null==a){var a=new QworumXML([QWORUM_NAMESPACE,"fault"]),b=a.getRoot();b.setAttribute("type","message");var e=a.getDocument(),d=e.createElementNS(QWORUM_NAMESPACE,"title");b.appendChild(d);d.appendChild(e.createTextNode("Message is not a well-formed XML document."))}this.xml=a;this.uri=c;for(this.statement=null;;){var f=null;try{this.statement=this.parse(this.xml.getRoot())}catch(i){f=""+i}if(null==f)break;this.xml=new QworumXML([QWORUM_NAMESPACE,"fault"]);b=this.xml.getRoot();
+b.setAttribute("type","message");null!=f&&(e=this.xml.getDocument(),d=e.createElementNS(QWORUM_NAMESPACE,"title"),b.appendChild(d),d.appendChild(e.createTextNode("Non-conforming Qworum message: "+f)))}this.transientNames=[];this.transientValues=[];this.executionStack=[];this.push(this.statement)}
+QworumMessage.prototype.parse=function(a){if(null==a)return null;var c={};c.element=a;c.titles=null;c.type=null;c.trace=null;c.types=null;c.xpath=null;c.namespaces=null;c.stylesheet=null;c.statements=[];if(a.namespaceURI!=QWORUM_NAMESPACE){for(var b=this.xml.findDescendents(a,function(a){return a.namespaceURI==QWORUM_NAMESPACE});0<b.length;){for(var e=b.shift(),d=!0,f=e;d;){f=f.parentNode;if(f==a)break;f.namespaceURI==QWORUM_NAMESPACE&&(d=!1)}d&&c.statements.push(this.parse(e))}return c}b=this.xml.findChildren(a,
+function(){return!0});if("catch"==a.localName||"sequence"==a.localName){for(0==b.length&&b.push(a.ownerDocument.createElementNS(QWORUM_NAMESPACE,"nil"));0<b.length;)c.statements.push(this.parse(b.shift()));if("catch"==a.localName){a=a.getAttribute("types");""==a&&(a=null);if(null!=a){a=a.split(",");for(d=0;d<a.length;d++){a[d]=a[d].split(" ");f=null;for(e=0;e<a[d].length;e++)null!=a[d][e]&&""!=a[d][e]&&(f=null==f?a[d][e]:f+" "+a[d][e]);a[d]=f}}c.types=a}}else if("try"==a.localName){if(2>b.length)throw new QworumParserException("<"+
+a.localName+"> should contain at least two elements.");if("catch"==b[0].localName)throw new QworumParserException("Expected a statement, found <"+b[0].localName+">.");for(d=1;d<b.length;d++)if("catch"!=b[d].localName)throw new QworumParserException("Expected <catch>.");for(;0<b.length;)c.statements.push(this.parse(b.shift()))}else if("transform"==a.localName){if(2!=b.length)throw new QworumParserException("<"+a.localName+"> should contain two elements.");a=this.xml.findChildren(b[0],function(a){return"output"==
+a.localName&&"http://www.w3.org/1999/XSL/Transform"==a.namespaceURI});if(0<a.length)for(d=0;d<a.length;d++)b[0].removeChild(a[d]);c.stylesheet=b.shift();c.statements.push(this.parse(b.shift()))}else if("if"==a.localName){if(2>b.length||3<b.length)throw new QworumParserException("<"+a.localName+"> should contain two or three elements.");for(;0<b.length;)c.statements.push(this.parse(b.shift()))}else if("select"==a.localName){if(1!=b.length)throw new QworumParserException("<"+a.localName+"> should contain exactly one element.");
+c.statements.push(this.parse(b.shift()));b=a.getAttribute("xpath");if(null==b)throw new QworumParserException("<"+a.localName+"> must have an attribute named xpath.");if(0==b.length)throw new QworumParserException("<"+a.localName+"> must have an non-empty attribute named xpath.");c.xpath=b;c.namespaces=[];b=a.getAttribute("namespaces");if(null!=b){if(!(-1==b.indexOf("'")&&-1==b.indexOf('"')))throw new QworumParserException("<"+a.localName+"> has an error in its namespaces attribute.");b=b.split(" ");
+e=null;for(d=0;d<b.length;d++)0!=b[d].length&&(null==e?e=[b[d]]:(e.push(b[d]),c.namespaces.push(e),e=null));if(null!=e)throw new QworumParserException("<"+a.localName+"> has an error in its namespaces attribute.");}}else if("goto"==a.localName||"call"==a.localName||"fault"==a.localName){c.titles=[];for(d=0;d<b.length;d++)e=b[d],e.namespaceURI==QWORUM_NAMESPACE&&"title"==e.localName&&(c.titles.push(e),b[d]=null);for(d=0;d<c.titles.length;d++){for(var e=c.titles[d],f={text:""},i=e.firstChild;null!=
+i;)i.nodeType==i.TEXT_NODE&&(f.text+=i.nodeValue),i=i.nextSibling;f.lang=e.getAttribute("lang");c.titles[d]=f;null==f.lang&&(f.lang="");for(;0<f.lang.length&&" "==f.lang.substring(0,1);)f.lang=f.lang.substring(1,f.lang.length);for(;0<f.lang.length&&" "==f.lang.substring(f.lang.length-1,f.lang.length);)f.lang=f.lang.substring(0,f.lang.length-1);0==f.lang.length&&(f.lang=null);if(null!=f.lang){f.lang=f.lang.split("-");for(e=0;e<f.lang.length;e++)f.lang[e]=f.lang[e].toLowerCase()}}if("fault"==a.localName){f=
+a.getAttribute("type");null==f&&(f="");""==f&&(f="service");if(-1!=f.indexOf(","))throw new QworumParserException("Fault type may not contain ',' character.");f=f.split(" ");d=null;for(e=0;e<f.length;e++)null!=f[e]&&""!=f[e]&&(d=null==d?f[e]:d+" "+f[e]);c.type=d;for(d=0;d<b.length;d++)if(null!=b[d])throw new QworumParserException("<"+a.localName+"> may only contain <title> elements.");}else for(d=0;d<b.length;d++)if(null!=b[d]){if(0<c.statements.length)throw new QworumParserException("<"+a.localName+
+"> has more than one parameter.");c.statements.push(this.parse(b[d]))}}else if("nil"==a.localName){if(0<b.length)throw new QworumParserException("<"+a.localName+"> should not contain any elements.");}else if("return"==a.localName){if(1<b.length)throw new QworumParserException("<"+a.localName+"> should not contain more than one element.");0==b.length&&b.push(a.ownerDocument.createElementNS(QWORUM_NAMESPACE,"nil"));c.statements.push(this.parse(b.shift()))}else if("variable"==a.localName||"transient"==
+a.localName){if(1<b.length)throw new QworumParserException("<"+a.localName+"> should not contain more than one element.");1==b.length&&c.statements.push(this.parse(b.shift()))}else throw new QworumParserException("Unknown Qworum element <"+a.localName+">.");return c};QworumMessage.prototype.pop=function(){return 0==this.executionStack.length?null:this.executionStack.pop()};QworumMessage.prototype.push=function(a){null!=a&&(this.executionStack.push(a),0<a.statements.length&&this.push(a.statements.shift()))};
+QworumMessage.prototype.href=function(a){if(null==a)return null;a=a.getAttributeNode("href");return null==a?this.uri:this.uri.resolve(a.value)};QworumMessage.prototype.setTransient=function(a,c){if(!(null==a||null==c)){for(var b=null,e=0;e<this.transientNames.length;e++)if(this.transientNames[e]==a){b=e;break}null!=b?this.transientValues[b]=c:(this.transientNames.push(a),this.transientValues.push(c))}};
+QworumMessage.prototype.getTransient=function(a){if(null==a)return null;for(var c=null,b=0;b<this.transientNames.length;b++)if(this.transientNames[b]==a){c=b;break}return null==c?null:this.transientValues[c]};QworumMessage.prototype.toString=function(){return this.uri.toString()+" "+this.xml.toString()};function QworumParserException(a){this.message=a}QworumParserException.prototype.toString=function(){return""+this.message};
+function QworumXML(a){this.root=this.doc=null;if(null!=a){if(a instanceof Document)this.doc=a;else if(a instanceof Element){var c=new DOMParser;this.doc=c.parseFromString("<dummy />","application/xml");this.doc.replaceChild(this.doc.importNode(a,!0),this.doc.documentElement)}else a instanceof Array?(c=new DOMParser,this.doc=c.parseFromString("<dummy />","application/xml"),this.doc.replaceChild(this.doc.createElementNS(a[0],a[1]),this.doc.documentElement)):(c=new DOMParser,this.doc=0<=a.indexOf("<")?
+c.parseFromString(a,"application/xml"):c.parseFromString("<"+a+" />","application/xml"));this.root=this.doc.documentElement}}QworumXML.prototype.clone=function(){return null==this.doc?null:new QworumXML(this.toString())};QworumXML.prototype.fromString=function(a){if(null==a)return this;this.doc=(new DOMParser).parseFromString(a,"application/xml");this.root=this.doc.documentElement;return this};QworumXML.prototype.getDocument=function(){return this.doc};
+QworumXML.prototype.setRoot=function(a){null!=a&&(this.root=a)};QworumXML.prototype.getRoot=function(){return this.root};QworumXML.prototype.getElementById=function(a){return null==this.doc||null==a?null:this.doc.getElementById(a)};QworumXML.prototype.getText=function(a){if(null==a)return null;for(var c="",a=a.firstChild;null!=a;)a.nodeType==a.TEXT_NODE&&(c+=a.nodeValue),a=a.nextSibling;return c};
+QworumXML.prototype.find=function(a,c){if(null==a||null==this.doc)return null;var b={};if(null!=c)for(var e=0;e<c.length;e++)b[c[e][0]]=c[e][1];for(var d=a.split("/"),e=0;e<d.length;e++)if(0!=d[e].length){var f=d[e].split("[");if(0!=f[0].length){var i=f[0].split(":");if(1!=i.length){if(2<i.length)throw"Namespace notation error";if(null==b[i[0]])throw"Unknown namespace";f[0]="*[namespace-uri()='"+b[i[0]]+"'][local-name()='"+i[1]+"']";d[e]=f.join("[")}}}a=d.join("/");b=this.doc.evaluate(a,this.root,
+null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);b=b.singleNodeValue;if(null!=b&&!(b instanceof Element))throw"Malformed XPath expression.";return b};QworumXML.prototype.removeAttributes=function(a,c){if(null!=a)for(var b=a.attributes,e=0;e<b.length;e++)0!=b.item(e).name.indexOf("xml")&&(null==c?a.removeAttributeNode(b.item(e)):c(b.item(e))&&a.removeAttributeNode(b.item(e)))};QworumXML.prototype.removeChildren=function(a,c){if(null!=a)for(var b=this.findChildren(a,c),e=0;e<b.length;e++)a.removeChild(b[e])};
+QworumXML.prototype.findChild=function(a,c){if(null==a)return null;for(var b=null,e=a.firstChild;null!=e;){if(e.nodeType==e.ELEMENT_NODE){if(null==c){b=e;break}if(c(e)){b=e;break}}e=e.nextSibling}return b};QworumXML.prototype.findChildren=function(a,c){if(null==a)return null;for(var b=[],e=a.firstChild;null!=e;)e.nodeType==e.ELEMENT_NODE&&(null==c?b.push(e):c(e)&&b.push(e)),e=e.nextSibling;return b};
+QworumXML.prototype.firstChild=function(a){if(null==a)return null;for(var c=null,a=a.firstChild;null!=a;){if(a.nodeType==a.ELEMENT_NODE){c=a;break}a=a.nextSibling}return c};QworumXML.prototype.findDescendent=function(a,c){if(null==a)return null;var b=this.findDescendents(a,c);return b=0==b.length?null:b[0]};QworumXML.prototype.findDescendents=function(a,c){if(null==a)return null;var b=[];this.findDescendentsPrivate(a,c,b);return b};
+QworumXML.prototype.findDescendentsPrivate=function(a,c,b){for(a=a.firstChild;null!=a;)a.nodeType==a.ELEMENT_NODE&&(null==c?b.push(a):c(a)&&b.push(a),this.findDescendentsPrivate(a,c,b)),a=a.nextSibling};QworumXML.prototype.elementToString=function(a){return null==a?null:(new XMLSerializer).serializeToString(a)};QworumXML.prototype.toString=function(){return null==this.doc?null:(new XMLSerializer).serializeToString(this.doc)};
+function QworumCallFrame(a){this.uri=a;this.message=null;this.variableNames=[];this.variableValues=[]}QworumCallFrame.prototype.setVariable=function(a,c){if(!(null==a||null==c)){for(var b=null,e=0;e<this.variableNames.length;e++)if(this.variableNames[e]==a){b=e;break}null!=b?this.variableValues[b]=c:(this.variableNames.push(a),this.variableValues.push(c))}};
+QworumCallFrame.prototype.getVariable=function(a){if(null==a)return null;for(var c=null,b=0;b<this.variableNames.length;b++)if(this.variableNames[b]==a){c=b;break}return null==c?null:this.variableValues[c]};
+QworumCallFrame.prototype.toString=function(){var a=" Call frame:\n";this.uri&&(a+=" URL: "+this.uri.toString()+"\n");this.message&&(a+=" Message: "+this.message.toString()+"\n");for(var c=0;c<this.variableNames.length;c++)null==this.variableNames[c]||null==this.variableValues[c]||(a+=" Variable '"+this.variableNames[c]+"' = "+this.variableValues[c]+"\n");return a};
+QworumCallFrame.prototype.variablesToSerializable=function(){var a={};new XMLSerializer;for(var c=0;c<this.variableNames.length;c++)if(null!=this.variableNames[c]){var b=this.variableValues[c];null!=b&&(null!=b&&null==b.getRoot()&&(b=null),null!=b&&b.getRoot().namespaceURI==QWORUM_NAMESPACE&&"nil"==b.getRoot().localName&&(b=null),null!=b&&(b=b.toString()),a[this.variableNames[c]]=b)}return a};
+function QworumURI(a,c){this.exist=!1;this.port=this.host=this.scheme=null;this.path=[];this.fragment=this.query=null;var b,e,d;if(a)if(0<=a.indexOf("://")){if(b=a.indexOf(":"),!(4>b)&&(this.scheme=a.substring(0,b).toLowerCase(),"http"==this.scheme||"https"==this.scheme))if(a=a.substring(b+1),"//"==a.substring(0,2)&&(a=a.substring(2),b=a.indexOf("/"),-1==b&&(a+="/",b=a.indexOf("/")),!(1>b))){e=a.indexOf(":");if(0<=e&&e<b){d=a.substring(0,e);if(e+1==b)return;e+=1;if(1>b-e)return;this.port=parseInt(a.substring(e,
+b))}else d=a.substring(0,b);this.host=new QworumDomainName(d);this.host.exists()||(this.host=new QworumIPAddress(d));this.host.exists()&&(a=a.substring(b),b=a.indexOf("#"),0<b&&(this.fragment=a.substring(b+1),a=a.substring(0,b)),b=a.indexOf("?"),0<b&&(this.query=a.substring(b+1),a=a.substring(0,b)),this.path=a.split("/"),this.path.shift(),this.exist=!0)}}else{if(c&&(this.exist=c.exist)){this.scheme=c.scheme;this.host=c.host;this.port=c.port;this.path=[];for(b=0;b<c.path.length;b++)this.path.push(c.path[b]);
+this.fragment=this.query=null;b=a.indexOf("#");if(0<=b){this.fragment=a.substring(b+1);if(0==b)return;a=a.substring(0,b)}b=a.indexOf("?");if(0<=b){this.query=a.substring(b+1);if(0==b)return;a=a.substring(0,b)}if(0==a.indexOf("/"))this.path=a.split("/"),this.path.shift();else{this.path.pop();for(a=a.split("/");0<a.length;)this.path.push(a.shift())}}}else if(c&&(this.exist=c.exist)){this.scheme=c.scheme;this.host=c.host;this.port=c.port;this.path=[];for(b=0;b<c.path.length;b++)this.path.push(c.path[b]);
+this.query=c.query;this.fragment=c.fragment}}QworumURI.prototype.resolve=function(a){return new QworumURI(a,this)};QworumURI.prototype.getScheme=function(){return!this.exist?null:this.scheme};QworumURI.prototype.equals=function(a){return!this.exist||null==a||!(a instanceof QworumURI)||!a.exists()?!1:this.toString()==a.toString()};QworumURI.prototype.exists=function(){return this.exist};
+QworumURI.prototype.toString=function(){if(!this.exist)return"";var a=this.scheme+"://"+this.host.toString();this.port&&(a=a+":"+this.port);a=a+"/"+this.path.join("/");this.query&&0<this.query.length&&(a=a+"?"+this.query);this.fragment&&(a=a+"#"+this.fragment);return a};
+function QworumDomainName(a){this.exist=!1;if(null!=a&&(this.name=null,this.isLocal=!0,this.isPrivate=!1,!(255<a.length))){var a=a.toLowerCase(),c=a.split(".");if(0!=c.length){for(var b=!1,e=0;e<c.length;e++){var d=c[e];if(0==d.length||63<d.length)return;for(var f=0;f<d.length;f++){var i=d.charAt(f);if(!("0"<=i&&"9">=i||"a"<=i&&"z">=i||"-"==i))return;if("a"<=i&&"z">=i||"-"==i)b=!0}}if(b){this.name=a;this.exist=!0;if(1==c.length)this.isLocal="localhost"==c.pop()?!0:!1;else{a="ac ad ae aero af ag ai al am an ao aq ar arpa as asia at au aw ax az ba bb bd be bf bg bh bi biz bj bm bn bo br bs bt bv bw by bz ca cat cc cd cf cg ch ci ck cl cm cn co com coop cr cu cv cx cy cz de dj dk dm do dz ec edu ee eg er es et eu fi fj fk fm fo fr ga gb gd ge gf gg gh gi gl gm gn gov gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il im in info int io iq ir is it je jm jo jobs jp ke kg kh ki km kn kp kr kw ky kz la lb lc li lk lr ls lt lu lv ly ma mc md me mg mh mil mk ml mm mn mo mobi mp mq mr ms mt mu museum mv mw mx my mz na name nc ne net nf ng ni nl no np nr nu nz om org pa pe pf pg ph pk pl pm pn pr pro ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sj sk sl sm sn so sr st su sv sy sz tc td tel tf tg th tj tk tl tm tn to tp tr travel tt tv tw tz ua ug uk us uy uz va vc ve vg vi vn vu wf ws xn--0zwm56d xn--11b5bs3a9aj6g xn--80akhbyknj4f xn--9t4b11yi5a xn--deba0ad xn--g6w251d xn--hgbk6aj7f53bba xn--hlcj6aya9esc7a xn--jxalpdlp xn--kgbechtv xn--zckzah ye yt yu za zm zw".split(" ");
+c=c.pop();for(e=0;e<a.length;e++)if(a[e]==c){this.isPrivate=this.isLocal=!1;return}this.isLocal=!1}this.isPrivate=!0}}}}QworumDomainName.prototype.exists=function(){return this.exist};QworumDomainName.prototype.equals=function(a){return!this.exist||null==a||!(a instanceof QworumDomainName)||!a.exists()?!1:this.toString()==a.toString()};QworumDomainName.prototype.toString=function(){return!this.exist?"":this.name};
+function QworumIPAddress(a){this.exist=!1;if(null!=a&&(this.mask=this.addr=null,this.isLocal=!0,this.isPrivate=!1,a=a.split("/"),!(2<a.length))){if(2==a.length){var c=parseInt(a[1]);if(0>c||32<c)return;this.mask=c}a=a[0].split(".");if(4==a.length){for(c=0;c<a.length;c++){for(var b=0;b<a[c].length;b++){for(var e=!1,d=0;10>d;d++)if(a[c].charAt(b)=="0123456789".charAt(d)){e=!0;break}if(!e)return}a[c]=parseInt(a[c]);if(0>a[c]||255<a[c])return}this.addr=a;0==this.addr[0]&&0==this.addr[1]&&0==this.addr[2]&&
+0==this.addr[3]||127==this.addr[0]?this.isPrivate=this.isLocal=!0:10==this.addr[0]||192==this.addr[0]&&168==this.addr[1]||172==this.addr[0]&&16<=this.addr[1]&&31>=this.addr[1]?(this.isLocal=!1,this.isPrivate=!0):this.isPrivate=this.isLocal=!1;this.exist=!0}}}QworumIPAddress.prototype.exists=function(){return this.exist};
+QworumIPAddress.prototype.contains=function(a){if(!this.exist||null==a||null!=a.mask)return!1;var c=this.mask;null==c&&(c=32);for(var b=0;b<this.addr.length;b++){if(8<=c){if(a.addr[b]!=this.addr[b])return!1}else if(0<c&&8>c&&a.addr[b]>>>8-c!=this.addr[b]>>>8-c)return!1;c-=8}return!0};
+QworumIPAddress.prototype.contains=function(a){if(!this.exist||null==a||null!=a.mask)return!1;var c=this.mask;null==c&&(c=32);for(var b=0;b<this.addr.length;b++){if(0<c&&8>c){if(a.addr[b]>>>8-c!=this.addr[b]>>>8-c)return!1}else if(a.addr[b]!=this.addr[b])return!1;c-=8}return!0};QworumIPAddress.prototype.equals=function(a){return!this.exist||null==a||!(a instanceof QworumIPAddress)||!a.exists()?!1:this.toString()==a.toString()};
+QworumIPAddress.prototype.toString=function(){if(!this.exist)return"";var a=""+this.addr[0]+"."+this.addr[1]+"."+this.addr[2]+"."+this.addr[3];null!=this.mask&&(a=a+"/"+this.mask);return a};var QWORUM_VERSION="1.0",QWORUM_CONTENT_TYPE="application/xml",QWORUM_NAMESPACE="http://qworum.net/";
+function QworumEnv(){this.PRODUCTION="production";this.DEVELOPMENT="development";this.TEST="test";this.mode=this.DEVELOPMENT;this.mode=this.PRODUCTION;this.CHROME="chrome";this.FIREFOX="firefox";this.browser=this.CHROME;this.logScope=[];this.tabs=[];this.oldTabs=[]}QworumEnv.prototype.create=function(a){console.log("creating interpreter for tab "+a);this.remove(a);var c=new QworumInterpreter;this.tabs.push({id:a,interpreter:c,html:null});return c};
+QworumEnv.prototype.get=function(a){for(var c=0;c<this.tabs.length;c++)if(this.tabs[c].id==a)return console.log("found interp for tab "+a),this.tabs[c].interpreter;return this.create(a)};QworumEnv.prototype.remove=function(a){for(var c=0;c<this.tabs.length;c++)if(this.tabs[c].id==a){this.tabs.splice(c,1);break}};QworumEnv.prototype.change=function(a,c){for(var b=0;b<this.tabs.length;b++)this.tabs[b].id==a&&(this.tabs[b].id=c)};
+QworumEnv.prototype.enterLogScope=function(a){this.mode==this.DEVELOPMENT&&(this.logScope.push(a),this.log(">"))};QworumEnv.prototype.exitLogScope=function(){this.mode==this.DEVELOPMENT&&(this.log("<"),0<this.logScope.length&&this.logScope.pop())};QworumEnv.prototype.log=function(a){if(this.mode==this.DEVELOPMENT){for(var c=0;c<this.logScope.length;c++);alert(a)}};QworumEnv.prototype.production=function(){this.mode=this.PRODUCTION};QworumEnv.prototype.development=function(){this.mode=this.DEVELOPMENT};
+QworumEnv.prototype.test=function(){this.mode=this.TEST};QworumEnv.prototype.isProduction=function(){return this.mode==this.PRODUCTION};QworumEnv.prototype.isDevelopment=function(){return this.mode==this.DEVELOPMENT};QworumEnv.prototype.isTest=function(){return this.mode==this.TEST};QworumEnv.prototype.isChrome=function(){return this.browser==this.CHROME};QworumEnv.prototype.isFirefox=function(){return this.browser==this.FIREFOX};var qworumEnv=new QworumEnv;
View
2  ajax/libs/qworum.js/package.json
@@ -1,7 +1,7 @@
{
"name": "qworum.js",
"filename": "qworum.min.js",
- "version": "1.0.0.1",
+ "version": "1.0.0.2",
"description": "A JavaScript library for developing modular single-page web applications.",
"homepage": "http://www.qworum.com/tutorials/qworum.js",
"keywords": [
Please sign in to comment.
Something went wrong with that request. Please try again.