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