Advertisement
Guest User

real_editado

a guest
Jan 25th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // deleta caixa de texto e vai ate o rodape da pagina
  2.  
  3.     // anti popup
  4. var cssId = 'antiPopup';
  5. if (!document.getElementById(cssId))
  6. {
  7.     var head  = document.getElementsByTagName('head')[0];
  8.     var link  = document.createElement('link');
  9.     link.id   = cssId;
  10.     link.rel  = 'stylesheet';
  11.     link.type = 'text/css';
  12.     link.href = 'https://files.catbox.moe/uhvi7v.css';
  13.     link.media = 'all';
  14.     head.appendChild(link);
  15. }
  16.  
  17.     // board list
  18. if (device_type == 'desktop') {
  19.     compact_boardlist = true;
  20.  
  21.     do_boardlist = function() {
  22.       var categories = [];
  23.       var topbl = $('.boardlist:first');
  24.  
  25.       topbl.find('>.sub').each(function() {
  26.         var cat = {name: $(this).data('description'), boards: []};
  27.         $(this).find('a').each(function() {
  28.           var board = {name: $(this).prop('title'), uri: $(this).html(), href: $(this).prop('href') }
  29.           cat.boards.push(board);
  30.         });
  31.         categories.push(cat);
  32.       });
  33.  
  34.       topbl.addClass("compact-boardlist")
  35.          .html("");
  36.  
  37.       for (var i in categories) {
  38.         var item = categories[i];
  39.  
  40.         if (item.name.match(/^icon_/)) {
  41.           var icon = item.name.replace(/^icon_/, '')
  42.           $("<a class='cb-item cb-icon' href='"+categories[i].boards[0].href+"'><img src='/static/icons/"+icon+".png'></a>")
  43.           .appendTo(topbl)
  44.         }
  45.         else if (item.name.match(/^fa_/)) {
  46.           var icon = item.name.replace(/^fa_/, '')
  47.           $('<a class="cb-item cb-fa" href="'+categories[i].boards[0].href+'"><i class="fa-'+icon+' fa"></i></a>')
  48.             .appendTo(topbl)
  49.         }
  50.         else if (item.name.match(/^d_/)) {
  51.           var icon = item.name.replace(/^d_/, '')
  52.           $('<a class="cb-item cb-cat" href="'+categories[i].boards[0].href+'">'+icon+'</a>')
  53.             .appendTo(topbl)
  54.         }
  55.         else {
  56.           $("<a class='cb-item cb-cat' href='javascript:void(0)'>"+item.name+"</a>")
  57.          .appendTo(topbl)
  58.         .mouseenter(function() {
  59.           var list = $("<div class='boardlist top cb-menu'></div>")
  60.             .css("top", $(this).position().top + 13 + $(this).height())
  61.             .css("left", $(this).position().left)
  62.             .css("right", "auto")
  63.             .appendTo(this);
  64.           for (var j in this.item.boards) {
  65.             var board = this.item.boards[j];
  66.              
  67.             var tag;
  68.                 if (board.name) {
  69.               tag = $("<a href='"+board.href+"'><span>"+board.name+"</span><span class='cb-uri'>/"+board.uri+"/</span></a>")
  70.             }
  71.             else {
  72.               tag = $("<a href='"+board.href+"'><span>"+board.uri+"</span><span class='cb-uri'><i class='fa fa-globe'></i></span></a>")
  73.             }
  74.             tag
  75.           .addClass("cb-menuitem")
  76.                   .appendTo(list)
  77.           }
  78.         })
  79.         .mouseleave(function() {
  80.           topbl.find(".cb-menu").remove();
  81.         })[0].item = item;
  82.         }
  83.       }
  84.       do_boardlist = undefined;
  85.     };
  86.   }
  87.  
  88.   // quick reply
  89. /*
  90.  * quick-reply.js
  91.  * https://github.com/savetheinternet/Tinyboard/blob/master/js/quick-reply.js
  92.  *
  93.  * Released under the MIT license
  94.  * Copyright (c) 2013 Michael Save <savetheinternet@tinyboard.org>
  95.  * Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
  96.  *
  97.  * Usage:
  98.  *   $config['additional_javascript'][] = 'js/jquery.min.js';
  99.  *   $config['additional_javascript'][] = 'js/jquery-ui.custom.min.js'; // Optional; if you want the form to be draggable.
  100.  *   $config['additional_javascript'][] = 'js/quick-reply.js';
  101.  *
  102.  */
  103.  
  104. (function() {
  105.     var settings = new script_settings('quick-reply');
  106.    
  107.     var do_css = function() {
  108.         $('#quick-reply-css').remove();
  109.        
  110.         // Find background of reply posts
  111.         var dummy_reply = $('<div class="post reply"></div>').appendTo($('body'));
  112.         var reply_background = dummy_reply.css('backgroundColor');
  113.         var reply_border_style = dummy_reply.css('borderStyle');
  114.         var reply_border_color = dummy_reply.css('borderColor');
  115.         var reply_border_width = dummy_reply.css('borderWidth');
  116.         dummy_reply.remove();
  117.        
  118.         $('<style type="text/css" id="quick-reply-css">\
  119.         #quick-reply {\
  120.             position: fixed;\
  121.             right: 5%;\
  122.             top: 5%;\
  123.             float: right;\
  124.             display: block;\
  125.             padding: 0 0 0 0;\
  126.             width: 300px;\
  127.             z-index: 100;\
  128.         }\
  129.         #quick-reply table {\
  130.             border-collapse: collapse;\
  131.             background: ' + reply_background + ';\
  132.             border-style: ' + reply_border_style + ';\
  133.             border-width: ' + reply_border_width + ';\
  134.             border-color: ' + reply_border_color + ';\
  135.             margin: 0;\
  136.             width: 100%;\
  137.         }\
  138.         #quick-reply tr td:nth-child(2) {\
  139.             white-space: nowrap;\
  140.             text-align: right;\
  141.             padding-right: 4px;\
  142.         }\
  143.         #quick-reply tr td:nth-child(2) input[type="submit"] {\
  144.             width: 100%;\
  145.         }\
  146.         #quick-reply th, #quick-reply td {\
  147.             margin: 0;\
  148.             padding: 0;\
  149.         }\
  150.         #quick-reply th {\
  151.             text-align: center;\
  152.             padding: 2px 0;\
  153.             border: 1px solid #222;\
  154.         }\
  155.         #quick-reply th .handle {\
  156.             float: left;\
  157.             width: 100%;\
  158.             display: inline-block;\
  159.         }\
  160.         #quick-reply th .close-btn {\
  161.             float: right;\
  162.             padding: 0 5px;\
  163.         }\
  164.         #quick-reply input[type="text"], #quick-reply select {\
  165.             width: 100%;\
  166.             padding: 2px;\
  167.             font-size: 10pt;\
  168.             box-sizing: border-box;\
  169.             -webkit-box-sizing:border-box;\
  170.             -moz-box-sizing: border-box;\
  171.         }\
  172.         #quick-reply textarea {\
  173.             width: 100%;\
  174.             min-width: 100%;\
  175.             box-sizing: border-box;\
  176.             -webkit-box-sizing:border-box;\
  177.             -moz-box-sizing: border-box;\
  178.             font-size: 10pt;\
  179.             resize: vertical horizontal;\
  180.         }\
  181.         #quick-reply input, #quick-reply select, #quick-reply textarea {\
  182.             margin: 0 0 1px 0;\
  183.         }\
  184.         #quick-reply input[type="file"] {\
  185.             padding: 5px 2px;\
  186.         }\
  187.         #quick-reply .nonsense {\
  188.             display: none;\
  189.         }\
  190.         #quick-reply td.submit {\
  191.             width: 1%;\
  192.         }\
  193.         #quick-reply td.recaptcha {\
  194.             text-align: center;\
  195.             padding: 0 0 1px 0;\
  196.         }\
  197.         #quick-reply td.recaptcha span {\
  198.             display: inline-block;\
  199.             width: 100%;\
  200.             background: white;\
  201.             border: 1px solid #ccc;\
  202.             cursor: pointer;\
  203.         }\
  204.         #quick-reply td.recaptcha-response {\
  205.             padding: 0 0 1px 0;\
  206.         }\
  207.         @media screen and (max-width: 400px) {\
  208.             #quick-reply {\
  209.                 display: none !important;\
  210.             }\
  211.         }\
  212.         </style>').appendTo($('head'));
  213.     };
  214.    
  215.     var show_quick_reply = function(){
  216.         if($('div.banner').length == 0)
  217.             return;
  218.         if($('#quick-reply').length != 0)
  219.             return;
  220.        
  221.         do_css();
  222.        
  223.         var $postForm = $('form[name="post"]').clone();
  224.        
  225.         $postForm.clone();
  226.        
  227.         $dummyStuff = $('<div class="nonsense"></div>').appendTo($postForm);
  228.        
  229.         $postForm.find('table tr').each(function() {
  230.             var $th = $(this).children('th:first');
  231.             var $td = $(this).children('td:first');    
  232.             if ($th.length && $td.length) {
  233.                 $td.attr('colspan', 2);
  234.    
  235.                 if ($td.find('input[type="text"]').length) {
  236.                     // Replace <th> with input placeholders
  237.                     $td.find('input[type="text"]')
  238.                         .removeAttr('size')
  239.                         .attr('placeholder', $th.clone().children().remove().end().text());
  240.                 }
  241.    
  242.                 // Move anti-spam nonsense and remove <th>
  243.                 $th.contents().filter(function() {
  244.                     return this.nodeType == 3; // Node.TEXT_NODE
  245.                 }).remove();
  246.                 $th.contents().appendTo($dummyStuff);
  247.                 $th.remove();
  248.    
  249.                 if ($td.find('input[name="password"]').length) {
  250.                     // Hide password field
  251.                     $(this).hide();
  252.                 }
  253.    
  254.                 // Fix submit button
  255.                 if ($td.find('input[type="submit"]').length) {
  256.                     $td.removeAttr('colspan');
  257.                     $('<td class="submit"></td>').append($td.find('input[type="submit"]')).insertAfter($td);
  258.                 }
  259.    
  260.                 // reCAPTCHA
  261.                 if ($td.find('#recaptcha_widget_div').length) {
  262.                     // Just show the image, and have it interact with the real form.
  263.                     var $captchaimg = $td.find('#recaptcha_image img');
  264.                    
  265.                     $captchaimg
  266.                         .removeAttr('id')
  267.                         .removeAttr('style')
  268.                         .addClass('recaptcha_image')
  269.                         .click(function() {
  270.                             $('#recaptcha_reload').click();
  271.                         });
  272.                    
  273.                     // When we get a new captcha...
  274.                     $('#recaptcha_response_field').focus(function() {
  275.                         if ($captchaimg.attr('src') != $('#recaptcha_image img').attr('src')) {
  276.                             $captchaimg.attr('src', $('#recaptcha_image img').attr('src'));
  277.                             $postForm.find('input[name="recaptcha_challenge_field"]').val($('#recaptcha_challenge_field').val());
  278.                             $postForm.find('input[name="recaptcha_response_field"]').val('').focus();
  279.                         }
  280.                     });
  281.                    
  282.                     $postForm.submit(function() {
  283.                         setTimeout(function() {
  284.                             $('#recaptcha_reload').click();
  285.                         }, 200);
  286.                     });
  287.                    
  288.                     // Make a new row for the response text
  289.                     var $newRow = $('<tr><td class="recaptcha-response" colspan="2"></td></tr>');
  290.                     $newRow.children().first().append(
  291.                         $td.find('input').removeAttr('style')
  292.                     );
  293.                     $newRow.find('#recaptcha_response_field')
  294.                         .removeAttr('id')
  295.                         .addClass('recaptcha_response_field')
  296.                         .attr('placeholder', $('#recaptcha_response_field').attr('placeholder'));
  297.                    
  298.                     $('#recaptcha_response_field').addClass('recaptcha_response_field')
  299.                    
  300.                     $td.replaceWith($('<td class="recaptcha" colspan="2"></td>').append($('<span></span>').append($captchaimg)));
  301.                    
  302.                     $newRow.insertAfter(this);
  303.                 }
  304.    
  305.                 // Upload section
  306.                 if ($td.find('input[type="file"]').length) {
  307.                     if ($td.find('input[name="file_url"]').length) {
  308.                         $file_url = $td.find('input[name="file_url"]');
  309.                        
  310.                         if (settings.get('show_remote', false)) {
  311.                             // Make a new row for it
  312.                             var $newRow = $('<tr><td colspan="2"></td></tr>');
  313.                        
  314.                             $file_url.clone().attr('placeholder', _('Upload URL')).appendTo($newRow.find('td'));
  315.                        
  316.                             $newRow.insertBefore(this);
  317.                         }
  318.                         $file_url.parent().remove();
  319.  
  320.                        
  321.                         $td.find('label').remove();
  322.                         $td.contents().filter(function() {
  323.                             return this.nodeType == 3; // Node.TEXT_NODE
  324.                         }).remove();
  325.                         $td.find('input[name="file_url"]').removeAttr('id');
  326.                     }
  327.                    
  328.                     if ($(this).find('input[name="spoiler"]').length) {
  329.                         $td.removeAttr('colspan');
  330.                     }
  331.                 }
  332.  
  333.                 // Disable embedding if configured so
  334.                 if (!settings.get('show_embed', false) && $td.find('input[name="embed"]').length) {
  335.                     $(this).remove();
  336.                 }
  337.  
  338.                 // Remove oekaki if existent
  339.                 if ($(this).is('#oekaki')) {
  340.                     $(this).remove();
  341.                 }
  342.  
  343.                 // Remove upload selection
  344.                 if ($td.is('#upload_selection')) {
  345.                     $(this).remove();
  346.                 }
  347.                
  348.                 // Remove mod controls, because it looks shit.
  349.                 if ($td.find('input[type="checkbox"]').length) {
  350.                     var tr = this;
  351.                     $td.find('input[type="checkbox"]').each(function() {
  352.                         if ($(this).attr('name') == 'spoiler') {
  353.                             $td.find('label').remove();
  354.                             $(this).attr('id', 'q-spoiler-image');
  355.                             $postForm.find('input[type="file"]').parent()
  356.                                 .removeAttr('colspan')
  357.                                 .after($('<td class="spoiler"></td>').append(this, ' ', $('<label for="q-spoiler-image">').text(_('Spoiler Image'))));
  358.                         } else if ($(this).attr('name') == 'no_country') {
  359.                             $td.find('label,input[type="checkbox"]').remove();
  360.                         } else {
  361.                             $(tr).remove();
  362.                         }
  363.                     });
  364.                 }
  365.                
  366.                 $td.find('small').hide();
  367.             }
  368.         });
  369.        
  370.         $postForm.find('textarea[name="body"]').removeAttr('id').removeAttr('cols').attr('placeholder', _('Comment'));
  371.    
  372.         $postForm.find('textarea:not([name="body"]),input[type="hidden"]:not(.captcha_cookie)').removeAttr('id').appendTo($dummyStuff);
  373.    
  374.         $postForm.find('br').remove();
  375.         $postForm.find('table').prepend('<tr><th colspan="2">\
  376.             <span class="handle">\
  377.                 <a class="close-btn" href="javascript:void(0)">×</a>\
  378.                 ' + _('Quick Reply') + '\
  379.             </span>\
  380.             </th></tr>');
  381.        
  382.         $postForm.attr('id', 'quick-reply');
  383.        
  384.         $postForm.appendTo($('body')).hide();
  385.         $origPostForm = $('form[name="post"]:first');
  386.        
  387.         // Synchronise body text with original post form
  388.         $origPostForm.find('textarea[name="body"]').on('change input propertychange', function() {
  389.             $postForm.find('textarea[name="body"]').val($(this).val());
  390.         });
  391.         $postForm.find('textarea[name="body"]').on('change input propertychange', function() {
  392.             $origPostForm.find('textarea[name="body"]').val($(this).val());
  393.         });
  394.         $postForm.find('textarea[name="body"]').focus(function() {
  395.             $origPostForm.find('textarea[name="body"]').removeAttr('id');
  396.             $(this).attr('id', 'body');
  397.         });
  398.         $origPostForm.find('textarea[name="body"]').focus(function() {
  399.             $postForm.find('textarea[name="body"]').removeAttr('id');
  400.             $(this).attr('id', 'body');
  401.         });
  402.         // Synchronise other inputs
  403.         $origPostForm.find('input[type="text"],select').on('change input propertychange', function() {
  404.             $postForm.find('[name="' + $(this).attr('name') + '"]').val($(this).val());
  405.         });
  406.         $postForm.find('input[type="text"],select').on('change input propertychange', function() {
  407.             $origPostForm.find('[name="' + $(this).attr('name') + '"]').val($(this).val());
  408.         });
  409.  
  410.         if (typeof $postForm.draggable != 'undefined') {   
  411.             if (localStorage.quickReplyPosition) {
  412.                 var offset = JSON.parse(localStorage.quickReplyPosition);
  413.                 if (offset.top < 0)
  414.                     offset.top = 0;
  415.                 if (offset.right > $(window).width() - $postForm.width())
  416.                     offset.right = $(window).width() - $postForm.width();
  417.                 if (offset.top > $(window).height() - $postForm.height())
  418.                     offset.top = $(window).height() - $postForm.height();
  419.                 $postForm.css('right', offset.right).css('top', offset.top);
  420.             }
  421.             $postForm.draggable({
  422.                 handle: 'th .handle',
  423.                 containment: 'window',
  424.                 distance: 10,
  425.                 scroll: false,
  426.                 stop: function() {
  427.                     var offset = {
  428.                         top: $(this).offset().top - $(window).scrollTop(),
  429.                         right: $(window).width() - $(this).offset().left - $(this).width(),
  430.                     };
  431.                     localStorage.quickReplyPosition = JSON.stringify(offset);
  432.                    
  433.                     $postForm.css('right', offset.right).css('top', offset.top).css('left', 'auto');
  434.                 }
  435.             });
  436.             $postForm.find('th .handle').css('cursor', 'move');
  437.         }
  438.        
  439.         $postForm.find('th .close-btn').click(function() {
  440.             $origPostForm.find('textarea[name="body"]').attr('id', 'body');
  441.             $postForm.remove();
  442.             floating_link();
  443.         });
  444.        
  445.         // Fix bug when table gets too big for form. Shouldn't exist, but crappy CSS etc.
  446.         $postForm.show();
  447.         $postForm.width($postForm.find('table').width());
  448.         $postForm.hide();
  449.        
  450.         $(window).trigger('quick-reply');
  451.    
  452.         $(window).ready(function() {
  453.             if (settings.get('hide_at_top', true)) {
  454.                 $(window).scroll(function() {
  455.                     if ($(this).width() <= 400)
  456.                         return;
  457.                     if ($(this).scrollTop() < $origPostForm.offset().top + $origPostForm.height() - 100)
  458.                         $postForm.fadeOut(100);
  459.                     else
  460.                         $postForm.fadeIn(100);
  461.                 }).scroll();
  462.             } else {
  463.                 $postForm.show();
  464.             }
  465.            
  466.             $(window).on('stylesheet', function() {
  467.                 do_css();
  468.                 if ($('link#stylesheet').attr('href')) {
  469.                     $('link#stylesheet')[0].onload = do_css;
  470.                 }
  471.             });
  472.         });
  473.     };
  474.    
  475.     $(window).on('cite', function(e, id, with_link) {
  476.         if ($(this).width() <= 400)
  477.             return;
  478.         show_quick_reply();
  479.         if (with_link) {
  480.             $(document).ready(function() {
  481.                 if ($('#' + id).length) {
  482.                     highlightReply(id);
  483.                     $(document).scrollTop($('#' + id).offset().top);
  484.                 }
  485.                
  486.                 // Honestly, I'm not sure why we need setTimeout() here, but it seems to work.
  487.                 // Same for the "tmp" variable stuff you see inside here:
  488.                 setTimeout(function() {
  489.                     var tmp = $('#quick-reply textarea[name="body"]').val();
  490.                     $('#quick-reply textarea[name="body"]').val('').focus().val(tmp);
  491.                 }, 1);
  492.             });
  493.         }
  494.     });
  495.    
  496.     var floating_link = function() {
  497.         if (!settings.get('floating_link', false))
  498.             return;
  499.         $('<a href="javascript:void(0)" class="quick-reply-btn">'+_('Quick Reply')+'</a>')
  500.             .click(function() {
  501.                 show_quick_reply();
  502.                 $(this).remove();
  503.             }).appendTo($('body'));
  504.        
  505.         $(window).on('quick-reply', function() {
  506.             $('.quick-reply-btn').remove();
  507.         });
  508.     };
  509.     document.getElementById("Responder").value = "";
  510.     if (settings.get('floating_link', false)) {
  511.         $(window).ready(function() {
  512.             if($('div.banner').length == 0)
  513.                 return;
  514.             $('<style type="text/css">\
  515.             a.quick-reply-btn {\
  516.                 position: fixed;\
  517.                 right: 0;\
  518.                 bottom: 0;\
  519.                 display: block;\
  520.                 padding: 5px 13px;\
  521.                 text-decoration: none;\
  522.             }\
  523.             </style>').appendTo($('head'));
  524.            
  525.             floating_link();
  526.            
  527.             if (settings.get('hide_at_top', true)) {
  528.                 $('.quick-reply-btn').hide();
  529.                
  530.                 $(window).scroll(function() {
  531.                     if ($(this).width() <= 400)
  532.                         return;
  533.                     if ($(this).scrollTop() < $('form[name="post"]:first').offset().top + $('form[name="post"]:first').height() - 100)
  534.                         $('.quick-reply-btn').fadeOut(100);
  535.                     else
  536.                         $('.quick-reply-btn').fadeIn(100);
  537.                 }).scroll();
  538.             }
  539.         });
  540.     }
  541. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement