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