]>
git.wh0rd.org - tt-rss.git/blob - prefs.js
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.
8 var active_feed
= false;
9 var active_filter
= false;
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.
16 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
19 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
26 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
27 xmlhttp
= new XMLHttpRequest();
30 function feedlist_callback() {
31 var container
= document
.getElementById('feedConfPane');
32 if (xmlhttp
.readyState
== 4) {
33 container
.innerHTML
=xmlhttp
.responseText
;
36 var row
= document
.getElementById("FEEDR-" + active_feed
);
38 if (!row
.className
.match("Selected")) {
39 row
.className
= row
.className
+ "Selected";
42 var checkbox
= document
.getElementById("FRCHK-" + active_feed
);
44 checkbox
.checked
= true;
50 function filterlist_callback() {
51 var container
= document
.getElementById('filterConfPane');
52 if (xmlhttp
.readyState
== 4) {
53 container
.innerHTML
=xmlhttp
.responseText
;
56 var row
= document
.getElementById("FILRR-" + active_filter
);
58 if (!row
.className
.match("Selected")) {
59 row
.className
= row
.className
+ "Selected";
62 var checkbox
= document
.getElementById("FICHK-" + active_filter
);
65 checkbox
.checked
= true;
71 function notify_callback() {
72 var container
= document
.getElementById('notify');
73 if (xmlhttp
.readyState
== 4) {
74 container
.innerHTML
=xmlhttp
.responseText
;
79 function updateFeedList() {
81 if (!xmlhttp_ready(xmlhttp
)) {
86 document
.getElementById("feedConfPane").innerHTML
= "Loading feeds, please wait...";
88 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
89 xmlhttp
.onreadystatechange
=feedlist_callback
;
94 function toggleSelectRow(sender
) {
95 var parent_row
= sender
.parentNode
.parentNode
;
98 if (!parent_row
.className
.match("Selected")) {
99 parent_row
.className
= parent_row
.className
+ "Selected";
102 if (parent_row
.className
.match("Selected")) {
103 parent_row
.className
= parent_row
.className
.replace("Selected", "");
108 function addFilter() {
110 if (!xmlhttp_ready(xmlhttp
)) {
115 var regexp
= document
.getElementById("fadd_regexp");
116 var match
= document
.getElementById("fadd_match");
118 if (regexp
.value
.length
== 0) {
119 notify("Missing filter expression.");
121 notify("Adding filter...");
123 var v_match
= match
[match
.selectedIndex
].text
;
125 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
126 param_escape(regexp
.value
) + "&match=" + v_match
, true);
128 xmlhttp
.onreadystatechange
=filterlist_callback
;
137 if (!xmlhttp_ready(xmlhttp
)) {
142 var link
= document
.getElementById("fadd_link");
144 if (link
.value
.length
== 0) {
145 notify("Missing feed URL.");
147 notify("Adding feed...");
149 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
150 param_escape(link
.value
), true);
151 xmlhttp
.onreadystatechange
=feedlist_callback
;
160 function editFilter(id
) {
162 if (!xmlhttp_ready(xmlhttp
)) {
169 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
170 param_escape(id
), true);
171 xmlhttp
.onreadystatechange
=filterlist_callback
;
176 function editFeed(feed
) {
178 // notify("Editing feed...");
180 if (!xmlhttp_ready(xmlhttp
)) {
187 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
188 param_escape(feed
), true);
189 xmlhttp
.onreadystatechange
=feedlist_callback
;
194 function getSelectedFilters() {
196 var content
= document
.getElementById("prefFilterList");
198 var sel_rows
= new Array();
200 for (i
= 0; i
< content
.rows
.length
; i
++) {
201 if (content
.rows
[i
].className
.match("Selected")) {
202 var row_id
= content
.rows
[i
].id
.replace("FILRR-", "");
203 sel_rows
.push(row_id
);
210 function getSelectedFeeds() {
212 var content
= document
.getElementById("prefFeedList");
214 var sel_rows
= new Array();
216 for (i
= 0; i
< content
.rows
.length
; i
++) {
217 if (content
.rows
[i
].className
.match("Selected")) {
218 var row_id
= content
.rows
[i
].id
.replace("FEEDR-", "");
219 sel_rows
.push(row_id
);
226 function readSelectedFeeds() {
228 if (!xmlhttp_ready(xmlhttp
)) {
233 var sel_rows
= getSelectedFeeds();
235 if (sel_rows
.length
> 0) {
237 notify("Marking selected feeds as read...");
239 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
240 param_escape(sel_rows
.toString()), true);
241 xmlhttp
.onreadystatechange
=notify_callback
;
246 notify("Please select some feeds first.");
251 function unreadSelectedFeeds() {
253 if (!xmlhttp_ready(xmlhttp
)) {
258 var sel_rows
= getSelectedFeeds();
260 if (sel_rows
.length
> 0) {
262 notify("Marking selected feeds as unread...");
264 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
265 param_escape(sel_rows
.toString()), true);
266 xmlhttp
.onreadystatechange
=notify_callback
;
271 notify("Please select some feeds first.");
276 function removeSelectedFeeds() {
278 if (!xmlhttp_ready(xmlhttp
)) {
283 var sel_rows
= getSelectedFeeds();
285 if (sel_rows
.length
> 0) {
287 notify("Removing selected feeds...");
289 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
290 param_escape(sel_rows
.toString()), true);
291 xmlhttp
.onreadystatechange
=feedlist_callback
;
296 notify("Please select some feeds first.");
302 function feedEditCancel() {
304 if (!xmlhttp_ready(xmlhttp
)) {
311 notify("Operation cancelled.");
313 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
314 xmlhttp
.onreadystatechange
=feedlist_callback
;
319 function feedEditSave() {
321 var feed
= active_feed
;
323 if (!xmlhttp_ready(xmlhttp
)) {
328 var link
= document
.getElementById("iedit_link").value
;
329 var title
= document
.getElementById("iedit_title").value
;
331 // notify("Saving feed.");
333 if (link
.length
== 0) {
334 notify("Feed link cannot be blank.");
338 if (title
.length
== 0) {
339 notify("Feed title cannot be blank.");
345 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
346 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) ,true);
347 xmlhttp
.onreadystatechange
=feedlist_callback
;
352 function filterEditCancel() {
354 if (!xmlhttp_ready(xmlhttp
)) {
359 active_filter
= false;
361 notify("Operation cancelled.");
363 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
364 xmlhttp
.onreadystatechange
=filterlist_callback
;
369 function filterEditSave() {
371 var filter
= active_filter
;
373 if (!xmlhttp_ready(xmlhttp
)) {
378 var regexp
= document
.getElementById("iedit_regexp").value
;
379 var descr
= document
.getElementById("iedit_descr").value
;
380 var match
= document
.getElementById("iedit_match");
382 var v_match
= match
[match
.selectedIndex
].text
;
384 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
386 if (regexp
.length
== 0) {
387 notify("Filter expression cannot be blank.");
391 active_filter
= false;
393 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
394 filter
+ "&r=" + param_escape(regexp
) + "&d=" + param_escape(descr
) +
395 "&m=" + param_escape(v_match
), true);
397 xmlhttp
.onreadystatechange
=filterlist_callback
;
402 function removeSelectedFilters() {
404 if (!xmlhttp_ready(xmlhttp
)) {
409 var sel_rows
= getSelectedFilters();
411 if (sel_rows
.length
> 0) {
413 notify("Removing selected filters...");
415 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
416 param_escape(sel_rows
.toString()), true);
417 xmlhttp
.onreadystatechange
=filterlist_callback
;
421 notify("Please select some filters first.");
426 function editSelectedFilter() {
427 var rows
= getSelectedFilters();
429 if (rows
.length
== 0) {
430 notify("No filters are selected.");
434 if (rows
.length
> 1) {
435 notify("Please select one filter.");
444 function editSelectedFeed() {
445 var rows
= getSelectedFeeds();
447 if (rows
.length
== 0) {
448 notify("No feeds are selected.");
452 if (rows
.length
> 1) {
453 notify("Please select one feed.");
461 function localPiggieFunction(enable
) {
463 piggie
.style
.display
= "block";
465 notify("I loveded it!!!");
467 piggie
.style
.display
= "none";
472 function validateOpmlImport() {
474 var opml_file
= document
.getElementById("opml_file");
476 if (opml_file
.value
.length
== 0) {
477 notify("Please select OPML file to upload.");
484 function updateFilterList() {
486 if (!xmlhttp_ready(xmlhttp
)) {
491 document
.getElementById("filterConfPane").innerHTML
= "Loading filters, please wait...";
493 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
494 xmlhttp
.onreadystatechange
=filterlist_callback
;
499 function expandPane(id
) {
503 container
= document
.getElementById(id
);
505 if (id
== "feedConfPane") {
507 } else if (id
== "filterConfPane") {
517 document
.getElementById("prefContent").innerHTML
=
518 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
519 "to function properly. Your browser doesn't seem to support it.";
524 document
.onkeydown
= hotkey_handler
;