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