OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 16 matching lines...) Expand all Loading... | |
27 | 27 |
28 (function () { | 28 (function () { |
29 | 29 |
30 ui.displayURLForBuilder = function(builderName) | 30 ui.displayURLForBuilder = function(builderName) |
31 { | 31 { |
32 return config.waterfallURL + '?' + $.param({ | 32 return config.waterfallURL + '?' + $.param({ |
33 'builder': builderName | 33 'builder': builderName |
34 }); | 34 }); |
35 } | 35 } |
36 | 36 |
37 ui.kUseNewWindowForLinksSetting = 'gardenomatic.use-new-window-for-links'; | |
38 | |
37 ui.displayNameForBuilder = function(builderName) | 39 ui.displayNameForBuilder = function(builderName) |
38 { | 40 { |
39 return builderName.replace(/Webkit /, ''); | 41 return builderName.replace(/Webkit /, ''); |
40 } | 42 } |
41 | 43 |
42 ui.urlForTest = function(testName) | 44 ui.urlForTest = function(testName) |
43 { | 45 { |
44 return 'http://trac.webkit.org/browser/trunk/LayoutTests/' + testName; | 46 return 'http://trac.webkit.org/browser/trunk/LayoutTests/' + testName; |
45 } | 47 } |
46 | 48 |
(...skipping 13 matching lines...) Expand all Loading... | |
60 return ui.urlForFlakinessDashboard(opt_testNameList) + '&showChrome=false'; | 62 return ui.urlForFlakinessDashboard(opt_testNameList) + '&showChrome=false'; |
61 } | 63 } |
62 | 64 |
63 ui.rolloutReasonForTestNameList = function(testNameList) | 65 ui.rolloutReasonForTestNameList = function(testNameList) |
64 { | 66 { |
65 return 'Broke:\n' + testNameList.map(function(testName) { | 67 return 'Broke:\n' + testNameList.map(function(testName) { |
66 return '* ' + testName; | 68 return '* ' + testName; |
67 }).join('\n'); | 69 }).join('\n'); |
68 } | 70 } |
69 | 71 |
72 ui.setTargetForLink = function(anchor) | |
73 { | |
74 if (!anchor.href.indexOf('#')) | |
pdr.
2014/03/04 23:12:09
Can you help me understand these checks for fragme
apavlov
2014/03/05 00:23:56
This is a catch-all check for the app navigation,
alecflett
2014/03/05 01:21:30
I've found the test !foo.indexOf() as a constant s
apavlov
2014/03/05 06:56:21
Hey Alec,
You are absolutely right. In our DevToo
| |
75 return; | |
76 if (ui.useNewWindowForLinks) | |
77 anchor.target = '_blank'; | |
78 else | |
79 anchor.removeAttribute('target'); | |
80 } | |
81 | |
82 ui.setUseNewWindowForLinks = function(enabled) | |
apavlov
2014/03/04 18:46:54
Not sure how to organize this best location-wise.
ojan
2014/03/04 22:49:02
Yeah...putting localStorage queries in the ui modu
apavlov
2014/03/05 00:23:56
Could it be "base" instead? localStorage is unrela
ojan
2014/03/05 01:04:20
I suppose you could add base.setUseNewWindowsForLi
apavlov
2014/03/05 06:56:21
Okay, let's leave it as is.
| |
83 { | |
84 ui.useNewWindowForLinks = enabled; | |
85 if (enabled) | |
apavlov
2014/03/04 18:46:54
Do we want to use localStorage? Or just go ahead w
ojan
2014/03/04 22:49:02
I think using localStorage makes sense. It's not a
| |
86 localStorage[ui.kUseNewWindowForLinksSetting] = 'true'; | |
87 else | |
88 delete localStorage[ui.kUseNewWindowForLinksSetting]; | |
89 | |
90 var anchors = $('a').filter(function() { | |
ojan
2014/03/05 01:04:20
Now that I look a bit more closely, you don't need
apavlov
2014/03/05 06:56:21
Correct, this is now not required.
| |
91 return this.href.indexOf('#') !== 0; | |
92 }); | |
93 $.each(anchors, function(index, anchor) { | |
94 ui.setTargetForLink(anchor); | |
95 }); | |
96 } | |
97 ui.setUseNewWindowForLinks(!!localStorage[ui.kUseNewWindowForLinksSetting]); | |
98 | |
99 ui.createLinkNode = function(url, textContent) | |
100 { | |
101 var link = document.createElement('a'); | |
102 link.href = url; | |
103 ui.setTargetForLink(link); | |
104 link.appendChild(document.createTextNode(textContent)); | |
105 return link; | |
106 } | |
107 | |
70 ui.onebar = base.extends('div', { | 108 ui.onebar = base.extends('div', { |
71 init: function() | 109 init: function() |
72 { | 110 { |
73 this.id = 'onebar'; | 111 this.id = 'onebar'; |
74 this.innerHTML = | 112 this.innerHTML = |
75 '<ul>' + | 113 '<ul>' + |
76 '<li><a href="#unexpected">Unexpected Failures</a></li>' + | 114 '<li><a href="#unexpected">Unexpected Failures</a></li>' + |
77 '<li><a href="#expected">Expected Failures</a></li>' + | 115 '<li><a href="#expected">Expected Failures</a></li>' + |
78 '<li><a href="#results">Results</a></li>' + | 116 '<li><a href="#results">Results</a></li>' + |
79 '</ul>' + | 117 '</ul>' + |
118 '<div id="link-handling"><input type="checkbox" id="new-window-for-l inks"><label for="new-window-for-links">Open links in new window</label></div>' + | |
80 '<div id="unexpected"></div>' + | 119 '<div id="unexpected"></div>' + |
81 '<div id="expected"></div>' + | 120 '<div id="expected"></div>' + |
82 '<div id="results"></div>'; | 121 '<div id="results"></div>'; |
83 this._tabNames = [ | 122 this._tabNames = [ |
84 'unexpected', | 123 'unexpected', |
85 'expected', | 124 'expected', |
86 'results', | 125 'results', |
87 ] | 126 ] |
88 | 127 |
89 this._tabIndexToSavedScrollOffset = {}; | 128 this._tabIndexToSavedScrollOffset = {}; |
90 this._tabs = $(this).tabs({ | 129 this._tabs = $(this).tabs({ |
91 disabled: [2], | 130 disabled: [2], |
92 show: function(event, ui) { this._restoreScrollOffset(ui.index); }, | 131 show: function(event, ui) { this._restoreScrollOffset(ui.index); }, |
132 select: function(event, ui) { | |
133 this._saveScrollOffset(); | |
134 window.location.hash = ui.tab.hash; | |
135 }.bind(this) | |
93 }); | 136 }); |
94 }, | 137 }, |
95 _saveScrollOffset: function() { | 138 _saveScrollOffset: function() { |
96 var tabIndex = this._tabs.tabs('option', 'selected'); | 139 var tabIndex = this._tabs.tabs('option', 'selected'); |
97 this._tabIndexToSavedScrollOffset[tabIndex] = document.body.scrollTop; | 140 this._tabIndexToSavedScrollOffset[tabIndex] = document.body.scrollTop; |
98 }, | 141 }, |
99 _restoreScrollOffset: function(tabIndex) | 142 _restoreScrollOffset: function(tabIndex) |
100 { | 143 { |
101 document.body.scrollTop = this._tabIndexToSavedScrollOffset[tabIndex] || 0; | 144 document.body.scrollTop = this._tabIndexToSavedScrollOffset[tabIndex] || 0; |
102 }, | 145 }, |
103 _setupHistoryHandlers: function() | 146 _setupHistoryHandlers: function() |
104 { | 147 { |
105 function currentHash() { | 148 function currentHash() { |
106 var hash = window.location.hash; | 149 var hash = window.location.hash; |
107 return (!hash || hash == '#') ? '#unexpected' : hash; | 150 return (!hash || hash == '#') ? '#unexpected' : hash; |
108 } | 151 } |
109 | 152 |
110 var self = this; | 153 var self = this; |
111 $('.ui-tabs-nav a').bind('mouseup', function(event) { | |
apavlov
2014/03/04 18:46:54
Drive-by: fixed clicking the tabs. With this code
| |
112 var href = event.target.getAttribute('href'); | |
113 var hash = currentHash(); | |
114 if (href != hash) { | |
115 self._saveScrollOffset(); | |
116 window.location = href | |
117 } | |
118 }); | |
119 | |
120 window.onhashchange = function(event) { | 154 window.onhashchange = function(event) { |
121 var tabName = currentHash().substring(1); | 155 var tabName = currentHash().substring(1); |
122 self._selectInternal(tabName); | 156 self._selectInternal(tabName); |
123 }; | 157 }; |
124 | 158 |
125 // When navigating from the browser chrome, we'll | 159 // When navigating from the browser chrome, we'll |
126 // scroll to the #tabname contents. popstate fires before | 160 // scroll to the #tabname contents. popstate fires before |
127 // we scroll, so we can save the scroll offset first. | 161 // we scroll, so we can save the scroll offset first. |
128 window.onpopstate = function() { | 162 window.onpopstate = function() { |
129 self._saveScrollOffset(); | 163 self._saveScrollOffset(); |
130 }; | 164 }; |
131 }, | 165 }, |
166 _setupLinkSettingHandler: function() | |
167 { | |
168 $('#new-window-for-links').attr('checked', ui.useNewWindowForLinks); | |
169 $('#new-window-for-links').change(function(event) { | |
170 ui.setUseNewWindowForLinks(this.checked); | |
171 }); | |
172 }, | |
132 attach: function() | 173 attach: function() |
133 { | 174 { |
134 document.body.insertBefore(this, document.body.firstChild); | 175 document.body.insertBefore(this, document.body.firstChild); |
176 this._setupLinkSettingHandler(); | |
135 this._setupHistoryHandlers(); | 177 this._setupHistoryHandlers(); |
136 }, | 178 }, |
137 tabNamed: function(tabName) | 179 tabNamed: function(tabName) |
138 { | 180 { |
139 if (this._tabNames.indexOf(tabName) == -1) | 181 if (this._tabNames.indexOf(tabName) == -1) |
140 return null; | 182 return null; |
141 tab = document.getElementById(tabName); | 183 tab = document.getElementById(tabName); |
142 // We perform this sanity check below to make sure getElementById | 184 // We perform this sanity check below to make sure getElementById |
143 // hasn't given us a node in some other unrelated part of the document. | 185 // hasn't given us a node in some other unrelated part of the document. |
144 // that shouldn't happen normally, but it could happen if an attacker | 186 // that shouldn't happen normally, but it could happen if an attacker |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 theSpan.appendChild(document.createTextNode('Latest revision processed b y every bot: ')); | 330 theSpan.appendChild(document.createTextNode('Latest revision processed b y every bot: ')); |
289 | 331 |
290 var latestRevision = model.latestRevisionWithNoBuildersInFlight(); | 332 var latestRevision = model.latestRevisionWithNoBuildersInFlight(); |
291 var latestRevisions = model.latestRevisionByBuilder(); | 333 var latestRevisions = model.latestRevisionByBuilder(); |
292 | 334 |
293 // Get the list of builders sorted with the most recent one first. | 335 // Get the list of builders sorted with the most recent one first. |
294 var builders = Object.keys(latestRevisions); | 336 var builders = Object.keys(latestRevisions); |
295 builders.sort(function (a, b) { return parseInt(latestRevisions[b]) - pa rseInt(latestRevisions[a]);}); | 337 builders.sort(function (a, b) { return parseInt(latestRevisions[b]) - pa rseInt(latestRevisions[a]);}); |
296 | 338 |
297 var summaryNode = document.createElement('summary'); | 339 var summaryNode = document.createElement('summary'); |
298 var summaryLinkNode = base.createLinkNode(trac.changesetURL(latestRevisi on), latestRevision); | 340 var summaryLinkNode = ui.createLinkNode(trac.changesetURL(latestRevision ), latestRevision); |
299 summaryNode.appendChild(summaryLinkNode); | 341 summaryNode.appendChild(summaryLinkNode); |
300 | 342 |
301 var revisionsTableNode = document.createElement('table'); | 343 var revisionsTableNode = document.createElement('table'); |
302 builders.forEach(function(builderName) { | 344 builders.forEach(function(builderName) { |
303 var trNode = document.createElement('tr'); | 345 var trNode = document.createElement('tr'); |
304 | 346 |
305 var tdNode = document.createElement('td'); | 347 var tdNode = document.createElement('td'); |
306 tdNode.appendChild(base.createLinkNode(ui.displayURLForBuilder(build erName), builderName.replace('WebKit ', ''))); | 348 tdNode.appendChild(ui.createLinkNode(ui.displayURLForBuilder(builder Name), builderName.replace('WebKit ', ''))); |
307 trNode.appendChild(tdNode); | 349 trNode.appendChild(tdNode); |
308 | 350 |
309 var tdNode = document.createElement('td'); | 351 var tdNode = document.createElement('td'); |
310 tdNode.appendChild(document.createTextNode(latestRevisions[builderNa me])); | 352 tdNode.appendChild(document.createTextNode(latestRevisions[builderNa me])); |
311 trNode.appendChild(tdNode); | 353 trNode.appendChild(tdNode); |
312 | 354 |
313 revisionsTableNode.appendChild(trNode); | 355 revisionsTableNode.appendChild(trNode); |
314 }); | 356 }); |
315 | 357 |
316 var revisionsNode = document.createElement('details'); | 358 var revisionsNode = document.createElement('details'); |
(...skipping 13 matching lines...) Expand all Loading... | |
330 } | 372 } |
331 }); | 373 }); |
332 $(summaryLinkNode).mouseout(function(ev) { | 374 $(summaryLinkNode).mouseout(function(ev) { |
333 if (!revisionsNode.open) { | 375 if (!revisionsNode.open) { |
334 $(revisionsPopUp).removeClass("active"); | 376 $(revisionsPopUp).removeClass("active"); |
335 } | 377 } |
336 }); | 378 }); |
337 | 379 |
338 var totRevision = model.latestRevision(); | 380 var totRevision = model.latestRevision(); |
339 theSpan.appendChild(document.createTextNode(', trunk is at ')); | 381 theSpan.appendChild(document.createTextNode(', trunk is at ')); |
340 theSpan.appendChild(base.createLinkNode(trac.changesetURL(totRevision), totRevision)); | 382 theSpan.appendChild(ui.createLinkNode(trac.changesetURL(totRevision), to tRevision)); |
341 | 383 |
342 checkout.lastBlinkRollRevision().then(function(revision) { | 384 checkout.lastBlinkRollRevision().then(function(revision) { |
343 theSpan.appendChild(document.createTextNode(', last roll is to ')); | 385 theSpan.appendChild(document.createTextNode(', last roll is to ')); |
344 theSpan.appendChild(base.createLinkNode(trac.changesetURL(revision), revision)); | 386 theSpan.appendChild(ui.createLinkNode(trac.changesetURL(revision), r evision)); |
345 }, function() {}); | 387 }, function() {}); |
346 | 388 |
347 rollbot.fetchCurrentRoll().then(function(roll) { | 389 rollbot.fetchCurrentRoll().then(function(roll) { |
348 theSpan.appendChild(document.createTextNode(', current autoroll ')); | 390 theSpan.appendChild(document.createTextNode(', current autoroll ')); |
349 if (roll) { | 391 if (roll) { |
350 var linkText = "" + roll.fromRevision + ":" + roll.toRevision; | 392 var linkText = "" + roll.fromRevision + ":" + roll.toRevision; |
351 theSpan.appendChild(base.createLinkNode(roll.url, linkText)); | 393 theSpan.appendChild(ui.createLinkNode(roll.url, linkText)); |
352 if (roll.isStopped) | 394 if (roll.isStopped) |
353 theSpan.appendChild(document.createTextNode(' (STOPPED) ')); | 395 theSpan.appendChild(document.createTextNode(' (STOPPED) ')); |
354 } else { | 396 } else { |
355 theSpan.appendChild(document.createTextNode(' None')); | 397 theSpan.appendChild(document.createTextNode(' None')); |
356 } | 398 } |
357 }); | 399 }); |
358 } | 400 } |
359 }); | 401 }); |
360 | 402 |
361 })(); | 403 })(); |
OLD | NEW |