]> git.wh0rd.org - tt-rss.git/blame - viewfeed.js
update schema, more mysql work
[tt-rss.git] / viewfeed.js
CommitLineData
bb7cface
AD
1var active_feed_id = false;
2var active_post_id = false;
f0601b87
AD
3var total_unread = 0;
4
5var xmlhttp_rpc = false;
6
7/*@cc_on @*/
8/*@if (@_jscript_version >= 5)
9// JScript gives us Conditional compilation, we can cope with old IE versions.
10// and security blocked creation of the objects.
11try {
12 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
13} catch (e) {
14 try {
15 xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
16 } catch (E) {
17 xmlhttp_rpc = false;
18 }
19}
20@end @*/
21
22if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') {
23 xmlhttp_rpc = new XMLHttpRequest();
24}
25
bb7cface 26function view(id, feed_id) {
f0601b87 27
90e395dc 28// p_notify("Loading article...");
c05608c2 29
f0601b87
AD
30 enableHotkeys();
31
32 var crow = document.getElementById("RROW-" + id);
33
e828e31e
AD
34 var f_doc = parent.frames["feeds-frame"].document;
35
f0601b87 36 if (crow.className.match("Unread")) {
e828e31e
AD
37 var umark = f_doc.getElementById("FEEDU-" + feed_id);
38
f0601b87
AD
39 umark.innerHTML = umark.innerHTML - 1;
40 crow.className = crow.className.replace("Unread", "");
41
42 if (umark.innerHTML == "0") {
e828e31e 43 var feedr = f_doc.getElementById("FEEDR-" + feed_id);
f0601b87 44 feedr.className = feedr.className.replace("Unread", "");
e828e31e
AD
45
46 var feedctr = f_doc.getElementById("FEEDCTR-" + feed_id);
47
48 if (feedctr) {
0c674406 49 feedctr.className = "invisible";
e828e31e 50 }
f0601b87
AD
51 }
52
53 total_unread--;
54 }
55
e828e31e 56
f0601b87
AD
57 cleanSelected("headlinesList");
58
59 var upd_img_pic = document.getElementById("FUPDPIC-" + id);
60
61 if (upd_img_pic) {
c80e2175 62 upd_img_pic.src = "images/blank_icon.png";
f0601b87
AD
63 }
64
65 var unread_rows = getVisibleUnreadHeadlines();
66
67 if (unread_rows.length == 0) {
68 var button = document.getElementById("btnCatchupPage");
69 if (button) {
70 button.className = "disabledButton";
71 button.href = "";
72 }
73 }
74
75 active_post_id = id;
bb7cface 76 active_feed_id = feed_id;
f0601b87
AD
77
78 var content = parent.document.getElementById("content-frame");
79
80 if (content) {
81 content.src = "backend.php?op=view&addheader=true&id=" + param_escape(id);
82 markHeadline(active_post_id);
83 }
84}
85
f0601b87 86
c05608c2 87function toggleMark(id, toggle) {
f0601b87
AD
88
89 if (!xmlhttp_ready(xmlhttp_rpc)) {
90 printLockingError();
91 return;
92 }
93
94 var mark_img = document.getElementById("FMARKPIC-" + id);
95
96 var query = "backend.php?op=rpc&id=" + id + "&subop=mark";
97
98 if (toggle == true) {
99 mark_img.src = "images/mark_set.png";
100 mark_img.alt = "Reset mark";
101 mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', false)');
102 query = query + "&mark=1";
103 } else {
104 mark_img.src = "images/mark_unset.png";
105 mark_img.alt = "Set mark";
106 mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', true)');
107 query = query + "&mark=0";
108 }
109
110 xmlhttp_rpc.open("GET", query, true);
111 xmlhttp_rpc.onreadystatechange=rpc_notify_callback;
112 xmlhttp_rpc.send(null);
113
114}
115
bb7cface 116function moveToPost(mode) {
f0601b87 117
bb7cface
AD
118 var rows = getVisibleHeadlineIds();
119
120 var prev_id;
121 var next_id;
122
123 if (active_post_id == false) {
124 next_id = getFirstVisibleHeadlineId();
125 prev_id = getLastVisibleHeadlineId();
126 } else {
127 for (var i = 0; i < rows.length; i++) {
128 if (rows[i] == active_post_id) {
129 prev_id = rows[i-1];
130 next_id = rows[i+1];
131 }
132 }
133 }
134
135 if (mode == "next") {
136 if (next_id != undefined) {
137 view(next_id, active_feed_id);
138 }
139 }
140
141 if (mode == "prev") {
142 if ( prev_id != undefined) {
143 view(prev_id, active_feed_id);
144 }
145 }
146}
147
148function localHotkeyHandler(keycode) {
149
150 if (keycode == 78) {
151 return moveToPost('next');
152 }
153
154 if (keycode == 80) {
155 return moveToPost('prev');
156 }
157
158// FIXME
159// if (keycode == 85) {
160// return viewfeed(active_feed_id, active_offset, "ForceUpdate");
161// }
162
163// alert("KC: " + keycode);
164
165}