]>
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;
62 if (msg
.length
== 0) {
63 n
.style
.display
= "none";
65 n
.style
.display
= "block";
70 function notify(msg
) {
72 var n
= document
.getElementById("notify");
73 var nb
= document
.getElementById("notify_body");
75 if (!n
|| !nb
) return;
79 if (msg
.length
== 0) {
80 n
.style
.display
= "none";
82 n
.style
.display
= "block";
87 function printLockingError() {
88 notify("Please wait until operation finishes");}
92 function hotkey_handler(e
) {
96 if (!hotkeys_enabled
) return;
99 keycode
= window
.event
.keyCode
;
104 if (keycode
== 13 || keycode
== 27) {
107 seq
= seq
+ "" + keycode
;
110 var piggie
= document
.getElementById("piggie");
114 if (seq
.match("807371717369")) {
115 localPiggieFunction(true);
117 localPiggieFunction(false);
121 if (typeof localHotkeyHandler
!= 'undefined') {
122 localHotkeyHandler(keycode
);
127 function cleanSelectedList(element
) {
128 var content
= document
.getElementById(element
);
130 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
131 content
.childNodes
[i
].className
=
132 content
.childNodes
[i
].className
.replace("Selected", "");
138 function cleanSelected(element
) {
139 var content
= document
.getElementById(element
);
141 for (i
= 0; i
< content
.rows
.length
; i
++) {
142 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
147 function getVisibleUnreadHeadlines() {
148 var content
= document
.getElementById("headlinesList");
150 var rows
= new Array();
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")) {
161 function getVisibleHeadlineIds() {
163 var content
= document
.getElementById("headlinesList");
165 var rows
= new Array();
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) {
176 function getFirstVisibleHeadlineId() {
177 var rows
= getVisibleHeadlineIds();
181 function getLastVisibleHeadlineId() {
182 var rows
= getVisibleHeadlineIds();
183 return rows
[rows
.length
-1];
186 function markHeadline(id
) {
187 var row
= document
.getElementById("RROW-" + id
);
189 row
.className
= row
.className
+ "Selected";
193 function getFeedIds() {
194 var content
= document
.getElementById("feedsList");
196 var rows
= new Array();
198 for (i
= 0; i
< content
.rows
.length
; i
++) {
199 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
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" : "");
216 function getCookie(name
) {
218 var dc
= document
.cookie
;
219 var prefix
= name
+ "=";
220 var begin
= dc
.indexOf("; " + prefix
);
222 begin
= dc
.indexOf(prefix
);
223 if (begin
!= 0) return null;
228 var end
= document
.cookie
.indexOf(";", begin
);
232 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
235 function disableContainerChildren(id
, disable
, doc
) {
237 if (!doc
) doc
= document
;
239 var container
= doc
.getElementById(id
);
241 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
242 var child
= container
.childNodes
[i
];
245 child
.disabled
= disable
;
251 if (child
.className
&& child
.className
.match("button")) {
252 child
.className
= "disabledButton";
255 if (child
.className
&& child
.className
.match("disabledButton")) {
256 child
.className
= "button";
263 function gotoPreferences() {
264 document
.location
.href
= "prefs.php";
267 function gotoMain() {
268 document
.location
.href
= "tt-rss.php";
271 function gotoExportOpml() {
272 document
.location
.href
= "opml.php?op=Export";
275 function getActiveFeedId() {
276 return getCookie("ttrss_vf_actfeed");
279 function setActiveFeedId(id
) {
280 return setCookie("ttrss_vf_actfeed", id
);
283 var xmlhttp_rpc
= false;
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.
290 xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP");
293 xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
300 if (!xmlhttp_rpc
&& typeof XMLHttpRequest
!='undefined') {
301 xmlhttp_rpc
= new XMLHttpRequest();
304 function label_counters_callback() {
305 if (xmlhttp_rpc
.readyState
== 4) {
306 var reply
= xmlhttp_rpc
.responseXML
.firstChild
;
308 var f_document
= parent
.frames
["feeds-frame"].document
;
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");
314 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
315 var feedu
= f_document
.getElementById("FEEDU-" + id
);
316 var feedr
= f_document
.getElementById("FEEDR-" + id
);
318 if (feedctr
&& feedu
&& feedr
) {
320 feedu
.innerHTML
= ctr
;
323 feedctr
.className
= "odd";
324 if (!feedr
.className
.match("Unread")) {
325 feedr
.className
= feedr
.className
+ "Unread";
328 feedctr
.className
= "invisible";
329 feedr
.className
= feedr
.className
.replace("Unread", "");
336 function update_label_counters(feed
) {
337 if (xmlhttp_ready(xmlhttp_rpc
)) {
338 var query
= "backend.php?op=rpc&subop=getAllCounters";
341 query
= query
+ "&aid=" + feed
;
344 xmlhttp_rpc
.open("GET", query
, true);
345 xmlhttp_rpc
.onreadystatechange
=label_counters_callback
;
346 xmlhttp_rpc
.send(null);