Index: trunk/kernel/admin_templates/incs/ajax.js
===================================================================
diff -u -r5464 -r5494
--- trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 5464)
+++ trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 5494)
@@ -182,23 +182,38 @@
};
// AJAX ProgressBar classs
-function AjaxProgressBar($prefix, $url) {
+function AjaxProgressBar($prefix, $url, $format) {
this.Prefix = $prefix;
this.URL = $url;
+ this.DisplayFormat = $format;
this.BusyRequest = false;
+ this.LastResponceTime = this.GetMicroTime();
+ this.ProgressPercent = 0; // progress percent
+ this.ProgressTime = new Array();
this.Query();
}
+AjaxProgressBar.prototype.GetMicroTime = function() {
+ var $now = new Date();
+ return Math.round($now.getTime() / 1000); // because miliseconds are returned too
+}
+
AjaxProgressBar.prototype.Query = function() {
Request.makeRequest(this.URL, this.BusyRequest, '', this.successCallback, this.errorCallback, '', this);
}
+// return time needed for progress to finish
+AjaxProgressBar.prototype.GetEstimatedTime = function() {
+ return Math.ceil((100 - this.ProgressPercent) * Math.sum(this.ProgressTime) / this.ProgressPercent);
+}
+
AjaxProgressBar.prototype.successCallback = function($request, $params, $object) {
var $responce = $request.responseText;
- if ($responce.match(/^#redirect#(.*)/)) {
+ var $match_redirect = new RegExp('^#redirect#(.*)').exec($responce);
+ if ($match_redirect != null) {
$object.showProgress(100);
// redirect to external template requested
- window.location.href = RegExp.$1;
+ window.location.href = $match_redirect[1];
return false;
}
@@ -210,13 +225,26 @@
alert('AJAX ERROR: ' + Request.getErrorHtml($request));
}
+AjaxProgressBar.prototype.FormatTime = function ($seconds) {
+ $seconds = parseInt($seconds);
+ return Math.floor($seconds / 60) + ':' + $seconds % 60;
+}
+
AjaxProgressBar.prototype.showProgress = function ($percent) {
- $percent = parseInt($percent);
+ this.ProgressPercent = $percent;
+ var $now = this.GetMicroTime();
+ this.ProgressTime[this.ProgressTime.length] = $now - this.LastResponceTime;
+ this.LastResponceTime = $now;
+
+ var $display_progress = parseInt(this.ProgressPercent);
var $display_div = document.getElementById('progress_display[' + this.Prefix + ']');
if ($display_div) {
- $display_div.innerHTML = '(' + $percent + '%)';
+ var $result = this.DisplayFormat;
+ $result = $result.replace('#PERCENT_DONE#', $display_progress);
+ $result = $result.replace('#TIME_LEFT#', this.FormatTime( this.GetEstimatedTime() ));
+ $result = $result.replace('#TIME_USED#', this.FormatTime( Math.sum(this.ProgressTime) ));
+ $display_div.innerHTML = $result;
}
-
- document.getElementById('progress_done[' + this.Prefix + ']').style.width = $percent + '%';
- document.getElementById('progress_left[' + this.Prefix + ']').style.width = (100 - $percent) + '%';
+ document.getElementById('progress_done[' + this.Prefix + ']').style.width = $display_progress + '%';
+ document.getElementById('progress_left[' + this.Prefix + ']').style.width = (100 - $display_progress) + '%';
}
\ No newline at end of file
Index: trunk/kernel/include/usersession.php
===================================================================
diff -u -r5431 -r5494
--- trunk/kernel/include/usersession.php (.../usersession.php) (revision 5431)
+++ trunk/kernel/include/usersession.php (.../usersession.php) (revision 5494)
@@ -511,6 +511,7 @@
$extra_groups = implode(',', $GroupList);
$this->SetVariable('UserGroups', $extra_groups);
+ $this->SetVariable('user_id', $this->Get('PortalUserId'));
$this->Set('GroupId', $PersonalGroup ? $PersonalGroup : $PrimaryGroup);
@@ -557,6 +558,7 @@
$group_list = $FrontEnd ? $objConfig->Get('User_GuestGroup').','.$objConfig->Get('User_LoggedInGroup') : '';
$this->Set("GroupList", $group_list);
$this->SetVariable('UserGroups', $group_list );
+ $this->SetVariable('user_id', -2);
if( class_exists('kApplication') )
{
Index: trunk/kernel/admin_templates/incs/script.js
===================================================================
diff -u -r5248 -r5494
--- trunk/kernel/admin_templates/incs/script.js (.../script.js) (revision 5248)
+++ trunk/kernel/admin_templates/incs/script.js (.../script.js) (revision 5494)
@@ -1019,3 +1019,17 @@
$dst_element.appendChild($new_element);
return $new_element;
}
+
+ Math.sum = function($array) {
+ var $i = 0;
+ var $total = 0;
+ while ($i < $array.length) {
+ $total += $array[$i];
+ $i++;
+ }
+ return $total;
+ }
+
+ Math.average = function($array) {
+ return Math.sum($array) / $array.length;
+ }
Index: trunk/core/admin_templates/categories/cache_updater.tpl
===================================================================
diff -u -r5464 -r5494
--- trunk/core/admin_templates/categories/cache_updater.tpl (.../cache_updater.tpl) (revision 5464)
+++ trunk/core/admin_templates/categories/cache_updater.tpl (.../cache_updater.tpl) (revision 5494)
@@ -33,11 +33,17 @@
-
+ ![]() + ![]() + |
+
+ ![]() + ![]() + |
+