OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function addToPage(html) { | 5 function addToPage(html) { |
6 var div = document.createElement('div'); | 6 var div = document.createElement('div'); |
7 div.innerHTML = html; | 7 div.innerHTML = html; |
8 document.getElementById('content').appendChild(div); | 8 document.getElementById('content').appendChild(div); |
9 } | 9 } |
10 | 10 |
11 function showLoadingIndicator(isLastPage) { | 11 function showLoadingIndicator(isLastPage) { |
12 document.getElementById('loadingIndicator').className = | 12 if (isLastPage) { |
nyquist
2014/08/11 20:47:05
Could this just be something short like this?
d
sunangel
2014/08/12 01:56:08
I think it would be better if it were ordered like
nyquist
2014/08/12 22:04:32
AFAIK the interval only triggers after 600 ms, and
sunangel
2014/08/12 23:17:55
Done.
| |
13 isLastPage ? 'hidden' : 'visible'; | 13 document.getElementById('loadingIndicator').className ='hidden'; |
14 updateLoadingIndicator(isLastPage); | |
15 } else { | |
16 updateLoadingIndicator(isLastPage); | |
17 document.getElementById('loadingIndicator').className ='visible'; | |
18 } | |
14 } | 19 } |
15 | 20 |
16 // Maps JS theme to CSS class and then changes body class name. | 21 // Maps JS theme to CSS class and then changes body class name. |
17 // CSS classes must agree with distilledpage.css. | 22 // CSS classes must agree with distilledpage.css. |
18 function useTheme(theme) { | 23 function useTheme(theme) { |
19 var cssClass; | 24 var cssClass; |
20 if (theme == "sepia") { | 25 if (theme == "sepia") { |
21 cssClass = "sepia"; | 26 cssClass = "sepia"; |
22 } else if (theme == "dark") { | 27 } else if (theme == "dark") { |
23 cssClass = "dark"; | 28 cssClass = "dark"; |
24 } else { | 29 } else { |
25 cssClass = "light"; | 30 cssClass = "light"; |
26 } | 31 } |
27 document.body.className = cssClass; | 32 document.body.className = cssClass; |
28 } | 33 } |
34 | |
35 var updateLoadingIndicator = function() { | |
36 var colors = ["red", "yellow", "green", "blue"]; | |
37 return function(isLastPage) { | |
38 if (!isLastPage && typeof this.colorShuffle == "undefined") { | |
39 var loader = document.getElementById("loader"); | |
40 if (loader) { | |
41 var colorIndex = -1; | |
42 this.colorShuffle = setInterval(function() { | |
43 colorIndex = (colorIndex + 1) % colors.length; | |
nyquist
2014/08/12 22:04:32
I think these two lines are missing indentation.
sunangel
2014/08/12 23:17:55
Done.
| |
44 loader.className = colors[colorIndex]; | |
45 }, 600); | |
46 } | |
47 } else if (isLastPage && typeof this.colorShuffle != "undefined") { | |
48 clearInterval(this.colorShuffle); | |
49 } | |
50 }; | |
51 }(); | |
OLD | NEW |