var SYS_ROOT_URL_WITHOUT_PROTOCOL = '/feelthere/src'; var SYS_ROOT_URL = 'http://127.0.0.1/feelthere/src/'; url = document.location.href; if (url.indexOf(SYS_ROOT_URL + 'administrator') > -1 ) { SYS_ROOT_URL = SYS_ROOT_URL + 'administrator/'; } var systemForm = null; $(document).ready ( function() { systemForm = document.getElementById("systemForm"); if (systemForm == null) { return; } /** * Create hidden field for this form. */ systemForm.setValue = function(name, value) { try { eval("var ctrl = systemForm."+name); } catch(err) { var ctrl = undefined; } if (ctrl == undefined) { ctrl = document.createElement("input"); ctrl.type = "hidden"; ctrl.name = name; ctrl.id = name; systemForm.appendChild(ctrl); } ctrl.value = value; }; /** * Get the value for a key name */ systemForm.getValue = function(name) { eval("var val = systemForm."+name+".value"); return val; }; /** * Set the application value */ systemForm.setApp = function(value) { systemForm.setValue("app", value); }; /** * Set the action value */ systemForm.setAct = function(value) { systemForm.setValue("act", value); }; /** * Set the task value */ systemForm.setTask = function(value) { systemForm.setValue("task", value); }; /** * Validation function for validate inside data. * CAUTION: this function should be implemented by the form that * want to check some think before submit. */ systemForm.validate = function() { return true; }; /** * Submit */ systemForm.onsubmit = function() { return systemForm.validate(); }; /** * Do ajax * * callback: function(returnText) {} */ systemForm.doAjax = function(callback) { var data = $("#systemForm").serializeArray(); var ajax = new Object(); ajax.name = "ajax"; ajax.value = "1"; data[data.length] = ajax; $.post(SYS_ROOT_URL, data, callback); }; /** * Get Data for Ajax post */ systemForm.getAjaxData = function(data) { var formData = $("#systemForm").serializeArray(); var ajax = new Object(); ajax.name = "ajax"; ajax.value = "1"; formData[formData.length] = ajax; formData = formData.concat(data); return formData; }; /** * Load ajax into an elementId (normaly this should be a