diff options
author | Máté Bartus <mate.bartus@gmail.com> | 2016-02-29 16:18:35 +0100 |
---|---|---|
committer | Máté Bartus <mate.bartus@gmail.com> | 2016-02-29 16:18:35 +0100 |
commit | 8993fef9c0ac2b49b9d51f9f804a13193ec64c36 (patch) | |
tree | cba4305d43e67cdc5fd784e6128f95ecf6a7903e /phpBB | |
parent | 062358f8b1d9a7fa3d9be97f6b58e06fea7ca844 (diff) | |
download | forums-8993fef9c0ac2b49b9d51f9f804a13193ec64c36.tar forums-8993fef9c0ac2b49b9d51f9f804a13193ec64c36.tar.gz forums-8993fef9c0ac2b49b9d51f9f804a13193ec64c36.tar.bz2 forums-8993fef9c0ac2b49b9d51f9f804a13193ec64c36.tar.xz forums-8993fef9c0ac2b49b9d51f9f804a13193ec64c36.zip |
[ticket/14487] Update javascript
PHPBB3-14487
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/assets/javascript/installer.js | 104 |
1 files changed, 50 insertions, 54 deletions
diff --git a/phpBB/assets/javascript/installer.js b/phpBB/assets/javascript/installer.js index 03b5b7deae..166c2ec472 100644 --- a/phpBB/assets/javascript/installer.js +++ b/phpBB/assets/javascript/installer.js @@ -13,9 +13,7 @@ var currentProgress = 0; var refreshRequested = false; var transmissionOver = false; - var status = ''; var statusCount = 0; - var statusTimeout = null; // Template related variables var $contentWrapper = $('.install-body').find('.main'); @@ -342,6 +340,55 @@ } /** + * Processes status data + * + * @param status + */ + function processTimeoutResponse(status) { + if (statusCount === 12) { // 1 minute hard cap + status = 'fail'; + } + + if (status === 'continue') { + refreshRequested = false; + doRefresh(); + } else if (status === 'running') { + statusCount++; + setTimeout(queryInstallerStatus, 5000); + } else { + addMessage('error', + [{ + title: installLang.title, + description: installLang.msg + }] + ); + } + } + + /** + * Queries the installer's status + */ + function queryInstallerStatus() { + var url = $(location).attr('pathname'); + var lookUp = 'install/app.php'; + var position = url.indexOf(lookUp); + + if (position === -1) { + lookUp = 'install'; + position = url.indexOf(lookUp); + + if (position === -1) { + return false; + } + } + + url = url.substring(0, position) + lookUp + '/installer/status'; + $.getJSON(url, function(data) { + processTimeoutResponse(data.status); + }); + } + + /** * Process updates in streamed response * * @param xhReq XHR object @@ -375,45 +422,8 @@ } if (timeoutDetected) { - status = queryInstallerStatus(); statusCount = 0; - - if (status === 'continue') { - refreshRequested = false; - doRefresh(); - } else if (status === 'running') { - statusTimeout = setTimeout(function() { - var s = queryInstallerStatus(); - if (statusCount === 12) { // 1 minute hard cap - s = 'fail'; - } - - if (s === 'continue') { - refreshRequested = false; - doRefresh(); - clearTimeout(statusTimeout); - } else if (s === 'fail') { - addMessage('error', - [{ - title: installLang.title, - description: installLang.msg - }] - ); - clearTimeout(statusTimeout); - } - - statusCount++; - }, - 5000 - ); - } else { - addMessage('error', - [{ - title: installLang.title, - description: installLang.msg - }] - ); - } + queryInstallerStatus(); } } } @@ -600,18 +610,4 @@ submitForm($form, $(this)); }); } - - /** - * Queries the installer's status - */ - function queryInstallerStatus() - { - var data = null; - $.ajax({url: "../installer/status", dataType: "json"}) - .done(function(d) { - data = d; - }); - - return data.status; - } })(jQuery); // Avoid conflicts with other libraries |