functions.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  1. var hotkeys_enabled = true;
  2. function exception_error(location, e) {
  3. var msg;
  4. if (e.fileName) {
  5. var base_fname = e.fileName.substring(e.fileName.lastIndexOf("/") + 1);
  6. msg = "Exception: " + e.name + ", " + e.message +
  7. "\nFunction: " + location + "()" +
  8. "\nLocation: " + base_fname + ":" + e.lineNumber;
  9. } else {
  10. msg = "Exception: " + e + "\nFunction: " + location + "()";
  11. }
  12. alert(msg);
  13. }
  14. function disableHotkeys() {
  15. hotkeys_enabled = false;
  16. }
  17. function enableHotkeys() {
  18. hotkeys_enabled = true;
  19. }
  20. function xmlhttp_ready(obj) {
  21. return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState;
  22. }
  23. function notify_callback() {
  24. var container = document.getElementById('notify');
  25. if (xmlhttp.readyState == 4) {
  26. container.innerHTML=xmlhttp.responseText;
  27. }
  28. }
  29. function rpc_notify_callback() {
  30. var container = document.getElementById('notify');
  31. if (xmlhttp_rpc.readyState == 4) {
  32. container.innerHTML=xmlhttp_rpc.responseText;
  33. }
  34. }
  35. function rpc_pnotify_callback() {
  36. var container = parent.document.getElementById('notify');
  37. if (xmlhttp_rpc.readyState == 4) {
  38. container.innerHTML=xmlhttp_rpc.responseText;
  39. }
  40. }
  41. function param_escape(arg) {
  42. if (typeof encodeURIComponent != 'undefined')
  43. return encodeURIComponent(arg);
  44. else
  45. return escape(arg);
  46. }
  47. function param_unescape(arg) {
  48. if (typeof decodeURIComponent != 'undefined')
  49. return decodeURIComponent(arg);
  50. else
  51. return unescape(arg);
  52. }
  53. function delay(gap) {
  54. var then,now;
  55. then=new Date().getTime();
  56. now=then;
  57. while((now-then)<gap) {
  58. now=new Date().getTime();
  59. }
  60. }
  61. function p_notify(msg) {
  62. var n = parent.document.getElementById("notify");
  63. var nb = parent.document.getElementById("notify_body");
  64. if (!n || !nb) return;
  65. if (msg == "") {
  66. nb.innerHTML = "&nbsp;";
  67. // n.style.background = "#ffffff";
  68. } else {
  69. nb.innerHTML = msg;
  70. // n.style.background = "#fffff0";
  71. }
  72. }
  73. function notify(msg) {
  74. var n = document.getElementById("notify");
  75. var nb = document.getElementById("notify_body");
  76. if (!n || !nb) return;
  77. if (msg == "") {
  78. nb.innerHTML = "&nbsp;";
  79. // n.style.background = "#ffffff";
  80. } else {
  81. nb.innerHTML = msg;
  82. // n.style.background = "#fffff0";
  83. }
  84. }
  85. function printLockingError() {
  86. notify("Please wait until operation finishes");}
  87. var seq = "";
  88. function hotkey_handler(e) {
  89. var keycode;
  90. if (!hotkeys_enabled) return;
  91. if (window.event) {
  92. keycode = window.event.keyCode;
  93. } else if (e) {
  94. keycode = e.which;
  95. }
  96. if (keycode == 13 || keycode == 27) {
  97. seq = "";
  98. } else {
  99. seq = seq + "" + keycode;
  100. }
  101. if (document.getElementById("piggie")) {
  102. if (seq.match("807371717369")) {
  103. seq = "";
  104. localPiggieFunction(true);
  105. } else {
  106. localPiggieFunction(false);
  107. }
  108. }
  109. if (typeof localHotkeyHandler != 'undefined') {
  110. try {
  111. localHotkeyHandler(keycode);
  112. } catch (e) {
  113. exception_error("hotkey_handler", e);
  114. }
  115. }
  116. }
  117. function cleanSelectedList(element) {
  118. var content = document.getElementById(element);
  119. if (!document.getElementById("feedCatHolder")) {
  120. for (i = 0; i < content.childNodes.length; i++) {
  121. var child = content.childNodes[i];
  122. try {
  123. child.className = child.className.replace("Selected", "");
  124. } catch (e) {
  125. //
  126. }
  127. }
  128. } else {
  129. for (i = 0; i < content.childNodes.length; i++) {
  130. var child = content.childNodes[i];
  131. if (child.id == "feedCatHolder") {
  132. parent.debug(child.id);
  133. var fcat = child.lastChild;
  134. for (j = 0; j < fcat.childNodes.length; j++) {
  135. var feed = fcat.childNodes[j];
  136. feed.className = feed.className.replace("Selected", "");
  137. }
  138. }
  139. }
  140. }
  141. }
  142. function cleanSelected(element) {
  143. var content = document.getElementById(element);
  144. for (i = 0; i < content.rows.length; i++) {
  145. content.rows[i].className = content.rows[i].className.replace("Selected", "");
  146. }
  147. }
  148. function getVisibleUnreadHeadlines() {
  149. var content = document.getElementById("headlinesList");
  150. var rows = new Array();
  151. for (i = 0; i < content.rows.length; i++) {
  152. var row_id = content.rows[i].id.replace("RROW-", "");
  153. if (row_id.length > 0 && content.rows[i].className.match("Unread")) {
  154. rows.push(row_id);
  155. }
  156. }
  157. return rows;
  158. }
  159. function getVisibleHeadlineIds() {
  160. var content = document.getElementById("headlinesList");
  161. var rows = new Array();
  162. for (i = 0; i < content.rows.length; i++) {
  163. var row_id = content.rows[i].id.replace("RROW-", "");
  164. if (row_id.length > 0) {
  165. rows.push(row_id);
  166. }
  167. }
  168. return rows;
  169. }
  170. function getFirstVisibleHeadlineId() {
  171. var rows = getVisibleHeadlineIds();
  172. return rows[0];
  173. }
  174. function getLastVisibleHeadlineId() {
  175. var rows = getVisibleHeadlineIds();
  176. return rows[rows.length-1];
  177. }
  178. function markHeadline(id) {
  179. var row = document.getElementById("RROW-" + id);
  180. if (row) {
  181. var is_active = false;
  182. if (row.className.match("Active")) {
  183. is_active = true;
  184. }
  185. row.className = row.className.replace("Selected", "");
  186. row.className = row.className.replace("Active", "");
  187. row.className = row.className.replace("Insensitive", "");
  188. if (is_active) {
  189. row.className = row.className = "Active";
  190. }
  191. var check = document.getElementById("RCHK-" + id);
  192. if (check) {
  193. check.checked = true;
  194. }
  195. row.className = row.className + "Selected";
  196. }
  197. }
  198. function getFeedIds() {
  199. var content = document.getElementById("feedsList");
  200. var rows = new Array();
  201. for (i = 0; i < content.rows.length; i++) {
  202. var id = content.rows[i].id.replace("FEEDR-", "");
  203. if (id.length > 0) {
  204. rows.push(id);
  205. }
  206. }
  207. return rows;
  208. }
  209. function setCookie(name, value, lifetime, path, domain, secure) {
  210. var d = false;
  211. if (lifetime) {
  212. d = new Date();
  213. d.setTime(lifetime * 1000);
  214. }
  215. int_setCookie(name, value, d, path, domain, secure);
  216. }
  217. function int_setCookie(name, value, expires, path, domain, secure) {
  218. document.cookie= name + "=" + escape(value) +
  219. ((expires) ? "; expires=" + expires.toGMTString() : "") +
  220. ((path) ? "; path=" + path : "") +
  221. ((domain) ? "; domain=" + domain : "") +
  222. ((secure) ? "; secure" : "");
  223. }
  224. function delCookie(name, path, domain) {
  225. if (getCookie(name)) {
  226. document.cookie = name + "=" +
  227. ((path) ? ";path=" + path : "") +
  228. ((domain) ? ";domain=" + domain : "" ) +
  229. ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
  230. }
  231. }
  232. function getCookie(name) {
  233. var dc = document.cookie;
  234. var prefix = name + "=";
  235. var begin = dc.indexOf("; " + prefix);
  236. if (begin == -1) {
  237. begin = dc.indexOf(prefix);
  238. if (begin != 0) return null;
  239. }
  240. else {
  241. begin += 2;
  242. }
  243. var end = document.cookie.indexOf(";", begin);
  244. if (end == -1) {
  245. end = dc.length;
  246. }
  247. return unescape(dc.substring(begin + prefix.length, end));
  248. }
  249. function disableContainerChildren(id, disable, doc) {
  250. if (!doc) doc = document;
  251. var container = doc.getElementById(id);
  252. for (var i = 0; i < container.childNodes.length; i++) {
  253. var child = container.childNodes[i];
  254. try {
  255. child.disabled = disable;
  256. } catch (E) {
  257. }
  258. if (disable) {
  259. if (child.className && child.className.match("button")) {
  260. child.className = "disabledButton";
  261. }
  262. } else {
  263. if (child.className && child.className.match("disabledButton")) {
  264. child.className = "button";
  265. }
  266. }
  267. }
  268. }
  269. function gotoPreferences() {
  270. document.location.href = "prefs.php";
  271. }
  272. function gotoMain() {
  273. document.location.href = "tt-rss.php";
  274. }
  275. function gotoExportOpml() {
  276. document.location.href = "opml.php?op=Export";
  277. }
  278. function getActiveFeedId() {
  279. return getCookie("ttrss_vf_actfeed");
  280. }
  281. function setActiveFeedId(id) {
  282. return setCookie("ttrss_vf_actfeed", id);
  283. }
  284. var xmlhttp_rpc = false;
  285. /*@cc_on @*/
  286. /*@if (@_jscript_version >= 5)
  287. // JScript gives us Conditional compilation, we can cope with old IE versions.
  288. // and security blocked creation of the objects.
  289. try {
  290. xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP");
  291. } catch (e) {
  292. try {
  293. xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
  294. } catch (E) {
  295. xmlhttp_rpc = false;
  296. }
  297. }
  298. @end @*/
  299. if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') {
  300. xmlhttp_rpc = new XMLHttpRequest();
  301. }
  302. function parse_counters(reply, f_document, title_obj, scheduled_call) {
  303. try {
  304. for (var l = 0; l < reply.childNodes.length; l++) {
  305. if (!reply.childNodes[l] ||
  306. typeof(reply.childNodes[l].getAttribute) == "undefined") {
  307. // where did this come from?
  308. continue;
  309. }
  310. var id = reply.childNodes[l].getAttribute("id");
  311. var t = reply.childNodes[l].getAttribute("type");
  312. var ctr = reply.childNodes[l].getAttribute("counter");
  313. var error = reply.childNodes[l].getAttribute("error");
  314. var has_img = reply.childNodes[l].getAttribute("hi");
  315. var updated = reply.childNodes[l].getAttribute("updated");
  316. if (id == "global-unread") {
  317. title_obj.global_unread = ctr;
  318. title_obj.updateTitle();
  319. continue;
  320. }
  321. if (t == "category") {
  322. var catctr = f_document.getElementById("FCATCTR-" + id);
  323. if (catctr) {
  324. catctr.innerHTML = "(" + ctr + " unread)";
  325. }
  326. continue;
  327. }
  328. var feedctr = f_document.getElementById("FEEDCTR-" + id);
  329. var feedu = f_document.getElementById("FEEDU-" + id);
  330. var feedr = f_document.getElementById("FEEDR-" + id);
  331. var feed_img = f_document.getElementById("FIMG-" + id);
  332. var feedlink = f_document.getElementById("FEEDL-" + id);
  333. if (updated && feedlink) {
  334. if (error) {
  335. feedlink.title = "Error: " + error + " (" + updated + ")";
  336. } else {
  337. feedlink.title = "Updated: " + updated;
  338. }
  339. }
  340. if (feedctr && feedu && feedr) {
  341. if (feedu.innerHTML != ctr && id == getActiveFeedId() && scheduled_call) {
  342. var hf = title_obj.parent.frames["headlines-frame"];
  343. hf.location.reload(true);
  344. }
  345. feedu.innerHTML = ctr;
  346. if (error) {
  347. feedr.className = feedr.className.replace("feed", "error");
  348. } else if (id > 0) {
  349. feedr.className = feedr.className.replace("error", "feed");
  350. }
  351. if (ctr > 0) {
  352. feedctr.className = "odd";
  353. if (!feedr.className.match("Unread")) {
  354. var is_selected = feedr.className.match("Selected");
  355. feedr.className = feedr.className.replace("Selected", "");
  356. feedr.className = feedr.className.replace("Unread", "");
  357. feedr.className = feedr.className + "Unread";
  358. if (is_selected) {
  359. feedr.className = feedr.className + "Selected";
  360. }
  361. }
  362. } else {
  363. feedctr.className = "invisible";
  364. feedr.className = feedr.className.replace("Unread", "");
  365. }
  366. }
  367. }
  368. } catch (e) {
  369. exception_error("parse_counters", e);
  370. }
  371. }
  372. // this one is called from feedlist context
  373. // thus title_obj passed to parse_counters is parent (e.g. main ttrss window)
  374. function all_counters_callback() {
  375. if (xmlhttp_rpc.readyState == 4) {
  376. try {
  377. if (!xmlhttp_rpc.responseXML || !xmlhttp_rpc.responseXML.firstChild) {
  378. notify("[all_counters_callback] backend did not return valid XML");
  379. return;
  380. }
  381. if (!parent.frames["feeds-frame"]) {
  382. notify("[all_counters_callback] no parent feeds-frame");
  383. return;
  384. }
  385. var reply = xmlhttp_rpc.responseXML.firstChild;
  386. var f_document = parent.frames["feeds-frame"].document;
  387. parse_counters(reply, f_document, parent);
  388. } catch (e) {
  389. exception_error("all_counters_callback", e);
  390. }
  391. }
  392. }
  393. function update_all_counters(feed) {
  394. if (xmlhttp_ready(xmlhttp_rpc)) {
  395. var query = "backend.php?op=rpc&subop=getAllCounters";
  396. if (feed > 0) {
  397. query = query + "&aid=" + feed;
  398. }
  399. xmlhttp_rpc.open("GET", query, true);
  400. xmlhttp_rpc.onreadystatechange=all_counters_callback;
  401. xmlhttp_rpc.send(null);
  402. }
  403. }
  404. function popupHelp(tid) {
  405. var w = window.open("backend.php?op=help&tid=" + tid,
  406. "Popup Help",
  407. "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
  408. }
  409. /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
  410. * * @author Sundar Dorai-Raj
  411. * * Email: sdoraira@vt.edu
  412. * * This program is free software; you can redistribute it and/or
  413. * * modify it under the terms of the GNU General Public License
  414. * * as published by the Free Software Foundation; either version 2
  415. * * of the License, or (at your option) any later version,
  416. * * provided that any use properly credits the author.
  417. * * This program is distributed in the hope that it will be useful,
  418. * * but WITHOUT ANY WARRANTY; without even the implied warranty of
  419. * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  420. * * GNU General Public License for more details at http://www.gnu.org * * */
  421. var numbers=".0123456789";
  422. function isNumeric(x) {
  423. // is x a String or a character?
  424. if(x.length>1) {
  425. // remove negative sign
  426. x=Math.abs(x)+"";
  427. for(j=0;j<x.length;j++) {
  428. // call isNumeric recursively for each character
  429. number=isNumeric(x.substring(j,j+1));
  430. if(!number) return number;
  431. }
  432. return number;
  433. }
  434. else {
  435. // if x is number return true
  436. if(numbers.indexOf(x)>=0) return true;
  437. return false;
  438. }
  439. }
  440. function hideOrShowFeeds(doc, hide) {
  441. if (!doc.styleSheets) return;
  442. var css_rules = doc.styleSheets[0].cssRules;
  443. if (!css_rules || !css_rules.length) return;
  444. for (i = 0; i < css_rules.length; i++) {
  445. var rule = css_rules[i];
  446. if (rule.selectorText == "ul.feedList li.feed") {
  447. if (!hide) {
  448. rule.style.display = "block";
  449. } else {
  450. rule.style.display = "none";
  451. }
  452. }
  453. }
  454. }
  455. function selectTableRow(r, do_select) {
  456. r.className = r.className.replace("Selected", "");
  457. if (do_select) {
  458. r.className = r.className + "Selected";
  459. }
  460. }
  461. function selectTableRowById(elem_id, check_id, do_select) {
  462. try {
  463. var row = document.getElementById(elem_id);
  464. if (row) {
  465. selectTableRow(row, do_select);
  466. }
  467. var check = document.getElementById(check_id);
  468. if (check) {
  469. check.checked = do_select;
  470. }
  471. } catch (e) {
  472. exception_error("selectTableRowById", e);
  473. }
  474. }
  475. function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select,
  476. classcheck, reset_others) {
  477. var content = document.getElementById(content_id);
  478. if (!content) {
  479. alert("[selectTableRows] Element " + content_id + " not found.");
  480. return;
  481. }
  482. for (i = 0; i < content.rows.length; i++) {
  483. if (!classcheck || content.rows[i].className.match(classcheck)) {
  484. if (content.rows[i].id.match(prefix)) {
  485. selectTableRow(content.rows[i], do_select);
  486. var row_id = content.rows[i].id.replace(prefix, "");
  487. var check = document.getElementById(check_prefix + row_id);
  488. if (check) {
  489. check.checked = do_select;
  490. }
  491. } else if (reset_others) {
  492. selectTableRow(content.rows[i], false);
  493. var row_id = content.rows[i].id.replace(prefix, "");
  494. var check = document.getElementById(check_prefix + row_id);
  495. if (check) {
  496. check.checked = false;
  497. }
  498. }
  499. } else if (reset_others) {
  500. selectTableRow(content.rows[i], false);
  501. var row_id = content.rows[i].id.replace(prefix, "");
  502. var check = document.getElementById(check_prefix + row_id);
  503. if (check) {
  504. check.checked = false;
  505. }
  506. }
  507. }
  508. }
  509. function getSelectedTableRowIds(content_id, prefix) {
  510. var content = document.getElementById(content_id);
  511. if (!content) {
  512. alert("[getSelectedTableRowIds] Element " + content_id + " not found.");
  513. return;
  514. }
  515. var sel_rows = new Array();
  516. for (i = 0; i < content.rows.length; i++) {
  517. if (content.rows[i].id.match(prefix) &&
  518. content.rows[i].className.match("Selected")) {
  519. var row_id = content.rows[i].id.replace(prefix + "-", "");
  520. sel_rows.push(row_id);
  521. }
  522. }
  523. return sel_rows;
  524. }
  525. function toggleSelectRowById(sender, id) {
  526. var row = document.getElementById(id);
  527. if (sender.checked) {
  528. if (!row.className.match("Selected")) {
  529. row.className = row.className + "Selected";
  530. }
  531. } else {
  532. if (row.className.match("Selected")) {
  533. row.className = row.className.replace("Selected", "");
  534. }
  535. }
  536. }
  537. function toggleSelectListRow(sender) {
  538. var parent_row = sender.parentNode;
  539. if (sender.checked) {
  540. if (!parent_row.className.match("Selected")) {
  541. parent_row.className = parent_row.className + "Selected";
  542. }
  543. } else {
  544. if (parent_row.className.match("Selected")) {
  545. parent_row.className = parent_row.className.replace("Selected", "");
  546. }
  547. }
  548. }
  549. function toggleSelectRow(sender) {
  550. var parent_row = sender.parentNode.parentNode;
  551. if (sender.checked) {
  552. if (!parent_row.className.match("Selected")) {
  553. parent_row.className = parent_row.className + "Selected";
  554. }
  555. } else {
  556. if (parent_row.className.match("Selected")) {
  557. parent_row.className = parent_row.className.replace("Selected", "");
  558. }
  559. }
  560. }
  561. function openExternalUrl(url) {
  562. var w = window.open(url);
  563. }
  564. function getRelativeFeedId(list, id, direction) {
  565. if (!id) {
  566. if (direction == "next") {
  567. for (i = 0; i < list.childNodes.length; i++) {
  568. var child = list.childNodes[i];
  569. if (child.id == "feedCatHolder") {
  570. if (child.lastChild) {
  571. var cr = getRelativeFeedId(child.firstChild, id, direction);
  572. if (cr) return cr;
  573. }
  574. } else if (child.id.match("FEEDR-")) {
  575. return child.id.replace('FEEDR-', '');
  576. }
  577. }
  578. }
  579. // FIXME select last feed doesn't work when only unread feeds are visible
  580. if (direction == "prev") {
  581. for (i = list.childNodes.length-1; i >= 0; i--) {
  582. var child = list.childNodes[i];
  583. if (child.id == "feedCatHolder") {
  584. if (child.firstChild) {
  585. var cr = getRelativeFeedId(child.firstChild, id, direction);
  586. if (cr) return cr;
  587. }
  588. } else if (child.id.match("FEEDR-")) {
  589. if (getCookie("ttrss_vf_hreadf") == 1) {
  590. if (child.className != "feed") {
  591. alert(child.className);
  592. return child.id.replace('FEEDR-', '');
  593. }
  594. } else {
  595. return child.id.replace('FEEDR-', '');
  596. }
  597. }
  598. }
  599. }
  600. } else {
  601. var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId());
  602. if (direction == "next") {
  603. if (feed.nextSibling) {
  604. var next_feed = feed.nextSibling;
  605. while (!next_feed.id && next_feed.nextSibling) {
  606. next_feed = next_feed.nextSibling;
  607. }
  608. if (getCookie("ttrss_vf_hreadf") == 1) {
  609. while (next_feed && next_feed.className == "feed") {
  610. next_feed = next_feed.nextSibling;
  611. }
  612. }
  613. if (next_feed && next_feed.id.match("FEEDR-")) {
  614. return next_feed.id.replace("FEEDR-", "");
  615. }
  616. }
  617. var this_cat = feed.parentNode.parentNode;
  618. if (this_cat && this_cat.nextSibling) {
  619. while (this_cat = this_cat.nextSibling) {
  620. if (this_cat.firstChild && this_cat.firstChild.firstChild) {
  621. var next_feed = this_cat.firstChild.firstChild;
  622. if (getCookie("ttrss_vf_hreadf") == 1) {
  623. while (next_feed && next_feed.className == "feed") {
  624. next_feed = next_feed.nextSibling;
  625. }
  626. }
  627. if (next_feed && next_feed.id.match("FEEDR-")) {
  628. return next_feed.id.replace("FEEDR-", "");
  629. }
  630. }
  631. }
  632. }
  633. } else if (direction == "prev") {
  634. if (feed.previousSibling) {
  635. var prev_feed = feed.previousSibling;
  636. if (getCookie("ttrss_vf_hreadf") == 1) {
  637. while (prev_feed && prev_feed.className == "feed") {
  638. prev_feed = prev_feed.previousSibling;
  639. }
  640. }
  641. while (!prev_feed.id && prev_feed.previousSibling) {
  642. prev_feed = prev_feed.previousSibling;
  643. }
  644. if (prev_feed && prev_feed.id.match("FEEDR-")) {
  645. return prev_feed.id.replace("FEEDR-", "");
  646. }
  647. }
  648. var this_cat = feed.parentNode.parentNode;
  649. if (this_cat && this_cat.previousSibling) {
  650. while (this_cat = this_cat.previousSibling) {
  651. if (this_cat.lastChild && this_cat.firstChild.lastChild) {
  652. var prev_feed = this_cat.firstChild.lastChild;
  653. if (getCookie("ttrss_vf_hreadf") == 1) {
  654. while (prev_feed && prev_feed.className == "feed") {
  655. prev_feed = prev_feed.previousSibling;
  656. }
  657. }
  658. if (prev_feed && prev_feed.id.match("FEEDR-")) {
  659. return prev_feed.id.replace("FEEDR-", "");
  660. }
  661. }
  662. }
  663. }
  664. }
  665. }
  666. }
  667. function showBlockElement(id) {
  668. var elem = document.getElementById(id);
  669. if (elem) {
  670. elem.style.display = "block";
  671. } else {
  672. alert("[showBlockElement] can't find element with id " + id);
  673. }
  674. }
  675. function hideParentElement(e) {
  676. e.parentNode.style.display = "none";
  677. }
  678. function dropboxSelect(e, v) {
  679. for (i = 0; i < e.length; i++) {
  680. if (e[i].value == v) {
  681. e.selectedIndex = i;
  682. break;
  683. }
  684. }
  685. }
  686. // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
  687. // bugfixed just a little bit :-)
  688. function getURLParam(strParamName){
  689. var strReturn = "";
  690. var strHref = window.location.href;
  691. if (strHref.indexOf("#") == strHref.length-1) {
  692. strHref = strHref.substring(0, strHref.length-1);
  693. }
  694. if ( strHref.indexOf("?") > -1 ){
  695. var strQueryString = strHref.substr(strHref.indexOf("?"));
  696. var aQueryString = strQueryString.split("&");
  697. for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
  698. if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
  699. var aParam = aQueryString[iParam].split("=");
  700. strReturn = aParam[1];
  701. break;
  702. }
  703. }
  704. }
  705. return strReturn;
  706. }
  707. function leading_zero(p) {
  708. var s = String(p);
  709. if (s.length == 1) s = "0" + s;
  710. return s;
  711. }
  712. function center_element(e) {
  713. try {
  714. var c_width = document.body.clientWidth;
  715. var c_height = document.body.clientHeight;
  716. var c_scroll = document.body.scrollTop;
  717. var e_width = e.clientWidth;
  718. var e_height = e.clientHeight;
  719. var set_y = (c_height / 2) + c_scroll - (e_height / 2);
  720. var set_x = (c_width / 2) - (e_width / 2);
  721. e.style.top = set_y + "px";
  722. e.style.left = set_x + "px";
  723. } catch (e) {
  724. exception_error("center_element", e);
  725. }
  726. }