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