Index: chrome/browser/resources/translate_internals/index.js |
diff --git a/chrome/browser/resources/translate_internals/index.js b/chrome/browser/resources/translate_internals/index.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3e2a61d3ee61b49b6df15a943f932004090db119 |
--- /dev/null |
+++ b/chrome/browser/resources/translate_internals/index.js |
@@ -0,0 +1,55 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+(function() { |
+ 'use strict'; |
+ |
+ cr.define('cr.translateInternals', function() { |
+ |
+ function initialize() { |
+ cr.ui.decorate('tabbox', cr.ui.TabBox); |
+ chrome.send('requestInfo'); |
+ } |
+ |
+ function escapeHTML(str) { |
+ return str.replace(/&/g, '&').replace(/</g, '<'). |
+ replace(/>/g, '>').replace(/"/g, '"'); |
+ } |
+ |
+ function onPrefsUpdated(detail) { |
+ console.log(detail); |
Evan Stade
2013/04/12 16:02:25
you probably shouldn't put logs in, but if you do
hajimehoshi
2013/04/15 04:01:49
I used just for debugging, and forget to remove it
|
+ var pre = $('tabpanelPrefs').querySelector('pre'); |
+ var content = JSON.stringify(detail, null, 2); |
+ pre.innerHTML = escapeHTML(content); |
Evan Stade
2013/04/12 16:02:25
why don't you just use textContent = ?
hajimehoshi
2013/04/15 04:01:49
Done.
|
+ } |
+ |
+ /** |
+ * The callback entry point from the browser. |
+ * This function will be called by the browser. |
Evan Stade
2013/04/12 16:02:25
there's a style for js documentation which involve
hajimehoshi
2013/04/15 04:01:49
Done.
|
+ */ |
+ function messageHandler(message, detail) { |
+ switch (message) { |
+ case 'prefsUpdated': |
+ cr.translateInternals.onPrefsUpdated(detail); |
+ break; |
+ default: |
+ console.error('Unknown message:', message); |
Evan Stade
2013/04/12 16:02:25
nit: space after :
hajimehoshi
2013/04/15 04:01:49
console.error adds space between the arugments, do
Evan Stade
2013/04/15 19:25:13
oh, so it does.
|
+ break; |
+ } |
+ } |
+ |
+ return { |
+ initialize: initialize, |
+ messageHandler: messageHandler, |
+ onPrefsUpdated: onPrefsUpdated |
+ }; |
+ }); |
+ |
+ function main() { |
+ cr.doc.addEventListener('DOMContentLoaded', |
+ cr.translateInternals.initialize); |
+ } |
+ |
+ main(); |
+})(); |