]>
Commit | Line | Data |
---|---|---|
760966c1 AD |
1 | var hotkeys_enabled = true; |
2 | ||
3 | function disableHotkeys() { | |
4 | hotkeys_enabled = false; | |
5 | } | |
6 | ||
7 | function enableHotkeys() { | |
8 | hotkeys_enabled = true; | |
9 | } | |
10 | ||
c0e5a40e AD |
11 | function xmlhttp_ready(obj) { |
12 | return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState; | |
13 | } | |
14 | ||
15 | ||
9cfc649a AD |
16 | function notify_callback() { |
17 | var container = document.getElementById('notify'); | |
18 | if (xmlhttp.readyState == 4) { | |
19 | container.innerHTML=xmlhttp.responseText; | |
20 | } | |
21 | } | |
22 | ||
23 | function rpc_notify_callback() { | |
24 | var container = document.getElementById('notify'); | |
25 | if (xmlhttp_rpc.readyState == 4) { | |
26 | container.innerHTML=xmlhttp_rpc.responseText; | |
27 | } | |
28 | } | |
29 | ||
7726fa02 AD |
30 | function param_escape(arg) { |
31 | if (typeof encodeURIComponent != 'undefined') | |
32 | return encodeURIComponent(arg); | |
33 | else | |
34 | return escape(arg); | |
35 | } | |
36 | ||
37 | function param_unescape(arg) { | |
38 | if (typeof decodeURIComponent != 'undefined') | |
39 | return decodeURIComponent(arg); | |
40 | else | |
41 | return unescape(arg); | |
42 | } | |
43 | ||
508a81e1 AD |
44 | function delay(gap) { |
45 | var then,now; | |
46 | then=new Date().getTime(); | |
47 | now=then; | |
48 | while((now-then)<gap) { | |
49 | now=new Date().getTime(); | |
50 | } | |
51 | } | |
7726fa02 | 52 | |
c05608c2 AD |
53 | function p_notify(msg) { |
54 | ||
55 | var n = parent.document.getElementById("notify"); | |
56 | var nb = parent.document.getElementById("notify_body"); | |
57 | ||
58 | if (!n || !nb) return; | |
59 | ||
60 | nb.innerHTML = msg; | |
61 | ||
62 | if (msg.length == 0) { | |
63 | n.style.display = "none"; | |
64 | } else { | |
65 | n.style.display = "block"; | |
66 | } | |
67 | ||
68 | } | |
69 | ||
7726fa02 AD |
70 | function notify(msg) { |
71 | ||
72 | var n = document.getElementById("notify"); | |
c05608c2 | 73 | var nb = document.getElementById("notify_body"); |
7726fa02 | 74 | |
c05608c2 | 75 | if (!n || !nb) return; |
f0601b87 | 76 | |
c05608c2 | 77 | nb.innerHTML = msg; |
7726fa02 AD |
78 | |
79 | if (msg.length == 0) { | |
80 | n.style.display = "none"; | |
81 | } else { | |
82 | n.style.display = "block"; | |
83 | } | |
84 | ||
85 | } | |
86 | ||
508a81e1 | 87 | function printLockingError() { |
f0601b87 | 88 | notify("Please wait until operation finishes");} |
508a81e1 | 89 | |
13ad9102 AD |
90 | var seq = ""; |
91 | ||
92 | function hotkey_handler(e) { | |
760966c1 | 93 | |
13ad9102 AD |
94 | var keycode; |
95 | ||
760966c1 AD |
96 | if (!hotkeys_enabled) return; |
97 | ||
13ad9102 AD |
98 | if (window.event) { |
99 | keycode = window.event.keyCode; | |
100 | } else if (e) { | |
101 | keycode = e.which; | |
102 | } | |
103 | ||
104 | if (keycode == 13 || keycode == 27) { | |
105 | seq = ""; | |
106 | } else { | |
107 | seq = seq + "" + keycode; | |
108 | } | |
109 | ||
110 | var piggie = document.getElementById("piggie"); | |
111 | ||
bb7cface | 112 | if (piggie) { |
13ad9102 | 113 | |
bb7cface AD |
114 | if (seq.match("807371717369")) { |
115 | localPiggieFunction(true); | |
116 | } else { | |
117 | localPiggieFunction(false); | |
118 | } | |
119 | } | |
120 | ||
9cfc649a AD |
121 | if (typeof localHotkeyHandler != 'undefined') { |
122 | localHotkeyHandler(keycode); | |
123 | } | |
124 | ||
13ad9102 AD |
125 | } |
126 | ||
e828e31e | 127 | function cleanSelectedList(element) { |
f0601b87 AD |
128 | var content = document.getElementById(element); |
129 | ||
e828e31e | 130 | for (i = 0; i < content.childNodes.length; i++) { |
4ce19859 AD |
131 | content.childNodes[i].className = |
132 | content.childNodes[i].className.replace("Selected", ""); | |
e828e31e AD |
133 | } |
134 | ||
135 | } | |
136 | ||
137 | ||
138 | function cleanSelected(element) { | |
139 | var content = document.getElementById(element); | |
f0601b87 AD |
140 | |
141 | for (i = 0; i < content.rows.length; i++) { | |
142 | content.rows[i].className = content.rows[i].className.replace("Selected", ""); | |
143 | } | |
144 | ||
145 | } | |
146 | ||
147 | function getVisibleUnreadHeadlines() { | |
148 | var content = document.getElementById("headlinesList"); | |
149 | ||
150 | var rows = new Array(); | |
151 | ||
152 | for (i = 0; i < content.rows.length; i++) { | |
153 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
154 | if (row_id.length > 0 && content.rows[i].className.match("Unread")) { | |
155 | rows.push(row_id); | |
156 | } | |
157 | } | |
158 | return rows; | |
159 | } | |
160 | ||
161 | function getVisibleHeadlineIds() { | |
162 | ||
163 | var content = document.getElementById("headlinesList"); | |
164 | ||
165 | var rows = new Array(); | |
166 | ||
167 | for (i = 0; i < content.rows.length; i++) { | |
168 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
169 | if (row_id.length > 0) { | |
170 | rows.push(row_id); | |
171 | } | |
172 | } | |
173 | return rows; | |
174 | } | |
175 | ||
176 | function getFirstVisibleHeadlineId() { | |
177 | var rows = getVisibleHeadlineIds(); | |
178 | return rows[0]; | |
179 | } | |
180 | ||
181 | function getLastVisibleHeadlineId() { | |
182 | var rows = getVisibleHeadlineIds(); | |
183 | return rows[rows.length-1]; | |
184 | } | |
185 | ||
186 | function markHeadline(id) { | |
187 | var row = document.getElementById("RROW-" + id); | |
188 | if (row) { | |
189 | row.className = row.className + "Selected"; | |
190 | } | |
191 | } | |
192 | ||
193 | function getFeedIds() { | |
194 | var content = document.getElementById("feedsList"); | |
195 | ||
196 | var rows = new Array(); | |
197 | ||
198 | for (i = 0; i < content.rows.length; i++) { | |
199 | var id = content.rows[i].id.replace("FEEDR-", ""); | |
200 | if (id.length > 0) { | |
201 | rows.push(id); | |
202 | } | |
203 | } | |
204 | ||
205 | return rows; | |
206 | } | |
13ad9102 | 207 | |
ac43eba1 AD |
208 | function setCookie(name, value, expires, path, domain, secure) { |
209 | document.cookie= name + "=" + escape(value) + | |
210 | ((expires) ? "; expires=" + expires.toGMTString() : "") + | |
211 | ((path) ? "; path=" + path : "") + | |
212 | ((domain) ? "; domain=" + domain : "") + | |
213 | ((secure) ? "; secure" : ""); | |
214 | } | |
215 | ||
216 | function getCookie(name) { | |
217 | ||
218 | var dc = document.cookie; | |
219 | var prefix = name + "="; | |
220 | var begin = dc.indexOf("; " + prefix); | |
221 | if (begin == -1) { | |
222 | begin = dc.indexOf(prefix); | |
223 | if (begin != 0) return null; | |
224 | } | |
225 | else { | |
226 | begin += 2; | |
227 | } | |
228 | var end = document.cookie.indexOf(";", begin); | |
229 | if (end == -1) { | |
230 | end = dc.length; | |
231 | } | |
232 | return unescape(dc.substring(begin + prefix.length, end)); | |
233 | } | |
234 | ||
1a66d16e AD |
235 | function disableContainerChildren(id, disable, doc) { |
236 | ||
237 | if (!doc) doc = document; | |
238 | ||
239 | var container = doc.getElementById(id); | |
ac43eba1 AD |
240 | |
241 | for (var i = 0; i < container.childNodes.length; i++) { | |
242 | var child = container.childNodes[i]; | |
243 | ||
d5224f0d AD |
244 | try { |
245 | child.disabled = disable; | |
246 | } catch (E) { | |
247 | ||
248 | } | |
ac43eba1 AD |
249 | |
250 | if (disable) { | |
251 | if (child.className && child.className.match("button")) { | |
252 | child.className = "disabledButton"; | |
253 | } | |
254 | } else { | |
255 | if (child.className && child.className.match("disabledButton")) { | |
256 | child.className = "button"; | |
257 | } | |
d5224f0d | 258 | } |
ac43eba1 AD |
259 | } |
260 | ||
261 | } | |
7726fa02 | 262 | |
e828e31e AD |
263 | function gotoPreferences() { |
264 | document.location.href = "prefs.php"; | |
265 | } | |
266 | ||
267 | function gotoMain() { | |
268 | document.location.href = "tt-rss.php"; | |
269 | } | |
270 | ||
8158c57a AD |
271 | function gotoExportOpml() { |
272 | document.location.href = "opml.php?op=Export"; | |
273 | } | |
86741347 AD |
274 | |
275 | function getActiveFeedId() { | |
276 | return getCookie("ttrss_vf_actfeed"); | |
277 | } | |
278 | ||
279 | function setActiveFeedId(id) { | |
280 | return setCookie("ttrss_vf_actfeed", id); | |
281 | } | |
090e250b AD |
282 | |
283 | var xmlhttp_rpc = false; | |
284 | ||
285 | /*@cc_on @*/ | |
286 | /*@if (@_jscript_version >= 5) | |
287 | // JScript gives us Conditional compilation, we can cope with old IE versions. | |
288 | // and security blocked creation of the objects. | |
289 | try { | |
290 | xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP"); | |
291 | } catch (e) { | |
292 | try { | |
293 | xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP"); | |
294 | } catch (E) { | |
295 | xmlhttp_rpc = false; | |
296 | } | |
297 | } | |
298 | @end @*/ | |
299 | ||
300 | if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') { | |
301 | xmlhttp_rpc = new XMLHttpRequest(); | |
302 | } | |
303 | ||
304 | function label_counters_callback() { | |
305 | if (xmlhttp_rpc.readyState == 4) { | |
306 | var reply = xmlhttp_rpc.responseXML.firstChild; | |
307 | ||
308 | var f_document = parent.frames["feeds-frame"].document; | |
309 | ||
310 | for (var l = 0; l < reply.childNodes.length; l++) { | |
311 | var id = reply.childNodes[l].getAttribute("id"); | |
312 | var ctr = reply.childNodes[l].getAttribute("counter"); | |
313 | ||
314 | var feedctr = f_document.getElementById("FEEDCTR-" + id); | |
315 | var feedu = f_document.getElementById("FEEDU-" + id); | |
392d4563 | 316 | var feedr = f_document.getElementById("FEEDR-" + id); |
090e250b | 317 | |
8143ae1f AD |
318 | if (feedctr && feedu && feedr) { |
319 | ||
320 | feedu.innerHTML = ctr; | |
321 | ||
322 | if (ctr > 0) { | |
323 | feedctr.className = "odd"; | |
324 | if (!feedr.className.match("Unread")) { | |
325 | feedr.className = feedr.className + "Unread"; | |
326 | } | |
327 | } else { | |
328 | feedctr.className = "invisible"; | |
329 | feedr.className = feedr.className.replace("Unread", ""); | |
330 | } | |
331 | } | |
090e250b AD |
332 | } |
333 | } | |
334 | } | |
335 | ||
8073cce7 | 336 | function update_label_counters(feed) { |
090e250b | 337 | if (xmlhttp_ready(xmlhttp_rpc)) { |
8143ae1f | 338 | var query = "backend.php?op=rpc&subop=getAllCounters"; |
e47cfe37 AD |
339 | |
340 | if (feed > 0) { | |
341 | query = query + "&aid=" + feed; | |
342 | } | |
343 | ||
090e250b AD |
344 | xmlhttp_rpc.open("GET", query, true); |
345 | xmlhttp_rpc.onreadystatechange=label_counters_callback; | |
346 | xmlhttp_rpc.send(null); | |
347 | } | |
348 | } |