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

Side by Side Diff: chrome/browser/resources/sessions.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/policy.js ('k') | chrome/browser/resources/sync_setup_overlay.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) 2011 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 localStrings = new LocalStrings(); 5 localStrings = new LocalStrings();
6 6
7 // UTF8 sequence for an arrow triangle pointing down. 7 // UTF8 sequence for an arrow triangle pointing down.
8 kExpandedArrow = "\u25BE"; 8 kExpandedArrow = '\u25BE';
9 // UTF8 sequence for an arrow triangle pointing right. 9 // UTF8 sequence for an arrow triangle pointing right.
10 kCollapsedArrow = "\u25B8"; 10 kCollapsedArrow = '\u25B8';
11 11
12 /** 12 /**
13 * Requests the list of sessions from the backend. 13 * Requests the list of sessions from the backend.
14 */ 14 */
15 function requestSessions() { 15 function requestSessions() {
16 chrome.send('requestSessionList', []) 16 chrome.send('requestSessionList');
17 } 17 }
18 18
19 /** 19 /**
20 * Expands or collapses the specified list. 20 * Expands or collapses the specified list.
21 */ 21 */
22 function toggleExpandedState(div) { 22 function toggleExpandedState(div) {
23 if (div.textContent.indexOf(kExpandedArrow) != -1) { 23 if (div.textContent.indexOf(kExpandedArrow) != -1) {
24 div.textContent = div.textContent.replace(kExpandedArrow, kCollapsedArrow); 24 div.textContent = div.textContent.replace(kExpandedArrow, kCollapsedArrow);
25 div.parentNode.querySelector(".indent").hidden = true; 25 div.parentNode.querySelector('.indent').hidden = true;
26 } else { 26 } else {
27 div.textContent = div.textContent.replace(kCollapsedArrow, kExpandedArrow); 27 div.textContent = div.textContent.replace(kCollapsedArrow, kExpandedArrow);
28 div.parentNode.querySelector(".indent").hidden = false; 28 div.parentNode.querySelector('.indent').hidden = false;
29 } 29 }
30 } 30 }
31 31
32 /** 32 /**
33 * Creates a div element to serve as an expandable/collapsable 33 * Creates a div element to serve as an expandable/collapsable
34 * title for a list of windows or tabs. 34 * title for a list of windows or tabs.
35 */ 35 */
36 function createTitleDiv(className, textContent) { 36 function createTitleDiv(className, textContent) {
37 var div = document.createElement('div'); 37 var div = document.createElement('div');
38 div.className = className + ' expandable'; 38 div.className = className + ' expandable';
(...skipping 25 matching lines...) Expand all
64 tabItem.className = 'tab-link'; 64 tabItem.className = 'tab-link';
65 tabItem.style.backgroundImage = url('chrome://favicon/' + tab.url); 65 tabItem.style.backgroundImage = url('chrome://favicon/' + tab.url);
66 return tabItem; 66 return tabItem;
67 } 67 }
68 68
69 /** 69 /**
70 * Transforms a window into an HTML element. 70 * Transforms a window into an HTML element.
71 */ 71 */
72 function transformWindow(window) { 72 function transformWindow(window) {
73 var windowDiv = document.createElement('div'); 73 var windowDiv = document.createElement('div');
74 windowDiv.className = "window"; 74 windowDiv.className = 'window';
75 windowDiv.appendChild(createTitleDiv('window-title', 'Window')); 75 windowDiv.appendChild(createTitleDiv('window-title', 'Window'));
76 addItems(windowDiv, window.tabs, transformTab); 76 addItems(windowDiv, window.tabs, transformTab);
77 return windowDiv; 77 return windowDiv;
78 } 78 }
79 79
80 /** 80 /**
81 * Transforms a session into an HTML element. 81 * Transforms a session into an HTML element.
82 */ 82 */
83 function transformSession(session) { 83 function transformSession(session) {
84 var sessionDiv = document.createElement('div'); 84 var sessionDiv = document.createElement('div');
85 var sessionName = session.name.length == 0 ? 'Session' : session.name; 85 var sessionName = session.name.length == 0 ? 'Session' : session.name;
86 sessionDiv.className = "session"; 86 sessionDiv.className = 'session';
87 sessionDiv.appendChild(createTitleDiv('session-title', sessionName)); 87 sessionDiv.appendChild(createTitleDiv('session-title', sessionName));
88 addItems(sessionDiv, session.windows, transformWindow); 88 addItems(sessionDiv, session.windows, transformWindow);
89 return sessionDiv; 89 return sessionDiv;
90 } 90 }
91 91
92 /** 92 /**
93 * Creates the UI for the sessions tree. 93 * Creates the UI for the sessions tree.
94 */ 94 */
95 function createSessionTreeUI(sessionList) { 95 function createSessionTreeUI(sessionList) {
96 $('sessions-summary-text').textContent = 96 $('sessions-summary-text').textContent =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 * Callback from backend with the list of sessions. Builds the UI. 131 * Callback from backend with the list of sessions. Builds the UI.
132 * @param {array} sessionList The list of sessions. 132 * @param {array} sessionList The list of sessions.
133 * @param {array} magicList List of "interesting" tabs. 133 * @param {array} magicList List of "interesting" tabs.
134 */ 134 */
135 function updateSessionList(sessionList, magicList) { 135 function updateSessionList(sessionList, magicList) {
136 createSessionTreeUI(sessionList); 136 createSessionTreeUI(sessionList);
137 createMagicListUI(magicList); 137 createMagicListUI(magicList);
138 } 138 }
139 139
140 document.addEventListener('DOMContentLoaded', requestSessions); 140 document.addEventListener('DOMContentLoaded', requestSessions);
OLDNEW
« no previous file with comments | « chrome/browser/resources/policy.js ('k') | chrome/browser/resources/sync_setup_overlay.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698