OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 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 function MiloInject(root, mastername) { | |
6 // Get our ".header" <div> (in "layout.html"). | |
7 var header = document.querySelector(".header"); | |
8 if (! header) { | |
9 return; | |
10 } | |
11 | |
12 // Do we have a Milo substitution avialable? | |
estaab
2016/11/09 23:24:56
available
dnj
2016/11/10 00:22:55
Done.
| |
13 var path = window.location.pathname; | |
14 var desc = null; | |
15 var miloPath = path; | |
16 [ | |
17 { | |
18 re: /^(?:\/[ip]\/([^\/]+))?\/builders\/([^\/]+)$/, | |
19 desc: "builder faster", | |
20 replacer: function(match, master, builder, offset, string) { | |
21 master = mastername || master; | |
22 if (! master) { | |
23 return string; | |
24 } | |
25 return ["buildbot", master, builder].join("/"); | |
26 }, | |
27 }, | |
28 { | |
29 re: /^(?:\/[ip]\/([^\/]+))?\/builders\/([^\/]+)\/builds\/([^\/]+)\/$/, | |
30 desc: "build faster and forever", | |
31 replacer: function(match, master, builder, buildno, offset, string) { | |
32 master = mastername || master; | |
33 if (! master) { | |
34 return string; | |
35 } | |
36 return ["buildbot", master, builder, buildno].join("/"); | |
37 }, | |
38 }, | |
39 ].every(function(e) { | |
40 miloPath = path.replace(e.re, e.replacer); | |
41 desc = e.desc; | |
42 return (miloPath === path); | |
43 }); | |
44 if (miloPath === path) { | |
45 return; | |
46 } | |
47 | |
48 // Build our milo elements. | |
49 miloPath = "https://luci-milo.appspot.com/" + miloPath; | |
50 var miloElement = document.createElement("span"); | |
51 miloElement.className = "header-right-align"; | |
52 miloElement.innerHTML += ` | |
estaab
2016/11/09 23:24:56
Not sure if we're supposed to be using ES6 templat
dnj
2016/11/10 00:22:55
SGTM. It's been in Chromium since M41, and we're o
estaab
2016/11/10 00:29:27
Someone on the web platform team pushed back when
| |
53 <div class="milo-container"> | |
54 <a class="milo-link" href="${miloPath}"> | |
55 <img class=".milo-logo" | |
56 src="${root}chrome-infra-logo-32x32.png" />[LogDog]</a> | |
57 <div class="milo-info"> | |
58 <div>View this ${desc} with LogDog / Milo!</div> | |
59 <p></p> | |
60 <div><a href="${miloPath}">Permalink</a></div> | |
61 <p></p> | |
62 <div class="milo-cit-info"> | |
63 <img src="${root}chrome-infra-logo-32x32.png"></img> | |
64 <span>Part of Chrome Infrastructure Team's LUCI project.</span> | |
65 </div> | |
66 </div> | |
67 </div> | |
68 `; | |
69 header.appendChild(miloElement); | |
70 } | |
OLD | NEW |