OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017 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 /** |
| 6 * Creates and returns a node (with |text| as content) assigning it the |
| 7 * |className| class. |
| 8 */ |
| 9 function createTextElementWithClassName(text, className) { |
| 10 var node = document.createElement('span'); |
| 11 node.textContent = text; |
| 12 node.className = className; |
| 13 return node; |
| 14 } |
| 15 |
| 16 /** |
| 17 * Callback from the backend with the information of a WebAPK to display. |
| 18 * This will be called once for each WebAPK available on the device and each |
| 19 * one will be appended at the end of the other. |
| 20 */ |
| 21 function returnWebApksInfo(appName, packageName, shellApkVersion, versionCode) { |
| 22 var webApksList = $('webapks-list'); |
| 23 |
| 24 webApksList.appendChild(document.createElement("BR")); |
| 25 webApksList.appendChild(document.createElement("BR")); |
| 26 webApksList.appendChild(createTextElementWithClassName(appName, "app-name")); |
| 27 |
| 28 webApksList.appendChild(document.createElement("BR")); |
| 29 webApksList.appendChild(createTextElementWithClassName( |
| 30 loadTimeData.getString('packageName'), "app-property-label")); |
| 31 webApksList.appendChild(document.createTextNode(packageName)); |
| 32 |
| 33 webApksList.appendChild(document.createElement("BR")); |
| 34 webApksList.appendChild(createTextElementWithClassName( |
| 35 loadTimeData.getString('shellApkVersion'), "app-property-label")); |
| 36 webApksList.appendChild(document.createTextNode(shellApkVersion)); |
| 37 |
| 38 webApksList.appendChild(document.createElement("BR")); |
| 39 webApksList.appendChild(createTextElementWithClassName( |
| 40 loadTimeData.getString('versionCode'), "app-property-label")); |
| 41 webApksList.appendChild(document.createTextNode(versionCode)); |
| 42 } |
| 43 |
| 44 /* All the work we do onload. */ |
| 45 function onLoadWork() { |
| 46 chrome.send('requestWebApksInfo'); |
| 47 } |
| 48 |
| 49 document.addEventListener('DOMContentLoaded', onLoadWork); |
OLD | NEW |