-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathstandalone.js
32 lines (27 loc) · 949 Bytes
/
standalone.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview
* @suppress {globalThis|missingProperties}
*/
window.onload = function() {
const elements = document.querySelectorAll('[i18n]');
elements.forEach((ele) => {
const msgid = ele.getAttribute('i18n');
const msg = chrome.i18n.getMessage(msgid);
if (ele.type === 'button')
ele.value = msg;
else
ele.innerText = msg;
});
const acceptButton = document.querySelector('input#acceptButton');
acceptButton.addEventListener('click', (e) => window.close());
document.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === 'Escape')
acceptButton.click();
});
// Show the window once ready. Not available for tests.
if (chrome.app && chrome.app.window)
chrome.app.window.current().show();
};