installing.js (2002B)
1 // This Source Code Form is subject to the terms of the Mozilla Public 2 // License, v. 2.0. If a copy of the MPL was not distributed with this 3 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 // Length of time (milliseconds) that one blurb stays up before we switch to 6 // displaying the next one. 7 var BLURB_CYCLE_MS = 20000; 8 9 // How frequently we should update the progress bar state, in milliseconds. 10 var PROGRESS_BAR_INTERVAL_MS = 250; 11 12 window.attachEvent("onload", function () { 13 // Set direction on the page body. 14 var direction = external.getTextDirection(); 15 document.body.style.direction = direction; 16 17 // Get this page's static strings. 18 var label = document.getElementById("label"); 19 label.innerText = external.getUIString("installing_label"); 20 21 // Poll and update the progress bar percentage. 22 setInterval(function () { 23 var percent = external.getProgressBarPercent(); 24 var progressBar = document.getElementById("progress_bar"); 25 progressBar.setAttribute("aria-valuenow", percent); 26 progressBar.style.width = percent + "%"; 27 }, PROGRESS_BAR_INTERVAL_MS); 28 29 // Get the blurb strings and initialize the blurb rotation. 30 var currentBlurb = 0; 31 // IE8 adds undefined to the array if there is a trailing comma in an 32 // array literal, so don't allow prettier to add one here. 33 // prettier-ignore 34 var blurbStrings = [ 35 external.getUIString("installing_blurb_0"), 36 external.getUIString("installing_blurb_1"), 37 external.getUIString("installing_blurb_2") 38 ]; 39 function rotateBlurb() { 40 document.getElementById("blurb").innerText = blurbStrings[currentBlurb]; 41 currentBlurb = (currentBlurb + 1) % blurbStrings.length; 42 } 43 rotateBlurb(); 44 setInterval(rotateBlurb, BLURB_CYCLE_MS); 45 46 // Focus the label, in order to get the focus in the web page, to 47 // assist screen readers. On Win 7's IE8 this causes the focus rectangle 48 // to be immediately visible, so also hide that here. 49 label.className += " no-focus-outline"; 50 label.focus(); 51 });