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

Unified Diff: chrome/browser/resources/net_internals/detailsview.js

Issue 1088007: Add an initial implementation of net-internals inspector in javascript.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: more build file Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_ui/net_internals_ui.cc ('k') | chrome/browser/resources/net_internals/index.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/net_internals/detailsview.js
===================================================================
--- chrome/browser/resources/net_internals/detailsview.js (revision 0)
+++ chrome/browser/resources/net_internals/detailsview.js (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (c) 2010 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.
+
+/**
+ * The DetailsView handles the tabbed view that displays either the "log" or
+ * "timeline" view. This class keeps track of what the current view is, and
+ * invalidates the specific view each time the selected data has changed.
+ *
+ * @constructor
+ */
+function DetailsView(logTabHandleId,
+ timelineTabHandleId,
+ detailsTabContentId) {
+ // The DOM nodes that which contain the tab title.
+ this.tabHandles_ = {};
+
+ this.tabHandles_['timeline'] = document.getElementById(timelineTabHandleId);
+ this.tabHandles_['log'] = document.getElementById(logTabHandleId);
+
+ // The DOM node that contains the currently active tab sheet.
+ this.contentArea_ = document.getElementById(detailsTabContentId);
+
+ // Attach listeners to the "tab handles" so when you click them, it switches
+ // active view.
+
+ var self = this;
+
+ this.tabHandles_['timeline'].onclick = function() {
+ self.switchToView_('timeline');
+ };
+
+ this.tabHandles_['log'].onclick = function() {
+ self.switchToView_('log');
+ };
+
+ this.currentData_ = [];
+
+ // Default to the log view.
+ this.switchToView_('log');
+};
+
+// The delay between updates to repaint.
+DetailsView.REPAINT_TIMEOUT_MS = 50;
+
+/**
+ * Switches to the tab with name |viewName|. (Either 'log' or 'timeline'.
+ */
+DetailsView.prototype.switchToView_ = function(viewName) {
+ if (this.currentView_) {
+ // Remove the selected styling on currently selected tab.
+ changeClassName(this.tabHandles_[this.currentView_], 'selected', false);
+ }
+
+ this.currentView_ = viewName;
+ changeClassName(this.tabHandles_[this.currentView_], 'selected', true);
+ this.repaint_();
+};
+
+/**
+ * Updates the data this view is using.
+ */
+DetailsView.prototype.setData = function(currentData) {
+ // Make a copy of the array (in case the caller mutates it), and sort it
+ // by the source ID.
+ this.currentData_ = DetailsView.createSortedCopy_(currentData);
+
+ // Invalidate the view.
+ if (!this.outstandingRepaint_) {
+ this.outstandingRepaint_ = true;
+ window.setTimeout(this.repaint_.bind(this),
+ DetailsView.REPAINT_TIMEOUT_MS);
+ }
+};
+
+DetailsView.prototype.repaint_ = function() {
+ this.outstandingRepaint_ = false;
+ this.contentArea_.innerHTML = '';
+
+ if (this.currentView_ == 'log') {
+ PaintLogView(this.currentData_, this.contentArea_);
+ } else {
+ PaintTimelineView(this.currentData_, this.contentArea_);
+ }
+};
+
+DetailsView.createSortedCopy_ = function(origArray) {
+ var sortedArray = origArray.slice(0);
+ sortedArray.sort(function(a, b) {
+ return a.getSourceId() - b.getSourceId();
+ });
+ return sortedArray;
+};
Property changes on: chrome\browser\resources\net_internals\detailsview.js
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/dom_ui/net_internals_ui.cc ('k') | chrome/browser/resources/net_internals/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698