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(webApksList) { |
| 22 for (const i in webApksList) { |
| 23 addWebApk(webApksList[i]); |
| 24 } |
| 25 } |
| 26 |
| 27 function addWebApk(webApkInfo) { |
| 28 var webApksList = $('webapks-list'); |
| 29 |
| 30 webApksList.appendChild(document.createElement("BR")); |
| 31 webApksList.appendChild(document.createElement("BR")); |
| 32 webApksList.appendChild( |
| 33 createTextElementWithClassName(webApkInfo.shortName, "app-name")); |
| 34 |
| 35 webApksList.appendChild(document.createElement("BR")); |
| 36 webApksList.appendChild(createTextElementWithClassName( |
| 37 loadTimeData.getString('packageName'), "app-property-label")); |
| 38 webApksList.appendChild(document.createTextNode(webApkInfo.packageName)); |
| 39 |
| 40 webApksList.appendChild(document.createElement("BR")); |
| 41 webApksList.appendChild(createTextElementWithClassName( |
| 42 loadTimeData.getString('shellApkVersion'), "app-property-label")); |
| 43 webApksList.appendChild(document.createTextNode(webApkInfo.shellApkVersion)); |
| 44 |
| 45 webApksList.appendChild(document.createElement("BR")); |
| 46 webApksList.appendChild(createTextElementWithClassName( |
| 47 loadTimeData.getString('versionCode'), "app-property-label")); |
| 48 webApksList.appendChild(document.createTextNode(webApkInfo.versionCode)); |
| 49 } |
| 50 |
| 51 /* All the work we do onload. */ |
| 52 function onLoadWork() { |
| 53 chrome.send('requestWebApksInfo'); |
| 54 } |
| 55 |
| 56 document.addEventListener('DOMContentLoaded', onLoadWork); |
OLD | NEW |