Index: trunk/kernel/admin_templates/incs/ajax.js =================================================================== diff -u -r5062 -r5063 --- trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 5062) +++ trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 5063) @@ -2,16 +2,18 @@ Request.timeout = 5000; //5 seconds Request.method = 'GET'; -Request.contentType = ''; +Request.headers = new Array(); Request.params = null; -Request.makeRequest = function(p_url, p_busyReq, p_progId, p_successCallBack, p_errorCallBack, p_pass) { +Request.makeRequest = function(p_url, p_busyReq, p_progId, p_successCallBack, p_errorCallBack, p_pass, p_object) { //p_url: the web service url //p_busyReq: is a request for this object currently in progress? //p_progId: element id where progress HTML should be shown //p_successCallBack: callback function for successful response //p_errorCallBack: callback function for erroneous response //p_pass: string of params to pass to callback functions + //p_object: object of params to pass to callback functions + if (p_busyReq) return; var req = Request.getRequest(); if (req != null) { @@ -22,38 +24,44 @@ p_busyReq = false; window.clearTimeout(toId); if (req.status == 200) { - p_successCallBack(req,p_pass); + p_successCallBack(req, p_pass, p_object); } else { - p_errorCallBack(req,p_pass); + p_errorCallBack(req, p_pass, p_object); } Request.hideProgress(p_progId); } } var $ajax_mark = (p_url.indexOf('?') ? '&' : '?') + 'ajax=yes'; req.open(Request.method, p_url + $ajax_mark, true); + if (Request.method == 'POST') { - req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); - req.setRequestHeader("referer", p_url); + Request.headers['Content-type'] = 'application/x-www-form-urlencoded'; + Request.headers['referer'] = p_url; + } + else { + Request.headers['If-Modified-Since'] = 'Sat, 1 Jan 2000 00:00:00 GMT'; + } + + Request.sendHeaders(req); + if (Request.method == 'POST') { req.send(Request.params); Request.method = 'GET'; // restore method back to GET } else { - req.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT'); - if (Request.contentType) { - req.setRequestHeader('Content-type', Request.contentType); - req.send(null); - Request.contentType = ''; - } - else { - req.send(null); - } + req.send(null); } - + Request.headers = new Array(); // reset header afterwards var toId = window.setTimeout( function() {if (p_busyReq) req.abort();}, Request.timeout ); } } +Request.sendHeaders = function($request) { + for (var $header_name in Request.headers) { + $request.setRequestHeader($header_name, Request.headers[$header_name]); + } +} + Request.getRequest = function() { var xmlHttp; try { xmlHttp = new ActiveXObject('MSXML2.XMLHTTP'); return xmlHttp; } catch (e) {} Index: trunk/kernel/admin_templates/incs/tree.js =================================================================== diff -u -r5062 -r5063 --- trunk/kernel/admin_templates/incs/tree.js (.../tree.js) (revision 5062) +++ trunk/kernel/admin_templates/incs/tree.js (.../tree.js) (revision 5063) @@ -326,8 +326,8 @@ TreeFolder.prototype.folderClick = function(img) { if (this.LateLoadURL && !this.Loaded) { - Request.contentType = 'text/xml'; - Request.makeRequest(this.LateLoadURL, false, '', this.successCallback, this.errorCallback, this); + Request.headers['Content-type'] = 'text/xml'; + Request.makeRequest(this.LateLoadURL, false, '', this.successCallback, this.errorCallback, '', this); } if (this.Expanded) { @@ -338,15 +338,15 @@ } } -TreeFolder.prototype.successCallback = function ($request, $object) { +TreeFolder.prototype.successCallback = function ($request, $params, $object) { $object.ProcessXMLNode($request.responseXML); $object.Loaded = true; $object.Render(); $object.locateTopItem().updateLastNodes(); $object.expand(); } -TreeFolder.prototype.errorCallback = function($request, $params) { +TreeFolder.prototype.errorCallback = function($request, $params, $object) { alert('AJAX ERROR: ' + Request.getErrorHtml($request)); } Index: trunk/core/kernel/utility/debugger/debugger.js =================================================================== diff -u -r4996 -r5063 --- trunk/core/kernel/utility/debugger/debugger.js (.../debugger.js) (revision 4996) +++ trunk/core/kernel/utility/debugger/debugger.js (.../debugger.js) (revision 5063) @@ -2,13 +2,14 @@ DebugReq.timeout = 5000; //5 seconds -DebugReq.makeRequest = function(p_url, p_busyReq, p_progId, p_successCallBack, p_errorCallBack, p_pass) { +DebugReq.makeRequest = function(p_url, p_busyReq, p_progId, p_successCallBack, p_errorCallBack, p_pass, p_object) { //p_url: the web service url //p_busyReq: is a request for this object currently in progress? //p_progId: element id where progress HTML should be shown //p_successCallBack: callback function for successful response //p_errorCallBack: callback function for erroneous response //p_pass: string of params to pass to callback functions + //p_object: object of params to pass to callback functions if (p_busyReq) { return; } @@ -21,9 +22,9 @@ p_busyReq = false; window.clearTimeout(toId); if (req.status == 200) { - p_successCallBack(req,p_pass); + p_successCallBack(req,p_pass,p_object); } else { - p_errorCallBack(req,p_pass); + p_errorCallBack(req,p_pass,p_object); } } } @@ -141,26 +142,31 @@ } Debugger.prototype.Query = function() { - DebugReq.makeRequest(this.DebugURL, this.busyRequest, '', this.successCallback, this.errorCallback, ''); + DebugReq.makeRequest(this.DebugURL, this.busyRequest, '', this.successCallback, this.errorCallback, '', this); } -Debugger.prototype.successCallback = function(p_req, p_pass) { +Debugger.prototype.successCallback = function(p_req, p_pass, p_object) { var contents = p_req.responseText; - contents = contents.split($Debugger.RowSeparator); + contents = contents.split(p_object.RowSeparator); if (contents.length == 1) { alert('error: '+p_req.responseText); - $Debugger.IsQueried = true; + p_object.IsQueried = true; return ; } for (var $i = 0; $i < contents.length - 1; $i++) { - $Debugger.AppendRow(contents[$i]); + p_object.AppendRow(contents[$i]); } - $Debugger.Refresh(); + p_object.Refresh(); } +Debugger.prototype.errorCallback = function(p_req, p_pass, p_object) { + alert('AJAX ERROR: '+DebugReq.getErrorHtml(p_req)); + p_object.Refresh(); +} + Debugger.prototype.Refresh = function() { // progress mether row this.RemoveRow(0); @@ -169,11 +175,6 @@ this.DebuggerDIV.scrollLeft = 0; } -Debugger.prototype.errorCallback = function(p_req, p_pass) { - alert('AJAX ERROR: '+DebugReq.getErrorHtml(p_req)); - $Debugger.Refresh(); -} - Debugger.prototype.Resize = function($e) { if (!this.DebuggerDIV) return false; var $pageTop = document.all ? document.body.offsetTop + document.body.scrollTop : window.scrollY; Index: trunk/core/admin_templates/js/catalog.js =================================================================== diff -u -r5057 -r5063 --- trunk/core/admin_templates/js/catalog.js (.../catalog.js) (revision 5057) +++ trunk/core/admin_templates/js/catalog.js (.../catalog.js) (revision 5063) @@ -50,12 +50,12 @@ Request.method = $kf.method.toUpperCase(); this.BusyRequest[$prefix] = false; - Request.makeRequest($kf.action, this.BusyRequest[$prefix], $tab_id + '_div', this.successCallback, this.errorCallback, $tab_id + '_div'); + Request.makeRequest($kf.action, this.BusyRequest[$prefix], $tab_id + '_div', this.successCallback, this.errorCallback, $tab_id + '_div', this); $form_name = 'kernel_form'; // restore back to main form with current category id of catalog }; -Catalog.prototype.successCallback = function($request, $params) { +Catalog.prototype.successCallback = function($request, $params, $object) { var $text = $request.responseText; if ($text.match(/^#redirect#(.*)/)) { // redirect to external template requested @@ -64,9 +64,9 @@ } $params = $params.split(','); - var $js_end = $text.indexOf($Catalog.Separator); + var $js_end = $text.indexOf($object.Separator); if ($js_end != -1) { - document.getElementById($params[0]).innerHTML = $text.substring($js_end + $Catalog.Separator.length); + document.getElementById($params[0]).innerHTML = $text.substring($js_end + $object.Separator.length); eval($text.substring(0, $js_end)); } else { @@ -76,7 +76,7 @@ if (isset($Debugger)) $Debugger.Clear(); } -Catalog.prototype.errorCallback = function($request, $params) { +Catalog.prototype.errorCallback = function($request, $params, $object) { alert('AJAX ERROR: ' + Request.getErrorHtml($request)); } @@ -122,7 +122,7 @@ var $prefix = this.TabRegistry[0]['prefix']; var $tab_id = this.TabRegistry[0]['tab_id']; this.BusyRequest[$prefix] = false; - Request.makeRequest($url, this.BusyRequest[$prefix], $tab_id + '_div', this.successCallback, this.errorCallback, $tab_id + '_div'); + Request.makeRequest($url, this.BusyRequest[$prefix], $tab_id + '_div', this.successCallback, this.errorCallback, $tab_id + '_div', this); this.switchTab(); // refresh current item tab } @@ -160,7 +160,7 @@ $url = $url.replace('#CATEGORY_ID#', $cat_id); this.BusyRequest[$prefix] = false; - Request.makeRequest($url, this.BusyRequest[$prefix], $div_id, this.successCallback, this.errorCallback, $div_id); + Request.makeRequest($url, this.BusyRequest[$prefix], $div_id, this.successCallback, this.errorCallback, $div_id, this); // $Debugger.ShowProps(this.BusyRequest); } /*else { Index: trunk/kernel/admin_templates/incs/catalog.js =================================================================== diff -u -r5057 -r5063 --- trunk/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 5057) +++ trunk/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 5063) @@ -50,12 +50,12 @@ Request.method = $kf.method.toUpperCase(); this.BusyRequest[$prefix] = false; - Request.makeRequest($kf.action, this.BusyRequest[$prefix], $tab_id + '_div', this.successCallback, this.errorCallback, $tab_id + '_div'); + Request.makeRequest($kf.action, this.BusyRequest[$prefix], $tab_id + '_div', this.successCallback, this.errorCallback, $tab_id + '_div', this); $form_name = 'kernel_form'; // restore back to main form with current category id of catalog }; -Catalog.prototype.successCallback = function($request, $params) { +Catalog.prototype.successCallback = function($request, $params, $object) { var $text = $request.responseText; if ($text.match(/^#redirect#(.*)/)) { // redirect to external template requested @@ -64,9 +64,9 @@ } $params = $params.split(','); - var $js_end = $text.indexOf($Catalog.Separator); + var $js_end = $text.indexOf($object.Separator); if ($js_end != -1) { - document.getElementById($params[0]).innerHTML = $text.substring($js_end + $Catalog.Separator.length); + document.getElementById($params[0]).innerHTML = $text.substring($js_end + $object.Separator.length); eval($text.substring(0, $js_end)); } else { @@ -76,7 +76,7 @@ if (isset($Debugger)) $Debugger.Clear(); } -Catalog.prototype.errorCallback = function($request, $params) { +Catalog.prototype.errorCallback = function($request, $params, $object) { alert('AJAX ERROR: ' + Request.getErrorHtml($request)); } @@ -122,7 +122,7 @@ var $prefix = this.TabRegistry[0]['prefix']; var $tab_id = this.TabRegistry[0]['tab_id']; this.BusyRequest[$prefix] = false; - Request.makeRequest($url, this.BusyRequest[$prefix], $tab_id + '_div', this.successCallback, this.errorCallback, $tab_id + '_div'); + Request.makeRequest($url, this.BusyRequest[$prefix], $tab_id + '_div', this.successCallback, this.errorCallback, $tab_id + '_div', this); this.switchTab(); // refresh current item tab } @@ -160,7 +160,7 @@ $url = $url.replace('#CATEGORY_ID#', $cat_id); this.BusyRequest[$prefix] = false; - Request.makeRequest($url, this.BusyRequest[$prefix], $div_id, this.successCallback, this.errorCallback, $div_id); + Request.makeRequest($url, this.BusyRequest[$prefix], $div_id, this.successCallback, this.errorCallback, $div_id, this); // $Debugger.ShowProps(this.BusyRequest); } /*else {