]> git.wh0rd.org - tt-rss.git/blob - prefs.js
basic functionality pass 11
[tt-rss.git] / prefs.js
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
8 /*@cc_on @*/
9 /*@if (@_jscript_version >= 5)
10 // JScript gives us Conditional compilation, we can cope with old IE versions.
11 // and security blocked creation of the objects.
12 try {
13 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
14 } catch (e) {
15 try {
16 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
17 } catch (E) {
18 xmlhttp = false;
19 }
20 }
21 @end @*/
22
23 if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
24 xmlhttp = new XMLHttpRequest();
25 }
26
27
28 function feedlist_callback() {
29 var container = document.getElementById('feeds');
30 if (xmlhttp.readyState == 4) {
31 container.innerHTML=xmlhttp.responseText;
32 }
33 }
34
35 function update_feeds() {
36
37 document.getElementById("feeds").innerHTML = "Loading feeds, please wait...";
38
39 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
40 xmlhttp.onreadystatechange=feedlist_callback;
41 xmlhttp.send(null);
42
43 }
44
45 function toggleSelectRow(sender) {
46 var parent_row = sender.parentNode.parentNode;
47
48 if (sender.checked) {
49 if (!parent_row.className.match("Selected")) {
50 parent_row.className = parent_row.className + "Selected";
51 }
52 } else {
53 if (parent_row.className.match("Selected")) {
54 parent_row.className = parent_row.className.replace("Selected", "");
55 }
56 }
57 }
58
59 function addFeed() {
60
61 var link = document.getElementById("fadd_link");
62
63 if (link.value.length == 0) {
64 notify("Error: Missing feed URL.");
65 } else {
66 notify("Adding feed...");
67
68 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
69 param_escape(link.value), true);
70 xmlhttp.onreadystatechange=feedlist_callback;
71 xmlhttp.send(null);
72
73 link.value = "";
74
75 }
76
77 }
78
79 function editFeed(feed) {
80
81 notify("Editing feed...");
82
83 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
84 param_escape(feed), true);
85 xmlhttp.onreadystatechange=feedlist_callback;
86 xmlhttp.send(null);
87
88 }
89
90 function getSelectedFeeds() {
91
92 var content = document.getElementById("prefFeedList");
93
94 var sel_rows = new Array();
95
96 for (i = 0; i < content.rows.length; i++) {
97 if (content.rows[i].className.match("Selected")) {
98 var row_id = content.rows[i].id.replace("FEEDR-", "");
99 sel_rows.push(row_id);
100 }
101 }
102
103 return sel_rows;
104 }
105
106 function readSelectedFeeds() {
107
108 var sel_rows = getSelectedFeeds();
109
110 if (sel_rows.length > 0) {
111
112 notify("Marking selected feeds as read...");
113
114 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=unread&ids="+
115 param_escape(sel_rows.toString()), true);
116 xmlhttp.onreadystatechange=feedlist_callback;
117 xmlhttp.send(null);
118
119 } else {
120
121 notify("Error: Please select some feeds first.");
122
123 }
124 }
125
126 function unreadSelectedFeeds() {
127
128 var sel_rows = getSelectedFeeds();
129
130 if (sel_rows.length > 0) {
131
132 notify("Marking selected feeds as unread...");
133
134 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=unread&ids="+
135 param_escape(sel_rows.toString()), true);
136 xmlhttp.onreadystatechange=feedlist_callback;
137 xmlhttp.send(null);
138
139 } else {
140
141 notify("Error: Please select some feeds first.");
142
143 }
144 }
145
146 function removeSelectedFeeds() {
147
148 var sel_rows = getSelectedFeeds();
149
150 if (sel_rows.length > 0) {
151
152 notify("Removing selected feeds...");
153
154 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
155 param_escape(sel_rows.toString()), true);
156 xmlhttp.onreadystatechange=feedlist_callback;
157 xmlhttp.send(null);
158
159 } else {
160
161 notify("Error: Please select some feeds first.");
162
163 }
164
165 }
166
167 function init() {
168
169 update_feeds();
170
171 notify("");
172
173 }