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

Side by Side Diff: appengine_apps/chromium_status/static/js/profiling/class_util.js

Issue 778533003: Moved chromium_status to appengine/ (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 6 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * Helper utility functions for manipulating the element classes.
7 */
8 var ClassUtil = {};
9
10 /**
11 * Finds an element based on its class name.
12 **/
13 ClassUtil.FindElementByClassName = function(className) {
14 var items = document.getElementsByClassName(className);
15 if (items.length != 1) {
16 throw "Found " + items.length + " item(s) by class " + className;
17 }
18 return items[0].id;
19 };
20
21 /**
22 * Resets class type of all items except one.
23 **/
24 ClassUtil.ResetClass = function(className, specialId, specialClass) {
25 var items = document.getElementsByClassName(className);
26 var fail = function(msg) {
27 throw "Internal error in ResetClass(" + className + ", " + specialId +
28 ", " + specialClass + ")\nEnumerated " + items.length + " items.\n" +
29 msg;
30 }
31 var found;
32 for (var i in items) {
33 var item = items[i];
34 if (item.id == specialId) {
35 item.className = className + " " + specialClass;
36 if (found) {
37 fail("Found 2 times");
38 }
39 found = i;
40 } else {
41 item.className = className;
42 }
43 }
44 if (!found) {
45 fail("Found 0 time");
46 }
47 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698