MDL-44486 core: Rewrite JavaScript progressbar
This commit is contained in:
+23
-26
@@ -1413,36 +1413,33 @@ function stripHTML(str) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Number.prototype.fixed=function(n){
|
||||
with(Math)
|
||||
return round(Number(this)*pow(10,n))/pow(10,n);
|
||||
};
|
||||
function update_progress_bar (id, width, pt, msg, es){
|
||||
var percent = pt;
|
||||
var status = document.getElementById("status_"+id);
|
||||
var percent_indicator = document.getElementById("pt_"+id);
|
||||
var progress_bar = document.getElementById("progress_"+id);
|
||||
var time_es = document.getElementById("time_"+id);
|
||||
status.innerHTML = msg;
|
||||
percent_indicator.innerHTML = percent.fixed(2) + '%';
|
||||
if(percent == 100) {
|
||||
progress_bar.style.background = "green";
|
||||
time_es.style.display = "none";
|
||||
} else {
|
||||
progress_bar.style.background = "#FFCC66";
|
||||
if (es == '?'){
|
||||
time_es.innerHTML = "";
|
||||
}else {
|
||||
time_es.innerHTML = es.fixed(2)+" sec";
|
||||
time_es.style.display
|
||||
= "block";
|
||||
}
|
||||
function updateProgressBar(id, percent, msg, estimate) {
|
||||
var progressIndicator = Y.one('#' + id);
|
||||
if (!progressIndicator) {
|
||||
return;
|
||||
}
|
||||
progress_bar.style.width = width + "px";
|
||||
|
||||
var progressBar = progressIndicator.one('.bar'),
|
||||
statusIndicator = progressIndicator.one('h2'),
|
||||
estimateIndicator = progressIndicator.one('p');
|
||||
|
||||
statusIndicator.set('innerHTML', Y.Escape.html(msg));
|
||||
progressBar.set('innerHTML', Y.Escape.html('' + percent + '%'));
|
||||
if (percent === 100) {
|
||||
progressIndicator.addClass('progress-success');
|
||||
estimateIndicator.set('innerHTML', null);
|
||||
} else {
|
||||
if (estimate) {
|
||||
estimateIndicator.set('innerHTML', Y.Escape.html(estimate));
|
||||
} else {
|
||||
estimateIndicator.set('innerHTML', null);
|
||||
}
|
||||
progressIndicator.removeClass('progress-success');
|
||||
}
|
||||
progressBar.setAttribute('aria-valuenow', percent);
|
||||
progressBar.setStyle('width', percent + '%');
|
||||
}
|
||||
|
||||
|
||||
// ===== Deprecated core Javascript functions for Moodle ====
|
||||
// DO NOT USE!!!!!!!
|
||||
// Do not put this stuff in separate file because it only adds extra load on servers!
|
||||
|
||||
Reference in New Issue
Block a user