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 var loadingIndicatorShuffle = updateLoadingIndicator(); |
13 isLastPage ? 'hidden' : 'visible'; | 13 if (isLastPage) { |
14 document.getElementById('loadingIndicator').className ='hidden'; | |
15 loadingIndicatorShuffle(false); | |
16 } else { | |
17 loadingIndicatorShuffle(true); | |
18 document.getElementById('loadingIndicator').className ='visible'; | |
19 } | |
14 } | 20 } |
15 | 21 |
16 // Maps JS theme to CSS class and then changes body class name. | 22 // Maps JS theme to CSS class and then changes body class name. |
17 // CSS classes must agree with distilledpage.css. | 23 // CSS classes must agree with distilledpage.css. |
18 function useTheme(theme) { | 24 function useTheme(theme) { |
19 var cssClass; | 25 var cssClass; |
20 if (theme == "sepia") { | 26 if (theme == "sepia") { |
21 cssClass = "sepia"; | 27 cssClass = "sepia"; |
22 } else if (theme == "dark") { | 28 } else if (theme == "dark") { |
23 cssClass = "dark"; | 29 cssClass = "dark"; |
24 } else { | 30 } else { |
25 cssClass = "light"; | 31 cssClass = "light"; |
26 } | 32 } |
27 document.body.className = cssClass; | 33 document.body.className = cssClass; |
28 } | 34 } |
35 | |
36 var updateLoadingIndicator = function() { | |
37 var colors = ["red", "yellow", "green", "blue"]; | |
38 return function(isNotLastPage) { | |
robliao
2014/08/07 21:53:04
If you inverted this to isLastPage, you can pass t
sunangel
2014/08/08 00:45:30
inverted it in function call above instead...is th
robliao
2014/08/08 17:22:30
Right. The point here is that this function can al
sunangel
2014/08/08 21:25:04
Wait hm okay sorry. The change I thought I made di
| |
39 if (isNotLastPage && typeof this.colorShuffle == "undefined") { | |
40 var loader = document.getElementById("loader"); | |
41 if (loader) { | |
42 var colorIndex = -1; | |
43 this.colorShuffle = setInterval(function() { | |
44 colorIndex = (colorIndex + 1) % colors.length; | |
45 loader.className = colors[colorIndex]; | |
46 }, 600); | |
47 } | |
48 } else if (!isNotLastPage && typeof this.colorShuffle != "undefined") { | |
49 clearInterval(this.colorShuffle); | |
50 } | |
51 }; | |
52 }; | |
robliao
2014/08/07 21:53:04
Don't forget to invoke it (note the () at the end
sunangel
2014/08/08 00:45:30
Done.
| |
OLD | NEW |