Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // post.js v2.1.1 Copyright (C) 2014-2016 Visman (mio.visman@yandex.ru)
  2. if (typeof FluxBB === 'undefined' || !FluxBB) {var FluxBB = {};}
  3.  
  4. FluxBB.post = (function (doc, win) {
  5.     'use strict';
  6.    
  7.     var nameusers = [],
  8.             bbcode = [],
  9.             lang = [],
  10.             fls = false,
  11.             typepost = (/pmsnew/.test(doc.location.pathname) ? 'pmquote' : 'quote'),
  12.             quote_text = '',
  13.             apq_id = -1,
  14.             apq_user,
  15.             apq_temp,
  16.             textarea,
  17.             flag_sm = true,
  18.             flag_cr = true;
  19.  
  20.     function get(elem) {
  21.         return doc.getElementById(elem);
  22.     }
  23.  
  24.     function getCN(classname, node) {
  25.         node = node || doc;
  26.         if (node.querySelectorAll) {
  27.             return node.querySelectorAll('.' + classname);
  28.         } else if (node.getElementsByClassName) {
  29.             return node.getElementsByClassName(classname);
  30.         }
  31.         return [];
  32.     }
  33.  
  34.     function createElement(elem) {
  35.         return (doc.createElementNS) ? doc.createElementNS('http://www.w3.org/1999/xhtml', elem) : doc.createElement(elem);
  36.     }
  37.  
  38.     function match(str, substr) {
  39.         if (str.indexOf('<' + substr + '>') != -1) {
  40.             var newstr = str.substring(str.indexOf('<' + substr + '>') + substr.length + 2);
  41.             return newstr.substring(0, newstr.indexOf('</' + substr + '>'));
  42.         } else return '';
  43.     }
  44.  
  45.     function cr_req() {
  46.         if (win.XMLHttpRequest) {
  47.             return new XMLHttpRequest();
  48.         } else {
  49.             try {
  50.                 return new ActiveXObject('Microsoft.XMLHTTP');
  51.             } catch (e){}
  52.         }
  53.         return !1;
  54.     }
  55.    
  56.     function check_apq () {
  57.         if (apq_id != -1)   {
  58.             get('pq' + apq_id).innerHTML = apq_temp;
  59.             apq_id = -1;
  60.         }
  61.     }
  62.    
  63.     function orsc(req) {
  64.         if (req.readyState == 4) {
  65.             check_apq();
  66.           if (req.status == 200) {
  67.                 var quote_message = match(req.responseText, 'quote_post');
  68.                 if (quote_message != '') {
  69.                     return FluxBB.post.insText('', '[quote="' + apq_user + '"]\n' + quote_message + '\n[/quote]\n');
  70.                 }
  71.                 alert(req.responseText);
  72.             } else alert('Error: ' + req.status);
  73.         }
  74.     }
  75.  
  76.     function SmileysMapBB() {
  77.         var html = '';
  78.         for (var i = 0; i < FluxBB.vars.bbSmImg.length; i++) {
  79.             html += '<img src="img/smilies/' + FluxBB.vars.bbSmImg[i] + '" alt="' + FluxBB.vars.bbSmTxt[i] + '" onclick="return FluxBB.post.insText(\'\', \' ' + FluxBB.vars.bbSmTxt[i].replace(/\\/g, '\\\\').replace(/&#039;/g, '\\\'') + ' \');" />';
  80.         }
  81.         return html;
  82.     }
  83.    
  84.     function ColorMapBB() {
  85.         var colors = [], a = ['00', '33', '66', '99', 'cc', 'ff'];
  86.         for (var x = 0; x < 6; x++) {
  87.             for (var y = 0; y < 6; y++) {
  88.                 for (var z = 0; z < 6; z++) {
  89.                     colors.push('#' +  a[y] + a[x] + a[z]);
  90.                 }
  91.             }
  92.         }
  93.         var html = '<table class="tbl"><tr>';
  94.         for (var i=0; i<colors.length; i++) {
  95.             html += '<td style="background-color:' + colors[i] + '" onclick="return FluxBB.post.insText(\'[color=' + colors[i] + ']\', \'[/color]\');" onfocus="FluxBB.post.showMapColor(\'' + colors[i] +  '\');" onmouseover="FluxBB.post.showMapColor(\'' + colors[i] + '\');"></td>';
  96.             if ((i+1) % 18 == 0)    html += '</tr><tr>';
  97.         }
  98.         html += '<td colspan="9" id="selectedMapColor" height="16"></td>'
  99.         + '<td colspan="9">'
  100.         + '<input id="selectedMapColorBox" name="selectedMapColorBox" type="text" size="7" maxlength="7" style="text-align:center;font-weight:bold;width:90px;border:1px solid;" value="" />'
  101.         + '</td></tr></table>';
  102.         return html;
  103.     }
  104. //*********************//
  105.     return {
  106.         init : function () {
  107.             if (fls) return false;
  108.             fls = true;
  109.            
  110.             textarea = doc.getElementsByName('req_message')[0];
  111.             if (typeof textarea === 'undefined') return false;
  112.  
  113.             bbcode = [{i:'b.png', a:'[b]', s:'[b]', e:'[/b]'},
  114.                 {i:'i.png', a:'[i]', s:'[i]', e:'[/i]'},
  115.                 {i:'u.png', a:'[u]', s:'[u]', e:'[/u]'},
  116.                 {i:'s.png', a:'[s]', s:'[s]', e:'[/s]'},
  117.                 {i:'spacer.png', a:'|'},
  118.                 {i:'center.png', a:'[center]', s:'[center]', e:'[/center]'},
  119.                 {i:'right.png', a:'[right]', s:'[right]', e:'[/right]'},
  120.                 {i:'justify.png', a:'[justify]', s:'[justify]', e:'[/justify]'},
  121.                 {i:'mono.png', a:'[mono]', s:'[mono]', e:'[/mono]'},
  122.                 {i:'spacer.png', a:'|'},
  123.                 {i:'url.png', a:'[url]', s:'[url]', e:'[/url]'},
  124.                 {i:'email.png', a:'[email]', s:'[email]', e:'[/email]'},
  125.                 {i:'img.png', a:'[img]', s:'[img]', e:'[/img]'},
  126.                 {i:'spacer.png', a:'|'},
  127.                 {i:'list.png', a:'[list]', s:'[list]', e:'[/list]'},
  128.                 {i:'li.png', a:'[*]', s:'[*]', e:'[/*]'},
  129.                 {i:'spacer.png', a:'|'},
  130.                 {i:'quote.png', a:'[quote]', s:'[quote]', e:'[/quote]'},
  131.                 {i:'code.png', a:'[code]', s:'[code]', e:'[/code]'},
  132.                 {i:'hr.png', a:'[hr]', s:'', e:'[hr]'},
  133.                 {i:'color.png', a:'[color=]', f:'return FluxBB.post.overlay(this, \'bbcode_color_map\');'},
  134.                 {i:'sp.png', a:'[spoiler]', s:'[spoiler]', e:'[/spoiler]'},
  135.                 {i:'spacer.png', a:'|'},
  136.                 {i:'smile.png', a:'smileys', f:'return FluxBB.post.overlay(this, \'bbcode_smileys\');'}];
  137.  
  138.             if (doc.getElementsByTagName('html')[0].getAttribute('lang') == 'ru') {
  139.               lang = {'b':'Полужирный текст', 'i':'Наклонный текст', 'u':'Подчеркнутый текст', 's':'Зачёркнутый текст', 'center':'По центру', 'right':'По правому краю', 'justify':'По ширине', 'mono':'Моношрифт', 'url':'Ссылка', 'email':'Электронная почта', 'img':'Картинка', 'list':'Список', '*':'Элемент списка', 'quote':'Цитата', 'code':'Блок кода', 'hr':'Горизонтальная линия', 'color':'Цвет текста', 'spoiler':'Скрытый текст', 'smileys':'Смайлы', 'upfiles':'Загрузки', 'QQ':'Цитировать', 'Loading':'Загрузка...', 'Must':'Вы должны выделить текст для цитирования'};
  140.             } else {
  141.               lang = {'b':'Bold text', 'i':'Italic text', 'u':'Underlined text', 's':'Strike-through text', 'center':'Center', 'right':'Right', 'justify':'Justify', 'mono':'Mono', 'url':'Link', 'email':'E-mail', 'img':'Image', 'list':'List', '*':'List element', 'quote':'Quote', 'code':'Code block', 'hr':'Horizontal line', 'color':'Colour of text', 'spoiler':'Spoiler', 'smileys':'Smileys', 'upfiles':'Uploads', 'QQ':'Quote', 'Loading':'Loading...', 'Must':'You must select text before quoting'};
  142.             }
  143.            
  144.             var div = createElement('div');
  145.             div.setAttribute('id', 'bbcode_bar');
  146.  
  147.             var t = '<div id="bbcodewrapper"><div id="bbcodebuttons">';
  148.             for (var i in bbcode) {
  149.                 var b = bbcode[i];
  150.                 t = t + '<img src="' + FluxBB.vars.bbDir + b.i + '" alt="' + b.a + '" ';
  151.                 var p = b.a.replace(/[\[\]\|\=]/g, '');
  152.                 if (!!p) t = t + 'title="' + lang[p] + '" ';
  153.                 if (!!b.f) {
  154.                     t = t + 'onclick="' + b.f + '" tabindex="' + (FluxBB.vars.bbCIndex++) + '" ';
  155.                 } else if (!!b.s || !!b.e) {
  156.                     t = t + 'onclick="return FluxBB.post.insText(\'' + b.s + '\', \'' + b.e + '\');" tabindex="' + (FluxBB.vars.bbCIndex++) + '" ';
  157.                 }
  158.                 t = t + '/>';
  159.             }
  160.             div.innerHTML = t + '</div></div>'
  161.             + '<div class="clearer"></div>'
  162.             + '<div id="bbcode_color_map" onclick="this.style.display=\'none\';"></div>'
  163.             + '<div id="bbcode_smileys" onclick="this.style.display=\'none\';"></div>';
  164.  
  165.             var p = textarea.parentNode;
  166.             p.insertBefore(div, textarea);
  167.  
  168.             var blockposts = getCN('blockpost');
  169.             for (var i in blockposts) {
  170.                 if (blockposts[i].id) {
  171.                     var id = blockposts[i].id.replace('p', '');
  172.                     var dt = blockposts[i].getElementsByTagName('dt')[0];
  173.                     if (typeof dt !== 'undefined') {
  174.                         var a = dt.innerHTML;
  175.                         var n = a.replace(/<[^>]+>/g, '');
  176.                        
  177.                         // Decode html special chars
  178.                         nameusers[id] = n.replace(/&lt;/g, '<')
  179.                             .replace(/&gt;/g, '>')
  180.                             .replace(/&quot;/g, '"')
  181.                             .replace(/&#039;/g, '\'')
  182.                             .replace(/&nbsp;/g, ' ')
  183.                             .replace(/&#160;/g, ' ')
  184.                             .replace(/&amp;/g, '&');
  185.                         dt.insertAdjacentHTML('afterBegin', '<strong><a href="#req_message" onclick="return FluxBB.post.insName(' + id + ');">@ </a></strong>');
  186.  
  187.                         var quote = getCN('postquote', blockposts[i])[0];
  188.                         if (typeof quote !== 'undefined') {
  189.                             a = quote.getElementsByTagName('a')[0];
  190.                             p = quote.parentNode;
  191.                             p.insertAdjacentHTML('beforeEnd', '<li class="postquote"><span id="pq' + id + '"><a href="' + a.href.replace(/&/g, '&amp;') + '" onmousedown="FluxBB.post.getText();" onclick="return FluxBB.post.quote(' + id + ');">' + lang['QQ'] + '</a></span></li>');
  192.                         }
  193.                     }
  194.                 }
  195.             }
  196.            
  197.  
  198.  
  199.         insText : function (open, close) {
  200.             get('bbcode_color_map').style.display = 'none';
  201.             get('bbcode_smileys').style.display = 'none';
  202.             textarea.focus();
  203.             // all and IE9+
  204.             if ('selectionStart' in textarea) {
  205.                 var len = textarea.value.length,
  206.                     sp = Math.min(textarea.selectionStart, len), // IE bug
  207.                     ep = Math.min(textarea.selectionEnd, len); // IE bug
  208.  
  209.                 textarea.value = textarea.value.substring(0, sp) + open + textarea.value.substring(sp, ep) + close + textarea.value.substring(ep);
  210.                 if (sp == ep && open == '') {
  211.                     textarea.selectionStart = sp + close.length;
  212.                     textarea.selectionEnd = ep + close.length;
  213.                 } else {
  214.                     textarea.selectionStart = sp + open.length;
  215.                     textarea.selectionEnd = ep + open.length;
  216.                 }
  217.             }
  218.             // IE9-
  219.             else if (doc.selection && doc.selection.createRange) {
  220.                 var sel = doc.selection.createRange();
  221.                 sel.text = open + sel.text + close;
  222.             }
  223.             textarea.focus();
  224.             return false;
  225.         },
  226.        
  227.         insName: function (id) {
  228.             return FluxBB.post.insText('', '[b]@' + nameusers[id] + '[/b], ');
  229.         },
  230.        
  231.         getText: function () {
  232.             if (win.getSelection) quote_text = win.getSelection().toString();
  233.             else if (doc.selection && doc.selection.createRange) quote_text = doc.selection.createRange().text;
  234.         },
  235.        
  236.         quote: function (id) {
  237.             if (typeof id !== 'number' || id < 1) return false;
  238.             if (quote_text != '') {
  239.                 return FluxBB.post.insText('', '[quote="' + nameusers[id] + '"]\n' + quote_text + '\n[/quote]\n');
  240.             } else if (!FluxBB.vars.bbGuest){
  241.                 check_apq();
  242.                 var req = cr_req();
  243.                 if (req) {
  244.                     apq_user = nameusers[id];
  245.                     apq_id = id;
  246.                     apq_temp = get('pq' + apq_id).innerHTML;
  247.                     get('pq' + apq_id).innerHTML = '<img src="img/loading.gif" />&#160;<a href="#">' + lang['Loading'] + '</a>';
  248.  
  249.                     req.onreadystatechange=function(){orsc(req);};
  250.                     req.open('POST', 'pjq.php?' + id, true);
  251.                     req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  252.                     req.send('action=' + typepost + '&id=' + id);
  253.                 }
  254.             } else {
  255.                 alert(lang['Must']);
  256.             }
  257.             return false;
  258.         },
  259.  
  260.         popUp : function (url) {
  261.           var h = Math.min(430, screen.height),
  262.           w = Math.min(820, screen.width),
  263.             t = Math.max((screen.height - h) / 3, 0),
  264.             l = (screen.width - w) / 2;
  265.             win.open(url, 'gest', 'top=' + t + ',left=' + l + ',width=' + w + ',height=' + h + ',resizable=yes,location=no,menubar=no,status=no,scrollbars=yes');
  266.             return false;
  267.         },
  268.        
  269.         overlay : function (prt, str) {
  270.             var m = get(str);
  271.             if (m.style.display != 'block') {
  272.  
  273.                 if (str == 'bbcode_smileys') {
  274.                     get('bbcode_color_map').style.display = 'none';
  275.                     if (flag_sm) {
  276.                         flag_sm = false;
  277.                         m.insertAdjacentHTML('afterBegin', SmileysMapBB());
  278.                     }
  279.                 }
  280.  
  281.                 if (str == 'bbcode_color_map') {
  282.                     get('bbcode_smileys').style.display = 'none';
  283.                     if (flag_cr) {
  284.                         flag_cr = false;
  285.                         m.insertAdjacentHTML('afterBegin', ColorMapBB());
  286.                         m.style.overflow = 'hidden';
  287.                     }
  288.                 }
  289.  
  290.                 m.style.display = 'block';
  291.                 m.style.position = 'absolute';
  292.                 m.style.left = Math.max(0, Math.min(textarea.offsetLeft + textarea.offsetParent.offsetLeft + textarea.offsetWidth - m.offsetWidth, prt.offsetLeft + prt.offsetParent.offsetLeft - (m.offsetWidth - prt.offsetWidth) / 2)) + 'px';
  293.                 m.style.top = prt.offsetTop + prt.offsetParent.offsetTop + prt.offsetHeight + 'px';
  294.             } else {
  295.                 m.style.display = 'none';
  296.             }
  297.  
  298.             return false;
  299.         },
  300.        
  301.         showMapColor : function (color) {
  302.             get('selectedMapColor').style.backgroundColor = color;
  303.             get('selectedMapColorBox').value = color;
  304.         }
  305.     };
  306. }(document, window));
  307.  
  308. if (typeof jQuery !== 'undefined') {
  309.     (function($){var textarea,staticOffset;var iLastMousePos=0;var iMin=64;var grip;$.fn.TextAreaResizer=function(){return this.each(function(){textarea=$(this).addClass('processed'),staticOffset=null;$(this).wrap('<div class="resizable-textarea"><span></span></div>').parent().append($('<div class="grippie"></div>').bind("mousedown",{el:this},startDrag));var grippie=$('div.grippie',$(this).parent())[0];grippie.style.marginRight=(grippie.offsetWidth-$(this)[0].offsetWidth)+'px'})};function startDrag(e){textarea=$(e.data.el);textarea.blur();iLastMousePos=mousePosition(e).y;staticOffset=textarea.height()-iLastMousePos;if(!window.ActiveXObject){textarea.css('opacity',0.25)}$(document).mousemove(performDrag).mouseup(endDrag);return false}function performDrag(e){var iThisMousePos=mousePosition(e).y;var iMousePos=staticOffset+iThisMousePos;if(iLastMousePos>=(iThisMousePos)){iMousePos-=5}iLastMousePos=iThisMousePos;iMousePos=Math.max(iMin,iMousePos);textarea.height(iMousePos+'px');if(iMousePos<iMin){endDrag(e)}return false}function endDrag(e){$(document).unbind('mousemove',performDrag).unbind('mouseup',endDrag);if(!window.ActiveXObject){textarea.css('opacity',1)}textarea.focus();textarea=null;staticOffset=null;iLastMousePos=0}function mousePosition(e){return{x:e.clientX+document.documentElement.scrollLeft,y:e.clientY+document.documentElement.scrollTop}}})(jQuery);
  310.     $(document).ready(function() {$('textarea:not(.processed)').TextAreaResizer();});
  311. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement