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