]>
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 | ||
0e091d38 AD |
35 | function notify_callback() { |
36 | var container = document.getElementById('notify'); | |
37 | if (xmlhttp.readyState == 4) { | |
38 | container.innerHTML=xmlhttp.responseText; | |
39 | } | |
40 | } | |
41 | ||
175847de | 42 | |
0e091d38 | 43 | function updateFeedList() { |
007bda35 AD |
44 | |
45 | document.getElementById("feeds").innerHTML = "Loading feeds, please wait..."; | |
46 | ||
47 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
48 | xmlhttp.onreadystatechange=feedlist_callback; | |
49 | xmlhttp.send(null); | |
50 | ||
51 | } | |
52 | ||
53 | function toggleSelectRow(sender) { | |
54 | var parent_row = sender.parentNode.parentNode; | |
55 | ||
56 | if (sender.checked) { | |
57 | if (!parent_row.className.match("Selected")) { | |
58 | parent_row.className = parent_row.className + "Selected"; | |
59 | } | |
60 | } else { | |
61 | if (parent_row.className.match("Selected")) { | |
62 | parent_row.className = parent_row.className.replace("Selected", ""); | |
63 | } | |
64 | } | |
65 | } | |
66 | ||
71ad3959 AD |
67 | function addFeed() { |
68 | ||
331900c6 AD |
69 | var link = document.getElementById("fadd_link"); |
70 | ||
83fe4d6d | 71 | if (link.value.length == 0) { |
c753cd32 | 72 | notify("Missing feed URL."); |
331900c6 AD |
73 | } else { |
74 | notify("Adding feed..."); | |
75 | ||
76 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" + | |
77 | param_escape(link.value), true); | |
78 | xmlhttp.onreadystatechange=feedlist_callback; | |
79 | xmlhttp.send(null); | |
80 | ||
81 | link.value = ""; | |
82 | ||
83 | } | |
84 | ||
85 | } | |
86 | ||
87 | function editFeed(feed) { | |
88 | ||
89 | notify("Editing feed..."); | |
90 | ||
91 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" + | |
92 | param_escape(feed), true); | |
93 | xmlhttp.onreadystatechange=feedlist_callback; | |
94 | xmlhttp.send(null); | |
95 | ||
96 | } | |
97 | ||
83fe4d6d | 98 | function getSelectedFeeds() { |
331900c6 AD |
99 | |
100 | var content = document.getElementById("prefFeedList"); | |
101 | ||
102 | var sel_rows = new Array(); | |
103 | ||
104 | for (i = 0; i < content.rows.length; i++) { | |
105 | if (content.rows[i].className.match("Selected")) { | |
106 | var row_id = content.rows[i].id.replace("FEEDR-", ""); | |
107 | sel_rows.push(row_id); | |
108 | } | |
109 | } | |
110 | ||
83fe4d6d AD |
111 | return sel_rows; |
112 | } | |
113 | ||
114 | function readSelectedFeeds() { | |
115 | ||
116 | var sel_rows = getSelectedFeeds(); | |
117 | ||
118 | if (sel_rows.length > 0) { | |
119 | ||
120 | notify("Marking selected feeds as read..."); | |
121 | ||
0e091d38 | 122 | xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ |
83fe4d6d | 123 | param_escape(sel_rows.toString()), true); |
0e091d38 | 124 | xmlhttp.onreadystatechange=notify_callback; |
83fe4d6d AD |
125 | xmlhttp.send(null); |
126 | ||
127 | } else { | |
128 | ||
c753cd32 | 129 | notify("Please select some feeds first."); |
83fe4d6d AD |
130 | |
131 | } | |
132 | } | |
133 | ||
134 | function unreadSelectedFeeds() { | |
135 | ||
136 | var sel_rows = getSelectedFeeds(); | |
137 | ||
138 | if (sel_rows.length > 0) { | |
139 | ||
140 | notify("Marking selected feeds as unread..."); | |
141 | ||
0e091d38 | 142 | xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ |
83fe4d6d | 143 | param_escape(sel_rows.toString()), true); |
0e091d38 | 144 | xmlhttp.onreadystatechange=notify_callback; |
83fe4d6d AD |
145 | xmlhttp.send(null); |
146 | ||
147 | } else { | |
148 | ||
c753cd32 | 149 | notify("Please select some feeds first."); |
83fe4d6d AD |
150 | |
151 | } | |
152 | } | |
153 | ||
154 | function removeSelectedFeeds() { | |
155 | ||
156 | var sel_rows = getSelectedFeeds(); | |
157 | ||
331900c6 AD |
158 | if (sel_rows.length > 0) { |
159 | ||
160 | notify("Removing selected feeds..."); | |
161 | ||
162 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
163 | param_escape(sel_rows.toString()), true); | |
164 | xmlhttp.onreadystatechange=feedlist_callback; | |
165 | xmlhttp.send(null); | |
71ad3959 | 166 | |
71ad3959 | 167 | } else { |
331900c6 | 168 | |
c753cd32 | 169 | notify("Please select some feeds first."); |
331900c6 | 170 | |
71ad3959 AD |
171 | } |
172 | ||
173 | } | |
007bda35 AD |
174 | |
175 | function init() { | |
857a9270 | 176 | |
0e091d38 | 177 | updateFeedList(); |
007bda35 | 178 | |
857a9270 AD |
179 | notify(""); |
180 | ||
007bda35 | 181 | } |