|
| 1 | +var Timeline = (function(window){ |
| 2 | + |
| 3 | +// Localize globals |
| 4 | +var CHANGES_URL = window.CHANGES_URL, readCheckbox = window.readCheckbox, |
| 5 | + getLoadText = window.getLoadText; |
| 6 | + |
| 7 | +var seriesindex = [], |
| 8 | + baselineColor = "#d8b83f", |
| 9 | + seriesColors = ["#4bb2c5", "#EAA228", "#579575", "#953579", "#839557", "#ff5800", "#958c12", "#4b5de4", "#0085cc"], |
| 10 | + defaults; |
| 11 | + |
1 | 12 | function setExeColors() { |
2 | 13 | // Set color data attribute for all executables |
3 | 14 | $("#executable > div.boxbody > ul > ul > li > input").each(function(index) { |
@@ -36,7 +47,7 @@ function getConfiguration() { |
36 | 47 | } |
37 | 48 |
|
38 | 49 | function permalinkToChanges(commitid, executableid, environment) { |
39 | | - window.location=changes_url + "?rev=" + commitid + "&" + "exe=" + executableid + "&env=" + environment; |
| 50 | + window.location=CHANGES_URL + "?rev=" + commitid + "&" + "exe=" + executableid + "&env=" + environment; |
40 | 51 | } |
41 | 52 |
|
42 | 53 | function OnMarkerClickHandler(ev, gridpos, datapos, neighbor, plot) { |
@@ -248,3 +259,79 @@ function refreshSite(event) { |
248 | 259 | setValuesOfInputFields(event); |
249 | 260 | refreshContent(); |
250 | 261 | } |
| 262 | + |
| 263 | +function setValuesOfInputFields(event) { |
| 264 | + // Either set the default value, or the one parsed from the url |
| 265 | + |
| 266 | + // Reset all checkboxes |
| 267 | + $("input:checkbox").removeAttr('checked'); |
| 268 | + |
| 269 | + $("#revisions").val(valueOrDefault(event.parameters.revs, defaults.revisions)); |
| 270 | + $("#baseline").val(valueOrDefault(event.parameters.base, defaults.baseline)); |
| 271 | + |
| 272 | + // Set default selected executables |
| 273 | + var executables = event.parameters.exe ? event.parameters.exe.split(',') : defaults.executables; |
| 274 | + var sel = $("input[name='executable']"); |
| 275 | + |
| 276 | + $.each(executables, function(i, exe) { |
| 277 | + sel.filter("[value='" + exe + "']").attr('checked', true); |
| 278 | + }); |
| 279 | + |
| 280 | + // Set default selected branches |
| 281 | + var branches = event.parameters.bran ? event.parameters.bran.split(',') : defaults.branches; |
| 282 | + sel = $("input[name='branch']"); |
| 283 | + |
| 284 | + $.each(branches, function(i, b) { |
| 285 | + sel.filter("[value='" + b + "']").attr('checked', true); |
| 286 | + }); |
| 287 | + |
| 288 | + // Set default selected benchmark |
| 289 | + var benchmark = valueOrDefault(event.parameters.ben, defaults.benchmark); |
| 290 | + $("input:radio[name='benchmark']") |
| 291 | + .filter("[value='" + benchmark + "']") |
| 292 | + .attr('checked', true); |
| 293 | + |
| 294 | + // Set default selected environment |
| 295 | + var environment = valueOrDefault(event.parameters.env, defaults.environment); |
| 296 | + $("input:radio[name='environments']") |
| 297 | + .filter("[value='" + environment + "']") |
| 298 | + .attr('checked', true); |
| 299 | + |
| 300 | + // Add color legend to executable list |
| 301 | + $("#executable div.boxbody > ul > ul > li > input").each(function() { |
| 302 | + $(this).parent() |
| 303 | + .find("div.seriescolor") |
| 304 | + .css("background-color", getColor($(this).attr("id").slice(10))); |
| 305 | + }); |
| 306 | + |
| 307 | + $("#baselinecolor").css("background-color", baselineColor); |
| 308 | + $("#equidistant").attr('checked', valueOrDefault(event.parameters.equid, defaults.equidistant === "on")); |
| 309 | +} |
| 310 | + |
| 311 | +function init(def) { |
| 312 | + defaults = def; |
| 313 | + |
| 314 | + $.ajaxSetup ({ |
| 315 | + cache: false |
| 316 | + }); |
| 317 | + |
| 318 | + // Even listener for clicks on plot markers |
| 319 | + $.jqplot.eventListenerHooks.push(['jqplotClick', OnMarkerClickHandler]); |
| 320 | + |
| 321 | + // Init and change handlers are set to the refreshContent handler |
| 322 | + $.address.init(initializeSite).change(refreshSite); |
| 323 | + |
| 324 | + $('.checkall, .uncheckall').click(refreshContent); |
| 325 | + |
| 326 | + setExeColors(); |
| 327 | + |
| 328 | + $("#permalink").click(function() { |
| 329 | + window.location = "?" + $.param(getConfiguration()); |
| 330 | + }); |
| 331 | +} |
| 332 | + |
| 333 | +return { |
| 334 | + init: init |
| 335 | +}; |
| 336 | + |
| 337 | +})(window); |
0 commit comments