Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: masters/master.chromium/public_html/common-resources/milo.js

Issue 2491643003: Update waterfall templates to include Milo link. (Closed)
Patch Set: Remove superfluous comment. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: masters/master.chromium/public_html/common-resources/milo.js
diff --git a/masters/master.chromium/public_html/common-resources/milo.js b/masters/master.chromium/public_html/common-resources/milo.js
new file mode 100644
index 0000000000000000000000000000000000000000..359768d19230e9adb5b074aa271134c960519ef3
--- /dev/null
+++ b/masters/master.chromium/public_html/common-resources/milo.js
@@ -0,0 +1,71 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function MiloInject(root, mastername) {
+ // Get our ".header" <div> (in "layout.html").
+ var header = document.querySelector(".header");
+ if (! header) {
+ return;
+ }
+
+ // Do we have a Milo substitution available?
+ var path = window.location.pathname;
+ var desc = null;
+ var miloPath = path;
+ [
+ {
+ re: /^(?:\/[ip]\/([^\/]+))?\/builders\/([^\/]+)$/,
+ desc: "builder faster",
+ replacer: function(match, master, builder, offset, string) {
+ master = mastername || master;
+ if (! master) {
+ return string;
+ }
+ return ["buildbot", master, builder].join("/");
+ },
+ },
+ {
+ re: /^(?:\/[ip]\/([^\/]+))?\/builders\/([^\/]+)\/builds\/([^\/]+)\/$/,
+ desc: "build faster and forever",
+ replacer: function(match, master, builder, buildno, offset, string) {
+ master = mastername || master;
+ if (! master) {
+ return string;
+ }
+ return ["buildbot", master, builder, buildno].join("/");
+ },
+ },
+ ].every(function(e) {
+ miloPath = path.replace(e.re, e.replacer);
+ desc = e.desc;
+ return (miloPath === path);
+ });
+ if (miloPath === path) {
+ return;
+ }
+
+ // Build our milo elements.
+ miloPath = "https://luci-milo.appspot.com/" + miloPath;
+ var miloElement = document.createElement("span");
+ miloElement.className = "header-right-align";
+ miloElement.innerHTML += `
+ <div class="milo-container">
+ <a class="milo-link" href="${miloPath}">
+ <img class=".milo-logo"
+ src="${root}common-resources/chrome-infra-logo-32x32.png" /><!--
+ -->[LogDog]</a>
+ <div class="milo-info">
+ <div>View this ${desc} with LogDog / Milo!</div>
+ <p></p>
+ <div><a href="${miloPath}">Permalink</a></div>
+ <p></p>
+ <div class="milo-cit-info">
+ <img src="${root}common-resources/chrome-infra-logo-32x32.png"></img>
+ <span>Part of Chrome Infrastructure Team's LUCI project.</span>
+ </div>
+ </div>
+ </div>
+ `;
+ header.appendChild(miloElement);
+}
« no previous file with comments | « masters/master.chromium/public_html/common-resources/milo.css ('k') | masters/master.chromium/templates/layout.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698