Brad Fitzpatrick | 09dd5bf | 2011-05-23 14:05:18 -0700 | [diff] [blame] | 1 | <html> |
| 2 | <!-- |
| 3 | Copyright 2011 The Go Authors. All rights reserved. |
| 4 | Use of this source code is governed by a BSD-style |
| 5 | license that can be found in the LICENSE file. |
| 6 | --> |
| 7 | <head> |
Brad Fitzpatrick | f4349f7 | 2011-05-31 13:16:51 -0700 | [diff] [blame] | 8 | <script src="gopher.js"></script> |
| 9 | <script> |
Brad Fitzpatrick | 09dd5bf | 2011-05-23 14:05:18 -0700 | [diff] [blame] | 10 | |
| 11 | function focusinput() { |
Brad Fitzpatrick | f4349f7 | 2011-05-31 13:16:51 -0700 | [diff] [blame] | 12 | document.getElementById("inputbox").focus(); |
Brad Fitzpatrick | 09dd5bf | 2011-05-23 14:05:18 -0700 | [diff] [blame] | 13 | } |
| 14 | |
Brad Fitzpatrick | 09dd5bf | 2011-05-23 14:05:18 -0700 | [diff] [blame] | 15 | function navigate() { |
Brad Fitzpatrick | f4349f7 | 2011-05-31 13:16:51 -0700 | [diff] [blame] | 16 | var box = document.getElementById("inputbox"); |
Brad Fitzpatrick | 09dd5bf | 2011-05-23 14:05:18 -0700 | [diff] [blame] | 17 | box.focus(); |
Brad Fitzpatrick | f4349f7 | 2011-05-31 13:16:51 -0700 | [diff] [blame] | 18 | |
Brad Fitzpatrick | 09dd5bf | 2011-05-23 14:05:18 -0700 | [diff] [blame] | 19 | var t = box.value; |
| 20 | if (t == "") { |
| 21 | return false; |
| 22 | } |
| 23 | |
Brad Fitzpatrick | f4349f7 | 2011-05-31 13:16:51 -0700 | [diff] [blame] | 24 | var success = function(url) { |
Brad Fitzpatrick | 09dd5bf | 2011-05-23 14:05:18 -0700 | [diff] [blame] | 25 | console.log("matched " + t + " to: " + url) |
| 26 | box.value = ""; |
| 27 | openURL(url); |
| 28 | return false; // cancel form submission |
Brad Fitzpatrick | f4349f7 | 2011-05-31 13:16:51 -0700 | [diff] [blame] | 29 | }; |
Brad Fitzpatrick | 09dd5bf | 2011-05-23 14:05:18 -0700 | [diff] [blame] | 30 | |
Brad Fitzpatrick | f4349f7 | 2011-05-31 13:16:51 -0700 | [diff] [blame] | 31 | var url = urlForInput(t); |
| 32 | if (url) { |
| 33 | return success(url); |
| 34 | } |
Brad Fitzpatrick | 09dd5bf | 2011-05-23 14:05:18 -0700 | [diff] [blame] | 35 | |
Brad Fitzpatrick | f4349f7 | 2011-05-31 13:16:51 -0700 | [diff] [blame] | 36 | console.log("no match for text: " + t) |
| 37 | return false; |
Brad Fitzpatrick | 09dd5bf | 2011-05-23 14:05:18 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | function openURL(url) { |
| 41 | chrome.tabs.create({ "url": url }) |
| 42 | } |
| 43 | |
| 44 | </script> |
| 45 | </head> |
| 46 | <body onload="focusinput()" style='margin: 0.5em; font-family: sans;'> |
| 47 | <small><a href="#" onclick="openURL('http://code.google.com/p/go/issues/list')">issue</a>, |
| 48 | <a href="#" onclick="openURL('http://codereview.appspot.com/')">codereview</a>, |
| 49 | <a href="#" onclick="openURL('http://code.google.com/p/go/source/list')">commit</a>, or |
| 50 | <a href="#" onclick="openURL('http://golang.org/pkg/')">pkg</a> id/name:</small> |
| 51 | <form style='margin: 0' onsubmit="return navigate();"><nobr><input id="inputbox" size=10 /><input type="submit" value="go" /></nobr></form> |
| 52 | <small>Also: <a href="#" onclick="openURL('http://godashboard.appspot.com/')">buildbots</small> |
| 53 | </body> |
| 54 | </html> |