var original = Array(); var ajax=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { ajax = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { ajax = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { ajax = false; } } @end @*/ if (!ajax && typeof XMLHttpRequest!='undefined') { ajax = new XMLHttpRequest(); } function editEntry(serverPage, objID) { var element = document.getElementById(objID); original[objID] = element.innerHTML; ajax.open('GET', serverPage); ajax.onreadystatechange = function() { switch(ajax.readyState) { case 1: element.innerHTML = "Loading."; break; case 2: element.innerHTML += " ."; break; case 3: element.innerHTML += " ."; break; case 4: if (ajax.status==200) { element.innerHTML = ajax.responseText; } break; } } ajax.send(null); } function cancelEntry(objID) { var element = document.getElementById(objID); element.innerHTML = original[objID]; } function saveEntry(serverPage, objID, form, save) { var element = document.getElementById(objID); var queryStr = formData2QueryString(form); if (save==false) { queryStr += '&preview=Preview'; } ajax.open('POST', serverPage, true); ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); ajax.onreadystatechange = function() { switch(ajax.readyState) { case 1: element.innerHTML = "Processing."; break; case 2: element.innerHTML += " ."; break; case 3: element.innerHTML += " ."; break; case 4: if (ajax.status==200) { element.innerHTML = ajax.responseText; if (save==true) { window.location.reload(false); } } break; } } ajax.send(queryStr); } /* --------------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING); if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA The following code is copyright 2003 by Matthew Eernisse Modified by Yvonne L --------------------------------------------------------------------------- */ function formData2QueryString(docForm) { var strSubmitContent = ''; var formElem; var strLastElemName = ''; for (i = 0; i < docForm.elements.length; i++) { formElem = docForm.elements[i]; switch (formElem.type) { // Text fields, hidden form elements case 'text': case 'hidden': case 'password': case 'textarea': case 'image': case 'select-one': strSubmitContent += formElem.name + '=' + encodeURIComponent(formElem.value) + '&'; break; case 'select-multiple': for (count = 0; count < formElem.length; count++) { if ( formElem[count].selected ) { strSubmitContent += formElem.name + '=' + encodeURIComponent(formElem[count].value) + '&'; } } break; // Radio buttons case 'radio': if (formElem.checked) { strSubmitContent += formElem.name + '=' + encodeURIComponent(formElem.value) + '&'; } break; // Checkboxes case 'checkbox': if (formElem.checked) { // Continuing multiple, same-name checkboxes if (formElem.name == strLastElemName) { // Strip of end ampersand if there is one if (strSubmitContent.lastIndexOf('&') == strSubmitContent.length-1) { strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1); } // Append value as comma-delimited string strSubmitContent += ',' + encodeURIComponent(formElem.value); } else { strSubmitContent += formElem.name + '=' + encodeURIComponent(formElem.value); } strSubmitContent += '&'; } break; } strLastElemName = formElem.name; } // Remove trailing separator strSubmitContent = strSubmitContent.substr(0, strSubmitContent.length - 1); return strSubmitContent; }