]>
Commit | Line | Data |
---|---|---|
1cd17194 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 | ||
6 | var 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. | |
12 | try { | |
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 | ||
23 | if (!xmlhttp && typeof XMLHttpRequest!='undefined') { | |
24 | xmlhttp = new XMLHttpRequest(); | |
25 | } | |
26 | ||
27 | function param_escape(arg) { | |
28 | if (typeof encodeURIComponent != 'undefined') | |
29 | return encodeURIComponent(arg); | |
30 | else | |
31 | return escape(arg); | |
32 | } | |
33 | ||
34 | function param_unescape(arg) { | |
35 | if (typeof decodeURIComponent != 'undefined') | |
36 | return decodeURIComponent(arg); | |
37 | else | |
38 | return unescape(arg); | |
39 | } | |
40 | ||
41 | function notify(msg) { | |
42 | ||
43 | var n = document.getElementById("notify"); | |
44 | ||
45 | n.innerHTML = msg; | |
46 | ||
47 | } | |
48 | ||
49 | function feedlist_callback() { | |
d76a3b03 | 50 | var container = document.getElementById('feeds'); |
1cd17194 | 51 | if (xmlhttp.readyState == 4) { |
d76a3b03 | 52 | container.innerHTML=xmlhttp.responseText; |
1cd17194 AD |
53 | } |
54 | } | |
55 | ||
56 | function viewfeed_callback() { | |
d76a3b03 | 57 | var container = document.getElementById('headlines'); |
1cd17194 | 58 | if (xmlhttp.readyState == 4) { |
d76a3b03 | 59 | container.innerHTML = xmlhttp.responseText; |
a1a8a2be AD |
60 | |
61 | var factive = document.getElementById("FACTIVE"); | |
62 | var funread = document.getElementById("FUNREAD"); | |
63 | var ftotal = document.getElementById("FTOTAL"); | |
64 | ||
65 | if (ftotal && factive && funread) { | |
66 | var feed_id = factive.innerHTML; | |
67 | ||
68 | var feedr = document.getElementById("FEEDR-" + feed_id); | |
69 | var feedt = document.getElementById("FEEDT-" + feed_id); | |
70 | var feedu = document.getElementById("FEEDU-" + feed_id); | |
71 | ||
72 | feedt.innerHTML = ftotal.innerHTML; | |
73 | feedu.innerHTML = funread.innerHTML; | |
74 | ||
75 | if (feedu.innerHTML > 0 && !feedr.className.match("Unread")) { | |
76 | feedr.className = feedr.className + "Unread"; | |
77 | } else if (feedu.innerHTML <= 0) { | |
78 | feedr.className = feedr.className.replace("Unread", ""); | |
79 | } | |
80 | ||
81 | } | |
1cd17194 AD |
82 | } |
83 | } | |
84 | ||
85 | function view_callback() { | |
d76a3b03 | 86 | var container = document.getElementById('content'); |
1cd17194 | 87 | if (xmlhttp.readyState == 4) { |
d76a3b03 | 88 | container.innerHTML=xmlhttp.responseText; |
1cd17194 AD |
89 | } |
90 | } | |
91 | ||
92 | ||
93 | function update_feed_list() { | |
94 | ||
82baad4a AD |
95 | document.getElementById("feeds").innerHTML = "Updating feeds, please wait..."; |
96 | ||
1cd17194 AD |
97 | xmlhttp.open("GET", "backend.php?op=feeds", true); |
98 | xmlhttp.onreadystatechange=feedlist_callback; | |
99 | xmlhttp.send(null); | |
100 | ||
101 | } | |
102 | ||
a1a8a2be | 103 | function viewfeed(feed, skip, ext) { |
1cd17194 AD |
104 | |
105 | notify("view-feed: " + feed); | |
106 | ||
d76a3b03 | 107 | document.getElementById('headlines').innerHTML='Loading headlines, please wait...'; |
a1a8a2be | 108 | document.getElementById('content').innerHTML=' '; |
d76a3b03 AD |
109 | |
110 | xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) + | |
a1a8a2be | 111 | "&skip=" + param_escape(skip) + "&ext=" + param_escape(ext) , true); |
1cd17194 AD |
112 | xmlhttp.onreadystatechange=viewfeed_callback; |
113 | xmlhttp.send(null); | |
114 | ||
115 | } | |
116 | ||
a1a8a2be | 117 | function view(id,feed_id) { |
d76a3b03 AD |
118 | |
119 | var crow = document.getElementById("RROW-" + id); | |
120 | ||
a1a8a2be AD |
121 | if (crow.className.match("Unread")) { |
122 | var umark = document.getElementById("FEEDU-" + feed_id); | |
123 | umark.innerHTML = umark.innerHTML - 1; | |
d76a3b03 | 124 | crow.className = crow.className.replace("Unread", ""); |
d76a3b03 | 125 | |
a1a8a2be AD |
126 | if (umark.innerHTML == "0") { |
127 | var feedr = document.getElementById("FEEDR-" + feed_id); | |
128 | feedr.className = feedr.className.replace("Unread", ""); | |
129 | } | |
130 | } | |
1cd17194 | 131 | |
d76a3b03 | 132 | document.getElementById('content').innerHTML='Loading, please wait...'; |
1cd17194 | 133 | |
d76a3b03 | 134 | xmlhttp.open("GET", "backend.php?op=view&id=" + param_escape(id), true); |
1cd17194 AD |
135 | xmlhttp.onreadystatechange=view_callback; |
136 | xmlhttp.send(null); | |
137 | ||
138 | } | |
139 | ||
140 | function init() { | |
141 | ||
142 | notify("init"); | |
143 | ||
144 | update_feed_list(); | |
145 | ||
146 | } |