Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.     //add buttons
  3.     $('.chatLog').append(`<div class="btn btn-success btn-toggle-chat-events">Game Events</div>`);
  4.     $('.chatLog').eq(0).css('max-height', '200px');
  5.     $('.chatLog').eq(1).css('max-height', '600px');
  6.  
  7.     var events = [];
  8.     $('.chatLog tr').each(function(){
  9.         var isLog;
  10.        
  11.         if ($(this).find('td').eq(1).find('span').length){
  12.             isLog = $(this).find('td').eq(1).find('span').html() ? false : true;
  13.         }else{
  14.             isLog = $(this).find('td').eq(1).html() ? false : true;
  15.         }
  16.  
  17.         var t = $(this).find('td').eq(0).html().split(':');
  18.         var time = (+t[0]) * 60 + (+t[1]);
  19.        
  20.         $(this).attr({
  21.             'data-line': $(this).index() + 1,
  22.             'data-log': isLog,
  23.             'data-time': time
  24.         });
  25.            
  26.         if (isLog){
  27.             var text = $(this).find('td').eq(3).text();
  28.                
  29.             if (text.split("]").length > 1 && text[0] == "["){
  30.                 text = text.replace(text.split("]")[0] + "]", "");
  31.                
  32.                 var found = $.grep(events, (e) => {
  33.                     return (text == e.text && time < e.time + 2) ? true : false;
  34.                 })
  35.                
  36.                 if(found.length){
  37.                     $(this).remove();
  38.                 }else{
  39.                     $(this).find('td').eq(3).text(text);
  40.                     events.push({
  41.                         text: text,
  42.                         time: time
  43.                     });
  44.                 }
  45.             }
  46.         }
  47.     })
  48.  
  49.    
  50.     $('.btn-toggle-chat-events').on('click', function(){
  51.         $(this).toggleClass('off');
  52.        
  53.         $(this).closest('.chatLog').find('tr[data-log="true"]').toggle();      
  54.     });
  55. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement