Advertisement
TikName

LOR TreeView

Aug 12th, 2016
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name          LOR TreeView
  3. // @description   Make tree view for LOR threads (with jQuery)
  4. // @exclude http*://*linux.org.ru/forum/*/
  5. // @exclude http*://*linux.org.ru/news/*/
  6. // @exclude http*://*linux.org.ru/gallery/*/
  7. // @exclude http*://*linux.org.ru/polls/*/
  8. // @include http*://*linux.org.ru/forum/*/*
  9. // @include http*://*linux.org.ru/news/*/*
  10. // @include http*://*linux.org.ru/gallery/*/*
  11. // @include http*://*linux.org.ru/polls/*/*
  12. // @require https://www.linux.org.ru/webjars/jquery/1.12.3/jquery.min.js
  13. // @grant none
  14. // @UpdateURL http://userscripts.org/scripts/source/15985.user.js
  15. // @version 7.16.1
  16. // ==/UserScript==
  17. //
  18. // License: GNU GPL v3 or later
  19. // Copyright (C) 2012 sdio
  20. //
  21. // The JavaScript code in this page is free software: you can
  22. // redistribute it and/or modify it under the terms of the GNU
  23. // General Public License (GNU GPL) as published by the Free Software
  24. // Foundation, either version 3 of the License, or (at your option)
  25. // any later version.  The code is distributed WITHOUT ANY WARRANTY;
  26. // without even the implied warranty of MERCHANTABILITY or FITNESS
  27. // FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
  28. //
  29. // As additional permission under GNU GPL version 3 section 7, you
  30. // may distribute non-source (e.g., minimized or compacted) forms of
  31. // that code without the copy of the GNU GPL normally required by
  32. // section 4, provided you include this license notice and a URL
  33. // through which recipients can access the Corresponding Source.
  34. //
  35. // Author:  sdio (http://www.linux.org.ru/people/sdio/profile)
  36. // Contributed by:
  37. //  kodx ( http://kodx.org )
  38. //  ZaWertun ( http://www.linux.org.ru/people/ZaWertun/profile )
  39. //  TikName ( https://www.linux.org.ru/people/TikName/profile )
  40. //
  41. //
  42.  
  43. // change color of links
  44. var ALTERLINKS = 1;
  45. // use quick answer form
  46. var USE_QUICK_ANSWER = 1;
  47.  
  48. var THEME;
  49. // set the default theme in case autodetect fail
  50. THEME = 'tango';
  51. //THEME = 'white'
  52. //THEME = 'black';
  53.  
  54. //----------------------------------------------------------------
  55. var COLOR = new Array;
  56. COLOR['white']  = 'black';
  57. COLOR['white2'] = 'black';
  58. COLOR['black']  = 'white';
  59. COLOR['tango']  = '#729fcf';
  60. COLOR['swamp']  = 'black';
  61.  
  62. // Length of the BACKGROUNDS array may be any, so change it as you want
  63. var BACKGROUNDS = new Array;
  64. BACKGROUNDS['white']  = ['#ccf', '#ffc', '#cfc', '#fcc', '#cff', '#fcf', '#ccc'];
  65. BACKGROUNDS['white2'] = ['#ccf', '#ffc', '#cfc', '#fcc', '#cff', '#fcf', '#ccc'];
  66. BACKGROUNDS['black']  = ['#006', '#330', '#303', '#033', '#300', '#030', '#333'];
  67. BACKGROUNDS['tango']  = ['#452830','#284542','#283145','#452845'];
  68. BACKGROUNDS['swamp']  = ['#C0C3B1', '#B0B8A1', '#A0A895','#909580'];
  69.  
  70. var POPUPBG = new Array;
  71. POPUPBG['white']  = 'yellow';
  72. POPUPBG['white2'] = 'yellow';
  73. POPUPBG['black']  = 'grey';
  74. POPUPBG['tango']  = 'grey';
  75. POPUPBG['swamp']  = 'yellow';
  76.  
  77. var POPUPBRD = new Array;
  78. POPUPBRD['white']  = 'black';
  79. POPUPBRD['white2'] = 'black';
  80. POPUPBRD['black']  = 'white';
  81. POPUPBRD['tango']  = 'white';
  82. POPUPBRD['swamp']  = 'black';
  83.  
  84. // Indentation per reply level
  85. const INDENT = '10px';
  86. const DAYS = 3;
  87. const COOKIENAME = "TreeView";
  88.  
  89. var options = {
  90.     // target: '#quickanswerdiv',
  91.     // post-submit callback
  92.     success: showResponse,
  93.     cache: false
  94. };
  95.  
  96. var jq;
  97. var st;
  98. jq = $;
  99. st = setTimeout;
  100. function ctrl_enter(e, form) {
  101.     if (((e.keyCode == 13) || (e.keyCode == 10)) && (e.ctrlKey)) {
  102.         jq("#quickanswerform").ajaxForm(options).submit();
  103.     }
  104. }
  105.  
  106. function jump(link) {
  107.     return 1;
  108. }
  109. function image_onload(elem) {
  110.     var width = elem.naturalWidth;
  111.     if (width < 320) {
  112.         elem.style.width = '';
  113.     }
  114. }
  115. window.onbeforeunload = null;
  116.  
  117. var msgs = -1;
  118. var thread_id;
  119. var topic = jq('div.messages article[id*="topic-"]');
  120. if (topic.length) {
  121.     thread_id = topic.attr('id').split('-')[1];
  122. } else {
  123.     alert('Error: can not detect thread ID.');
  124. }
  125.  
  126. var cnt = getCounter(thread_id, 0);
  127. var newid = new Array;
  128.  
  129.  
  130. jq('link').each(function() {
  131.     var found = this.href.match(/\/([^/]*)\/combined\.css/);
  132.     if (found) {
  133.         THEME = found[0].split('/')[1];
  134.         if (THEME == 'tango') {
  135.             var subtheme = readCookie("style_selected");
  136.             if (subtheme == 'tango-swamp') {
  137.                 THEME = 'swamp';
  138.             }
  139.         }
  140.     }
  141. });
  142.  
  143.  
  144. jq('<div id="popupContact"><br><h2><span id="popupMsgs">0</span> new messages</h2><br></div>').hide().appendTo('body');
  145. jq("#popupContact").css({
  146.     "background-color": POPUPBG[THEME],
  147.     "padding": "10px",
  148.     "border": "1px solid " + POPUPBRD[THEME],
  149.     "position": "fixed",
  150.     "top": (document.documentElement.clientHeight - 200)/2,
  151.     "left": (document.documentElement.clientWidth  - 300)/2
  152. });
  153.  
  154. jq('<div id="popupPreview"></div>').hide().appendTo('body');
  155.  
  156. jq("#popupPreview").css({
  157.     "text-align": "left",
  158.     "background-color": POPUPBG[THEME],
  159.     "padding": "5px",
  160.     "border": "1px solid " +  POPUPBRD[THEME],
  161.     "position": "fixed",
  162.     "top":  (document.documentElement.clientHeight)/5,
  163.     "left": 50
  164. });
  165.  
  166. jq('.msg-container').css('margin-left', '0.5em');
  167.  
  168. //start: Сообщить модератору (based on http://infoman.name/userscripts)
  169.  
  170. jq.GMReport = {
  171.     topicnum: null
  172. }
  173.  
  174. GMReportFunctions = {
  175.     // Save topic number in cache
  176.     savetopicnum: function() {
  177.         createCookie("topicnum",jq.GMReport.topicnum,DAYS)
  178.         createCookie("topictime", new Date().getTime().toString(),DAYS);
  179.     },
  180.  
  181.     fetchtopicnum: function() {
  182.         jq.GMReport.topicnum = -1;
  183.         var req = new XMLHttpRequest();
  184.         req.open('GET', location.protocol + '//www.linux.org.ru/group.jsp?group=4068', true);
  185.         req.onreadystatechange = function (e) {
  186.             if (req.readyState == 4) {
  187.                 if(req.status == 200)
  188.                 {
  189.                     jq(req.responseText).find("img[alt='Прикреплено']").each(function()
  190.                     {
  191.                         var link = jq(this).next("a");
  192.                         if (/Ссылки.*некор/i.test(link.html()))
  193.                         {
  194.                             jq.GMReport.topicnum = /linux-org-ru\/(\d+)/.exec(link.attr("href"))[1];
  195.                             GMReportFunctions.savetopicnum();
  196.                         }
  197.                     });
  198.                 } else
  199.                     alert("Cannot get reports topic number");
  200.             }
  201.         }
  202.         req.send(null);
  203.     },
  204.  
  205.     // Get topic number for sending reports
  206.     gettopicnum: function() {
  207.         if (jq.GMReport.topicnum == null) {
  208.             var num = readCookie("topicnum");
  209.             var time = new Number(readCookie("topictime"));
  210.             var cur = new Date().getTime();
  211.             if ((num != null) && ((cur - time) < 7200000))
  212.                 jq.GMReport.topicnum = num;
  213.             else
  214.                 GMReportFunctions.fetchtopicnum();
  215.         }
  216.         if (jq.GMReport.topicnum == -1)
  217.             st(GMReportFunctions.gettopicnum, 100);
  218.         if (jq.GMReport.topicnum > 0)
  219.             letsGo();
  220.     }
  221. }
  222.  
  223. GMReportFunctions.gettopicnum();
  224.  
  225. // All your GM code must be inside this function
  226. function letsGo() {
  227.     jq("div.reply").each(function() {
  228.         var div = jq(this);
  229.         if (/^[^Ответ]/.test(div.html()))
  230.             div.append("[<a class='lor-report-msg' href='javascript:{/*Сообщить модератору (страница не будет перезагружена)*/}'>Сообщить модератору</a>]");
  231.     });
  232.  
  233.  
  234.     jq("a.lor-report-msg").click(function() {
  235.         // hack: why .unbind() doesn't work
  236.         if (jq(this).html() == "Просмотреть")
  237.             return true;
  238.  
  239.         var comment = prompt("Please provide a comment about this message", "Нацпол");
  240.         if (comment === null)
  241.             return false;
  242.         // Constructing message for posting
  243.         var msgtext = null;
  244.         var reportlink = jq(this);
  245.         var  url1 = reportlink.parent().parent().parent().parent().find("div.msg_body h1 a:first");
  246.         if (url1.length == 0)
  247.             url1 = reportlink.parent().find("li:nth-child(2) a:first");
  248.  
  249.         if (!msgtext)
  250.             msgtext = comment + " : " + url1.get(0).href;
  251.  
  252.         var message = {
  253.             csrf: /CSRF_TOKEN="(.+)"/.exec(document.cookie)[1],
  254.             topic:    jq.GMReport.topicnum,
  255.             title:    "",
  256.             msg:      msgtext
  257.         }
  258.         jq.post(location.protocol + "//www.linux.org.ru/add_comment.jsp", message, function(data) {
  259.             var allmsgs = jq(data).find("article.msg");
  260.             var reportnum = /\d+/.exec(allmsgs.eq(allmsgs.length - 1).attr("id"))[0];
  261.             reportlink.unbind().attr("href", location.protocol + "//www.linux.org.ru/jump-message.jsp?msgid=" + jq.GMReport.topicnum + "&cid=" + reportnum).html("Просмотреть");
  262.         })
  263.  });
  264. }
  265.  
  266. //end: Сообщить модератору
  267.  
  268. function createCookie(name,value,days) {
  269.     var expires;
  270.     if (days) {
  271.         var date = new Date();
  272.         date.setTime(date.getTime()+(days*24*60*60*1000));
  273.         expires = "; expires="+date.toGMTString();
  274.     } else
  275.         expires = "";
  276.     document.cookie = name+"="+value+expires+"; path=/";
  277. }
  278.  
  279. function readCookie(name) {
  280.         var nameEQ = name + "=";
  281.         var ca = document.cookie.split(';');
  282.         for(var i=0; i<ca.length; i++) {
  283.                 var c = ca[i];
  284.                 while (c.charAt(0)==' ') c = c.substring(1,c.length);
  285.                 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  286.         }
  287.         return null;
  288. }
  289.  
  290. function jq_get(url, callback) {
  291.     var data = {};
  292.     var param = url.split('?')[1];
  293.     var url = url.split('?')[0];
  294.     if (param) {
  295.         var params = param.split('&');
  296.         for (var i=0; i<params.length; i++) {
  297.             var key = params[i].split('=')[0];
  298.             var val = params[i].split('=')[1];
  299.             switch (key) {
  300.             case 'msgid':
  301.                 data[key] = val;
  302.                 break;
  303.             case 'page':
  304.                 data[key] = val;
  305.                 break;
  306.             case 'filter':
  307.                 data[key] = val;
  308.                 break;
  309.             }
  310.         }
  311.     }
  312.     jq.ajaxSetup({cache: false});
  313.     jq.get(url, data, callback);
  314. }
  315.  
  316.  
  317.  
  318. //get from Cookie or GM stored thread's message counter
  319. function getCounter(msg_id, update) {
  320.     var count = null;
  321.     var str = readCookie(COOKIENAME);
  322.     if (str) {
  323.         var flag = 0;
  324.         var d = new Date();
  325.         var nowtime = d.getTime();
  326.         var newarr = new Array;
  327.         var arr = str.split("_");
  328.         var j;
  329.         var k = 0;
  330.         newarr[k++] = "";
  331.         for (var i=1; i<arr.length; i+=3){
  332.             if (arr[i] == msg_id) {
  333.                 // found
  334.                 j = i+1;
  335.                 count = arr[j];
  336.             } //if
  337.             j = i+2;
  338.             if (arr[j] > nowtime) {
  339.                 j=i;
  340.                 newarr[k++] = arr[j++];
  341.                 newarr[k++] = arr[j++];
  342.                 newarr[k++] = arr[j++];
  343.             } else {
  344.                 flag = 1; // will purge expired records
  345.             } //if
  346.  
  347.         } //for
  348.         if (flag) {
  349.             str = newarr.join("_");
  350.             createCookie(COOKIENAME, str, DAYS);
  351.         }
  352.     } //if(str)
  353.     if (!count) {
  354.         if (update) {
  355.             count = jq("div.comment article.msg").length;
  356.         } else {
  357.             count = 0;
  358.         }
  359.     }
  360.     return count;
  361. }
  362.  
  363. function setCounter(msg_id, value) {
  364.     var d = new Date();
  365.     var expireat = d.getTime();
  366.     expireat += DAYS * 24 * 60 * 60 * 1000;
  367.  
  368.     var flag = 0;
  369.     var str = readCookie(COOKIENAME);
  370.     if (str) {
  371.         var arr = str.split("_");
  372.         for (var i=1; i<arr.length; i+=3){
  373.             if (arr[i] == msg_id) {
  374.                 // found
  375.                 arr[++i] = value;
  376.                 arr[++i] = expireat;
  377.                 flag = 1;
  378.                 break;
  379.             }
  380.         }
  381.     } else {
  382.         str = "";
  383.     }
  384.  
  385.     if (flag) {
  386.         // updated
  387.         str = arr.join("_");
  388.     } else {
  389.         // new one
  390.         str = str + "_" + msg_id + "_" + value + "_" + expireat;
  391.     }
  392.     createCookie(COOKIENAME, str, DAYS);
  393. }
  394.  
  395. //
  396. // callback function on UPDATE action
  397. //
  398. function onAjaxSuccess(data) {
  399.     // data is html returned by server
  400.     var up_div = jq(data).find('div.comment article.msg');
  401.  
  402.     // number of messages received from server
  403.     var newmsgs = up_div.length;
  404.  
  405.     // [newmsgs > msgs] means that there are new messages
  406.     if (newmsgs > msgs) {
  407.         newid.length = 0;
  408.         if (msgs > 0) {
  409.             up_div.slice(msgs,newmsgs).each(doindent);
  410.         } else {
  411.             up_div.each(doindent);
  412.         }
  413.         // update message counter
  414.         jq("#popupMsgs").text(newmsgs-msgs);
  415.         msgs = jq('div.comment article.msg').length;
  416.         setCounter(thread_id, msgs);
  417.         cnt = msgs;
  418.  
  419.         jq('a._new_').remove();
  420.         addNavigateLinks(newid);
  421.         if (document.getElementById(newid[0]))  document.getElementById(newid[0]).scrollIntoView();
  422.         newid.length = 0;
  423.  
  424.     } else {
  425.         // no news
  426.         // drop temp data
  427.         jq("#popupMsgs").text('0');
  428.     }
  429.     jq("#popupContact").show();
  430.     st('$("#popupContact").hide();',3000);
  431. }
  432.  
  433.  
  434. function quickAnswer(elem) {
  435.     var topic;
  436.     var replyto;
  437.     var href = elem.search;
  438.     var session = /CSRF_TOKEN="(.+)"/.exec(document.cookie)[1];
  439.  
  440.     var seltxt;
  441.     try {
  442.         seltxt = window.getSelection().toString();
  443.     } catch(err){
  444.         alert(err);
  445.     }
  446.     if (seltxt) {
  447.         seltxt = '> ' + seltxt + "\n";
  448.     }
  449.  
  450.     jq("#quickanswerdiv").remove();
  451.  
  452.     var formhtml1 = '<form id="quickanswerform" method="POST" action="add_comment.jsp"> <input type="hidden" name="csrf" value="' + session + '"/>  <input type="hidden" name="topic" value="';
  453.     var formhtml2 = '<input type="text" name="title" size="73" value=""/><br> <textarea name="msg" cols="70" rows="10" onkeypress="return ctrl_enter(event, this.form);">'+seltxt+'</textarea><br> <input type="hidden" name="texttype" value="0"/><br><input type="submit" value="Отправить"/><input type="submit" value="Предпросмотр" name="preview"/></form>';
  454.  
  455.     if (href.match(/replyto=/)) {
  456.         topic   = href.replace(/^.*topic=(\d+).*$/, "$1");
  457.         replyto = href.replace(/^.*replyto=(\d+).*$/, "$1");
  458.         formhtml1 = formhtml1 + topic + '"/> <input type="hidden" name="replyto" value="'+replyto+'"/>';
  459.     } else {
  460.         topic   = href.replace(/^.*topic=(\d+).*$/, "$1");
  461.         formhtml1 = formhtml1 + topic + '"/>';
  462.     }
  463.  
  464.     jq(elem).parent().append('<div id="quickanswerdiv">' + formhtml1 + formhtml2 + '</div>');
  465.  
  466.     jq("#quickanswerform").ajaxForm(options);
  467.  
  468.     jq("textarea[name=msg]").focus();
  469.  
  470. }
  471.  
  472.  
  473. function showResponse(responseText, statusText) {
  474.     // data is html returned by server
  475.     var h1txt = jq(responseText).find('div.error').text();
  476.     if (h1txt) {
  477.         alert(h1txt);
  478.         return;
  479.     }
  480.     h1txt = jq(responseText).find('p:contains("Ваше сообщение")').text();
  481.     if (h1txt) {
  482.         var rmsg = jq(responseText).find('div.messages');
  483.         if (rmsg) {
  484.             jq("#popupPreview").get(0).innerHTML = rmsg.get(rmsg.length - 1).innerHTML;
  485.             jq("#popupPreview").show();
  486.             st('$("#popupPreview").hide();',5000);
  487.         }
  488.     } else {
  489.         //up_div.empty();
  490.         jq("#quickanswerdiv").remove();
  491.         jq_get(document.location.href, onAjaxSuccess);
  492.     }
  493. }
  494.  
  495. //add a link with "text", "url" and "id" after <<elem>> html object.
  496. function addNavButton(elem, text, url, cls){
  497.     var newA = document.createElement("a");
  498.     newA.href = url;
  499.     newA.className = cls;
  500.     newA.textContent = text;
  501.     newA.style.paddingLeft = "20px !important";
  502.     newA.style.color = COLOR[THEME] + '!important';
  503.     elem.appendChild(document.createTextNode(' '));
  504.     elem.appendChild(newA);
  505. }
  506.  
  507. //add navigation links (First/Next/Prev/Last) for recently added messages
  508. function addNavigateLinks(msg_array){
  509.     var len = msg_array.length;
  510.     //Add navigation buttons for new messages
  511.     for (var i=0; i<len; i++){
  512.         var msgTD = jq("#"+msg_array[i]+" div.title").get(0);
  513.         if (msgTD) {
  514.             //next message
  515.             var nText = "[Next new]";
  516.             var n = i + 1;
  517.             if (n >= len) {
  518.                 n = 0;
  519.                 nText = "[First new]";
  520.                 var titleA = jq("div.title").get(0);
  521.                 if (titleA) {
  522.                     addNavButton(titleA,
  523.                                  nText,
  524.                                  'javascript:document.getElementById("' + msg_array[n] + '").scrollIntoView()', "sign_more _new_"
  525.                                 );
  526.                 }
  527.             }
  528.             addNavButton(msgTD, nText, 'javascript:document.getElementById("' + msg_array[n] + '").scrollIntoView()', "sign_more _new_");
  529.  
  530.             //previous message
  531.             var pText = "[Prev new]";
  532.             var p = i - 1;
  533.             if (p < 0) {
  534.                 p = len - 1;
  535.                 pText = "[Last new]";
  536.             }
  537.             addNavButton(msgTD,
  538.                          pText,
  539.                          'javascript:document.getElementById("' + msg_array[p] + '").scrollIntoView()', "sign_more _new_"
  540.                         );
  541.             }
  542.         }
  543. }
  544.  
  545. // ---------------------------------------------------------------------
  546. function doindent(index) {
  547.     this.setAttribute("treelevel", "0");  // initial indent level
  548. //    this.style.paddingBottom = "1px"; // style
  549. //    this.style.marginBottom  = "4px"; // style
  550.     var root;
  551.  
  552.     // store new id in array
  553.     if ((msgs+index+1) >= cnt) {
  554.         newid.push(this.id);
  555.     }
  556.  
  557.     root = jq("div.comment").get(0);
  558.  
  559.     // remove subject
  560. //  jq("h2", this).html('<hr>');
  561.  
  562.     var nick = jq("div.sign a:first",this).text();
  563.     if (nick) {
  564.         jq("div.title", this).append(' <a class = "sign_more" href="'+location.protocol + '//www.linux.org.ru/show-replies.jsp?output=rss&nick=' + nick + '" >[' + nick + ' events]</a>');
  565.     }
  566.     // append [update page] link
  567.     jq("div.title", this).append(' <a href="#" class="sign_more updatepage">[update page]</a>');
  568.     jq('a.updatepage', this).click(function(event) {
  569.         jq_get(document.location.href, onAjaxSuccess);
  570.         event.preventDefault();
  571.     });
  572.     var ign = jq('span.user-remark:contains("###"):first', this);
  573.     if (ign.length) {
  574.         ign.parent().parent().hide();
  575.             jq("div.title", this).append('<a href="javascript:{}" class="vtoggle">[show/hide]</a>');
  576.             jq('a.vtoggle', this).click(function(event) {
  577.                 jq('div[class*="msg_body"]:first', jq(this).parent().parent()).toggle();
  578.                 event.preventDefault();
  579.             });
  580.  
  581.     }
  582.  
  583.     // do all links colored black
  584.     if (ALTERLINKS) {
  585.         if (THEME != 'tango' || THEME != 'swamp') {
  586.             jq("a", this).css('cssText', 'color: ' + COLOR[THEME] + ' !important');
  587.         }
  588.     }
  589.     jq(".sign", this).css('cssText', 'text-align: left');
  590.  
  591.     // enumerate message
  592.     jq("div.title", this).prepend('['+(msgs+index+1) + '] ');
  593. //    jq("div.title a:first", this).each(function () {
  594. //        this.setAttribute("class", "counter");
  595. //    });
  596.  
  597.     // quick answer
  598.     if (USE_QUICK_ANSWER) {
  599.         jq('a:contains("Ответить на это сообщение")', this).click(function(event) {
  600.             event.preventDefault();
  601.             quickAnswer(this);
  602.         });
  603.     }
  604.  
  605.     // is a message answer to other (non root) message?
  606.     var a = jq('div.title a[data-samepage="samePage"]', this);
  607.     if (a.length) {
  608.         // #Id of reply message <DIV>
  609.         var idr = a.attr('href').split('cid=')[1];
  610.         idr='comment-'+idr;
  611.         // "parent" message
  612.         var idr_msg   = document.getElementById(idr);
  613.         // child's indent level
  614.         var idr_level = idr_msg.getAttribute("treelevel");
  615.         idr_level++;
  616.  
  617.         // save child's indent level
  618.         this.setAttribute("treelevel", idr_level);
  619.  
  620.         // move child to parent
  621.         idr_msg.appendChild(this);
  622.         // choose color accordingly to indent level
  623.         var bgcolor = BACKGROUNDS[THEME][idr_level % BACKGROUNDS[THEME].length] + ' !important';
  624.         // set background color to .title and .body
  625.         jq('article#' + this.id + ', article#' + this.id +' div.title').css('cssText', "padding-bottom: 1px; margin-bottom: 4px; padding-left: 0px; padding-right: " + INDENT + "; margin-left: " + INDENT + "; background-color: " + bgcolor);
  626.  
  627.     } else {
  628.         if (msgs > -1) {
  629.             root.appendChild(this);
  630.         }
  631.     }
  632. }
  633. // ---------------------------------------------------------------------
  634.  
  635.  
  636. jq('#commentForm').remove();
  637.  
  638. function makeTree() {
  639.     msgs = -1;
  640.     jq(".updatepage,._new_").remove();
  641.  
  642.     jq("article.msg").each(doindent);
  643.     idx = newid.shift(); // remove topic
  644.  
  645.     addNavigateLinks(newid);
  646.     newid.length = 0;
  647.     // set message counter
  648.     msgs = jq('div.comment article.msg').length;
  649.     setCounter(thread_id, msgs);
  650. }
  651.  
  652. makeTree();
  653.  
  654. //var h1subj = jq('div.msg_body h1').get(0);
  655. //h1subj.innerHTML = '<br><u>' + h1subj.innerHTML + '</u><br><br>';
  656.  
  657. var urlhash = document.location.hash;
  658. if (urlhash) {
  659.     urlhash = urlhash.split('#')[1];
  660.     document.getElementById(urlhash).scrollIntoView();
  661. }
  662.  
  663. window.onbeforeunload = null;
  664.  
  665. // ---------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement