viewfeed.js 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389
  1. var article_cache = new Array();
  2. var _active_article_id = 0;
  3. var vgroup_last_feed = false;
  4. var post_under_pointer = false;
  5. var last_requested_article = false;
  6. var catchup_id_batch = [];
  7. var catchup_timeout_id = false;
  8. var cids_requested = [];
  9. var loaded_article_ids = [];
  10. var _last_headlines_update = 0;
  11. var has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null;
  12. function headlines_callback2(transport, offset, background, infscroll_req) {
  13. try {
  14. handle_rpc_json(transport);
  15. console.log("headlines_callback2 [offset=" + offset + "] B:" + background + " I:" + infscroll_req);
  16. var is_cat = false;
  17. var feed_id = false;
  18. var reply = false;
  19. try {
  20. reply = JSON.parse(transport.responseText);
  21. } catch (e) {
  22. console.error(e);
  23. }
  24. if (reply) {
  25. is_cat = reply['headlines']['is_cat'];
  26. feed_id = reply['headlines']['id'];
  27. if (background) {
  28. var content = reply['headlines']['content'];
  29. content = content + "<div id='headlines-spacer'></div>";
  30. return;
  31. }
  32. if (feed_id != getActiveFeedId() || is_cat != activeFeedIsCat())
  33. return;
  34. /* dijit.getEnclosingWidget(
  35. document.forms["main_toolbar_form"].update).attr('disabled',
  36. is_cat || feed_id <= 0); */
  37. try {
  38. if (infscroll_req == false) {
  39. $("headlines-frame").scrollTop = 0;
  40. Element.hide("floatingTitle");
  41. $("floatingTitle").setAttribute("rowid", 0);
  42. $("floatingTitle").innerHTML = "";
  43. }
  44. } catch (e) { };
  45. $("headlines-frame").removeClassName("cdm");
  46. $("headlines-frame").removeClassName("normal");
  47. $("headlines-frame").addClassName(isCdmMode() ? "cdm" : "normal");
  48. var headlines_count = reply['headlines-info']['count'];
  49. vgroup_last_feed = reply['headlines-info']['vgroup_last_feed'];
  50. if (parseInt(headlines_count) < 30) {
  51. _infscroll_disable = 1;
  52. } else {
  53. _infscroll_disable = 0;
  54. }
  55. var counters = reply['counters'];
  56. var articles = reply['articles'];
  57. //var runtime_info = reply['runtime-info'];
  58. if (infscroll_req == false) {
  59. loaded_article_ids = [];
  60. dijit.byId("headlines-frame").attr('content',
  61. reply['headlines']['content']);
  62. //dijit.byId("headlines-toolbar").attr('content',
  63. // reply['headlines']['toolbar']);
  64. dojo.html.set($("headlines-toolbar"),
  65. reply['headlines']['toolbar'],
  66. {parseContent: true});
  67. $$("#headlines-frame > div[id*=RROW]").each(function(row) {
  68. if (loaded_article_ids.indexOf(row.id) != -1) {
  69. row.parentNode.removeChild(row);
  70. } else {
  71. loaded_article_ids.push(row.id);
  72. }
  73. });
  74. var hsp = $("headlines-spacer");
  75. if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
  76. dijit.byId('headlines-frame').domNode.appendChild(hsp);
  77. initHeadlinesMenu();
  78. if (_search_query) {
  79. $("feed_title").innerHTML += "<span id='cancel_search'>" +
  80. " (<a href='#' onclick='cancelSearch()'>" + __("Cancel search") + "</a>)" +
  81. "</span>";
  82. }
  83. } else {
  84. if (headlines_count > 0 && feed_id == getActiveFeedId() && is_cat == activeFeedIsCat()) {
  85. console.log("adding some more headlines: " + headlines_count);
  86. var c = dijit.byId("headlines-frame");
  87. var ids = getSelectedArticleIds2();
  88. var new_elems = [];
  89. $("headlines-tmp").innerHTML = reply['headlines']['content'];
  90. var hsp = $("headlines-spacer");
  91. if (hsp)
  92. c.domNode.removeChild(hsp);
  93. $$("#headlines-tmp > div").each(function(row) {
  94. if (row.className == 'cdmFeedTitle') {
  95. row.style.display = 'none';
  96. c.domNode.appendChild(row);
  97. new_elems.push(row);
  98. } else if (loaded_article_ids.indexOf(row.id) == -1) {
  99. row.style.display = 'none';
  100. c.domNode.appendChild(row);
  101. new_elems.push(row);
  102. loaded_article_ids.push(row.id);
  103. } else {
  104. row.parentNode.removeChild(row);
  105. }
  106. });
  107. if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
  108. if (getInitParam("cdm_auto_catchup") == 1) {
  109. c.domNode.appendChild(hsp);
  110. }
  111. console.log("added " + new_elems.size() + " headlines");
  112. if (new_elems.size() == 0)
  113. _infscroll_disable = true;
  114. console.log("restore selected ids: " + ids);
  115. for (var i = 0; i < ids.length; i++) {
  116. markHeadline(ids[i]);
  117. }
  118. initHeadlinesMenu();
  119. new_elems.each(function(child) {
  120. dojo.parser.parse(child);
  121. if (!Element.visible(child))
  122. new Effect.Appear(child, { duration : 0.5 });
  123. });
  124. } else {
  125. console.log("no new headlines received");
  126. var hsp = $("headlines-spacer");
  127. if (hsp) hsp.innerHTML = "";
  128. }
  129. }
  130. if (articles) {
  131. for (var i = 0; i < articles.length; i++) {
  132. var a_id = articles[i]['id'];
  133. cache_set("article:" + a_id, articles[i]['content']);
  134. }
  135. } else {
  136. console.log("no cached articles received");
  137. }
  138. if (counters)
  139. parse_counters(counters);
  140. else
  141. request_counters(true);
  142. } else if (transport.responseText) {
  143. console.error("Invalid object received: " + transport.responseText);
  144. dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
  145. __('Could not update headlines (invalid object received - see error console for details)') +
  146. "</div>");
  147. } else {
  148. //notify_error("Error communicating with server.");
  149. Element.show(dijit.byId("net-alert").domNode);
  150. }
  151. _infscroll_request_sent = 0;
  152. _last_headlines_update = new Date().getTime();
  153. unpackVisibleHeadlines();
  154. // if we have some more space in the buffer, why not try to fill it
  155. if (!_infscroll_disable && $("headlines-spacer") &&
  156. $("headlines-spacer").offsetTop < $("headlines-frame").offsetHeight) {
  157. window.setTimeout(function() {
  158. loadMoreHeadlines();
  159. }, 250);
  160. }
  161. notify("");
  162. } catch (e) {
  163. exception_error("headlines_callback2", e, transport);
  164. }
  165. }
  166. function render_article(article) {
  167. try {
  168. dijit.byId("headlines-wrap-inner").addChild(
  169. dijit.byId("content-insert"));
  170. var c = dijit.byId("content-insert");
  171. try {
  172. c.domNode.scrollTop = 0;
  173. } catch (e) { };
  174. PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED, article);
  175. c.attr('content', article);
  176. correctHeadlinesOffset(getActiveArticleId());
  177. try {
  178. c.focus();
  179. } catch (e) { };
  180. } catch (e) {
  181. exception_error("render_article", e);
  182. }
  183. }
  184. function showArticleInHeadlines(id, noexpand) {
  185. try {
  186. selectArticles("none");
  187. var crow = $("RROW-" + id);
  188. if (!crow) return;
  189. var article_is_unread = crow.hasClassName("Unread");
  190. if (!noexpand)
  191. crow.removeClassName("Unread");
  192. crow.addClassName("active");
  193. selectArticles('none');
  194. var view_mode = false;
  195. try {
  196. view_mode = document.forms['main_toolbar_form'].view_mode;
  197. view_mode = view_mode[view_mode.selectedIndex].value;
  198. } catch (e) {
  199. //
  200. }
  201. markHeadline(id);
  202. if (article_is_unread && !noexpand)
  203. _force_scheduled_update = true;
  204. } catch (e) {
  205. exception_error("showArticleInHeadlines", e);
  206. }
  207. }
  208. function article_callback2(transport, id) {
  209. try {
  210. console.log("article_callback2 " + id);
  211. handle_rpc_json(transport);
  212. var reply = false;
  213. try {
  214. reply = JSON.parse(transport.responseText);
  215. } catch (e) {
  216. console.error(e);
  217. }
  218. if (reply) {
  219. reply.each(function(article) {
  220. if (getActiveArticleId() == article['id']) {
  221. render_article(article['content']);
  222. }
  223. cids_requested.remove(article['id']);
  224. cache_set("article:" + article['id'], article['content']);
  225. });
  226. // if (id != last_requested_article) {
  227. // console.log("requested article id is out of sequence, aborting");
  228. // return;
  229. // }
  230. } else if (transport.responseText) {
  231. console.error("Invalid object received: " + transport.responseText);
  232. render_article("<div class='whiteBox'>" +
  233. __('Could not display article (invalid object received - see error console for details)') + "</div>");
  234. } else {
  235. Element.show(dijit.byId("net-alert").domNode);
  236. }
  237. var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
  238. request_counters(unread_in_buffer == 0);
  239. //headlines_scroll_handler($("headlines-frame"));
  240. /* try {
  241. if (!_infscroll_disable &&
  242. $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
  243. loadMoreHeadlines();
  244. }
  245. } catch (e) {
  246. console.warn(e);
  247. } */
  248. notify("");
  249. } catch (e) {
  250. exception_error("article_callback2", e, transport);
  251. }
  252. }
  253. function view(id, activefeed, noexpand) {
  254. try {
  255. var oldrow = $("RROW-" + getActiveArticleId());
  256. if (oldrow) oldrow.removeClassName("active");
  257. var crow = $("RROW-" + id);
  258. if (!crow) return;
  259. if (noexpand) {
  260. setActiveArticleId(id);
  261. showArticleInHeadlines(id, noexpand);
  262. return;
  263. }
  264. console.log("loading article: " + id);
  265. var cached_article = cache_get("article:" + id);
  266. console.log("cache check result: " + (cached_article != false));
  267. var query = "?op=article&method=view&id=" + param_escape(id);
  268. var neighbor_ids = getRelativePostIds(id);
  269. /* only request uncached articles */
  270. var cids_to_request = [];
  271. for (var i = 0; i < neighbor_ids.length; i++) {
  272. if (cids_requested.indexOf(neighbor_ids[i]) == -1)
  273. if (!cache_get("article:" + neighbor_ids[i])) {
  274. cids_to_request.push(neighbor_ids[i]);
  275. cids_requested.push(neighbor_ids[i]);
  276. }
  277. }
  278. console.log("additional ids: " + cids_to_request.toString());
  279. query = query + "&cids=" + cids_to_request.toString();
  280. var article_is_unread = crow.hasClassName("Unread");
  281. setActiveArticleId(id);
  282. showArticleInHeadlines(id);
  283. if (cached_article && article_is_unread) {
  284. query = query + "&mode=prefetch";
  285. render_article(cached_article);
  286. } else if (cached_article) {
  287. query = query + "&mode=prefetch_old";
  288. render_article(cached_article);
  289. // if we don't need to request any relative ids, we might as well skip
  290. // the server roundtrip altogether
  291. if (cids_to_request.length == 0) {
  292. /* try {
  293. if (!_infscroll_disable &&
  294. $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
  295. loadMoreHeadlines();
  296. }
  297. } catch (e) {
  298. console.warn(e);
  299. } */
  300. //headlines_scroll_handler($("headlines-frame"));
  301. return;
  302. }
  303. }
  304. last_requested_article = id;
  305. console.log(query);
  306. if (article_is_unread) {
  307. decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
  308. }
  309. new Ajax.Request("backend.php", {
  310. parameters: query,
  311. onComplete: function(transport) {
  312. article_callback2(transport, id);
  313. } });
  314. return false;
  315. } catch (e) {
  316. exception_error("view", e);
  317. }
  318. }
  319. function toggleMark(id, client_only) {
  320. try {
  321. var query = "?op=rpc&id=" + id + "&method=mark";
  322. var row = $("RROW-" + id);
  323. if (!row) return;
  324. var imgs = [];
  325. var row_imgs = row.getElementsByClassName("markedPic");
  326. for (var i = 0; i < row_imgs.length; i++)
  327. imgs.push(row_imgs[i]);
  328. var ft = $("floatingTitle");
  329. if (ft && ft.getAttribute("rowid") == "RROW-" + id) {
  330. var fte = ft.getElementsByClassName("markedPic");
  331. for (var i = 0; i < fte.length; i++)
  332. imgs.push(fte[i]);
  333. }
  334. for (i = 0; i < imgs.length; i++) {
  335. var img = imgs[i];
  336. if (!row.hasClassName("marked")) {
  337. img.src = img.src.replace("mark_unset", "mark_set");
  338. img.alt = __("Unstar article");
  339. query = query + "&mark=1";
  340. } else {
  341. img.src = img.src.replace("mark_set", "mark_unset");
  342. img.alt = __("Star article");
  343. query = query + "&mark=0";
  344. }
  345. }
  346. row.toggleClassName("marked");
  347. if (!client_only) {
  348. new Ajax.Request("backend.php", {
  349. parameters: query,
  350. onComplete: function(transport) {
  351. handle_rpc_json(transport);
  352. } });
  353. }
  354. } catch (e) {
  355. exception_error("toggleMark", e);
  356. }
  357. }
  358. function togglePub(id, client_only, no_effects, note) {
  359. try {
  360. var query = "?op=rpc&id=" + id + "&method=publ";
  361. if (note != undefined) {
  362. query = query + "&note=" + param_escape(note);
  363. } else {
  364. query = query + "&note=undefined";
  365. }
  366. var row = $("RROW-" + id);
  367. if (!row) return;
  368. var imgs = [];
  369. var row_imgs = row.getElementsByClassName("pubPic");
  370. for (var i = 0; i < row_imgs.length; i++)
  371. imgs.push(row_imgs[i]);
  372. var ft = $("floatingTitle");
  373. if (ft && ft.getAttribute("rowid") == "RROW-" + id) {
  374. var fte = ft.getElementsByClassName("pubPic");
  375. for (var i = 0; i < fte.length; i++)
  376. imgs.push(fte[i]);
  377. }
  378. for (i = 0; i < imgs.length; i++) {
  379. var img = imgs[i];
  380. if (!row.hasClassName("published") || note != undefined) {
  381. img.src = img.src.replace("pub_unset", "pub_set");
  382. img.alt = __("Unpublish article");
  383. query = query + "&pub=1";
  384. } else {
  385. img.src = img.src.replace("pub_set", "pub_unset");
  386. img.alt = __("Publish article");
  387. query = query + "&pub=0";
  388. }
  389. }
  390. if (note != undefined)
  391. row.addClassName("published");
  392. else
  393. row.toggleClassName("published");
  394. if (!client_only) {
  395. new Ajax.Request("backend.php", {
  396. parameters: query,
  397. onComplete: function(transport) {
  398. handle_rpc_json(transport);
  399. } });
  400. }
  401. } catch (e) {
  402. exception_error("togglePub", e);
  403. }
  404. }
  405. function moveToPost(mode, noscroll, noexpand) {
  406. try {
  407. var rows = getVisibleArticleIds();
  408. var prev_id = false;
  409. var next_id = false;
  410. if (!$('RROW-' + getActiveArticleId())) {
  411. setActiveArticleId(0);
  412. }
  413. if (!getActiveArticleId()) {
  414. next_id = rows[0];
  415. prev_id = rows[rows.length-1]
  416. } else {
  417. for (var i = 0; i < rows.length; i++) {
  418. if (rows[i] == getActiveArticleId()) {
  419. // Account for adjacent identical article ids.
  420. if (i > 0) prev_id = rows[i-1];
  421. for (var j = i+1; j < rows.length; j++) {
  422. if (rows[j] != getActiveArticleId()) {
  423. next_id = rows[j];
  424. break;
  425. }
  426. }
  427. break;
  428. }
  429. }
  430. }
  431. if (mode == "next") {
  432. if (next_id || getActiveArticleId()) {
  433. if (isCdmMode()) {
  434. var article = $("RROW-" + getActiveArticleId());
  435. var ctr = $("headlines-frame");
  436. if (!noscroll && article && article.offsetTop + article.offsetHeight >
  437. ctr.scrollTop + ctr.offsetHeight) {
  438. scrollArticle(ctr.offsetHeight/4);
  439. } else if (next_id) {
  440. cdmExpandArticle(next_id, noexpand);
  441. cdmScrollToArticleId(next_id, true);
  442. }
  443. } else if (next_id) {
  444. correctHeadlinesOffset(next_id);
  445. view(next_id, getActiveFeedId(), noexpand);
  446. }
  447. }
  448. }
  449. if (mode == "prev") {
  450. if (prev_id || getActiveArticleId()) {
  451. if (isCdmMode()) {
  452. var article = $("RROW-" + getActiveArticleId());
  453. var prev_article = $("RROW-" + prev_id);
  454. var ctr = $("headlines-frame");
  455. if (!getInitParam("cdm_expanded")) {
  456. if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
  457. scrollArticle(-ctr.offsetHeight/4);
  458. } else {
  459. cdmExpandArticle(prev_id, noexpand);
  460. cdmScrollToArticleId(prev_id, true);
  461. }
  462. } else {
  463. if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
  464. scrollArticle(-ctr.offsetHeight/3);
  465. } else if (!noscroll && prev_article &&
  466. prev_article.offsetTop < ctr.scrollTop) {
  467. cdmExpandArticle(prev_id, noexpand);
  468. scrollArticle(-ctr.offsetHeight/4);
  469. } else if (prev_id) {
  470. cdmExpandArticle(prev_id, noexpand);
  471. cdmScrollToArticleId(prev_id, noscroll);
  472. }
  473. }
  474. } else if (prev_id) {
  475. correctHeadlinesOffset(prev_id);
  476. view(prev_id, getActiveFeedId(), noexpand);
  477. }
  478. }
  479. }
  480. } catch (e) {
  481. exception_error("moveToPost", e);
  482. }
  483. }
  484. function toggleSelected(id, force_on) {
  485. try {
  486. var row = $("RROW-" + id);
  487. if (row) {
  488. var cb = dijit.getEnclosingWidget(
  489. row.getElementsByClassName("rchk")[0]);
  490. if (row.hasClassName('Selected') && !force_on) {
  491. row.removeClassName('Selected');
  492. if (cb) cb.attr("checked", false);
  493. } else {
  494. row.addClassName('Selected');
  495. if (cb) cb.attr("checked", true);
  496. }
  497. }
  498. updateSelectedPrompt();
  499. } catch (e) {
  500. exception_error("toggleSelected", e);
  501. }
  502. }
  503. function updateSelectedPrompt() {
  504. try {
  505. var count = getSelectedArticleIds2().size();
  506. var elem = $("selected_prompt");
  507. if (elem) {
  508. elem.innerHTML = ngettext("%d article selected",
  509. "%d articles selected", count).replace("%d", count);
  510. if (count > 0)
  511. Element.show(elem);
  512. else
  513. Element.hide(elem);
  514. }
  515. } catch (e) {
  516. exception_error("updateSelectedPrompt", e);
  517. }
  518. }
  519. function toggleUnread_afh(effect) {
  520. try {
  521. var elem = effect.element;
  522. elem.style.backgroundColor = "";
  523. } catch (e) {
  524. exception_error("toggleUnread_afh", e);
  525. }
  526. }
  527. function toggleUnread(id, cmode, effect) {
  528. try {
  529. var row = $("RROW-" + id);
  530. if (row) {
  531. if (cmode == undefined || cmode == 2) {
  532. if (row.hasClassName("Unread")) {
  533. row.removeClassName("Unread");
  534. } else {
  535. row.addClassName("Unread");
  536. }
  537. } else if (cmode == 0) {
  538. row.removeClassName("Unread");
  539. } else if (cmode == 1) {
  540. row.addClassName("Unread");
  541. }
  542. if (cmode == undefined) cmode = 2;
  543. var query = "?op=rpc&method=catchupSelected" +
  544. "&cmode=" + param_escape(cmode) + "&ids=" + param_escape(id);
  545. // notify_progress("Loading, please wait...");
  546. new Ajax.Request("backend.php", {
  547. parameters: query,
  548. onComplete: function(transport) {
  549. handle_rpc_json(transport);
  550. } });
  551. }
  552. } catch (e) {
  553. exception_error("toggleUnread", e);
  554. }
  555. }
  556. function selectionRemoveLabel(id, ids) {
  557. try {
  558. if (!ids) ids = getSelectedArticleIds2();
  559. if (ids.length == 0) {
  560. alert(__("No articles are selected."));
  561. return;
  562. }
  563. var query = "?op=article&method=removeFromLabel&ids=" +
  564. param_escape(ids.toString()) + "&lid=" + param_escape(id);
  565. console.log(query);
  566. new Ajax.Request("backend.php", {
  567. parameters: query,
  568. onComplete: function(transport) {
  569. handle_rpc_json(transport);
  570. show_labels_in_headlines(transport);
  571. } });
  572. } catch (e) {
  573. exception_error("selectionAssignLabel", e);
  574. }
  575. }
  576. function selectionAssignLabel(id, ids) {
  577. try {
  578. if (!ids) ids = getSelectedArticleIds2();
  579. if (ids.length == 0) {
  580. alert(__("No articles are selected."));
  581. return;
  582. }
  583. var query = "?op=article&method=assignToLabel&ids=" +
  584. param_escape(ids.toString()) + "&lid=" + param_escape(id);
  585. console.log(query);
  586. new Ajax.Request("backend.php", {
  587. parameters: query,
  588. onComplete: function(transport) {
  589. handle_rpc_json(transport);
  590. show_labels_in_headlines(transport);
  591. } });
  592. } catch (e) {
  593. exception_error("selectionAssignLabel", e);
  594. }
  595. }
  596. function selectionToggleUnread(set_state, callback, no_error, ids) {
  597. try {
  598. var rows = ids ? ids : getSelectedArticleIds2();
  599. if (rows.length == 0 && !no_error) {
  600. alert(__("No articles are selected."));
  601. return;
  602. }
  603. for (var i = 0; i < rows.length; i++) {
  604. var row = $("RROW-" + rows[i]);
  605. if (row) {
  606. if (set_state == undefined) {
  607. if (row.hasClassName("Unread")) {
  608. row.removeClassName("Unread");
  609. } else {
  610. row.addClassName("Unread");
  611. }
  612. }
  613. if (set_state == false) {
  614. row.removeClassName("Unread");
  615. }
  616. if (set_state == true) {
  617. row.addClassName("Unread");
  618. }
  619. }
  620. }
  621. updateFloatingTitle(true);
  622. if (rows.length > 0) {
  623. var cmode = "";
  624. if (set_state == undefined) {
  625. cmode = "2";
  626. } else if (set_state == true) {
  627. cmode = "1";
  628. } else if (set_state == false) {
  629. cmode = "0";
  630. }
  631. var query = "?op=rpc&method=catchupSelected" +
  632. "&cmode=" + cmode + "&ids=" + param_escape(rows.toString());
  633. notify_progress("Loading, please wait...");
  634. new Ajax.Request("backend.php", {
  635. parameters: query,
  636. onComplete: function(transport) {
  637. handle_rpc_json(transport);
  638. if (callback) callback(transport);
  639. } });
  640. }
  641. } catch (e) {
  642. exception_error("selectionToggleUnread", e);
  643. }
  644. }
  645. // sel_state ignored
  646. function selectionToggleMarked(sel_state, callback, no_error, ids) {
  647. try {
  648. var rows = ids ? ids : getSelectedArticleIds2();
  649. if (rows.length == 0 && !no_error) {
  650. alert(__("No articles are selected."));
  651. return;
  652. }
  653. for (var i = 0; i < rows.length; i++) {
  654. toggleMark(rows[i], true, true);
  655. }
  656. if (rows.length > 0) {
  657. var query = "?op=rpc&method=markSelected&ids=" +
  658. param_escape(rows.toString()) + "&cmode=2";
  659. new Ajax.Request("backend.php", {
  660. parameters: query,
  661. onComplete: function(transport) {
  662. handle_rpc_json(transport);
  663. if (callback) callback(transport);
  664. } });
  665. }
  666. } catch (e) {
  667. exception_error("selectionToggleMarked", e);
  668. }
  669. }
  670. // sel_state ignored
  671. function selectionTogglePublished(sel_state, callback, no_error, ids) {
  672. try {
  673. var rows = ids ? ids : getSelectedArticleIds2();
  674. if (rows.length == 0 && !no_error) {
  675. alert(__("No articles are selected."));
  676. return;
  677. }
  678. for (var i = 0; i < rows.length; i++) {
  679. togglePub(rows[i], true, true);
  680. }
  681. if (rows.length > 0) {
  682. var query = "?op=rpc&method=publishSelected&ids=" +
  683. param_escape(rows.toString()) + "&cmode=2";
  684. new Ajax.Request("backend.php", {
  685. parameters: query,
  686. onComplete: function(transport) {
  687. handle_rpc_json(transport);
  688. } });
  689. }
  690. } catch (e) {
  691. exception_error("selectionToggleMarked", e);
  692. }
  693. }
  694. function getSelectedArticleIds2() {
  695. var rv = [];
  696. $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
  697. function(child) {
  698. rv.push(child.id.replace("RROW-", ""));
  699. });
  700. return rv;
  701. }
  702. function getLoadedArticleIds() {
  703. var rv = [];
  704. var children = $$("#headlines-frame > div[id*=RROW-]");
  705. children.each(function(child) {
  706. rv.push(child.id.replace("RROW-", ""));
  707. });
  708. return rv;
  709. }
  710. // mode = all,none,unread,invert,marked,published
  711. function selectArticles(mode, query) {
  712. try {
  713. if (!query) query = "#headlines-frame > div[id*=RROW]";
  714. var children = $$(query);
  715. children.each(function(child) {
  716. var id = child.id.replace("RROW-", "");
  717. var cb = dijit.getEnclosingWidget(
  718. child.getElementsByClassName("rchk")[0]);
  719. if (mode == "all") {
  720. child.addClassName("Selected");
  721. if (cb) cb.attr("checked", true);
  722. } else if (mode == "unread") {
  723. if (child.hasClassName("Unread")) {
  724. child.addClassName("Selected");
  725. if (cb) cb.attr("checked", true);
  726. } else {
  727. child.removeClassName("Selected");
  728. if (cb) cb.attr("checked", false);
  729. }
  730. } else if (mode == "marked") {
  731. if (child.hasClassName("marked")) {
  732. child.addClassName("Selected");
  733. if (cb) cb.attr("checked", true);
  734. } else {
  735. child.removeClassName("Selected");
  736. if (cb) cb.attr("checked", false);
  737. }
  738. } else if (mode == "published") {
  739. if (child.hasClassName("published")) {
  740. child.addClassName("Selected");
  741. if (cb) cb.attr("checked", true);
  742. } else {
  743. child.removeClassName("Selected");
  744. if (cb) cb.attr("checked", false);
  745. }
  746. } else if (mode == "invert") {
  747. if (child.hasClassName("Selected")) {
  748. child.removeClassName("Selected");
  749. if (cb) cb.attr("checked", false);
  750. } else {
  751. child.addClassName("Selected");
  752. if (cb) cb.attr("checked", true);
  753. }
  754. } else {
  755. child.removeClassName("Selected");
  756. if (cb) cb.attr("checked", false);
  757. }
  758. });
  759. updateSelectedPrompt();
  760. } catch (e) {
  761. exception_error("selectArticles", e);
  762. }
  763. }
  764. function deleteSelection() {
  765. try {
  766. var rows = getSelectedArticleIds2();
  767. if (rows.length == 0) {
  768. alert(__("No articles are selected."));
  769. return;
  770. }
  771. var fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
  772. var str;
  773. if (getActiveFeedId() != 0) {
  774. str = ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?" , rows.length);
  775. } else {
  776. str = ngettext("Delete %d selected article?", "Delete %d selected articles?", rows.length);
  777. }
  778. str = str.replace("%d", rows.length);
  779. str = str.replace("%s", fn);
  780. if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
  781. return;
  782. }
  783. query = "?op=rpc&method=delete&ids=" + param_escape(rows);
  784. console.log(query);
  785. new Ajax.Request("backend.php", {
  786. parameters: query,
  787. onComplete: function(transport) {
  788. handle_rpc_json(transport);
  789. viewCurrentFeed();
  790. } });
  791. } catch (e) {
  792. exception_error("deleteSelection", e);
  793. }
  794. }
  795. function archiveSelection() {
  796. try {
  797. var rows = getSelectedArticleIds2();
  798. if (rows.length == 0) {
  799. alert(__("No articles are selected."));
  800. return;
  801. }
  802. var fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
  803. var str;
  804. var op;
  805. if (getActiveFeedId() != 0) {
  806. str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length);
  807. op = "archive";
  808. } else {
  809. str = ngettext("Move %d archived article back?", "Move %d archived articles back?", rows.length);
  810. str += " " + __("Please note that unstarred articles might get purged on next feed update.");
  811. op = "unarchive";
  812. }
  813. str = str.replace("%d", rows.length);
  814. str = str.replace("%s", fn);
  815. if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
  816. return;
  817. }
  818. query = "?op=rpc&method="+op+"&ids=" + param_escape(rows);
  819. console.log(query);
  820. for (var i = 0; i < rows.length; i++) {
  821. cache_delete("article:" + rows[i]);
  822. }
  823. new Ajax.Request("backend.php", {
  824. parameters: query,
  825. onComplete: function(transport) {
  826. handle_rpc_json(transport);
  827. viewCurrentFeed();
  828. } });
  829. } catch (e) {
  830. exception_error("archiveSelection", e);
  831. }
  832. }
  833. function catchupSelection() {
  834. try {
  835. var rows = getSelectedArticleIds2();
  836. if (rows.length == 0) {
  837. alert(__("No articles are selected."));
  838. return;
  839. }
  840. var fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
  841. var str = ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows.length);
  842. str = str.replace("%d", rows.length);
  843. str = str.replace("%s", fn);
  844. if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
  845. return;
  846. }
  847. selectionToggleUnread(false, 'viewCurrentFeed()', true);
  848. } catch (e) {
  849. exception_error("catchupSelection", e);
  850. }
  851. }
  852. function editArticleTags(id) {
  853. var query = "backend.php?op=article&method=editArticleTags&param=" + param_escape(id);
  854. if (dijit.byId("editTagsDlg"))
  855. dijit.byId("editTagsDlg").destroyRecursive();
  856. dialog = new dijit.Dialog({
  857. id: "editTagsDlg",
  858. title: __("Edit article Tags"),
  859. style: "width: 600px",
  860. execute: function() {
  861. if (this.validate()) {
  862. var query = dojo.objectToQuery(this.attr('value'));
  863. notify_progress("Saving article tags...", true);
  864. new Ajax.Request("backend.php", {
  865. parameters: query,
  866. onComplete: function(transport) {
  867. try {
  868. notify('');
  869. dialog.hide();
  870. var data = JSON.parse(transport.responseText);
  871. if (data) {
  872. var id = data.id;
  873. console.log(id);
  874. var tags = $("ATSTR-" + id);
  875. var tooltip = dijit.byId("ATSTRTIP-" + id);
  876. if (tags) tags.innerHTML = data.content;
  877. if (tooltip) tooltip.attr('label', data.content_full);
  878. }
  879. } catch (e) {
  880. exception_error("editArticleTags/inner", e);
  881. }
  882. }});
  883. }
  884. },
  885. href: query,
  886. });
  887. var tmph = dojo.connect(dialog, 'onLoad', function() {
  888. dojo.disconnect(tmph);
  889. new Ajax.Autocompleter('tags_str', 'tags_choices',
  890. "backend.php?op=article&method=completeTags",
  891. { tokens: ',', paramName: "search" });
  892. });
  893. dialog.show();
  894. }
  895. function cdmScrollToArticleId(id, force) {
  896. try {
  897. var ctr = $("headlines-frame");
  898. var e = $("RROW-" + id);
  899. if (!e || !ctr) return;
  900. if (force || e.offsetTop+e.offsetHeight > (ctr.scrollTop+ctr.offsetHeight) ||
  901. e.offsetTop < ctr.scrollTop) {
  902. // expanded cdm has a 4px margin now
  903. ctr.scrollTop = parseInt(e.offsetTop) - 4;
  904. }
  905. } catch (e) {
  906. exception_error("cdmScrollToArticleId", e);
  907. }
  908. }
  909. function setActiveArticleId(id) {
  910. _active_article_id = id;
  911. PluginHost.run(PluginHost.HOOK_ARTICLE_SET_ACTIVE, _active_article_id);
  912. }
  913. function getActiveArticleId() {
  914. return _active_article_id;
  915. }
  916. function postMouseIn(e, id) {
  917. post_under_pointer = id;
  918. }
  919. function postMouseOut(id) {
  920. post_under_pointer = false;
  921. }
  922. function unpackVisibleHeadlines() {
  923. try {
  924. if (!isCdmMode() || !getInitParam("cdm_expanded")) return;
  925. $$("#headlines-frame > div[id*=RROW]").each(
  926. function(child) {
  927. if (child.offsetTop <= $("headlines-frame").scrollTop +
  928. $("headlines-frame").offsetHeight) {
  929. var cencw = $("CENCW-" + child.id.replace("RROW-", ""));
  930. if (cencw) {
  931. PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, child);
  932. cencw.innerHTML = htmlspecialchars_decode(cencw.innerHTML);
  933. cencw.setAttribute('id', '');
  934. Element.show(cencw);
  935. }
  936. }
  937. }
  938. );
  939. } catch (e) {
  940. exception_error("unpackVisibleHeadlines", e);
  941. }
  942. }
  943. function headlines_scroll_handler(e) {
  944. try {
  945. var hsp = $("headlines-spacer");
  946. unpackVisibleHeadlines();
  947. // set topmost child in the buffer as active
  948. if (isCdmMode() && getInitParam("cdm_auto_catchup") == 1 &&
  949. getSelectedArticleIds2().length <= 1 &&
  950. getInitParam("cdm_expanded")) {
  951. var rows = $$("#headlines-frame > div[id*=RROW]");
  952. for (var i = 0; i < rows.length; i++) {
  953. var child = rows[i];
  954. if ($("headlines-frame").scrollTop <= child.offsetTop &&
  955. child.offsetTop - $("headlines-frame").scrollTop < 100 &&
  956. child.id.replace("RROW-", "") != _active_article_id) {
  957. if (_active_article_id) {
  958. var row = $("RROW-" + _active_article_id);
  959. if (row) row.removeClassName("active");
  960. }
  961. _active_article_id = child.id.replace("RROW-", "");
  962. showArticleInHeadlines(_active_article_id, true);
  963. updateSelectedPrompt();
  964. break;
  965. }
  966. }
  967. }
  968. if (!_infscroll_disable) {
  969. if ((hsp && e.scrollTop + e.offsetHeight >= hsp.offsetTop - hsp.offsetHeight) ||
  970. (e.scrollHeight != 0 &&
  971. ((e.scrollTop + e.offsetHeight) / e.scrollHeight >= 0.7))) {
  972. if (hsp)
  973. hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
  974. __("Loading, please wait...");
  975. loadMoreHeadlines();
  976. return;
  977. }
  978. } else {
  979. if (hsp) hsp.innerHTML = "";
  980. }
  981. if (isCdmMode()) {
  982. updateFloatingTitle();
  983. }
  984. if (getInitParam("cdm_auto_catchup") == 1) {
  985. // let's get DOM some time to settle down
  986. var ts = new Date().getTime();
  987. if (ts - _last_headlines_update < 100) return;
  988. $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
  989. function(child) {
  990. if (child.hasClassName("Unread") && $("headlines-frame").scrollTop >
  991. (child.offsetTop + child.offsetHeight/2)) {
  992. var id = child.id.replace("RROW-", "");
  993. if (catchup_id_batch.indexOf(id) == -1)
  994. catchup_id_batch.push(id);
  995. //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
  996. }
  997. });
  998. if (catchup_id_batch.length > 0) {
  999. window.clearTimeout(catchup_timeout_id);
  1000. if (!_infscroll_request_sent) {
  1001. catchup_timeout_id = window.setTimeout('catchupBatchedArticles()',
  1002. 500);
  1003. }
  1004. }
  1005. }
  1006. } catch (e) {
  1007. console.warn("headlines_scroll_handler: " + e);
  1008. }
  1009. }
  1010. function catchupBatchedArticles() {
  1011. try {
  1012. if (catchup_id_batch.length > 0 && !_infscroll_request_sent) {
  1013. // make a copy of the array
  1014. var batch = catchup_id_batch.slice();
  1015. var query = "?op=rpc&method=catchupSelected" +
  1016. "&cmode=0&ids=" + param_escape(batch.toString());
  1017. console.log(query);
  1018. new Ajax.Request("backend.php", {
  1019. parameters: query,
  1020. onComplete: function(transport) {
  1021. handle_rpc_json(transport);
  1022. reply = JSON.parse(transport.responseText);
  1023. var batch = reply.ids;
  1024. batch.each(function(id) {
  1025. console.log(id);
  1026. var elem = $("RROW-" + id);
  1027. if (elem) elem.removeClassName("Unread");
  1028. catchup_id_batch.remove(id);
  1029. });
  1030. updateFloatingTitle(true);
  1031. } });
  1032. }
  1033. } catch (e) {
  1034. exception_error("catchupBatchedArticles", e);
  1035. }
  1036. }
  1037. function catchupRelativeToArticle(below, id) {
  1038. try {
  1039. if (!id) id = getActiveArticleId();
  1040. if (!id) {
  1041. alert(__("No article is selected."));
  1042. return;
  1043. }
  1044. var visible_ids = getVisibleArticleIds();
  1045. var ids_to_mark = new Array();
  1046. if (!below) {
  1047. for (var i = 0; i < visible_ids.length; i++) {
  1048. if (visible_ids[i] != id) {
  1049. var e = $("RROW-" + visible_ids[i]);
  1050. if (e && e.hasClassName("Unread")) {
  1051. ids_to_mark.push(visible_ids[i]);
  1052. }
  1053. } else {
  1054. break;
  1055. }
  1056. }
  1057. } else {
  1058. for (var i = visible_ids.length-1; i >= 0; i--) {
  1059. if (visible_ids[i] != id) {
  1060. var e = $("RROW-" + visible_ids[i]);
  1061. if (e && e.hasClassName("Unread")) {
  1062. ids_to_mark.push(visible_ids[i]);
  1063. }
  1064. } else {
  1065. break;
  1066. }
  1067. }
  1068. }
  1069. if (ids_to_mark.length == 0) {
  1070. alert(__("No articles found to mark"));
  1071. } else {
  1072. var msg = ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark.length).replace("%d", ids_to_mark.length);
  1073. if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) {
  1074. for (var i = 0; i < ids_to_mark.length; i++) {
  1075. var e = $("RROW-" + ids_to_mark[i]);
  1076. e.removeClassName("Unread");
  1077. }
  1078. var query = "?op=rpc&method=catchupSelected" +
  1079. "&cmode=0" + "&ids=" + param_escape(ids_to_mark.toString());
  1080. new Ajax.Request("backend.php", {
  1081. parameters: query,
  1082. onComplete: function(transport) {
  1083. handle_rpc_json(transport);
  1084. } });
  1085. }
  1086. }
  1087. } catch (e) {
  1088. exception_error("catchupRelativeToArticle", e);
  1089. }
  1090. }
  1091. function cdmCollapseArticle(event, id, unmark) {
  1092. try {
  1093. if (unmark == undefined) unmark = true;
  1094. var row = $("RROW-" + id);
  1095. var elem = $("CICD-" + id);
  1096. if (elem && row) {
  1097. var collapse = $$("div#RROW-" + id +
  1098. " span[class='collapseBtn']")[0];
  1099. Element.hide(elem);
  1100. Element.show("CEXC-" + id);
  1101. Element.hide(collapse);
  1102. if (unmark) {
  1103. row.removeClassName("active");
  1104. markHeadline(id, false);
  1105. if (id == getActiveArticleId()) {
  1106. setActiveArticleId(0);
  1107. }
  1108. updateSelectedPrompt();
  1109. }
  1110. if (event) Event.stop(event);
  1111. PluginHost.run(PluginHost.HOOK_ARTICLE_COLLAPSED, id);
  1112. if (row.offsetTop < $("headlines-frame").scrollTop)
  1113. scrollToRowId(row.id);
  1114. Element.hide("floatingTitle");
  1115. $("floatingTitle").setAttribute("rowid", false);
  1116. }
  1117. } catch (e) {
  1118. exception_error("cdmCollapseArticle", e);
  1119. }
  1120. }
  1121. function cdmExpandArticle(id, noexpand) {
  1122. try {
  1123. console.log("cdmExpandArticle " + id);
  1124. if (!$("RROW-" + id)) return false;
  1125. var oldrow = $("RROW-" + getActiveArticleId());
  1126. var elem = $("CICD-" + getActiveArticleId());
  1127. if (id == getActiveArticleId() && Element.visible(elem))
  1128. return true;
  1129. selectArticles("none");
  1130. var old_offset = $("RROW-" + id).offsetTop;
  1131. if (getActiveArticleId() && elem && !getInitParam("cdm_expanded")) {
  1132. var collapse = $$("div#RROW-" + getActiveArticleId() +
  1133. " span[class='collapseBtn']")[0];
  1134. Element.hide(elem);
  1135. Element.show("CEXC-" + getActiveArticleId());
  1136. Element.hide(collapse);
  1137. }
  1138. if (oldrow) oldrow.removeClassName("active");
  1139. setActiveArticleId(id);
  1140. elem = $("CICD-" + id);
  1141. var collapse = $$("div#RROW-" + id +
  1142. " span[class='collapseBtn']")[0];
  1143. var cencw = $("CENCW-" + id);
  1144. if (!Element.visible(elem) && !noexpand) {
  1145. if (cencw) {
  1146. cencw.innerHTML = htmlspecialchars_decode(cencw.innerHTML);
  1147. cencw.setAttribute('id', '');
  1148. Element.show(cencw);
  1149. }
  1150. Element.show(elem);
  1151. Element.hide("CEXC-" + id);
  1152. Element.show(collapse);
  1153. }
  1154. var new_offset = $("RROW-" + id).offsetTop;
  1155. if (old_offset > new_offset)
  1156. $("headlines-frame").scrollTop -= (old_offset-new_offset);
  1157. if (!noexpand)
  1158. toggleUnread(id, 0, true);
  1159. toggleSelected(id);
  1160. $("RROW-" + id).addClassName("active");
  1161. PluginHost.run(PluginHost.HOOK_ARTICLE_EXPANDED, id);
  1162. } catch (e) {
  1163. exception_error("cdmExpandArticle", e);
  1164. }
  1165. return false;
  1166. }
  1167. function getArticleUnderPointer() {
  1168. return post_under_pointer;
  1169. }
  1170. function scrollArticle(offset) {
  1171. try {
  1172. if (!isCdmMode()) {
  1173. var ci = $("content-insert");
  1174. if (ci) {
  1175. ci.scrollTop += offset;
  1176. }
  1177. } else {
  1178. var hi = $("headlines-frame");
  1179. if (hi) {
  1180. hi.scrollTop += offset;
  1181. }
  1182. }
  1183. } catch (e) {
  1184. exception_error("scrollArticle", e);
  1185. }
  1186. }
  1187. function show_labels_in_headlines(transport) {
  1188. try {
  1189. var data = JSON.parse(transport.responseText);
  1190. if (data) {
  1191. data['info-for-headlines'].each(function(elem) {
  1192. $$(".HLLCTR-" + elem.id).each(function(ctr) {
  1193. ctr.innerHTML = elem.labels;
  1194. });
  1195. });
  1196. }
  1197. } catch (e) {
  1198. exception_error("show_labels_in_headlines", e);
  1199. }
  1200. }
  1201. function dismissArticle(id) {
  1202. try {
  1203. var elem = $("RROW-" + id);
  1204. if (!elem) return;
  1205. toggleUnread(id, 0, true);
  1206. new Effect.Fade(elem, {duration : 0.5});
  1207. // Remove the content, too
  1208. var elem_content = $("CICD-" + id);
  1209. if (elem_content) {
  1210. Element.remove(elem_content);
  1211. }
  1212. if (id == getActiveArticleId()) {
  1213. setActiveArticleId(0);
  1214. }
  1215. } catch (e) {
  1216. exception_error("dismissArticle", e);
  1217. }
  1218. }
  1219. function dismissSelectedArticles() {
  1220. try {
  1221. var ids = getVisibleArticleIds();
  1222. var tmp = [];
  1223. var sel = [];
  1224. for (var i = 0; i < ids.length; i++) {
  1225. var elem = $("RROW-" + ids[i]);
  1226. if (elem.className && elem.hasClassName("Selected") &&
  1227. ids[i] != getActiveArticleId()) {
  1228. new Effect.Fade(elem, {duration : 0.5});
  1229. sel.push(ids[i]);
  1230. // Remove the content, too
  1231. var elem_content = $("CICD-" + ids[i]);
  1232. if (elem_content) {
  1233. Element.remove(elem_content);
  1234. }
  1235. } else {
  1236. tmp.push(ids[i]);
  1237. }
  1238. }
  1239. if (sel.length > 0)
  1240. selectionToggleUnread(false);
  1241. } catch (e) {
  1242. exception_error("dismissSelectedArticles", e);
  1243. }
  1244. }
  1245. function dismissReadArticles() {
  1246. try {
  1247. var ids = getVisibleArticleIds();
  1248. var tmp = [];
  1249. for (var i = 0; i < ids.length; i++) {
  1250. var elem = $("RROW-" + ids[i]);
  1251. if (elem.className && !elem.hasClassName("Unread") &&
  1252. !elem.hasClassName("Selected")) {
  1253. new Effect.Fade(elem, {duration : 0.5});
  1254. // Remove the content, too
  1255. var elem_content = $("CICD-" + ids[i]);
  1256. if (elem_content) {
  1257. Element.remove(elem_content);
  1258. }
  1259. } else {
  1260. tmp.push(ids[i]);
  1261. }
  1262. }
  1263. } catch (e) {
  1264. exception_error("dismissReadArticles", e);
  1265. }
  1266. }
  1267. function getVisibleArticleIds() {
  1268. var ids = [];
  1269. try {
  1270. getLoadedArticleIds().each(function(id) {
  1271. var elem = $("RROW-" + id);
  1272. if (elem && Element.visible(elem))
  1273. ids.push(id);
  1274. });
  1275. } catch (e) {
  1276. exception_error("getVisibleArticleIds", e);
  1277. }
  1278. return ids;
  1279. }
  1280. function cdmClicked(event, id) {
  1281. try {
  1282. //var shift_key = event.shiftKey;
  1283. if (!event.ctrlKey) {
  1284. if (!getInitParam("cdm_expanded")) {
  1285. return cdmExpandArticle(id);
  1286. } else {
  1287. var elem = $("RROW-" + getActiveArticleId());
  1288. if (elem) elem.removeClassName("active");
  1289. selectArticles("none");
  1290. toggleSelected(id);
  1291. var elem = $("RROW-" + id);
  1292. var article_is_unread = elem.hasClassName("Unread");
  1293. elem.removeClassName("Unread");
  1294. elem.addClassName("active");
  1295. setActiveArticleId(id);
  1296. if (article_is_unread) {
  1297. decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
  1298. updateFloatingTitle(true);
  1299. }
  1300. var query = "?op=rpc&method=catchupSelected" +
  1301. "&cmode=0&ids=" + param_escape(id);
  1302. new Ajax.Request("backend.php", {
  1303. parameters: query,
  1304. onComplete: function(transport) {
  1305. handle_rpc_json(transport);
  1306. } });
  1307. return !event.shiftKey;
  1308. }
  1309. } else {
  1310. toggleSelected(id, true);
  1311. var elem = $("RROW-" + id);
  1312. var article_is_unread = elem.hasClassName("Unread");
  1313. if (article_is_unread) {
  1314. decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
  1315. }
  1316. toggleUnread(id, 0, false);
  1317. openArticleInNewWindow(id);
  1318. }
  1319. var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
  1320. request_counters(unread_in_buffer == 0);
  1321. } catch (e) {
  1322. exception_error("cdmClicked");
  1323. }
  1324. return false;
  1325. }
  1326. function hlClicked(event, id) {
  1327. try {
  1328. if (event.which == 2) {
  1329. view(id);
  1330. return true;
  1331. } else if (event.ctrlKey) {
  1332. toggleSelected(id, true);
  1333. toggleUnread(id, 0, false);
  1334. openArticleInNewWindow(id);
  1335. return false;
  1336. } else {
  1337. view(id);
  1338. return false;
  1339. }
  1340. } catch (e) {
  1341. exception_error("hlClicked");
  1342. }
  1343. }
  1344. function getFirstVisibleHeadlineId() {
  1345. var rows = getVisibleArticleIds();
  1346. return rows[0];
  1347. }
  1348. function getLastVisibleHeadlineId() {
  1349. var rows = getVisibleArticleIds();
  1350. return rows[rows.length-1];
  1351. }
  1352. function openArticleInNewWindow(id) {
  1353. toggleUnread(id, 0, false);
  1354. window.open("backend.php?op=article&method=redirect&id=" + id);
  1355. }
  1356. function isCdmMode() {
  1357. return getInitParam("combined_display_mode");
  1358. }
  1359. function markHeadline(id, marked) {
  1360. if (marked == undefined) marked = true;
  1361. var row = $("RROW-" + id);
  1362. if (row) {
  1363. var check = dijit.getEnclosingWidget(
  1364. row.getElementsByClassName("rchk")[0]);
  1365. if (check) {
  1366. check.attr("checked", marked);
  1367. }
  1368. if (marked)
  1369. row.addClassName("Selected");
  1370. else
  1371. row.removeClassName("Selected");
  1372. }
  1373. }
  1374. function getRelativePostIds(id, limit) {
  1375. var tmp = [];
  1376. try {
  1377. if (!limit) limit = 6; //3
  1378. var ids = getVisibleArticleIds();
  1379. for (var i = 0; i < ids.length; i++) {
  1380. if (ids[i] == id) {
  1381. for (var k = 1; k <= limit; k++) {
  1382. //if (i > k-1) tmp.push(ids[i-k]);
  1383. if (i < ids.length-k) tmp.push(ids[i+k]);
  1384. }
  1385. break;
  1386. }
  1387. }
  1388. } catch (e) {
  1389. exception_error("getRelativePostIds", e);
  1390. }
  1391. return tmp;
  1392. }
  1393. function correctHeadlinesOffset(id) {
  1394. try {
  1395. var container = $("headlines-frame");
  1396. var row = $("RROW-" + id);
  1397. if (!container || !row) return;
  1398. var viewport = container.offsetHeight;
  1399. var rel_offset_top = row.offsetTop - container.scrollTop;
  1400. var rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop;
  1401. //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
  1402. //console.log("Vport: " + viewport);
  1403. if (rel_offset_top <= 0 || rel_offset_top > viewport) {
  1404. container.scrollTop = row.offsetTop;
  1405. } else if (rel_offset_bottom > viewport) {
  1406. /* doesn't properly work with Opera in some cases because
  1407. Opera fucks up element scrolling */
  1408. container.scrollTop = row.offsetTop + row.offsetHeight - viewport;
  1409. }
  1410. } catch (e) {
  1411. exception_error("correctHeadlinesOffset", e);
  1412. }
  1413. }
  1414. function headlineActionsChange(elem) {
  1415. try {
  1416. eval(elem.value);
  1417. elem.attr('value', 'false');
  1418. } catch (e) {
  1419. exception_error("headlineActionsChange", e);
  1420. }
  1421. }
  1422. function closeArticlePanel() {
  1423. if (dijit.byId("content-insert"))
  1424. dijit.byId("headlines-wrap-inner").removeChild(
  1425. dijit.byId("content-insert"));
  1426. }
  1427. function initFloatingMenu() {
  1428. try {
  1429. if (dijit.byId("floatingMenu"))
  1430. dijit.byId("floatingMenu").destroyRecursive();
  1431. var menu = new dijit.Menu({
  1432. id: "floatingMenu",
  1433. targetNodeIds: ["floatingTitle"]
  1434. });
  1435. var id = $("floatingTitle").getAttribute("rowid").replace("RROW-", "");
  1436. headlinesMenuCommon(menu, id);
  1437. menu.startup();
  1438. } catch (e) {
  1439. exception_error("initFloatingMenu", e);
  1440. }
  1441. }
  1442. function headlinesMenuCommon(menu, base_id) {
  1443. try {
  1444. menu.addChild(new dijit.MenuItem({
  1445. label: __("Open original article"),
  1446. onClick: function(event) {
  1447. openArticleInNewWindow(base_id ? base_id : this.getParent().callerRowId);
  1448. }}));
  1449. menu.addChild(new dijit.MenuItem({
  1450. label: __("Display article URL"),
  1451. onClick: function(event) {
  1452. displayArticleUrl(base_id ? base_id : this.getParent().callerRowId);
  1453. }}));
  1454. menu.addChild(new dijit.MenuSeparator());
  1455. menu.addChild(new dijit.MenuItem({
  1456. label: __("Toggle unread"),
  1457. onClick: function(event) {
  1458. var ids = getSelectedArticleIds2();
  1459. // cast to string
  1460. var id = (base_id ? base_id : this.getParent().callerRowId) + "";
  1461. ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
  1462. selectionToggleUnread(undefined, false, true, ids);
  1463. }}));
  1464. menu.addChild(new dijit.MenuItem({
  1465. label: __("Toggle starred"),
  1466. onClick: function(event) {
  1467. var ids = getSelectedArticleIds2();
  1468. // cast to string
  1469. var id = (base_id ? base_id : this.getParent().callerRowId) + "";
  1470. ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
  1471. selectionToggleMarked(undefined, false, true, ids);
  1472. }}));
  1473. menu.addChild(new dijit.MenuItem({
  1474. label: __("Toggle published"),
  1475. onClick: function(event) {
  1476. var ids = getSelectedArticleIds2();
  1477. // cast to string
  1478. var id = (base_id ? base_id : this.getParent().callerRowId) + "";
  1479. ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
  1480. selectionTogglePublished(undefined, false, true, ids);
  1481. }}));
  1482. menu.addChild(new dijit.MenuSeparator());
  1483. menu.addChild(new dijit.MenuItem({
  1484. label: __("Mark above as read"),
  1485. onClick: function(event) {
  1486. catchupRelativeToArticle(0, base_id ? base_id : this.getParent().callerRowId);
  1487. }}));
  1488. menu.addChild(new dijit.MenuItem({
  1489. label: __("Mark below as read"),
  1490. onClick: function(event) {
  1491. catchupRelativeToArticle(1, base_id ? base_id : this.getParent().callerRowId);
  1492. }}));
  1493. var labels = dijit.byId("feedTree").model.getItemsInCategory(-2);
  1494. if (labels) {
  1495. menu.addChild(new dijit.MenuSeparator());
  1496. var labelAddMenu = new dijit.Menu({ownerMenu: menu});
  1497. var labelDelMenu = new dijit.Menu({ownerMenu: menu});
  1498. labels.each(function(label) {
  1499. var id = label.id[0];
  1500. var bare_id = id.substr(id.indexOf(":")+1);
  1501. var name = label.name[0];
  1502. bare_id = feed_to_label_id(bare_id);
  1503. labelAddMenu.addChild(new dijit.MenuItem({
  1504. label: name,
  1505. labelId: bare_id,
  1506. onClick: function(event) {
  1507. var ids = getSelectedArticleIds2();
  1508. // cast to string
  1509. var id = (base_id ? base_id : this.getParent().ownerMenu.callerRowId) + "";
  1510. ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
  1511. selectionAssignLabel(this.labelId, ids);
  1512. }}));
  1513. labelDelMenu.addChild(new dijit.MenuItem({
  1514. label: name,
  1515. labelId: bare_id,
  1516. onClick: function(event) {
  1517. var ids = getSelectedArticleIds2();
  1518. // cast to string
  1519. var id = (base_id ? base_id : this.getParent().ownerMenu.callerRowId) + "";
  1520. ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
  1521. selectionRemoveLabel(this.labelId, ids);
  1522. }}));
  1523. });
  1524. menu.addChild(new dijit.PopupMenuItem({
  1525. label: __("Assign label"),
  1526. popup: labelAddMenu,
  1527. }));
  1528. menu.addChild(new dijit.PopupMenuItem({
  1529. label: __("Remove label"),
  1530. popup: labelDelMenu,
  1531. }));
  1532. }
  1533. } catch (e) {
  1534. exception_error("headlinesMenuCommon", e);
  1535. }
  1536. }
  1537. function initHeadlinesMenu() {
  1538. try {
  1539. if (dijit.byId("headlinesMenu"))
  1540. dijit.byId("headlinesMenu").destroyRecursive();
  1541. var ids = [];
  1542. if (!isCdmMode()) {
  1543. nodes = $$("#headlines-frame > div[id*=RROW]");
  1544. } else {
  1545. nodes = $$("#headlines-frame span[id*=RTITLE]");
  1546. }
  1547. nodes.each(function(node) {
  1548. ids.push(node.id);
  1549. });
  1550. var menu = new dijit.Menu({
  1551. id: "headlinesMenu",
  1552. targetNodeIds: ids,
  1553. });
  1554. var tmph = dojo.connect(menu, '_openMyself', function (event) {
  1555. var callerNode = event.target, match = null, tries = 0;
  1556. while (match == null && callerNode && tries <= 3) {
  1557. match = callerNode.id.match("^[A-Z]+[-]([0-9]+)$");
  1558. callerNode = callerNode.parentNode;
  1559. ++tries;
  1560. }
  1561. if (match) this.callerRowId = parseInt(match[1]);
  1562. });
  1563. headlinesMenuCommon(menu, false);
  1564. menu.startup();
  1565. /* vgroup feed title menu */
  1566. var nodes = $$("#headlines-frame > div[class='cdmFeedTitle']");
  1567. var ids = [];
  1568. nodes.each(function(node) {
  1569. ids.push(node.id);
  1570. });
  1571. if (ids.length > 0) {
  1572. if (dijit.byId("headlinesFeedTitleMenu"))
  1573. dijit.byId("headlinesFeedTitleMenu").destroyRecursive();
  1574. var menu = new dijit.Menu({
  1575. id: "headlinesFeedTitleMenu",
  1576. targetNodeIds: ids,
  1577. });
  1578. var tmph = dojo.connect(menu, '_openMyself', function (event) {
  1579. var callerNode = event.target, match = null, tries = 0;
  1580. while (match == null && callerNode && tries <= 3) {
  1581. console.log(callerNode.id);
  1582. match = callerNode.id.match("^[A-Z]+[-]([0-9]+)$");
  1583. callerNode = callerNode.parentNode;
  1584. ++tries;
  1585. console.log(match[1]);
  1586. }
  1587. if (match) this.callerRowId = parseInt(match[1]);
  1588. });
  1589. menu.addChild(new dijit.MenuItem({
  1590. label: __("Select articles in group"),
  1591. onClick: function(event) {
  1592. selectArticles("all",
  1593. "#headlines-frame > div[id*=RROW]"+
  1594. "[orig-feed-id='"+menu.callerRowId+"']");
  1595. }}));
  1596. menu.addChild(new dijit.MenuItem({
  1597. label: __("Mark group as read"),
  1598. onClick: function(event) {
  1599. selectArticles("none");
  1600. selectArticles("all",
  1601. "#headlines-frame > div[id*=RROW]"+
  1602. "[orig-feed-id='"+menu.callerRowId+"']");
  1603. catchupSelection();
  1604. }}));
  1605. menu.addChild(new dijit.MenuItem({
  1606. label: __("Mark feed as read"),
  1607. onClick: function(event) {
  1608. catchupFeedInGroup(menu.callerRowId);
  1609. }}));
  1610. menu.startup();
  1611. }
  1612. } catch (e) {
  1613. exception_error("initHeadlinesMenu", e);
  1614. }
  1615. }
  1616. function cache_set(id, obj) {
  1617. //console.log("cache_set: " + id);
  1618. if (has_storage)
  1619. try {
  1620. sessionStorage[id] = obj;
  1621. } catch (e) {
  1622. sessionStorage.clear();
  1623. }
  1624. }
  1625. function cache_get(id) {
  1626. if (has_storage)
  1627. return sessionStorage[id];
  1628. }
  1629. function cache_clear() {
  1630. if (has_storage)
  1631. sessionStorage.clear();
  1632. }
  1633. function cache_delete(id) {
  1634. if (has_storage)
  1635. sessionStorage.removeItem(id);
  1636. }
  1637. function cancelSearch() {
  1638. try {
  1639. _search_query = "";
  1640. viewCurrentFeed();
  1641. } catch (e) {
  1642. exception_error("cancelSearch", e);
  1643. }
  1644. }
  1645. function setSelectionScore() {
  1646. try {
  1647. var ids = getSelectedArticleIds2();
  1648. if (ids.length > 0) {
  1649. console.log(ids);
  1650. var score = prompt(__("Please enter new score for selected articles:"), score);
  1651. if (score != undefined) {
  1652. var query = "op=article&method=setScore&id=" + param_escape(ids.toString()) +
  1653. "&score=" + param_escape(score);
  1654. new Ajax.Request("backend.php", {
  1655. parameters: query,
  1656. onComplete: function(transport) {
  1657. var reply = JSON.parse(transport.responseText);
  1658. if (reply) {
  1659. console.log(ids);
  1660. ids.each(function(id) {
  1661. var row = $("RROW-" + id);
  1662. if (row) {
  1663. var pic = row.getElementsByClassName("hlScorePic")[0];
  1664. if (pic) {
  1665. pic.src = pic.src.replace(/score_.*?\.png/,
  1666. reply["score_pic"]);
  1667. pic.setAttribute("score", score);
  1668. }
  1669. }
  1670. });
  1671. }
  1672. } });
  1673. }
  1674. } else {
  1675. alert(__("No articles are selected."));
  1676. }
  1677. } catch (e) {
  1678. exception_error("setSelectionScore", e);
  1679. }
  1680. }
  1681. function changeScore(id, pic) {
  1682. try {
  1683. var score = pic.getAttribute("score");
  1684. var new_score = prompt(__("Please enter new score for this article:"), score);
  1685. if (new_score != undefined) {
  1686. var query = "op=article&method=setScore&id=" + param_escape(id) +
  1687. "&score=" + param_escape(new_score);
  1688. new Ajax.Request("backend.php", {
  1689. parameters: query,
  1690. onComplete: function(transport) {
  1691. var reply = JSON.parse(transport.responseText);
  1692. if (reply) {
  1693. pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
  1694. pic.setAttribute("score", new_score);
  1695. }
  1696. } });
  1697. }
  1698. } catch (e) {
  1699. exception_error("changeScore", e);
  1700. }
  1701. }
  1702. function displayArticleUrl(id) {
  1703. try {
  1704. var query = "op=rpc&method=getlinktitlebyid&id=" + param_escape(id);
  1705. new Ajax.Request("backend.php", {
  1706. parameters: query,
  1707. onComplete: function(transport) {
  1708. var reply = JSON.parse(transport.responseText);
  1709. if (reply && reply.link) {
  1710. prompt(__("Article URL:"), reply.link);
  1711. }
  1712. } });
  1713. } catch (e) {
  1714. exception_error("changeScore", e);
  1715. }
  1716. }
  1717. function openSelectedAttachment(elem) {
  1718. try {
  1719. var url = elem[elem.selectedIndex].value;
  1720. if (url) {
  1721. window.open(url);
  1722. elem.selectedIndex = 0;
  1723. }
  1724. } catch (e) {
  1725. exception_error("openSelectedAttachment", e);
  1726. }
  1727. }
  1728. function scrollToRowId(id) {
  1729. try {
  1730. var row = $(id);
  1731. if (row)
  1732. $("headlines-frame").scrollTop = row.offsetTop;
  1733. } catch (e) {
  1734. exception_error("scrollToRowId", e);
  1735. }
  1736. }
  1737. function updateFloatingTitle(unread_only) {
  1738. try {
  1739. if (!isCdmMode()) return;
  1740. var hf = $("headlines-frame");
  1741. var elems = $$("#headlines-frame > div[id*=RROW]");
  1742. for (var i = 0; i < elems.length; i++) {
  1743. var child = elems[i];
  1744. if (child && child.offsetTop + child.offsetHeight > hf.scrollTop) {
  1745. var header = child.getElementsByClassName("cdmHeader")[0];
  1746. if (unread_only || child.id != $("floatingTitle").getAttribute("rowid")) {
  1747. if (child.id != $("floatingTitle").getAttribute("rowid")) {
  1748. $("floatingTitle").setAttribute("rowid", child.id);
  1749. $("floatingTitle").innerHTML = header.innerHTML;
  1750. $("floatingTitle").firstChild.innerHTML = "<img class='anchor markedPic' src='images/page_white_go.png' onclick=\"scrollToRowId('"+child.id+"')\">" + $("floatingTitle").firstChild.innerHTML;
  1751. initFloatingMenu();
  1752. var cb = $$("#floatingTitle .dijitCheckBox")[0];
  1753. if (cb)
  1754. cb.parentNode.removeChild(cb);
  1755. }
  1756. if (child.hasClassName("Unread"))
  1757. $("floatingTitle").addClassName("Unread");
  1758. else
  1759. $("floatingTitle").removeClassName("Unread");
  1760. PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, child);
  1761. }
  1762. if (child.offsetTop < hf.scrollTop - header.offsetHeight &&
  1763. child.offsetTop + child.offsetHeight - hf.scrollTop > header.offsetHeight)
  1764. Element.show("floatingTitle");
  1765. else
  1766. Element.hide("floatingTitle");
  1767. return;
  1768. }
  1769. }
  1770. } catch (e) {
  1771. exception_error("updateFloatingTitle", e);
  1772. }
  1773. }