diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-27 21:28:56 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-27 21:28:56 +0000 |
commit | f8146166a066a7bbd5370795ab6951a7947ded0b (patch) | |
tree | c507fe4be3e9068f557496a6c348d6a8291fdeea | |
parent | 0f0cfa7bfd8b987818539d4ebf780c05068a264d (diff) | |
download | chromium_src-f8146166a066a7bbd5370795ab6951a7947ded0b.zip chromium_src-f8146166a066a7bbd5370795ab6951a7947ded0b.tar.gz chromium_src-f8146166a066a7bbd5370795ab6951a7947ded0b.tar.bz2 |
Replace occurrences of document.getElementById() with $() throughout net_internals' javascript.
This is a common practice throughout Chrome's DOMUI pages, and helps match the style. It also leads to slightly more compact code.
Review URL: http://codereview.chromium.org/7482023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94360 0039d316-1c4b-4281-b951-d872f2087c98
16 files changed, 84 insertions, 98 deletions
diff --git a/chrome/browser/resources/net_internals/dataview.js b/chrome/browser/resources/net_internals/dataview.js index 7736251..14d7cd0 100644 --- a/chrome/browser/resources/net_internals/dataview.js +++ b/chrome/browser/resources/net_internals/dataview.js @@ -33,40 +33,36 @@ function DataView(mainBoxId, loggingTextSpanId) { DivView.call(this, mainBoxId); - var securityStrippingCheckbox = - document.getElementById(securityStrippingCheckboxId); + var securityStrippingCheckbox = $(securityStrippingCheckboxId); securityStrippingCheckbox.onclick = this.onSetSecurityStripping_.bind(this, securityStrippingCheckbox); - var byteLoggingCheckbox = document.getElementById(byteLoggingCheckboxId); + var byteLoggingCheckbox = $(byteLoggingCheckboxId); byteLoggingCheckbox.onclick = this.onSetByteLogging_.bind(this, byteLoggingCheckbox); - this.downloadIframe_ = document.getElementById(downloadIframeId); + this.downloadIframe_ = $(downloadIframeId); - this.saveFileButton_ = document.getElementById(saveFileButtonId); + this.saveFileButton_ = $(saveFileButtonId); this.saveFileButton_.onclick = this.onSaveFile_.bind(this); - this.saveStatusText_ = document.getElementById(dataViewSaveStatusTextId); + this.saveStatusText_ = $(dataViewSaveStatusTextId); - this.activelyCapturedCountBox_ = - document.getElementById(activelyCapturedCountId); - this.passivelyCapturedCountBox_ = - document.getElementById(passivelyCapturedCountId); - document.getElementById(deleteAllId).onclick = - g_browser.deleteAllEvents.bind(g_browser); + this.activelyCapturedCountBox_ = $(activelyCapturedCountId); + this.passivelyCapturedCountBox_ = $(passivelyCapturedCountId); + $(deleteAllId).onclick = g_browser.deleteAllEvents.bind(g_browser); - this.dumpDataDiv_ = document.getElementById(dumpDataDivId); - this.capturingTextSpan_ = document.getElementById(capturingTextSpanId); - this.loggingTextSpan_ = document.getElementById(loggingTextSpanId); + this.dumpDataDiv_ = $(dumpDataDivId); + this.capturingTextSpan_ = $(capturingTextSpanId); + this.loggingTextSpan_ = $(loggingTextSpanId); - this.loadedDiv_ = document.getElementById(loadedDivId); - this.loadedClientInfoText_ = document.getElementById(loadedClientInfoTextId); + this.loadedDiv_ = $(loadedDivId); + this.loadedClientInfoText_ = $(loadedClientInfoTextId); - this.loadFileElement_ = document.getElementById(loadLogFileId); + this.loadFileElement_ = $(loadLogFileId); this.loadFileElement_.onchange = this.logFileChanged.bind(this); - this.loadStatusText_ = document.getElementById(dataViewLoadStatusTextId); + this.loadStatusText_ = $(dataViewLoadStatusTextId); - var dropTarget = document.getElementById(loadLogFileDropTargetId); + var dropTarget = $(loadLogFileDropTargetId); dropTarget.ondragenter = this.onDrag.bind(this); dropTarget.ondragover = this.onDrag.bind(this); dropTarget.ondrop = this.onDrop.bind(this); @@ -244,7 +240,7 @@ DataView.prototype.setLoadFileStatus = function(text, isLoading) { var loadFileElementId = this.loadFileElement_.id; var loadFileElementOnChange = this.loadFileElement_.onchange; this.loadFileElement_.outerHTML = this.loadFileElement_.outerHTML; - this.loadFileElement_ = document.getElementById(loadFileElementId); + this.loadFileElement_ = $(loadFileElementId); this.loadFileElement_.onchange = loadFileElementOnChange; } }; diff --git a/chrome/browser/resources/net_internals/dnsview.js b/chrome/browser/resources/net_internals/dnsview.js index b258ada..588501a 100644 --- a/chrome/browser/resources/net_internals/dnsview.js +++ b/chrome/browser/resources/net_internals/dnsview.js @@ -25,18 +25,17 @@ function DnsView(mainBoxId, DivView.call(this, mainBoxId); // Hook up the UI components. - this.cacheTbody_ = document.getElementById(cacheTbodyId); - this.defaultFamilySpan_ = document.getElementById(defaultFamilySpanId); - this.ipv6DisabledSpan_ = document.getElementById(ipv6DisabledSpanId); + this.cacheTbody_ = $(cacheTbodyId); + this.defaultFamilySpan_ = $(defaultFamilySpanId); + this.ipv6DisabledSpan_ = $(ipv6DisabledSpanId); - document.getElementById(enableIPv6ButtonId).onclick = - g_browser.enableIPv6.bind(g_browser); + $(enableIPv6ButtonId).onclick = g_browser.enableIPv6.bind(g_browser); - this.capacitySpan_ = document.getElementById(capacitySpanId); - this.ttlSuccessSpan_ = document.getElementById(ttlSuccessSpanId); - this.ttlFailureSpan_ = document.getElementById(ttlFailureSpanId); + this.capacitySpan_ = $(capacitySpanId); + this.ttlSuccessSpan_ = $(ttlSuccessSpanId); + this.ttlFailureSpan_ = $(ttlFailureSpanId); - var clearCacheButton = document.getElementById(clearCacheButtonId); + var clearCacheButton = $(clearCacheButtonId); clearCacheButton.onclick = g_browser.sendClearHostResolverCache.bind(g_browser); diff --git a/chrome/browser/resources/net_internals/eventsview.js b/chrome/browser/resources/net_internals/eventsview.js index 85ad1a8..919ada0 100644 --- a/chrome/browser/resources/net_internals/eventsview.js +++ b/chrome/browser/resources/net_internals/eventsview.js @@ -52,30 +52,26 @@ function EventsView(tableBodyId, filterInputId, filterCountId, g_browser.addLogObserver(this); - this.tableBody_ = document.getElementById(tableBodyId); + this.tableBody_ = $(tableBodyId); - this.filterInput_ = document.getElementById(filterInputId); - this.filterCount_ = document.getElementById(filterCountId); + this.filterInput_ = $(filterInputId); + this.filterCount_ = $(filterCountId); this.filterInput_.addEventListener('search', this.onFilterTextChanged_.bind(this), true); - document.getElementById(deleteSelectedId).onclick = - this.deleteSelected_.bind(this); + $(deleteSelectedId).onclick = this.deleteSelected_.bind(this); - document.getElementById(deleteAllId).onclick = - g_browser.deleteAllEvents.bind(g_browser); + $(deleteAllId).onclick = g_browser.deleteAllEvents.bind(g_browser); - document.getElementById(selectAllId).addEventListener( - 'click', this.selectAll_.bind(this), true); + $(selectAllId).addEventListener('click', this.selectAll_.bind(this), true); - document.getElementById(sortByIdId).addEventListener( - 'click', this.sortById_.bind(this), true); + $(sortByIdId).addEventListener('click', this.sortById_.bind(this), true); - document.getElementById(sortBySourceTypeId).addEventListener( + $(sortBySourceTypeId).addEventListener( 'click', this.sortBySourceType_.bind(this), true); - document.getElementById(sortByDescriptionId).addEventListener( + $(sortByDescriptionId).addEventListener( 'click', this.sortByDescription_.bind(this), true); // Sets sort order and filter. diff --git a/chrome/browser/resources/net_internals/hstsview.js b/chrome/browser/resources/net_internals/hstsview.js index 10cfab6..2e869f5 100644 --- a/chrome/browser/resources/net_internals/hstsview.js +++ b/chrome/browser/resources/net_internals/hstsview.js @@ -15,18 +15,18 @@ function HSTSView(mainBoxId, queryInputId, formId, queryOutputDivId, deleteInputId, deleteFormId) { DivView.call(this, mainBoxId); - this.queryInput_ = document.getElementById(queryInputId); - this.addCheck_ = document.getElementById(addCheckId); - this.addInput_ = document.getElementById(addInputId); - this.addPins_ = document.getElementById(addPinsId); - this.deleteInput_ = document.getElementById(deleteInputId); - this.queryOutputDiv_ = document.getElementById(queryOutputDivId); - - var form = document.getElementById(formId); + this.queryInput_ = $(queryInputId); + this.addCheck_ = $(addCheckId); + this.addInput_ = $(addInputId); + this.addPins_ = $(addPinsId); + this.deleteInput_ = $(deleteInputId); + this.queryOutputDiv_ = $(queryOutputDivId); + + var form = $(formId); form.addEventListener('submit', this.onSubmitQuery_.bind(this), false); - form = document.getElementById(addFormId); + form = $(addFormId); form.addEventListener('submit', this.onSubmitAdd_.bind(this), false); - form = document.getElementById(deleteFormId); + form = $(deleteFormId); form.addEventListener('submit', this.onSubmitDelete_.bind(this), false); g_browser.addHSTSObserver(this); diff --git a/chrome/browser/resources/net_internals/httpcacheview.js b/chrome/browser/resources/net_internals/httpcacheview.js index 2e0e624e..c94abfa 100644 --- a/chrome/browser/resources/net_internals/httpcacheview.js +++ b/chrome/browser/resources/net_internals/httpcacheview.js @@ -9,7 +9,7 @@ function HttpCacheView(mainBoxId, statsDivId) { DivView.call(this, mainBoxId); - this.statsDiv_ = document.getElementById(statsDivId); + this.statsDiv_ = $(statsDivId); // Register to receive http cache info. g_browser.addHttpCacheInfoObserver(this); diff --git a/chrome/browser/resources/net_internals/httpthrottlingview.js b/chrome/browser/resources/net_internals/httpthrottlingview.js index 4cc8305..03a55db5 100644 --- a/chrome/browser/resources/net_internals/httpthrottlingview.js +++ b/chrome/browser/resources/net_internals/httpthrottlingview.js @@ -9,7 +9,7 @@ function HttpThrottlingView(mainBoxId, enableCheckboxId) { DivView.call(this, mainBoxId); - this.enableCheckbox_ = document.getElementById(enableCheckboxId); + this.enableCheckbox_ = $(enableCheckboxId); this.enableCheckbox_.onclick = this.onEnableCheckboxClicked_.bind(this); g_browser.addHttpThrottlingObserver(this); diff --git a/chrome/browser/resources/net_internals/logsview.js b/chrome/browser/resources/net_internals/logsview.js index 032d4577..98d273f 100644 --- a/chrome/browser/resources/net_internals/logsview.js +++ b/chrome/browser/resources/net_internals/logsview.js @@ -11,14 +11,14 @@ */ function LogsView(mainBoxId, tableId, globalShowButtonId, globalHideButtonId, refreshLogsButtonId) { - var tableDiv = document.getElementById(tableId); + var tableDiv = $(tableId); this.rows = []; this.PopulateTable(tableDiv, this.logFilterList); - document.getElementById(globalShowButtonId).addEventListener('click', + $(globalShowButtonId).addEventListener('click', this.onGlobalChangeVisibleClick_.bind(this, true)); - document.getElementById(globalHideButtonId).addEventListener('click', + $(globalHideButtonId).addEventListener('click', this.onGlobalChangeVisibleClick_.bind(this, false)); - document.getElementById(refreshLogsButtonId).addEventListener('click', + $(refreshLogsButtonId).addEventListener('click', this.onLogsRefresh_.bind(this)); DivView.call(this, mainBoxId); }; diff --git a/chrome/browser/resources/net_internals/main.js b/chrome/browser/resources/net_internals/main.js index 7d0cd47..bc25d88 100644 --- a/chrome/browser/resources/net_internals/main.js +++ b/chrome/browser/resources/net_internals/main.js @@ -170,7 +170,7 @@ function onLoaded() { var anchorMap = {}; var tabIds = categoryTabSwitcher.getAllTabIds(); for (var i = 0; i < tabIds.length; ++i) { - var aNode = document.getElementById(tabIds[i]); + var aNode = $(tabIds[i]); anchorMap[aNode.hash] = tabIds[i]; } // Default the empty hash to the data tab. diff --git a/chrome/browser/resources/net_internals/prerenderview.js b/chrome/browser/resources/net_internals/prerenderview.js index 5b6ad85..cd79f60 100644 --- a/chrome/browser/resources/net_internals/prerenderview.js +++ b/chrome/browser/resources/net_internals/prerenderview.js @@ -10,9 +10,9 @@ function PrerenderView(mainBoxId, prerenderEnabledSpanId, prerenderHistoryDivId, prerenderActiveDivId) { DivView.call(this, mainBoxId); g_browser.addPrerenderInfoObserver(this); - this.prerenderEnabledSpan_ = document.getElementById(prerenderEnabledSpanId); - this.prerenderHistoryDiv_ = document.getElementById(prerenderHistoryDivId); - this.prerenderActiveDiv_ = document.getElementById(prerenderActiveDivId); + this.prerenderEnabledSpan_ = $(prerenderEnabledSpanId); + this.prerenderHistoryDiv_ = $(prerenderHistoryDivId); + this.prerenderActiveDiv_ = $(prerenderActiveDivId); } inherits(PrerenderView, DivView); diff --git a/chrome/browser/resources/net_internals/proxyview.js b/chrome/browser/resources/net_internals/proxyview.js index 239229a..f83ce79 100644 --- a/chrome/browser/resources/net_internals/proxyview.js +++ b/chrome/browser/resources/net_internals/proxyview.js @@ -26,14 +26,13 @@ function ProxyView(mainBoxId, this.latestProxySourceId_ = 0; // Hook up the UI components. - this.originalSettingsDiv_ = document.getElementById(originalSettingsDivId); - this.effectiveSettingsDiv_ = - document.getElementById(effectiveSettingsDivId); - this.proxyResolverLogPre_ = document.getElementById(proxyResolverLogPreId); - this.badProxiesTbody_ = document.getElementById(badProxiesTbodyId); - - var reloadSettingsButton = document.getElementById(reloadSettingsButtonId); - var clearBadProxiesButton = document.getElementById(clearBadProxiesButtonId); + this.originalSettingsDiv_ = $(originalSettingsDivId); + this.effectiveSettingsDiv_ = $(effectiveSettingsDivId); + this.proxyResolverLogPre_ = $(proxyResolverLogPreId); + this.badProxiesTbody_ = $(badProxiesTbodyId); + + var reloadSettingsButton = $(reloadSettingsButtonId); + var clearBadProxiesButton = $(clearBadProxiesButtonId); clearBadProxiesButton.onclick = g_browser.sendClearBadProxies.bind(g_browser); reloadSettingsButton.onclick = diff --git a/chrome/browser/resources/net_internals/serviceprovidersview.js b/chrome/browser/resources/net_internals/serviceprovidersview.js index 48751a7..d910606 100644 --- a/chrome/browser/resources/net_internals/serviceprovidersview.js +++ b/chrome/browser/resources/net_internals/serviceprovidersview.js @@ -18,13 +18,11 @@ function ServiceProvidersView(tabId, namespaceProvidersTbodyId) { DivView.call(this, mainBoxId); - var tab = document.getElementById(tabId); + var tab = $(tabId); setNodeDisplay(tab, true); - this.serviceProvidersTbody_ = - document.getElementById(serviceProvidersTbodyId); - this.namespaceProvidersTbody_ = - document.getElementById(namespaceProvidersTbodyId); + this.serviceProvidersTbody_ = $(serviceProvidersTbodyId); + this.namespaceProvidersTbody_ = $(namespaceProvidersTbodyId); g_browser.addServiceProvidersObserver(this); } diff --git a/chrome/browser/resources/net_internals/socketsview.js b/chrome/browser/resources/net_internals/socketsview.js index b99ed2b..2c6607f 100644 --- a/chrome/browser/resources/net_internals/socketsview.js +++ b/chrome/browser/resources/net_internals/socketsview.js @@ -16,13 +16,13 @@ function SocketsView(mainBoxId, socketPoolDivId, socketPoolGroupsDivId, DivView.call(this, mainBoxId); g_browser.addSocketPoolInfoObserver(this); - this.socketPoolDiv_ = document.getElementById(socketPoolDivId); - this.socketPoolGroupsDiv_ = document.getElementById(socketPoolGroupsDivId); + this.socketPoolDiv_ = $(socketPoolDivId); + this.socketPoolGroupsDiv_ = $(socketPoolGroupsDivId); - var closeIdleButton = document.getElementById(closeIdleSocketsButtonId); + var closeIdleButton = $(closeIdleSocketsButtonId); closeIdleButton.onclick = this.closeIdleSockets.bind(this); - var flushSocketsButton = document.getElementById(socketPoolFlushButtonId); + var flushSocketsButton = $(socketPoolFlushButtonId); flushSocketsButton.onclick = this.flushSocketPools.bind(this); } diff --git a/chrome/browser/resources/net_internals/spdyview.js b/chrome/browser/resources/net_internals/spdyview.js index a36d036..559b791 100644 --- a/chrome/browser/resources/net_internals/spdyview.js +++ b/chrome/browser/resources/net_internals/spdyview.js @@ -19,19 +19,17 @@ function SpdyView(mainBoxId, spdyEnabledSpanId, g_browser.addSpdyStatusObserver(this); g_browser.addSpdyAlternateProtocolMappingsObserver(this); - this.spdyEnabledSpan_ = document.getElementById(spdyEnabledSpanId); - this.spdyUseAlternateProtocolSpan_ = - document.getElementById(spdyUseAlternateProtocolSpanId); - this.spdyForceAlwaysSpan_ = document.getElementById(spdyForceAlwaysSpanId); - this.spdyForceOverSslSpan_ = document.getElementById(spdyForceOverSslSpanId); - this.spdyNextProtocolsSpan_ = - document.getElementById(spdyNextProtocolsSpanId); + this.spdyEnabledSpan_ = $(spdyEnabledSpanId); + this.spdyUseAlternateProtocolSpan_ = $(spdyUseAlternateProtocolSpanId); + this.spdyForceAlwaysSpan_ = $(spdyForceAlwaysSpanId); + this.spdyForceOverSslSpan_ = $(spdyForceOverSslSpanId); + this.spdyNextProtocolsSpan_ = $(spdyNextProtocolsSpanId); this.spdyAlternateProtocolMappingsDiv_ = - document.getElementById(spdyAlternateProtocolMappingsDivId); - this.spdySessionNoneSpan_ = document.getElementById(spdySessionNoneSpanId); - this.spdySessionLinkSpan_ = document.getElementById(spdySessionLinkSpanId); - this.spdySessionDiv_ = document.getElementById(spdySessionDivId); + $(spdyAlternateProtocolMappingsDivId); + this.spdySessionNoneSpan_ = $(spdySessionNoneSpanId); + this.spdySessionLinkSpan_ = $(spdySessionLinkSpanId); + this.spdySessionDiv_ = $(spdySessionDivId); } inherits(SpdyView, DivView); diff --git a/chrome/browser/resources/net_internals/tabswitcherview.js b/chrome/browser/resources/net_internals/tabswitcherview.js index 97eca54..ad25052 100644 --- a/chrome/browser/resources/net_internals/tabswitcherview.js +++ b/chrome/browser/resources/net_internals/tabswitcherview.js @@ -23,7 +23,7 @@ * @constructor */ function TabSwitcherView(tabHandleDivId) { - document.getElementById(tabHandleDivId).classList.add('tab-switcher-view'); + $(tabHandleDivId).classList.add('tab-switcher-view'); var tabHandleView = new DivView(tabHandleDivId); View.call(this); @@ -166,6 +166,6 @@ TabEntry.prototype.setSelected = function(isSelected) { * Returns the DOM node that is used to select the tab. */ TabEntry.prototype.getTabHandleNode = function() { - return document.getElementById(this.id); + return $(this.id); }; diff --git a/chrome/browser/resources/net_internals/testview.js b/chrome/browser/resources/net_internals/testview.js index 4ca3b17..d2d5512 100644 --- a/chrome/browser/resources/net_internals/testview.js +++ b/chrome/browser/resources/net_internals/testview.js @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -15,10 +15,10 @@ function TestView(mainBoxId, urlInputId, formId, summaryDivId) { DivView.call(this, mainBoxId); - this.urlInput_ = document.getElementById(urlInputId); - this.summaryDiv_ = document.getElementById(summaryDivId); + this.urlInput_ = $(urlInputId); + this.summaryDiv_ = $(summaryDivId); - var form = document.getElementById(formId); + var form = $(formId); form.addEventListener('submit', this.onSubmitForm_.bind(this), false); g_browser.addConnectionTestsObserver(this); diff --git a/chrome/browser/resources/net_internals/view.js b/chrome/browser/resources/net_internals/view.js index b1d229a..9e2773d 100644 --- a/chrome/browser/resources/net_internals/view.js +++ b/chrome/browser/resources/net_internals/view.js @@ -96,7 +96,7 @@ View.prototype.onLoadLogFinish = function(polledData, tabData) { function DivView(divId) { View.call(this); - this.node_ = document.getElementById(divId); + this.node_ = $(divId); if (!this.node_) throw new Error('Element ' + divId + ' not found'); |