1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 function addToPage(html) {
6 var div = document.createElement('div');
8 document.getElementById('content').appendChild(div);
11 function showLoadingIndicator(isLastPage) {
12 document.getElementById('loadingIndicator').className =
13 isLastPage ? 'hidden' : 'visible';
14 updateLoadingIndicator(isLastPage);
17 // Maps JS Font Family to CSS class and then changes body class name.
18 // CSS classes must agree with distilledpage.css.
19 function useFontFamily(fontFamily) {
21 if (fontFamily == "serif") {
23 } else if (fontFamily == "monospace") {
24 cssClass = "monospace";
26 cssClass = "sans-serif";
28 // Relies on the classname order of the body being Theme class, then Font
30 var themeClass = document.body.className.split(" ")[0];
31 document.body.className = themeClass + " " + cssClass;
34 // Maps JS theme to CSS class and then changes body class name.
35 // CSS classes must agree with distilledpage.css.
36 function useTheme(theme) {
38 if (theme == "sepia") {
40 } else if (theme == "dark") {
45 // Relies on the classname order of the body being Theme class, then Font
47 var fontFamilyClass = document.body.className.split(" ")[1];
48 document.body.className = cssClass + " " + fontFamilyClass;
51 var updateLoadingIndicator = function() {
52 var colors = ["red", "yellow", "green", "blue"];
53 return function(isLastPage) {
54 if (!isLastPage && typeof this.colorShuffle == "undefined") {
55 var loader = document.getElementById("loader");
58 this.colorShuffle = setInterval(function() {
59 colorIndex = (colorIndex + 1) % colors.length;
60 loader.className = colors[colorIndex];
63 } else if (isLastPage && typeof this.colorShuffle != "undefined") {
64 clearInterval(this.colorShuffle);