]>
Commit | Line | Data |
---|---|---|
bb7cface AD |
1 | var active_feed_id = false; |
2 | var active_post_id = false; | |
f0601b87 AD |
3 | var total_unread = 0; |
4 | ||
5 | var 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. | |
11 | try { | |
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 | ||
22 | if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') { | |
23 | xmlhttp_rpc = new XMLHttpRequest(); | |
24 | } | |
25 | ||
bb7cface | 26 | function view(id, feed_id) { |
f0601b87 | 27 | |
c05608c2 AD |
28 | // p_notify("Loading article..."); |
29 | ||
f0601b87 AD |
30 | enableHotkeys(); |
31 | ||
32 | var crow = document.getElementById("RROW-" + id); | |
33 | ||
34 | if (crow.className.match("Unread")) { | |
1a66d16e | 35 | var umark = parent.frames["feeds-frame"].document.getElementById("FEEDU-" + feed_id); |
f0601b87 AD |
36 | umark.innerHTML = umark.innerHTML - 1; |
37 | crow.className = crow.className.replace("Unread", ""); | |
38 | ||
39 | if (umark.innerHTML == "0") { | |
1a66d16e | 40 | var feedr = parent.frames["feeds-frame"].document.getElementById("FEEDR-" + feed_id); |
f0601b87 AD |
41 | feedr.className = feedr.className.replace("Unread", ""); |
42 | } | |
43 | ||
44 | total_unread--; | |
45 | } | |
46 | ||
47 | cleanSelected("headlinesList"); | |
48 | ||
49 | var upd_img_pic = document.getElementById("FUPDPIC-" + id); | |
50 | ||
51 | if (upd_img_pic) { | |
52 | upd_img_pic.innerHTML = ""; | |
53 | } | |
54 | ||
55 | var unread_rows = getVisibleUnreadHeadlines(); | |
56 | ||
57 | if (unread_rows.length == 0) { | |
58 | var button = document.getElementById("btnCatchupPage"); | |
59 | if (button) { | |
60 | button.className = "disabledButton"; | |
61 | button.href = ""; | |
62 | } | |
63 | } | |
64 | ||
65 | active_post_id = id; | |
bb7cface | 66 | active_feed_id = feed_id; |
f0601b87 AD |
67 | |
68 | var content = parent.document.getElementById("content-frame"); | |
69 | ||
70 | if (content) { | |
71 | content.src = "backend.php?op=view&addheader=true&id=" + param_escape(id); | |
72 | markHeadline(active_post_id); | |
73 | } | |
74 | } | |
75 | ||
f0601b87 | 76 | |
c05608c2 | 77 | function toggleMark(id, toggle) { |
f0601b87 AD |
78 | |
79 | if (!xmlhttp_ready(xmlhttp_rpc)) { | |
80 | printLockingError(); | |
81 | return; | |
82 | } | |
83 | ||
84 | var mark_img = document.getElementById("FMARKPIC-" + id); | |
85 | ||
86 | var query = "backend.php?op=rpc&id=" + id + "&subop=mark"; | |
87 | ||
88 | if (toggle == true) { | |
89 | mark_img.src = "images/mark_set.png"; | |
90 | mark_img.alt = "Reset mark"; | |
91 | mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', false)'); | |
92 | query = query + "&mark=1"; | |
93 | } else { | |
94 | mark_img.src = "images/mark_unset.png"; | |
95 | mark_img.alt = "Set mark"; | |
96 | mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', true)'); | |
97 | query = query + "&mark=0"; | |
98 | } | |
99 | ||
100 | xmlhttp_rpc.open("GET", query, true); | |
101 | xmlhttp_rpc.onreadystatechange=rpc_notify_callback; | |
102 | xmlhttp_rpc.send(null); | |
103 | ||
104 | } | |
105 | ||
bb7cface | 106 | function moveToPost(mode) { |
f0601b87 | 107 | |
bb7cface AD |
108 | var rows = getVisibleHeadlineIds(); |
109 | ||
110 | var prev_id; | |
111 | var next_id; | |
112 | ||
113 | if (active_post_id == false) { | |
114 | next_id = getFirstVisibleHeadlineId(); | |
115 | prev_id = getLastVisibleHeadlineId(); | |
116 | } else { | |
117 | for (var i = 0; i < rows.length; i++) { | |
118 | if (rows[i] == active_post_id) { | |
119 | prev_id = rows[i-1]; | |
120 | next_id = rows[i+1]; | |
121 | } | |
122 | } | |
123 | } | |
124 | ||
125 | if (mode == "next") { | |
126 | if (next_id != undefined) { | |
127 | view(next_id, active_feed_id); | |
128 | } | |
129 | } | |
130 | ||
131 | if (mode == "prev") { | |
132 | if ( prev_id != undefined) { | |
133 | view(prev_id, active_feed_id); | |
134 | } | |
135 | } | |
136 | } | |
137 | ||
138 | function localHotkeyHandler(keycode) { | |
139 | ||
140 | if (keycode == 78) { | |
141 | return moveToPost('next'); | |
142 | } | |
143 | ||
144 | if (keycode == 80) { | |
145 | return moveToPost('prev'); | |
146 | } | |
147 | ||
148 | // FIXME | |
149 | // if (keycode == 85) { | |
150 | // return viewfeed(active_feed_id, active_offset, "ForceUpdate"); | |
151 | // } | |
152 | ||
153 | // alert("KC: " + keycode); | |
154 | ||
155 | } |