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