|
160 | 160 | </div>
|
161 | 161 | <br />
|
162 | 162 | <div id="app">
|
163 |
| - <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="before">???</span> and <span |
164 |
| - id="after">???</span></h1> |
| 163 | + <h1>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{{before}}</span> and |
| 164 | + <span id="after">{{after}}</span> |
| 165 | + </h1> |
165 | 166 | <fieldset id="settings">
|
166 | 167 | <legend id="search-toggle" class="section-heading">Do another comparison<span
|
167 | 168 | id="search-toggle-indicator"></span></legend>
|
@@ -349,6 +350,13 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
|
349 | 350 | <script src="https://cdnjs.cloudflare.com/ajax/libs/msgpack-lite/0.1.26/msgpack.min.js"></script>
|
350 | 351 | <script src="shared.js"></script>
|
351 | 352 | <script>
|
| 353 | + function findQueryParam(name) { |
| 354 | + let urlParams = window.location.search.substring(1).split("&").map(x => x.split("=")); |
| 355 | + let pair = urlParams.find(x => x[0] === name) |
| 356 | + if (pair) { |
| 357 | + return unescape(pair[1]); |
| 358 | + } |
| 359 | + } |
352 | 360 | let app = new Vue({
|
353 | 361 | el: '#app',
|
354 | 362 | data: {
|
@@ -461,6 +469,21 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
|
461 | 469 | };
|
462 | 470 | }).sort((a, b) => Math.abs(b.percent) - Math.abs(a.percent));
|
463 | 471 | },
|
| 472 | + before() { |
| 473 | + if (!this.data) { |
| 474 | + return findQueryParam("start").substring(0, 7); |
| 475 | + } |
| 476 | + return `#${this.data.a.pr}` || this.formatDate(this.data.a.date) || this.data.a.commit.substring(0, 7); |
| 477 | + }, |
| 478 | + after() { |
| 479 | + if (!this.data) { |
| 480 | + return findQueryParam("end").substring(0, 7); |
| 481 | + } |
| 482 | + return `#${this.data.b.pr}` || this.formatDate(this.data.b.date) || this.data.b.commit.substring(0, 7); |
| 483 | + }, |
| 484 | + stat() { |
| 485 | + return findQueryParam("stat"); |
| 486 | + } |
464 | 487 | },
|
465 | 488 | methods: {
|
466 | 489 | short(comparison) {
|
@@ -575,31 +598,10 @@ <h1>Comparing <span id="stat-header">instructions:u</span> between <span id="bef
|
575 | 598 | stat: "instructions:u",
|
576 | 599 | }, state);
|
577 | 600 | makeRequest("/get", values).then(function (data) {
|
578 |
| - updateHeader(data.a.commit, data.b.commit); |
579 | 601 | app.data = data;
|
580 | 602 | });
|
581 | 603 | }
|
582 | 604 |
|
583 |
| - function updateHeader(a, b, stat) { |
584 |
| - let shorten = (text) => { |
585 |
| - return text.substring(0, 7); |
586 |
| - } |
587 |
| - a && (document.getElementById("before").innerHTML = shorten(a)); |
588 |
| - b && (document.getElementById("after").innerHTML = shorten(b)); |
589 |
| - stat && (document.getElementById("stat-header").innerHTML = stat); |
590 |
| - } |
591 |
| - |
592 |
| - function findQueryParam(name) { |
593 |
| - let urlParams = window.location.search.substring(1).split("&").map(x => x.split("=")); |
594 |
| - let pair = urlParams.find(x => x[0] === name) |
595 |
| - if (pair) { |
596 |
| - return unescape(pair[1]); |
597 |
| - } |
598 |
| - } |
599 |
| - let start = findQueryParam("start"); |
600 |
| - let end = findQueryParam("end"); |
601 |
| - let stat = findQueryParam("stat") |
602 |
| - updateHeader(start, end, stat); |
603 | 605 |
|
604 | 606 | function submitSettings() {
|
605 | 607 | let start = document.getElementById("start-bound").value;
|
|
0 commit comments