| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 * Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 2 * Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 3 * source code is governed by a BSD-style license that can be found in the | 3 * source code is governed by a BSD-style license that can be found in the |
| 4 * LICENSE file. | 4 * LICENSE file. |
| 5 --> | 5 --> |
| 6 <html> | 6 <html> |
| 7 <head> | 7 <head> |
| 8 <style> | 8 <style> |
| 9 body { | 9 body { |
| 10 overflow-x: hidden; | 10 overflow-x: hidden; |
| 11 } | 11 } |
| 12 | 12 |
| 13 .heading { | 13 .heading { |
| 14 font-family: Helvetica, Arial; | 14 font-family: Helvetica, Arial; |
| 15 font-size: small; | 15 font-size: small; |
| 16 font-weight: bold; | 16 font-weight: bold; |
| 17 margin-left: 2px; | 17 margin-left: 2px; |
| 18 } | 18 } |
| 19 | 19 |
| 20 .feedList { | 20 .feedList { |
| 21 font-family: Helvetica, Arial; | 21 font-family: Helvetica, Arial; |
| 22 font-size: small; | 22 font-size: small; |
| 23 vertical-align: bottom; | 23 vertical-align: bottom; |
| 24 } | 24 } |
| 25 </style> | 25 </style> |
| 26 <script> | 26 <script type="text/javascript" src="popup.js"></script> |
| 27 function feedLink(url) { | |
| 28 var feed_link = document.createElement('a'); | |
| 29 feed_link.href = url; | |
| 30 feed_link.addEventListener("click", onClick); | |
| 31 return feed_link; | |
| 32 } | |
| 33 | |
| 34 function main() { | |
| 35 chrome.tabs.getSelected(null, function(tab) { | |
| 36 var feeds = chrome.extension.getBackgroundPage().feedData[tab.id]; | |
| 37 if (feeds.length == 1) { | |
| 38 // Only one feed, no need for a bubble; go straight to the subscribe page. | |
| 39 preview(feeds[0].href); | |
| 40 } else { | |
| 41 var content = document.getElementById('content'); | |
| 42 var heading = document.getElementById('heading'); | |
| 43 heading.innerText = | |
| 44 chrome.i18n.getMessage("rss_subscription_action_title"); | |
| 45 content.appendChild(document.createElement('br')); | |
| 46 | |
| 47 var feed_list = document.createElement('table'); | |
| 48 feed_list.style.width = "400"; | |
| 49 for (var i = 0; i < feeds.length; ++i) { | |
| 50 // Create an RSS image and the anhor encapsulating it. | |
| 51 var img_link = feedLink(feeds[i].href); | |
| 52 var img = document.createElement('img'); | |
| 53 img.src = "feed-icon-16x16.png"; | |
| 54 img_link.appendChild(img); | |
| 55 | |
| 56 // Create a text node and the anchor encapsulating it. | |
| 57 var text_link = feedLink(feeds[i].href); | |
| 58 text_link.appendChild(document.createTextNode(feeds[i].title)); | |
| 59 | |
| 60 // Add the data to a row in the table. | |
| 61 var tr = document.createElement('tr'); | |
| 62 tr.className = "feedList"; | |
| 63 var td = document.createElement('td'); | |
| 64 td.width = "16"; | |
| 65 td.appendChild(img_link); | |
| 66 var td2 = document.createElement('td'); | |
| 67 td2.appendChild(text_link); | |
| 68 tr.appendChild(td); | |
| 69 tr.appendChild(td2); | |
| 70 feed_list.appendChild(tr); | |
| 71 } | |
| 72 | |
| 73 content.appendChild(feed_list); | |
| 74 } | |
| 75 }); | |
| 76 } | |
| 77 | |
| 78 function onClick(event) { | |
| 79 var a = event.currentTarget; | |
| 80 preview(a.href); | |
| 81 } | |
| 82 | |
| 83 function preview(feed_url) { | |
| 84 // See if we need to skip the preview page and subscribe directly. | |
| 85 var url = ""; | |
| 86 if (window.localStorage && window.localStorage.showPreviewPage == "No") { | |
| 87 // Skip the preview. | |
| 88 url = window.localStorage.defaultReader.replace("%s", escape(feed_url)); | |
| 89 } else { | |
| 90 // Show the preview page. | |
| 91 url = "subscribe.html?" + encodeURIComponent(feed_url); | |
| 92 } | |
| 93 chrome.tabs.create({ url: url }); | |
| 94 window.close(); | |
| 95 } | |
| 96 </script> | |
| 97 </head> | 27 </head> |
| 98 <body onload="javascript:main()"> | 28 <body> |
| 99 <div id="content"> | 29 <div id="content"> |
| 100 <span id="heading" class="heading">Loading...</span> | 30 <span id="heading" class="heading">Loading...</span> |
| 101 </div> | 31 </div> |
| 102 </body> | 32 </body> |
| 103 </html> | 33 </html> |
| OLD | NEW |