viewfeed.js 52 KB

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