]>
Commit | Line | Data |
---|---|---|
1 | var xmlhttp = false; | |
2 | ||
3 | var active_feed_cat = false; | |
4 | var active_label = false; | |
5 | var active_tab = false; | |
6 | var feed_to_expand = false; | |
7 | ||
8 | var piggie_top = -400; | |
9 | var piggie_fwd = true; | |
10 | ||
11 | var xmlhttp = Ajax.getTransport(); | |
12 | ||
13 | var init_params = new Array(); | |
14 | ||
15 | function expand_feed_callback() { | |
16 | if (xmlhttp.readyState == 4) { | |
17 | try { | |
18 | var container = document.getElementById("BRDET-" + feed_to_expand); | |
19 | container.innerHTML=xmlhttp.responseText; | |
20 | container.style.display = "block"; | |
21 | // p_notify(""); | |
22 | } catch (e) { | |
23 | exception_error("expand_feed_callback", e); | |
24 | } | |
25 | } | |
26 | } | |
27 | ||
28 | function feedlist_callback() { | |
29 | if (xmlhttp.readyState == 4) { | |
30 | try { | |
31 | var container = document.getElementById('prefContent'); | |
32 | container.innerHTML=xmlhttp.responseText; | |
33 | selectTab("feedConfig", true); | |
34 | ||
35 | if (active_feed_cat) { | |
36 | var row = document.getElementById("FCATR-" + active_feed_cat); | |
37 | if (row) { | |
38 | if (!row.className.match("Selected")) { | |
39 | row.className = row.className + "Selected"; | |
40 | } | |
41 | } | |
42 | var checkbox = document.getElementById("FCCHK-" + active_feed_cat); | |
43 | if (checkbox) { | |
44 | checkbox.checked = true; | |
45 | } | |
46 | } | |
47 | ||
48 | notify(""); | |
49 | } catch (e) { | |
50 | exception_error("feedlist_callback", e); | |
51 | } | |
52 | } | |
53 | } | |
54 | ||
55 | function filterlist_callback() { | |
56 | var container = document.getElementById('prefContent'); | |
57 | if (xmlhttp.readyState == 4) { | |
58 | container.innerHTML=xmlhttp.responseText; | |
59 | notify(""); | |
60 | } | |
61 | } | |
62 | ||
63 | function labellist_callback() { | |
64 | var container = document.getElementById('prefContent'); | |
65 | if (xmlhttp.readyState == 4) { | |
66 | closeInfoBox(); | |
67 | container.innerHTML=xmlhttp.responseText; | |
68 | if (active_label) { | |
69 | var row = document.getElementById("LILRR-" + active_label); | |
70 | if (row) { | |
71 | if (!row.className.match("Selected")) { | |
72 | row.className = row.className + "Selected"; | |
73 | } | |
74 | } | |
75 | var checkbox = document.getElementById("LICHK-" + active_label); | |
76 | ||
77 | if (checkbox) { | |
78 | checkbox.checked = true; | |
79 | } | |
80 | } | |
81 | notify(""); | |
82 | } | |
83 | } | |
84 | ||
85 | function labeltest_callback() { | |
86 | var container = document.getElementById('label_test_result'); | |
87 | if (xmlhttp.readyState == 4) { | |
88 | container.innerHTML=xmlhttp.responseText; | |
89 | notify(""); | |
90 | } | |
91 | } | |
92 | ||
93 | function feed_browser_callback() { | |
94 | var container = document.getElementById('prefContent'); | |
95 | if (xmlhttp.readyState == 4) { | |
96 | container.innerHTML=xmlhttp.responseText; | |
97 | notify(""); | |
98 | } | |
99 | } | |
100 | ||
101 | function userlist_callback() { | |
102 | var container = document.getElementById('prefContent'); | |
103 | if (xmlhttp.readyState == 4) { | |
104 | container.innerHTML=xmlhttp.responseText; | |
105 | notify(""); | |
106 | } | |
107 | } | |
108 | ||
109 | function prefslist_callback() { | |
110 | var container = document.getElementById('prefContent'); | |
111 | if (xmlhttp.readyState == 4) { | |
112 | ||
113 | container.innerHTML=xmlhttp.responseText; | |
114 | ||
115 | notify(""); | |
116 | } | |
117 | } | |
118 | ||
119 | function gethelp_callback() { | |
120 | var container = document.getElementById('prefHelpBox'); | |
121 | if (xmlhttp.readyState == 4) { | |
122 | ||
123 | container.innerHTML = xmlhttp.responseText; | |
124 | container.style.display = "block"; | |
125 | ||
126 | } | |
127 | } | |
128 | ||
129 | ||
130 | function notify_callback() { | |
131 | var container = document.getElementById('notify'); | |
132 | if (xmlhttp.readyState == 4) { | |
133 | container.innerHTML=xmlhttp.responseText; | |
134 | } | |
135 | } | |
136 | ||
137 | function updateFeedList(sort_key) { | |
138 | ||
139 | if (!xmlhttp_ready(xmlhttp)) { | |
140 | printLockingError(); | |
141 | return | |
142 | } | |
143 | ||
144 | // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait..."; | |
145 | ||
146 | // p_notify("Loading, please wait..."); | |
147 | ||
148 | var feed_search = document.getElementById("feed_search"); | |
149 | var search = ""; | |
150 | if (feed_search) { search = feed_search.value; } | |
151 | ||
152 | xmlhttp.open("GET", "backend.php?op=pref-feeds" + | |
153 | "&sort=" + param_escape(sort_key) + | |
154 | "&search=" + param_escape(search), true); | |
155 | xmlhttp.onreadystatechange=feedlist_callback; | |
156 | xmlhttp.send(null); | |
157 | ||
158 | } | |
159 | ||
160 | function updateUsersList(sort_key) { | |
161 | ||
162 | if (!xmlhttp_ready(xmlhttp)) { | |
163 | printLockingError(); | |
164 | return | |
165 | } | |
166 | ||
167 | // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait..."; | |
168 | ||
169 | // p_notify("Loading, please wait..."); | |
170 | ||
171 | xmlhttp.open("GET", "backend.php?op=pref-users&sort=" | |
172 | + param_escape(sort_key), true); | |
173 | xmlhttp.onreadystatechange=userlist_callback; | |
174 | xmlhttp.send(null); | |
175 | ||
176 | } | |
177 | ||
178 | function addLabel() { | |
179 | ||
180 | if (!xmlhttp_ready(xmlhttp)) { | |
181 | printLockingError(); | |
182 | return | |
183 | } | |
184 | ||
185 | var form = document.forms['label_edit_form']; | |
186 | ||
187 | var sql_exp = form.sql_exp.value; | |
188 | var description = form.description.value; | |
189 | ||
190 | if (sql_exp == "") { | |
191 | alert("Can't create label: missing SQL expression."); | |
192 | return false; | |
193 | } | |
194 | ||
195 | if (description == "") { | |
196 | alert("Can't create label: missing caption."); | |
197 | return false; | |
198 | } | |
199 | ||
200 | var query = Form.serialize("label_edit_form"); | |
201 | ||
202 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true); | |
203 | xmlhttp.onreadystatechange=infobox_submit_callback; | |
204 | xmlhttp.send(null); | |
205 | } | |
206 | ||
207 | function addFeed() { | |
208 | ||
209 | if (!xmlhttp_ready(xmlhttp)) { | |
210 | printLockingError(); | |
211 | return | |
212 | } | |
213 | ||
214 | var link = document.getElementById("fadd_link"); | |
215 | ||
216 | if (link.value.length == 0) { | |
217 | alert("Error: No feed URL given."); | |
218 | } else if (!isValidURL(link.value)) { | |
219 | alert("Error: Invalid feed URL."); | |
220 | } else { | |
221 | notify("Adding feed..."); | |
222 | ||
223 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&feed_url=" + | |
224 | param_escape(link.value), true); | |
225 | xmlhttp.onreadystatechange=feedlist_callback; | |
226 | xmlhttp.send(null); | |
227 | ||
228 | link.value = ""; | |
229 | ||
230 | } | |
231 | ||
232 | } | |
233 | ||
234 | function addFeedCat() { | |
235 | ||
236 | if (!xmlhttp_ready(xmlhttp)) { | |
237 | printLockingError(); | |
238 | return | |
239 | } | |
240 | ||
241 | var cat = document.getElementById("fadd_cat"); | |
242 | ||
243 | if (cat.value.length == 0) { | |
244 | alert("Can't add category: no name specified."); | |
245 | } else { | |
246 | notify("Adding feed category..."); | |
247 | ||
248 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" + | |
249 | param_escape(cat.value), true); | |
250 | xmlhttp.onreadystatechange=feedlist_callback; | |
251 | xmlhttp.send(null); | |
252 | ||
253 | link.value = ""; | |
254 | ||
255 | } | |
256 | ||
257 | } | |
258 | function addUser() { | |
259 | ||
260 | if (!xmlhttp_ready(xmlhttp)) { | |
261 | printLockingError(); | |
262 | return | |
263 | } | |
264 | ||
265 | var sqlexp = document.getElementById("uadd_box"); | |
266 | ||
267 | if (sqlexp.value.length == 0) { | |
268 | alert("Can't add user: no login specified."); | |
269 | } else { | |
270 | notify("Adding user..."); | |
271 | ||
272 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" + | |
273 | param_escape(sqlexp.value), true); | |
274 | ||
275 | xmlhttp.onreadystatechange=userlist_callback; | |
276 | xmlhttp.send(null); | |
277 | ||
278 | sqlexp.value = ""; | |
279 | } | |
280 | ||
281 | } | |
282 | ||
283 | function editLabel(id) { | |
284 | ||
285 | if (!xmlhttp_ready(xmlhttp)) { | |
286 | printLockingError(); | |
287 | return | |
288 | } | |
289 | ||
290 | document.getElementById("label_create_btn").disabled = true; | |
291 | ||
292 | active_label = id; | |
293 | ||
294 | selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false); | |
295 | selectTableRowById('LILRR-'+id, 'LICHK-'+id, true); | |
296 | ||
297 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" + | |
298 | param_escape(id), true); | |
299 | xmlhttp.onreadystatechange=infobox_callback; | |
300 | xmlhttp.send(null); | |
301 | ||
302 | } | |
303 | ||
304 | function editUser(id) { | |
305 | ||
306 | if (!xmlhttp_ready(xmlhttp)) { | |
307 | printLockingError(); | |
308 | return | |
309 | } | |
310 | ||
311 | selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false); | |
312 | selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true); | |
313 | ||
314 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" + | |
315 | param_escape(id), true); | |
316 | xmlhttp.onreadystatechange=infobox_callback; | |
317 | xmlhttp.send(null); | |
318 | ||
319 | } | |
320 | ||
321 | function editFilter(id) { | |
322 | ||
323 | if (!xmlhttp_ready(xmlhttp)) { | |
324 | printLockingError(); | |
325 | return | |
326 | } | |
327 | ||
328 | document.getElementById("create_filter_btn").disabled = true; | |
329 | ||
330 | selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false); | |
331 | selectTableRowById('FILRR-'+id, 'FICHK-'+id, true); | |
332 | ||
333 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id), true); | |
334 | xmlhttp.onreadystatechange=infobox_callback; | |
335 | xmlhttp.send(null); | |
336 | } | |
337 | ||
338 | function editFeed(feed) { | |
339 | ||
340 | // notify("Editing feed..."); | |
341 | ||
342 | if (!xmlhttp_ready(xmlhttp)) { | |
343 | printLockingError(); | |
344 | return | |
345 | } | |
346 | ||
347 | // clean selection from all rows & select row being edited | |
348 | selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false); | |
349 | selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true); | |
350 | ||
351 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" + | |
352 | param_escape(feed), true); | |
353 | ||
354 | xmlhttp.onreadystatechange=infobox_callback; | |
355 | xmlhttp.send(null); | |
356 | ||
357 | } | |
358 | ||
359 | function editFeedCat(cat) { | |
360 | ||
361 | if (!xmlhttp_ready(xmlhttp)) { | |
362 | printLockingError(); | |
363 | return | |
364 | } | |
365 | ||
366 | active_feed_cat = cat; | |
367 | ||
368 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" + | |
369 | param_escape(cat), true); | |
370 | xmlhttp.onreadystatechange=feedlist_callback; | |
371 | xmlhttp.send(null); | |
372 | ||
373 | } | |
374 | ||
375 | function getSelectedLabels() { | |
376 | return getSelectedTableRowIds("prefLabelList", "LILRR"); | |
377 | } | |
378 | ||
379 | function getSelectedUsers() { | |
380 | return getSelectedTableRowIds("prefUserList", "UMRR"); | |
381 | } | |
382 | ||
383 | function getSelectedFeeds() { | |
384 | return getSelectedTableRowIds("prefFeedList", "FEEDR"); | |
385 | } | |
386 | ||
387 | function getSelectedFilters() { | |
388 | return getSelectedTableRowIds("prefFilterList", "FILRR"); | |
389 | } | |
390 | ||
391 | function getSelectedFeedCats() { | |
392 | return getSelectedTableRowIds("prefFeedCatList", "FCATR"); | |
393 | } | |
394 | ||
395 | function getSelectedFeedsFromBrowser() { | |
396 | ||
397 | var list = document.getElementById("browseFeedList"); | |
398 | if (!list) list = document.getElementById("browseBigFeedList"); | |
399 | ||
400 | var selected = new Array(); | |
401 | ||
402 | for (i = 0; i < list.childNodes.length; i++) { | |
403 | var child = list.childNodes[i]; | |
404 | if (child.id && child.id.match("FBROW-")) { | |
405 | var id = child.id.replace("FBROW-", ""); | |
406 | ||
407 | var cb = document.getElementById("FBCHK-" + id); | |
408 | ||
409 | if (cb.checked) { | |
410 | selected.push(id); | |
411 | } | |
412 | } | |
413 | } | |
414 | ||
415 | return selected; | |
416 | } | |
417 | ||
418 | function removeSelectedLabels() { | |
419 | ||
420 | if (!xmlhttp_ready(xmlhttp)) { | |
421 | printLockingError(); | |
422 | return | |
423 | } | |
424 | ||
425 | var sel_rows = getSelectedLabels(); | |
426 | ||
427 | if (sel_rows.length > 0) { | |
428 | ||
429 | var ok = confirm("Remove selected labels?"); | |
430 | ||
431 | if (ok) { | |
432 | notify("Removing selected labels..."); | |
433 | ||
434 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+ | |
435 | param_escape(sel_rows.toString()), true); | |
436 | xmlhttp.onreadystatechange=labellist_callback; | |
437 | xmlhttp.send(null); | |
438 | } | |
439 | } else { | |
440 | alert("No labels are selected."); | |
441 | } | |
442 | ||
443 | return false; | |
444 | } | |
445 | ||
446 | function removeSelectedUsers() { | |
447 | ||
448 | if (!xmlhttp_ready(xmlhttp)) { | |
449 | printLockingError(); | |
450 | return | |
451 | } | |
452 | ||
453 | var sel_rows = getSelectedUsers(); | |
454 | ||
455 | if (sel_rows.length > 0) { | |
456 | ||
457 | var ok = confirm("Remove selected users?"); | |
458 | ||
459 | if (ok) { | |
460 | notify("Removing selected users..."); | |
461 | ||
462 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+ | |
463 | param_escape(sel_rows.toString()), true); | |
464 | xmlhttp.onreadystatechange=userlist_callback; | |
465 | xmlhttp.send(null); | |
466 | } | |
467 | ||
468 | } else { | |
469 | alert("No users are selected."); | |
470 | } | |
471 | ||
472 | return false; | |
473 | } | |
474 | ||
475 | function removeSelectedFilters() { | |
476 | ||
477 | if (!xmlhttp_ready(xmlhttp)) { | |
478 | printLockingError(); | |
479 | return | |
480 | } | |
481 | ||
482 | var sel_rows = getSelectedFilters(); | |
483 | ||
484 | if (sel_rows.length > 0) { | |
485 | ||
486 | var ok = confirm("Remove selected filters?"); | |
487 | ||
488 | if (ok) { | |
489 | notify("Removing selected filters..."); | |
490 | ||
491 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+ | |
492 | param_escape(sel_rows.toString()), true); | |
493 | xmlhttp.onreadystatechange=filterlist_callback; | |
494 | xmlhttp.send(null); | |
495 | } | |
496 | } else { | |
497 | alert("No filters are selected."); | |
498 | } | |
499 | ||
500 | return false; | |
501 | } | |
502 | ||
503 | ||
504 | function removeSelectedFeeds() { | |
505 | ||
506 | if (!xmlhttp_ready(xmlhttp)) { | |
507 | printLockingError(); | |
508 | return | |
509 | } | |
510 | ||
511 | var sel_rows = getSelectedFeeds(); | |
512 | ||
513 | if (sel_rows.length > 0) { | |
514 | ||
515 | var ok = confirm("Unsubscribe from selected feeds?"); | |
516 | ||
517 | if (ok) { | |
518 | ||
519 | notify("Unsubscribing from selected feeds..."); | |
520 | ||
521 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
522 | param_escape(sel_rows.toString()), true); | |
523 | xmlhttp.onreadystatechange=feedlist_callback; | |
524 | xmlhttp.send(null); | |
525 | } | |
526 | ||
527 | } else { | |
528 | ||
529 | alert("No feeds are selected."); | |
530 | ||
531 | } | |
532 | ||
533 | return false; | |
534 | } | |
535 | ||
536 | function removeSelectedFeedCats() { | |
537 | ||
538 | if (!xmlhttp_ready(xmlhttp)) { | |
539 | printLockingError(); | |
540 | return | |
541 | } | |
542 | ||
543 | var sel_rows = getSelectedFeedCats(); | |
544 | ||
545 | if (sel_rows.length > 0) { | |
546 | ||
547 | var ok = confirm("Remove selected categories?"); | |
548 | ||
549 | if (ok) { | |
550 | notify("Removing selected categories..."); | |
551 | ||
552 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+ | |
553 | param_escape(sel_rows.toString()), true); | |
554 | xmlhttp.onreadystatechange=feedlist_callback; | |
555 | xmlhttp.send(null); | |
556 | } | |
557 | ||
558 | } else { | |
559 | ||
560 | alert("No categories are selected."); | |
561 | ||
562 | } | |
563 | ||
564 | return false; | |
565 | } | |
566 | ||
567 | function feedEditCancel() { | |
568 | ||
569 | if (!xmlhttp_ready(xmlhttp)) { | |
570 | printLockingError(); | |
571 | return | |
572 | } | |
573 | ||
574 | closeInfoBox(); | |
575 | ||
576 | selectPrefRows('feed', false); // cleanup feed selection | |
577 | ||
578 | return false; | |
579 | } | |
580 | ||
581 | function feedCatEditCancel() { | |
582 | ||
583 | if (!xmlhttp_ready(xmlhttp)) { | |
584 | printLockingError(); | |
585 | return | |
586 | } | |
587 | ||
588 | active_feed_cat = false; | |
589 | ||
590 | // notify("Operation cancelled."); | |
591 | ||
592 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
593 | xmlhttp.onreadystatechange=feedlist_callback; | |
594 | xmlhttp.send(null); | |
595 | ||
596 | return false; | |
597 | } | |
598 | ||
599 | function feedEditSave() { | |
600 | ||
601 | try { | |
602 | ||
603 | if (!xmlhttp_ready(xmlhttp)) { | |
604 | printLockingError(); | |
605 | return | |
606 | } | |
607 | ||
608 | // FIXME: add parameter validation | |
609 | ||
610 | var query = Form.serialize("edit_feed_form"); | |
611 | ||
612 | notify("Saving feed..."); | |
613 | ||
614 | xmlhttp.open("POST", "backend.php", true); | |
615 | xmlhttp.onreadystatechange=feedlist_callback; | |
616 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
617 | xmlhttp.send(query); | |
618 | ||
619 | closeInfoBox(); | |
620 | ||
621 | return false; | |
622 | ||
623 | } catch (e) { | |
624 | exception_error("feedEditSave", e); | |
625 | } | |
626 | } | |
627 | ||
628 | function feedCatEditSave() { | |
629 | ||
630 | if (!xmlhttp_ready(xmlhttp)) { | |
631 | printLockingError(); | |
632 | return | |
633 | } | |
634 | ||
635 | notify("Saving category..."); | |
636 | ||
637 | var query = Form.serialize("feed_cat_edit_form"); | |
638 | ||
639 | xmlhttp.open("GET", "backend.php?" + query, true); | |
640 | xmlhttp.onreadystatechange=feedlist_callback; | |
641 | xmlhttp.send(null); | |
642 | ||
643 | active_feed_cat = false; | |
644 | ||
645 | return false; | |
646 | } | |
647 | ||
648 | ||
649 | function labelTest() { | |
650 | ||
651 | var container = document.getElementById('label_test_result'); | |
652 | container.style.display = "block"; | |
653 | container.innerHTML = "<p>Loading, please wait...</p>"; | |
654 | ||
655 | var form = document.forms['label_edit_form']; | |
656 | ||
657 | var sql_exp = form.sql_exp.value; | |
658 | var description = form.description.value; | |
659 | ||
660 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" + | |
661 | param_escape(sql_exp) + "&descr=" + param_escape(description), true); | |
662 | ||
663 | xmlhttp.onreadystatechange=labeltest_callback; | |
664 | xmlhttp.send(null); | |
665 | ||
666 | return false; | |
667 | } | |
668 | ||
669 | function displayHelpInfobox(topic_id) { | |
670 | ||
671 | xmlhttp.open("GET", "backend.php?op=help&tid=" + | |
672 | param_escape(topic_id) + "&noheaders=1", true); | |
673 | ||
674 | xmlhttp.onreadystatechange=infobox_callback; | |
675 | xmlhttp.send(null); | |
676 | ||
677 | } | |
678 | ||
679 | function labelEditCancel() { | |
680 | ||
681 | if (!xmlhttp_ready(xmlhttp)) { | |
682 | printLockingError(); | |
683 | return | |
684 | } | |
685 | ||
686 | document.getElementById("label_create_btn").disabled = false; | |
687 | ||
688 | active_label = false; | |
689 | ||
690 | selectPrefRows('label', false); // cleanup feed selection | |
691 | closeInfoBox(); | |
692 | ||
693 | return false; | |
694 | } | |
695 | ||
696 | function userEditCancel() { | |
697 | ||
698 | if (!xmlhttp_ready(xmlhttp)) { | |
699 | printLockingError(); | |
700 | return | |
701 | } | |
702 | ||
703 | selectPrefRows('user', false); // cleanup feed selection | |
704 | closeInfoBox(); | |
705 | ||
706 | return false; | |
707 | } | |
708 | ||
709 | function filterEditCancel() { | |
710 | ||
711 | if (!xmlhttp_ready(xmlhttp)) { | |
712 | printLockingError(); | |
713 | return | |
714 | } | |
715 | ||
716 | document.getElementById("create_filter_btn").disabled = false; | |
717 | ||
718 | selectPrefRows('filter', false); // cleanup feed selection | |
719 | closeInfoBox(); | |
720 | ||
721 | return false; | |
722 | } | |
723 | ||
724 | function labelEditSave() { | |
725 | ||
726 | var label = active_label; | |
727 | ||
728 | if (!xmlhttp_ready(xmlhttp)) { | |
729 | printLockingError(); | |
730 | return | |
731 | } | |
732 | ||
733 | /* if (!is_opera()) { | |
734 | ||
735 | var sql_exp = document.forms["label_edit_form"].sql_exp.value; | |
736 | var description = document.forms["label_edit_form"].description.value; | |
737 | ||
738 | if (sql_exp.length == 0) { | |
739 | alert("SQL Expression cannot be blank."); | |
740 | return false; | |
741 | } | |
742 | ||
743 | if (description.length == 0) { | |
744 | alert("Caption field cannot be blank."); | |
745 | return false; | |
746 | } | |
747 | } */ | |
748 | ||
749 | closeInfoBox(); | |
750 | ||
751 | notify("Saving label..."); | |
752 | ||
753 | active_label = false; | |
754 | ||
755 | query = Form.serialize("label_edit_form"); | |
756 | ||
757 | xmlhttp.open("GET", "backend.php?" + query, true); | |
758 | xmlhttp.onreadystatechange=labellist_callback; | |
759 | xmlhttp.send(null); | |
760 | ||
761 | return false; | |
762 | } | |
763 | ||
764 | function userEditSave() { | |
765 | ||
766 | if (!xmlhttp_ready(xmlhttp)) { | |
767 | printLockingError(); | |
768 | return | |
769 | } | |
770 | ||
771 | var login = document.forms["user_edit_form"].login.value; | |
772 | ||
773 | if (login.length == 0) { | |
774 | alert("Login field cannot be blank."); | |
775 | return; | |
776 | } | |
777 | ||
778 | notify("Saving user..."); | |
779 | ||
780 | closeInfoBox(); | |
781 | ||
782 | var query = Form.serialize("user_edit_form"); | |
783 | ||
784 | xmlhttp.open("GET", "backend.php?" + query, true); | |
785 | xmlhttp.onreadystatechange=userlist_callback; | |
786 | xmlhttp.send(null); | |
787 | ||
788 | return false; | |
789 | } | |
790 | ||
791 | ||
792 | function filterEditSave() { | |
793 | ||
794 | if (!xmlhttp_ready(xmlhttp)) { | |
795 | printLockingError(); | |
796 | return | |
797 | } | |
798 | ||
799 | /* if (!is_opera()) { | |
800 | var reg_exp = document.forms["filter_edit_form"].reg_exp.value; | |
801 | ||
802 | if (reg_exp.length == 0) { | |
803 | alert("Filter expression field cannot be blank."); | |
804 | return; | |
805 | } | |
806 | } */ | |
807 | ||
808 | notify("Saving filter..."); | |
809 | ||
810 | var query = Form.serialize("filter_edit_form"); | |
811 | ||
812 | closeInfoBox(); | |
813 | ||
814 | document.getElementById("create_filter_btn").disabled = false; | |
815 | ||
816 | xmlhttp.open("GET", "backend.php?" + query, true); | |
817 | xmlhttp.onreadystatechange=filterlist_callback; | |
818 | xmlhttp.send(null); | |
819 | ||
820 | return false; | |
821 | } | |
822 | ||
823 | function editSelectedLabel() { | |
824 | var rows = getSelectedLabels(); | |
825 | ||
826 | if (rows.length == 0) { | |
827 | alert("No labels are selected."); | |
828 | return; | |
829 | } | |
830 | ||
831 | if (rows.length > 1) { | |
832 | alert("Please select only one label."); | |
833 | return; | |
834 | } | |
835 | ||
836 | notify(""); | |
837 | ||
838 | editLabel(rows[0]); | |
839 | ||
840 | } | |
841 | ||
842 | function editSelectedUser() { | |
843 | var rows = getSelectedUsers(); | |
844 | ||
845 | if (rows.length == 0) { | |
846 | alert("No users are selected."); | |
847 | return; | |
848 | } | |
849 | ||
850 | if (rows.length > 1) { | |
851 | alert("Please select only one user."); | |
852 | return; | |
853 | } | |
854 | ||
855 | notify(""); | |
856 | ||
857 | editUser(rows[0]); | |
858 | } | |
859 | ||
860 | function resetSelectedUserPass() { | |
861 | var rows = getSelectedUsers(); | |
862 | ||
863 | if (rows.length == 0) { | |
864 | alert("No users are selected."); | |
865 | return; | |
866 | } | |
867 | ||
868 | if (rows.length > 1) { | |
869 | alert("Please select only one user."); | |
870 | return; | |
871 | } | |
872 | ||
873 | var ok = confirm("Reset password of selected user?"); | |
874 | ||
875 | if (ok) { | |
876 | notify("Resetting password for selected user..."); | |
877 | ||
878 | var id = rows[0]; | |
879 | ||
880 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" + | |
881 | param_escape(id), true); | |
882 | xmlhttp.onreadystatechange=userlist_callback; | |
883 | xmlhttp.send(null); | |
884 | } | |
885 | } | |
886 | ||
887 | function selectedUserDetails() { | |
888 | ||
889 | if (!xmlhttp_ready(xmlhttp)) { | |
890 | printLockingError(); | |
891 | return | |
892 | } | |
893 | ||
894 | var rows = getSelectedUsers(); | |
895 | ||
896 | if (rows.length == 0) { | |
897 | alert("No users are selected."); | |
898 | return; | |
899 | } | |
900 | ||
901 | if (rows.length > 1) { | |
902 | alert("Please select only one user."); | |
903 | return; | |
904 | } | |
905 | ||
906 | var id = rows[0]; | |
907 | ||
908 | notify(""); | |
909 | ||
910 | xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true); | |
911 | xmlhttp.onreadystatechange=infobox_callback; | |
912 | xmlhttp.send(null); | |
913 | ||
914 | } | |
915 | ||
916 | function selectedFeedDetails() { | |
917 | ||
918 | if (!xmlhttp_ready(xmlhttp)) { | |
919 | printLockingError(); | |
920 | return | |
921 | } | |
922 | ||
923 | var rows = getSelectedFeeds(); | |
924 | ||
925 | if (rows.length == 0) { | |
926 | alert("No feeds are selected."); | |
927 | return; | |
928 | } | |
929 | ||
930 | if (rows.length > 1) { | |
931 | notify("Please select only one feed."); | |
932 | return; | |
933 | } | |
934 | ||
935 | // var id = rows[0]; | |
936 | ||
937 | notify(""); | |
938 | ||
939 | xmlhttp.open("GET", "backend.php?op=feed-details&id=" + | |
940 | param_escape(rows.toString()), true); | |
941 | xmlhttp.onreadystatechange=infobox_callback; | |
942 | xmlhttp.send(null); | |
943 | ||
944 | } | |
945 | ||
946 | function editSelectedFilter() { | |
947 | var rows = getSelectedFilters(); | |
948 | ||
949 | if (rows.length == 0) { | |
950 | alert("No filters are selected."); | |
951 | return; | |
952 | } | |
953 | ||
954 | if (rows.length > 1) { | |
955 | alert("Please select only one filter."); | |
956 | return; | |
957 | } | |
958 | ||
959 | notify(""); | |
960 | ||
961 | editFilter(rows[0]); | |
962 | ||
963 | } | |
964 | ||
965 | ||
966 | function editSelectedFeed() { | |
967 | var rows = getSelectedFeeds(); | |
968 | ||
969 | if (rows.length == 0) { | |
970 | notify("No feeds are selected."); | |
971 | return; | |
972 | } | |
973 | ||
974 | if (rows.length > 1) { | |
975 | notify("Please select one feed."); | |
976 | return; | |
977 | } | |
978 | ||
979 | notify(""); | |
980 | ||
981 | editFeed(rows[0]); | |
982 | ||
983 | } | |
984 | ||
985 | function editSelectedFeedCat() { | |
986 | var rows = getSelectedFeedCats(); | |
987 | ||
988 | if (rows.length == 0) { | |
989 | alert("No categories are selected."); | |
990 | return; | |
991 | } | |
992 | ||
993 | if (rows.length > 1) { | |
994 | alert("Please select only one category."); | |
995 | return; | |
996 | } | |
997 | ||
998 | notify(""); | |
999 | ||
1000 | editFeedCat(rows[0]); | |
1001 | ||
1002 | } | |
1003 | ||
1004 | function piggie_callback() { | |
1005 | var piggie = document.getElementById("piggie"); | |
1006 | ||
1007 | piggie.style.top = piggie_top; | |
1008 | piggie.style.backgroundColor = "white"; | |
1009 | piggie.style.borderWidth = "1px"; | |
1010 | ||
1011 | if (piggie_fwd && piggie_top < 0) { | |
1012 | setTimeout("piggie_callback()", 50); | |
1013 | piggie_top = piggie_top + 10; | |
1014 | } else if (piggie_fwd && piggie_top >= 0) { | |
1015 | piggie_fwd = false; | |
1016 | setTimeout("piggie_callback()", 50); | |
1017 | } else if (!piggie_fwd && piggie_top > -400) { | |
1018 | setTimeout("piggie_callback()", 50); | |
1019 | piggie_top = piggie_top - 10; | |
1020 | } else if (!piggie_fwd && piggie_top <= -400) { | |
1021 | piggie.style.display = "none"; | |
1022 | piggie_fwd = true; | |
1023 | } | |
1024 | } | |
1025 | ||
1026 | var piggie_opacity = 0; | |
1027 | ||
1028 | function piggie2_callback() { | |
1029 | var piggie = document.getElementById("piggie"); | |
1030 | piggie.style.top = 0; | |
1031 | piggie.style.opacity = piggie_opacity; | |
1032 | piggie.style.backgroundColor = "transparent"; | |
1033 | piggie.style.borderWidth = "0px"; | |
1034 | ||
1035 | if (piggie_fwd && piggie_opacity < 1) { | |
1036 | setTimeout("piggie2_callback()", 50); | |
1037 | piggie_opacity = piggie_opacity + 0.03; | |
1038 | } else if (piggie_fwd && piggie_opacity >= 1) { | |
1039 | piggie_fwd = false; | |
1040 | setTimeout("piggie2_callback()", 50); | |
1041 | } else if (!piggie_fwd && piggie_opacity > 0) { | |
1042 | setTimeout("piggie2_callback()", 50); | |
1043 | piggie_opacity = piggie_opacity - 0.03; | |
1044 | } else if (!piggie_fwd && piggie_opacity <= 0) { | |
1045 | piggie.style.display = "none"; | |
1046 | piggie_fwd = true; | |
1047 | } | |
1048 | } | |
1049 | ||
1050 | function localPiggieFunction(enable) { | |
1051 | if (enable) { | |
1052 | debug("I LOVEDED IT!"); | |
1053 | var piggie = document.getElementById("piggie"); | |
1054 | piggie.style.display = "block"; | |
1055 | ||
1056 | if (navigator.userAgent.match("Gecko") && Math.random(1) > 0.5) { | |
1057 | piggie2_callback(); | |
1058 | } else { | |
1059 | piggie_callback(); | |
1060 | } | |
1061 | } | |
1062 | } | |
1063 | ||
1064 | function validateOpmlImport() { | |
1065 | ||
1066 | var opml_file = document.getElementById("opml_file"); | |
1067 | ||
1068 | if (opml_file.value.length == 0) { | |
1069 | alert("No OPML file to upload."); | |
1070 | return false; | |
1071 | } else { | |
1072 | return true; | |
1073 | } | |
1074 | } | |
1075 | ||
1076 | function updateFilterList(sort_key) { | |
1077 | ||
1078 | if (!xmlhttp_ready(xmlhttp)) { | |
1079 | printLockingError(); | |
1080 | return | |
1081 | } | |
1082 | ||
1083 | // document.getElementById("prefContent").innerHTML = "Loading filters, please wait..."; | |
1084 | ||
1085 | // p_notify("Loading, please wait..."); | |
1086 | ||
1087 | xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" + | |
1088 | param_escape(sort_key), true); | |
1089 | xmlhttp.onreadystatechange=filterlist_callback; | |
1090 | xmlhttp.send(null); | |
1091 | ||
1092 | } | |
1093 | ||
1094 | function updateLabelList(sort_key) { | |
1095 | ||
1096 | if (!xmlhttp_ready(xmlhttp)) { | |
1097 | printLockingError(); | |
1098 | return | |
1099 | } | |
1100 | ||
1101 | // p_notify("Loading, please wait..."); | |
1102 | ||
1103 | // document.getElementById("prefContent").innerHTML = "Loading labels, please wait..."; | |
1104 | ||
1105 | xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" + | |
1106 | param_escape(sort_key), true); | |
1107 | xmlhttp.onreadystatechange=labellist_callback; | |
1108 | xmlhttp.send(null); | |
1109 | } | |
1110 | ||
1111 | function updatePrefsList() { | |
1112 | ||
1113 | if (!xmlhttp_ready(xmlhttp)) { | |
1114 | printLockingError(); | |
1115 | return | |
1116 | } | |
1117 | ||
1118 | // p_notify("Loading, please wait..."); | |
1119 | ||
1120 | xmlhttp.open("GET", "backend.php?op=pref-prefs", true); | |
1121 | xmlhttp.onreadystatechange=prefslist_callback; | |
1122 | xmlhttp.send(null); | |
1123 | ||
1124 | } | |
1125 | ||
1126 | function selectTab(id, noupdate) { | |
1127 | ||
1128 | // alert(id); | |
1129 | ||
1130 | if (!id) id = active_tab; | |
1131 | ||
1132 | try { | |
1133 | ||
1134 | if (!xmlhttp_ready(xmlhttp)) { | |
1135 | printLockingError(); | |
1136 | return | |
1137 | } | |
1138 | ||
1139 | if (!noupdate) { | |
1140 | ||
1141 | debug("selectTab: " + id + "(NU: " + noupdate + ")"); | |
1142 | ||
1143 | // notify("Loading, please wait...", true); | |
1144 | ||
1145 | // close active infobox if needed | |
1146 | closeInfoBox(); | |
1147 | ||
1148 | // clean up all current selections, just in case | |
1149 | active_feed_cat = false; | |
1150 | active_label = false; | |
1151 | ||
1152 | if (id == "feedConfig") { | |
1153 | updateFeedList(); | |
1154 | } else if (id == "filterConfig") { | |
1155 | updateFilterList(); | |
1156 | } else if (id == "labelConfig") { | |
1157 | updateLabelList(); | |
1158 | } else if (id == "genConfig") { | |
1159 | updatePrefsList(); | |
1160 | } else if (id == "userConfig") { | |
1161 | updateUsersList(); | |
1162 | } else if (id == "feedBrowser") { | |
1163 | updateBigFeedBrowser(); | |
1164 | } | |
1165 | } | |
1166 | ||
1167 | var tab = document.getElementById(active_tab + "Tab"); | |
1168 | ||
1169 | if (tab) { | |
1170 | if (tab.className.match("Selected")) { | |
1171 | tab.className = "prefsTab"; | |
1172 | } | |
1173 | } | |
1174 | ||
1175 | tab = document.getElementById(id + "Tab"); | |
1176 | ||
1177 | if (tab) { | |
1178 | if (!tab.className.match("Selected")) { | |
1179 | tab.className = tab.className + "Selected"; | |
1180 | } | |
1181 | } | |
1182 | ||
1183 | if (active_tab != id) { | |
1184 | storeInitParam("prefs_active_tab", id); | |
1185 | } | |
1186 | ||
1187 | active_tab = id; | |
1188 | ||
1189 | } catch (e) { | |
1190 | exception_error("selectTab", e); | |
1191 | } | |
1192 | } | |
1193 | ||
1194 | function backend_sanity_check_callback() { | |
1195 | ||
1196 | if (xmlhttp.readyState == 4) { | |
1197 | ||
1198 | try { | |
1199 | ||
1200 | if (!xmlhttp.responseXML) { | |
1201 | fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText); | |
1202 | return; | |
1203 | } | |
1204 | ||
1205 | var reply = xmlhttp.responseXML.firstChild.firstChild; | |
1206 | ||
1207 | if (!reply) { | |
1208 | fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText); | |
1209 | return; | |
1210 | } | |
1211 | ||
1212 | var error_code = reply.getAttribute("error-code"); | |
1213 | ||
1214 | if (error_code && error_code != 0) { | |
1215 | return fatalError(error_code, reply.getAttribute("error-msg")); | |
1216 | } | |
1217 | ||
1218 | debug("sanity check ok"); | |
1219 | ||
1220 | var params = reply.nextSibling; | |
1221 | ||
1222 | if (params) { | |
1223 | debug('reading init-params...'); | |
1224 | var param = params.firstChild; | |
1225 | ||
1226 | while (param) { | |
1227 | var k = param.getAttribute("key"); | |
1228 | var v = param.getAttribute("value"); | |
1229 | debug(k + " => " + v); | |
1230 | init_params[k] = v; | |
1231 | param = param.nextSibling; | |
1232 | } | |
1233 | } | |
1234 | ||
1235 | init_second_stage(); | |
1236 | ||
1237 | } catch (e) { | |
1238 | exception_error("backend_sanity_check_callback", e); | |
1239 | } | |
1240 | } | |
1241 | } | |
1242 | ||
1243 | function init_second_stage() { | |
1244 | ||
1245 | try { | |
1246 | active_tab = getInitParam("prefs_active_tab"); | |
1247 | if (!active_tab) active_tab = "genConfig"; | |
1248 | ||
1249 | document.onkeydown = pref_hotkey_handler; | |
1250 | ||
1251 | if (navigator.userAgent.match("Opera")) { | |
1252 | setTimeout("selectTab()", 500); | |
1253 | } else { | |
1254 | selectTab(active_tab); | |
1255 | } | |
1256 | notify(""); | |
1257 | } catch (e) { | |
1258 | exception_error("init_second_stage", e); | |
1259 | } | |
1260 | } | |
1261 | ||
1262 | function init() { | |
1263 | ||
1264 | try { | |
1265 | ||
1266 | if (arguments.callee.done) return; | |
1267 | arguments.callee.done = true; | |
1268 | ||
1269 | if (getURLParam('debug')) { | |
1270 | document.getElementById('debug_output').style.display = 'block'; | |
1271 | debug('debug mode activated'); | |
1272 | } | |
1273 | ||
1274 | // IE kludge | |
1275 | if (!xmlhttp) { | |
1276 | document.getElementById("prefContent").innerHTML = | |
1277 | "<b>Fatal error:</b> This program needs XmlHttpRequest " + | |
1278 | "to function properly. Your browser doesn't seem to support it."; | |
1279 | return; | |
1280 | } | |
1281 | ||
1282 | xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true); | |
1283 | xmlhttp.onreadystatechange=backend_sanity_check_callback; | |
1284 | xmlhttp.send(null); | |
1285 | ||
1286 | } catch (e) { | |
1287 | exception_error("init", e); | |
1288 | } | |
1289 | } | |
1290 | ||
1291 | function categorizeSelectedFeeds() { | |
1292 | ||
1293 | if (!xmlhttp_ready(xmlhttp)) { | |
1294 | printLockingError(); | |
1295 | return | |
1296 | } | |
1297 | ||
1298 | var sel_rows = getSelectedFeeds(); | |
1299 | ||
1300 | var cat_sel = document.getElementById("sfeed_set_fcat"); | |
1301 | var cat_id = cat_sel[cat_sel.selectedIndex].value; | |
1302 | ||
1303 | if (sel_rows.length > 0) { | |
1304 | ||
1305 | notify("Changing category of selected feeds..."); | |
1306 | ||
1307 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+ | |
1308 | param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true); | |
1309 | xmlhttp.onreadystatechange=feedlist_callback; | |
1310 | xmlhttp.send(null); | |
1311 | ||
1312 | } else { | |
1313 | ||
1314 | alert("No feeds are selected."); | |
1315 | ||
1316 | } | |
1317 | ||
1318 | } | |
1319 | ||
1320 | function validatePrefsReset() { | |
1321 | return confirm("Reset to defaults?"); | |
1322 | } | |
1323 | ||
1324 | function browseFeeds(limit) { | |
1325 | ||
1326 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true); | |
1327 | xmlhttp.onreadystatechange=infobox_callback; | |
1328 | xmlhttp.send(null); | |
1329 | ||
1330 | } | |
1331 | ||
1332 | function feedBrowserSubscribe() { | |
1333 | try { | |
1334 | ||
1335 | var selected = getSelectedFeedsFromBrowser(); | |
1336 | ||
1337 | if (selected.length > 0) { | |
1338 | closeInfoBox(); | |
1339 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+ | |
1340 | param_escape(selected.toString()), true); | |
1341 | xmlhttp.onreadystatechange=feedlist_callback; | |
1342 | xmlhttp.send(null); | |
1343 | } else { | |
1344 | alert("No feeds are selected."); | |
1345 | } | |
1346 | ||
1347 | } catch (e) { | |
1348 | exception_error("feedBrowserSubscribe", e); | |
1349 | } | |
1350 | } | |
1351 | ||
1352 | function updateBigFeedBrowser(limit) { | |
1353 | ||
1354 | if (!xmlhttp_ready(xmlhttp)) { | |
1355 | printLockingError(); | |
1356 | return | |
1357 | } | |
1358 | ||
1359 | // p_notify("Loading, please wait..."); | |
1360 | ||
1361 | var query = "backend.php?op=pref-feed-browser"; | |
1362 | ||
1363 | var limit_sel = document.getElementById("feedBrowserLimit"); | |
1364 | ||
1365 | if (limit_sel) { | |
1366 | var limit = limit_sel[limit_sel.selectedIndex].value; | |
1367 | query = query + "&limit=" + param_escape(limit); | |
1368 | } | |
1369 | ||
1370 | xmlhttp.open("GET", query, true); | |
1371 | xmlhttp.onreadystatechange=feed_browser_callback; | |
1372 | xmlhttp.send(null); | |
1373 | } | |
1374 | ||
1375 | function browserToggleExpand(id) { | |
1376 | try { | |
1377 | /* if (feed_to_expand && feed_to_expand != id) { | |
1378 | var d = document.getElementById("BRDET-" + feed_to_expand); | |
1379 | d.style.display = "none"; | |
1380 | } */ | |
1381 | ||
1382 | if (!xmlhttp_ready(xmlhttp)) { | |
1383 | printLockingError(); | |
1384 | return | |
1385 | } | |
1386 | ||
1387 | var d = document.getElementById("BRDET-" + id); | |
1388 | ||
1389 | if (d.style.display == "block") { | |
1390 | d.style.display = "none"; | |
1391 | ||
1392 | } else { | |
1393 | ||
1394 | feed_to_expand = id; | |
1395 | ||
1396 | d.style.display = "block"; | |
1397 | d.innerHTML = "Loading, please wait..."; | |
1398 | ||
1399 | xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id=" | |
1400 | + param_escape(id), true); | |
1401 | xmlhttp.onreadystatechange=expand_feed_callback; | |
1402 | xmlhttp.send(null); | |
1403 | } | |
1404 | ||
1405 | } catch (e) { | |
1406 | exception_error("browserExpand", e); | |
1407 | } | |
1408 | } | |
1409 | ||
1410 | function validateNewPassword(form) { | |
1411 | if (form.OLD_PASSWORD.value == "") { | |
1412 | alert("Old password cannot be blank"); | |
1413 | return false; | |
1414 | } | |
1415 | if (form.NEW_PASSWORD.value == "") { | |
1416 | alert("New password cannot be blank"); | |
1417 | return false; | |
1418 | } | |
1419 | return true; | |
1420 | } | |
1421 | ||
1422 | function selectPrefRows(kind, select) { | |
1423 | ||
1424 | if (kind) { | |
1425 | var opbarid = false; | |
1426 | var nchk = false; | |
1427 | var nrow = false; | |
1428 | var lname = false; | |
1429 | ||
1430 | if (kind == "feed") { | |
1431 | opbarid = "feedOpToolbar"; | |
1432 | nrow = "FEEDR-"; | |
1433 | nchk = "FRCHK-"; | |
1434 | lname = "prefFeedList"; | |
1435 | } else if (kind == "fcat") { | |
1436 | opbarid = "catOpToolbar"; | |
1437 | nrow = "FCATR-"; | |
1438 | nchk = "FCHK-"; | |
1439 | lname = "prefFeedCatList"; | |
1440 | } else if (kind == "filter") { | |
1441 | opbarid = "filterOpToolbar"; | |
1442 | nrow = "FILRR-"; | |
1443 | nchk = "FICHK-"; | |
1444 | lname = "prefFilterList"; | |
1445 | } else if (kind == "label") { | |
1446 | opbarid = "labelOpToolbar"; | |
1447 | nrow = "LILRR-"; | |
1448 | nchk = "LICHK-"; | |
1449 | lname = "prefLabelList"; | |
1450 | } else if (kind == "user") { | |
1451 | opbarid = "userOpToolbar"; | |
1452 | nrow = "UMRR-"; | |
1453 | nchk = "UMCHK-"; | |
1454 | lname = "prefUserList"; | |
1455 | } | |
1456 | ||
1457 | if (opbarid) { | |
1458 | selectTableRowsByIdPrefix(lname, nrow, nchk, select); | |
1459 | disableContainerChildren(opbarid, !select); | |
1460 | } | |
1461 | ||
1462 | } | |
1463 | } | |
1464 | ||
1465 | ||
1466 | function toggleSelectPrefRow(sender, kind) { | |
1467 | ||
1468 | toggleSelectRow(sender); | |
1469 | ||
1470 | if (kind) { | |
1471 | var opbarid = false; | |
1472 | var nsel = -1; | |
1473 | ||
1474 | if (kind == "feed") { | |
1475 | opbarid = "feedOpToolbar"; | |
1476 | nsel = getSelectedFeeds(); | |
1477 | } else if (kind == "fcat") { | |
1478 | opbarid = "catOpToolbar"; | |
1479 | nsel = getSelectedFeedCats(); | |
1480 | } else if (kind == "filter") { | |
1481 | opbarid = "filterOpToolbar"; | |
1482 | nsel = getSelectedFilters(); | |
1483 | } else if (kind == "label") { | |
1484 | opbarid = "labelOpToolbar"; | |
1485 | nsel = getSelectedLabels(); | |
1486 | } else if (kind == "user") { | |
1487 | opbarid = "userOpToolbar"; | |
1488 | nsel = getSelectedUsers(); | |
1489 | } | |
1490 | ||
1491 | if (opbarid && nsel != -1) { | |
1492 | disableContainerChildren(opbarid, nsel == false); | |
1493 | } | |
1494 | ||
1495 | } | |
1496 | } | |
1497 | ||
1498 | function toggleSelectFBListRow(sender) { | |
1499 | toggleSelectListRow(sender); | |
1500 | disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0); | |
1501 | } | |
1502 | ||
1503 | var seq = ""; | |
1504 | ||
1505 | function pref_hotkey_handler(e) { | |
1506 | try { | |
1507 | ||
1508 | var keycode; | |
1509 | ||
1510 | if (!hotkeys_enabled) return; | |
1511 | ||
1512 | if (window.event) { | |
1513 | keycode = window.event.keyCode; | |
1514 | } else if (e) { | |
1515 | keycode = e.which; | |
1516 | } | |
1517 | ||
1518 | if (keycode == 13 || keycode == 27) { | |
1519 | seq = ""; | |
1520 | } else { | |
1521 | seq = seq + "" + keycode; | |
1522 | } | |
1523 | ||
1524 | ||
1525 | if (document.getElementById("piggie")) { | |
1526 | ||
1527 | if (seq.match("807371717369")) { | |
1528 | seq = ""; | |
1529 | localPiggieFunction(true); | |
1530 | } else { | |
1531 | localPiggieFunction(false); | |
1532 | } | |
1533 | } | |
1534 | ||
1535 | } catch (e) { | |
1536 | exception_error("pref_hotkey_handler", e); | |
1537 | } | |
1538 | } | |
1539 | ||
1540 | function userSwitch() { | |
1541 | var chooser = document.getElementById("userSwitch"); | |
1542 | var user = chooser[chooser.selectedIndex].value; | |
1543 | window.location = "prefs.php?swu=" + user; | |
1544 | } |