Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: chrome/browser/resources/certificate_viewer.js

Issue 10010019: JS style nits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: couple more Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/about_stats.js ('k') | chrome/browser/resources/crashes.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('cert_viewer', function() { 5 cr.define('cert_viewer', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Initialize the certificate viewer dialog by wiring up the close button, 9 * Initialize the certificate viewer dialog by wiring up the close button,
10 * substituting in translated strings and requesting certificate details. 10 * substituting in translated strings and requesting certificate details.
11 */ 11 */
12 function initialize() { 12 function initialize() {
13 $('export').onclick = exportCertificate; 13 $('export').onclick = exportCertificate;
14 cr.ui.decorate('tabbox', cr.ui.TabBox); 14 cr.ui.decorate('tabbox', cr.ui.TabBox);
15 15
16 initializeTree($('hierarchy'), showCertificateFields); 16 initializeTree($('hierarchy'), showCertificateFields);
17 initializeTree($('cert-fields'), showCertificateFieldValue); 17 initializeTree($('cert-fields'), showCertificateFieldValue);
18 18
19 i18nTemplate.process(document, templateData); 19 i18nTemplate.process(document, templateData);
20 stripGtkAccessorKeys(); 20 stripGtkAccessorKeys();
21 chrome.send('requestCertificateInfo'); 21 chrome.send('requestCertificateInfo');
22 // TODO(kochi): ESC key should be handled in the views window side. 22 // TODO(kochi): ESC key should be handled in the views window side.
23 document.addEventListener('keydown', function(e) { 23 document.addEventListener('keydown', function(e) {
24 if (e.keyCode == 27) { // ESC 24 if (e.keyCode == 27) // ESC
25 chrome.send('DialogClose'); 25 chrome.send('DialogClose');
26 }
27 }); 26 });
28 } 27 }
29 28
30 /** 29 /**
31 * Initialize a cr.ui.Tree object from a given element using the specified 30 * Initialize a cr.ui.Tree object from a given element using the specified
32 * change handler. 31 * change handler.
33 * @param {HTMLElement} tree The HTMLElement to style as a tree. 32 * @param {HTMLElement} tree The HTMLElement to style as a tree.
34 * @param {function()} handler Function to call when a node is selected. 33 * @param {function()} handler Function to call when a node is selected.
35 */ 34 */
36 function initializeTree(tree, handler) { 35 function initializeTree(tree, handler) {
37 cr.ui.decorate(tree, cr.ui.Tree); 36 cr.ui.decorate(tree, cr.ui.Tree);
38 tree.detail = {payload: {}, children: {}}; 37 tree.detail = {payload: {}, children: {}};
39 tree.addEventListener('change', handler); 38 tree.addEventListener('change', handler);
40 } 39 }
41 40
42 /** 41 /**
43 * The tab name strings in the languages file have accessor keys indicated 42 * The tab name strings in the languages file have accessor keys indicated
44 * by a preceding & sign. Strip these out for now. 43 * by a preceding & sign. Strip these out for now.
45 * @TODO(flackr) These accessor keys could be implemented with Javascript or 44 * TODO(flackr) These accessor keys could be implemented with Javascript or
46 * translated strings could be added / modified to remove the & sign. 45 * translated strings could be added / modified to remove the & sign.
47 */ 46 */
48 function stripGtkAccessorKeys() { 47 function stripGtkAccessorKeys() {
49 // Copy all the tab labels into an array. 48 // Copy all the tab labels into an array.
50 var nodes = Array.prototype.slice.call($('tabs').childNodes, 0); 49 var nodes = Array.prototype.slice.call($('tabs').childNodes, 0);
51 nodes.push($('export')); 50 nodes.push($('export'));
52 for (var i = 0; i < nodes.length; i++) 51 for (var i = 0; i < nodes.length; i++)
53 nodes[i].textContent = nodes[i].textContent.replace('&',''); 52 nodes[i].textContent = nodes[i].textContent.replace('&', '');
54 } 53 }
55 54
56 /** 55 /**
57 * Expand all nodes of the given tree object. 56 * Expand all nodes of the given tree object.
58 * @param {cr.ui.Tree} tree The tree object to expand all nodes on. 57 * @param {cr.ui.Tree} tree The tree object to expand all nodes on.
59 */ 58 */
60 function revealTree(tree) { 59 function revealTree(tree) {
61 tree.expanded = true; 60 tree.expanded = true;
62 for (var key in tree.detail.children) { 61 for (var key in tree.detail.children) {
63 revealTree(tree.detail.children[key]); 62 revealTree(tree.detail.children[key]);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 172 }
174 173
175 return { 174 return {
176 initialize: initialize, 175 initialize: initialize,
177 getCertificateInfo: getCertificateInfo, 176 getCertificateInfo: getCertificateInfo,
178 getCertificateFields: getCertificateFields, 177 getCertificateFields: getCertificateFields,
179 }; 178 };
180 }); 179 });
181 180
182 document.addEventListener('DOMContentLoaded', cert_viewer.initialize); 181 document.addEventListener('DOMContentLoaded', cert_viewer.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/resources/about_stats.js ('k') | chrome/browser/resources/crashes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698