]>
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 AD |
52 | container.innerHTML=xmlhttp.responseText; |
53 | } else { | |
1cd17194 AD |
54 | } |
55 | } | |
56 | ||
57 | function viewfeed_callback() { | |
d76a3b03 | 58 | var container = document.getElementById('headlines'); |
1cd17194 | 59 | if (xmlhttp.readyState == 4) { |
d76a3b03 AD |
60 | container.innerHTML = xmlhttp.responseText; |
61 | } else { | |
1cd17194 AD |
62 | } |
63 | } | |
64 | ||
65 | function view_callback() { | |
d76a3b03 | 66 | var container = document.getElementById('content'); |
1cd17194 | 67 | if (xmlhttp.readyState == 4) { |
d76a3b03 AD |
68 | container.innerHTML=xmlhttp.responseText; |
69 | } else { | |
1cd17194 AD |
70 | } |
71 | } | |
72 | ||
73 | ||
74 | function update_feed_list() { | |
75 | ||
76 | xmlhttp.open("GET", "backend.php?op=feeds", true); | |
77 | xmlhttp.onreadystatechange=feedlist_callback; | |
78 | xmlhttp.send(null); | |
79 | ||
80 | } | |
81 | ||
d76a3b03 | 82 | function viewfeed(feed, skip) { |
1cd17194 AD |
83 | |
84 | notify("view-feed: " + feed); | |
85 | ||
d76a3b03 AD |
86 | document.getElementById('headlines').innerHTML='Loading headlines, please wait...'; |
87 | ||
88 | xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) + | |
89 | "&skip=" + skip, true); | |
1cd17194 AD |
90 | xmlhttp.onreadystatechange=viewfeed_callback; |
91 | xmlhttp.send(null); | |
92 | ||
93 | } | |
94 | ||
d76a3b03 AD |
95 | function view(id) { |
96 | ||
97 | var crow = document.getElementById("RROW-" + id); | |
98 | ||
99 | if (crow) { | |
100 | crow.className = crow.className.replace("Unread", ""); | |
101 | } | |
102 | ||
103 | notify(crow.className); | |
1cd17194 | 104 | |
d76a3b03 | 105 | document.getElementById('content').innerHTML='Loading, please wait...'; |
1cd17194 | 106 | |
d76a3b03 | 107 | xmlhttp.open("GET", "backend.php?op=view&id=" + param_escape(id), true); |
1cd17194 AD |
108 | xmlhttp.onreadystatechange=view_callback; |
109 | xmlhttp.send(null); | |
110 | ||
111 | } | |
112 | ||
113 | function init() { | |
114 | ||
115 | notify("init"); | |
116 | ||
117 | update_feed_list(); | |
118 | ||
119 | } |