]>
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
= content
.childNodes
[i
].className
.replace("Selected", "");
137 function cleanSelected(element
) {
138 var content
= document
.getElementById(element
);
140 for (i
= 0; i
< content
.rows
.length
; i
++) {
141 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
146 function getVisibleUnreadHeadlines() {
147 var content
= document
.getElementById("headlinesList");
149 var rows
= new Array();
151 for (i
= 0; i
< content
.rows
.length
; i
++) {
152 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
153 if (row_id
.length
> 0 && content
.rows
[i
].className
.match("Unread")) {
160 function getVisibleHeadlineIds() {
162 var content
= document
.getElementById("headlinesList");
164 var rows
= new Array();
166 for (i
= 0; i
< content
.rows
.length
; i
++) {
167 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
168 if (row_id
.length
> 0) {
175 function getFirstVisibleHeadlineId() {
176 var rows
= getVisibleHeadlineIds();
180 function getLastVisibleHeadlineId() {
181 var rows
= getVisibleHeadlineIds();
182 return rows
[rows
.length
-1];
185 function markHeadline(id
) {
186 var row
= document
.getElementById("RROW-" + id
);
188 row
.className
= row
.className
+ "Selected";
192 function getFeedIds() {
193 var content
= document
.getElementById("feedsList");
195 var rows
= new Array();
197 for (i
= 0; i
< content
.rows
.length
; i
++) {
198 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
207 function setCookie(name
, value
, expires
, path
, domain
, secure
) {
208 document
.cookie
= name
+ "=" + escape(value
) +
209 ((expires
) ? "; expires=" + expires
.toGMTString() : "") +
210 ((path
) ? "; path=" + path
: "") +
211 ((domain
) ? "; domain=" + domain
: "") +
212 ((secure
) ? "; secure" : "");
215 function getCookie(name
) {
217 var dc
= document
.cookie
;
218 var prefix
= name
+ "=";
219 var begin
= dc
.indexOf("; " + prefix
);
221 begin
= dc
.indexOf(prefix
);
222 if (begin
!= 0) return null;
227 var end
= document
.cookie
.indexOf(";", begin
);
231 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
234 function disableContainerChildren(id
, disable
, doc
) {
236 if (!doc
) doc
= document
;
238 var container
= doc
.getElementById(id
);
240 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
241 var child
= container
.childNodes
[i
];
243 child
.disabled
= disable
;
246 if (child
.className
&& child
.className
.match("button")) {
247 child
.className
= "disabledButton";
250 if (child
.className
&& child
.className
.match("disabledButton")) {
251 child
.className
= "button";
258 function gotoPreferences() {
259 document
.location
.href
= "prefs.php";
262 function gotoMain() {
263 document
.location
.href
= "tt-rss.php";
266 function gotoExportOpml() {
267 document
.location
.href
= "opml.php?op=Export";