1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12:41 +01:00
phorge-phorge/webroot/rsrc/js/phui/behavior-phui-timer-control.js

42 lines
986 B
JavaScript
Raw Normal View History

/**
* @provides javelin-behavior-phui-timer-control
* @requires javelin-behavior
* javelin-stratcom
* javelin-dom
*/
JX.behavior('phui-timer-control', function(config) {
var node = JX.$(config.nodeID);
var uri = config.uri;
var state = null;
function onupdate(result) {
var markup = result.markup;
if (markup) {
var new_node = JX.$H(markup).getFragment().firstChild;
JX.DOM.replace(node, new_node);
node = new_node;
// If the overall state has changed from the previous display state,
// animate the control to draw the user's attention to the state change.
if (result.state !== state) {
state = result.state;
JX.DOM.alterClass(node, 'phui-form-timer-updated', true);
}
}
var retry = result.retry;
if (retry) {
setTimeout(update, 1000);
}
}
function update() {
new JX.Request(uri, onupdate)
.setTimeout(10000)
.send();
}
update();
});