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 'use strict'; | |
6 | |
7 /** @suppress {duplicate} */ | |
8 var remoting = remoting || {}; | |
9 | |
10 /** | |
11 * @type {base.EventSourceImpl} An event source object for handling global | |
12 * events. This is an interim hack. Eventually, we should move | |
13 * functionalities away from the remoting namespace and into smaller objects. | |
14 */ | |
15 remoting.testEvents; | |
16 | |
17 /** | |
18 * Initialization tasks that are common to all remoting apps. | |
19 */ | |
20 remoting.initGlobalObjects = function() { | |
21 if (base.isAppsV2()) { | |
22 var htmlNode = /** @type {HTMLElement} */ (document.body.parentNode); | |
23 htmlNode.classList.add('apps-v2'); | |
24 } | |
25 | |
26 console.log(remoting.getExtensionInfo()); | |
27 l10n.localize(); | |
28 | |
29 remoting.formatIq = new remoting.FormatIq(); | |
30 | |
31 var sandbox = | |
32 /** @type {HTMLIFrameElement} */ (document.getElementById('wcs-sandbox')); | |
33 remoting.wcsSandbox = new remoting.WcsSandboxContainer(sandbox.contentWindow); | |
34 | |
35 remoting.initModalDialogs(); | |
36 | |
37 remoting.testEvents = new base.EventSourceImpl(); | |
38 /** @enum {string} */ | |
39 remoting.testEvents.Names = { | |
40 uiModeChanged: 'uiModeChanged' | |
41 }; | |
42 remoting.testEvents.defineEvents(base.values(remoting.testEvents.Names)); | |
43 }; | |
44 | |
45 /** | |
46 * @return {string} Information about the current extension. | |
47 */ | |
48 remoting.getExtensionInfo = function() { | |
49 var v2OrLegacy = base.isAppsV2() ? " (v2)" : " (legacy)"; | |
50 var manifest = chrome.runtime.getManifest(); | |
51 if (manifest && manifest.version) { | |
52 var name = remoting.app.getApplicationName(); | |
53 return name + ' version: ' + manifest.version + v2OrLegacy; | |
54 } else { | |
55 return 'Failed to get product version. Corrupt manifest?'; | |
56 } | |
57 }; | |
58 | |
59 /** | |
60 * Return the current time as a formatted string suitable for logging. | |
61 * | |
62 * @return {string} The current time, formatted as [mmdd/hhmmss.xyz] | |
63 */ | |
64 remoting.timestamp = function() { | |
65 /** | |
66 * @param {number} num A number. | |
67 * @param {number} len The required length of the answer. | |
68 * @return {string} The number, formatted as a string of the specified length | |
69 * by prepending zeroes as necessary. | |
70 */ | |
71 var pad = function(num, len) { | |
72 var result = num.toString(); | |
73 if (result.length < len) { | |
74 result = new Array(len - result.length + 1).join('0') + result; | |
75 } | |
76 return result; | |
77 }; | |
78 var now = new Date(); | |
79 var timestamp = pad(now.getMonth() + 1, 2) + pad(now.getDate(), 2) + '/' + | |
80 pad(now.getHours(), 2) + pad(now.getMinutes(), 2) + | |
81 pad(now.getSeconds(), 2) + '.' + pad(now.getMilliseconds(), 3); | |
82 return '[' + timestamp + ']'; | |
83 }; | |
OLD | NEW |