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