]>
Commit | Line | Data |
---|---|---|
71af6d36 | 1 | var SCHEMA_VERSION = 10; |
b871dd06 | 2 | |
25d99353 AD |
3 | var offline_mode = false; |
4 | var store = false; | |
5 | var localServer = false; | |
6 | var db = false; | |
79e565a9 AD |
7 | var articles_synced = 0; |
8 | var sync_in_progress = false; | |
206d4967 | 9 | var sync_timer = false; |
25d99353 | 10 | |
4681834e AD |
11 | function view_offline(id, feed_id) { |
12 | try { | |
13 | ||
14 | enableHotkeys(); | |
15 | showArticleInHeadlines(id); | |
16 | ||
1b27261c AD |
17 | db.execute("UPDATE articles SET unread = 0 WHERE id = ?", [id]); |
18 | ||
19 | var rs = db.execute("SELECT * FROM articles WHERE id = ?", [id]); | |
20 | ||
21 | if (rs.isValidRow()) { | |
22 | ||
23 | var tmp = "<div class=\"postReply\">"; | |
24 | ||
25 | tmp += "<div class=\"postHeader\" onmouseover=\"enable_resize(true)\" "+ | |
26 | "onmouseout=\"enable_resize(false)\">"; | |
27 | ||
28 | tmp += "<div class=\"postDate\">"+rs.fieldByName("updated")+"</div>"; | |
29 | ||
30 | if (rs.fieldByName("link") != "") { | |
31 | tmp += "<div clear='both'><a target=\"_blank\" "+ | |
32 | "href=\"" + rs.fieldByName("link") + "\">" + | |
33 | rs.fieldByName("title") + "</a></div>"; | |
34 | } else { | |
35 | tmp += "<div clear='both'>" + rs.fieldByName("title") + "</div>"; | |
36 | } | |
4681834e | 37 | |
3ab18266 | 38 | /* tmp += "<div style='float : right'> "+ |
1b27261c AD |
39 | "<img src='images/tag.png' class='tagsPic' alt='Tags' title='Tags'>"; |
40 | tmp += rs.fieldByName("tags"); | |
3ab18266 | 41 | tmp += "</div>"; */ |
1b27261c | 42 | |
424fc145 | 43 | /* tmp += "<div clear='both'>"+ |
12aa4007 AD |
44 | "<a target=\"_blank\" "+ |
45 | "href=\"" + rs.fieldByName("comments") + "\">" + | |
424fc145 | 46 | __("comments") + "</a></div>"; */ |
1b27261c AD |
47 | |
48 | tmp += "</div>"; | |
49 | ||
50 | tmp += "<div class=\"postContent\">" | |
51 | tmp += rs.fieldByName("content"); | |
52 | tmp += "</div>"; | |
53 | ||
54 | tmp += "</div>"; | |
55 | ||
56 | render_article(tmp); | |
57 | update_local_feedlist_counters(); | |
58 | } | |
4681834e | 59 | |
03c96380 AD |
60 | rs.close(); |
61 | ||
4681834e AD |
62 | return false; |
63 | ||
64 | } catch (e) { | |
65 | exception_error("view_offline", e); | |
66 | } | |
67 | } | |
68 | ||
69 | function viewfeed_offline(feed_id, subop, is_cat, subop_param, skip_history, offset) { | |
70 | try { | |
71 | notify(''); | |
72 | ||
73 | if (!offset) offset = 0; | |
74 | ||
0e923da4 AD |
75 | if (offset > 0) { |
76 | _feed_cur_page = parseInt(offset); | |
77 | if (_infscroll_request_sent) { | |
78 | return; | |
79 | } | |
80 | } else { | |
81 | _feed_cur_page = 0; | |
82 | _infscroll_disable = 0; | |
83 | } | |
84 | ||
85 | if (getActiveFeedId() != feed_id) { | |
86 | _feed_cur_page = 0; | |
87 | active_post_id = 0; | |
88 | _infscroll_disable = 0; | |
89 | } | |
90 | ||
4681834e AD |
91 | loading_set_progress(100); |
92 | ||
93 | clean_feed_selections(); | |
94 | ||
95 | setActiveFeedId(feed_id, is_cat); | |
96 | ||
97 | if (!is_cat) { | |
acac8448 | 98 | var feedr = $("FEEDR-" + feed_id); |
4681834e AD |
99 | if (feedr && !feedr.className.match("Selected")) { |
100 | feedr.className = feedr.className + "Selected"; | |
101 | } | |
102 | } else { | |
acac8448 | 103 | var feedr = $("FCAT-" + feed_id); |
4681834e AD |
104 | if (feedr && !feedr.className.match("Selected")) { |
105 | feedr.className = feedr.className + "Selected"; | |
106 | } | |
107 | } | |
108 | ||
67625745 AD |
109 | if (subop == "MarkAllRead") { |
110 | catchup_local_feed(feed_id, is_cat); | |
111 | } | |
112 | ||
4681834e AD |
113 | disableContainerChildren("headlinesToolbar", false); |
114 | Form.enable("main_toolbar_form"); | |
115 | ||
acac8448 | 116 | var f = $("headlines-frame"); |
4681834e AD |
117 | try { |
118 | if (reply.offset == 0) { | |
119 | debug("resetting headlines scrollTop"); | |
120 | f.scrollTop = 0; | |
121 | } | |
122 | } catch (e) { }; | |
123 | ||
124 | ||
4681834e | 125 | var tmp = ""; |
046a2e3c | 126 | var feed_title = ""; |
4681834e | 127 | |
046a2e3c AD |
128 | if (is_cat) { |
129 | feed_title = get_local_category_title(feed_id); | |
130 | } else { | |
131 | feed_title = get_local_feed_title(feed_id); | |
132 | } | |
4681834e | 133 | |
88a66534 | 134 | if (feed_title) { |
4681834e AD |
135 | |
136 | if (offset == 0) { | |
137 | tmp += "<div id=\"headlinesContainer\">"; | |
138 | ||
139 | tmp += "<div class=\"headlinesSubToolbar\">"; | |
140 | tmp += "<div id=\"subtoolbar_ftitle\">"; | |
141 | tmp += feed_title; | |
142 | tmp += "</div>"; | |
143 | ||
779ba075 AD |
144 | var sel_all_link; |
145 | var sel_unread_link; | |
146 | var sel_none_link; | |
147 | var sel_inv_link; | |
148 | ||
acac8448 | 149 | if ($("content-frame")) { |
779ba075 AD |
150 | sel_all_link = "javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, '', true)"; |
151 | sel_unread_link = "javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true)"; | |
152 | sel_none_link = "javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false)"; | |
153 | sel_inv_link = "javascript:invertHeadlineSelection()"; | |
154 | } else { | |
155 | sel_all_link = "javascript:cdmSelectArticles('all')"; | |
156 | sel_unread_link = "javascript:cdmSelectArticles('unread')"; | |
157 | sel_none_link = "javascript:cdmSelectArticles('none')"; | |
158 | sel_inv_link = "javascript:invertHeadlineSelection()"; | |
159 | } | |
4681834e AD |
160 | |
161 | tmp += __('Select:')+ | |
162 | " <a href=\""+sel_all_link+"\">"+__('All')+"</a>, "+ | |
163 | "<a href=\""+sel_unread_link+"\">"+__('Unread')+"</a>, "+ | |
164 | "<a href=\""+sel_inv_link+"\">"+__('Invert')+"</a>, "+ | |
165 | "<a href=\""+sel_none_link+"\">"+__('None')+"</a>"; | |
166 | ||
167 | tmp += " "; | |
168 | ||
169 | tmp += "</div>"; | |
170 | ||
171 | tmp += "<div id=\"headlinesInnerContainer\" onscroll=\"headlines_scroll_handler()\">"; | |
acac8448 | 172 | if ($("content-frame")) { |
779ba075 AD |
173 | tmp += "<table class=\"headlinesList\" id=\"headlinesList\" cellspacing=\"0\">"; |
174 | } | |
4681834e AD |
175 | |
176 | } | |
177 | ||
4681834e AD |
178 | var limit = 30; |
179 | ||
180 | var toolbar_form = document.forms["main_toolbar_form"]; | |
181 | ||
182 | var limit = toolbar_form.limit[toolbar_form.limit.selectedIndex].value; | |
183 | var view_mode = toolbar_form.view_mode[toolbar_form.view_mode.selectedIndex].value; | |
184 | ||
185 | var limit_qpart = ""; | |
186 | var strategy_qpart = ""; | |
187 | var mode_qpart = ""; | |
e491d06d | 188 | var offset_qpart = ""; |
4681834e AD |
189 | |
190 | if (limit != 0) { | |
191 | limit_qpart = "LIMIT " + limit; | |
192 | } | |
193 | ||
194 | if (view_mode == "all_articles") { | |
195 | mode_qpart = "1"; | |
196 | } else if (view_mode == "adaptive") { | |
046a2e3c AD |
197 | if (is_cat && get_local_category_unread(feed_id) || |
198 | get_local_feed_unread(feed_id) > 0) { | |
199 | mode_qpart = "unread = 1"; | |
4681834e AD |
200 | } else { |
201 | mode_qpart = "1"; | |
202 | } | |
046a2e3c | 203 | |
4681834e AD |
204 | } else if (view_mode == "marked") { |
205 | mode_qpart = "marked = 1"; | |
206 | } else if (view_mode == "unread") { | |
207 | mode_qpart = "unread = 1"; | |
208 | } else { | |
209 | mode_qpart = "1"; | |
210 | } | |
211 | ||
79645416 AD |
212 | var ext_tables_qpart = ""; |
213 | ||
046a2e3c AD |
214 | if (is_cat) { |
215 | if (feed_id >= 0) { | |
216 | strategy_qpart = "cat_id = " + feed_id; | |
217 | } else if (feed_id == -2) { | |
218 | strategy_qpart = "article_labels.id = articles.id"; | |
219 | ext_tables_qpart = ",article_labels"; | |
220 | } | |
221 | } else if (feed_id > 0) { | |
4681834e AD |
222 | strategy_qpart = "feed_id = " + feed_id; |
223 | } else if (feed_id == -1) { | |
224 | strategy_qpart = "marked = 1"; | |
225 | } else if (feed_id == -4) { | |
226 | strategy_qpart = "1"; | |
88a66534 AD |
227 | } else if (feed_id < -10) { |
228 | var label_id = -11 - feed_id; | |
79645416 AD |
229 | strategy_qpart = "article_labels.id = articles.id AND label_id = " + label_id; |
230 | ext_tables_qpart = ",article_labels"; | |
e491d06d AD |
231 | } |
232 | ||
233 | if (offset > 0) { | |
234 | offset_qpart = "OFFSET " + (offset*30); | |
235 | } else { | |
236 | offset_qpart = ""; | |
237 | } | |
4681834e | 238 | |
851ce414 | 239 | var query = "SELECT *,feeds.title AS feed_title "+ |
046a2e3c | 240 | "FROM articles,feeds,categories"+ext_tables_qpart+" "+ |
79645416 | 241 | "WHERE " + |
046a2e3c | 242 | "cat_id = categories.id AND " + |
851ce414 | 243 | "feed_id = feeds.id AND " + |
4681834e AD |
244 | strategy_qpart + |
245 | " AND " + mode_qpart + | |
246 | " ORDER BY updated DESC "+ | |
e491d06d AD |
247 | limit_qpart + " " + |
248 | offset_qpart; | |
4681834e AD |
249 | |
250 | var rs = db.execute(query); | |
251 | ||
e491d06d | 252 | var line_num = offset*30; |
4681834e | 253 | |
851ce414 AD |
254 | var real_feed_id = feed_id; |
255 | ||
4681834e AD |
256 | while (rs.isValidRow()) { |
257 | ||
258 | var id = rs.fieldByName("id"); | |
259 | var feed_id = rs.fieldByName("feed_id"); | |
260 | ||
851ce414 AD |
261 | var entry_feed_title = false; |
262 | ||
046a2e3c | 263 | if (real_feed_id < 0 || is_cat) { |
851ce414 AD |
264 | entry_feed_title = rs.fieldByName("feed_title"); |
265 | } | |
266 | ||
4681834e AD |
267 | var marked_pic; |
268 | ||
269 | var row_class = (line_num % 2) ? "even" : "odd"; | |
270 | ||
271 | if (rs.fieldByName("unread") == "1") { | |
272 | row_class += "Unread"; | |
273 | } | |
6da82466 AD |
274 | |
275 | var labels = get_local_article_labels(id); | |
276 | ||
6da82466 AD |
277 | var labels_str = "<span id=\"HLLCTR-"+id+"\">"; |
278 | labels_str += format_article_labels(labels, id); | |
279 | labels_str += "</span>"; | |
280 | ||
4681834e AD |
281 | if (rs.fieldByName("marked") == "1") { |
282 | marked_pic = "<img id=\"FMPIC-"+id+"\" "+ | |
283 | "src=\"images/mark_set.png\" class=\"markedPic\""+ | |
284 | "alt=\"Unstar article\" onclick='javascript:tMark("+id+")'>"; | |
285 | } else { | |
286 | marked_pic = "<img id=\"FMPIC-"+id+"\" "+ | |
287 | "src=\"images/mark_unset.png\" class=\"markedPic\""+ | |
288 | "alt=\"Star article\" onclick='javascript:tMark("+id+")'>"; | |
289 | } | |
290 | ||
291 | var mouseover_attrs = "onmouseover='postMouseIn($id)' "+ | |
292 | "onmouseout='postMouseOut($id)'"; | |
779ba075 AD |
293 | |
294 | var content_preview = truncate_string(strip_tags(rs.fieldByName("content")), | |
295 | 100); | |
4681834e | 296 | |
acac8448 | 297 | if ($("content-frame")) { |
4681834e | 298 | |
779ba075 AD |
299 | tmp += "<tr class='"+row_class+"' id='RROW-"+id+"' "+mouseover_attrs+">"; |
300 | ||
301 | tmp += "<td class='hlUpdPic'> </td>"; | |
4681834e | 302 | |
779ba075 AD |
303 | tmp += "<td class='hlSelectRow'>"+ |
304 | "<input type=\"checkbox\" onclick=\"tSR(this)\" id=\"RCHK-"+id+"\"></td>"; | |
305 | ||
306 | tmp += "<td class='hlMarkedPic'>"+marked_pic+"</td>"; | |
307 | ||
308 | tmp += "<td onclick='view("+id+","+feed_id+")' "+ | |
309 | "class='hlContent' valign='middle'>"; | |
310 | ||
851ce414 | 311 | tmp += "<a target=\"_blank\" id=\"RTITLE-"+id+"\" href=\"" + |
779ba075 AD |
312 | rs.fieldByName("link") + "\"" + |
313 | "onclick=\"return view("+id+","+feed_id+");\">"+ | |
314 | rs.fieldByName("title"); | |
4681834e | 315 | |
779ba075 AD |
316 | tmp += "<span class=\"contentPreview\"> - "+content_preview+"</span>"; |
317 | ||
318 | tmp += "</a>"; | |
851ce414 | 319 | |
6da82466 AD |
320 | tmp += labels_str; |
321 | ||
851ce414 AD |
322 | if (entry_feed_title) { |
323 | tmp += " <span class=\"hlFeed\">"+ | |
324 | "(<a href='javascript:viewfeed("+feed_id+ | |
325 | ")'>"+entry_feed_title+"</a>)</span>"; | |
326 | } | |
327 | ||
779ba075 | 328 | tmp += "</td>"; |
d07f08e8 | 329 | |
779ba075 | 330 | tmp += "<td class=\"hlUpdated\" onclick='view("+id+","+feed_id+")'>"+ |
d07f08e8 AD |
331 | "<nobr>"+rs.fieldByName("updated").substring(0,16)+ |
332 | "</nobr></td>"; | |
779ba075 AD |
333 | |
334 | tmp += "</tr>"; | |
335 | } else { | |
4681834e | 336 | |
779ba075 AD |
337 | var add_class = ""; |
338 | ||
339 | if (rs.fieldByName("unread") == "1") { | |
340 | add_class = "Unread"; | |
341 | } | |
342 | ||
343 | tmp += "<div class=\"cdmArticle"+add_class+"\" id=\"RROW-"+id+"\" "+ | |
344 | mouseover_attrs+"'>"; | |
345 | ||
d07f08e8 AD |
346 | feed_icon_img = "<img class=\"tinyFeedIcon\" src=\""+ |
347 | getInitParam("icons_url")+"/"+feed_id+".ico\" alt=\"\">"; | |
348 | cdm_feed_icon = "<span style=\"cursor : pointer\" "+ | |
349 | "onclick=\"viewfeed("+feed_id+")\">"+feed_icon_img+"</span>"; | |
350 | ||
779ba075 AD |
351 | tmp += "<div class=\"cdmHeader\">"; |
352 | tmp += "<div class=\"articleUpdated\">"+ | |
d07f08e8 AD |
353 | rs.fieldByName("updated").substring(0,16)+ |
354 | " "+cdm_feed_icon+"</div>"; | |
779ba075 AD |
355 | |
356 | tmp += "<span id=\"RTITLE-"+id+"\" class=\"titleWrap\">"+ | |
357 | "<a class=\"title\" onclick=\"javascript:toggleUnread("+id+", 0)\""+ | |
358 | "target=\"_blank\" href=\""+rs.fieldByName("link")+ | |
359 | "\">"+rs.fieldByName("title")+"</a>"; | |
851ce414 | 360 | |
6da82466 AD |
361 | tmp += labels_str; |
362 | ||
851ce414 AD |
363 | if (entry_feed_title) { |
364 | tmp += " (<a href='javascript:viewfeed("+feed_id+ | |
365 | ")'>"+entry_feed_title+"</a>)"; | |
366 | } | |
367 | ||
779ba075 AD |
368 | tmp += "</span></div>"; |
369 | ||
370 | tmp += "<div class=\"cdmContent\" onclick=\"cdmClicked("+id+")\""+ | |
371 | "id=\"CICD-"+id+"\">"; | |
372 | tmp += rs.fieldByName("content"); | |
373 | tmp += "<br clear='both'>" | |
374 | tmp += "</div>"; | |
375 | ||
376 | tmp += "<div class=\"cdmFooter\"><span class='s0'>"; | |
377 | tmp += __("Select:")+ | |
378 | " <input type=\"checkbox\" "+ | |
379 | "onclick=\"toggleSelectRowById(this, 'RROW-"+id+"')\" "+ | |
380 | "class=\"feedCheckBox\" id=\"RCHK-"+id+"\">"; | |
381 | ||
382 | tmp += "</span><span class='s1'>"+marked_pic+"</span> "; | |
383 | ||
3ab18266 | 384 | /* tmp += "<span class='s1'>"+ |
779ba075 AD |
385 | "<img class='tagsPic' src='images/tag.png' alt='Tags' title='Tags'>"+ |
386 | "<span id=\"ATSTR-"+id+"\">"+rs.fieldByName("tags")+"</span>"+ | |
3ab18266 | 387 | "</span>"; */ |
779ba075 AD |
388 | |
389 | tmp += "<span class='s2'>Toggle: <a class=\"cdmToggleLink\""+ | |
390 | "href=\"javascript:toggleUnread("+id+")\">"+ | |
391 | "Unread</a></span>"; | |
392 | tmp += "</div>"; | |
393 | ||
394 | tmp += "</div>"; | |
395 | } | |
4681834e AD |
396 | |
397 | rs.next(); | |
398 | line_num++; | |
399 | } | |
03c96380 | 400 | |
0e923da4 AD |
401 | if (line_num - offset*30 < 30) { |
402 | _infscroll_disable = 1; | |
403 | } | |
404 | ||
03c96380 | 405 | rs.close(); |
4681834e AD |
406 | |
407 | if (offset == 0) { | |
408 | tmp += "</table>"; | |
76d20f5f AD |
409 | |
410 | if (line_num - offset*30 == 0) { | |
411 | tmp += "<div class='whiteBox'>" + | |
412 | __("No articles found to display.") + | |
413 | "</div>"; | |
414 | } | |
4681834e AD |
415 | tmp += "</div></div>"; |
416 | } | |
417 | ||
418 | if (offset == 0) { | |
acac8448 | 419 | var container = $("headlines-frame"); |
4681834e AD |
420 | container.innerHTML = tmp; |
421 | } else { | |
422 | var ids = getSelectedArticleIds2(); | |
423 | ||
acac8448 | 424 | var container = $("headlinesList"); |
e491d06d | 425 | container.innerHTML = container.innerHTML + tmp; |
4681834e AD |
426 | |
427 | for (var i = 0; i < ids.length; i++) { | |
428 | markHeadline(ids[i]); | |
429 | } | |
430 | } | |
431 | } | |
432 | ||
433 | remove_splash(); | |
434 | ||
0e923da4 | 435 | _infscroll_request_sent = 0; |
4681834e AD |
436 | |
437 | } catch (e) { | |
438 | exception_error("viewfeed_offline", e); | |
439 | } | |
440 | } | |
441 | ||
442 | function render_offline_feedlist() { | |
443 | try { | |
1c980681 | 444 | var cats_enabled = getInitParam("enable_feed_cats") == "1"; |
d6416405 | 445 | |
4681834e AD |
446 | var tmp = "<ul class=\"feedList\" id=\"feedList\">"; |
447 | ||
448 | var unread = get_local_feed_unread(-4); | |
449 | ||
450 | global_unread = unread; | |
451 | updateTitle(); | |
452 | ||
d6416405 | 453 | if (cats_enabled) { |
c2726c96 | 454 | tmp += printCategoryHeader(-1, is_local_cat_collapsed(-1), false); |
d6416405 AD |
455 | } |
456 | ||
4681834e AD |
457 | tmp += printFeedEntry(-4, __("All articles"), "feed", unread, |
458 | "images/tag.png"); | |
459 | ||
460 | var unread = get_local_feed_unread(-1); | |
461 | ||
462 | tmp += printFeedEntry(-1, __("Starred articles"), "feed", unread, | |
463 | "images/mark_set.png"); | |
464 | ||
d6416405 AD |
465 | if (cats_enabled) { |
466 | tmp += "</ul></li>"; | |
467 | } else { | |
468 | tmp += "<li><hr/></li>"; | |
469 | } | |
4681834e | 470 | |
c2726c96 AD |
471 | if (cats_enabled) { |
472 | tmp += printCategoryHeader(-2, is_local_cat_collapsed(-2), false); | |
473 | } | |
474 | ||
475 | var rs = db.execute("SELECT id,caption "+ | |
476 | "FROM labels "+ | |
477 | "ORDER BY caption"); | |
478 | ||
479 | while (rs.isValidRow()) { | |
480 | var id = -11 - parseInt(rs.field(0)); | |
481 | var caption = rs.field(1); | |
482 | var unread = get_local_feed_unread(id); | |
483 | ||
484 | tmp += printFeedEntry(id, caption, "feed", unread, | |
485 | "images/label.png"); | |
486 | ||
487 | rs.next(); | |
488 | } | |
489 | ||
490 | rs.close(); | |
491 | ||
492 | if (cats_enabled) { | |
493 | tmp += "</ul></li>"; | |
494 | } else { | |
495 | tmp += "<li><hr/></li>"; | |
496 | } | |
497 | ||
f4c11347 | 498 | /* var rs = db.execute("SELECT feeds.id,feeds.title,has_icon,COUNT(articles.id) "+ |
4681834e AD |
499 | "FROM feeds LEFT JOIN articles ON (feed_id = feeds.id) "+ |
500 | "WHERE unread = 1 OR unread IS NULL GROUP BY feeds.id "+ | |
f4c11347 AD |
501 | "ORDER BY feeds.title"); */ |
502 | ||
d6416405 AD |
503 | var order_by = "feeds.title"; |
504 | ||
505 | if (cats_enabled) order_by = "categories.title," + order_by; | |
506 | ||
507 | var rs = db.execute("SELECT "+ | |
508 | "feeds.id,feeds.title,has_icon,cat_id,collapsed "+ | |
509 | "FROM feeds,categories WHERE cat_id = categories.id "+ | |
510 | "ORDER BY "+order_by); | |
511 | ||
512 | var tmp_cat_id = -1; | |
4681834e AD |
513 | |
514 | while (rs.isValidRow()) { | |
515 | ||
516 | var id = rs.field(0); | |
517 | var title = rs.field(1); | |
518 | var has_icon = rs.field(2); | |
f4c11347 | 519 | var unread = get_local_feed_unread(id); |
d6416405 AD |
520 | var cat_id = rs.field(3); |
521 | var cat_hidden = rs.field(4); | |
522 | ||
523 | if (cat_id != tmp_cat_id && cats_enabled) { | |
524 | if (tmp_cat_id != -1) { | |
525 | tmp += "</ul></li>"; | |
526 | } | |
046a2e3c | 527 | tmp += printCategoryHeader(cat_id, cat_hidden, true); |
d6416405 AD |
528 | tmp_cat_id = cat_id; |
529 | } | |
4681834e AD |
530 | |
531 | var icon = ""; | |
532 | ||
533 | if (has_icon) { | |
046a2e3c | 534 | icon = getInitParam("icons_url") + "/" + id + ".ico"; |
4681834e AD |
535 | } |
536 | ||
4681834e AD |
537 | var feed_icon = ""; |
538 | ||
539 | var row_class = "feed"; | |
540 | ||
541 | if (unread > 0) { | |
542 | row_class += "Unread"; | |
543 | fctr_class = "feedCtrHasUnread"; | |
544 | } else { | |
545 | fctr_class = "feedCtrNoUnread"; | |
546 | } | |
547 | ||
548 | tmp += printFeedEntry(id, title, "feed", unread, icon); | |
549 | ||
550 | rs.next(); | |
551 | } | |
552 | ||
03c96380 AD |
553 | rs.close(); |
554 | ||
983a6a9c AD |
555 | if (cats_enabled) { |
556 | tmp += "</ul>"; | |
557 | } | |
558 | ||
4681834e AD |
559 | tmp += "</ul>"; |
560 | ||
561 | render_feedlist(tmp); | |
562 | } catch (e) { | |
563 | exception_error("render_offline_feedlist", e); | |
564 | } | |
565 | } | |
566 | ||
567 | function init_offline() { | |
568 | try { | |
569 | offline_mode = true; | |
570 | ||
571 | Element.hide("dispSwitchPrompt"); | |
572 | Element.hide("feedBrowserPrompt"); | |
4681834e | 573 | |
69ea0cdd AD |
574 | Element.hide("topLinksOnline"); |
575 | Element.show("topLinksOffline"); | |
576 | ||
acac8448 | 577 | var tb_form = $("main_toolbar_form"); |
80b1c238 AD |
578 | Element.hide(tb_form.update); |
579 | ||
acac8448 | 580 | var chooser = $("quickMenuChooser"); |
3c6d3586 AD |
581 | chooser.disabled = true; |
582 | ||
3034277a AD |
583 | var rs = db.execute("SELECT key, value FROM init_params"); |
584 | ||
585 | while (rs.isValidRow()) { | |
586 | init_params[rs.field(0)] = rs.field(1); | |
587 | rs.next(); | |
588 | } | |
589 | ||
590 | rs.close(); | |
4681834e | 591 | |
b15e516e AD |
592 | var rs = db.execute("SELECT COUNT(*) FROM feeds"); |
593 | ||
594 | var num_feeds = 0; | |
595 | ||
596 | if (rs.isValidRow()) { | |
597 | num_feeds = rs.field(0); | |
598 | } | |
599 | ||
600 | rs.close(); | |
601 | ||
602 | if (num_feeds == 0) { | |
603 | remove_splash(); | |
604 | return fatalError(0, | |
605 | __("Data for offline browsing has not been downloaded yet.")); | |
606 | } | |
607 | ||
4681834e | 608 | render_offline_feedlist(); |
10003c4c | 609 | init_second_stage(); |
b15e516e AD |
610 | window.setTimeout("viewfeed(-4)", 50); |
611 | ||
4681834e AD |
612 | } catch (e) { |
613 | exception_error("init_offline", e); | |
614 | } | |
615 | } | |
616 | ||
617 | function offline_download_parse(stage, transport) { | |
618 | try { | |
619 | if (transport.responseXML) { | |
620 | ||
206d4967 AD |
621 | if (!sync_in_progress) return; |
622 | ||
badac687 AD |
623 | var sync_ok = transport.responseXML.getElementsByTagName("sync-ok"); |
624 | ||
625 | if (sync_ok.length > 0) { | |
626 | for (var i = 0; i < sync_ok.length; i++) { | |
627 | var id = sync_ok[i].getAttribute("id"); | |
628 | if (id) { | |
629 | debug("synced offline info for id " + id); | |
630 | db.execute("UPDATE articles SET modified = '' WHERE id = ?", [id]); | |
631 | } | |
632 | } | |
633 | } | |
634 | ||
4681834e AD |
635 | if (stage == 0) { |
636 | ||
8ca1a0ac AD |
637 | $("offlineModeSyncMsg").innerHTML = __("Synchronizing feeds..."); |
638 | ||
4681834e AD |
639 | var feeds = transport.responseXML.getElementsByTagName("feed"); |
640 | ||
641 | if (feeds.length > 0) { | |
642 | db.execute("DELETE FROM feeds"); | |
643 | } | |
644 | ||
645 | for (var i = 0; i < feeds.length; i++) { | |
646 | var id = feeds[i].getAttribute("id"); | |
647 | var has_icon = feeds[i].getAttribute("has_icon"); | |
648 | var title = feeds[i].firstChild.nodeValue; | |
d8781c91 AD |
649 | var cat_id = feeds[i].getAttribute("cat_id"); |
650 | ||
651 | db.execute("INSERT INTO feeds (id,title,has_icon,cat_id)"+ | |
75aa83ec | 652 | "VALUES (?,?,?,?)", |
d8781c91 | 653 | [id, title, has_icon, cat_id]); |
4681834e | 654 | } |
75aa83ec | 655 | |
8ca1a0ac AD |
656 | $("offlineModeSyncMsg").innerHTML = __("Synchronizing categories..."); |
657 | ||
75aa83ec AD |
658 | var cats = transport.responseXML.getElementsByTagName("category"); |
659 | ||
660 | if (feeds.length > 0) { | |
661 | db.execute("DELETE FROM categories"); | |
662 | } | |
663 | ||
664 | for (var i = 0; i < cats.length; i++) { | |
665 | var id = cats[i].getAttribute("id"); | |
666 | var collapsed = cats[i].getAttribute("collapsed"); | |
667 | var title = cats[i].firstChild.nodeValue; | |
668 | ||
669 | db.execute("INSERT INTO categories (id,title,collapsed)"+ | |
670 | "VALUES (?,?,?)", | |
671 | [id, title, collapsed]); | |
672 | } | |
673 | ||
8ca1a0ac AD |
674 | $("offlineModeSyncMsg").innerHTML = __("Synchronizing labels..."); |
675 | ||
ed22888b AD |
676 | var labels = transport.responseXML.getElementsByTagName("label"); |
677 | ||
678 | if (labels.length > 0) { | |
679 | db.execute("DELETE FROM labels"); | |
680 | } | |
681 | ||
682 | for (var i = 0; i < labels.length; i++) { | |
683 | var id = labels[i].getAttribute("id"); | |
684 | var fg_color = labels[i].getAttribute("fg_color"); | |
685 | var bg_color = labels[i].getAttribute("bg_color"); | |
686 | var caption = labels[i].firstChild.nodeValue; | |
687 | ||
688 | db.execute("INSERT INTO labels (id,caption,fg_color,bg_color)"+ | |
689 | "VALUES (?,?,?,?)", | |
690 | [id, caption, fg_color, bg_color]); | |
691 | } | |
692 | ||
8ca1a0ac AD |
693 | $("offlineModeSyncMsg").innerHTML = __("Synchronizing articles..."); |
694 | ||
695 | sync_timer = window.setTimeout("update_offline_data("+(stage+1)+")", 2*1000); | |
4681834e AD |
696 | } else { |
697 | ||
698 | var articles = transport.responseXML.getElementsByTagName("article"); | |
699 | ||
3e52ab08 AD |
700 | var limit = transport.responseXML.getElementsByTagName("limit")[0]; |
701 | ||
702 | if (limit) { | |
703 | limit = limit.getAttribute("value"); | |
704 | } else { | |
705 | limit = 0; | |
706 | } | |
707 | ||
4681834e AD |
708 | var articles_found = 0; |
709 | ||
710 | for (var i = 0; i < articles.length; i++) { | |
711 | var a = eval("("+articles[i].firstChild.nodeValue+")"); | |
712 | articles_found++; | |
713 | if (a) { | |
714 | ||
4681834e | 715 | db.execute("DELETE FROM articles WHERE id = ?", [a.id]); |
c2726c96 | 716 | |
4681834e AD |
717 | db.execute("INSERT INTO articles "+ |
718 | "(id, feed_id, title, link, guid, updated, content, "+ | |
55852afa AD |
719 | "unread, marked, tags, comments) "+ |
720 | "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | |
4681834e | 721 | [a.id, a.feed_id, a.title, a.link, a.guid, a.updated, |
55852afa | 722 | a.content, a.unread, a.marked, a.tags, |
3034277a | 723 | a.comments]); |
4681834e | 724 | |
c2726c96 AD |
725 | if (a.labels.length > 0) { |
726 | for (var j = 0; j < a.labels.length; j++) { | |
727 | label_local_add_article(a.id, a.labels[j][0]); | |
728 | } | |
729 | } | |
730 | ||
4681834e AD |
731 | } |
732 | } | |
733 | ||
3e52ab08 AD |
734 | debug("downloaded articles: " + articles_found + " limit: " + limit); |
735 | ||
79e565a9 AD |
736 | articles_synced += articles_found; |
737 | ||
b4dc02e2 | 738 | var msg =__("Synchronizing articles (%d)...").replace("%d", articles_synced); |
79e565a9 AD |
739 | |
740 | $("offlineModeSyncMsg").innerHTML = msg; | |
741 | ||
badac687 AD |
742 | var has_sync_data = has_local_sync_data(); |
743 | ||
744 | if (articles_found >= limit || has_sync_data) { | |
206d4967 | 745 | sync_timer = window.setTimeout("update_offline_data("+(stage+1)+")", |
8ca1a0ac | 746 | 3*1000); |
badac687 AD |
747 | debug("<b>update_offline_data: done " + stage + " HSD: " + |
748 | has_sync_data + "</b>"); | |
4681834e | 749 | } else { |
206d4967 | 750 | window.setTimeout("offlineDownloadStart()", 180*1000); |
3e52ab08 | 751 | debug("update_offline_data: finished"); |
4681834e | 752 | |
79e565a9 | 753 | var pic = $("offlineModePic"); |
04870193 AD |
754 | |
755 | if (pic) { | |
756 | pic.src = "images/offline.png"; | |
79e565a9 AD |
757 | |
758 | var rs = db.execute("SELECT value FROM syncdata WHERE key = 'last_online'"); | |
759 | var last_sync = ""; | |
760 | ||
761 | if (rs.isValidRow()) { | |
762 | last_sync = rs.field(0).substring(0,16); | |
763 | } | |
764 | rs.close(); | |
765 | ||
766 | var msg = __("Last sync: %s").replace("%s", last_sync); | |
767 | ||
768 | articles_synced = 0; | |
769 | ||
770 | $("offlineModeSyncMsg").innerHTML = msg; | |
04870193 AD |
771 | } |
772 | ||
8ca1a0ac | 773 | offlineSyncShowHideElems(false); |
79e565a9 AD |
774 | |
775 | sync_in_progress = false; | |
776 | ||
711f9461 AD |
777 | db.execute("DELETE FROM articles WHERE "+ |
778 | "updated < DATETIME('NOW', 'localtime', '-31 days')"); | |
4681834e AD |
779 | |
780 | } | |
781 | } | |
782 | ||
7f4f9f4e | 783 | update_local_sync_data(); |
04870193 | 784 | |
7f4f9f4e | 785 | |
f45c85f9 | 786 | // notify(''); |
b2319311 | 787 | |
b4dc02e2 AD |
788 | } else { |
789 | sync_in_progress = false; | |
790 | ||
791 | var pic = $("offlineModePic"); | |
792 | ||
793 | if (pic) { | |
794 | pic.src = "images/offline.png"; | |
8ca1a0ac | 795 | var msg = __("Last sync: Error receiving data."); |
b4dc02e2 AD |
796 | articles_synced = 0; |
797 | $("offlineModeSyncMsg").innerHTML = msg; | |
798 | } | |
799 | ||
8ca1a0ac | 800 | offlineSyncShowHideElems(false); |
4681834e | 801 | } |
b4dc02e2 | 802 | |
4681834e AD |
803 | } catch (e) { |
804 | exception_error("offline_download_parse", e); | |
805 | } | |
806 | } | |
807 | ||
808 | function update_offline_data(stage) { | |
809 | try { | |
810 | ||
811 | if (!stage) stage = 0; | |
79e565a9 | 812 | |
23e2fb84 | 813 | if (!db || offline_mode || getInitParam("offline_enabled") != "1") return; |
4681834e | 814 | |
f45c85f9 | 815 | // notify_progress("Updating offline data... (" + stage +")", true); |
4681834e | 816 | |
e8080ee9 AD |
817 | var query = "backend.php?op=rpc&subop=download"; |
818 | ||
4681834e | 819 | var rs = db.execute("SELECT MAX(id), MIN(id) FROM articles"); |
03c96380 | 820 | |
4681834e AD |
821 | if (rs.isValidRow() && rs.field(0)) { |
822 | var offline_dl_max_id = rs.field(0); | |
823 | var offline_dl_min_id = rs.field(1); | |
824 | ||
825 | query = query + "&cidt=" + offline_dl_max_id; | |
826 | query = query + "&cidb=" + offline_dl_min_id; | |
e8080ee9 AD |
827 | |
828 | stage = 1; | |
4681834e AD |
829 | } |
830 | ||
03c96380 AD |
831 | rs.close(); |
832 | ||
e8080ee9 AD |
833 | debug("update_offline_data: stage " + stage); |
834 | ||
835 | query = query + "&stage=" + stage; | |
836 | ||
badac687 AD |
837 | var to_sync = prepare_local_sync_data(); |
838 | ||
839 | if (to_sync != "") { | |
840 | to_sync = "?sync=" + param_escape(to_sync); | |
841 | } | |
842 | ||
843 | debug(query + "/" + to_sync); | |
844 | ||
79e565a9 | 845 | var pic = $("offlineModePic"); |
04870193 AD |
846 | |
847 | if (pic) { | |
848 | pic.src = "images/offline-sync.gif"; | |
79e565a9 AD |
849 | if (articles_synced == 0) { |
850 | $("offlineModeSyncMsg").innerHTML = __("Synchronizing..."); | |
851 | } | |
852 | } | |
853 | ||
8ca1a0ac | 854 | offlineSyncShowHideElems(true); |
79e565a9 | 855 | |
79e565a9 | 856 | sync_in_progress = true; |
04870193 | 857 | |
4681834e | 858 | new Ajax.Request(query, { |
badac687 | 859 | parameters: to_sync, |
4681834e AD |
860 | onComplete: function(transport) { |
861 | offline_download_parse(stage, transport); | |
4681834e AD |
862 | } }); |
863 | ||
864 | } catch (e) { | |
865 | exception_error("initiate_offline_download", e); | |
866 | } | |
867 | } | |
868 | ||
d6416405 | 869 | function set_feedlist_counter(id, ctr, is_cat) { |
4681834e AD |
870 | try { |
871 | ||
acac8448 AD |
872 | var feedctr = $("FEEDCTR-" + id); |
873 | var feedu = $("FEEDU-" + id); | |
874 | var feedr = $("FEEDR-" + id); | |
4681834e | 875 | |
d6416405 | 876 | if (is_cat) { |
acac8448 | 877 | var catctr = $("FCATCTR-" + id); |
d6416405 AD |
878 | if (catctr) { |
879 | catctr.innerHTML = "(" + ctr + ")"; | |
880 | if (ctr > 0) { | |
881 | catctr.className = "catCtrHasUnread"; | |
882 | } else { | |
883 | catctr.className = "catCtrNoUnread"; | |
884 | } | |
885 | } | |
886 | } else if (feedctr && feedu && feedr) { | |
4681834e AD |
887 | |
888 | var row_needs_hl = (ctr > 0 && ctr > parseInt(feedu.innerHTML)); | |
889 | ||
890 | feedu.innerHTML = ctr; | |
891 | ||
892 | if (ctr > 0) { | |
893 | feedctr.className = "feedCtrHasUnread"; | |
894 | if (!feedr.className.match("Unread")) { | |
895 | var is_selected = feedr.className.match("Selected"); | |
896 | ||
897 | feedr.className = feedr.className.replace("Selected", ""); | |
898 | feedr.className = feedr.className.replace("Unread", ""); | |
899 | ||
900 | feedr.className = feedr.className + "Unread"; | |
901 | ||
902 | if (is_selected) { | |
903 | feedr.className = feedr.className + "Selected"; | |
904 | } | |
905 | ||
906 | } | |
907 | ||
908 | if (row_needs_hl) { | |
909 | new Effect.Highlight(feedr, {duration: 1, startcolor: "#fff7d5", | |
910 | queue: { position:'end', scope: 'EFQ-' + id, limit: 1 } } ); | |
911 | } | |
912 | } else { | |
913 | feedctr.className = "feedCtrNoUnread"; | |
914 | feedr.className = feedr.className.replace("Unread", ""); | |
915 | } | |
916 | } | |
917 | ||
918 | } catch (e) { | |
919 | exception_error("set_feedlist_counter", e); | |
920 | } | |
921 | } | |
922 | ||
923 | function update_local_feedlist_counters() { | |
924 | try { | |
b7dbf528 | 925 | if (!offline_mode || !db) return; |
4681834e | 926 | |
f4c11347 | 927 | /* var rs = db.execute("SELECT feeds.id,COUNT(articles.id) "+ |
4681834e AD |
928 | "FROM feeds LEFT JOIN articles ON (feed_id = feeds.id) "+ |
929 | "WHERE unread = 1 OR unread IS NULL GROUP BY feeds.id "+ | |
f4c11347 AD |
930 | "ORDER BY feeds.title"); */ |
931 | ||
d6416405 | 932 | var rs = db.execute("SELECT id FROM feeds "+ |
f4c11347 | 933 | "ORDER BY title"); |
4681834e AD |
934 | |
935 | while (rs.isValidRow()) { | |
936 | var id = rs.field(0); | |
f4c11347 | 937 | var ctr = get_local_feed_unread(id); |
d6416405 AD |
938 | set_feedlist_counter(id, ctr, false); |
939 | rs.next(); | |
940 | } | |
4681834e | 941 | |
d6416405 AD |
942 | rs.close(); |
943 | ||
944 | var rs = db.execute("SELECT cat_id,SUM(unread) "+ | |
945 | "FROM articles, feeds WHERE feeds.id = feed_id GROUP BY cat_id"); | |
4681834e | 946 | |
d6416405 AD |
947 | while (rs.isValidRow()) { |
948 | var id = rs.field(0); | |
949 | var ctr = rs.field(1); | |
950 | set_feedlist_counter(id, ctr, true); | |
4681834e AD |
951 | rs.next(); |
952 | } | |
953 | ||
03c96380 AD |
954 | rs.close(); |
955 | ||
c174bcdf AD |
956 | set_feedlist_counter(-2, get_local_category_unread(-2), true); |
957 | ||
4681834e AD |
958 | set_feedlist_counter(-4, get_local_feed_unread(-4)); |
959 | set_feedlist_counter(-1, get_local_feed_unread(-1)); | |
960 | ||
88a66534 AD |
961 | var rs = db.execute("SELECT id FROM labels"); |
962 | ||
963 | while (rs.isValidRow()) { | |
964 | var id = -11 - rs.field(0); | |
965 | var ctr = get_local_feed_unread(id); | |
966 | set_feedlist_counter(id, ctr, false); | |
967 | rs.next(); | |
968 | } | |
969 | ||
970 | rs.close(); | |
971 | ||
4681834e AD |
972 | hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); |
973 | ||
974 | global_unread = get_local_feed_unread(-4); | |
975 | updateTitle(); | |
976 | ||
977 | } catch (e) { | |
978 | exception_error("update_local_feedlist_counters", e); | |
979 | } | |
980 | } | |
774b8df8 AD |
981 | |
982 | function get_local_feed_unread(id) { | |
983 | try { | |
984 | var rs; | |
985 | ||
986 | if (id == -4) { | |
987 | rs = db.execute("SELECT SUM(unread) FROM articles"); | |
988 | } else if (id == -1) { | |
989 | rs = db.execute("SELECT SUM(unread) FROM articles WHERE marked = 1"); | |
88a66534 | 990 | } else if (id > 0) { |
774b8df8 | 991 | rs = db.execute("SELECT SUM(unread) FROM articles WHERE feed_id = ?", [id]); |
88a66534 AD |
992 | } else if (id < -10) { |
993 | var label_id = -11 - id; | |
994 | rs = db.execute("SELECT SUM(unread) FROM articles,article_labels "+ | |
995 | "WHERE article_labels.id = articles.id AND label_id = ?", [label_id]); | |
774b8df8 AD |
996 | } |
997 | ||
03c96380 AD |
998 | var a = false; |
999 | ||
774b8df8 | 1000 | if (rs.isValidRow()) { |
03c96380 | 1001 | a = rs.field(0); |
774b8df8 | 1002 | } else { |
03c96380 | 1003 | a = 0; |
774b8df8 AD |
1004 | } |
1005 | ||
03c96380 AD |
1006 | rs.close(); |
1007 | ||
1008 | return a; | |
1009 | ||
774b8df8 AD |
1010 | } catch (e) { |
1011 | exception_error("get_local_feed_unread", e); | |
1012 | } | |
1013 | } | |
1014 | ||
59b223d7 AD |
1015 | function enable_offline_reading() { |
1016 | try { | |
1017 | ||
23e2fb84 | 1018 | if (db && getInitParam("offline_enabled") == "1") { |
59b223d7 | 1019 | init_local_sync_data(); |
79e565a9 AD |
1020 | Element.show("offlineModePic"); |
1021 | offlineDownloadStart(); | |
59b223d7 AD |
1022 | } |
1023 | ||
1024 | } catch (e) { | |
1025 | exception_error("enable_offline_reading", e); | |
1026 | } | |
1027 | } | |
1028 | ||
25d99353 AD |
1029 | function init_gears() { |
1030 | try { | |
1031 | ||
1032 | if (window.google && google.gears) { | |
8ca1a0ac AD |
1033 | |
1034 | try { | |
1035 | localServer = google.gears.factory.create("beta.localserver"); | |
1036 | } catch (e) { | |
1037 | return; | |
1038 | } | |
1039 | ||
25d99353 | 1040 | store = localServer.createManagedStore("tt-rss"); |
206d4967 AD |
1041 | store.manifestUrl = "manifest.json.php"; |
1042 | ||
25d99353 AD |
1043 | db = google.gears.factory.create('beta.database'); |
1044 | db.open('tt-rss'); | |
1045 | ||
1046 | db.execute("CREATE TABLE IF NOT EXISTS version (schema_version text)"); | |
1047 | ||
1048 | var rs = db.execute("SELECT schema_version FROM version"); | |
1049 | ||
1050 | var version = ""; | |
1051 | ||
1052 | if (rs.isValidRow()) { | |
1053 | version = rs.field(0); | |
1054 | } | |
1055 | ||
3034277a AD |
1056 | rs.close(); |
1057 | ||
25d99353 | 1058 | if (version != SCHEMA_VERSION) { |
3034277a | 1059 | db.execute("DROP TABLE IF EXISTS init_params"); |
b871dd06 AD |
1060 | db.execute("DROP TABLE IF EXISTS cache"); |
1061 | db.execute("DROP TABLE IF EXISTS feeds"); | |
d8781c91 | 1062 | db.execute("DROP TABLE IF EXISTS categories"); |
ed22888b AD |
1063 | db.execute("DROP TABLE IF EXISTS labels"); |
1064 | db.execute("DROP TABLE IF EXISTS article_labels"); | |
b871dd06 | 1065 | db.execute("DROP TABLE IF EXISTS articles"); |
c174bcdf AD |
1066 | db.execute("DROP INDEX IF EXISTS article_labels_label_id_idx"); |
1067 | db.execute("DROP INDEX IF EXISTS articles_unread_idx"); | |
1068 | db.execute("DROP INDEX IF EXISTS articles_feed_id_idx"); | |
badac687 AD |
1069 | db.execute("DROP INDEX IF EXISTS articles_id_idx"); |
1070 | db.execute("DROP INDEX IF EXISTS article_labels_id_idx"); | |
3034277a | 1071 | db.execute("DROP TABLE IF EXISTS version"); |
6b684299 AD |
1072 | db.execute("DROP TRIGGER IF EXISTS articles_update_unread"); |
1073 | db.execute("DROP TRIGGER IF EXISTS articles_update_marked"); | |
5b880817 | 1074 | db.execute("DROP TRIGGER IF EXISTS articles_remove_labelrefs"); |
3034277a | 1075 | db.execute("CREATE TABLE IF NOT EXISTS version (schema_version text)"); |
6b684299 | 1076 | db.execute("DROP TABLE IF EXISTS syncdata"); |
25d99353 AD |
1077 | db.execute("INSERT INTO version (schema_version) VALUES (?)", |
1078 | [SCHEMA_VERSION]); | |
1079 | } | |
1080 | ||
71af6d36 | 1081 | db.execute("CREATE TABLE IF NOT EXISTS init_params (key text, value text)"); |
3034277a | 1082 | |
71af6d36 AD |
1083 | db.execute("CREATE TABLE IF NOT EXISTS cache (id integer, article text, param text, added text)"); |
1084 | db.execute("CREATE TABLE IF NOT EXISTS feeds (id integer, title text, has_icon integer, cat_id integer)"); | |
1085 | db.execute("CREATE TABLE IF NOT EXISTS categories (id integer, title text, collapsed integer)"); | |
1086 | db.execute("CREATE TABLE IF NOT EXISTS labels (id integer, caption text, fg_color text, bg_color text)"); | |
ed22888b | 1087 | db.execute("CREATE TABLE IF NOT EXISTS article_labels (id integer, label_id integer)"); |
55852afa | 1088 | db.execute("CREATE TABLE IF NOT EXISTS articles (id integer, feed_id integer, title text, link text, guid text, updated timestamp, content text, tags text, unread integer, marked integer, added text, modified timestamp, comments text)"); |
c174bcdf AD |
1089 | |
1090 | db.execute("CREATE INDEX IF NOT EXISTS articles_unread_idx ON articles(unread)"); | |
1091 | db.execute("CREATE INDEX IF NOT EXISTS article_labels_label_id_idx ON article_labels(label_id)"); | |
1092 | db.execute("CREATE INDEX IF NOT EXISTS articles_feed_id_idx ON articles(feed_id)"); | |
badac687 AD |
1093 | db.execute("CREATE INDEX IF NOT EXISTS articles_id_idx ON articles(id)"); |
1094 | db.execute("CREATE INDEX IF NOT EXISTS article_labels_id_idx ON article_labels(id)"); | |
779ba075 | 1095 | |
71af6d36 | 1096 | db.execute("CREATE TABLE IF NOT EXISTS syncdata (key integer, value text)"); |
6b684299 | 1097 | |
779ba075 | 1098 | db.execute("DELETE FROM cache WHERE id LIKE 'F:%' OR id LIKE 'C:%'"); |
69ea0cdd | 1099 | |
6b684299 | 1100 | db.execute("CREATE TRIGGER IF NOT EXISTS articles_update_unread "+ |
55852afa AD |
1101 | "UPDATE OF unread ON articles "+ |
1102 | "BEGIN "+ | |
711f9461 | 1103 | "UPDATE articles SET modified = DATETIME('NOW', 'localtime') "+ |
6b684299 AD |
1104 | "WHERE id = OLD.id AND "+ |
1105 | "OLD.unread != NEW.unread;"+ | |
1106 | "END;"); | |
1107 | ||
1108 | db.execute("CREATE TRIGGER IF NOT EXISTS articles_update_marked "+ | |
1109 | "UPDATE OF marked ON articles "+ | |
1110 | "BEGIN "+ | |
1111 | "UPDATE articles SET modified = DATETIME('NOW', 'localtime') "+ | |
1112 | "WHERE id = OLD.id;"+ | |
55852afa AD |
1113 | "END;"); |
1114 | ||
5b880817 AD |
1115 | db.execute("CREATE TRIGGER IF NOT EXISTS articles_remove_labelrefs "+ |
1116 | "DELETE ON articles "+ | |
1117 | "BEGIN "+ | |
1118 | "DELETE FROM article_labels WHERE id = OLD.id; "+ | |
1119 | "END; "); | |
1120 | ||
25d99353 AD |
1121 | } |
1122 | ||
1123 | cache_expire(); | |
1124 | ||
1125 | } catch (e) { | |
1126 | exception_error("init_gears", e); | |
1127 | } | |
1128 | } | |
1129 | ||
69ea0cdd | 1130 | function gotoOffline() { |
206d4967 AD |
1131 | |
1132 | // debug("[Local store] currentVersion = " + store.currentVersion); | |
1133 | ||
8ca1a0ac AD |
1134 | var rs = db.execute("SELECT COUNT(*) FROM articles"); |
1135 | var count = 0; | |
1136 | if (rs.isValidRow()) { | |
1137 | count = rs.field(0); | |
1138 | } | |
1139 | ||
1140 | rs.close(); | |
1141 | ||
1142 | if (count == 0) { | |
1143 | notify_error("You have to synchronize some articles before going into offline mode."); | |
1144 | return; | |
1145 | } | |
1146 | ||
206d4967 AD |
1147 | if (confirm(__("Switch Tiny Tiny RSS into offline mode?"))) { |
1148 | ||
1149 | store.checkForUpdate(); | |
1150 | ||
1151 | notify_progress("Preparing offline mode..."); | |
1152 | ||
1153 | var timerId = window.setInterval(function() { | |
1154 | if (store.currentVersion) { | |
1155 | window.clearInterval(timerId); | |
8ca1a0ac AD |
1156 | debug("[Local store] sync complete: " + store.currentVersion); |
1157 | ||
1158 | //window.location.href = "tt-rss.php"; | |
1159 | ||
1160 | offlineDownloadStop(); | |
1161 | offline_mode = true; | |
1162 | init_offline(); | |
1163 | ||
1164 | notify_info("Tiny Tiny RSS is in offline mode."); | |
1165 | ||
206d4967 AD |
1166 | } else if (store.updateStatus == 3) { |
1167 | debug("[Local store] sync error: " + store.lastErrorMessage); | |
8ca1a0ac | 1168 | notify_error(store.lastErrorMessage, true); |
206d4967 AD |
1169 | } }, 500); |
1170 | } | |
69ea0cdd AD |
1171 | } |
1172 | ||
1173 | function gotoOnline() { | |
206d4967 AD |
1174 | if (confirm(__("You won't be able to access offline version of Tiny Tiny RSS until you switch it into offline mode again. Go online?"))) { |
1175 | localServer.removeManagedStore("tt-rss"); | |
1176 | window.location.href = "tt-rss.php"; | |
1177 | } | |
69ea0cdd | 1178 | } |
774b8df8 | 1179 | |
c26aa9f0 AD |
1180 | function local_collapse_cat(id) { |
1181 | try { | |
1182 | if (db) { | |
1183 | db.execute("UPDATE categories SET collapsed = NOT collapsed WHERE id = ?", | |
1184 | [id]); | |
1185 | } | |
1186 | } catch (e) { | |
1187 | exception_error("local_collapse_cat", e); | |
1188 | } | |
1189 | } | |
d6416405 AD |
1190 | |
1191 | function get_local_category_title(id) { | |
1192 | try { | |
71af6d36 | 1193 | |
d6416405 AD |
1194 | var rs = db.execute("SELECT title FROM categories WHERE id = ?", [id]); |
1195 | var tmp = ""; | |
1196 | ||
1197 | if (rs.isValidRow()) { | |
1198 | tmp = rs.field(0); | |
1199 | } | |
1200 | ||
1201 | rs.close(); | |
1202 | ||
1203 | return tmp; | |
1204 | ||
1205 | } catch (e) { | |
1206 | exception_error("get_local_category_title", e); | |
1207 | } | |
1208 | } | |
1209 | ||
1210 | function get_local_category_unread(id) { | |
1211 | try { | |
c174bcdf AD |
1212 | var rs = false; |
1213 | ||
1214 | if (id >= 0) { | |
1215 | rs = db.execute("SELECT SUM(unread) FROM articles, feeds "+ | |
1216 | "WHERE feeds.id = feed_id AND cat_id = ?", [id]); | |
1217 | } else if (id == -2) { | |
1218 | rs = db.execute("SELECT SUM(unread) FROM article_labels, articles "+ | |
1219 | "where article_labels.id = articles.id"); | |
1220 | } else { | |
1221 | return 0; | |
1222 | } | |
d6416405 AD |
1223 | |
1224 | var tmp = 0; | |
1225 | ||
1226 | if (rs.isValidRow()) { | |
1227 | tmp = rs.field(0); | |
1228 | } | |
1229 | ||
1230 | rs.close(); | |
1231 | ||
1232 | return tmp; | |
1233 | ||
1234 | } catch (e) { | |
1235 | exception_error("get_local_category_unread", e); | |
1236 | } | |
1237 | } | |
1238 | ||
1239 | function printCategoryHeader(cat_id, hidden, can_browse) { | |
1240 | try { | |
1241 | if (hidden == undefined) hidden = false; | |
1242 | if (can_browse == undefined) can_browse = false; | |
1243 | ||
1244 | var tmp_category = get_local_category_title(cat_id); | |
1245 | var tmp = ""; | |
1246 | ||
1247 | var cat_unread = get_local_category_unread(cat_id); | |
1248 | ||
1249 | var holder_style = ""; | |
1250 | var ellipsis = ""; | |
1251 | ||
1252 | if (hidden) { | |
1253 | holder_style = "display:none;"; | |
1254 | ellipsis = "…"; | |
1255 | } | |
1256 | ||
1257 | var catctr_class = (cat_unread > 0) ? "catCtrHasUnread" : "catCtrNoUnread"; | |
1258 | ||
1259 | var browse_cat_link = ""; | |
1260 | var inner_title_class = "catTitleNL"; | |
1261 | ||
1262 | if (can_browse) { | |
046a2e3c | 1263 | browse_cat_link = "onclick=\"javascript:viewCategory("+cat_id+")\""; |
d6416405 AD |
1264 | inner_title_class = "catTitle"; |
1265 | } | |
1266 | ||
1267 | var cat_class = "feedCat"; | |
1268 | ||
1269 | tmp += "<li class=\""+cat_class+"\" id=\"FCAT-"+cat_id+"\">"+ | |
1270 | "<img onclick=\"toggleCollapseCat("+cat_id+")\" class=\"catCollapse\""+ | |
1271 | " title=\""+__('Click to collapse category')+"\""+ | |
1272 | " src=\"images/cat-collapse.png\"><span class=\""+inner_title_class+"\" "+ | |
1273 | " id=\"FCATN-"+cat_id+"\" "+browse_cat_link+ | |
1274 | "\">"+tmp_category+"</span>"; | |
1275 | ||
1276 | tmp += "<span id=\"FCAP-"+cat_id+"\">"; | |
1277 | ||
1278 | tmp += " <span id=\"FCATCTR-"+cat_id+"\" "+ | |
1279 | "class=\""+catctr_class+"\">("+cat_unread+")</span> "+ellipsis; | |
1280 | ||
1281 | tmp += "</span>"; | |
1282 | ||
1283 | tmp += "<ul class=\"feedCatList\" id=\"FCATLIST-"+cat_id+"\" "+ | |
1284 | "style='"+holder_style+"'>"; | |
1285 | ||
1286 | return tmp; | |
1287 | } catch (e) { | |
1288 | exception_error("printCategoryHeader", e); | |
1289 | } | |
1290 | } | |
1291 | ||
c2726c96 AD |
1292 | function is_local_cat_collapsed(id) { |
1293 | try { | |
1294 | ||
1295 | var rs = db.execute("SELECT collapsed FROM categories WHERE id = ?", [id]); | |
1296 | var cat_hidden = 0; | |
1297 | ||
1298 | if (rs.isValidRow()) { | |
1299 | cat_hidden = rs.field(0); | |
1300 | } | |
1301 | ||
1302 | rs.close(); | |
1303 | ||
1304 | return cat_hidden == "1"; | |
1305 | ||
1306 | } catch (e) { | |
1307 | exception_error("is_local_cat_collapsed", e); | |
1308 | } | |
1309 | } | |
1310 | ||
6da82466 AD |
1311 | function get_local_article_labels(id) { |
1312 | try { | |
1313 | var rs = db.execute("SELECT DISTINCT label_id,caption,fg_color,bg_color "+ | |
1314 | "FROM labels, article_labels "+ | |
1315 | "WHERE labels.id = label_id AND article_labels.id = ?", [id]); | |
1316 | ||
1317 | var tmp = new Array(); | |
1318 | ||
1319 | while (rs.isValidRow()) { | |
1320 | var e = new Array(); | |
1321 | ||
1322 | e[0] = rs.field(0); | |
1323 | e[1] = rs.field(1); | |
1324 | e[2] = rs.field(2); | |
1325 | e[3] = rs.field(3); | |
1326 | ||
1327 | tmp.push(e); | |
1328 | ||
1329 | rs.next(); | |
1330 | } | |
1331 | ||
1332 | return tmp; | |
1333 | ||
1334 | } catch (e) { | |
1335 | exception_error("get_local_article_labels", e); | |
1336 | } | |
1337 | } | |
1338 | ||
c2726c96 AD |
1339 | function label_local_add_article(id, label_id) { |
1340 | try { | |
5b880817 | 1341 | //debug("label_local_add_article " + id + " => " + label_id); |
c2726c96 AD |
1342 | |
1343 | var rs = db.execute("SELECT COUNT(id) FROM article_labels WHERE "+ | |
1344 | "id = ? AND label_id = ?", [id, label_id]); | |
1345 | var check = rs.field(0); | |
1346 | ||
1347 | if (rs.isValidRow()) { | |
1348 | var check = rs.field(0); | |
1349 | } | |
1350 | rs.close(); | |
1351 | ||
1352 | if (check == 0) { | |
1353 | db.execute("INSERT INTO article_labels (id, label_id) VALUES "+ | |
1354 | "(?,?)", [id, label_id]); | |
1355 | } | |
1356 | ||
1357 | } catch (e) { | |
1358 | exception_error("label_local_add_article", e); | |
1359 | } | |
1360 | } | |
88a66534 AD |
1361 | |
1362 | function get_local_feed_title(id) { | |
1363 | try { | |
1364 | ||
1365 | var feed_title = "Unknown feed: " + id; | |
1366 | ||
1367 | if (id > 0) { | |
1368 | var rs = db.execute("SELECT title FROM feeds WHERE id = ?", [id]); | |
1369 | ||
1370 | if (rs.isValidRow()) { | |
1371 | feed_title = rs.field(0); | |
1372 | } | |
1373 | ||
1374 | rs.close(); | |
1375 | } else if (id == -1) { | |
1376 | feed_title = __("Starred articles"); | |
1377 | } else if (id == -4) { | |
1378 | feed_title = __("All articles"); | |
1379 | } else if (id < -10) { | |
1380 | ||
1381 | var label_id = -11 - id; | |
1382 | ||
1383 | var rs = db.execute("SELECT caption FROM labels WHERE id = ?", [label_id]); | |
1384 | ||
1385 | if (rs.isValidRow()) { | |
1386 | feed_title = rs.field(0); | |
1387 | } | |
1388 | ||
1389 | rs.close(); | |
1390 | } | |
1391 | ||
1392 | return feed_title; | |
1393 | ||
1394 | } catch (e) { | |
1395 | exception_error("get_local_feed_title", e); | |
1396 | } | |
1397 | } | |
6da82466 AD |
1398 | |
1399 | function format_article_labels(labels, id) { | |
1400 | try { | |
1401 | ||
1402 | var labels_str = ""; | |
1403 | ||
1404 | if (!labels) return ""; | |
1405 | ||
1406 | for (var i = 0; i < labels.length; i++) { | |
1407 | var l = labels[i]; | |
1408 | ||
1409 | labels_str += "<span class='hlLabelRef' "+ | |
1410 | "style='color : "+l[2]+"; background-color : "+l[3]+"'>"+l[1]+"</span>"; | |
1411 | } | |
1412 | ||
1413 | return labels_str; | |
1414 | ||
1415 | } catch (e) { | |
1416 | exception_error("format_article_labels", e); | |
1417 | } | |
1418 | } | |
1419 | ||
6b684299 AD |
1420 | function init_local_sync_data() { |
1421 | try { | |
23e2fb84 AD |
1422 | |
1423 | if (!db) return; | |
1424 | ||
6b684299 AD |
1425 | var rs = db.execute("SELECT COUNT(*) FROM syncdata WHERE key = 'last_online'"); |
1426 | var has_last_online = 0; | |
1427 | ||
1428 | if (rs.isValidRow()) { | |
1429 | has_last_online = rs.field(0); | |
1430 | } | |
1431 | ||
1432 | rs.close(); | |
1433 | ||
1434 | if (!has_last_online) { | |
1435 | db.execute("INSERT INTO syncdata (key, value) VALUES ('last_online', '')"); | |
1436 | } | |
1437 | ||
1438 | } catch (e) { | |
1439 | exception_error("init_local_sync_data", e); | |
1440 | ||
1441 | } | |
1442 | } | |
1443 | ||
badac687 AD |
1444 | function has_local_sync_data() { |
1445 | try { | |
1446 | ||
1447 | var rs = db.execute("SELECT id FROM articles "+ | |
1448 | "WHERE modified > (SELECT value FROM syncdata WHERE key = 'last_online') "+ | |
1449 | "LIMIT 1"); | |
1450 | ||
1451 | var tmp = 0; | |
1452 | ||
1453 | if (rs.isValidRow()) { | |
1454 | tmp = rs.field(0); | |
1455 | } | |
1456 | ||
1457 | rs.close(); | |
1458 | ||
1459 | return tmp != 0; | |
1460 | ||
1461 | } catch (e) { | |
1462 | exception_error("has_local_sync_data", e); | |
1463 | } | |
1464 | } | |
1465 | ||
1466 | function prepare_local_sync_data() { | |
1467 | try { | |
1468 | var rs = db.execute("SELECT value FROM syncdata WHERE key = 'last_online'"); | |
1469 | ||
1470 | var last_online = ""; | |
1471 | ||
1472 | if (rs.isValidRow()) { | |
1473 | last_online = rs.field(0); | |
1474 | } | |
1475 | ||
1476 | rs.close(); | |
1477 | ||
1478 | var rs = db.execute("SELECT id,unread,marked FROM articles "+ | |
1479 | "WHERE modified > ? LIMIT 200", [last_online]); | |
1480 | ||
1481 | var tmp = last_online + ";"; | |
1482 | ||
1483 | var entries = 0; | |
1484 | ||
1485 | while (rs.isValidRow()) { | |
1486 | var e = new Array(); | |
1487 | ||
1488 | tmp = tmp + rs.field(0) + "," + rs.field(1) + "," + rs.field(2) + ";"; | |
1489 | entries++; | |
1490 | ||
1491 | rs.next(); | |
1492 | } | |
1493 | ||
1494 | rs.close(); | |
1495 | ||
1496 | if (entries > 0) { | |
1497 | return tmp; | |
1498 | } else { | |
1499 | return ''; | |
1500 | } | |
1501 | ||
1502 | } catch (e) { | |
1503 | exception_error("prepare_local_sync_data", e); | |
1504 | } | |
1505 | } | |
1506 | ||
6b684299 AD |
1507 | function update_local_sync_data() { |
1508 | try { | |
1509 | if (db && !offline_mode) { | |
badac687 AD |
1510 | |
1511 | var rs = db.execute("SELECT id FROM articles "+ | |
1512 | "WHERE modified > (SELECT value FROM syncdata WHERE "+ | |
1513 | "key = 'last_online') LIMIT 1") | |
1514 | ||
1515 | var f_id = 0; | |
1516 | ||
1517 | if (rs.isValidRow()) { | |
1518 | f_id = rs.field(0); | |
1519 | } | |
1520 | ||
1521 | rs.close(); | |
1522 | ||
1523 | /* no pending articles to sync */ | |
1524 | ||
1525 | if (f_id == 0) { | |
1526 | db.execute("UPDATE syncdata SET value = DATETIME('NOW', 'localtime') "+ | |
1527 | "WHERE key = 'last_online'"); | |
1528 | } | |
6b684299 AD |
1529 | |
1530 | } | |
1531 | } catch (e) { | |
1532 | exception_error("update_local_sync_data", e); | |
1533 | } | |
1534 | } | |
67625745 AD |
1535 | |
1536 | function catchup_local_feed(id, is_cat) { | |
1537 | try { | |
6161d5cc AD |
1538 | if (!db) return; |
1539 | ||
67625745 AD |
1540 | if (!is_cat) { |
1541 | if (id >= 0) { | |
1542 | db.execute("UPDATE articles SET unread = 0 WHERE feed_id = ?", [id]); | |
1543 | } else if (id == -1) { | |
1544 | db.execute("UPDATE articles SET unread = 0 WHERE marked = 1"); | |
1545 | } else if (id == -4) { | |
1546 | db.execute("UPDATE articles SET unread = 0"); | |
1547 | } else if (id < -10) { | |
1548 | var label_id = -11-id; | |
1549 | ||
1550 | db.execute("UPDATE articles SET unread = 0 WHERE "+ | |
1551 | "(SELECT COUNT(*) FROM article_labels WHERE "+ | |
1552 | "article_labels.id = articles.id AND label_id = ?) > 0", [label_id]); | |
1553 | } | |
1554 | } | |
1555 | ||
1556 | update_local_feedlist_counters(); | |
1557 | ||
1558 | } catch (e) { | |
1559 | exception_error("catchup_local_feed", e); | |
1560 | } | |
1561 | } | |
79e565a9 AD |
1562 | |
1563 | function toggleOfflineModeInfo() { | |
1564 | try { | |
1565 | var e = $('offlineModeDrop'); | |
1566 | var p = $('offlineModePic'); | |
1567 | ||
1568 | if (Element.visible(e)) { | |
1569 | Element.hide(e); | |
1570 | } else { | |
1571 | Element.show(e); | |
1572 | } | |
1573 | ||
1574 | } catch (e) { | |
1575 | exception_error("toggleOfflineModeInfo", e); | |
1576 | } | |
1577 | } | |
1578 | ||
1579 | function offlineDownloadStart() { | |
1580 | try { | |
1581 | if (db && !sync_in_progress && getInitParam("offline_enabled") == "1") { | |
1582 | window.setTimeout("update_offline_data(0)", 100); | |
1583 | } | |
1584 | } catch (e) { | |
1585 | exception_error("offlineDownloadStart", e); | |
1586 | } | |
1587 | } | |
1588 | ||
206d4967 AD |
1589 | function offlineDownloadStop() { |
1590 | try { | |
1591 | if (db && sync_in_progress && getInitParam("offline_enabled") == "1") { | |
8ca1a0ac AD |
1592 | |
1593 | sync_in_progress = false; | |
1594 | ||
1595 | if (sync_timer) { | |
1596 | window.clearTimeout(sync_timer); | |
1597 | sync_timer = false; | |
1598 | } | |
1599 | ||
1600 | var pic = $("offlineModePic"); | |
1601 | ||
1602 | if (pic) { | |
1603 | pic.src = "images/offline.png"; | |
1604 | var msg = __("Last sync: Cancelled."); | |
1605 | articles_synced = 0; | |
1606 | $("offlineModeSyncMsg").innerHTML = msg; | |
1607 | } | |
1608 | ||
1609 | offlineSyncShowHideElems(false); | |
1610 | ||
206d4967 AD |
1611 | } |
1612 | } catch (e) { | |
1613 | exception_error("offlineDownloadStart", e); | |
1614 | } | |
1615 | } | |
1616 | ||
79e565a9 AD |
1617 | function offlineClearData() { |
1618 | try { | |
1619 | if (db) { | |
1620 | ||
b4dc02e2 | 1621 | if (confirm(__("This will remove all offline data stored by Tiny Tiny RSS on this computer. Continue?"))) { |
79e565a9 AD |
1622 | |
1623 | notify_progress("Removing offline data..."); | |
1624 | ||
b4dc02e2 AD |
1625 | localServer.removeManagedStore("tt-rss"); |
1626 | ||
79e565a9 AD |
1627 | db.execute("DELETE FROM articles"); |
1628 | db.execute("DELETE FROM article_labels"); | |
1629 | db.execute("DELETE FROM labels"); | |
1630 | db.execute("DELETE FROM feeds"); | |
8ca1a0ac | 1631 | db.execute("DELETE FROM cache"); |
79e565a9 | 1632 | |
8ca1a0ac | 1633 | notify_info("Local data removed."); |
79e565a9 AD |
1634 | } |
1635 | } | |
1636 | } catch (e) { | |
1637 | exception_error("offlineClearData", e); | |
1638 | } | |
1639 | } | |
206d4967 AD |
1640 | |
1641 | function offlineUpdateStore() { | |
1642 | try { | |
1643 | ||
1644 | if (offline_mode) return; | |
1645 | ||
1646 | } catch (e) { | |
1647 | exception_error("offlineUpdateStore", e); | |
1648 | } | |
1649 | } | |
8ca1a0ac AD |
1650 | |
1651 | function offlineSyncShowHideElems(syncing) { | |
1652 | try { | |
1653 | ||
1654 | var elems = $$("div.hideWhenSyncing"); | |
1655 | ||
1656 | for (var j = 0; j < elems.length; j++) { | |
1657 | if (syncing) { | |
1658 | Element.hide(elems[j]); | |
1659 | } else { | |
1660 | Element.show(elems[j]); | |
1661 | } | |
1662 | } | |
1663 | ||
1664 | var elems = $$("div.showWhenSyncing"); | |
1665 | ||
1666 | for (var j = 0; j < elems.length; j++) { | |
1667 | if (syncing) { | |
1668 | Element.show(elems[j]); | |
1669 | } else { | |
1670 | Element.hide(elems[j]); | |
1671 | } | |
1672 | } | |
1673 | ||
1674 | } catch (e) { | |
1675 | exception_error("offlineSyncShowHideElems", e); | |
1676 | } | |
1677 | } |