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