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