]>
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 | ||
961513a3 | 8 | var active_feed = false; |
91ff844a | 9 | var active_feed_cat = false; |
a0d53889 | 10 | var active_filter = false; |
48f0adb0 | 11 | var active_label = false; |
e6cb77a0 | 12 | var active_user = false; |
961513a3 | 13 | |
f5a50b25 AD |
14 | var active_tab = false; |
15 | ||
007bda35 AD |
16 | /*@cc_on @*/ |
17 | /*@if (@_jscript_version >= 5) | |
18 | // JScript gives us Conditional compilation, we can cope with old IE versions. | |
19 | // and security blocked creation of the objects. | |
20 | try { | |
21 | xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); | |
22 | } catch (e) { | |
23 | try { | |
24 | xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); | |
25 | } catch (E) { | |
26 | xmlhttp = false; | |
27 | } | |
28 | } | |
29 | @end @*/ | |
30 | ||
31 | if (!xmlhttp && typeof XMLHttpRequest!='undefined') { | |
32 | xmlhttp = new XMLHttpRequest(); | |
33 | } | |
34 | ||
007bda35 | 35 | function feedlist_callback() { |
f5a50b25 | 36 | var container = document.getElementById('prefContent'); |
007bda35 AD |
37 | if (xmlhttp.readyState == 4) { |
38 | container.innerHTML=xmlhttp.responseText; | |
961513a3 AD |
39 | if (active_feed) { |
40 | var row = document.getElementById("FEEDR-" + active_feed); | |
41 | if (row) { | |
42 | if (!row.className.match("Selected")) { | |
43 | row.className = row.className + "Selected"; | |
44 | } | |
45 | } | |
46 | var checkbox = document.getElementById("FRCHK-" + active_feed); | |
47 | if (checkbox) { | |
48 | checkbox.checked = true; | |
49 | } | |
50 | } | |
f5a50b25 | 51 | p_notify(""); |
007bda35 AD |
52 | } |
53 | } | |
54 | ||
a0d53889 | 55 | function filterlist_callback() { |
f5a50b25 | 56 | var container = document.getElementById('prefContent'); |
a0d53889 | 57 | if (xmlhttp.readyState == 4) { |
f5a50b25 | 58 | |
a0d53889 AD |
59 | container.innerHTML=xmlhttp.responseText; |
60 | ||
61 | if (active_filter) { | |
62 | var row = document.getElementById("FILRR-" + active_filter); | |
63 | if (row) { | |
64 | if (!row.className.match("Selected")) { | |
65 | row.className = row.className + "Selected"; | |
66 | } | |
67 | } | |
68 | var checkbox = document.getElementById("FICHK-" + active_filter); | |
69 | ||
70 | if (checkbox) { | |
71 | checkbox.checked = true; | |
72 | } | |
73 | } | |
f5a50b25 | 74 | p_notify(""); |
a0d53889 AD |
75 | } |
76 | } | |
77 | ||
48f0adb0 | 78 | function labellist_callback() { |
f5a50b25 | 79 | var container = document.getElementById('prefContent'); |
48f0adb0 AD |
80 | if (xmlhttp.readyState == 4) { |
81 | container.innerHTML=xmlhttp.responseText; | |
82 | ||
967955b7 | 83 | if (active_label) { |
48f0adb0 AD |
84 | var row = document.getElementById("LILRR-" + active_label); |
85 | if (row) { | |
86 | if (!row.className.match("Selected")) { | |
87 | row.className = row.className + "Selected"; | |
88 | } | |
89 | } | |
90 | var checkbox = document.getElementById("LICHK-" + active_label); | |
91 | ||
92 | if (checkbox) { | |
93 | checkbox.checked = true; | |
94 | } | |
95 | } | |
f5a50b25 | 96 | p_notify(""); |
48f0adb0 AD |
97 | } |
98 | } | |
4255b24c | 99 | |
e6cb77a0 AD |
100 | function userlist_callback() { |
101 | var container = document.getElementById('prefContent'); | |
102 | if (xmlhttp.readyState == 4) { | |
103 | container.innerHTML=xmlhttp.responseText; | |
104 | ||
1a7572cb AD |
105 | if (active_user) { |
106 | var row = document.getElementById("UMRR-" + active_user); | |
e6cb77a0 AD |
107 | if (row) { |
108 | if (!row.className.match("Selected")) { | |
109 | row.className = row.className + "Selected"; | |
110 | } | |
111 | } | |
1a7572cb | 112 | var checkbox = document.getElementById("UMCHK-" + active_user); |
e6cb77a0 AD |
113 | |
114 | if (checkbox) { | |
115 | checkbox.checked = true; | |
116 | } | |
1a7572cb AD |
117 | } |
118 | ||
e6cb77a0 AD |
119 | p_notify(""); |
120 | } | |
121 | } | |
122 | ||
c6c3a07f | 123 | function infobox_callback() { |
1a7572cb | 124 | if (xmlhttp.readyState == 4) { |
2317ffaa AD |
125 | var box = document.getElementById('infoBox'); |
126 | var shadow = document.getElementById('infoBoxShadow'); | |
127 | ||
128 | if (box) { | |
129 | box.innerHTML=xmlhttp.responseText; | |
130 | if (shadow) { | |
131 | shadow.style.display = "block"; | |
132 | } else { | |
133 | box.style.display = "block"; | |
134 | } | |
c6c3a07f | 135 | } |
1a7572cb AD |
136 | } |
137 | } | |
138 | ||
139 | ||
4255b24c AD |
140 | function prefslist_callback() { |
141 | var container = document.getElementById('prefContent'); | |
142 | if (xmlhttp.readyState == 4) { | |
143 | ||
144 | container.innerHTML=xmlhttp.responseText; | |
145 | ||
146 | p_notify(""); | |
147 | } | |
148 | } | |
149 | ||
b1895692 AD |
150 | function gethelp_callback() { |
151 | var container = document.getElementById('prefHelpBox'); | |
152 | if (xmlhttp.readyState == 4) { | |
153 | ||
154 | container.innerHTML = xmlhttp.responseText; | |
155 | container.style.display = "block"; | |
156 | ||
157 | } | |
158 | } | |
4255b24c AD |
159 | |
160 | ||
0e091d38 AD |
161 | function notify_callback() { |
162 | var container = document.getElementById('notify'); | |
163 | if (xmlhttp.readyState == 4) { | |
164 | container.innerHTML=xmlhttp.responseText; | |
165 | } | |
166 | } | |
167 | ||
175847de | 168 | |
0e091d38 | 169 | function updateFeedList() { |
007bda35 | 170 | |
c0e5a40e | 171 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
172 | printLockingError(); |
173 | return | |
174 | } | |
175 | ||
f5a50b25 AD |
176 | // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait..."; |
177 | ||
178 | p_notify("Loading, please wait..."); | |
007bda35 AD |
179 | |
180 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
181 | xmlhttp.onreadystatechange=feedlist_callback; | |
182 | xmlhttp.send(null); | |
183 | ||
184 | } | |
185 | ||
e6cb77a0 AD |
186 | function updateUsersList() { |
187 | ||
188 | if (!xmlhttp_ready(xmlhttp)) { | |
189 | printLockingError(); | |
190 | return | |
191 | } | |
192 | ||
193 | // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait..."; | |
194 | ||
195 | p_notify("Loading, please wait..."); | |
196 | ||
197 | xmlhttp.open("GET", "backend.php?op=pref-users", true); | |
198 | xmlhttp.onreadystatechange=userlist_callback; | |
199 | xmlhttp.send(null); | |
200 | ||
201 | } | |
202 | ||
007bda35 AD |
203 | function toggleSelectRow(sender) { |
204 | var parent_row = sender.parentNode.parentNode; | |
205 | ||
206 | if (sender.checked) { | |
207 | if (!parent_row.className.match("Selected")) { | |
208 | parent_row.className = parent_row.className + "Selected"; | |
209 | } | |
210 | } else { | |
211 | if (parent_row.className.match("Selected")) { | |
212 | parent_row.className = parent_row.className.replace("Selected", ""); | |
213 | } | |
214 | } | |
215 | } | |
216 | ||
48f0adb0 AD |
217 | function addLabel() { |
218 | ||
219 | if (!xmlhttp_ready(xmlhttp)) { | |
220 | printLockingError(); | |
221 | return | |
222 | } | |
223 | ||
224 | var sqlexp = document.getElementById("ladd_expr"); | |
225 | ||
226 | if (sqlexp.value.length == 0) { | |
227 | notify("Missing SQL expression."); | |
228 | } else { | |
229 | notify("Adding label..."); | |
230 | ||
231 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" + | |
232 | param_escape(sqlexp.value), true); | |
233 | ||
234 | xmlhttp.onreadystatechange=labellist_callback; | |
235 | xmlhttp.send(null); | |
236 | ||
237 | sqlexp.value = ""; | |
238 | } | |
239 | ||
240 | } | |
241 | ||
de435974 AD |
242 | function addFilter() { |
243 | ||
244 | if (!xmlhttp_ready(xmlhttp)) { | |
245 | printLockingError(); | |
246 | return | |
247 | } | |
248 | ||
249 | var regexp = document.getElementById("fadd_regexp"); | |
250 | var match = document.getElementById("fadd_match"); | |
ead60402 | 251 | var feed = document.getElementById("fadd_feed"); |
de435974 AD |
252 | |
253 | if (regexp.value.length == 0) { | |
254 | notify("Missing filter expression."); | |
255 | } else { | |
256 | notify("Adding filter..."); | |
257 | ||
25cb5736 AD |
258 | var v_match = match[match.selectedIndex].text; |
259 | ||
ead60402 AD |
260 | var feed_id = feed[feed.selectedIndex].id; |
261 | ||
de435974 | 262 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add®exp=" + |
ead60402 AD |
263 | param_escape(regexp.value) + "&match=" + v_match + |
264 | "&fid=" + param_escape(feed_id), true); | |
de435974 AD |
265 | |
266 | xmlhttp.onreadystatechange=filterlist_callback; | |
267 | xmlhttp.send(null); | |
268 | ||
269 | regexp.value = ""; | |
270 | } | |
271 | ||
272 | } | |
48f0adb0 | 273 | |
71ad3959 AD |
274 | function addFeed() { |
275 | ||
c0e5a40e | 276 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
277 | printLockingError(); |
278 | return | |
279 | } | |
280 | ||
331900c6 AD |
281 | var link = document.getElementById("fadd_link"); |
282 | ||
83fe4d6d | 283 | if (link.value.length == 0) { |
c753cd32 | 284 | notify("Missing feed URL."); |
331900c6 AD |
285 | } else { |
286 | notify("Adding feed..."); | |
287 | ||
288 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" + | |
289 | param_escape(link.value), true); | |
290 | xmlhttp.onreadystatechange=feedlist_callback; | |
291 | xmlhttp.send(null); | |
292 | ||
293 | link.value = ""; | |
294 | ||
295 | } | |
296 | ||
297 | } | |
298 | ||
91ff844a AD |
299 | function addFeedCat() { |
300 | ||
301 | if (!xmlhttp_ready(xmlhttp)) { | |
302 | printLockingError(); | |
303 | return | |
304 | } | |
305 | ||
306 | var cat = document.getElementById("fadd_cat"); | |
307 | ||
308 | if (cat.value.length == 0) { | |
309 | notify("Missing feed category."); | |
310 | } else { | |
311 | notify("Adding feed category..."); | |
312 | ||
313 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" + | |
314 | param_escape(cat.value), true); | |
315 | xmlhttp.onreadystatechange=feedlist_callback; | |
316 | xmlhttp.send(null); | |
317 | ||
318 | link.value = ""; | |
319 | ||
320 | } | |
321 | ||
322 | } | |
e6cb77a0 AD |
323 | function addUser() { |
324 | ||
325 | if (!xmlhttp_ready(xmlhttp)) { | |
326 | printLockingError(); | |
327 | return | |
328 | } | |
329 | ||
330 | var sqlexp = document.getElementById("uadd_box"); | |
331 | ||
332 | if (sqlexp.value.length == 0) { | |
333 | notify("Missing user login."); | |
334 | } else { | |
335 | notify("Adding user..."); | |
336 | ||
337 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" + | |
338 | param_escape(sqlexp.value), true); | |
339 | ||
340 | xmlhttp.onreadystatechange=userlist_callback; | |
341 | xmlhttp.send(null); | |
342 | ||
343 | sqlexp.value = ""; | |
344 | } | |
345 | ||
346 | } | |
347 | ||
48f0adb0 AD |
348 | function editLabel(id) { |
349 | ||
350 | if (!xmlhttp_ready(xmlhttp)) { | |
351 | printLockingError(); | |
352 | return | |
353 | } | |
354 | ||
355 | active_label = id; | |
356 | ||
357 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" + | |
358 | param_escape(id), true); | |
359 | xmlhttp.onreadystatechange=labellist_callback; | |
360 | xmlhttp.send(null); | |
361 | ||
362 | } | |
363 | ||
e6cb77a0 AD |
364 | function editUser(id) { |
365 | ||
366 | if (!xmlhttp_ready(xmlhttp)) { | |
367 | printLockingError(); | |
368 | return | |
369 | } | |
370 | ||
371 | active_user = id; | |
372 | ||
373 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" + | |
374 | param_escape(id), true); | |
375 | xmlhttp.onreadystatechange=userlist_callback; | |
376 | xmlhttp.send(null); | |
377 | ||
378 | } | |
379 | ||
a0d53889 AD |
380 | function editFilter(id) { |
381 | ||
382 | if (!xmlhttp_ready(xmlhttp)) { | |
383 | printLockingError(); | |
384 | return | |
385 | } | |
386 | ||
387 | active_filter = id; | |
388 | ||
389 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + | |
390 | param_escape(id), true); | |
391 | xmlhttp.onreadystatechange=filterlist_callback; | |
392 | xmlhttp.send(null); | |
393 | ||
394 | } | |
395 | ||
331900c6 AD |
396 | function editFeed(feed) { |
397 | ||
508a81e1 AD |
398 | // notify("Editing feed..."); |
399 | ||
c0e5a40e | 400 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
401 | printLockingError(); |
402 | return | |
403 | } | |
331900c6 | 404 | |
961513a3 AD |
405 | active_feed = feed; |
406 | ||
331900c6 AD |
407 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" + |
408 | param_escape(feed), true); | |
409 | xmlhttp.onreadystatechange=feedlist_callback; | |
410 | xmlhttp.send(null); | |
411 | ||
412 | } | |
413 | ||
91ff844a | 414 | function editFeedCat(cat) { |
48f0adb0 | 415 | |
91ff844a AD |
416 | if (!xmlhttp_ready(xmlhttp)) { |
417 | printLockingError(); | |
418 | return | |
48f0adb0 AD |
419 | } |
420 | ||
91ff844a | 421 | active_feed_cat = cat; |
e6cb77a0 | 422 | |
91ff844a AD |
423 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" + |
424 | param_escape(cat), true); | |
425 | xmlhttp.onreadystatechange=feedlist_callback; | |
426 | xmlhttp.send(null); | |
e6cb77a0 | 427 | |
e6cb77a0 AD |
428 | } |
429 | ||
91ff844a AD |
430 | function getSelectedLabels() { |
431 | return getSelectedTableRowIds("prefLabelList", "LILRR"); | |
432 | } | |
48f0adb0 | 433 | |
91ff844a AD |
434 | function getSelectedUsers() { |
435 | return getSelectedTableRowIds("prefUserList", "UMRR"); | |
a0d53889 AD |
436 | } |
437 | ||
83fe4d6d | 438 | function getSelectedFeeds() { |
91ff844a AD |
439 | return getSelectedTableRowIds("prefFeedList", "FEEDR"); |
440 | } | |
331900c6 | 441 | |
91ff844a AD |
442 | function getSelectedFilters() { |
443 | return getSelectedTableRowIds("prefFilterList", "FILRR"); | |
444 | } | |
331900c6 | 445 | |
91ff844a AD |
446 | function getSelectedFeedCats() { |
447 | return getSelectedTableRowIds("prefFeedCatList", "FCATR"); | |
83fe4d6d AD |
448 | } |
449 | ||
91ff844a | 450 | |
83fe4d6d AD |
451 | function readSelectedFeeds() { |
452 | ||
c0e5a40e | 453 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
454 | printLockingError(); |
455 | return | |
456 | } | |
457 | ||
83fe4d6d AD |
458 | var sel_rows = getSelectedFeeds(); |
459 | ||
460 | if (sel_rows.length > 0) { | |
461 | ||
462 | notify("Marking selected feeds as read..."); | |
463 | ||
0e091d38 | 464 | xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ |
83fe4d6d | 465 | param_escape(sel_rows.toString()), true); |
0e091d38 | 466 | xmlhttp.onreadystatechange=notify_callback; |
83fe4d6d AD |
467 | xmlhttp.send(null); |
468 | ||
469 | } else { | |
470 | ||
c753cd32 | 471 | notify("Please select some feeds first."); |
83fe4d6d AD |
472 | |
473 | } | |
474 | } | |
475 | ||
476 | function unreadSelectedFeeds() { | |
477 | ||
c0e5a40e | 478 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
479 | printLockingError(); |
480 | return | |
481 | } | |
482 | ||
83fe4d6d AD |
483 | var sel_rows = getSelectedFeeds(); |
484 | ||
485 | if (sel_rows.length > 0) { | |
486 | ||
487 | notify("Marking selected feeds as unread..."); | |
488 | ||
0e091d38 | 489 | xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ |
83fe4d6d | 490 | param_escape(sel_rows.toString()), true); |
0e091d38 | 491 | xmlhttp.onreadystatechange=notify_callback; |
83fe4d6d AD |
492 | xmlhttp.send(null); |
493 | ||
494 | } else { | |
495 | ||
c753cd32 | 496 | notify("Please select some feeds first."); |
83fe4d6d AD |
497 | |
498 | } | |
499 | } | |
500 | ||
48f0adb0 AD |
501 | function removeSelectedLabels() { |
502 | ||
503 | if (!xmlhttp_ready(xmlhttp)) { | |
504 | printLockingError(); | |
505 | return | |
506 | } | |
507 | ||
508 | var sel_rows = getSelectedLabels(); | |
509 | ||
510 | if (sel_rows.length > 0) { | |
511 | ||
512 | notify("Removing selected labels..."); | |
513 | ||
514 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+ | |
515 | param_escape(sel_rows.toString()), true); | |
516 | xmlhttp.onreadystatechange=labellist_callback; | |
517 | xmlhttp.send(null); | |
518 | ||
519 | } else { | |
520 | notify("Please select some labels first."); | |
521 | } | |
522 | } | |
523 | ||
e6cb77a0 AD |
524 | function removeSelectedUsers() { |
525 | ||
526 | if (!xmlhttp_ready(xmlhttp)) { | |
527 | printLockingError(); | |
528 | return | |
529 | } | |
530 | ||
531 | var sel_rows = getSelectedUsers(); | |
532 | ||
533 | if (sel_rows.length > 0) { | |
534 | ||
535 | notify("Removing selected users..."); | |
536 | ||
537 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+ | |
538 | param_escape(sel_rows.toString()), true); | |
539 | xmlhttp.onreadystatechange=userlist_callback; | |
540 | xmlhttp.send(null); | |
541 | ||
542 | } else { | |
543 | notify("Please select some labels first."); | |
544 | } | |
545 | } | |
546 | ||
48f0adb0 AD |
547 | function removeSelectedFilters() { |
548 | ||
549 | if (!xmlhttp_ready(xmlhttp)) { | |
550 | printLockingError(); | |
551 | return | |
552 | } | |
553 | ||
554 | var sel_rows = getSelectedFilters(); | |
555 | ||
556 | if (sel_rows.length > 0) { | |
557 | ||
558 | notify("Removing selected filters..."); | |
559 | ||
560 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+ | |
561 | param_escape(sel_rows.toString()), true); | |
562 | xmlhttp.onreadystatechange=filterlist_callback; | |
563 | xmlhttp.send(null); | |
564 | ||
565 | } else { | |
566 | notify("Please select some filters first."); | |
567 | } | |
568 | } | |
569 | ||
570 | ||
83fe4d6d AD |
571 | function removeSelectedFeeds() { |
572 | ||
c0e5a40e | 573 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
574 | printLockingError(); |
575 | return | |
576 | } | |
577 | ||
83fe4d6d AD |
578 | var sel_rows = getSelectedFeeds(); |
579 | ||
331900c6 AD |
580 | if (sel_rows.length > 0) { |
581 | ||
582 | notify("Removing selected feeds..."); | |
583 | ||
584 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
585 | param_escape(sel_rows.toString()), true); | |
586 | xmlhttp.onreadystatechange=feedlist_callback; | |
587 | xmlhttp.send(null); | |
71ad3959 | 588 | |
71ad3959 | 589 | } else { |
331900c6 | 590 | |
c753cd32 | 591 | notify("Please select some feeds first."); |
331900c6 | 592 | |
71ad3959 AD |
593 | } |
594 | ||
595 | } | |
007bda35 | 596 | |
91ff844a AD |
597 | function removeSelectedFeedCats() { |
598 | ||
599 | if (!xmlhttp_ready(xmlhttp)) { | |
600 | printLockingError(); | |
601 | return | |
602 | } | |
603 | ||
604 | var sel_rows = getSelectedFeedCats(); | |
605 | ||
606 | if (sel_rows.length > 0) { | |
607 | ||
608 | notify("Removing selected categories..."); | |
609 | ||
610 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+ | |
611 | param_escape(sel_rows.toString()), true); | |
612 | xmlhttp.onreadystatechange=feedlist_callback; | |
613 | xmlhttp.send(null); | |
614 | ||
615 | } else { | |
616 | ||
617 | notify("Please select some feeds first."); | |
618 | ||
619 | } | |
620 | ||
621 | } | |
622 | ||
508a81e1 AD |
623 | function feedEditCancel() { |
624 | ||
c0e5a40e | 625 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
626 | printLockingError(); |
627 | return | |
628 | } | |
629 | ||
961513a3 AD |
630 | active_feed = false; |
631 | ||
508a81e1 AD |
632 | notify("Operation cancelled."); |
633 | ||
634 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
635 | xmlhttp.onreadystatechange=feedlist_callback; | |
636 | xmlhttp.send(null); | |
637 | ||
638 | } | |
639 | ||
91ff844a AD |
640 | function feedCatEditCancel() { |
641 | ||
642 | if (!xmlhttp_ready(xmlhttp)) { | |
643 | printLockingError(); | |
644 | return | |
645 | } | |
646 | ||
647 | active_feed_cat = false; | |
648 | ||
649 | notify("Operation cancelled."); | |
650 | ||
651 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
652 | xmlhttp.onreadystatechange=feedlist_callback; | |
653 | xmlhttp.send(null); | |
654 | ||
655 | } | |
656 | ||
603c27f8 AD |
657 | function feedEditSave() { |
658 | ||
659 | var feed = active_feed; | |
508a81e1 | 660 | |
c0e5a40e | 661 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
662 | printLockingError(); |
663 | return | |
664 | } | |
665 | ||
603c27f8 AD |
666 | var link = document.getElementById("iedit_link").value; |
667 | var title = document.getElementById("iedit_title").value; | |
d148926e | 668 | var upd_intl = document.getElementById("iedit_updintl").value; |
5d73494a | 669 | var purge_intl = document.getElementById("iedit_purgintl").value; |
91ff844a AD |
670 | var fcat = document.getElementById("iedit_fcat"); |
671 | ||
672 | var fcat_id = fcat[fcat.selectedIndex].id; | |
508a81e1 | 673 | |
603c27f8 | 674 | // notify("Saving feed."); |
508a81e1 | 675 | |
140aae81 | 676 | /* if (upd_intl < 0) { |
d148926e AD |
677 | notify("Update interval must be >= 0 (0 = default)"); |
678 | return; | |
679 | } | |
680 | ||
5d73494a AD |
681 | if (purge_intl < 0) { |
682 | notify("Purge days must be >= 0 (0 = default)"); | |
683 | return; | |
140aae81 | 684 | } */ |
d148926e | 685 | |
508a81e1 AD |
686 | if (link.length == 0) { |
687 | notify("Feed link cannot be blank."); | |
688 | return; | |
689 | } | |
690 | ||
691 | if (title.length == 0) { | |
692 | notify("Feed title cannot be blank."); | |
693 | return; | |
694 | } | |
695 | ||
603c27f8 AD |
696 | active_feed = false; |
697 | ||
dbd9e2f1 AD |
698 | notify(""); |
699 | ||
508a81e1 | 700 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" + |
d148926e | 701 | feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) + |
91ff844a AD |
702 | "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) + |
703 | "&catid=" + param_escape(fcat_id), true); | |
508a81e1 AD |
704 | xmlhttp.onreadystatechange=feedlist_callback; |
705 | xmlhttp.send(null); | |
706 | ||
707 | } | |
708 | ||
48f0adb0 AD |
709 | function labelEditCancel() { |
710 | ||
711 | if (!xmlhttp_ready(xmlhttp)) { | |
712 | printLockingError(); | |
713 | return | |
714 | } | |
715 | ||
716 | active_label = false; | |
717 | ||
718 | notify("Operation cancelled."); | |
719 | ||
720 | xmlhttp.open("GET", "backend.php?op=pref-labels", true); | |
721 | xmlhttp.onreadystatechange=labellist_callback; | |
722 | xmlhttp.send(null); | |
723 | ||
724 | } | |
725 | ||
e6cb77a0 AD |
726 | function userEditCancel() { |
727 | ||
728 | if (!xmlhttp_ready(xmlhttp)) { | |
729 | printLockingError(); | |
730 | return | |
731 | } | |
732 | ||
733 | active_user = false; | |
734 | ||
735 | notify("Operation cancelled."); | |
736 | ||
737 | xmlhttp.open("GET", "backend.php?op=pref-users", true); | |
738 | xmlhttp.onreadystatechange=userlist_callback; | |
739 | xmlhttp.send(null); | |
740 | ||
741 | } | |
48f0adb0 | 742 | |
a0d53889 AD |
743 | function filterEditCancel() { |
744 | ||
745 | if (!xmlhttp_ready(xmlhttp)) { | |
746 | printLockingError(); | |
747 | return | |
748 | } | |
749 | ||
750 | active_filter = false; | |
751 | ||
752 | notify("Operation cancelled."); | |
753 | ||
754 | xmlhttp.open("GET", "backend.php?op=pref-filters", true); | |
755 | xmlhttp.onreadystatechange=filterlist_callback; | |
756 | xmlhttp.send(null); | |
757 | ||
758 | } | |
759 | ||
48f0adb0 AD |
760 | function labelEditSave() { |
761 | ||
762 | var label = active_label; | |
763 | ||
764 | if (!xmlhttp_ready(xmlhttp)) { | |
765 | printLockingError(); | |
766 | return | |
767 | } | |
768 | ||
769 | var sqlexp = document.getElementById("iedit_expr").value; | |
770 | var descr = document.getElementById("iedit_descr").value; | |
771 | ||
772 | // notify("Saving label " + sqlexp + ": " + descr); | |
773 | ||
774 | if (sqlexp.length == 0) { | |
775 | notify("SQL expression cannot be blank."); | |
776 | return; | |
777 | } | |
778 | ||
779 | if (descr.length == 0) { | |
780 | notify("Caption cannot be blank."); | |
781 | return; | |
782 | } | |
783 | ||
dbd9e2f1 AD |
784 | notify(""); |
785 | ||
48f0adb0 AD |
786 | active_label = false; |
787 | ||
788 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" + | |
789 | label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr), | |
790 | true); | |
791 | ||
792 | xmlhttp.onreadystatechange=labellist_callback; | |
793 | xmlhttp.send(null); | |
794 | ||
795 | } | |
796 | ||
e6cb77a0 AD |
797 | function userEditSave() { |
798 | ||
799 | var user = active_user; | |
800 | ||
801 | if (!xmlhttp_ready(xmlhttp)) { | |
802 | printLockingError(); | |
803 | return | |
804 | } | |
805 | ||
806 | var login = document.getElementById("iedit_ulogin").value; | |
807 | var level = document.getElementById("iedit_ulevel").value; | |
808 | ||
809 | if (login.length == 0) { | |
810 | notify("Login cannot be blank."); | |
811 | return; | |
812 | } | |
813 | ||
814 | if (level.length == 0) { | |
815 | notify("User level cannot be blank."); | |
816 | return; | |
817 | } | |
818 | ||
819 | active_user = false; | |
820 | ||
dbd9e2f1 AD |
821 | notify(""); |
822 | ||
e6cb77a0 AD |
823 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" + |
824 | user + "&l=" + param_escape(login) + "&al=" + param_escape(level), | |
825 | true); | |
826 | ||
dbd9e2f1 | 827 | xmlhttp.onreadystatechange=userlist_callback; |
e6cb77a0 AD |
828 | xmlhttp.send(null); |
829 | ||
830 | } | |
831 | ||
832 | ||
a0d53889 AD |
833 | function filterEditSave() { |
834 | ||
835 | var filter = active_filter; | |
836 | ||
837 | if (!xmlhttp_ready(xmlhttp)) { | |
838 | printLockingError(); | |
839 | return | |
840 | } | |
841 | ||
842 | var regexp = document.getElementById("iedit_regexp").value; | |
843 | var descr = document.getElementById("iedit_descr").value; | |
25cb5736 | 844 | var match = document.getElementById("iedit_match"); |
ead60402 | 845 | |
25cb5736 | 846 | var v_match = match[match.selectedIndex].text; |
a0d53889 | 847 | |
ead60402 AD |
848 | var feed = document.getElementById("iedit_feed"); |
849 | var feed_id = feed[feed.selectedIndex].id; | |
850 | ||
a0d53889 AD |
851 | // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match); |
852 | ||
853 | if (regexp.length == 0) { | |
854 | notify("Filter expression cannot be blank."); | |
855 | return; | |
856 | } | |
857 | ||
858 | active_filter = false; | |
859 | ||
860 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" + | |
861 | filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) + | |
ead60402 | 862 | "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id), true); |
dbd9e2f1 AD |
863 | |
864 | notify(""); | |
865 | ||
a0d53889 AD |
866 | xmlhttp.onreadystatechange=filterlist_callback; |
867 | xmlhttp.send(null); | |
868 | ||
869 | } | |
870 | ||
48f0adb0 AD |
871 | function editSelectedLabel() { |
872 | var rows = getSelectedLabels(); | |
a0d53889 | 873 | |
48f0adb0 AD |
874 | if (rows.length == 0) { |
875 | notify("No labels are selected."); | |
876 | return; | |
a0d53889 AD |
877 | } |
878 | ||
48f0adb0 AD |
879 | if (rows.length > 1) { |
880 | notify("Please select one label."); | |
881 | return; | |
882 | } | |
a0d53889 | 883 | |
dbd9e2f1 AD |
884 | notify(""); |
885 | ||
48f0adb0 | 886 | editLabel(rows[0]); |
a0d53889 | 887 | |
a0d53889 AD |
888 | } |
889 | ||
e6cb77a0 AD |
890 | function editSelectedUser() { |
891 | var rows = getSelectedUsers(); | |
892 | ||
893 | if (rows.length == 0) { | |
894 | notify("No users are selected."); | |
895 | return; | |
896 | } | |
897 | ||
898 | if (rows.length > 1) { | |
899 | notify("Please select one user."); | |
900 | return; | |
901 | } | |
902 | ||
dbd9e2f1 AD |
903 | notify(""); |
904 | ||
e6cb77a0 AD |
905 | editUser(rows[0]); |
906 | } | |
907 | ||
908 | function resetSelectedUserPass() { | |
909 | var rows = getSelectedUsers(); | |
910 | ||
911 | if (rows.length == 0) { | |
912 | notify("No users are selected."); | |
913 | return; | |
914 | } | |
915 | ||
916 | if (rows.length > 1) { | |
917 | notify("Please select one user."); | |
918 | return; | |
919 | } | |
920 | ||
921 | notify("Resetting password for selected user..."); | |
922 | ||
923 | var id = rows[0]; | |
924 | ||
925 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" + | |
926 | param_escape(id), true); | |
927 | xmlhttp.onreadystatechange=userlist_callback; | |
928 | xmlhttp.send(null); | |
929 | ||
930 | } | |
931 | ||
717f5e64 | 932 | function selectedUserDetails() { |
e6cb77a0 | 933 | |
1a7572cb AD |
934 | if (!xmlhttp_ready(xmlhttp)) { |
935 | printLockingError(); | |
936 | return | |
937 | } | |
938 | ||
717f5e64 AD |
939 | var rows = getSelectedUsers(); |
940 | ||
941 | if (rows.length == 0) { | |
942 | notify("No users are selected."); | |
943 | return; | |
944 | } | |
945 | ||
946 | if (rows.length > 1) { | |
947 | notify("Please select one user."); | |
948 | return; | |
949 | } | |
950 | ||
951 | var id = rows[0]; | |
952 | ||
dbd9e2f1 AD |
953 | notify(""); |
954 | ||
1a7572cb | 955 | xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true); |
c6c3a07f AD |
956 | xmlhttp.onreadystatechange=infobox_callback; |
957 | xmlhttp.send(null); | |
958 | ||
959 | } | |
960 | ||
961 | function selectedFeedDetails() { | |
962 | ||
963 | if (!xmlhttp_ready(xmlhttp)) { | |
964 | printLockingError(); | |
965 | return | |
966 | } | |
967 | ||
968 | var rows = getSelectedFeeds(); | |
969 | ||
970 | if (rows.length == 0) { | |
971 | notify("No feeds are selected."); | |
972 | return; | |
973 | } | |
974 | ||
975 | if (rows.length > 1) { | |
976 | notify("Please select one feed."); | |
977 | return; | |
978 | } | |
979 | ||
980 | var id = rows[0]; | |
981 | ||
dbd9e2f1 AD |
982 | notify(""); |
983 | ||
c6c3a07f AD |
984 | xmlhttp.open("GET", "backend.php?op=feed-details&id=" + id, true); |
985 | xmlhttp.onreadystatechange=infobox_callback; | |
1a7572cb | 986 | xmlhttp.send(null); |
717f5e64 AD |
987 | |
988 | } | |
a0d53889 AD |
989 | |
990 | function editSelectedFilter() { | |
991 | var rows = getSelectedFilters(); | |
992 | ||
993 | if (rows.length == 0) { | |
994 | notify("No filters are selected."); | |
995 | return; | |
996 | } | |
997 | ||
998 | if (rows.length > 1) { | |
999 | notify("Please select one filter."); | |
1000 | return; | |
1001 | } | |
1002 | ||
dbd9e2f1 AD |
1003 | notify(""); |
1004 | ||
a0d53889 AD |
1005 | editFilter(rows[0]); |
1006 | ||
1007 | } | |
1008 | ||
1009 | ||
508a81e1 AD |
1010 | function editSelectedFeed() { |
1011 | var rows = getSelectedFeeds(); | |
1012 | ||
1013 | if (rows.length == 0) { | |
1014 | notify("No feeds are selected."); | |
1015 | return; | |
1016 | } | |
1017 | ||
1018 | if (rows.length > 1) { | |
1019 | notify("Please select one feed."); | |
1020 | return; | |
1021 | } | |
1022 | ||
dbd9e2f1 AD |
1023 | notify(""); |
1024 | ||
508a81e1 | 1025 | editFeed(rows[0]); |
91ff844a AD |
1026 | |
1027 | } | |
1028 | ||
1029 | function editSelectedFeedCat() { | |
1030 | var rows = getSelectedFeedCats(); | |
1031 | ||
1032 | if (rows.length == 0) { | |
1033 | notify("No categories are selected."); | |
1034 | return; | |
1035 | } | |
1036 | ||
1037 | if (rows.length > 1) { | |
1038 | notify("Please select one category."); | |
1039 | return; | |
1040 | } | |
1041 | ||
1042 | notify(""); | |
1043 | ||
1044 | editFeedCat(rows[0]); | |
508a81e1 AD |
1045 | |
1046 | } | |
1047 | ||
13ad9102 AD |
1048 | function localPiggieFunction(enable) { |
1049 | if (enable) { | |
508a81e1 AD |
1050 | piggie.style.display = "block"; |
1051 | seq = ""; | |
1052 | notify("I loveded it!!!"); | |
1053 | } else { | |
1054 | piggie.style.display = "none"; | |
1055 | notify(""); | |
1056 | } | |
508a81e1 AD |
1057 | } |
1058 | ||
9f311df6 AD |
1059 | function validateOpmlImport() { |
1060 | ||
1061 | var opml_file = document.getElementById("opml_file"); | |
1062 | ||
1063 | if (opml_file.value.length == 0) { | |
1064 | notify("Please select OPML file to upload."); | |
1065 | return false; | |
1066 | } else { | |
1067 | return true; | |
1068 | } | |
1069 | } | |
1070 | ||
a0d53889 AD |
1071 | function updateFilterList() { |
1072 | ||
1073 | if (!xmlhttp_ready(xmlhttp)) { | |
1074 | printLockingError(); | |
1075 | return | |
1076 | } | |
1077 | ||
f5a50b25 AD |
1078 | // document.getElementById("prefContent").innerHTML = "Loading filters, please wait..."; |
1079 | ||
1080 | p_notify("Loading, please wait..."); | |
a0d53889 AD |
1081 | |
1082 | xmlhttp.open("GET", "backend.php?op=pref-filters", true); | |
1083 | xmlhttp.onreadystatechange=filterlist_callback; | |
1084 | xmlhttp.send(null); | |
1085 | ||
1086 | } | |
1087 | ||
48f0adb0 AD |
1088 | function updateLabelList() { |
1089 | ||
1090 | if (!xmlhttp_ready(xmlhttp)) { | |
1091 | printLockingError(); | |
1092 | return | |
1093 | } | |
1094 | ||
f5a50b25 AD |
1095 | p_notify("Loading, please wait..."); |
1096 | ||
1097 | // document.getElementById("prefContent").innerHTML = "Loading labels, please wait..."; | |
48f0adb0 AD |
1098 | |
1099 | xmlhttp.open("GET", "backend.php?op=pref-labels", true); | |
1100 | xmlhttp.onreadystatechange=labellist_callback; | |
1101 | xmlhttp.send(null); | |
48f0adb0 AD |
1102 | } |
1103 | ||
4255b24c AD |
1104 | function updatePrefsList() { |
1105 | ||
1106 | if (!xmlhttp_ready(xmlhttp)) { | |
1107 | printLockingError(); | |
1108 | return | |
1109 | } | |
1110 | ||
1111 | p_notify("Loading, please wait..."); | |
1112 | ||
1113 | xmlhttp.open("GET", "backend.php?op=pref-prefs", true); | |
1114 | xmlhttp.onreadystatechange=prefslist_callback; | |
1115 | xmlhttp.send(null); | |
1116 | ||
1117 | } | |
1118 | ||
f5a50b25 | 1119 | function selectTab(id) { |
48f0adb0 | 1120 | |
c6c3a07f AD |
1121 | if (!xmlhttp_ready(xmlhttp)) { |
1122 | printLockingError(); | |
1123 | return | |
1124 | } | |
1125 | ||
f5a50b25 | 1126 | if (id == "feedConfig") { |
a0d53889 | 1127 | updateFeedList(); |
f5a50b25 | 1128 | } else if (id == "filterConfig") { |
a0d53889 | 1129 | updateFilterList(); |
f5a50b25 | 1130 | } else if (id == "labelConfig") { |
48f0adb0 | 1131 | updateLabelList(); |
4255b24c AD |
1132 | } else if (id == "genConfig") { |
1133 | updatePrefsList(); | |
e6cb77a0 AD |
1134 | } else if (id == "userConfig") { |
1135 | updateUsersList(); | |
a0d53889 | 1136 | } |
f5a50b25 AD |
1137 | |
1138 | var tab = document.getElementById(active_tab + "Tab"); | |
1139 | ||
1140 | if (tab) { | |
1141 | if (tab.className.match("Selected")) { | |
1142 | tab.className = "prefsTab"; | |
1143 | } | |
1144 | } | |
1145 | ||
1146 | tab = document.getElementById(id + "Tab"); | |
1147 | ||
1148 | if (tab) { | |
1149 | if (!tab.className.match("Selected")) { | |
1150 | tab.className = tab.className + "Selected"; | |
1151 | } | |
1152 | } | |
1153 | ||
1154 | active_tab = id; | |
1155 | ||
a0d53889 AD |
1156 | } |
1157 | ||
007bda35 | 1158 | function init() { |
e2ec66a8 AD |
1159 | |
1160 | // IE kludge | |
1161 | ||
ad095c16 | 1162 | if (!xmlhttp) { |
e2ec66a8 AD |
1163 | document.getElementById("prefContent").innerHTML = |
1164 | "<b>Fatal error:</b> This program needs XmlHttpRequest " + | |
1165 | "to function properly. Your browser doesn't seem to support it."; | |
1166 | return; | |
1167 | } | |
1168 | ||
77e96719 | 1169 | selectTab("genConfig"); |
f5a50b25 | 1170 | |
508a81e1 | 1171 | document.onkeydown = hotkey_handler; |
857a9270 AD |
1172 | notify(""); |
1173 | ||
007bda35 | 1174 | } |
b1895692 AD |
1175 | |
1176 | /* | |
1177 | var help_topic_id = false; | |
1178 | ||
1179 | function do_dispOptionHelp() { | |
1180 | ||
1181 | if (!xmlhttp_ready(xmlhttp)) | |
1182 | return; | |
1183 | ||
1184 | xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" + | |
1185 | param_escape(help_topic_id), true); | |
1186 | xmlhttp.onreadystatechange=gethelp_callback; | |
1187 | xmlhttp.send(null); | |
1188 | ||
1189 | } | |
1190 | ||
1191 | function dispOptionHelp(event, sender) { | |
1192 | ||
1193 | help_topic_id = sender.id; | |
1194 | ||
1195 | // document.setTimeout("do_dispOptionHelp()", 100); | |
1196 | ||
1197 | } */ | |
1198 | ||
c6c3a07f | 1199 | function closeInfoBox() { |
2317ffaa AD |
1200 | var box = document.getElementById('infoBox'); |
1201 | var shadow = document.getElementById('infoBoxShadow'); | |
1202 | ||
1203 | if (shadow) { | |
1204 | shadow.style.display = "none"; | |
1205 | } else if (box) { | |
1206 | box.style.display = "none"; | |
1207 | } | |
1a7572cb | 1208 | } |