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('#') === 0) |
| 75 return; |
| 76 if (ui.useNewWindowForLinks) |
| 77 anchor.target = '_blank'; |
| 78 else |
| 79 anchor.removeAttribute('target'); |
| 80 } |
| 81 |
| 82 ui.setUseNewWindowForLinks = function(enabled) |
| 83 { |
| 84 ui.useNewWindowForLinks = enabled; |
| 85 if (enabled) |
| 86 localStorage[ui.kUseNewWindowForLinksSetting] = 'true'; |
| 87 else |
| 88 delete localStorage[ui.kUseNewWindowForLinksSetting]; |
| 89 |
| 90 $('a').each(function() { |
| 91 ui.setTargetForLink(this); |
| 92 }); |
| 93 } |
| 94 ui.setUseNewWindowForLinks(!!localStorage[ui.kUseNewWindowForLinksSetting]); |
| 95 |
| 96 ui.createLinkNode = function(url, textContent) |
| 97 { |
| 98 var link = document.createElement('a'); |
| 99 link.href = url; |
| 100 ui.setTargetForLink(link); |
| 101 link.appendChild(document.createTextNode(textContent)); |
| 102 return link; |
| 103 } |
| 104 |
70 ui.onebar = base.extends('div', { | 105 ui.onebar = base.extends('div', { |
71 init: function() | 106 init: function() |
72 { | 107 { |
73 this.id = 'onebar'; | 108 this.id = 'onebar'; |
74 this.innerHTML = | 109 this.innerHTML = |
75 '<ul>' + | 110 '<ul>' + |
76 '<li><a href="#unexpected">Unexpected Failures</a></li>' + | 111 '<li><a href="#unexpected">Unexpected Failures</a></li>' + |
77 '<li><a href="#expected">Expected Failures</a></li>' + | 112 '<li><a href="#expected">Expected Failures</a></li>' + |
78 '<li><a href="#results">Results</a></li>' + | 113 '<li><a href="#results">Results</a></li>' + |
79 '</ul>' + | 114 '</ul>' + |
| 115 '<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>' + | 116 '<div id="unexpected"></div>' + |
81 '<div id="expected"></div>' + | 117 '<div id="expected"></div>' + |
82 '<div id="results"></div>'; | 118 '<div id="results"></div>'; |
83 this._tabNames = [ | 119 this._tabNames = [ |
84 'unexpected', | 120 'unexpected', |
85 'expected', | 121 'expected', |
86 'results', | 122 'results', |
87 ] | 123 ] |
88 | 124 |
89 this._tabIndexToSavedScrollOffset = {}; | 125 this._tabIndexToSavedScrollOffset = {}; |
90 this._tabs = $(this).tabs({ | 126 this._tabs = $(this).tabs({ |
91 disabled: [2], | 127 disabled: [2], |
92 show: function(event, ui) { this._restoreScrollOffset(ui.index); }, | 128 show: function(event, ui) { this._restoreScrollOffset(ui.index); }, |
| 129 select: function(event, ui) { |
| 130 this._saveScrollOffset(); |
| 131 window.location.hash = ui.tab.hash; |
| 132 }.bind(this) |
93 }); | 133 }); |
94 }, | 134 }, |
95 _saveScrollOffset: function() { | 135 _saveScrollOffset: function() { |
96 var tabIndex = this._tabs.tabs('option', 'selected'); | 136 var tabIndex = this._tabs.tabs('option', 'selected'); |
97 this._tabIndexToSavedScrollOffset[tabIndex] = document.body.scrollTop; | 137 this._tabIndexToSavedScrollOffset[tabIndex] = document.body.scrollTop; |
98 }, | 138 }, |
99 _restoreScrollOffset: function(tabIndex) | 139 _restoreScrollOffset: function(tabIndex) |
100 { | 140 { |
101 document.body.scrollTop = this._tabIndexToSavedScrollOffset[tabIndex] ||
0; | 141 document.body.scrollTop = this._tabIndexToSavedScrollOffset[tabIndex] ||
0; |
102 }, | 142 }, |
103 _setupHistoryHandlers: function() | 143 _setupHistoryHandlers: function() |
104 { | 144 { |
105 function currentHash() { | 145 function currentHash() { |
106 var hash = window.location.hash; | 146 var hash = window.location.hash; |
107 return (!hash || hash == '#') ? '#unexpected' : hash; | 147 return (!hash || hash == '#') ? '#unexpected' : hash; |
108 } | 148 } |
109 | 149 |
110 var self = this; | 150 var self = this; |
111 $('.ui-tabs-nav a').bind('mouseup', function(event) { | |
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) { | 151 window.onhashchange = function(event) { |
121 var tabName = currentHash().substring(1); | 152 var tabName = currentHash().substring(1); |
122 self._selectInternal(tabName); | 153 self._selectInternal(tabName); |
123 }; | 154 }; |
124 | 155 |
125 // When navigating from the browser chrome, we'll | 156 // When navigating from the browser chrome, we'll |
126 // scroll to the #tabname contents. popstate fires before | 157 // scroll to the #tabname contents. popstate fires before |
127 // we scroll, so we can save the scroll offset first. | 158 // we scroll, so we can save the scroll offset first. |
128 window.onpopstate = function() { | 159 window.onpopstate = function() { |
129 self._saveScrollOffset(); | 160 self._saveScrollOffset(); |
130 }; | 161 }; |
131 }, | 162 }, |
| 163 _setupLinkSettingHandler: function() |
| 164 { |
| 165 $('#new-window-for-links').attr('checked', ui.useNewWindowForLinks); |
| 166 $('#new-window-for-links').change(function(event) { |
| 167 ui.setUseNewWindowForLinks(this.checked); |
| 168 }); |
| 169 }, |
132 attach: function() | 170 attach: function() |
133 { | 171 { |
134 document.body.insertBefore(this, document.body.firstChild); | 172 document.body.insertBefore(this, document.body.firstChild); |
| 173 this._setupLinkSettingHandler(); |
135 this._setupHistoryHandlers(); | 174 this._setupHistoryHandlers(); |
136 }, | 175 }, |
137 tabNamed: function(tabName) | 176 tabNamed: function(tabName) |
138 { | 177 { |
139 if (this._tabNames.indexOf(tabName) == -1) | 178 if (this._tabNames.indexOf(tabName) == -1) |
140 return null; | 179 return null; |
141 tab = document.getElementById(tabName); | 180 tab = document.getElementById(tabName); |
142 // We perform this sanity check below to make sure getElementById | 181 // 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. | 182 // 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 | 183 // 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: ')); | 327 theSpan.appendChild(document.createTextNode('Latest revision processed b
y every bot: ')); |
289 | 328 |
290 var latestRevision = model.latestRevisionWithNoBuildersInFlight(); | 329 var latestRevision = model.latestRevisionWithNoBuildersInFlight(); |
291 var latestRevisions = model.latestRevisionByBuilder(); | 330 var latestRevisions = model.latestRevisionByBuilder(); |
292 | 331 |
293 // Get the list of builders sorted with the most recent one first. | 332 // Get the list of builders sorted with the most recent one first. |
294 var builders = Object.keys(latestRevisions); | 333 var builders = Object.keys(latestRevisions); |
295 builders.sort(function (a, b) { return parseInt(latestRevisions[b]) - pa
rseInt(latestRevisions[a]);}); | 334 builders.sort(function (a, b) { return parseInt(latestRevisions[b]) - pa
rseInt(latestRevisions[a]);}); |
296 | 335 |
297 var summaryNode = document.createElement('summary'); | 336 var summaryNode = document.createElement('summary'); |
298 var summaryLinkNode = base.createLinkNode(trac.changesetURL(latestRevisi
on), latestRevision); | 337 var summaryLinkNode = ui.createLinkNode(trac.changesetURL(latestRevision
), latestRevision); |
299 summaryNode.appendChild(summaryLinkNode); | 338 summaryNode.appendChild(summaryLinkNode); |
300 | 339 |
301 var revisionsTableNode = document.createElement('table'); | 340 var revisionsTableNode = document.createElement('table'); |
302 builders.forEach(function(builderName) { | 341 builders.forEach(function(builderName) { |
303 var trNode = document.createElement('tr'); | 342 var trNode = document.createElement('tr'); |
304 | 343 |
305 var tdNode = document.createElement('td'); | 344 var tdNode = document.createElement('td'); |
306 tdNode.appendChild(base.createLinkNode(ui.displayURLForBuilder(build
erName), builderName.replace('WebKit ', ''))); | 345 tdNode.appendChild(ui.createLinkNode(ui.displayURLForBuilder(builder
Name), builderName.replace('WebKit ', ''))); |
307 trNode.appendChild(tdNode); | 346 trNode.appendChild(tdNode); |
308 | 347 |
309 var tdNode = document.createElement('td'); | 348 var tdNode = document.createElement('td'); |
310 tdNode.appendChild(document.createTextNode(latestRevisions[builderNa
me])); | 349 tdNode.appendChild(document.createTextNode(latestRevisions[builderNa
me])); |
311 trNode.appendChild(tdNode); | 350 trNode.appendChild(tdNode); |
312 | 351 |
313 revisionsTableNode.appendChild(trNode); | 352 revisionsTableNode.appendChild(trNode); |
314 }); | 353 }); |
315 | 354 |
316 var revisionsNode = document.createElement('details'); | 355 var revisionsNode = document.createElement('details'); |
(...skipping 13 matching lines...) Expand all Loading... |
330 } | 369 } |
331 }); | 370 }); |
332 $(summaryLinkNode).mouseout(function(ev) { | 371 $(summaryLinkNode).mouseout(function(ev) { |
333 if (!revisionsNode.open) { | 372 if (!revisionsNode.open) { |
334 $(revisionsPopUp).removeClass("active"); | 373 $(revisionsPopUp).removeClass("active"); |
335 } | 374 } |
336 }); | 375 }); |
337 | 376 |
338 var totRevision = model.latestRevision(); | 377 var totRevision = model.latestRevision(); |
339 theSpan.appendChild(document.createTextNode(', trunk is at ')); | 378 theSpan.appendChild(document.createTextNode(', trunk is at ')); |
340 theSpan.appendChild(base.createLinkNode(trac.changesetURL(totRevision),
totRevision)); | 379 theSpan.appendChild(ui.createLinkNode(trac.changesetURL(totRevision), to
tRevision)); |
341 | 380 |
342 checkout.lastBlinkRollRevision().then(function(revision) { | 381 checkout.lastBlinkRollRevision().then(function(revision) { |
343 theSpan.appendChild(document.createTextNode(', last roll is to ')); | 382 theSpan.appendChild(document.createTextNode(', last roll is to ')); |
344 theSpan.appendChild(base.createLinkNode(trac.changesetURL(revision),
revision)); | 383 theSpan.appendChild(ui.createLinkNode(trac.changesetURL(revision), r
evision)); |
345 }, function() {}); | 384 }, function() {}); |
346 | 385 |
347 rollbot.fetchCurrentRoll().then(function(roll) { | 386 rollbot.fetchCurrentRoll().then(function(roll) { |
348 theSpan.appendChild(document.createTextNode(', current autoroll ')); | 387 theSpan.appendChild(document.createTextNode(', current autoroll ')); |
349 if (roll) { | 388 if (roll) { |
350 var linkText = "" + roll.fromRevision + ":" + roll.toRevision; | 389 var linkText = "" + roll.fromRevision + ":" + roll.toRevision; |
351 theSpan.appendChild(base.createLinkNode(roll.url, linkText)); | 390 theSpan.appendChild(ui.createLinkNode(roll.url, linkText)); |
352 if (roll.isStopped) | 391 if (roll.isStopped) |
353 theSpan.appendChild(document.createTextNode(' (STOPPED) ')); | 392 theSpan.appendChild(document.createTextNode(' (STOPPED) ')); |
354 } else { | 393 } else { |
355 theSpan.appendChild(document.createTextNode(' None')); | 394 theSpan.appendChild(document.createTextNode(' None')); |
356 } | 395 } |
357 }); | 396 }); |
358 } | 397 } |
359 }); | 398 }); |
360 | 399 |
361 })(); | 400 })(); |
OLD | NEW |