forked from adamzr/RSS-Alert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.html
75 lines (71 loc) · 2.57 KB
/
popup.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<meta name="generator" content="HTML Tidy for Windows (vers 14 February 2006), see www.w3.org">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js">
</script>
<style type="text/css" >
li {
white-space: nowrap;
}
</style>
<title>
Add Feeds
</title>
</head>
<body>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16826446-5']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<label for="url">Feed URL:</label>
<form>
<input type="url" id="url"> <input type="button" id="add" value="Add">
</form>
<p id="heading">
There are no feeds being monitored.
</p>
<ul id="list"></ul>
<script type="text/javascript">
//Preload the list
for(index in chrome.extension.getBackgroundPage().RN.feedURLs){
var feedURL = chrome.extension.getBackgroundPage().RN.feedURLs[index];
$("#list").append("<li style='cursor: pointer;'>" + feedURL + "<img class='delete' data-feed='" + feedURL + "' src='x.png'></li>");
}
//Update the heading to say "Feeds", "Feed", or none depends on the number of feeds in the list
updateHeading();
//Handle adding a feed
$("#add").click(function(){
var feedURL = $("#url").val()
chrome.extension.getBackgroundPage().addFeed(feedURL);
$("#list").append("<li style='cursor: pointer;'>" + feedURL + "<img class='delete' data-feed='" + feedURL + "' src='x.png'></li>");
updateHeading();
});
//Handle removing a feed from the list
$(".delete").live("click", function(){
var feedURL = $(this).data("feed");
chrome.extension.getBackgroundPage().removeFeed(feedURL);
$(this).parent("li").fadeOut().remove();
updateHeading();
});
//Update the heading with coreect wording for 0, 1, or more feeds
function updateHeading(){
var feedCount = chrome.extension.getBackgroundPage().RN.feedURLs.length;
var message = "There are no feeds being monitored.";
if(feedCount === 1){
message = "Feed being monitored:"
}
if(feedCount > 1){
message = "Feeds being monitored:"
}
$("#heading").html(message);
}
</script>
</body>
</html>