]>
Commit | Line | Data |
---|---|---|
007bda35 AD |
1 | /* |
2 | This program is Copyright (c) 2003-2005 Andrew Dolgov <cthulhoo@gmail.com> | |
3 | Licensed under GPL v.2 or (at your preference) any later version. | |
4 | */ | |
5 | ||
6 | var xmlhttp = false; | |
7 | ||
8 | /*@cc_on @*/ | |
9 | /*@if (@_jscript_version >= 5) | |
10 | // JScript gives us Conditional compilation, we can cope with old IE versions. | |
11 | // and security blocked creation of the objects. | |
12 | try { | |
13 | xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); | |
14 | } catch (e) { | |
15 | try { | |
16 | xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); | |
17 | } catch (E) { | |
18 | xmlhttp = false; | |
19 | } | |
20 | } | |
21 | @end @*/ | |
22 | ||
23 | if (!xmlhttp && typeof XMLHttpRequest!='undefined') { | |
24 | xmlhttp = new XMLHttpRequest(); | |
25 | } | |
26 | ||
007bda35 AD |
27 | |
28 | function feedlist_callback() { | |
29 | var container = document.getElementById('feeds'); | |
30 | if (xmlhttp.readyState == 4) { | |
31 | container.innerHTML=xmlhttp.responseText; | |
32 | } | |
33 | } | |
34 | ||
35 | function update_feeds() { | |
36 | ||
37 | document.getElementById("feeds").innerHTML = "Loading feeds, please wait..."; | |
38 | ||
39 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
40 | xmlhttp.onreadystatechange=feedlist_callback; | |
41 | xmlhttp.send(null); | |
42 | ||
43 | } | |
44 | ||
45 | function toggleSelectRow(sender) { | |
46 | var parent_row = sender.parentNode.parentNode; | |
47 | ||
48 | if (sender.checked) { | |
49 | if (!parent_row.className.match("Selected")) { | |
50 | parent_row.className = parent_row.className + "Selected"; | |
51 | } | |
52 | } else { | |
53 | if (parent_row.className.match("Selected")) { | |
54 | parent_row.className = parent_row.className.replace("Selected", ""); | |
55 | } | |
56 | } | |
57 | } | |
58 | ||
71ad3959 AD |
59 | function addFeed() { |
60 | ||
331900c6 AD |
61 | var link = document.getElementById("fadd_link"); |
62 | ||
63 | if (link.length == 0) { | |
64 | notify("Missing feed URL."); | |
65 | } else { | |
66 | notify("Adding feed..."); | |
67 | ||
68 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" + | |
69 | param_escape(link.value), true); | |
70 | xmlhttp.onreadystatechange=feedlist_callback; | |
71 | xmlhttp.send(null); | |
72 | ||
73 | link.value = ""; | |
74 | ||
75 | } | |
76 | ||
77 | } | |
78 | ||
79 | function editFeed(feed) { | |
80 | ||
81 | notify("Editing feed..."); | |
82 | ||
83 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" + | |
84 | param_escape(feed), true); | |
85 | xmlhttp.onreadystatechange=feedlist_callback; | |
86 | xmlhttp.send(null); | |
87 | ||
88 | } | |
89 | ||
90 | ||
91 | function removeSelectedFeeds() { | |
92 | ||
93 | var content = document.getElementById("prefFeedList"); | |
94 | ||
95 | var sel_rows = new Array(); | |
96 | ||
97 | for (i = 0; i < content.rows.length; i++) { | |
98 | if (content.rows[i].className.match("Selected")) { | |
99 | var row_id = content.rows[i].id.replace("FEEDR-", ""); | |
100 | sel_rows.push(row_id); | |
101 | } | |
102 | } | |
103 | ||
104 | if (sel_rows.length > 0) { | |
105 | ||
106 | notify("Removing selected feeds..."); | |
107 | ||
108 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
109 | param_escape(sel_rows.toString()), true); | |
110 | xmlhttp.onreadystatechange=feedlist_callback; | |
111 | xmlhttp.send(null); | |
71ad3959 | 112 | |
71ad3959 | 113 | } else { |
331900c6 AD |
114 | |
115 | notify("Please select some feeds first."); | |
116 | ||
71ad3959 AD |
117 | } |
118 | ||
119 | } | |
007bda35 AD |
120 | |
121 | function init() { | |
857a9270 | 122 | |
007bda35 AD |
123 | update_feeds(); |
124 | ||
857a9270 AD |
125 | notify(""); |
126 | ||
007bda35 | 127 | } |