Commit d8a58a0e authored by yoshiki@chromium.org's avatar yoshiki@chromium.org

[WebUI TaskManager] Fix JS check nits in chrome/browser/resources/task_manager.

TBR=mazda@chromium.org, tbreisacher@chromium.org
BUG=122009
TEST=manual

Review URL: https://chromiumcodereview.appspot.com/10095003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132374 0039d316-1c4b-4281-b951-d872f2087c98
parent 819863fa
......@@ -47,7 +47,6 @@ TaskManagerCommands = {
/**
* Sends command to enable or disable the given columns to update the data.
* @public
*/
setUpdateColumn: function(columnId, isEnabled) {
chrome.send('setUpdateColumn', [columnId, isEnabled]);
......
......@@ -12,8 +12,9 @@ var localStrings = new LocalStrings();
TaskManager.prototype = {
/**
* Handle window close.
* @this
*/
onClose: function () {
onClose: function() {
if (!this.disabled_) {
this.disabled_ = true;
commands.disableTaskManager();
......@@ -24,8 +25,9 @@ TaskManager.prototype = {
* Handles selection changes.
* This is also called when data of tasks are refreshed, even if selection
* has not been changed.
* @this
*/
onSelectionChange: function () {
onSelectionChange: function() {
var sm = this.selectionModel_;
var dm = this.dataModel_;
var selectedIndexes = sm.selectedIndexes;
......@@ -40,9 +42,9 @@ TaskManager.prototype = {
}
if (this.is_end_process_enabled_ != is_end_process_enabled) {
if (is_end_process_enabled)
$('kill-process').removeAttribute("disabled");
$('kill-process').removeAttribute('disabled');
else
$('kill-process').setAttribute("disabled", "true");
$('kill-process').setAttribute('disabled', 'true');
this.is_end_process_enabled_ = is_end_process_enabled;
}
......@@ -51,15 +53,17 @@ TaskManager.prototype = {
/**
* Closes taskmanager dialog.
* After this function is called, onClose() will be called.
* @this
*/
close: function () {
close: function() {
window.close();
},
/**
* Sends commands to kill selected processes.
* @this
*/
killSelectedProcesses: function () {
killSelectedProcesses: function() {
var selectedIndexes = this.selectionModel_.selectedIndexes;
var dm = this.dataModel_;
var uniqueIds = [];
......@@ -74,8 +78,9 @@ TaskManager.prototype = {
/**
* Initializes taskmanager.
* @this
*/
initialize: function (dialogDom, opt) {
initialize: function(dialogDom, opt) {
if (!dialogDom) {
console.log('ERROR: dialogDom is not defined.');
return;
......@@ -96,7 +101,7 @@ TaskManager.prototype = {
var column_label_id = DEFAULT_COLUMNS[i][1];
var localized_label = localStrings.getString(column_label_id);
// Falls back to raw column_label_id if localized string is not defined.
if (localized_label == "")
if (localized_label == '')
localized_label = column_label_id;
this.localized_column_[i] = localized_label;
......@@ -155,6 +160,7 @@ TaskManager.prototype = {
* Initializes the visibilities and handlers of the elements.
* This method is called by initialize().
* @private
* @this
*/
initElements_: function() {
// <if expr="pp_ifdef('chromeos')">
......@@ -174,6 +180,7 @@ TaskManager.prototype = {
/**
* Additional initialization of taskmanager. This function is called when
* the loading of delayed scripts finished.
* @this
*/
delayedInitialize: function() {
this.initColumnMenu_();
......@@ -206,7 +213,7 @@ TaskManager.prototype = {
this.table_.redraw();
},
initColumnModel_: function () {
initColumnModel_: function() {
var table_columns = new Array();
for (var i = 0; i < DEFAULT_COLUMNS.length; i++) {
var column = DEFAULT_COLUMNS[i];
......@@ -226,7 +233,7 @@ TaskManager.prototype = {
this.columnModel_ = new cr.ui.table.TableColumnModel(table_columns);
},
initColumnMenu_: function () {
initColumnMenu_: function() {
this.column_menu_commands_ = [];
this.commandsElement_ = this.document_.createElement('commands');
......@@ -249,7 +256,7 @@ TaskManager.prototype = {
command.menuitem = item;
item.textContent = this.localized_column_[i];
if (isColumnEnabled(column[0]))
item.setAttributeNode(this.document_.createAttribute("checked"));
item.setAttributeNode(this.document_.createAttribute('checked'));
this.columnSelectContextMenu_.appendChild(item);
}
......@@ -266,11 +273,11 @@ TaskManager.prototype = {
this.onCommandCanExecute_.bind(this));
},
initTableMenu_: function () {
initTableMenu_: function() {
this.table_menu_commands_ = [];
this.tableContextMenu_ = this.document_.createElement('menu');
var addMenuItem = function (tm, command_id, string_id, default_label) {
var addMenuItem = function(tm, command_id, string_id, default_label) {
// Creates command element to receive event.
var command = tm.document_.createElement('command');
command.id = COMMAND_CONTEXTMENU_TABLE_PREFIX + '-' + command_id;
......@@ -287,14 +294,14 @@ TaskManager.prototype = {
tm.tableContextMenu_.appendChild(item);
};
addMenuItem(this, 'inspect', 'inspect', "Inspect");
addMenuItem(this, 'activate', 'activate', "Activate");
addMenuItem(this, 'inspect', 'inspect', 'Inspect');
addMenuItem(this, 'activate', 'activate', 'Activate');
this.document_.body.appendChild(this.tableContextMenu_);
cr.ui.Menu.decorate(this.tableContextMenu_);
},
initTable_: function () {
initTable_: function() {
if (!this.dataModel_ || !this.selectionModel_ || !this.columnModel_) {
console.log('ERROR: some models are not defined.');
return;
......@@ -321,7 +328,9 @@ TaskManager.prototype = {
/**
* Returns a list item element of the list. This method trys to reuse the
* cached element, or creates a new element.
* @return {cr.ui.ListItem} list item element which contains the given data.
* @private
* @this
*/
getRow_: function(data, table) {
// Trys to reuse the cached row;
......@@ -332,10 +341,10 @@ TaskManager.prototype = {
// Initializes the cache.
var pid = data['processId'][0];
this.elementsCache_[pid] = {
listItem:null,
cell:[],
icon:[],
columns:{}
listItem: null,
cell: [],
icon: [],
columns: {}
};
// Create new row.
......@@ -345,7 +354,9 @@ TaskManager.prototype = {
/**
* Returns a list item element with re-using the previous cached element, or
* returns null if failed.
* @return {cr.ui.ListItem} cached un-used element to be reused.
* @private
* @this
*/
renderRowFromCache_: function(data, table) {
var pid = data['processId'][0];
......@@ -410,8 +421,10 @@ TaskManager.prototype = {
},
/**
* Create a new list item element and returns it.
* Create a new list item element.
* @return {cr.ui.ListItem} created new list item element.
* @private
* @this
*/
renderRow_: function(data, table) {
var pid = data['processId'][0];
......@@ -453,7 +466,9 @@ TaskManager.prototype = {
/**
* Create a new element of the cell.
* @return {HTMLDIVElement} created cell
* @private
* @this
*/
renderColumn_: function(entry, columnId, table) {
var container = this.document_.createElement('div');
......@@ -518,6 +533,7 @@ TaskManager.prototype = {
/**
* Updates the task list with the supplied task.
* @private
* @this
*/
processTaskChange: function(task) {
var dm = this.dataModel_;
......@@ -574,6 +590,7 @@ TaskManager.prototype = {
/**
* Respond to a command being executed.
* @this
*/
onCommand_: function(event) {
var command = event.command;
......@@ -606,8 +623,9 @@ TaskManager.prototype = {
/**
* Store resourceIndex of target resource of context menu, because resource
* will be replaced when it is refreshed.
* @this
*/
onTableContextMenuOpened_: function (e) {
onTableContextMenuOpened_: function(e) {
if (!this.isFinishedInitDelayed_)
return;
......@@ -622,7 +640,7 @@ TaskManager.prototype = {
activate_menuitem.disabled = true;
var target = e.target;
for (; ; target = target.parentNode) {
for (;; target = target.parentNode) {
if (!target) return;
var classes = target.classList;
if (classes &&
......@@ -663,7 +681,7 @@ TaskManager.prototype = {
menuitem.checked = newChecked;
setColumnEnabled(columnId, newChecked);
this.initColumnModel_()
this.initColumnModel_();
this.table_.columnModel = this.columnModel_;
this.table_.redraw();
},
......
......@@ -8,6 +8,10 @@
* To be included as a first script in main.html
*/
/**
* measureTime class
* @constructor
*/
var measureTime = {
isEnabled: localStorage.measureTimeEnabled,
......
......@@ -8,6 +8,9 @@ var taskmanager = undefined; // This will be instantiated in main.js.
/**
* Invoked when a range of items has changed.
* @param {Integer} start The start position of tasks to be changed
* @param {Integer} length The length of tasks to be changed
* @param {Array of task} tasks The array of updated task
*/
function taskChanged(start, length, tasks) {
var task = {type: 'change', start: start, length: length, tasks: tasks};
......@@ -19,8 +22,8 @@ function taskChanged(start, length, tasks) {
var cachedEnabledColumns;
/**
* Returns the dictionary which contains the list of columns and whether each
* column is enabled or not.
* @return {Dictionary} the dictionary which contains the list of columns and
* whether each column is enabled or not.
*/
function getEnabledColumns() {
// Use the cache after the second time since access to localStorage is slow.
......@@ -41,14 +44,17 @@ function getEnabledColumns() {
}
/**
* Returns whether the given column (at |columnId|) is enabled or not.
* @return {Boolean} the given column (at |columnId|) is enabled or not.
* @param {String} columnId The ID of the collumn to be checked.
*/
function isColumnEnabled(columnId) {
return (getEnabledColumns())[columnId];
}
/**
* Sets whether the given column is enabled or not.
* Sets the given column either enabled or disabled.
* @param {String} columnId The ID of the collumn to be set.
* @param {Boolean} newChecked True, to set the column enable. False otherwise.
*/
function setColumnEnabled(columnId, newChecked) {
commands.setUpdateColumn(columnId, newChecked);
......@@ -58,7 +64,7 @@ function setColumnEnabled(columnId, newChecked) {
}
// Enable the taskmanager model before the loading of scripts.
(function () {
(function() {
for (var i = 0; i < DEFAULT_COLUMNS.length; i++) {
var columnId = DEFAULT_COLUMNS[i][0];
if (isColumnEnabled(columnId))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment