]> git.wh0rd.org - tt-rss.git/blame - tt-rss.js
initial mockup
[tt-rss.git] / tt-rss.js
CommitLineData
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
6var 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.
12try {
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
23if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
24 xmlhttp = new XMLHttpRequest();
25}
26
27function param_escape(arg) {
28 if (typeof encodeURIComponent != 'undefined')
29 return encodeURIComponent(arg);
30 else
31 return escape(arg);
32}
33
34function param_unescape(arg) {
35 if (typeof decodeURIComponent != 'undefined')
36 return decodeURIComponent(arg);
37 else
38 return unescape(arg);
39}
40
41function notify(msg) {
42
43 var n = document.getElementById("notify");
44
45 n.innerHTML = msg;
46
47}
48
49function feedlist_callback() {
50 if (xmlhttp.readyState == 4) {
51 document.getElementById('feeds').innerHTML=xmlhttp.responseText;
52 }
53}
54
55function viewfeed_callback() {
56 if (xmlhttp.readyState == 4) {
57 document.getElementById('headlines').innerHTML=xmlhttp.responseText;
58 }
59}
60
61function view_callback() {
62 if (xmlhttp.readyState == 4) {
63 document.getElementById('content').innerHTML=xmlhttp.responseText;
64 }
65}
66
67
68function update_feed_list() {
69
70 xmlhttp.open("GET", "backend.php?op=feeds", true);
71 xmlhttp.onreadystatechange=feedlist_callback;
72 xmlhttp.send(null);
73
74}
75
76function viewfeed(feed) {
77
78 notify("view-feed: " + feed);
79
80 xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) , true);
81 xmlhttp.onreadystatechange=viewfeed_callback;
82 xmlhttp.send(null);
83
84}
85
86function view(feed, post) {
87
88 notify("view: " + feed + ", " + post);
89
90 xmlhttp.open("GET", "backend.php?op=view&feed=" + param_escape(feed) +
91 "&post=" + post, true);
92 xmlhttp.onreadystatechange=view_callback;
93 xmlhttp.send(null);
94
95}
96
97function init() {
98
99 notify("init");
100
101 update_feed_list();
102
103}