Whoops, forgot to commit these.
This commit is contained in:
parent
45c338ed31
commit
2a598ce18b
4 changed files with 108 additions and 0 deletions
20
www/extras/Fork/ProgressBar.css
Normal file
20
www/extras/Fork/ProgressBar.css
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
.webgui-fork-pb {
|
||||||
|
border: thin solid black;
|
||||||
|
position: relative;
|
||||||
|
line-height: 20pt;
|
||||||
|
height: 20pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
.webgui-fork-pb .webgui-fork-pb-bar {
|
||||||
|
background-color: lime;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.webgui-fork-pb .webgui-fork-pb-caption {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 18pt;
|
||||||
|
}
|
||||||
30
www/extras/Fork/ProgressBar.js
Normal file
30
www/extras/Fork/ProgressBar.js
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*global YAHOO, WebGUI, document */
|
||||||
|
/* Dependencies: yahoo, dom */
|
||||||
|
(function () {
|
||||||
|
var dom = YAHOO.util.Dom,
|
||||||
|
ns = YAHOO.namespace('WebGUI.Fork'),
|
||||||
|
cls = ns.ProgressBar = function () {},
|
||||||
|
proto = cls.prototype;
|
||||||
|
|
||||||
|
proto.render = function (node) {
|
||||||
|
var bar, cap;
|
||||||
|
if (!node.tagName) {
|
||||||
|
node = document.getElementById(node);
|
||||||
|
}
|
||||||
|
dom.addClass(node, 'webgui-fork-pb');
|
||||||
|
bar = document.createElement('div');
|
||||||
|
cap = document.createElement('div');
|
||||||
|
dom.addClass(bar, 'webgui-fork-pb-bar');
|
||||||
|
dom.addClass(cap, 'webgui-fork-pb-caption');
|
||||||
|
node.appendChild(bar);
|
||||||
|
node.appendChild(cap);
|
||||||
|
this.domNode = node;
|
||||||
|
this.bar = bar;
|
||||||
|
this.caption = cap;
|
||||||
|
};
|
||||||
|
proto.update = function (done, total) {
|
||||||
|
var pct = (total > 0 ? Math.floor((done/total)*100) : 100) + '%';
|
||||||
|
this.caption.innerHTML = pct;
|
||||||
|
this.bar.style.width = pct;
|
||||||
|
};
|
||||||
|
}());
|
||||||
42
www/extras/Fork/poll.js
Normal file
42
www/extras/Fork/poll.js
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*global YAHOO, setTimeout */
|
||||||
|
/* Dependencies: yahoo, connection_core, json */
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var ns = YAHOO.namespace('WebGUI.Fork'), JSON = YAHOO.lang.JSON;
|
||||||
|
|
||||||
|
ns.poll = function(args) {
|
||||||
|
function fetch() {
|
||||||
|
var first = true;
|
||||||
|
YAHOO.util.Connect.asyncRequest('GET', args.url, {
|
||||||
|
success: function (o) {
|
||||||
|
var data, e;
|
||||||
|
if (o.status != 200) {
|
||||||
|
args.error("Server returned bad response");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data = JSON.parse(o.responseText);
|
||||||
|
e = data.error;
|
||||||
|
if (e) {
|
||||||
|
args.error(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
args.draw(data);
|
||||||
|
if (args.first && first) {
|
||||||
|
first = false;
|
||||||
|
args.first();
|
||||||
|
}
|
||||||
|
if (data.finished) {
|
||||||
|
args.finish();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setTimeout(fetch, args.interval || 1000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
failure: function (o) {
|
||||||
|
args.error("Could not communicate with server");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
fetch();
|
||||||
|
};
|
||||||
|
}());
|
||||||
16
www/extras/Fork/redirect.js
Normal file
16
www/extras/Fork/redirect.js
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*global YAHOO, setTimeout, window */
|
||||||
|
/* Dependencies: yahoo */
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var ns = YAHOO.namespace('WebGUI.Fork');
|
||||||
|
ns.redirect = function (redir, after) {
|
||||||
|
if (!redir) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setTimeout(function() {
|
||||||
|
// The idea here is to only allow local redirects
|
||||||
|
var loc = window.location;
|
||||||
|
loc.href = loc.protocol + '//' + loc.host + redir;
|
||||||
|
}, after || 1000);
|
||||||
|
};
|
||||||
|
}());
|
||||||
Loading…
Add table
Add a link
Reference in a new issue