Index: trunk/kernel/admin_templates/incs/ajax.js =================================================================== diff -u -r5302 -r5464 --- trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 5302) +++ trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 5464) @@ -1,3 +1,4 @@ +// Main AJAX classs function Request() {} Request.timeout = 5000; //5 seconds @@ -178,4 +179,44 @@ } } return queryString; -}; \ No newline at end of file +}; + +// AJAX ProgressBar classs +function AjaxProgressBar($prefix, $url) { + this.Prefix = $prefix; + this.URL = $url; + this.BusyRequest = false; + this.Query(); +} + +AjaxProgressBar.prototype.Query = function() { + Request.makeRequest(this.URL, this.BusyRequest, '', this.successCallback, this.errorCallback, '', this); +} + +AjaxProgressBar.prototype.successCallback = function($request, $params, $object) { + var $responce = $request.responseText; + if ($responce.match(/^#redirect#(.*)/)) { + $object.showProgress(100); + // redirect to external template requested + window.location.href = RegExp.$1; + return false; + } + + $object.showProgress($responce); + $object.Query(); +} + +AjaxProgressBar.prototype.errorCallback = function($request, $params, $object) { + alert('AJAX ERROR: ' + Request.getErrorHtml($request)); +} + +AjaxProgressBar.prototype.showProgress = function ($percent) { + $percent = parseInt($percent); + var $display_div = document.getElementById('progress_display[' + this.Prefix + ']'); + if ($display_div) { + $display_div.innerHTML = '(' + $percent + '%)'; + } + + document.getElementById('progress_done[' + this.Prefix + ']').style.width = $percent + '%'; + document.getElementById('progress_left[' + this.Prefix + ']').style.width = (100 - $percent) + '%'; +} \ No newline at end of file