diff options
Diffstat (limited to 'phpBB/assets/javascript/installer.js')
-rw-r--r-- | phpBB/assets/javascript/installer.js | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/phpBB/assets/javascript/installer.js b/phpBB/assets/javascript/installer.js index c5909556c6..d9f446a28d 100644 --- a/phpBB/assets/javascript/installer.js +++ b/phpBB/assets/javascript/installer.js @@ -12,6 +12,7 @@ var progressTimer = null; var currentProgress = 0; var refreshRequested = false; + var transmissionOver = false; // Template related variables var $contentWrapper = $('.install-body').find('.main'); @@ -177,7 +178,7 @@ * @param progressObject */ function setProgress(progressObject) { - var $statusText, $progressBar, $progressText, $progressFiller; + var $statusText, $progressBar, $progressText, $progressFiller, $progressFillerText; if (progressObject.task_name.length) { if (!progressBarTriggered) { @@ -189,27 +190,34 @@ $progressBar.attr('id', 'progress-bar'); $progressText = $('<p />'); $progressText.attr('id', 'progress-bar-text'); - $progressFiller = $('<span />'); + $progressFiller = $('<div />'); $progressFiller.attr('id', 'progress-bar-filler'); - $progressFiller.html($progressText); + $progressFillerText = $('<p />'); + $progressFillerText.attr('id', 'progress-bar-filler-text'); $statusText = $('<p />'); $statusText.attr('id', 'progress-status-text'); + $progressFiller.append($progressFillerText); + $progressBar.append($progressText); $progressBar.append($progressFiller); $progressBarWrapper.append($statusText); $progressBarWrapper.append($progressBar); + $progressFillerText.css('width', $progressBar.width()); + progressBarTriggered = true; } else if (progressObject.hasOwnProperty('restart')) { clearInterval(progressTimer); $progressFiller = $('#progress-bar-filler'); + $progressFillerText = $('#progress-bar-filler-text'); $progressText = $('#progress-bar-text'); $statusText = $('#progress-status-text'); $progressText.text('0%'); + $progressFillerText.text('0%'); $progressFiller.css('width', '0%'); currentProgress = 0; @@ -236,6 +244,22 @@ } } + // Redirects user + function redirect(url, use_ajax) { + if (use_ajax) { + resetPolling(); + + var xhReq = createXhrObject(); + xhReq.open('GET', url, true); + xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); + xhReq.send(); + + startPolling(xhReq); + } else { + window.location.href = url; + } + } + /** * Parse messages from the response object * @@ -302,6 +326,16 @@ if (responseObject.hasOwnProperty('refresh')) { refreshRequested = true; } + + if (responseObject.hasOwnProperty('redirect')) { + redirect(responseObject.redirect.url, responseObject.redirect.use_ajax); + } + + if (responseObject.hasOwnProperty('over')) { + if (responseObject.over) { + transmissionOver = true; + } + } } /** @@ -330,10 +364,21 @@ $('#loading_indicator').css('display', 'none'); resetPolling(); + var timeoutDetected = !transmissionOver; + if (refreshRequested) { refreshRequested = false; doRefresh(); } + + if (timeoutDetected) { + addMessage('error', + [{ + title: installLang.title, + description: installLang.msg + }] + ); + } } } @@ -342,15 +387,20 @@ * * @param $progressText * @param $progressFiller + * @param $progressFillerText * @param progressLimit */ - function incrementFiller($progressText, $progressFiller, progressLimit) { + function incrementFiller($progressText, $progressFiller, $progressFillerText, progressLimit) { if (currentProgress >= progressLimit || currentProgress >= 100) { clearInterval(progressTimer); return; } + var $progressBar = $('#progress-bar'); + currentProgress++; + $progressFillerText.css('width', $progressBar.width()); + $progressFillerText.text(currentProgress + '%'); $progressText.text(currentProgress + '%'); $progressFiller.css('width', currentProgress + '%'); } @@ -362,13 +412,14 @@ */ function incrementProgressBar(progressLimit) { var $progressFiller = $('#progress-bar-filler'); + var $progressFillerText = $('#progress-bar-filler-text'); var $progressText = $('#progress-bar-text'); var progressStart = $progressFiller.width() / $progressFiller.offsetParent().width() * 100; currentProgress = Math.floor(progressStart); clearInterval(progressTimer); progressTimer = setInterval(function() { - incrementFiller($progressText, $progressFiller, progressLimit); + incrementFiller($progressText, $progressFiller, $progressFillerText, progressLimit); }, 10); } @@ -387,6 +438,7 @@ */ function startPolling(xhReq) { resetPolling(); + transmissionOver = false; pollTimer = setInterval(function () { pollContent(xhReq); }, 250); |