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