diff --git a/misc/chrome/gophertool/background.html b/misc/chrome/gophertool/background.html index 058c18142b..06daa98b14 100644 --- a/misc/chrome/gophertool/background.html +++ b/misc/chrome/gophertool/background.html @@ -6,19 +6,7 @@ --> - + diff --git a/misc/chrome/gophertool/background.js b/misc/chrome/gophertool/background.js new file mode 100644 index 0000000000..d18faa986f --- /dev/null +++ b/misc/chrome/gophertool/background.js @@ -0,0 +1,9 @@ +chrome.omnibox.onInputEntered.addListener(function(t) { + var url = urlForInput(t); + if (url) { + chrome.tabs.getSelected(null, function(tab) { + if (!tab) return; + chrome.tabs.update(tab.id, { "url": url, "selected": true }); + }); + } +}); diff --git a/misc/chrome/gophertool/popup.html b/misc/chrome/gophertool/popup.html index a569392d0d..aec10048a3 100644 --- a/misc/chrome/gophertool/popup.html +++ b/misc/chrome/gophertool/popup.html @@ -6,49 +6,14 @@ --> - + - + issue, codereview, commit, or pkg id/name: -
-Also: buildbots + +Also: buildbots diff --git a/misc/chrome/gophertool/popup.js b/misc/chrome/gophertool/popup.js new file mode 100644 index 0000000000..717fc169cd --- /dev/null +++ b/misc/chrome/gophertool/popup.js @@ -0,0 +1,38 @@ +function openURL(url) { + chrome.tabs.create({ "url": url }) +} + +window.addEventListener("load", function () { + console.log("hacking gopher pop-up loaded."); + document.getElementById("inputbox").focus(); +}); + +window.addEventListener("submit", function () { + console.log("submitting form"); + var box = document.getElementById("inputbox"); + box.focus(); + + var t = box.value; + if (t == "") { + return false; + } + + var success = function(url) { + console.log("matched " + t + " to: " + url) + box.value = ""; + openURL(url); + return false; // cancel form submission + }; + + var url = urlForInput(t); + if (url) { + return success(url); + } + + console.log("no match for text: " + t) + return false; +}); + +window.addEventListener("click", function () { + openURL("http://build.golang.org/"); +});