OLD | NEW |
---|---|
(Empty) | |
1 <script> | |
2 (function () { | |
3 function updateNotificationsEnabledInfo(notificationsEnabled) { | |
4 var notificationsEnabledInfo = | |
5 document.getElementById('notificationsEnabledInfo'); | |
6 jstProcess( | |
7 new JsEvalContext({ 'notificationsEnabled': notificationsEnabled }), | |
8 notificationsEnabledInfo); | |
9 } | |
10 | |
11 function onLoad() { | |
12 chrome.sync.getNotificationState(updateNotificationsEnabledInfo); | |
13 chrome.sync.onSyncNotificationStateChange.addListener( | |
14 updateNotificationsEnabledInfo); | |
15 | |
16 var notificationCounts = {}; | |
17 chrome.sync.onSyncIncomingNotification.addListener(function(changedTypes) { | |
18 for (var i = 0; i < changedTypes.length; ++i) { | |
19 var changedType = changedTypes[i]; | |
20 notificationCounts[changedType] = notificationCounts[changedType] || 0; | |
21 ++notificationCounts[changedType]; | |
22 } | |
23 | |
24 var infos = []; | |
25 for (var k in notificationCounts) { | |
26 var info = { 'modelType': k, 'notificationCount': notificationCounts[k] }; | |
27 infos.push(info); | |
28 } | |
29 | |
30 var notificationCountsInfo = | |
31 document.getElementById('notificationCountsInfo'); | |
32 jstProcess(new JsEvalContext({ 'notificationCounts': infos }), | |
33 notificationCountsInfo); | |
34 }); | |
35 } | |
36 | |
37 document.addEventListener("DOMContentLoaded", onLoad, false); | |
38 })(); | |
39 </script> | |
40 | |
41 <div class="desc"><h2> Notifications </h2></div> | |
42 <p id='notificationsEnabledInfo'> | |
43 Enabled: <span jscontent='notificationsEnabled'></span> | |
44 </p> | |
45 | |
46 <table class='list' id='notificationCountsInfo'> | |
47 <tr jsselect='notificationCounts'> | |
John Gregg
2011/02/17 20:49:38
nit: be consistent with naming your jst variables
| |
48 <td class='name'> | |
49 <div jscontent='modelType'></div> | |
50 </td> | |
51 <td class='number'> | |
52 <div jscontent='notificationCount'></div> | |
53 </td> | |
54 </tr> | |
55 </table> | |
56 | |
OLD | NEW |