]> git.wh0rd.org - tt-rss.git/blame - prefs.js
basic functionality pass 11
[tt-rss.git] / prefs.js
CommitLineData
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
6var 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.
12try {
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
23if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
24 xmlhttp = new XMLHttpRequest();
25}
26
007bda35
AD
27
28function feedlist_callback() {
29 var container = document.getElementById('feeds');
30 if (xmlhttp.readyState == 4) {
31 container.innerHTML=xmlhttp.responseText;
32 }
33}
34
35function 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
45function 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
71ad3959
AD
59function addFeed() {
60
331900c6
AD
61 var link = document.getElementById("fadd_link");
62
83fe4d6d
AD
63 if (link.value.length == 0) {
64 notify("Error: Missing feed URL.");
331900c6
AD
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
79function 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
83fe4d6d 90function getSelectedFeeds() {
331900c6
AD
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
83fe4d6d
AD
103 return sel_rows;
104}
105
106function 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
126function 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
146function removeSelectedFeeds() {
147
148 var sel_rows = getSelectedFeeds();
149
331900c6
AD
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);
71ad3959 158
71ad3959 159 } else {
331900c6 160
83fe4d6d 161 notify("Error: Please select some feeds first.");
331900c6 162
71ad3959
AD
163 }
164
165}
007bda35
AD
166
167function init() {
857a9270 168
007bda35
AD
169 update_feeds();
170
857a9270
AD
171 notify("");
172
007bda35 173}