X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=js%2Fpz2.js;h=dd70d5475c45a026b02d5b4ceb5c785a3f34f7e1;hb=8adb6de10317a09f4a8db8d71dc339629fca72e2;hp=55a92c7e27f0f8f9f392b8348bd3145ef35ea71d;hpb=fa4a8f5a36d63ba1487fa06a0244c4a8e86969d6;p=pazpar2-moved-to-github.git diff --git a/js/pz2.js b/js/pz2.js index 55a92c7..dd70d54 100644 --- a/js/pz2.js +++ b/js/pz2.js @@ -1,5 +1,5 @@ /* -** $Id: pz2.js,v 1.48 2007-07-18 13:40:56 adam Exp $ +** $Id: pz2.js,v 1.50 2007-08-14 14:23:32 jakub Exp $ ** pz2.js - pazpar2's javascript client library. */ @@ -181,7 +181,7 @@ pz2.prototype = } ); }, - search: function (query, num, sort, filter) + search: function (query, num, sort, filter, showfrom) { clearTimeout(__myself.statTimer); clearTimeout(__myself.showTimer); @@ -200,6 +200,11 @@ pz2.prototype = __myself.currQuery = query; else throw new Error("You need to supply query to the search command"); + + if ( showfrom !== undefined ) + var start = showfrom; + else + var start = 0; var searchParams = { "command": "search", "query": __myself.currQuery, "session": __myself.sessionID }; @@ -213,7 +218,7 @@ pz2.prototype = if ( data.getElementsByTagName("status")[0].childNodes[0].nodeValue == "OK" ) { __myself.searchStatusOK = true; //piggyback search - __myself.show(0, num, sort); + __myself.show(start, num, sort); if ( __myself.statCallback ) __myself.stat(); //__myself.statTimer = setTimeout("__myself.stat()", __myself.statTime / 4); @@ -653,6 +658,116 @@ pzHttpRequest.prototype = /* ********************************************************************************* +** XML HELPER CLASS ************************************************************ +********************************************************************************* +*/ + +// 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; +} + +// 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 (DOM_Element.textContent) { + return DOM_Element.textContent; + } else if (DOM_Element.text ) { + return DOM_Element.text; + } else { + throw new Error("Cannot get text content of the node, no such method."); + } +} + +/* +********************************************************************************* ** QUERY CLASS ****************************************************************** ********************************************************************************* */