/* esegue la get di e richiama la funzione il cui nome รจ in */ function getUrl( url, callbackName ) { // esecuzione della richiesta req = getXmlHttp(); if(req!=null) { req.onreadystatechange = eval( callbackName ); //alert( url + ", " + callbackName ); //req.onreadystatechange = callbackName; req.open( "get", url, true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.send( null ); } startLoading(); } /* funzione cross-browser per ottenere l'oggetto XmlHttpRequest */ function getXmlHttp() { req = null; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } return req; } /* fa il trim di una stringa */ function trim(stringa) { reTrim = /\s+$|^\s+/g; return stringa.replace(reTrim,""); } /* fa partire il loading */ function startLoading() { if(document.getElementById("loading")) document.getElementById("loading").style.display = "inline"; } /* ferma il loading */ function stopLoading() { if(document.getElementById("loading")) document.getElementById("loading").style.display = "none"; } var searchResultsId = 'searchResults'; function getUrlDivSelect( url, callbackName, divResultsContainer ) { if(divResultsContainer != null) searchResultsId = divResultsContainer; return getUrl ( url, callbackName ); } /************** QueryResult JS Object *******************************************************************************/ QueryResult = function( columns, data, currentPage, totItems, totPages, searchUrl, sortColumn, mode, callback ) { this.columns = columns; this.data = data; this.currentPage = currentPage; this.totItems = totItems; this.totPages = totPages; this.sortColumn = sortColumn; this.mode = mode; this.callback = callback; if(callback == null) this.callback = '\"manageDoSearch\"'; if( searchUrl.indexOf( "?" ) < 0 ) searchUrl += "?"; else searchUrl += "&"; this.searchUrl = searchUrl; } QueryResult.prototype.getSortColumn = function () { return this.sortColumn; } QueryResult.prototype.setMode = function (mode) { this.mode = mode; } QueryResult.prototype.getMode = function () { return this.mode; } QueryResult.prototype.getColumns = function () { return this.columns; } QueryResult.prototype.getData = function () { return this.data; } QueryResult.prototype.getCurrentPage = function () { return this.currentPage; } QueryResult.prototype.getTotItems = function () { return this.totItems; } QueryResult.prototype.getTotPages = function () { return this.totPages; } QueryResult.prototype.getSearchUrl = function () { return this.searchUrl; } QueryResult.prototype.getCallback = function () { return this.callback; } QueryResult.prototype.setCallback = function (callback) { this.callback = callback; } QueryResult.prototype.getPaginazione = function () { var orderedSearchUrl = this.searchUrl; if( this.getSortColumn() != null && this.getSortColumn() != "" ) { orderedSearchUrl += "of=" + this.getSortColumn(); if( this.getMode() == null ) orderedSearchUrl += "&om=desc"; else orderedSearchUrl += "&om="+this.getMode(); orderedSearchUrl += "&"; //alert(orderedSearchUrl); } var firstLink = orderedSearchUrl + "p=0"; var prevLink = orderedSearchUrl + "p=" + (this.getCurrentPage() - 1); var nextLink = orderedSearchUrl + "p=" + (this.getCurrentPage() + 1); var lastLink = orderedSearchUrl + "p=" + (this.getTotPages() - 1); var callback = this.getCallback(); var result = "
"+ ""+ ""+ ""+ ""+ ""+ "" + "" + " " + ""+ ""+ "
"+ "
" + this.getTotItems() + "
" + "
"+ "
"+ ( this.getCurrentPage() > 0 ? " " : "" ) + ( this.getCurrentPage() > 0 ? " " : "" ) + "
"+ "
"+ "   " + (this.getTotPages() > 0 ? this.getCurrentPage()+1 : 0) + " " + this.getTotPages() + " " + ""+ ( this.getCurrentPage() < this.getTotPages()-1 ? "" : "" ) + ( this.getCurrentPage() < this.getTotPages()-1 ? " " : "" ) + "" + "
: " + " " + "
" + "
"+ "
"+ "
"+ ""+ ""+ ""; for ( var i = 0; i "+this.getColumns()[i][0]+""; else result += ""; else result += ""; else result += ""; } result+= ""; for ( var i = 0; i "; for (var j = 1; j"; } result+= ""; } result += ""+ ""+ "
"; return result; }