]>
git.wh0rd.org - tt-rss.git/blob - functions.js
1 var hotkeys_enabled
= true;
3 function disableHotkeys() {
4 hotkeys_enabled
= false;
7 function enableHotkeys() {
8 hotkeys_enabled
= true;
11 function xmlhttp_ready(obj
) {
12 return obj
.readyState
== 4 || obj
.readyState
== 0 || !obj
.readyState
;
16 function notify_callback() {
17 var container
= document
.getElementById('notify');
18 if (xmlhttp
.readyState
== 4) {
19 container
.innerHTML
=xmlhttp
.responseText
;
23 function rpc_notify_callback() {
24 var container
= document
.getElementById('notify');
25 if (xmlhttp_rpc
.readyState
== 4) {
26 container
.innerHTML
=xmlhttp_rpc
.responseText
;
30 function param_escape(arg
) {
31 if (typeof encodeURIComponent
!= 'undefined')
32 return encodeURIComponent(arg
);
37 function param_unescape(arg
) {
38 if (typeof decodeURIComponent
!= 'undefined')
39 return decodeURIComponent(arg
);
46 then
=new Date().getTime();
48 while((now
-then
)<gap
) {
49 now
=new Date().getTime();
53 function p_notify(msg
) {
55 var n
= parent
.document
.getElementById("notify");
56 var nb
= parent
.document
.getElementById("notify_body");
58 if (!n
|| !nb
) return;
60 if (msg
== "") msg
= " ";
64 /* if (msg.length == 0) {
65 n.style.display = "none";
67 n.style.display = "block";
72 function notify(msg
) {
74 var n
= document
.getElementById("notify");
75 var nb
= document
.getElementById("notify_body");
77 if (!n
|| !nb
) return;
79 if (msg
== "") msg
= " ";
83 /* if (msg.length == 0) {
84 n.style.display = "none";
86 n.style.display = "block";
91 function printLockingError() {
92 notify("Please wait until operation finishes");}
96 function hotkey_handler(e
) {
100 if (!hotkeys_enabled
) return;
103 keycode
= window
.event
.keyCode
;
108 if (keycode
== 13 || keycode
== 27) {
111 seq
= seq
+ "" + keycode
;
114 var piggie
= document
.getElementById("piggie");
118 if (seq
.match("807371717369")) {
119 localPiggieFunction(true);
121 localPiggieFunction(false);
125 if (typeof localHotkeyHandler
!= 'undefined') {
126 localHotkeyHandler(keycode
);
131 function cleanSelectedList(element
) {
132 var content
= document
.getElementById(element
);
134 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
135 content
.childNodes
[i
].className
=
136 content
.childNodes
[i
].className
.replace("Selected", "");
142 function cleanSelected(element
) {
143 var content
= document
.getElementById(element
);
145 for (i
= 0; i
< content
.rows
.length
; i
++) {
146 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
151 function getVisibleUnreadHeadlines() {
152 var content
= document
.getElementById("headlinesList");
154 var rows
= new Array();
156 for (i
= 0; i
< content
.rows
.length
; i
++) {
157 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
158 if (row_id
.length
> 0 && content
.rows
[i
].className
.match("Unread")) {
165 function getVisibleHeadlineIds() {
167 var content
= document
.getElementById("headlinesList");
169 var rows
= new Array();
171 for (i
= 0; i
< content
.rows
.length
; i
++) {
172 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
173 if (row_id
.length
> 0) {
180 function getFirstVisibleHeadlineId() {
181 var rows
= getVisibleHeadlineIds();
185 function getLastVisibleHeadlineId() {
186 var rows
= getVisibleHeadlineIds();
187 return rows
[rows
.length
-1];
190 function markHeadline(id
) {
191 var row
= document
.getElementById("RROW-" + id
);
193 row
.className
= row
.className
+ "Selected";
197 function getFeedIds() {
198 var content
= document
.getElementById("feedsList");
200 var rows
= new Array();
202 for (i
= 0; i
< content
.rows
.length
; i
++) {
203 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
212 function setCookie(name
, value
, expires
, path
, domain
, secure
) {
213 document
.cookie
= name
+ "=" + escape(value
) +
214 ((expires
) ? "; expires=" + expires
.toGMTString() : "") +
215 ((path
) ? "; path=" + path
: "") +
216 ((domain
) ? "; domain=" + domain
: "") +
217 ((secure
) ? "; secure" : "");
220 function getCookie(name
) {
222 var dc
= document
.cookie
;
223 var prefix
= name
+ "=";
224 var begin
= dc
.indexOf("; " + prefix
);
226 begin
= dc
.indexOf(prefix
);
227 if (begin
!= 0) return null;
232 var end
= document
.cookie
.indexOf(";", begin
);
236 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
239 function disableContainerChildren(id
, disable
, doc
) {
241 if (!doc
) doc
= document
;
243 var container
= doc
.getElementById(id
);
245 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
246 var child
= container
.childNodes
[i
];
249 child
.disabled
= disable
;
255 if (child
.className
&& child
.className
.match("button")) {
256 child
.className
= "disabledButton";
259 if (child
.className
&& child
.className
.match("disabledButton")) {
260 child
.className
= "button";
267 function gotoPreferences() {
268 document
.location
.href
= "prefs.php";
271 function gotoMain() {
272 document
.location
.href
= "tt-rss.php";
275 function gotoExportOpml() {
276 document
.location
.href
= "opml.php?op=Export";
279 function getActiveFeedId() {
280 return getCookie("ttrss_vf_actfeed");
283 function setActiveFeedId(id
) {
284 return setCookie("ttrss_vf_actfeed", id
);
287 var xmlhttp_rpc
= false;
290 /*@if (@_jscript_version >= 5)
291 // JScript gives us Conditional compilation, we can cope with old IE versions.
292 // and security blocked creation of the objects.
294 xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP");
297 xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
304 if (!xmlhttp_rpc
&& typeof XMLHttpRequest
!='undefined') {
305 xmlhttp_rpc
= new XMLHttpRequest();
308 function label_counters_callback() {
309 if (xmlhttp_rpc
.readyState
== 4) {
311 if (!xmlhttp_rpc
.responseXML
) {
312 notify("label_counters_callback: backend did not return valid XML");
316 var reply
= xmlhttp_rpc
.responseXML
.firstChild
;
318 var f_document
= parent
.frames
["feeds-frame"].document
;
320 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
321 var id
= reply
.childNodes
[l
].getAttribute("id");
322 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
324 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
325 var feedu
= f_document
.getElementById("FEEDU-" + id
);
326 var feedr
= f_document
.getElementById("FEEDR-" + id
);
328 if (feedctr
&& feedu
&& feedr
) {
330 feedu
.innerHTML
= ctr
;
333 feedctr
.className
= "odd";
334 if (!feedr
.className
.match("Unread")) {
335 feedr
.className
= feedr
.className
+ "Unread";
338 feedctr
.className
= "invisible";
339 feedr
.className
= feedr
.className
.replace("Unread", "");
346 function update_label_counters(feed
) {
347 if (xmlhttp_ready(xmlhttp_rpc
)) {
348 var query
= "backend.php?op=rpc&subop=getAllCounters";
351 query
= query
+ "&aid=" + feed
;
354 xmlhttp_rpc
.open("GET", query
, true);
355 xmlhttp_rpc
.onreadystatechange
=label_counters_callback
;
356 xmlhttp_rpc
.send(null);
360 function popupHelp(tid
) {
361 var w
= window
.open("backend.php?op=help&tid=" + tid
,
363 "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
366 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
367 * * @author Sundar Dorai-Raj
368 * * Email: sdoraira@vt.edu
369 * * This program is free software; you can redistribute it and/or
370 * * modify it under the terms of the GNU General Public License
371 * * as published by the Free Software Foundation; either version 2
372 * * of the License, or (at your option) any later version,
373 * * provided that any use properly credits the author.
374 * * This program is distributed in the hope that it will be useful,
375 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
376 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
377 * * GNU General Public License for more details at http://www.gnu.org * * */
379 var numbers
=".0123456789";
380 function isNumeric(x
) {
381 // is x a String or a character?
383 // remove negative sign
385 for(j
=0;j
<x
.length
;j
++) {
386 // call isNumeric recursively for each character
387 number
=isNumeric(x
.substring(j
,j
+1));
388 if(!number
) return number
;
393 // if x is number return true
394 if(numbers
.indexOf(x
)>=0) return true;