- this.simpleQuery = '';
- this.singleFilter = null;
- this.advTerms = new Array();
- this.filterHash = new Array();
- this.numTerms = 0;
- this.filterNums = 0;
-};
-pzQuery.prototype = {
- clearSimpleQuery: function()
- {
- this.simpleQuery = '';
- },
- reset: function()
- {
- this.simpleQuery = '';
- this.advTerms = new Array();
- this.simpleFilter = null;
- this.numTerms = 0;
- },
- addTerm: function(field, value)
- {
- var term = {"field": field, "value": value};
- this.advTerms[this.numTerms] = term;
- this.numTerms++;
- },
- getTermValueByIdx: function(index)
- {
- return this.advTerms[index].value;
- },
- getTermFieldByIdx: function(index)
- {
- return this.advTerms[index].field;
- },
- /* semicolon separated list of terms for given field*/
- getTermsByField: function(field)
- {
- var terms = '';
- for(var i = 0; i < this.advTerms.length; i++)
- {
- if( this.advTerms[i].field == field )
- terms = terms + this.queryHas[i].value + ';';
- }
- return terms;
- },
- addTermsFromList: function(inputString, field)
- {
- var inputArr = inputString.split(';');
- for(var i=0; i < inputArr.length; i++)
- {
- if(inputArr[i].length < 3) continue;
- this.advTerms[this.numTerms] = {"field": field, "value": inputArr[i] };
- this.numTerms++;
- }
- },
- removeTermByIdx: function(index)
- {
- this.advTerms.splice(index, 1);
- this.numTerms--;
- },
- toCCL: function()
- {
- var ccl = '';
- if( this.simpleQuery != '')
- ccl = this.simpleQuery;
- for(var i = 0; i < this.advTerms.length; i++)
- {
- if (ccl != '') ccl = ccl + ' and ';
- ccl = ccl + this.advTerms[i].field+'="'+this.advTerms[i].value+'"';
- }
- return ccl;
- },
- addFilter: function(name, value)
- {
- var filter = {"name": name, "id": value };
- this.filterHash[this.filterHash.length] = filter;
- this.filterNums++
- return this.filterHash.length - 1;
- },
- setFilter: function(name, value)
- {
- this.filterHash = new Array();
- this.filterNums = 0;
- this.addFilter(name, value);
- },
- getFilter: function(index)
- {
- return this.filterHash[index].id;
- },
- getFilterName: function(index)
- {
- return this.filterHash[index].name;
- },
- removeFilter: function(index)
- {
- delete this.filterHash[index];
- this.filterNums--;
- },
- clearFilter: function()
- {
- this.filterHash = new Array();
- this.filterNums = 0;
- },
- getFilterString: function()
- {
- //temporary
- if( this.singleFilter != null ) {
- return 'pz:id='+this.singleFilter.id;
- }
- else if( this.filterNums <= 0 ) {
- return undefined;
- }
+ 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.");
+ }
+}