ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / components / dom_distiller / core / javascript / dom_distiller_viewer.js
blob55f53bbf3854feaebdf305bed92df2acce7a9ef2
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');
7 div.innerHTML = html;
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) {
20 var cssClass;
21 if (fontFamily == "serif") {
22 cssClass = "serif";
23 } else if (fontFamily == "monospace") {
24 cssClass = "monospace";
25 } else {
26 cssClass = "sans-serif";
28 // Relies on the classname order of the body being Theme class, then Font
29 // Family class.
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) {
37 var cssClass;
38 if (theme == "sepia") {
39 cssClass = "sepia";
40 } else if (theme == "dark") {
41 cssClass = "dark";
42 } else {
43 cssClass = "light";
45 // Relies on the classname order of the body being Theme class, then Font
46 // Family class.
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");
56 if (loader) {
57 var colorIndex = -1;
58 this.colorShuffle = setInterval(function() {
59 colorIndex = (colorIndex + 1) % colors.length;
60 loader.className = colors[colorIndex];
61 }, 600);
63 } else if (isLastPage && typeof this.colorShuffle != "undefined") {
64 clearInterval(this.colorShuffle);
67 }();
69 // Add a listener to the "View Original" link to report opt-outs.
70 document.getElementById('showOriginal').addEventListener('click', function(e) {
71 var img = document.createElement('img');
72 img.src = "/vieworiginal";
73 img.style.display = "none";
74 document.body.appendChild(img);
75 }, true);