Advertisement
Kalashnikov

LOR pda tracker

Sep 6th, 2013
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if ( document.location.hostname.match(/linux\.org\.ru$/) ) {
  2.     // DOMContentReady ???
  3.     var table = $(".message-table");
  4.     if (table && table.length) {
  5.         injectStyle();
  6.  
  7.         var list = $("<ul>").addClass("message-list");
  8.         list.css({
  9.             "margin": "0",
  10.             "padding": "0",
  11.             "list-style": "none",
  12.         });
  13.  
  14.         var rows = table.find("tr");
  15.         for (var i=0+1; i<rows.length; i++) {
  16.             var cells = $(rows[i]).children();
  17.  
  18.             if (cells.length == 4) {    // трекер
  19.                 var category = cells.eq(0).html();
  20.                 var title    = cells.eq(1).html();
  21.                 var time     = cells.eq(2).html();
  22.                 var numbers  = cells.eq(3).html();
  23.             }
  24.             else if (cells.length == 3) {   // форум
  25.                 var category = null;
  26.                 var title    = cells.eq(0).html();
  27.                 var time     = cells.eq(1).html();
  28.                 var numbers  = cells.eq(2).html();
  29.             }
  30.             else
  31.                 break;
  32.             list.append(formatItem( category, title, time, numbers ));
  33.         };
  34.  
  35.         table.replaceWith(list);
  36.        
  37.         list.on("click", "li", function() {
  38.             $(this).find("a").get(0).click();
  39.         });
  40.  
  41.  
  42.         function formatItem(category, title, time, numbers) {
  43.             var e = $("<li>");
  44.  
  45.             e.append(title)
  46.              .append("<br>")
  47.              .append( $("<small>").append(" Последнее: ").append(time).append(" Всего ответов: ").append(numbers) );
  48.  
  49.             e.find("a").eq(0).css("font-weight", "bold");   // название топика
  50.             return e;
  51.         };
  52.  
  53.         function injectStyle() {
  54.             var style = $("<style>");
  55.  
  56.             // в тч костыли для просранной семантики в цсс лора, для танго
  57.             style.text("\
  58. .message-list li {\
  59.     margin: 0!important;\
  60.     padding: 5px;\
  61.     border-bottom: 1px solid #555753;\
  62. }\
  63. \
  64. .message-list li:hover {\
  65.    background: #5c3566;\
  66. }\
  67. \
  68. .message-list a {\
  69.     color: #eeeeec;\
  70.     text-decoration: none;\
  71. }\
  72. \
  73. .message-list a:visited {\
  74.     #babdb6;\
  75. }\
  76. \
  77. .tag {\
  78.     border-radius: 3px;\
  79.     font-size: 0.8em;\
  80.     padding: 2px 4px;\
  81.     background-color: #555753;\
  82.     font-weight: normal;\
  83. }");
  84.             $("head").append(style);
  85.         }
  86.     };
  87. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement