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 = createElementWithClassName('span', className); |
| 11 node.textContent = text; |
| 12 return node; |
| 13 } |
| 14 |
| 15 /** |
| 16 * Callback from the backend with the information of a WebAPK to display. |
| 17 * This will be called once for each WebAPK available on the device and each |
| 18 * one will be appended at the end of the other. |
| 19 */ |
| 20 function returnWebApksInfo(webApksList) { |
| 21 for (const i in webApksList) { |
| 22 addWebApk(webApksList[i]); |
| 23 } |
| 24 } |
| 25 |
| 26 function addWebApk(webApkInfo) { |
| 27 var webApksList = $('webapks-list'); |
| 28 |
| 29 webApksList.appendChild(document.createElement('br')); |
| 30 webApksList.appendChild(document.createElement('br')); |
| 31 webApksList.appendChild( |
| 32 createTextElementWithClassName(webApkInfo.shortName, 'app-name')); |
| 33 |
| 34 webApksList.appendChild(document.createElement('br')); |
| 35 webApksList.appendChild( |
| 36 createTextElementWithClassName('Package name: ', 'app-property-label')); |
| 37 webApksList.appendChild(document.createTextNode(webApkInfo.packageName)); |
| 38 |
| 39 webApksList.appendChild(document.createElement('br')); |
| 40 webApksList.appendChild(createTextElementWithClassName( |
| 41 'Shell APK version: ', 'app-property-label')); |
| 42 webApksList.appendChild(document.createTextNode(webApkInfo.shellApkVersion)); |
| 43 |
| 44 webApksList.appendChild(document.createElement('br')); |
| 45 webApksList.appendChild( |
| 46 createTextElementWithClassName('Version code: ', 'app-property-label')); |
| 47 webApksList.appendChild(document.createTextNode(webApkInfo.versionCode)); |
| 48 } |
| 49 |
| 50 /* All the work we do onload. */ |
| 51 function onLoadWork() { |
| 52 chrome.send('requestWebApksInfo'); |
| 53 } |
| 54 |
| 55 document.addEventListener('DOMContentLoaded', onLoadWork); |
OLD | NEW |