]>
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 | document.getElementById("subscribe_to_feed_btn").disabled = true; | |
412 | ||
413 | try { | |
414 | document.getElementById("top25_feeds_btn").disabled = true; | |
415 | } catch (e) { | |
416 | // this button is not always available, no-op if not found | |
417 | } | |
418 | ||
419 | // clean selection from all rows & select row being edited | |
420 | selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false); | |
421 | selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true); | |
422 | ||
423 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" + | |
424 | param_escape(feed), true); | |
425 | ||
426 | xmlhttp.onreadystatechange=infobox_callback; | |
427 | xmlhttp.send(null); | |
428 | ||
429 | } | |
430 | ||
431 | function editFeedCat(cat) { | |
432 | ||
433 | if (!xmlhttp_ready(xmlhttp)) { | |
434 | printLockingError(); | |
435 | return | |
436 | } | |
437 | ||
438 | notify_progress("Loading, please wait..."); | |
439 | ||
440 | active_feed_cat = cat; | |
441 | ||
442 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" + | |
443 | param_escape(cat), true); | |
444 | xmlhttp.onreadystatechange=infobox_callback; | |
445 | xmlhttp.send(null); | |
446 | ||
447 | } | |
448 | ||
449 | function getSelectedLabels() { | |
450 | return getSelectedTableRowIds("prefLabelList", "LILRR"); | |
451 | } | |
452 | ||
453 | function getSelectedUsers() { | |
454 | return getSelectedTableRowIds("prefUserList", "UMRR"); | |
455 | } | |
456 | ||
457 | function getSelectedFeeds() { | |
458 | return getSelectedTableRowIds("prefFeedList", "FEEDR"); | |
459 | } | |
460 | ||
461 | function getSelectedFilters() { | |
462 | return getSelectedTableRowIds("prefFilterList", "FILRR"); | |
463 | } | |
464 | ||
465 | function getSelectedFeedCats() { | |
466 | return getSelectedTableRowIds("prefFeedCatList", "FCATR"); | |
467 | } | |
468 | ||
469 | function getSelectedFeedsFromBrowser() { | |
470 | ||
471 | var list = document.getElementById("browseFeedList"); | |
472 | if (!list) list = document.getElementById("browseBigFeedList"); | |
473 | ||
474 | var selected = new Array(); | |
475 | ||
476 | for (i = 0; i < list.childNodes.length; i++) { | |
477 | var child = list.childNodes[i]; | |
478 | if (child.id && child.id.match("FBROW-")) { | |
479 | var id = child.id.replace("FBROW-", ""); | |
480 | ||
481 | var cb = document.getElementById("FBCHK-" + id); | |
482 | ||
483 | if (cb.checked) { | |
484 | selected.push(id); | |
485 | } | |
486 | } | |
487 | } | |
488 | ||
489 | return selected; | |
490 | } | |
491 | ||
492 | function removeSelectedLabels() { | |
493 | ||
494 | if (!xmlhttp_ready(xmlhttp)) { | |
495 | printLockingError(); | |
496 | return | |
497 | } | |
498 | ||
499 | var sel_rows = getSelectedLabels(); | |
500 | ||
501 | if (sel_rows.length > 0) { | |
502 | ||
503 | var ok = confirm("Remove selected labels?"); | |
504 | ||
505 | if (ok) { | |
506 | notify_progress("Removing selected labels..."); | |
507 | ||
508 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+ | |
509 | param_escape(sel_rows.toString()), true); | |
510 | xmlhttp.onreadystatechange=labellist_callback; | |
511 | xmlhttp.send(null); | |
512 | } | |
513 | } else { | |
514 | alert("No labels are selected."); | |
515 | } | |
516 | ||
517 | return false; | |
518 | } | |
519 | ||
520 | function removeSelectedUsers() { | |
521 | ||
522 | if (!xmlhttp_ready(xmlhttp)) { | |
523 | printLockingError(); | |
524 | return | |
525 | } | |
526 | ||
527 | var sel_rows = getSelectedUsers(); | |
528 | ||
529 | if (sel_rows.length > 0) { | |
530 | ||
531 | var ok = confirm("Remove selected users?"); | |
532 | ||
533 | if (ok) { | |
534 | notify_progress("Removing selected users..."); | |
535 | ||
536 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+ | |
537 | param_escape(sel_rows.toString()), true); | |
538 | xmlhttp.onreadystatechange=userlist_callback; | |
539 | xmlhttp.send(null); | |
540 | } | |
541 | ||
542 | } else { | |
543 | alert("No users are selected."); | |
544 | } | |
545 | ||
546 | return false; | |
547 | } | |
548 | ||
549 | function removeSelectedFilters() { | |
550 | ||
551 | if (!xmlhttp_ready(xmlhttp)) { | |
552 | printLockingError(); | |
553 | return | |
554 | } | |
555 | ||
556 | var sel_rows = getSelectedFilters(); | |
557 | ||
558 | if (sel_rows.length > 0) { | |
559 | ||
560 | var ok = confirm("Remove selected filters?"); | |
561 | ||
562 | if (ok) { | |
563 | notify_progress("Removing selected filters..."); | |
564 | ||
565 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+ | |
566 | param_escape(sel_rows.toString()), true); | |
567 | xmlhttp.onreadystatechange=filterlist_callback; | |
568 | xmlhttp.send(null); | |
569 | } | |
570 | } else { | |
571 | alert("No filters are selected."); | |
572 | } | |
573 | ||
574 | return false; | |
575 | } | |
576 | ||
577 | ||
578 | function removeSelectedFeeds() { | |
579 | ||
580 | if (!xmlhttp_ready(xmlhttp)) { | |
581 | printLockingError(); | |
582 | return | |
583 | } | |
584 | ||
585 | var sel_rows = getSelectedFeeds(); | |
586 | ||
587 | if (sel_rows.length > 0) { | |
588 | ||
589 | var ok = confirm("Unsubscribe from selected feeds?"); | |
590 | ||
591 | if (ok) { | |
592 | ||
593 | notify_progress("Unsubscribing from selected feeds..."); | |
594 | ||
595 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
596 | param_escape(sel_rows.toString()), true); | |
597 | xmlhttp.onreadystatechange=feedlist_callback; | |
598 | xmlhttp.send(null); | |
599 | } | |
600 | ||
601 | } else { | |
602 | ||
603 | alert("No feeds are selected."); | |
604 | ||
605 | } | |
606 | ||
607 | return false; | |
608 | } | |
609 | ||
610 | function removeSelectedFeedCats() { | |
611 | ||
612 | if (!xmlhttp_ready(xmlhttp)) { | |
613 | printLockingError(); | |
614 | return | |
615 | } | |
616 | ||
617 | var sel_rows = getSelectedFeedCats(); | |
618 | ||
619 | if (sel_rows.length > 0) { | |
620 | ||
621 | var ok = confirm("Remove selected categories?"); | |
622 | ||
623 | if (ok) { | |
624 | notify_progress("Removing selected categories..."); | |
625 | ||
626 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+ | |
627 | param_escape(sel_rows.toString()), true); | |
628 | xmlhttp.onreadystatechange=infobox_callback; | |
629 | xmlhttp.send(null); | |
630 | } | |
631 | ||
632 | } else { | |
633 | ||
634 | alert("No categories are selected."); | |
635 | ||
636 | } | |
637 | ||
638 | return false; | |
639 | } | |
640 | ||
641 | function feedEditCancel() { | |
642 | ||
643 | if (!xmlhttp_ready(xmlhttp)) { | |
644 | printLockingError(); | |
645 | return | |
646 | } | |
647 | ||
648 | document.getElementById("subscribe_to_feed_btn").disabled = false; | |
649 | ||
650 | try { | |
651 | document.getElementById("top25_feeds_btn").disabled = false; | |
652 | } catch (e) { | |
653 | // this button is not always available, no-op if not found | |
654 | } | |
655 | ||
656 | closeInfoBox(); | |
657 | ||
658 | selectPrefRows('feed', false); // cleanup feed selection | |
659 | ||
660 | return false; | |
661 | } | |
662 | ||
663 | function feedCatEditCancel() { | |
664 | ||
665 | if (!xmlhttp_ready(xmlhttp)) { | |
666 | printLockingError(); | |
667 | return | |
668 | } | |
669 | ||
670 | active_feed_cat = false; | |
671 | ||
672 | // notify("Operation cancelled."); | |
673 | ||
674 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true); | |
675 | xmlhttp.onreadystatechange=infobox_callback; | |
676 | xmlhttp.send(null); | |
677 | ||
678 | return false; | |
679 | } | |
680 | ||
681 | function feedEditSave() { | |
682 | ||
683 | try { | |
684 | ||
685 | if (!xmlhttp_ready(xmlhttp)) { | |
686 | printLockingError(); | |
687 | return | |
688 | } | |
689 | ||
690 | // FIXME: add parameter validation | |
691 | ||
692 | var query = Form.serialize("edit_feed_form"); | |
693 | ||
694 | notify_progress("Saving feed..."); | |
695 | ||
696 | xmlhttp.open("POST", "backend.php", true); | |
697 | xmlhttp.onreadystatechange=feedlist_callback; | |
698 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
699 | xmlhttp.send(query); | |
700 | ||
701 | closeInfoBox(); | |
702 | ||
703 | return false; | |
704 | ||
705 | } catch (e) { | |
706 | exception_error("feedEditSave", e); | |
707 | } | |
708 | } | |
709 | ||
710 | function feedCatEditSave() { | |
711 | ||
712 | if (!xmlhttp_ready(xmlhttp)) { | |
713 | printLockingError(); | |
714 | return | |
715 | } | |
716 | ||
717 | notify_progress("Saving category..."); | |
718 | ||
719 | var query = Form.serialize("feed_cat_edit_form"); | |
720 | ||
721 | xmlhttp.open("GET", "backend.php?" + query, true); | |
722 | xmlhttp.onreadystatechange=infobox_callback; | |
723 | xmlhttp.send(null); | |
724 | ||
725 | active_feed_cat = false; | |
726 | ||
727 | return false; | |
728 | } | |
729 | ||
730 | ||
731 | function labelTest() { | |
732 | ||
733 | var container = document.getElementById('label_test_result'); | |
734 | container.style.display = "block"; | |
735 | container.innerHTML = "<p>Loading, please wait...</p>"; | |
736 | ||
737 | var form = document.forms['label_edit_form']; | |
738 | ||
739 | var sql_exp = form.sql_exp.value; | |
740 | var description = form.description.value; | |
741 | ||
742 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" + | |
743 | param_escape(sql_exp) + "&descr=" + param_escape(description), true); | |
744 | ||
745 | xmlhttp.onreadystatechange=labeltest_callback; | |
746 | xmlhttp.send(null); | |
747 | ||
748 | return false; | |
749 | } | |
750 | ||
751 | function displayHelpInfobox(topic_id) { | |
752 | ||
753 | /* if (!xmlhttp_ready(xmlhttp)) { | |
754 | printLockingError(); | |
755 | return | |
756 | } | |
757 | ||
758 | notify_progress("Loading help..."); | |
759 | ||
760 | xmlhttp.open("GET", "backend.php?op=help&tid=" + | |
761 | param_escape(topic_id), true); | |
762 | ||
763 | xmlhttp.onreadystatechange=helpbox_callback; | |
764 | xmlhttp.send(null); */ | |
765 | ||
766 | var url = "backend.php?op=help&tid=" + param_escape(topic_id); | |
767 | ||
768 | var w = window.open(url, "ttrss_help", | |
769 | "status=0,toolbar=0,location=0,width=400,height=450,menubar=0"); | |
770 | ||
771 | } | |
772 | ||
773 | function labelEditCancel() { | |
774 | ||
775 | if (!xmlhttp_ready(xmlhttp)) { | |
776 | printLockingError(); | |
777 | return | |
778 | } | |
779 | ||
780 | document.getElementById("label_create_btn").disabled = false; | |
781 | ||
782 | active_label = false; | |
783 | ||
784 | selectPrefRows('label', false); // cleanup feed selection | |
785 | closeInfoBox(); | |
786 | ||
787 | return false; | |
788 | } | |
789 | ||
790 | function userEditCancel() { | |
791 | ||
792 | if (!xmlhttp_ready(xmlhttp)) { | |
793 | printLockingError(); | |
794 | return | |
795 | } | |
796 | ||
797 | selectPrefRows('user', false); // cleanup feed selection | |
798 | closeInfoBox(); | |
799 | ||
800 | return false; | |
801 | } | |
802 | ||
803 | function filterEditCancel() { | |
804 | ||
805 | if (!xmlhttp_ready(xmlhttp)) { | |
806 | printLockingError(); | |
807 | return | |
808 | } | |
809 | ||
810 | document.getElementById("create_filter_btn").disabled = false; | |
811 | ||
812 | selectPrefRows('filter', false); // cleanup feed selection | |
813 | closeInfoBox(); | |
814 | ||
815 | return false; | |
816 | } | |
817 | ||
818 | function labelEditSave() { | |
819 | ||
820 | var label = active_label; | |
821 | ||
822 | if (!xmlhttp_ready(xmlhttp)) { | |
823 | printLockingError(); | |
824 | return | |
825 | } | |
826 | ||
827 | /* if (!is_opera()) { | |
828 | ||
829 | var sql_exp = document.forms["label_edit_form"].sql_exp.value; | |
830 | var description = document.forms["label_edit_form"].description.value; | |
831 | ||
832 | if (sql_exp.length == 0) { | |
833 | alert("SQL Expression cannot be blank."); | |
834 | return false; | |
835 | } | |
836 | ||
837 | if (description.length == 0) { | |
838 | alert("Caption field cannot be blank."); | |
839 | return false; | |
840 | } | |
841 | } */ | |
842 | ||
843 | closeInfoBox(); | |
844 | ||
845 | notify_progress("Saving label..."); | |
846 | ||
847 | active_label = false; | |
848 | ||
849 | query = Form.serialize("label_edit_form"); | |
850 | ||
851 | xmlhttp.open("GET", "backend.php?" + query, true); | |
852 | xmlhttp.onreadystatechange=labellist_callback; | |
853 | xmlhttp.send(null); | |
854 | ||
855 | return false; | |
856 | } | |
857 | ||
858 | function userEditSave() { | |
859 | ||
860 | if (!xmlhttp_ready(xmlhttp)) { | |
861 | printLockingError(); | |
862 | return | |
863 | } | |
864 | ||
865 | var login = document.forms["user_edit_form"].login.value; | |
866 | ||
867 | if (login.length == 0) { | |
868 | alert("Login field cannot be blank."); | |
869 | return; | |
870 | } | |
871 | ||
872 | notify_progress("Saving user..."); | |
873 | ||
874 | closeInfoBox(); | |
875 | ||
876 | var query = Form.serialize("user_edit_form"); | |
877 | ||
878 | xmlhttp.open("GET", "backend.php?" + query, true); | |
879 | xmlhttp.onreadystatechange=userlist_callback; | |
880 | xmlhttp.send(null); | |
881 | ||
882 | return false; | |
883 | } | |
884 | ||
885 | ||
886 | function filterEditSave() { | |
887 | ||
888 | if (!xmlhttp_ready(xmlhttp)) { | |
889 | printLockingError(); | |
890 | return | |
891 | } | |
892 | ||
893 | /* if (!is_opera()) { | |
894 | var reg_exp = document.forms["filter_edit_form"].reg_exp.value; | |
895 | ||
896 | if (reg_exp.length == 0) { | |
897 | alert("Filter expression field cannot be blank."); | |
898 | return; | |
899 | } | |
900 | } */ | |
901 | ||
902 | notify_progress("Saving filter..."); | |
903 | ||
904 | var query = Form.serialize("filter_edit_form"); | |
905 | ||
906 | closeInfoBox(); | |
907 | ||
908 | document.getElementById("create_filter_btn").disabled = false; | |
909 | ||
910 | xmlhttp.open("GET", "backend.php?" + query, true); | |
911 | xmlhttp.onreadystatechange=filterlist_callback; | |
912 | xmlhttp.send(null); | |
913 | ||
914 | return false; | |
915 | } | |
916 | ||
917 | function editSelectedLabel() { | |
918 | var rows = getSelectedLabels(); | |
919 | ||
920 | if (rows.length == 0) { | |
921 | alert(__("No labels are selected.")); | |
922 | return; | |
923 | } | |
924 | ||
925 | if (rows.length > 1) { | |
926 | alert(__("Please select only one label.")); | |
927 | return; | |
928 | } | |
929 | ||
930 | notify(""); | |
931 | ||
932 | editLabel(rows[0]); | |
933 | ||
934 | } | |
935 | ||
936 | function editSelectedUser() { | |
937 | var rows = getSelectedUsers(); | |
938 | ||
939 | if (rows.length == 0) { | |
940 | alert(__("No users are selected.")); | |
941 | return; | |
942 | } | |
943 | ||
944 | if (rows.length > 1) { | |
945 | alert(__("Please select only one user.")); | |
946 | return; | |
947 | } | |
948 | ||
949 | notify(""); | |
950 | ||
951 | editUser(rows[0]); | |
952 | } | |
953 | ||
954 | function resetSelectedUserPass() { | |
955 | var rows = getSelectedUsers(); | |
956 | ||
957 | if (rows.length == 0) { | |
958 | alert(__("No users are selected.")); | |
959 | return; | |
960 | } | |
961 | ||
962 | if (rows.length > 1) { | |
963 | alert(__("Please select only one user.")); | |
964 | return; | |
965 | } | |
966 | ||
967 | var ok = confirm(__("Reset password of selected user?")); | |
968 | ||
969 | if (ok) { | |
970 | notify_progress("Resetting password for selected user..."); | |
971 | ||
972 | var id = rows[0]; | |
973 | ||
974 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" + | |
975 | param_escape(id), true); | |
976 | xmlhttp.onreadystatechange=userlist_callback; | |
977 | xmlhttp.send(null); | |
978 | } | |
979 | } | |
980 | ||
981 | function selectedUserDetails() { | |
982 | ||
983 | if (!xmlhttp_ready(xmlhttp)) { | |
984 | printLockingError(); | |
985 | return | |
986 | } | |
987 | ||
988 | var rows = getSelectedUsers(); | |
989 | ||
990 | if (rows.length == 0) { | |
991 | alert(__("No users are selected.")); | |
992 | return; | |
993 | } | |
994 | ||
995 | if (rows.length > 1) { | |
996 | alert(__("Please select only one user.")); | |
997 | return; | |
998 | } | |
999 | ||
1000 | notify_progress("Loading, please wait..."); | |
1001 | ||
1002 | var id = rows[0]; | |
1003 | ||
1004 | xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true); | |
1005 | xmlhttp.onreadystatechange=infobox_callback; | |
1006 | xmlhttp.send(null); | |
1007 | ||
1008 | } | |
1009 | ||
1010 | function selectedFeedDetails() { | |
1011 | ||
1012 | if (!xmlhttp_ready(xmlhttp)) { | |
1013 | printLockingError(); | |
1014 | return | |
1015 | } | |
1016 | ||
1017 | var rows = getSelectedFeeds(); | |
1018 | ||
1019 | if (rows.length == 0) { | |
1020 | alert(__("No feeds are selected.")); | |
1021 | return; | |
1022 | } | |
1023 | ||
1024 | if (rows.length > 1) { | |
1025 | alert(__("Please select only one feed.")); | |
1026 | return; | |
1027 | } | |
1028 | ||
1029 | // var id = rows[0]; | |
1030 | ||
1031 | notify(""); | |
1032 | ||
1033 | xmlhttp.open("GET", "backend.php?op=feed-details&id=" + | |
1034 | param_escape(rows.toString()), true); | |
1035 | xmlhttp.onreadystatechange=infobox_callback; | |
1036 | xmlhttp.send(null); | |
1037 | ||
1038 | } | |
1039 | ||
1040 | function editSelectedFilter() { | |
1041 | var rows = getSelectedFilters(); | |
1042 | ||
1043 | if (rows.length == 0) { | |
1044 | alert(__("No filters are selected.")); | |
1045 | return; | |
1046 | } | |
1047 | ||
1048 | if (rows.length > 1) { | |
1049 | alert(__("Please select only one filter.")); | |
1050 | return; | |
1051 | } | |
1052 | ||
1053 | notify(""); | |
1054 | ||
1055 | editFilter(rows[0]); | |
1056 | ||
1057 | } | |
1058 | ||
1059 | ||
1060 | function editSelectedFeed() { | |
1061 | var rows = getSelectedFeeds(); | |
1062 | ||
1063 | if (rows.length == 0) { | |
1064 | alert(__("No feeds are selected.")); | |
1065 | return; | |
1066 | } | |
1067 | ||
1068 | if (rows.length > 1) { | |
1069 | alert(__("Please select one feed.")); | |
1070 | return; | |
1071 | } | |
1072 | ||
1073 | notify(""); | |
1074 | ||
1075 | editFeed(rows[0]); | |
1076 | ||
1077 | } | |
1078 | ||
1079 | function editSelectedFeedCat() { | |
1080 | var rows = getSelectedFeedCats(); | |
1081 | ||
1082 | if (rows.length == 0) { | |
1083 | alert(__("No categories are selected.")); | |
1084 | return; | |
1085 | } | |
1086 | ||
1087 | if (rows.length > 1) { | |
1088 | alert(__("Please select only one category.")); | |
1089 | return; | |
1090 | } | |
1091 | ||
1092 | notify(""); | |
1093 | ||
1094 | editFeedCat(rows[0]); | |
1095 | ||
1096 | } | |
1097 | ||
1098 | function piggie_callback() { | |
1099 | var piggie = document.getElementById("piggie"); | |
1100 | ||
1101 | piggie.style.top = piggie_top; | |
1102 | piggie.style.backgroundColor = "white"; | |
1103 | piggie.style.borderWidth = "1px"; | |
1104 | ||
1105 | if (piggie_fwd && piggie_top < 0) { | |
1106 | setTimeout("piggie_callback()", 50); | |
1107 | piggie_top = piggie_top + 10; | |
1108 | } else if (piggie_fwd && piggie_top >= 0) { | |
1109 | piggie_fwd = false; | |
1110 | setTimeout("piggie_callback()", 50); | |
1111 | } else if (!piggie_fwd && piggie_top > -400) { | |
1112 | setTimeout("piggie_callback()", 50); | |
1113 | piggie_top = piggie_top - 10; | |
1114 | } else if (!piggie_fwd && piggie_top <= -400) { | |
1115 | piggie.style.display = "none"; | |
1116 | piggie_fwd = true; | |
1117 | } | |
1118 | } | |
1119 | ||
1120 | var piggie_opacity = 0; | |
1121 | ||
1122 | function piggie2_callback() { | |
1123 | var piggie = document.getElementById("piggie"); | |
1124 | piggie.style.top = 0; | |
1125 | piggie.style.opacity = piggie_opacity; | |
1126 | piggie.style.backgroundColor = "transparent"; | |
1127 | piggie.style.borderWidth = "0px"; | |
1128 | ||
1129 | if (piggie_fwd && piggie_opacity < 1) { | |
1130 | setTimeout("piggie2_callback()", 50); | |
1131 | piggie_opacity = piggie_opacity + 0.03; | |
1132 | } else if (piggie_fwd && piggie_opacity >= 1) { | |
1133 | piggie_fwd = false; | |
1134 | setTimeout("piggie2_callback()", 50); | |
1135 | } else if (!piggie_fwd && piggie_opacity > 0) { | |
1136 | setTimeout("piggie2_callback()", 50); | |
1137 | piggie_opacity = piggie_opacity - 0.03; | |
1138 | } else if (!piggie_fwd && piggie_opacity <= 0) { | |
1139 | piggie.style.display = "none"; | |
1140 | piggie_fwd = true; | |
1141 | } | |
1142 | } | |
1143 | ||
1144 | function localPiggieFunction(enable) { | |
1145 | if (enable) { | |
1146 | debug("I LOVEDED IT!"); | |
1147 | var piggie = document.getElementById("piggie"); | |
1148 | piggie.style.display = "block"; | |
1149 | ||
1150 | if (navigator.userAgent.match("Gecko") && Math.random(1) > 0.5) { | |
1151 | piggie2_callback(); | |
1152 | } else { | |
1153 | piggie_callback(); | |
1154 | } | |
1155 | } | |
1156 | } | |
1157 | ||
1158 | function validateOpmlImport() { | |
1159 | ||
1160 | var opml_file = document.getElementById("opml_file"); | |
1161 | ||
1162 | if (opml_file.value.length == 0) { | |
1163 | alert(__("No OPML file to upload.")); | |
1164 | return false; | |
1165 | } else { | |
1166 | return true; | |
1167 | } | |
1168 | } | |
1169 | ||
1170 | function updateFilterList(sort_key) { | |
1171 | ||
1172 | if (!xmlhttp_ready(xmlhttp)) { | |
1173 | printLockingError(); | |
1174 | return | |
1175 | } | |
1176 | ||
1177 | // document.getElementById("prefContent").innerHTML = "Loading filters, please wait..."; | |
1178 | ||
1179 | // p_notify("Loading, please wait..."); | |
1180 | ||
1181 | xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" + | |
1182 | param_escape(sort_key), true); | |
1183 | xmlhttp.onreadystatechange=filterlist_callback; | |
1184 | xmlhttp.send(null); | |
1185 | ||
1186 | } | |
1187 | ||
1188 | function updateLabelList(sort_key) { | |
1189 | ||
1190 | if (!xmlhttp_ready(xmlhttp)) { | |
1191 | printLockingError(); | |
1192 | return | |
1193 | } | |
1194 | ||
1195 | // p_notify("Loading, please wait..."); | |
1196 | ||
1197 | // document.getElementById("prefContent").innerHTML = "Loading labels, please wait..."; | |
1198 | ||
1199 | xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" + | |
1200 | param_escape(sort_key), true); | |
1201 | xmlhttp.onreadystatechange=labellist_callback; | |
1202 | xmlhttp.send(null); | |
1203 | } | |
1204 | ||
1205 | function updatePrefsList() { | |
1206 | ||
1207 | if (!xmlhttp_ready(xmlhttp)) { | |
1208 | printLockingError(); | |
1209 | return | |
1210 | } | |
1211 | ||
1212 | // p_notify("Loading, please wait..."); | |
1213 | ||
1214 | xmlhttp.open("GET", "backend.php?op=pref-prefs", true); | |
1215 | xmlhttp.onreadystatechange=prefslist_callback; | |
1216 | xmlhttp.send(null); | |
1217 | ||
1218 | } | |
1219 | ||
1220 | function selectTab(id, noupdate, subop) { | |
1221 | ||
1222 | // alert(id); | |
1223 | ||
1224 | if (!id) id = active_tab; | |
1225 | ||
1226 | try { | |
1227 | ||
1228 | if (!xmlhttp_ready(xmlhttp)) { | |
1229 | printLockingError(); | |
1230 | return | |
1231 | } | |
1232 | ||
1233 | try { | |
1234 | var c = document.getElementById('prefContent'); | |
1235 | c.scrollTop = 0; | |
1236 | } catch (e) { }; | |
1237 | ||
1238 | if (!noupdate) { | |
1239 | ||
1240 | debug("selectTab: " + id + "(NU: " + noupdate + ")"); | |
1241 | ||
1242 | notify_progress("Loading, please wait..."); | |
1243 | ||
1244 | // close active infobox if needed | |
1245 | closeInfoBox(); | |
1246 | ||
1247 | // clean up all current selections, just in case | |
1248 | active_feed_cat = false; | |
1249 | active_label = false; | |
1250 | ||
1251 | if (id == "feedConfig") { | |
1252 | updateFeedList(); | |
1253 | } else if (id == "filterConfig") { | |
1254 | updateFilterList(); | |
1255 | } else if (id == "labelConfig") { | |
1256 | updateLabelList(); | |
1257 | } else if (id == "genConfig") { | |
1258 | updatePrefsList(); | |
1259 | } else if (id == "userConfig") { | |
1260 | updateUsersList(); | |
1261 | } else if (id == "feedBrowser") { | |
1262 | updateBigFeedBrowser(); | |
1263 | } | |
1264 | } | |
1265 | ||
1266 | var tab = document.getElementById(active_tab + "Tab"); | |
1267 | ||
1268 | if (tab) { | |
1269 | if (tab.className.match("Selected")) { | |
1270 | tab.className = "prefsTab"; | |
1271 | } | |
1272 | } | |
1273 | ||
1274 | tab = document.getElementById(id + "Tab"); | |
1275 | ||
1276 | if (tab) { | |
1277 | if (!tab.className.match("Selected")) { | |
1278 | tab.className = tab.className + "Selected"; | |
1279 | } | |
1280 | } | |
1281 | ||
1282 | active_tab = id; | |
1283 | ||
1284 | } catch (e) { | |
1285 | exception_error("selectTab", e); | |
1286 | } | |
1287 | } | |
1288 | ||
1289 | function backend_sanity_check_callback() { | |
1290 | ||
1291 | if (xmlhttp.readyState == 4) { | |
1292 | ||
1293 | try { | |
1294 | ||
1295 | if (sanity_check_done) { | |
1296 | fatalError(11, "Sanity check request received twice. This can indicate "+ | |
1297 | "presence of Firebug or some other disrupting extension. "+ | |
1298 | "Please disable it and try again."); | |
1299 | return; | |
1300 | } | |
1301 | ||
1302 | if (!xmlhttp.responseXML) { | |
1303 | fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText); | |
1304 | return; | |
1305 | } | |
1306 | ||
1307 | var reply = xmlhttp.responseXML.firstChild.firstChild; | |
1308 | ||
1309 | if (!reply) { | |
1310 | fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText); | |
1311 | return; | |
1312 | } | |
1313 | ||
1314 | var error_code = reply.getAttribute("error-code"); | |
1315 | ||
1316 | if (error_code && error_code != 0) { | |
1317 | return fatalError(error_code, reply.getAttribute("error-msg")); | |
1318 | } | |
1319 | ||
1320 | debug("sanity check ok"); | |
1321 | ||
1322 | var params = reply.nextSibling; | |
1323 | ||
1324 | if (params) { | |
1325 | debug('reading init-params...'); | |
1326 | var param = params.firstChild; | |
1327 | ||
1328 | while (param) { | |
1329 | var k = param.getAttribute("key"); | |
1330 | var v = param.getAttribute("value"); | |
1331 | debug(k + " => " + v); | |
1332 | init_params[k] = v; | |
1333 | param = param.nextSibling; | |
1334 | } | |
1335 | } | |
1336 | ||
1337 | sanity_check_done = true; | |
1338 | ||
1339 | init_second_stage(); | |
1340 | ||
1341 | } catch (e) { | |
1342 | exception_error("backend_sanity_check_callback", e); | |
1343 | } | |
1344 | } | |
1345 | } | |
1346 | ||
1347 | function init_second_stage() { | |
1348 | ||
1349 | try { | |
1350 | active_tab = getInitParam("prefs_active_tab"); | |
1351 | if (!active_tab || active_tab == '0') active_tab = "genConfig"; | |
1352 | ||
1353 | document.onkeydown = pref_hotkey_handler; | |
1354 | ||
1355 | var tab = getURLParam('tab'); | |
1356 | ||
1357 | caller_subop = getURLParam('subop'); | |
1358 | ||
1359 | if (tab) { | |
1360 | active_tab = tab; | |
1361 | } | |
1362 | ||
1363 | if (navigator.userAgent.match("Opera")) { | |
1364 | setTimeout("selectTab()", 500); | |
1365 | } else { | |
1366 | selectTab(active_tab); | |
1367 | } | |
1368 | notify(""); | |
1369 | } catch (e) { | |
1370 | exception_error("init_second_stage", e); | |
1371 | } | |
1372 | } | |
1373 | ||
1374 | function init() { | |
1375 | ||
1376 | try { | |
1377 | ||
1378 | if (arguments.callee.done) return; | |
1379 | arguments.callee.done = true; | |
1380 | ||
1381 | if (getURLParam('debug')) { | |
1382 | document.getElementById('debug_output').style.display = 'block'; | |
1383 | debug('debug mode activated'); | |
1384 | } | |
1385 | ||
1386 | // IE kludge | |
1387 | if (!xmlhttp) { | |
1388 | document.getElementById("prefContent").innerHTML = | |
1389 | "<b>Fatal error:</b> This program needs XmlHttpRequest " + | |
1390 | "to function properly. Your browser doesn't seem to support it."; | |
1391 | return; | |
1392 | } | |
1393 | ||
1394 | xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true); | |
1395 | xmlhttp.onreadystatechange=backend_sanity_check_callback; | |
1396 | xmlhttp.send(null); | |
1397 | ||
1398 | } catch (e) { | |
1399 | exception_error("init", e); | |
1400 | } | |
1401 | } | |
1402 | ||
1403 | function categorizeSelectedFeeds() { | |
1404 | ||
1405 | if (!xmlhttp_ready(xmlhttp)) { | |
1406 | printLockingError(); | |
1407 | return | |
1408 | } | |
1409 | ||
1410 | var sel_rows = getSelectedFeeds(); | |
1411 | ||
1412 | var cat_sel = document.getElementById("sfeed_set_fcat"); | |
1413 | var cat_id = cat_sel[cat_sel.selectedIndex].value; | |
1414 | ||
1415 | if (sel_rows.length > 0) { | |
1416 | ||
1417 | notify_progress("Changing category of selected feeds..."); | |
1418 | ||
1419 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+ | |
1420 | param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true); | |
1421 | xmlhttp.onreadystatechange=feedlist_callback; | |
1422 | xmlhttp.send(null); | |
1423 | ||
1424 | } else { | |
1425 | ||
1426 | alert(__("No feeds are selected.")); | |
1427 | ||
1428 | } | |
1429 | ||
1430 | } | |
1431 | ||
1432 | function validatePrefsReset() { | |
1433 | return confirm(__("Reset to defaults?")); | |
1434 | } | |
1435 | ||
1436 | function browseFeeds(limit) { | |
1437 | ||
1438 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true); | |
1439 | xmlhttp.onreadystatechange=infobox_callback; | |
1440 | xmlhttp.send(null); | |
1441 | ||
1442 | } | |
1443 | ||
1444 | function feedBrowserSubscribe() { | |
1445 | try { | |
1446 | ||
1447 | var selected = getSelectedFeedsFromBrowser(); | |
1448 | ||
1449 | if (selected.length > 0) { | |
1450 | closeInfoBox(); | |
1451 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+ | |
1452 | param_escape(selected.toString()), true); | |
1453 | xmlhttp.onreadystatechange=feedlist_callback; | |
1454 | xmlhttp.send(null); | |
1455 | } else { | |
1456 | alert("No feeds are selected."); | |
1457 | } | |
1458 | ||
1459 | } catch (e) { | |
1460 | exception_error("feedBrowserSubscribe", e); | |
1461 | } | |
1462 | } | |
1463 | ||
1464 | function updateBigFeedBrowser(limit) { | |
1465 | ||
1466 | if (!xmlhttp_ready(xmlhttp)) { | |
1467 | printLockingError(); | |
1468 | return | |
1469 | } | |
1470 | ||
1471 | // p_notify("Loading, please wait..."); | |
1472 | ||
1473 | var query = "backend.php?op=pref-feed-browser"; | |
1474 | ||
1475 | var limit_sel = document.getElementById("feedBrowserLimit"); | |
1476 | ||
1477 | if (limit_sel) { | |
1478 | var limit = limit_sel[limit_sel.selectedIndex].value; | |
1479 | query = query + "&limit=" + param_escape(limit); | |
1480 | } | |
1481 | ||
1482 | xmlhttp.open("GET", query, true); | |
1483 | xmlhttp.onreadystatechange=feed_browser_callback; | |
1484 | xmlhttp.send(null); | |
1485 | } | |
1486 | ||
1487 | function browserToggleExpand(id) { | |
1488 | try { | |
1489 | /* if (feed_to_expand && feed_to_expand != id) { | |
1490 | var d = document.getElementById("BRDET-" + feed_to_expand); | |
1491 | d.style.display = "none"; | |
1492 | } */ | |
1493 | ||
1494 | if (!xmlhttp_ready(xmlhttp)) { | |
1495 | printLockingError(); | |
1496 | return | |
1497 | } | |
1498 | ||
1499 | var d = document.getElementById("BRDET-" + id); | |
1500 | ||
1501 | if (d.style.display == "block") { | |
1502 | d.style.display = "none"; | |
1503 | ||
1504 | } else { | |
1505 | ||
1506 | feed_to_expand = id; | |
1507 | ||
1508 | d.style.display = "block"; | |
1509 | d.innerHTML = "Loading, please wait..."; | |
1510 | ||
1511 | xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id=" | |
1512 | + param_escape(id), true); | |
1513 | xmlhttp.onreadystatechange=expand_feed_callback; | |
1514 | xmlhttp.send(null); | |
1515 | } | |
1516 | ||
1517 | } catch (e) { | |
1518 | exception_error("browserExpand", e); | |
1519 | } | |
1520 | } | |
1521 | ||
1522 | function selectPrefRows(kind, select) { | |
1523 | ||
1524 | if (kind) { | |
1525 | var opbarid = false; | |
1526 | var nchk = false; | |
1527 | var nrow = false; | |
1528 | var lname = false; | |
1529 | ||
1530 | if (kind == "feed") { | |
1531 | opbarid = "feedOpToolbar"; | |
1532 | nrow = "FEEDR-"; | |
1533 | nchk = "FRCHK-"; | |
1534 | lname = "prefFeedList"; | |
1535 | } else if (kind == "fcat") { | |
1536 | opbarid = "catOpToolbar"; | |
1537 | nrow = "FCATR-"; | |
1538 | nchk = "FCCHK-"; | |
1539 | lname = "prefFeedCatList"; | |
1540 | } else if (kind == "filter") { | |
1541 | opbarid = "filterOpToolbar"; | |
1542 | nrow = "FILRR-"; | |
1543 | nchk = "FICHK-"; | |
1544 | lname = "prefFilterList"; | |
1545 | } else if (kind == "label") { | |
1546 | opbarid = "labelOpToolbar"; | |
1547 | nrow = "LILRR-"; | |
1548 | nchk = "LICHK-"; | |
1549 | lname = "prefLabelList"; | |
1550 | } else if (kind == "user") { | |
1551 | opbarid = "userOpToolbar"; | |
1552 | nrow = "UMRR-"; | |
1553 | nchk = "UMCHK-"; | |
1554 | lname = "prefUserList"; | |
1555 | } | |
1556 | ||
1557 | if (opbarid) { | |
1558 | selectTableRowsByIdPrefix(lname, nrow, nchk, select); | |
1559 | disableContainerChildren(opbarid, !select); | |
1560 | } | |
1561 | ||
1562 | } | |
1563 | } | |
1564 | ||
1565 | ||
1566 | function toggleSelectPrefRow(sender, kind) { | |
1567 | ||
1568 | toggleSelectRow(sender); | |
1569 | ||
1570 | if (kind) { | |
1571 | var opbarid = false; | |
1572 | var nsel = -1; | |
1573 | ||
1574 | if (kind == "feed") { | |
1575 | opbarid = "feedOpToolbar"; | |
1576 | nsel = getSelectedFeeds(); | |
1577 | } else if (kind == "fcat") { | |
1578 | opbarid = "catOpToolbar"; | |
1579 | nsel = getSelectedFeedCats(); | |
1580 | } else if (kind == "filter") { | |
1581 | opbarid = "filterOpToolbar"; | |
1582 | nsel = getSelectedFilters(); | |
1583 | } else if (kind == "label") { | |
1584 | opbarid = "labelOpToolbar"; | |
1585 | nsel = getSelectedLabels(); | |
1586 | } else if (kind == "user") { | |
1587 | opbarid = "userOpToolbar"; | |
1588 | nsel = getSelectedUsers(); | |
1589 | } | |
1590 | ||
1591 | if (opbarid && nsel != -1) { | |
1592 | disableContainerChildren(opbarid, nsel == false); | |
1593 | } | |
1594 | ||
1595 | } | |
1596 | } | |
1597 | ||
1598 | function toggleSelectFBListRow(sender) { | |
1599 | toggleSelectListRow(sender); | |
1600 | disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0); | |
1601 | } | |
1602 | ||
1603 | var seq = ""; | |
1604 | ||
1605 | function pref_hotkey_handler(e) { | |
1606 | try { | |
1607 | ||
1608 | var keycode; | |
1609 | ||
1610 | if (!hotkeys_enabled) return; | |
1611 | ||
1612 | if (window.event) { | |
1613 | keycode = window.event.keyCode; | |
1614 | } else if (e) { | |
1615 | keycode = e.which; | |
1616 | } | |
1617 | ||
1618 | if (keycode == 13 || keycode == 27) { | |
1619 | seq = ""; | |
1620 | } else { | |
1621 | seq = seq + "" + keycode; | |
1622 | } | |
1623 | ||
1624 | ||
1625 | if (document.getElementById("piggie")) { | |
1626 | ||
1627 | if (seq.match("807371717369")) { | |
1628 | seq = ""; | |
1629 | localPiggieFunction(true); | |
1630 | } else { | |
1631 | localPiggieFunction(false); | |
1632 | } | |
1633 | } | |
1634 | ||
1635 | } catch (e) { | |
1636 | exception_error("pref_hotkey_handler", e); | |
1637 | } | |
1638 | } | |
1639 | ||
1640 | function userSwitch() { | |
1641 | var chooser = document.getElementById("userSwitch"); | |
1642 | var user = chooser[chooser.selectedIndex].value; | |
1643 | window.location = "prefs.php?swu=" + user; | |
1644 | } | |
1645 | ||
1646 | function editFeedCats() { | |
1647 | if (!xmlhttp_ready(xmlhttp)) { | |
1648 | printLockingError(); | |
1649 | return | |
1650 | } | |
1651 | ||
1652 | document.getElementById("subscribe_to_feed_btn").disabled = true; | |
1653 | ||
1654 | try { | |
1655 | document.getElementById("top25_feeds_btn").disabled = true; | |
1656 | } catch (e) { | |
1657 | // this button is not always available, no-op if not found | |
1658 | } | |
1659 | ||
1660 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true); | |
1661 | xmlhttp.onreadystatechange=infobox_callback; | |
1662 | xmlhttp.send(null); | |
1663 | } | |
1664 | ||
1665 | function showFeedsWithErrors() { | |
1666 | displayDlg('feedUpdateErrors'); | |
1667 | } | |
1668 | ||
1669 | function changeUserPassword() { | |
1670 | ||
1671 | try { | |
1672 | ||
1673 | if (!xmlhttp_ready(xmlhttp)) { | |
1674 | printLockingError(); | |
1675 | return false; | |
1676 | } | |
1677 | ||
1678 | var query = Form.serialize("change_pass_form"); | |
1679 | ||
1680 | notify_progress("Trying to change password..."); | |
1681 | ||
1682 | xmlhttp.open("POST", "backend.php", true); | |
1683 | xmlhttp.onreadystatechange=changepass_callback; | |
1684 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
1685 | xmlhttp.send(query); | |
1686 | ||
1687 | } catch (e) { | |
1688 | exception_error("changeUserPassword", e); | |
1689 | } | |
1690 | ||
1691 | return false; | |
1692 | } | |
1693 | ||
1694 | function changeUserEmail() { | |
1695 | ||
1696 | try { | |
1697 | ||
1698 | if (!xmlhttp_ready(xmlhttp)) { | |
1699 | printLockingError(); | |
1700 | return false; | |
1701 | } | |
1702 | ||
1703 | var query = Form.serialize("change_email_form"); | |
1704 | ||
1705 | notify_progress("Trying to change e-mail..."); | |
1706 | ||
1707 | xmlhttp.open("POST", "backend.php", true); | |
1708 | xmlhttp.onreadystatechange=notify_callback; | |
1709 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
1710 | xmlhttp.send(query); | |
1711 | ||
1712 | } catch (e) { | |
1713 | exception_error("changeUserPassword", e); | |
1714 | } | |
1715 | ||
1716 | return false; | |
1717 | ||
1718 | } |