OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <link rel="stylesheet" type="text/css" href="extensions_toolstrip.css"> |
| 3 <div id="button" class="toolstrip-button"> |
| 4 <img id="icon" src="icon_disabled.png"><span>Subscribe</span> |
| 5 </div> |
| 6 |
| 7 <script> |
| 8 var icon = document.getElementById("icon"); |
| 9 var button = document.getElementById("button"); |
| 10 var enabled = false; |
| 11 var feedUrl, req; |
| 12 |
| 13 button.onclick = handleClick; |
| 14 |
| 15 chromium.self.onConnect.addListener(function(port) { |
| 16 port.onMessage.addListener(function(feedUrls) { |
| 17 // TODO(aa): When we have the ability to display drop downs, we should let |
| 18 // the user pick which feed to subscribe. Right now, we just pick the |
| 19 // first. |
| 20 feedUrl = feedUrls[0]; |
| 21 if (!feedUrl) { |
| 22 icon.src = "icon_disabled.png"; |
| 23 enabled = false; |
| 24 } else { |
| 25 icon.src = "icon.png"; |
| 26 enabled = true; |
| 27 |
| 28 feedUrl = encodeURIComponent(feedUrl); |
| 29 req = new XMLHttpRequest(); |
| 30 req.onload = handleResponse; |
| 31 req.open("GET", |
| 32 "http://www.google.com/reader/api/0/subscribed?s=feed%2F" + fee
dUrl, |
| 33 false); |
| 34 req.send(null); |
| 35 } |
| 36 }); |
| 37 }); |
| 38 |
| 39 function handleResponse() { |
| 40 if (req.responseText == "true") { |
| 41 icon.src = "icon_subscribed.png"; |
| 42 enabled = false; |
| 43 } |
| 44 } |
| 45 |
| 46 function handleClick() { |
| 47 if (enabled) { |
| 48 var url = "http://www.google.com/reader/view/feed/" + feedUrl; |
| 49 chromium.tabs.createTab({url: url}); |
| 50 } |
| 51 } |
| 52 </script> |
| 53 </html> |
OLD | NEW |