mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-29 08:50:58 +01:00
2ca316d652
Summary: Ref T13249. Poll for Duo updates in the background so we can automatically update the UI when the user clicks the mobile phone app button. Test Plan: Hit a Duo gate, clicked "Approve" in the mobile app, saw the UI update immediately. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13249 Differential Revision: https://secure.phabricator.com/D20169
41 lines
986 B
JavaScript
41 lines
986 B
JavaScript
/**
|
|
* @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();
|
|
});
|