OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 cr.define('extension_activity', function() { | |
6 'use strict'; | |
7 | |
8 function initialize() { | |
9 var params = parseQueryParams(location); | |
10 if (params.extensionId) | |
11 chrome.send('requestExtensionData', [params.extensionId]); | |
12 } | |
13 | |
14 function handleExtensionData(result) { | |
15 var extension = result.extension; | |
16 | |
17 var item = document.querySelector('.extension-list-item'); | |
18 item.style.backgroundImage = 'url(' + extension.icon + ')'; | |
19 item.querySelector('.extension-title').textContent = extension.name; | |
20 item.querySelector('.extension-version').textContent = extension.version; | |
21 item.querySelector('.extension-description').textContent = | |
22 extension.description; | |
23 } | |
24 | |
25 function handleExtensionActivity(result) { | |
26 var template = $('template-collection'); | |
27 | |
28 // Clone the activity item template. | |
29 var item = | |
30 template.querySelector('.extension-activity-item').cloneNode(true); | |
31 item.querySelector('.extension-activity-time').textContent = | |
32 new Date().toLocaleTimeString(); | |
33 item.querySelector('.extension-activity-label').textContent = | |
34 template.querySelector('.extension-activity-label-' + result.activity) | |
35 .textContent; | |
36 | |
37 // Clone the message node and then delete the empty template. | |
38 var msgNode = item.querySelector('.extension-activity-message'); | |
39 for (var i = 0; i < result.messages.length; ++i) { | |
40 var newNode = msgNode.cloneNode(true); | |
41 newNode.textContent = result.messages[i]; | |
42 item.appendChild(newNode); | |
43 } | |
44 item.removeChild(msgNode); | |
45 | |
46 $('extension-activity-list').appendChild(item); | |
47 } | |
48 | |
49 return { | |
50 initialize: initialize, | |
51 handleExtensionData: handleExtensionData, | |
52 handleExtensionActivity: handleExtensionActivity | |
53 }; | |
54 }); | |
55 | |
56 window.addEventListener('load', extension_activity.initialize); | |
OLD | NEW |