Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 highlightIfChanged(node, oldVal, newVal) { | 5 function highlightIfChanged(node, oldVal, newVal) { |
| 6 function clearHighlight() { | 6 function clearHighlight() { |
| 7 this.removeAttribute('highlighted'); | 7 this.removeAttribute('highlighted'); |
| 8 } | 8 } |
| 9 | 9 |
| 10 var oldStr = oldVal.toString(); | 10 var oldStr = oldVal.toString(); |
| 11 var newStr = newVal.toString(); | 11 var newStr = newVal.toString(); |
| 12 if (oldStr != '' && oldStr != newStr) { | 12 if (oldStr != '' && oldStr != newStr) { |
| 13 // Note the addListener function does not end up creating duplicate | 13 // Note the addListener function does not end up creating duplicate |
| 14 // listeners. There can be only one listener per event at a time. | 14 // listeners. There can be only one listener per event at a time. |
| 15 // Reference: https://developer.mozilla.org/en/DOM/element.addEventListener | 15 // Reference: https://developer.mozilla.org/en/DOM/element.addEventListener |
| 16 node.addEventListener('webkitAnimationEnd', clearHighlight, false); | 16 node.addEventListener('webkitAnimationEnd', clearHighlight, false); |
| 17 node.setAttribute('highlighted', ''); | 17 node.setAttribute('highlighted', ''); |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 (function() { | 21 (function() { |
| 22 // Contains the latest snapshot of sync about info. | 22 // Contains the latest snapshot of sync about info. |
| 23 chrome.sync.aboutInfo = {}; | 23 chrome.sync.aboutInfo = {}; |
| 24 | 24 |
| 25 // TODO(akalin): Make aboutInfo have key names likeThis and not | |
| 26 // like_this. | |
| 27 function refreshAboutInfo(aboutInfo) { | 25 function refreshAboutInfo(aboutInfo) { |
| 28 chrome.sync.aboutInfo = aboutInfo; | 26 chrome.sync.aboutInfo = aboutInfo; |
| 29 var aboutInfoDiv = $('aboutInfo'); | 27 var aboutInfoDiv = $('aboutInfo'); |
| 30 jstProcess(new JsEvalContext(aboutInfo), aboutInfoDiv); | 28 jstProcess(new JsEvalContext(aboutInfo), aboutInfoDiv); |
| 31 } | 29 } |
| 32 | 30 |
| 31 function onAboutInfoUpdatedEvent(e) { | |
| 32 var aboutInfo = e.details; | |
| 33 refreshAboutInfo(aboutInfo); | |
|
Dan Beam
2014/02/13 22:32:45
nit: refreshAboutInfo(e.details);
rlarocque
2014/02/13 23:34:30
Done.
| |
| 34 } | |
| 35 | |
| 33 function onLoad() { | 36 function onLoad() { |
| 34 $('status-data').hidden = true; | 37 $('status-data').hidden = true; |
| 35 chrome.sync.getAboutInfo(refreshAboutInfo); | |
| 36 | 38 |
| 37 chrome.sync.events.addEventListener( | 39 chrome.sync.events.addEventListener( |
| 38 'onServiceStateChanged', | 40 'onAboutInfoUpdated', |
| 39 function(e) { | 41 onAboutInfoUpdatedEvent); |
| 40 chrome.sync.getAboutInfo(refreshAboutInfo); | 42 chrome.sync.requestUpdatedAboutInfo(); |
| 41 }); | |
| 42 | 43 |
| 43 var dumpStatusButton = $('dump-status'); | 44 var dumpStatusButton = $('dump-status'); |
| 44 dumpStatusButton.addEventListener('click', function(event) { | 45 dumpStatusButton.addEventListener('click', function(event) { |
| 45 var aboutInfo = chrome.sync.aboutInfo; | 46 var aboutInfo = chrome.sync.aboutInfo; |
| 46 if (!$('include-ids').checked) { | 47 if (!$('include-ids').checked) { |
| 47 aboutInfo.details = chrome.sync.aboutInfo.details.filter(function(el) { | 48 aboutInfo.details = chrome.sync.aboutInfo.details.filter(function(el) { |
| 48 return !el.is_sensitive; | 49 return !el.is_sensitive; |
| 49 }); | 50 }); |
| 50 } | 51 } |
| 51 var data = ''; | 52 var data = ''; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 71 var data = $('status-text').value; | 72 var data = $('status-text').value; |
| 72 var firstBrace = data.indexOf('{'); | 73 var firstBrace = data.indexOf('{'); |
| 73 if (firstBrace < 0) { | 74 if (firstBrace < 0) { |
| 74 $('status-text').value = 'Invalid sync status dump.'; | 75 $('status-text').value = 'Invalid sync status dump.'; |
| 75 return; | 76 return; |
| 76 } | 77 } |
| 77 data = data.substr(firstBrace); | 78 data = data.substr(firstBrace); |
| 78 | 79 |
| 79 // Remove listeners to prevent sync events from overwriting imported data. | 80 // Remove listeners to prevent sync events from overwriting imported data. |
| 80 chrome.sync.events.removeEventListener( | 81 chrome.sync.events.removeEventListener( |
| 81 'onServiceStateChanged', | 82 'onAboutInfoUpdated', |
| 82 refreshAboutInfo); | 83 onAboutInfoUpdatedEvent); |
| 83 | 84 |
| 84 var aboutInfo = JSON.parse(data); | 85 var aboutInfo = JSON.parse(data); |
| 85 refreshAboutInfo(aboutInfo); | 86 refreshAboutInfo(aboutInfo); |
| 86 }); | 87 }); |
| 87 } | 88 } |
| 88 | 89 |
| 89 document.addEventListener('DOMContentLoaded', onLoad, false); | 90 document.addEventListener('DOMContentLoaded', onLoad, false); |
| 90 })(); | 91 })(); |
| OLD | NEW |