]> Cypherpunks repositories - gostls13.git/commitdiff
gophertool: fix links
authorShenghou Ma <minux.ma@gmail.com>
Sun, 21 Oct 2012 17:05:21 +0000 (01:05 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Sun, 21 Oct 2012 17:05:21 +0000 (01:05 +0800)
R=bradfitz
CC=golang-dev
https://golang.org/cl/6713043

misc/chrome/gophertool/popup.html
misc/chrome/gophertool/popup.js

index aec10048a3079edab85ec070e8fe8dafefa83eee..8bb7795faca16ca64199fe56b3830f02c1f05dd2 100644 (file)
@@ -9,11 +9,11 @@
 <script src="popup.js"></script>
 </head>
 <body style='margin: 0.5em; font-family: sans;'>
-<small><a href="#" onclick="openURL('http://code.google.com/p/go/issues/list')">issue</a>,
-<a href="#" onclick="openURL('http://codereview.appspot.com/')">codereview</a>,
-<a href="#" onclick="openURL('http://code.google.com/p/go/source/list')">commit</a>, or
-<a href="#" onclick="openURL('http://golang.org/pkg/')">pkg</a> id/name:</small>
+<small><a href="#" url="http://code.google.com/p/go/issues/list">issue</a>,
+<a href="#" url="http://codereview.appspot.com/">codereview</a>,
+<a href="#" url="http://code.google.com/p/go/source/list">commit</a>, or
+<a href="#" url="http://golang.org/pkg/">pkg</a> id/name:</small>
 <form style='margin: 0' id='navform'><nobr><input id="inputbox" size=10 tabindex=1 /><input type="submit" value="go" /></nobr></form>
-<small>Also: <a href="#" id='buildbotslink'>buildbots</small>
+<small>Also: <a href="#" url="http://build.golang.org">buildbots</a></small>
 </body>
 </html>
index 717fc169cd6c5fd588408578df2102afba9365f2..410d65120e6f067023f1c407b5dc76adfdae4e15 100644 (file)
@@ -2,7 +2,19 @@ function openURL(url) {
   chrome.tabs.create({ "url": url })
 }
 
+function addLinks() {
+  var links = document.getElementsByTagName("a");
+  for (var i = 0; i < links.length; i++) {
+    var url = links[i].getAttribute("url");
+    if (url)
+      links[i].addEventListener("click", function () {
+        openURL(this.getAttribute("url"));
+      });
+  }
+}
+
 window.addEventListener("load", function () {
+  addLinks();
   console.log("hacking gopher pop-up loaded.");
   document.getElementById("inputbox").focus();
 });
@@ -32,7 +44,3 @@ window.addEventListener("submit", function () {
   console.log("no match for text: " + t)
   return false;
 });
-
-window.addEventListener("click", function () {
-  openURL("http://build.golang.org/");
-});