Advertisement
dovah-chan

shoutbox..js

Sep 23rd, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Product Title:       IPB Shoutbox
  3.  * Author:              Pete Treanor
  4.  * Website URL:         http://www.ipbshoutbox.com
  5.  * Copyright�:            IPB Works All rights Reserved 2011-2013
  6.  */
  7.  
  8. var Resize =
  9. {
  10.     obj     : null,
  11.     objloop : null,
  12.     int     : null,
  13.  
  14.     init: function(o, oRoot, ho, wo, minX, maxX, minY, maxY)
  15.     {
  16.         o.onmousedown = Resize.start;
  17.         o.hmode       = true;
  18.         o.vmode       = true;
  19.         o.root        = (oRoot && oRoot != null) ? oRoot : o;
  20.  
  21.         if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
  22.         if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
  23.         if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
  24.         if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";
  25.  
  26.         o.minX = (typeof minX != 'undefined') ? minX : null;
  27.         o.minY = (typeof minY != 'undefined') ? minY : null;
  28.         o.maxX = (typeof maxX != 'undefined') ? maxX : null;
  29.         o.maxY = (typeof maxY != 'undefined') ? maxY : null;
  30.  
  31.         o.h_only = false;
  32.         o.w_only = false;
  33.  
  34.         o.root.Resizing = new Function();
  35.  
  36.         ho = (ho == true) ? true : false;
  37.         wo = (wo == true) ? true : false;
  38.  
  39.         if (ho == true)
  40.         {
  41.             o.h_only = true;
  42.         }
  43.         else if (wo == true)
  44.         {
  45.             o.w_only = true;
  46.         }
  47.     },
  48.  
  49.     start: function(e)
  50.     {
  51.         var o = Resize.obj = Resize.objloop = this;
  52.         e     = Resize.fixE(e);
  53.         var y = parseInt((o.vmode) ? o.root.style.top  : o.root.style.bottom);
  54.         var x = parseInt((o.hmode) ? o.root.style.left : o.root.style.right );
  55.  
  56.         o.lastMouseX = o.startMouseX = e.clientX;
  57.         o.lastMouseY = o.startMouseY = e.clientY;
  58.  
  59.         var obj = Resize.data();
  60.         var rec = ipb.shoutbox.rect(obj.x, obj.y, obj.w, obj.h);
  61.         o.oh    = rec.h;
  62.         o.ow    = rec.w;
  63.  
  64.         if (o.hmode)
  65.         {
  66.             if (o.minX != null) o.minMouseX = e.clientX - x + o.minX;
  67.             if (o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX;
  68.         }
  69.         else
  70.         {
  71.             if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
  72.             if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
  73.         }
  74.  
  75.         if (o.vmode)
  76.         {
  77.             if (o.minY != null) o.minMouseY = e.clientY - y + o.minY;
  78.             if (o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY;
  79.         }
  80.         else
  81.         {
  82.             if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
  83.             if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
  84.         }
  85.  
  86.         document.onmousemove = Resize.resize;
  87.         document.onmouseup   = Resize.end;
  88.  
  89.         return false;
  90.     },
  91.  
  92.     resize : function(e)
  93.     {
  94.         e     = Resize.fixE(e);
  95.         var o = Resize.obj;
  96.  
  97.         var ey  = e.clientY;
  98.         var ex  = e.clientX;
  99.         var y   = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
  100.         var x   = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
  101.         var h   = parseInt(o.root.offsetHeight);
  102.         var t   = (document.all) ? ipb.shoutbox.truebody().scrollTop : window.pageYOffset;
  103.  
  104.         if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
  105.         if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
  106.         if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
  107.         if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);
  108.  
  109.         var rec = Resize.data();
  110.         if (Resize.obj.h_only == true)
  111.         {
  112.             ajh     = ey-o.startMouseY;
  113.             rec.h   = o.oh+ajh;
  114.  
  115.             if (!isNaN(o.root.min_height) && o.root.min_height > 0)
  116.             {
  117.                 if (rec.h < o.root.min_height)
  118.                 {
  119.                     rec.h = o.root.min_height;
  120.                 }
  121.             }
  122.  
  123.             rec.ho = true;
  124.             if (ey >= 0 && ey <= 3)
  125.             {
  126.                 Resize.int = setInterval(Resize.resizeloop, 1);
  127.                 window.scrollBy(0, -3);
  128.             }
  129.             else
  130.             {
  131.                 if (Resize.int)
  132.                 {
  133.                     clearInterval(Resize.int);
  134.                 }
  135.             }
  136.  
  137.             Resize.obj.root.style['height'] = rec.h+'px';
  138.         }
  139.         else if (Resize.obj.w_only == true)
  140.         {
  141.             ajw     = ex-o.startMouseX;
  142.             rec.w   = o.ow+ajw;
  143.  
  144.             if (!isNaN(o.root.min_width) && o.root.min_width > 0)
  145.             {
  146.                 if (rec.w < o.root.min_width)
  147.                 {
  148.                     rec.w = o.root.min_width;
  149.                 }
  150.             }
  151.  
  152.             rec.wo = true;
  153.             if (!isNaN(o.root.max_width) && o.root.max_width > 0)
  154.             {
  155.                 if (rec.w > o.root.max_width)
  156.                 {
  157.                     rec.w = o.root.max_width;
  158.                 }
  159.             }
  160.  
  161.             Resize.obj.root.style['width'] = rec.w+'px';
  162.         }
  163.  
  164.         Resize.obj.lastMouseX           = ex;
  165.         Resize.obj.lastMouseY           = ey;
  166.         Resize.obj.root.Resizing(rec);
  167.  
  168.         return false;
  169.     },
  170.  
  171.     resizeloop : function(e)
  172.     {
  173.         Resize.obj = Resize.obj_loop;
  174.         Resize.resize(e);
  175.     },
  176.  
  177.     end : function(e)
  178.     {
  179.         document.onmousemove = null;
  180.         document.onmouseup   = null;
  181.  
  182.         Resize.obj.root.Resize_end(Resize.data());
  183.  
  184.         Resize.obj     = null;
  185.         Resize.objloop = null;
  186.  
  187.         if (Resize.int)
  188.         {
  189.             clearInterval(Resize.int);
  190.         }
  191.     },
  192.  
  193.     data : function(e)
  194.     {
  195.         var oo = Resize.obj.root;
  196.         var xx = Resize.style(oo, 'left');
  197.         var yy = Resize.style(oo, 'top');
  198.         var ww = Resize.style(oo, 'width');
  199.         var hh = Resize.style(oo, 'height');
  200.  
  201.         if (hh <= 0)
  202.         {
  203.             hh = oo.offsetHeight;
  204.         }
  205.  
  206.         if (ww <= 0)
  207.         {
  208.             ww = oo.offsetWidth;
  209.         }
  210.  
  211.         rect = ipb.shoutbox.rect( xx, yy, ww, hh );
  212.         return rect;
  213.     },
  214.  
  215.     style : function(o, n)
  216.     {
  217.         if (!o)
  218.         {
  219.             return 0;
  220.         }
  221.  
  222.         if (!o.style)
  223.         {
  224.             return 0;
  225.         }
  226.  
  227.         var t;
  228.         var s = o.style;
  229.  
  230.         try
  231.         {
  232.             eval("t = parseInt(s."+n+", 10);");
  233.         }
  234.  
  235.         catch(e)
  236.         {
  237.             return 0;
  238.         }
  239.  
  240.         if (isNaN(t))
  241.         {
  242.             t=0;
  243.         }
  244.  
  245.         return t;
  246.     },
  247.  
  248.     fixE : function(e)
  249.     {
  250.         if (typeof e == 'undefined') e = window.event;
  251.         if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
  252.         if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
  253.         return e;
  254.     }
  255. };
  256.  
  257. /**
  258.  * Core javascript class
  259.  *
  260.  * Contains global functions
  261.  */
  262. window.IPBoard.prototype.shoutbox=
  263. {
  264.     /* Paths to fix cross-site AJAX issues */
  265.     realBaseUrl:    location.protocol + '//' + location.host,
  266.     realBaseUrlWww: location.protocol + '//www.' + location.host + location.pathname + '?',
  267.  
  268.     /* Normal Base URL which PHP uses */
  269.     baseUrl:        ipb.vars['base_url'] + '&app=shoutbox&module=ajax&section=coreAjax&secure_key=' + ipb.vars['secure_hash'] + '&',
  270.  
  271.     /**
  272.      * Member specific variables
  273.      */
  274.     can_use:            0,
  275.     can_edit:           0,
  276.     members_refresh:    15,
  277.     shouts_refresh:     30,
  278.     hide_refresh:       1,
  279.     flood_limit:        0,
  280.     bypass_flood:       0,
  281.     my_last_shout:      0,
  282.     total_shouts:       0,
  283.     last_shout_id:      0,
  284.     inactive_timeout:   5,
  285.  
  286.     /**
  287.      * OTHER: Array variables
  288.      */
  289.     errors:         [],
  290.     langs:          [],
  291.     month_days:     [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
  292.     langs:          [],
  293.  
  294.     /**
  295.      * OTHER: Boolean variables
  296.      */
  297.     global_on:          false,
  298.     enable_cmds:        true,
  299.     mod_in_action:      false,
  300.     moderator:          false,
  301.     _inactive:          false,
  302.     view_archive:       false,
  303.     events_loaded:      false,
  304.     events_rte_loaded:  false,
  305.     submittingShout:    false,
  306.     inactiveWhenPopup:  false,
  307.     animatingGlobal:    false,
  308.     archive_filtering:  false, //Prevent too much filter requests to be done
  309.  
  310.     /**
  311.      * OTHER: Integer variables
  312.      */
  313.     mod_shout_id:           0,
  314.     time_minute:            60 * 1000,
  315.     events_load_max_tries:  10,
  316.     events_load_tries:      0,
  317.  
  318.     /**
  319.      * OTHER: Other variables
  320.      */
  321.     timeoutShouts:  null,
  322.     timeoutMembers: null,
  323.     mod_command:    '',
  324.     tempShout:      null, //1.1.0 RC1
  325.  
  326.     /**
  327.      * Javascript functions
  328.      *
  329.      * Code below this comment are functions
  330.      * used within the javascript
  331.      */
  332.     initialize: function()
  333.     {
  334.         Debug.write( 'IP.Shoutbox javascript is loading' );
  335.  
  336.         document.observe( 'dom:loaded', function()
  337.         {
  338.             // Is global shoutbox?
  339.             if ( ipb.shoutbox.shoutboxGLOBAL )
  340.             {
  341.                 ipb.shoutbox.global_on = true;
  342.             }
  343.  
  344.             /**
  345.              * Sort out AJAX URLS
  346.              *
  347.              * This fixes a bug as AJAX treats http://
  348.              * and http://www. as two seperate URLs
  349.              */
  350.  
  351.             /* Without www */
  352.             if ( ipb.shoutbox.realBaseUrl.match( /^http:\/\/www/ ) && ! ipb.vars['base_url'].match( /^http:\/\/www/ ) )
  353.             {
  354.                 ipb.vars['base_url'] = ipb.vars['base_url'].replace( /^http:\/\//, 'http://www.' );
  355.             }
  356.  
  357.             /* With www */
  358.             if ( ipb.vars['base_url'].match( /^http:\/\/www/ ) && ! ipb.shoutbox.realBaseUrl.match( /^http:\/\/www/ ) )
  359.             {
  360.                 location.href = location.href.replace( /^http:\/\//, 'http://www.' );
  361.             }
  362.  
  363.             ipb.shoutbox.setupShoutbox();
  364.         }.bind(this));
  365.     },
  366.  
  367.     populateSmilies: function(element, e)
  368.     {
  369.         Event.stop(e);
  370.  
  371.         if ( Object.isUndefined( ipb.global.popups['sb_smilies'] ) )
  372.         {
  373.             ipb.global.popups['sb_smilies'] = true;
  374.             ipb.menus.closeAll(e);
  375.             $(element).identify();
  376.  
  377.             /* Create pop-up wrapper */
  378.             $('ipboard_body').insert( { bottom: new Element('div', { 'id': 'shoutbox-smilies-button_menucontent'}) } );
  379.             $('shoutbox-smilies-button_menucontent').setStyle('width: 400px').update( "<div class='ipsPad ipsForm_center'><img src='" + ipb.vars['loading_img'] + "' /></div>" );
  380.  
  381.             var _newMenu = new ipb.Menu( $(element), $( "shoutbox-smilies-button_menucontent" ) );
  382.             _newMenu.doOpen();
  383.  
  384.             new Ajax.Request
  385.             (
  386.                 ipb.shoutbox.baseUrl + 'type=smilies',
  387.                 {
  388.                     method: 'post',
  389.                     evalJSON: 'force',
  390.                     hideLoader: true,
  391.                     parameters: {
  392.                         secure_key: ipb.vars['secure_hash']
  393.                     },
  394.                     onSuccess: function(t)
  395.                     {
  396.                         $('shoutbox-smilies-button_menucontent').update( t.responseText );
  397.                     }
  398.                 }
  399.             );
  400.         }
  401.  
  402.         return false;
  403.     },
  404.  
  405.     emoticonPager: function(e, elem)
  406.     {
  407.         Event.stop(e);
  408.         var _pg = elem.id.replace( 'page_', '' );
  409.  
  410.         new Ajax.Request
  411.         (
  412.             ipb.shoutbox.baseUrl + 'type=smilies',
  413.             {
  414.                 method: 'post',
  415.                 evalJSON: 'force',
  416.                 hideLoader: true,
  417.                 parameters: {
  418.                     secure_key: ipb.vars['secure_hash'],
  419.                     pg: _pg
  420.                 },
  421.                 onSuccess: function(t)
  422.                 {
  423.                     $('shoutbox-smilies-button_menucontent').update( t.responseText );
  424.                 }
  425.             }
  426.         );
  427.     },
  428.  
  429.     insertMember: function(e, elem)
  430.     {
  431.         Event.stop(e);
  432.  
  433.         var to_insert = "@" + elem.readAttribute("data-store") + " ";
  434.  
  435.         if ( ipb.shoutbox.global_on )
  436.         {
  437.             ipb.shoutbox.insertAtCursor( to_insert );
  438.         }
  439.         else
  440.         {
  441.             d = ipb.textEditor.getEditor().CKEditor.getData();
  442.             ipb.textEditor.getEditor().CKEditor.setData( d + to_insert.replace( ' ', '&nbsp;' ) );
  443.             ipb.textEditor.getEditor().CKEditor.focus();
  444.         }
  445.     },
  446.  
  447.     deleteShout: function(e, elem)
  448.     {
  449.         /* Check to make sure */
  450.         if ( confirm( ipb.shoutbox.langs['sure_delete_shout'] ) )
  451.         {
  452.             /* INIT */
  453.             Event.stop(e);
  454.             var id = elem.id.replace( 'delete_', '' );
  455.  
  456.             /* Send the ajax request */
  457.             new Ajax.Request( ipb.shoutbox.baseUrl + 'type=delete',
  458.             {
  459.                 method: 'post',
  460.                 encoding: ipb.vars['charset'],
  461.                 parameters: {
  462.                     shout: id
  463.                 },
  464.                 onSuccess: function(s)
  465.                 {
  466.                     if ( s.responseJSON['error'] )
  467.                     {
  468.                         /* Display the correct error message */
  469.                         switch ( s.responseJSON['error'] )
  470.                         {
  471.                             case 'noshout':
  472.                                 alert( ipb.shoutbox.langs['no_found_shout'] );
  473.                             break;
  474.                             case 'nopermission':
  475.                                 alert( ipb.shoutbox.langs['no_delete_shout'] );
  476.                             break;
  477.                         }
  478.                     }
  479.                     else
  480.                     {
  481.                         /* Remove that row */
  482.                         $('shout-row-' + s.responseJSON['id']).remove();
  483.                     }
  484.                 }
  485.             });
  486.         }
  487.     },
  488.  
  489.     setupShoutbox: function()
  490.     {
  491.         var doReload = true;
  492.  
  493.         /* Allowed to use it? =O */
  494.         if ( ipb.shoutbox.can_use )
  495.         {
  496.             /* At-member */
  497.             ipb.delegate.register( '.at_member', ipb.shoutbox.insertMember );
  498.  
  499.             /* Delete my shout */
  500.             ipb.delegate.register( '.deleteMyShout', ipb.shoutbox.deleteShout );
  501.  
  502.             /** Init buttons **/
  503.             var bts = [
  504.                 [ 'shoutbox-refresh-button', ipb.shoutbox.refreshShouts ],
  505.                 [ 'shoutbox-submit-button' , ipb.shoutbox.submitShout ],
  506.                 [ 'shoutbox-clear-button'  , ipb.shoutbox.clearShout ],
  507.                 [ 'shoutbox-myprefs-button', ipb.shoutbox.myPrefsLoad ],
  508.                 [ 'shoutbox-popup-button'  , ipb.shoutbox.showShoutboxPopup ]
  509.             ];
  510.  
  511.             /** Global SB?  **/
  512.             if ( ipb.shoutbox.global_on )
  513.             {
  514.                 /* Setup global resizer */
  515.                 ipb.shoutbox.resizeGlobalShouts();
  516.  
  517.                 /* Add also BBCODE button */
  518.                 bts.push( [ 'shoutbox-bbcode-button' , ipb.shoutbox.bbcodePopup ] );
  519.  
  520.                 // Setup our global SB toggle
  521.                 ipb.shoutbox.setupToggle();
  522.  
  523.                 /* Emoticon pager */
  524.                 ipb.delegate.register( '.emoticonPager', ipb.shoutbox.emoticonPager );
  525.             }
  526.             else
  527.             {
  528.                 ipb.shoutbox.resizeShouts();
  529.  
  530.                 /* Archive time =O */
  531.                 if ( ipb.shoutbox.view_archive && $('load-shoutbox-archive') )
  532.                 {
  533.                     bts.push( [ 'load-shoutbox-archive' , ipb.shoutbox.displayArchive ] );
  534.                 }
  535.             }
  536.  
  537.             /**
  538.              * 1.1.0 Beta 2
  539.              * Setup onlick for all buttons
  540.              */
  541.             for ( var x=0; x<bts.length; x++ )
  542.             {
  543.                 if ( $( bts[x][0] ) )
  544.                 {
  545.                     $( bts[x][0] ).observe('click', bts[x][1]);
  546.                 }
  547.             }
  548.         }
  549.         else
  550.         {
  551.             /* Reset some vars to be sure */
  552.             ipb.shoutbox.myMemberID   = 0;
  553.             ipb.shoutbox.moderator    = 0;
  554.             ipb.shoutbox.hide_refresh = 0;
  555.             ipb.shoutbox.view_archive = false;
  556.         }
  557.  
  558.         /** Sort other things **/
  559.         ipb.shoutbox.initEvents();
  560.  
  561.         /**
  562.          * 1.0.0 Final
  563.          * Update shouts view (class, scroll, etc)
  564.          */
  565.         ipb.shoutbox.updateLastActivity();
  566.         ipb.shoutbox.updateJSPreferences();
  567.         ipb.shoutbox.rewriteShoutClasses();
  568.         ipb.shoutbox.shoutsGetLastID();
  569.         ipb.shoutbox.shoutsScrollThem();
  570.  
  571.         if( ipb.shoutbox.global_on )
  572.         {
  573.             /**
  574.              * 1.1.0 RC 1
  575.              * Let's update live active users on board index! =D
  576.              */
  577.             if ( $('shoutbox-active-total') && $('shoutbox-active-total').hasClassName('ajax_update') )
  578.             {
  579.                 ipb.shoutbox.reloadMembers(false);
  580.             }
  581.  
  582.             /* Block refresh if collapsed */
  583.             if ( $('category_shoutbox') && $('category_shoutbox').hasClassName('collapsed') )
  584.             {
  585.                 doReload = false;
  586.             }
  587.  
  588.             if ( $('shoutbox_sidebar') && !$('shoutbox_sidebar').down('ul').visible() )
  589.             {
  590.                 doReload = false;
  591.             }
  592.         }
  593.         else
  594.         {
  595.             /**
  596.              * 1.1.0 Beta 2
  597.              * Set timer, we load members on display
  598.              */
  599.             ipb.shoutbox.reloadMembers(false);
  600.         }
  601.  
  602.         /**
  603.          * 1.0.0 Final
  604.          * Set timer, we load shouts on display
  605.          */
  606.         if ( doReload )
  607.         {
  608.             ipb.shoutbox.reloadShouts(false);
  609.         }
  610.     },
  611.  
  612.     checkForCommands: function()
  613.     {
  614.         var s = ipb.shoutbox.getShout( true ),
  615.             a = s.split(' '),
  616.             m = new Array();
  617.  
  618.         if ( !ipb.shoutbox.validCommandSyntax( a[0], true  ))
  619.         {
  620.             return 'doshout';
  621.         }
  622.  
  623.         if ( !ipb.shoutbox.enable_cmds )
  624.         {
  625.             ipb.shoutbox.produceError('no_cmds_enabled');
  626.             return null;
  627.         }
  628.         else
  629.         {
  630.             switch (a[0])
  631.             {
  632.                 case '/announce':
  633.                     //Let's clear the shout there
  634.                     ipb.shoutbox.clearShout();
  635.  
  636.                     if ( ipb.shoutbox.can_access_acp )
  637.                     {
  638.                         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=announce',
  639.                             {
  640.                                 method: 'post',
  641.                                 encoding: ipb.vars['charset'],
  642.                                 parameters: {
  643.                                     announce: s.substring(9).encodeParam()
  644.                                 },
  645.                                 onSuccess: function(s)
  646.                                 {
  647.                                     if ( ipb.shoutbox.checkForErrors(s.responseText) )
  648.                                     {
  649.                                         return false;
  650.                                     }
  651.  
  652.                                     if ( s.responseText == '<!--nothing-->' || s.responseText == '' )
  653.                                     {
  654.                                         $('shoutbox-announcement-row').hide();
  655.                                     }
  656.                                     else
  657.                                     {
  658.                                         $('shoutbox-announcement-row').show();
  659.                                         $('shoutbox-announcement-text').update( s.responseText );
  660.                                     }
  661.  
  662.                                     return true;
  663.                                 }
  664.                             }
  665.                         );
  666.                     }
  667.                     else
  668.                     {
  669.                         ipb.shoutbox.produceError('no_acp_access');
  670.                     }
  671.                     break;
  672.                 /**
  673.                  * RC1
  674.                  * Prune old shouts
  675.                  */
  676.                 case '/prune':
  677.                     if ( ipb.shoutbox.can_access_acp )
  678.                     {
  679.                         var days = s.substring(6);
  680.  
  681.                         if ( !isNaN(days) && days != '' )
  682.                         {
  683.                             ipb.shoutbox.clearShout();
  684.  
  685.                             new Ajax.Request( ipb.shoutbox.baseUrl + 'type=prune',
  686.                                 {
  687.                                     method: 'post',
  688.                                     encoding: ipb.vars['charset'],
  689.                                     parameters: {
  690.                                         days:       days
  691.                                     },
  692.                                     onSuccess: function(s)
  693.                                     {
  694.                                         if ( ipb.shoutbox.checkForErrors(s.responseText) )
  695.                                         {
  696.                                             return false;
  697.                                         }
  698.  
  699.                                         /**
  700.                                          * 1.1.0 Final
  701.                                          *
  702.                                          * Reset this value just in case
  703.                                          * the page is not reloaded
  704.                                          */
  705.                                         ipb.shoutbox.last_shout_id = 0;
  706.  
  707.                                         ipb.shoutbox.actionTaken(s.responseText);
  708.  
  709.                                         /**
  710.                                          * 1.1.0 Beta 1
  711.                                          * Reload page if shouts are pruned
  712.                                          */
  713.                                         window.location=window.location;
  714.                                     }
  715.                                 }
  716.                             );
  717.                         }
  718.                         else
  719.                         {
  720.                             ipb.shoutbox.produceError('prune_invalid_number');
  721.                         }
  722.                     }
  723.                     else
  724.                     {
  725.                         ipb.shoutbox.clearShout();
  726.                         ipb.shoutbox.produceError('no_acp_access');
  727.                     }
  728.                     break;
  729.                 /**
  730.                  * RC1
  731.                  * Ban members
  732.                  */
  733.                 case '/ban':
  734.                     if (ipb.shoutbox.mod_perms['m_ban_members'])
  735.                     {
  736.                         var banName = s.substring(4);
  737.  
  738.                         if ( banName != null && banName != '' )
  739.                         {
  740.                             ipb.shoutbox.clearShout();
  741.  
  742.                             new Ajax.Request( ipb.shoutbox.baseUrl + 'type=ban',
  743.                                 {
  744.                                     method: 'post',
  745.                                     encoding: ipb.vars['charset'],
  746.                                     parameters: {
  747.                                         name:       banName
  748.                                     },
  749.                                     onSuccess: function(s)
  750.                                     {
  751.                                         if ( ipb.shoutbox.checkForErrors(s.responseText) )
  752.                                         {
  753.                                             return false;
  754.                                         }
  755.  
  756.                                         ipb.shoutbox.actionTaken(s.responseText);
  757.                                     }
  758.                                 }
  759.                             );
  760.                         }
  761.                         else
  762.                         {
  763.                             ipb.shoutbox.produceError('mod_invalid_name');
  764.                         }
  765.                     }
  766.                     else
  767.                     {
  768.                         ipb.shoutbox.clearShout();
  769.                         ipb.shoutbox.produceError('mod_no_perm');
  770.                     }
  771.                     break;
  772.                 case '/ban24':
  773.                     if (ipb.shoutbox.mod_perms['m_ban_members'])
  774.                     {
  775.                         var banName = s.substring(4);
  776.  
  777.                         if ( banName != null && banName != '' )
  778.                         {
  779.                             ipb.shoutbox.clearShout();
  780.  
  781.                             new Ajax.Request( ipb.shoutbox.baseUrl + 'type=ban24',
  782.                                 {
  783.                                     method: 'post',
  784.                                     encoding: ipb.vars['charset'],
  785.                                     parameters: {
  786.                                         name:       banName
  787.                                     },
  788.                                     onSuccess: function(s)
  789.                                     {
  790.                                         if ( ipb.shoutbox.checkForErrors(s.responseText) )
  791.                                         {
  792.                                             return false;
  793.                                         }
  794.  
  795.                                         ipb.shoutbox.actionTaken(s.responseText);
  796.                                     }
  797.                                 }
  798.                             );
  799.                         }
  800.                         else
  801.                         {
  802.                             ipb.shoutbox.produceError('mod_invalid_name');
  803.                         }
  804.                     }
  805.                     else
  806.                     {
  807.                         ipb.shoutbox.clearShout();
  808.                         ipb.shoutbox.produceError('mod_no_perm');
  809.                     }
  810.                     break;
  811.                 case '/ban48':
  812.                     if (ipb.shoutbox.mod_perms['m_ban_members'])
  813.                     {
  814.                         var banName = s.substring(4);
  815.  
  816.                         if ( banName != null && banName != '' )
  817.                         {
  818.                             ipb.shoutbox.clearShout();
  819.  
  820.                             new Ajax.Request( ipb.shoutbox.baseUrl + 'type=ban48',
  821.                                 {
  822.                                     method: 'post',
  823.                                     encoding: ipb.vars['charset'],
  824.                                     parameters: {
  825.                                         name:       banName
  826.                                     },
  827.                                     onSuccess: function(s)
  828.                                     {
  829.                                         if ( ipb.shoutbox.checkForErrors(s.responseText) )
  830.                                         {
  831.                                             return false;
  832.                                         }
  833.  
  834.                                         ipb.shoutbox.actionTaken(s.responseText);
  835.                                     }
  836.                                 }
  837.                             );
  838.                         }
  839.                         else
  840.                         {
  841.                             ipb.shoutbox.produceError('mod_invalid_name');
  842.                         }
  843.                     }
  844.                     else
  845.                     {
  846.                         ipb.shoutbox.clearShout();
  847.                         ipb.shoutbox.produceError('mod_no_perm');
  848.                     }
  849.                     break;
  850.                 /**
  851.                  * RC1
  852.                  * Unban members
  853.                  */
  854.                 case '/unban':
  855.                     if (ipb.shoutbox.mod_perms['m_unban_members'])
  856.                     {
  857.                         var unbanName = s.substring(6);
  858.  
  859.                         if ( unbanName != null && unbanName != '' )
  860.                         {
  861.                             ipb.shoutbox.clearShout();
  862.  
  863.                             new Ajax.Request( ipb.shoutbox.baseUrl + 'type=unban',
  864.                                 {
  865.                                     method: 'post',
  866.                                     encoding: ipb.vars['charset'],
  867.                                     parameters: {
  868.                                         name:       unbanName
  869.                                     },
  870.                                     onSuccess: function(s)
  871.                                     {
  872.                                         if ( ipb.shoutbox.checkForErrors(s.responseText) )
  873.                                         {
  874.                                             return false;
  875.                                         }
  876.  
  877.                                         ipb.shoutbox.actionTaken(s.responseText);
  878.                                     }
  879.                                 }
  880.                             );
  881.                         }
  882.                         else
  883.                         {
  884.                             ipb.shoutbox.produceError('mod_invalid_name');
  885.                         }
  886.                     }
  887.                     else
  888.                     {
  889.                         ipb.shoutbox.clearShout();
  890.                         ipb.shoutbox.produceError('mod_no_perm');
  891.                     }
  892.                     break;
  893.                 case '/refresh':
  894.                     ipb.shoutbox.clearShout();
  895.                     ipb.shoutbox.reloadShouts(true);
  896.                     break;
  897.                 case '/prefs':
  898.                     ipb.shoutbox.clearShout();
  899.                     if (ipb.shoutbox.myMemberID > 0)
  900.                     {
  901.                         if ( ipb.shoutbox.global_on )
  902.                         {
  903.                             ipb.shoutbox.setActionAndReload('myprefs');
  904.                         }
  905.                         else
  906.                         {
  907.                             ipb.shoutbox.myPrefsLoad();
  908.                         }
  909.                     }
  910.                     else
  911.                     {
  912.                         ipb.shoutbox.produceError('prefs_login');
  913.                     }
  914.                     break;
  915.                 case '/archive':
  916.                     ipb.shoutbox.clearShout();
  917.  
  918.                     if (ipb.shoutbox.view_archive)
  919.                     {
  920.                         if (ipb.shoutbox.global_on)
  921.                         {
  922.                             ipb.shoutbox.setActionAndReload('archive');
  923.                         }
  924.                         else
  925.                         {
  926.                             ipb.shoutbox.displayArchive();
  927.                         }
  928.                     }
  929.                     else
  930.                     {
  931.                         ipb.shoutbox.produceError('no_archive_perm');
  932.                     }
  933.  
  934.                     break;
  935.                 case '/moderator':
  936.                     if (ipb.shoutbox.moderator)
  937.                     {
  938.                         if ( ipb.shoutbox.validCommandSyntax(a[1]) && ipb.shoutbox.validCommandSyntax(a[2]))
  939.                         {
  940.                             t = a[1];
  941.                             d = a[2];
  942.  
  943.                             var modType  = null,
  944.                                 shoutID  = 0,
  945.                                 memType  = '',
  946.                                 memberID = 0;
  947.  
  948.                             switch (t)
  949.                             {
  950.                                 case 'shout':
  951.                                     if (parseInt(d) > 0)
  952.                                     {
  953.                                         modType = 'shout';
  954.                                         shoutID = parseInt(d);
  955.                                     }
  956.                                     break;
  957.                                 case 'member':
  958.                                     modType = 'member';
  959.  
  960.                                     if (parseInt(d) > 0)
  961.                                     {
  962.                                         memType  = 'number';
  963.                                         memberID = parseInt(d);
  964.                                     }
  965.                                     else
  966.                                     {
  967.                                         memType  = 'string';
  968.                                         memberID = d.toString();
  969.                                     }
  970.                                     break;
  971.                                 default:
  972.                                     break;
  973.                             }
  974.  
  975.                             if ( modType != null && modType != '' )
  976.                             {
  977.                                 ipb.shoutbox.clearShout();
  978.  
  979.                                 if ( ipb.shoutbox.global_on )
  980.                                 {
  981.                                     ipb.shoutbox.setActionAndReload('mod|'+modType+'|'+((modType == 'member') ? memType+'|'+memberID : shoutID));
  982.                                 }
  983.                                 else
  984.                                 {
  985.                                     new Ajax.Request( ipb.shoutbox.baseUrl + 'type=mod&action=loadQuickCmd',
  986.                                         {
  987.                                             method: 'post',
  988.                                             encoding: ipb.vars['charset'],
  989.                                             parameters: {
  990.                                                 modtype:    modType,
  991.                                                 shout:      shoutID,
  992.                                                 memtype:    memType,
  993.                                                 member:     memberID
  994.                                             },
  995.                                             onSuccess: function(s)
  996.                                             {
  997.                                                 if ( ipb.shoutbox.checkForErrors(s.responseText) )
  998.                                                 {
  999.                                                     return false;
  1000.                                                 }
  1001.  
  1002.                                                 /* Popup already exist, show it! */
  1003.                                                 if ( $('modOpts_popup') )
  1004.                                                 {
  1005.                                                     $('modOpts_inner').update( s.responseText );
  1006.                                                 }
  1007.                                                 else
  1008.                                                 {
  1009.                                                     ipb.shoutbox.modOpts    = new ipb.Popup( 'modOpts',
  1010.                                                                     {
  1011.                                                                         type: 'pane',
  1012.                                                                         modal: true,
  1013.                                                                         w: '550px',
  1014.                                                                         h: 'auto',
  1015.                                                                         initial: s.responseText,
  1016.                                                                         hideAtStart: true,
  1017.                                                                         close: '.cancel'
  1018.                                                                     }
  1019.                                                                 );
  1020.  
  1021.                                                     /* Setup close button */
  1022.                                                     $('modOpts_close').stopObserving();
  1023.                                                     $('modOpts_close').observe( 'click',
  1024.                                                         function()
  1025.                                                         {
  1026.                                                             ipb.shoutbox.closePopup('moderator');
  1027.                                                         }
  1028.                                                     );
  1029.                                                 }
  1030.  
  1031.                                                 ipb.shoutbox.setupPopup('moderator');
  1032.                                             }
  1033.                                         }
  1034.                                     );
  1035.                                 }
  1036.                             }
  1037.                             else
  1038.                             {
  1039.                                 ipb.shoutbox.produceError('invalid_command');
  1040.                             }
  1041.                         }
  1042.                         else
  1043.                         {
  1044.                             ipb.shoutbox.produceError('invalid_command');
  1045.                         }
  1046.                     }
  1047.                     else
  1048.                     {
  1049.                         ipb.shoutbox.clearShout();
  1050.                         ipb.shoutbox.produceError('mod_no_perms');
  1051.                     }
  1052.  
  1053.                     break;
  1054.                 default:
  1055.                     return 'doshout';
  1056.             }
  1057.         }
  1058.     },
  1059.  
  1060.     validCommandSyntax: function(c, m)
  1061.     {
  1062.         if (c != '' && typeof(c) != 'undefined' && c != null && c)
  1063.         {
  1064.             if (m == true)
  1065.             {
  1066.                 c = c.toString();
  1067.                 if (c.match(new RegExp("^/([a-zA-Z]+?)$", 'i')))
  1068.                 {
  1069.                     return true;
  1070.                 }
  1071.                 else
  1072.                 {
  1073.                     return false;
  1074.                 }
  1075.             }
  1076.             else
  1077.             {
  1078.                 return true;
  1079.             }
  1080.         }
  1081.  
  1082.         return false;
  1083.     },
  1084.  
  1085.     /**
  1086.      * Rewrites the classes for the shouts
  1087.      *
  1088.      * @var     boolean     check   Tells the function to skip or perfom the check for in_archive (needed when we reload shouts while the archive popup is open!)
  1089.      */
  1090.     rewriteShoutClasses: function(check)
  1091.     {
  1092.         var table = null,
  1093.             check = check == false ? false : true;
  1094.             skip  = 0;
  1095.  
  1096.         if ( check && ipb.shoutbox.in_archive )
  1097.         {
  1098.             table = $('shoutbox-archive-shouts');
  1099.         }
  1100.         else
  1101.         {
  1102.             table = $('shoutbox-shouts-table');
  1103.         }
  1104.  
  1105.         /* Let's update the rows! =D */
  1106.         if ( table.down('tbody') )
  1107.         {
  1108.             $A( table.down('tbody').childElements() ).each(
  1109.                 function(tr)
  1110.                 {
  1111.                     skip = ( skip == 0 ) ? 1 : 0;
  1112.  
  1113.                     $A( tr.childElements() ).each(
  1114.                         function(td)
  1115.                         {
  1116.                             /* Remove inline styles added by Highlight */
  1117.                             td.setStyle({
  1118.                                 backgroundColor: '',
  1119.                                 backgroundImage: ''
  1120.                             });
  1121.  
  1122.                             if ( skip )
  1123.                             {
  1124.                                 if ( td.hasClassName('altrow') )
  1125.                                 {
  1126.                                     td.removeClassName('altrow');
  1127.                                 }
  1128.                             }
  1129.                             else
  1130.                             {
  1131.                                 td.addClassName('altrow');
  1132.                             }
  1133.                         }
  1134.                     );
  1135.                 }
  1136.             )
  1137.         };
  1138.     },
  1139.  
  1140.     initEvents: function()
  1141.     {
  1142.         if ( !ipb.shoutbox.events_loaded )
  1143.         {
  1144.             ipb.shoutbox.events_loaded = true;
  1145.             document.observe('keypress', ipb.shoutbox.keypress_handler );
  1146.         }
  1147.     },
  1148.  
  1149.     displayArchive: function(e)
  1150.     {
  1151.         if ( !ipb.shoutbox.view_archive || ipb.shoutbox.global_on )
  1152.         {
  1153.             return false;
  1154.         }
  1155.  
  1156.         if ( ipb.shoutbox.in_prefs || ipb.shoutbox.in_archive || ipb.shoutbox.in_mod )
  1157.         {
  1158.             Debug.write("displayArchive: in_prefs, in_archive or in_mod are set to true so this check fails and this should never happen!");
  1159.             return false;
  1160.         }
  1161.  
  1162.         if ( typeof( e ) != 'undefined' )
  1163.         {
  1164.             Event.stop(e);
  1165.         }
  1166.  
  1167.         if ( $('archiveArea_popup') )
  1168.         {
  1169.             ipb.shoutbox.setupPopup('archive');
  1170.             return true;
  1171.         }
  1172.  
  1173.         new Ajax.Request( ipb.shoutbox.baseUrl + '&type=archive&action=load',
  1174.             {
  1175.                 method: 'get',
  1176.                 encoding: ipb.vars['charset'],
  1177.                 onSuccess: function(s)
  1178.                 {
  1179.                     ipb.shoutbox.archiveArea = new ipb.Popup(
  1180.                         'archiveArea',
  1181.                         {
  1182.                             type: 'pane',
  1183.                             modal: true,
  1184.                             w: '740px',
  1185.                             h: '450px',
  1186.                             initial: s.responseText,
  1187.                             hideAtStart: true,
  1188.                             close: '.cancel'
  1189.                         }
  1190.                     );
  1191.  
  1192.                     /* Setup close button */
  1193.                     $('archiveArea_close').stopObserving();
  1194.                     $('archiveArea_close').observe( 'click',
  1195.                         function()
  1196.                         {
  1197.                             ipb.shoutbox.closePopup('archive');
  1198.                         }
  1199.                     );
  1200.  
  1201.                     /* Setup the filter button */
  1202.                     $('shoutbox-archive-filter-button').observe( 'click', ipb.shoutbox.archiveDoFilter );
  1203.  
  1204.                     /* Setup menu and onclick for archive filters */
  1205.                     new ipb.Menu( $( 'shoutbox_archive_filters' ), $( 'shoutbox_archive_filters_menucontent' ) );
  1206.  
  1207.                     $('filter_today').down('a').observe('click', ipb.shoutbox.archiveQuickFilters.bindAsEventListener(this) );
  1208.                     $('filter_yesterday').down('a').observe('click', ipb.shoutbox.archiveQuickFilters.bindAsEventListener(this) );
  1209.                     $('filter_month').down('a').observe('click', ipb.shoutbox.archiveQuickFilters.bindAsEventListener(this) );
  1210.                     $('filter_all').down('a').observe('click', ipb.shoutbox.archiveQuickFilters.bindAsEventListener(this) );
  1211.                     $('filter_mine').down('a').observe('click', ipb.shoutbox.archiveQuickFilters.bindAsEventListener(this) );
  1212.  
  1213.                     /* Let's "fix" the ugly scrollbar removing overflow:auto */
  1214.                     $('archiveArea_inner').setStyle( { overflow: 'hidden' } );
  1215.  
  1216.                     ipb.shoutbox.setupPopup('archive');
  1217.                 }
  1218.             }
  1219.         );
  1220.     },
  1221.  
  1222.     produceError: function( error )
  1223.     {
  1224.         var errorDiv  = 'app';
  1225.  
  1226.         /* Global shoutbox? */
  1227.         if ( ipb.shoutbox.global_on )
  1228.         {
  1229.             if ( ipb.shoutbox.can_edit && ipb.shoutbox.mod_in_action )
  1230.             {
  1231.                 errorDiv = 'editShout';
  1232.             }
  1233.             else
  1234.             {
  1235.                 errorDiv = 'glb';
  1236.             }
  1237.         }
  1238.         else if ( ipb.shoutbox.in_prefs )
  1239.         {
  1240.             errorDiv = 'myprefs';
  1241.         }
  1242.         else if ( ipb.shoutbox.in_mod )
  1243.         {
  1244.             errorDiv = 'moderator';
  1245.         }
  1246.         else if ( ipb.shoutbox.in_archive )
  1247.         {
  1248.             errorDiv = 'archive';
  1249.         }
  1250.  
  1251.         /* Got a key to find the string? */
  1252.         if ( ipb.shoutbox.errors[ error ] )
  1253.         {
  1254.             error = ipb.shoutbox.errors[ error ];
  1255.         }
  1256.  
  1257.         /* Div exists? Display it! =D */
  1258.         if ( $('shoutbox-inline-error-'+errorDiv) )
  1259.         {
  1260.             $('shoutbox-inline-error-'+errorDiv).update( error ).show();
  1261.  
  1262.             // Set timer to hide it
  1263.             setTimeout("$('shoutbox-inline-error-" + errorDiv + "').hide()", 2000);
  1264.         }
  1265.         else
  1266.         {
  1267.             alert( error );
  1268.         }
  1269.     },
  1270.  
  1271.     getShout: function( strip_html )
  1272.     {
  1273.         var d = '';
  1274.  
  1275.         if ( ipb.shoutbox.global_on )
  1276.         {
  1277.             d = $('shoutbox-global-shout').value;
  1278.         }
  1279.         else if (ipb.textEditor.getEditor().CKEditor)
  1280.         {
  1281.             d = ipb.textEditor.getEditor().CKEditor.getData();
  1282.         }
  1283.         else
  1284.         {
  1285.             $$('textarea.ipsEditor_textarea').each
  1286.             (
  1287.                 function( te )
  1288.                 {
  1289.                     if (te.name == "shout_msg")
  1290.                     {
  1291.                         d = te.value;
  1292.                     }
  1293.                 }
  1294.             );
  1295.         }
  1296.  
  1297.         d = d.strip();
  1298.  
  1299.         while (d.match(new RegExp("^(.+?)<br>$", 'i')))
  1300.         {
  1301.             d = d.replace(new RegExp("^(.+?)<br>$", 'i'), '$1');
  1302.         }
  1303.  
  1304.         d = d.strip();
  1305.  
  1306.         if (d.toLowerCase().substring(d.length-4, d.length) == '<br>')
  1307.         {
  1308.             d = d.substring(0, d.length-4);
  1309.         }
  1310.  
  1311.         d = d.strip();
  1312.  
  1313.         if ( strip_html )
  1314.         {
  1315.             d = d.stripTags();
  1316.         }
  1317.  
  1318.         return d;
  1319.     },
  1320.  
  1321.     clearShout: function()
  1322.     {
  1323.         ipb.shoutbox.updateLastActivity();
  1324.  
  1325.         if ( ipb.shoutbox.global_on )
  1326.         {
  1327.             // Save our shout if we get errors
  1328.             ipb.shoutbox.tempShout = $('shoutbox-global-shout').getValue();
  1329.  
  1330.             $('shoutbox-global-shout').setValue("");
  1331.             $('shoutbox-global-shout').focus();
  1332.         }
  1333.         else if ( ipb.textEditor.getEditor().CKEditor )
  1334.         {
  1335.             // Save our shout if we get errors
  1336.             ipb.shoutbox.tempShout = ipb.textEditor.getEditor().CKEditor.getData();
  1337.             ipb.textEditor.getEditor().CKEditor.setData('');
  1338.         }
  1339.         else
  1340.         {
  1341.             $$('textarea.ipsEditor_textarea').each
  1342.             (
  1343.                 function( te )
  1344.                 {
  1345.                     if (te.name == "shout_msg")
  1346.                     {
  1347.                         // Save our shout if we get errors
  1348.                         ipb.shoutbox.tempShout = te.getValue();
  1349.  
  1350.                         te.setValue("");
  1351.                         te.focus();
  1352.                     }
  1353.                 }
  1354.             );
  1355.         }
  1356.     },
  1357.  
  1358.     restoreShout: function()
  1359.     {
  1360.         if ( ipb.shoutbox.tempShout != null )
  1361.         {
  1362.             if ( ipb.shoutbox.global_on )
  1363.             {
  1364.                 $('shoutbox-global-shout').setValue( ipb.shoutbox.tempShout );
  1365.                 $('shoutbox-global-shout').focus();
  1366.             }
  1367.             else
  1368.             {
  1369.                 ipb.textEditor.getEditor().CKEditor.setData( ipb.shoutbox.tempShout );
  1370.             }
  1371.         }
  1372.     },
  1373.  
  1374.     resizeShouts: function()
  1375.     {
  1376.         var ss = $('shoutbox-shouts'),
  1377.             sr = $('shouts-resizer');
  1378.  
  1379.         if ( ! ipb.shoutbox.myMemberID)
  1380.         {
  1381.             sr.style.cursor = 'default';
  1382.             return false;
  1383.         }
  1384.  
  1385.         Resize.init( sr, ss, true, false );
  1386.  
  1387.         ss.min_height = 100;
  1388.         ss.Resizing   = function()
  1389.         {
  1390.             ipb.shoutbox.shoutsScrollThem();
  1391.         }
  1392.  
  1393.         ss.Resize_end = function(data)
  1394.         {
  1395.             ipb.shoutbox.myPrefsHeightSave( parseInt(data.h) );
  1396.         }
  1397.     },
  1398.  
  1399.     getTimestamp: function()
  1400.     {
  1401.         var d = new Date(),
  1402.             t = d.getTime();
  1403.  
  1404.         return Math.floor( t / 1000 );
  1405.     },
  1406.  
  1407.     updateJSPreferences: function()
  1408.     {
  1409.         if ( !ipb.shoutbox.myMemberID || !ipb.shoutbox.can_use )
  1410.         {
  1411.             return false;
  1412.         }
  1413.  
  1414.         if ( ipb.shoutbox.my_prefs['display_refresh_button'] == 1 )
  1415.         {
  1416.             $('shoutbox-refresh-button').show();
  1417.         }
  1418.         else
  1419.         {
  1420.             $('shoutbox-refresh-button').hide();
  1421.         }
  1422.  
  1423.         ipb.shoutbox.enable_cmds = ( ipb.shoutbox.my_prefs['enable_quick_commands'] == 1 ) ? true : false;
  1424.     },
  1425.  
  1426.     shoutsGetLastID: function()
  1427.     {
  1428.         var tempLastID = 0;
  1429.  
  1430.         $A( $('shoutbox-shouts-table').down('tbody').childElements() ).each(
  1431.             function(tr)
  1432.             {
  1433.                 tempLastID = parseInt(tr.id.substring(10));
  1434.  
  1435.                 if ( tempLastID > ipb.shoutbox.last_shout_id )
  1436.                 {
  1437.                     ipb.shoutbox.last_shout_id = tempLastID;
  1438.                 }
  1439.             }
  1440.         );
  1441.  
  1442.         return ipb.shoutbox.last_shout_id;
  1443.     },
  1444.  
  1445.     shoutsScrollThem: function()
  1446.     {
  1447.         var area = $( 'shoutbox-shouts' );
  1448.  
  1449.         if ( ipb.shoutbox.shout_order == 'asc' )
  1450.         {
  1451.             area.scrollTop = area.scrollHeight - parseInt( area.getHeight() ) + 500;
  1452.         }
  1453.         else
  1454.         {
  1455.             area.scrollTop = 0;
  1456.         }
  1457.     },
  1458.  
  1459.     isInactive: function()
  1460.     {
  1461.         if ( ipb.shoutbox._inactive )
  1462.         {
  1463.             return true;
  1464.         }
  1465.  
  1466.         var diff     = parseInt( ipb.shoutbox.getTimestamp() - ipb.shoutbox.last_active ),
  1467.             myMin    = ( diff / 60 ) * ipb.shoutbox.time_minute,
  1468.             checkMin = ipb.shoutbox.inactive_timeout * ipb.shoutbox.time_minute;
  1469.  
  1470.         if ( myMin >= checkMin )
  1471.         {
  1472.             ipb.shoutbox.displayInactivePrompt();
  1473.             return true;
  1474.         }
  1475.         else
  1476.         {
  1477.             return false;
  1478.         }
  1479.     },
  1480.  
  1481.     displayInactivePrompt: function()
  1482.     {
  1483.         /** Do some common things =O **/
  1484.         ipb.shoutbox._inactive = true;
  1485.         clearTimeout( ipb.shoutbox.timeoutShouts );
  1486.         clearTimeout( ipb.shoutbox.timeoutMembers );
  1487.  
  1488.         // Which shoutbox? :D
  1489.         if ( ipb.shoutbox.global_on )
  1490.         {
  1491.             $('shoutbox-shouts-table').hide();
  1492.  
  1493.             $('shoutbox-inactive-prompt').setStyle( { height: $('shoutbox-shouts').getStyle('height') } );
  1494.             $('shoutbox-inactive-prompt').show();
  1495.         }
  1496.         else
  1497.         {
  1498.             // Do we have another popup open already?
  1499.             if ( ipb.shoutbox.in_prefs || ipb.shoutbox.in_mod || ipb.shoutbox.in_archive )
  1500.             {
  1501.                 ipb.shoutbox.inactiveWhenPopup = true;
  1502.             }
  1503.             else
  1504.             {
  1505.                 if ( $('inactivePrompt_popup') )
  1506.                 {
  1507.                     ipb.shoutbox.inactivePrompt.show();
  1508.                 }
  1509.                 else
  1510.                 {
  1511.                     ipb.shoutbox.inactivePrompt = new ipb.Popup( 'inactivePrompt',
  1512.                         {
  1513.                             type: 'pane',
  1514.                             modal: true,
  1515.                             w: '450px',
  1516.                             initial: "<table>" + $('shoutbox-inactive-prompt').innerHTML + "</table>",
  1517.                             hideAtStart: false,
  1518.                             close: '.close'
  1519.                         }
  1520.                     );
  1521.  
  1522.                     $('inactivePrompt_close').hide();
  1523.                 }
  1524.             }
  1525.         }
  1526.     },
  1527.  
  1528.     processInactivePrompt: function()
  1529.     {
  1530.         if ( !ipb.shoutbox._inactive )
  1531.         {
  1532.             return false;
  1533.         }
  1534.  
  1535.         /** Do some common things =O **/
  1536.         ipb.shoutbox._inactive = false;
  1537.         ipb.shoutbox.updateLastActivity();
  1538.  
  1539.         // Which shoutbox? :D
  1540.         if ( ipb.shoutbox.global_on )
  1541.         {
  1542.             $('shoutbox-inactive-prompt').hide();
  1543.             $('shoutbox-shouts-table').show();
  1544.  
  1545.             // Refresh shout only if we are not submitting
  1546.             if ( !ipb.shoutbox.submittingShout )
  1547.             {
  1548.                 ipb.shoutbox.reloadShouts(true);
  1549.             }
  1550.         }
  1551.         else
  1552.         {
  1553.             ipb.shoutbox.inactivePrompt.hide();
  1554.  
  1555.             // App page, get also members :D
  1556.             ipb.shoutbox.reloadMembers(true);
  1557.             ipb.shoutbox.reloadShouts(true);
  1558.         }
  1559.     },
  1560.  
  1561.     actionTaken: function(text)
  1562.     {
  1563.         if ( !text)
  1564.         {
  1565.             return false;
  1566.         }
  1567.  
  1568.         alert( text );
  1569.     },
  1570.  
  1571.     setActionAndReload: function(action)
  1572.     {
  1573.         if ( action != '' && typeof(action) != 'undefined' && action != null )
  1574.         {
  1575.             var url = ipb.vars['base_url'] + '&app=shoutbox';
  1576.  
  1577.             ipb.Cookie.set( '_shoutbox_jscmd', action );
  1578.  
  1579.             try
  1580.             {
  1581.                 window.location = url.replace(/&$/ig, '');
  1582.             }
  1583.  
  1584.             catch(me)
  1585.             {
  1586.                 window.location.href = url.replace(/&$/ig, '');
  1587.             }
  1588.         }
  1589.  
  1590.         return false;
  1591.     },
  1592.  
  1593.     emoticonOnclick: function(emo_code)
  1594.     {
  1595.         //Check focus
  1596.         $('shoutbox-global-shout').focus();
  1597.  
  1598.         // Parse properly emo_code
  1599.         emo_code = emo_code.replace( /&quot;/g, '"' );
  1600.         emo_code = emo_code.replace( /&lt;/g  , '<' );
  1601.         emo_code = emo_code.replace( /&gt;/g  , '>' );
  1602.         emo_code = emo_code.replace( /&amp;/g , '&' );
  1603.  
  1604.         // Update textarea and close menu
  1605.         ipb.shoutbox.insertAtCursor( " " + emo_code + " " );
  1606.  
  1607.         return false;
  1608.     },
  1609.  
  1610.     bbcodePopup: function(e)
  1611.     {
  1612.         window.open( ipb.vars['base_url'] + "&app=forums&module=extras&section=legends&do=bbcode", "bbcode", "status=0,toolbar=0,width=1024,height=800,scrollbars=1");
  1613.         Event.stop(e);
  1614.         return false;
  1615.     },
  1616.  
  1617.     showShoutboxPopup: function(e)
  1618.     {
  1619.         window.open( ipb.vars['board_url'] + "/index.php?app=shoutbox&do=popup", "popup", "status=0,toolbar=0,location=0,menubar=0,width=1024,height=768,scrollbars=1");
  1620.         Event.stop(e);
  1621.         return false;
  1622.     },
  1623.  
  1624.     popupUpdateStatus: function(lang, text)
  1625.     {
  1626.         if ( !$('shoutbox-popup-status') )
  1627.         {
  1628.             Debug.warn("ID shoutbox-popup-status NOT FOUND! | LANG: " + lang + " | TEXT: " + text );
  1629.             return false;
  1630.         }
  1631.  
  1632.         if ( !ipb.shoutbox.myMemberID || ipb.shoutbox.global_on )
  1633.         {
  1634.             return false;
  1635.         }
  1636.  
  1637.         text = ( text == true ) ? true : false;
  1638.  
  1639.         if ( !text && ( !lang || !ipb.shoutbox.langs[lang] ) )
  1640.         {
  1641.             return false;
  1642.         }
  1643.  
  1644.         if ( text )
  1645.         {
  1646.             $('shoutbox-popup-status').update( lang );
  1647.         }
  1648.         else
  1649.         {
  1650.             $('shoutbox-popup-status').update( ipb.shoutbox.langs[lang] );
  1651.         }
  1652.     },
  1653.  
  1654.     popupUpdateContent: function(lang, text)
  1655.     {
  1656.         if ( !ipb.shoutbox.myMemberID || ipb.shoutbox.global_on )
  1657.         {
  1658.             return false;
  1659.         }
  1660.  
  1661.         text = ( text == true ) ? true : false;
  1662.  
  1663.         if ( !text && ( !lang || !ipb.shoutbox.langs[lang] ) )
  1664.         {
  1665.             return false;
  1666.         }
  1667.  
  1668.         if ( text )
  1669.         {
  1670.             $('shoutbox-popup-content').update( lang );
  1671.         }
  1672.         else
  1673.         {
  1674.             $('shoutbox-popup-content').update( ipb.shoutbox.langs[lang] );
  1675.         }
  1676.     },
  1677.  
  1678.     mod_opts_get_edit_shout: function()
  1679.     {
  1680.         if ( !ipb.shoutbox.moderator && !ipb.shoutbox.can_edit && !ipb.shoutbox.mod_in_action )
  1681.         {
  1682.             return false;
  1683.         }
  1684.  
  1685.         var d = ipb.textEditor.getEditor().CKEditor.getData();
  1686.  
  1687.         d = d.strip();
  1688.  
  1689.         while (d.match(new RegExp("^(.+?)<br>$", 'i')))
  1690.         {
  1691.             d = d.replace(new RegExp("^(.+?)<br>$", 'i'), '$1');
  1692.         }
  1693.  
  1694.         d = d.strip();
  1695.  
  1696.         if (d.toLowerCase().substring(d.length-4, d.length) == '<br>')
  1697.         {
  1698.             d = d.substring(0, d.length-4);
  1699.         }
  1700.  
  1701.         d = d.strip();
  1702.  
  1703.         return d;
  1704.     },
  1705.  
  1706.     mod_opts_do_edit_shout: function()
  1707.     {
  1708.         if ( (!ipb.shoutbox.moderator && !ipb.shoutbox.can_edit) || !ipb.shoutbox.mod_in_action )
  1709.         {
  1710.             return false;
  1711.         }
  1712.  
  1713.         ipb.shoutbox.updateLastActivity();
  1714.  
  1715.         var globalOn = ( ipb.shoutbox.global_on ) ? '&global=1' : '',
  1716.             shout    = ipb.shoutbox.mod_opts_get_edit_shout();
  1717.  
  1718.         if ( shout == '' )
  1719.         {
  1720.             ipb.shoutbox.produceError('blank_shout');
  1721.             return false;
  1722.         }
  1723.  
  1724.         if ( shout.length * 1024 > ipb.shoutbox.max_length )
  1725.         {
  1726.             ipb.shoutbox.produceError('shout_too_big');
  1727.             return false;
  1728.         }
  1729.  
  1730.         /**
  1731.          * 1.1.2
  1732.          * Show "processing" only if we are in the app page!
  1733.          */
  1734.         if ( ipb.shoutbox.global_on )
  1735.         {
  1736.             ipb.shoutbox.popupUpdateStatus('processing');
  1737.         }
  1738.  
  1739.         /* Letz ajax! */
  1740.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=mod&action=performCommand&command=' + ipb.shoutbox.mod_command + '&modtype=shout' + globalOn,
  1741.             {
  1742.                 method: 'post',
  1743.                 encoding: ipb.vars['charset'],
  1744.                 parameters: {
  1745.                     id:         ipb.shoutbox.mod_shout_id,
  1746.                     shout:      shout.encodeParam()
  1747.                 },
  1748.                 onSuccess: function(s)
  1749.                 {
  1750.                     $('shout-row-' + ipb.shoutbox.mod_shout_id ).update( s.responseText );
  1751.  
  1752.                     /* We have the editShout_popup available and visible? */
  1753.                     if ( $('editShout_popup') && $('editShout_popup').visible() )
  1754.                     {
  1755.                         ipb.shoutbox.closePopup('editShout');
  1756.                     }
  1757.                     else
  1758.                     {
  1759.                         if ( $('editHistory_shout') )
  1760.                         {
  1761.                             $('editHistory_shout').show();
  1762.                         }
  1763.  
  1764.                         ipb.shoutbox.modOptsEditReset();
  1765.                     }
  1766.  
  1767.                     window.location.reload();
  1768.                 }
  1769.             }
  1770.         );
  1771.     },
  1772.  
  1773.     refreshShouts: function()
  1774.     {
  1775.         /* Block it if we are inactive */
  1776.         if ( ipb.shoutbox._inactive )
  1777.         {
  1778.             return false;
  1779.         }
  1780.  
  1781.         ipb.shoutbox.updateLastActivity();
  1782.         ipb.shoutbox.reloadShouts(true);
  1783.     },
  1784.  
  1785.     archive_get_dropdowns: function(t, v)
  1786.     {
  1787.         if (t != 'start' && t != 'end')
  1788.         {
  1789.             return new Array();
  1790.         }
  1791.  
  1792.         var a = new Array
  1793.         (
  1794.             $('filter_'+t+'_month'),
  1795.             $('filter_'+t+'_day'),
  1796.             $('filter_'+t+'_year'),
  1797.             $('filter_'+t+'_hour'),
  1798.             $('filter_'+t+'_minute'),
  1799.             $('filter_'+t+'_meridiem')
  1800.         );
  1801.  
  1802.         if (v == true)
  1803.         {
  1804.             for (var i=0; i<a.length; i++)
  1805.             {
  1806.                 if ( a[i] )
  1807.                 {
  1808.                     a[i] = a[i].getValue();
  1809.                 }
  1810.             }
  1811.         }
  1812.  
  1813.         return a;
  1814.     },
  1815.  
  1816.     archive_set_dropdown_option: function(o, v)
  1817.     {
  1818.         if (o.options.length > 0)
  1819.         {
  1820.             for (var i=0; i<o.options.length; i++)
  1821.             {
  1822.                 if (o.options[i].value == v)
  1823.                 {
  1824.                     o.selectedIndex = i;
  1825.                     break;
  1826.                 }
  1827.             }
  1828.         }
  1829.     },
  1830.  
  1831.     archiveDoFilter: function()
  1832.     {
  1833.         if ( !ipb.shoutbox.view_archive || ipb.shoutbox.global_on || !ipb.shoutbox.in_archive )
  1834.         {
  1835.             return false;
  1836.         }
  1837.  
  1838.         /* Already filtering? prevent odd things then */
  1839.         if ( ipb.shoutbox.archive_filtering )
  1840.         {
  1841.             ipb.shoutbox.produceError('already_filtering');
  1842.             return false;
  1843.         }
  1844.  
  1845.         ipb.shoutbox.archive_filtering = true;
  1846.  
  1847.  
  1848.         if ( ipb.shoutbox.blur )
  1849.         {
  1850.             ipb.shoutbox.blur();
  1851.         }
  1852.  
  1853.         ipb.shoutbox._inactive   = true;
  1854.         ipb.shoutbox.updateLastActivity();
  1855.  
  1856.         var p = {
  1857.             'start':    ipb.shoutbox.archive_get_dropdowns( 'start', true ),
  1858.             'end':      ipb.shoutbox.archive_get_dropdowns( 'end', true ),
  1859.             'member':   $('filter_member_name').getValue().strip()
  1860.         };
  1861.  
  1862.         if ( p['member'].indexOf(',') > 0 )
  1863.         {
  1864.             var x = new Array();
  1865.             var m = p['member'].split(',');
  1866.  
  1867.             for (var i=0; i<m.length; i++)
  1868.             {
  1869.                 m[i] = m[i].strip();
  1870.                 if (m[i] == '' || m[i].length < 3)
  1871.                 {
  1872.                     continue;
  1873.                 }
  1874.  
  1875.                 x[x.length] = m[i];
  1876.             }
  1877.  
  1878.             if (x.length <= 0)
  1879.             {
  1880.                 ipb.shoutbox.produceError('member_names_too_short');
  1881.                 return false;
  1882.             }
  1883.         }
  1884.         else if (p['member'].length > 0 && p['member'].length < 3)
  1885.         {
  1886.             ipb.shoutbox.produceError('member_name_too_short');
  1887.             return false;
  1888.         }
  1889.  
  1890.         ipb.shoutbox.archive_cur_filter = p;
  1891.  
  1892.         ipb.shoutbox.popupUpdateStatus('filtering');
  1893.  
  1894.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=archive&action=filter',
  1895.             {
  1896.                 method:     'post',
  1897.                 encoding: ipb.vars['charset'],
  1898.                 parameters: {
  1899.                     'start':    ipb.shoutbox.archive_get_dropdowns( 'start', true ).join(','),
  1900.                     'end':      ipb.shoutbox.archive_get_dropdowns( 'end', true ).join(','),
  1901.                     'member':   p['member']
  1902.                 },
  1903.                 onSuccess: function(s)
  1904.                 {
  1905.                     ipb.shoutbox.archive_filter_process(s);
  1906.                 }
  1907.             }
  1908.         );
  1909.  
  1910.         return false;
  1911.     },
  1912.  
  1913.     archive_filter_process: function(s)
  1914.     {
  1915.         ipb.shoutbox.popupUpdateStatus('processed');
  1916.  
  1917.         if ( ipb.shoutbox.checkForErrors(s.responseText) )
  1918.         {
  1919.             ipb.shoutbox.archive_filtering = false;
  1920.             return false;
  1921.         }
  1922.  
  1923.         $('shoutbox-archive-shouts').update( s.responseText );
  1924.  
  1925.         new Effect.Parallel(
  1926.             [
  1927.                 new Effect.BlindUp( $('beforeButtonClick') ),
  1928.                 new Effect.BlindDown( $('afterButtonClick') )
  1929.             ],
  1930.             {
  1931.                 duration: 1.0
  1932.             }
  1933.         );
  1934.  
  1935.         $('backToFilters').stopObserving();
  1936.         $('backToFilters').observe( 'click', function()
  1937.             {
  1938.                 new Effect.Parallel(
  1939.                     [
  1940.                         new Effect.BlindUp( $('afterButtonClick') ),
  1941.                         new Effect.BlindDown( $('beforeButtonClick') )
  1942.                     ],
  1943.                     {
  1944.                         duration: 1.0
  1945.                     }
  1946.                 );
  1947.  
  1948.                 /* Reset filtering action using that button! */
  1949.                 ipb.shoutbox.archive_filtering = false;
  1950.             }
  1951.         );
  1952.  
  1953.         ipb.shoutbox.rewriteShoutClasses();
  1954.         ipb.shoutbox.archive_update_floaters();
  1955.     },
  1956.  
  1957.     rect: function(x, y, w, h)
  1958.     {
  1959.         var recta = new Object;
  1960.         recta.x = x;
  1961.         recta.y = y;
  1962.         recta.w = w;
  1963.         recta.h = h;
  1964.  
  1965.         return recta;
  1966.     },
  1967.  
  1968.     archiveQuickFilters: function(event)
  1969.     {
  1970.         if ( !ipb.shoutbox.view_archive || ipb.shoutbox.global_on || !ipb.shoutbox.in_archive )
  1971.         {
  1972.             return false;
  1973.         }
  1974.  
  1975.         if ( ipb.shoutbox.blur )
  1976.         {
  1977.             ipb.shoutbox.blur();
  1978.         }
  1979.  
  1980.         /* Get the proper filter */
  1981.         var element = Event.element(event);
  1982.         var filter  = element.up('li').id.sub( 'filter_', '' );
  1983.  
  1984.         /* Ypdate last active */
  1985.         ipb.shoutbox.updateLastActivity();
  1986.  
  1987.         var d = new Date();
  1988.         var s = ipb.shoutbox.archive_get_dropdowns('start', false);
  1989.         var e = ipb.shoutbox.archive_get_dropdowns('end', false);
  1990.  
  1991.         switch ( filter )
  1992.         {
  1993.             case 'today':
  1994.                 ipb.shoutbox.archive_set_dropdown_option(s[0], d.getMonth()+1);
  1995.                 ipb.shoutbox.archive_set_dropdown_option(s[1], d.getDate());
  1996.                 ipb.shoutbox.archive_set_dropdown_option(s[2], d.getFullYear());
  1997.                 ipb.shoutbox.archive_set_dropdown_option(s[3], 12);
  1998.                 ipb.shoutbox.archive_set_dropdown_option(s[4], 0);
  1999.                 ipb.shoutbox.archive_set_dropdown_option(s[5], 'am');
  2000.  
  2001.                 ipb.shoutbox.archive_set_dropdown_option(e[0], d.getMonth()+1);
  2002.                 ipb.shoutbox.archive_set_dropdown_option(e[1], d.getDate());
  2003.                 ipb.shoutbox.archive_set_dropdown_option(e[2], d.getFullYear());
  2004.                 ipb.shoutbox.archive_set_dropdown_option(e[3], 11);
  2005.                 ipb.shoutbox.archive_set_dropdown_option(e[4], 59);
  2006.                 ipb.shoutbox.archive_set_dropdown_option(e[5], 'pm');
  2007.  
  2008.                 $('filter_member_name').value = '';
  2009.                 break;
  2010.             case 'yesterday':
  2011.                 var m = d.getMonth()+1;
  2012.                 var a = d.getDate();
  2013.                 var y = d.getFullYear();
  2014.  
  2015.                 if (a == 1)
  2016.                 {
  2017.                     if (m == 1)
  2018.                     {
  2019.                         m  = 12;
  2020.                         y -= 1;
  2021.                     }
  2022.                     else
  2023.                     {
  2024.                         m -= 1;
  2025.                     }
  2026.  
  2027.                     a = ipb.shoutbox.month_days(m-1);
  2028.                 }
  2029.                 else
  2030.                 {
  2031.                     a -= 1;
  2032.                 }
  2033.  
  2034.                 ipb.shoutbox.archive_set_dropdown_option(s[0], m);
  2035.                 ipb.shoutbox.archive_set_dropdown_option(s[1], a);
  2036.                 ipb.shoutbox.archive_set_dropdown_option(s[2], y);
  2037.                 ipb.shoutbox.archive_set_dropdown_option(s[3], 12);
  2038.                 ipb.shoutbox.archive_set_dropdown_option(s[4], 0);
  2039.                 ipb.shoutbox.archive_set_dropdown_option(s[5], 'am');
  2040.  
  2041.                 ipb.shoutbox.archive_set_dropdown_option(e[0], m);
  2042.                 ipb.shoutbox.archive_set_dropdown_option(e[1], a);
  2043.                 ipb.shoutbox.archive_set_dropdown_option(e[2], y);
  2044.                 ipb.shoutbox.archive_set_dropdown_option(e[3], 11);
  2045.                 ipb.shoutbox.archive_set_dropdown_option(e[4], 59);
  2046.                 ipb.shoutbox.archive_set_dropdown_option(e[5], 'pm');
  2047.  
  2048.                 $('filter_member_name').value = '';
  2049.                 break;
  2050.             case 'month':
  2051.                 ipb.shoutbox.archive_set_dropdown_option(s[0], d.getMonth()+1);
  2052.                 ipb.shoutbox.archive_set_dropdown_option(s[1], 1);
  2053.                 ipb.shoutbox.archive_set_dropdown_option(s[2], d.getFullYear());
  2054.                 ipb.shoutbox.archive_set_dropdown_option(s[3], 12);
  2055.                 ipb.shoutbox.archive_set_dropdown_option(s[4], 0);
  2056.                 ipb.shoutbox.archive_set_dropdown_option(s[5], 'am');
  2057.  
  2058.                 ipb.shoutbox.archive_set_dropdown_option(e[0], d.getMonth()+1);
  2059.                 ipb.shoutbox.archive_set_dropdown_option(e[1], ipb.shoutbox.month_days[d.getMonth()]);
  2060.                 ipb.shoutbox.archive_set_dropdown_option(e[2], d.getFullYear());
  2061.                 ipb.shoutbox.archive_set_dropdown_option(e[3], 11);
  2062.                 ipb.shoutbox.archive_set_dropdown_option(e[4], 59);
  2063.                 ipb.shoutbox.archive_set_dropdown_option(e[5], 'pm');
  2064.  
  2065.                 $('filter_member_name').value = '';
  2066.                 break;
  2067.             case 'all':
  2068.             case 'mine':
  2069.                 dd = new Date(ipb.shoutbox.oldest_shout);
  2070.                 hr = dd.getHours();
  2071.                 md = '';
  2072.  
  2073.                 if (hr < 12)
  2074.                 {
  2075.                     md = 'am';
  2076.                     if (hr == 0)
  2077.                     {
  2078.                         hr = 12;
  2079.                     }
  2080.                 }
  2081.                 else if (hr > 12)
  2082.                 {
  2083.                     md  = 'pm';
  2084.                     hr -= 12;
  2085.                 }
  2086.  
  2087.                 ipb.shoutbox.archive_set_dropdown_option(s[0], dd.getMonth()+1);
  2088.                 ipb.shoutbox.archive_set_dropdown_option(s[1], dd.getDate());
  2089.                 ipb.shoutbox.archive_set_dropdown_option(s[2], dd.getFullYear());
  2090.                 ipb.shoutbox.archive_set_dropdown_option(s[3], hr);
  2091.                 ipb.shoutbox.archive_set_dropdown_option(s[4], dd.getMinutes());
  2092.                 ipb.shoutbox.archive_set_dropdown_option(s[5], md);
  2093.  
  2094.                 ipb.shoutbox.archive_set_dropdown_option(e[0], d.getMonth()+1);
  2095.                 ipb.shoutbox.archive_set_dropdown_option(e[1], d.getDate());
  2096.                 ipb.shoutbox.archive_set_dropdown_option(e[2], d.getFullYear());
  2097.                 ipb.shoutbox.archive_set_dropdown_option(e[3], 11);
  2098.                 ipb.shoutbox.archive_set_dropdown_option(e[4], 59);
  2099.                 ipb.shoutbox.archive_set_dropdown_option(e[5], 'pm');
  2100.  
  2101.                 if ( filter == 'mine' )
  2102.                 {
  2103.                     $('filter_member_name').value = ipb.shoutbox.my_dname;
  2104.                 }
  2105.                 else
  2106.                 {
  2107.                     $('filter_member_name').value = '';
  2108.                 }
  2109.                 break;
  2110.             default:
  2111.                 ipb.shoutbox.archive_filtering = false;
  2112.                 return false; //Leave a return here!
  2113.         }
  2114.  
  2115.         ipb.shoutbox.archiveDoFilter();
  2116.     },
  2117.  
  2118.     archive_update_floaters: function()
  2119.     {
  2120.         if ( !ipb.shoutbox.view_archive || ipb.shoutbox.global_on || !ipb.shoutbox.in_archive )
  2121.         {
  2122.             return false;
  2123.         }
  2124.  
  2125.         ipb.shoutbox.archive_filtering = false;
  2126.  
  2127.         var o = $('shoutbox-archive-shouts-div');
  2128.         var r = $('shoutbox-archive-pages-floater');
  2129.  
  2130.         /* Scroll shouts to top again after changing page */
  2131.         o.scrollTop = 0;
  2132.  
  2133.         if ( ipb.shoutbox.shout_pages == 0 )
  2134.         {
  2135.             r.hide();
  2136.             return false;
  2137.         }
  2138.     },
  2139.  
  2140.     archive_update_pager: function(p)
  2141.     {
  2142.         var html = '';
  2143.  
  2144.         ipb.shoutbox.cur_page = p;
  2145.  
  2146.         if ( p > 1 )
  2147.         {
  2148.             html += "<span onclick='ipb.shoutbox.archive_goto_prev_page()' style='cursor:pointer'>&laquo;</span>&nbsp;";
  2149.         }
  2150.  
  2151.         html += ipb.shoutbox.langs['page']+' '+p+' '+ipb.shoutbox.langs['of']+' '+ipb.shoutbox.shout_pages;
  2152.  
  2153.         if ( p < ipb.shoutbox.shout_pages )
  2154.         {
  2155.             html += "&nbsp;<span onclick='ipb.shoutbox.archive_goto_next_page()' style='cursor:pointer'>&raquo;</span>";
  2156.         }
  2157.  
  2158.         $('shoutbox-archive-pages-data').innerHTML = html;
  2159.     },
  2160.  
  2161.     archive_goto_prev_page: function()
  2162.     {
  2163.         if ( !ipb.shoutbox.view_archive || ipb.shoutbox.global_on || !ipb.shoutbox.in_archive )
  2164.         {
  2165.             return false;
  2166.         }
  2167.  
  2168.         var p = ipb.shoutbox.cur_page;
  2169.         var t = ipb.shoutbox.shout_pages;
  2170.         var n = Math.floor(p-1);
  2171.  
  2172.         if (n < 1)
  2173.         {
  2174.             return false;
  2175.         }
  2176.  
  2177.         ipb.shoutbox.updateLastActivity();
  2178.         ipb.shoutbox.archive_cur_filter['page'] = n;
  2179.  
  2180.         ipb.shoutbox.popupUpdateStatus('filtering');
  2181.  
  2182.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=archive&action=filter',
  2183.             {
  2184.                 method:     'post',
  2185.                 encoding: ipb.vars['charset'],
  2186.                 parameters: {
  2187.                     'start':    ipb.shoutbox.archive_get_dropdowns( 'start', true ).join(','),
  2188.                     'end':      ipb.shoutbox.archive_get_dropdowns( 'end', true ).join(','),
  2189.                     'member':   $('filter_member_name').getValue().strip(),
  2190.                     'page':     n
  2191.                 },
  2192.                 onSuccess: function(s)
  2193.                 {
  2194.                     ipb.shoutbox.archive_filter_process(s);
  2195.                 }
  2196.             }
  2197.         );
  2198.     },
  2199.  
  2200.     archive_goto_next_page: function()
  2201.     {
  2202.         if (!ipb.shoutbox.view_archive || ipb.shoutbox.global_on || !ipb.shoutbox.in_archive)
  2203.         {
  2204.             return false;
  2205.         }
  2206.  
  2207.         var p = ipb.shoutbox.cur_page;
  2208.         var t = ipb.shoutbox.shout_pages;
  2209.         var n = Math.floor(p+1);
  2210.  
  2211.         if (n > t)
  2212.         {
  2213.             return false;
  2214.         }
  2215.  
  2216.         ipb.shoutbox.updateLastActivity();
  2217.         ipb.shoutbox.archive_cur_filter['page'] = n;
  2218.  
  2219.         ipb.shoutbox.popupUpdateStatus('filtering');
  2220.  
  2221.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=archive&action=filter',
  2222.             {
  2223.                 method:     'post',
  2224.                 encoding: ipb.vars['charset'],
  2225.                 parameters: {
  2226.                     'start':    ipb.shoutbox.archive_get_dropdowns( 'start', true ).join(','),
  2227.                     'end':      ipb.shoutbox.archive_get_dropdowns( 'end', true ).join(','),
  2228.                     'member':   $('filter_member_name').getValue().strip(),
  2229.                     'page':     n
  2230.                 },
  2231.                 onSuccess: function(s)
  2232.                 {
  2233.                     ipb.shoutbox.archive_filter_process(s);
  2234.                 }
  2235.             }
  2236.         );
  2237.     },
  2238.  
  2239.     shouts_fade: function(ids)
  2240.     {
  2241.         if ( ids != null && ids.length > 0 )
  2242.         {
  2243.             /** Update live total shouts count **/
  2244.             ipb.shoutbox.updateTotalShouts( ipb.shoutbox.total_shouts + ids.length );
  2245.  
  2246.             /* Fade disabled, stop here u_u */
  2247.             if ( !ipb.shoutbox.enable_fade )
  2248.             {
  2249.                 return false;
  2250.             }
  2251.  
  2252.             // Fade our new shouts
  2253.             ids.each(
  2254.                 function( ID )
  2255.                 {
  2256.                     $A( $( 'shout-row-' + ID ).childElements() ).each(
  2257.                         function( td )
  2258.                         {
  2259.                             new Effect.Highlight( td, { startcolor: '#ffff99' } );
  2260.                         }
  2261.                     );
  2262.                 }
  2263.             );
  2264.         }
  2265.     },
  2266.  
  2267.     resizeGlobalShouts: function()
  2268.     {
  2269.         var sso = $('shoutbox-shouts');
  2270.         var srh = $('shouts-global-resizer');
  2271.  
  2272.         if ( !ipb.shoutbox.myMemberID )
  2273.         {
  2274.             srh.style.cursor = 'default';
  2275.             return false;
  2276.         }
  2277.  
  2278.         Resize.init(srh, sso, true, false);
  2279.  
  2280.         sso.min_height = 100;
  2281.         sso.Resizing   = function()
  2282.         {
  2283.             ipb.shoutbox.shoutsScrollThem();
  2284.         }
  2285.  
  2286.         sso.Resize_end = function(data)
  2287.         {
  2288.             ipb.shoutbox.myPrefsGlobalHeightSave( parseInt(data.h) );
  2289.         }
  2290.     },
  2291.  
  2292.     keypress_handler: function(e)
  2293.     {
  2294.         if (document.all)
  2295.         {
  2296.             if (e && window.event && e._skip != true)
  2297.             {
  2298.                 e = window.event;
  2299.             }
  2300.         }
  2301.  
  2302.         if (!e || e == null || typeof(e) == 'undefined')
  2303.         {
  2304.             return false;
  2305.         }
  2306.  
  2307.         ipb.shoutbox.updateLastActivity();
  2308.  
  2309.         var ret = true;
  2310.         if (document.layers)
  2311.         {
  2312.             var alt   = (e.modifiers&Event.ALT_MASK) ? true : false;
  2313.             var ctrl  = (e.modifiers&Event.CONTROL_MASK) ? true : false;
  2314.             var shift = (e.modifiers&Event.SHIFT_MASK) ? true : false;
  2315.             var key   = (e.data.keyCode) ? e.data.keyCode : e.which;
  2316.         }
  2317.         else
  2318.         {
  2319.             var alt   = e.altKey;
  2320.             var ctrl  = e.ctrlKey;
  2321.             var shift = e.shiftKey;
  2322.  
  2323.             if (document.all)
  2324.             {
  2325.                 var key = (e.data.keyCode) ? e.data.keyCode : e.keyCode;
  2326.             }
  2327.             else
  2328.             {
  2329.                 if (e.keyCode > 0)
  2330.                 {
  2331.                     var key = e.keyCode;
  2332.                 }
  2333.                 else if (e.which > 0)
  2334.                 {
  2335.                     var key = e.which;
  2336.                 }
  2337.                 else
  2338.                 {
  2339.                     var key = e.data.keyCode;
  2340.                 }
  2341.             }
  2342.         }
  2343.  
  2344.         var obj = (e.srcElement) ? e.srcElement : (e.editor) ? 'ckeditor' : e.target;
  2345.  
  2346.         if ( obj != 'ckeditor' )
  2347.         {
  2348.             if ( Prototype.Browser.WebKit || Prototype.Browser.Gecko )
  2349.             {
  2350.                 if (obj.nodeType == 3 && e.target.parentNode.nodeType == 1)
  2351.                 {
  2352.                     obj = e.target.parentNode;
  2353.                 }
  2354.             }
  2355.  
  2356.             if (typeof(obj.id) == 'undefined')
  2357.             {
  2358.                 obj.id = '';
  2359.             }
  2360.         }
  2361.  
  2362.         if ( ipb.shoutbox.my_prefs['enter_key_shout'] == 1 && (obj.id == 'shoutbox-global-shout' || obj.name == "shout_msg" || obj == 'ckeditor') && !shift && !alt && !ctrl && key == 13)
  2363.         {
  2364.             ipb.shoutbox.submitShout();
  2365.  
  2366.             Event.stop(e);
  2367.             return false;
  2368.         }
  2369.         else if ( (alt && key == 13) || (ctrl && key == 13) )
  2370.         {
  2371.             ipb.shoutbox.submitShout();
  2372.  
  2373.             Event.stop(e);
  2374.             return false;
  2375.         }
  2376.  
  2377.         return true;
  2378.     },
  2379.  
  2380.     insertAtCursor: function(text)
  2381.     {
  2382.         var editor = $('shoutbox-global-shout');
  2383.  
  2384.         editor.focus();
  2385.  
  2386.         if ( !Object.isUndefined( editor.selectionStart ) )
  2387.         {
  2388.             var open = editor.selectionStart + 0;
  2389.             var st   = editor.scrollTop;
  2390.             var end  = open + text.length;
  2391.  
  2392.             /* Opera doesn't count the linebreaks properly for some reason */
  2393.             if( Prototype.Browser.Opera )
  2394.             {
  2395.                 var opera_len = text.match( /\n/g );
  2396.  
  2397.                 try
  2398.                 {
  2399.                     end += parseInt(opera_len.length);
  2400.                 }
  2401.                 catch(e)
  2402.                 {
  2403.                     Debug.write( "Error with Opera => " + e );
  2404.                 }
  2405.             }
  2406.  
  2407.             editor.value = editor.value.substr(0, editor.selectionStart) + text + editor.value.substr(editor.selectionEnd);
  2408.  
  2409.             editor.setSelectionRange( end, end );
  2410.         }
  2411.         else if ( document.selection && document.selection.createRange )
  2412.         {
  2413.             var sel  = document.selection.createRange();
  2414.             sel.text = text.replace(/\r?\n/g, '\r\n');
  2415.             sel.select();
  2416.         }
  2417.         else
  2418.         {
  2419.             editor.value += text;
  2420.         }
  2421.     },
  2422.  
  2423.     truebody: function()
  2424.     {
  2425.         return (document.compatMode && document.compatMode != 'BackCompat') ? document.documentElement : document.body;
  2426.     },
  2427.  
  2428.     get_offset_left: function(o, p)
  2429.     {
  2430.         var l = 0;
  2431.         if (o.offsetParent)
  2432.         {
  2433.             while (o.offsetParent)
  2434.             {
  2435.                 if (p != null && o == p)
  2436.                 {
  2437.                     break;
  2438.                 }
  2439.  
  2440.                 l += o.offsetLeft;
  2441.                 o = o.offsetParent;
  2442.             }
  2443.         }
  2444.         else if (o.x)
  2445.         {
  2446.             l += o.x;
  2447.         }
  2448.  
  2449.         return l;
  2450.     },
  2451.  
  2452.     get_offset_top: function(o, p)
  2453.     {
  2454.         var t = 0;
  2455.         if (o.offsetParent)
  2456.         {
  2457.             while (o.offsetParent)
  2458.             {
  2459.                 if (p != null && o == p)
  2460.                 {
  2461.                     break;
  2462.                 }
  2463.  
  2464.                 t += o.offsetTop;
  2465.                 o = o.offsetParent;
  2466.             }
  2467.         }
  2468.         else if (o.y)
  2469.         {
  2470.             t += o.y;
  2471.         }
  2472.  
  2473.         return t;
  2474.     },
  2475.  
  2476.     get_page_size: function()
  2477.     {
  2478.         var x;
  2479.         var y;
  2480.         var ww;
  2481.         var wh;
  2482.         var pw;
  2483.         var ph;
  2484.  
  2485.         if (window.innerHeight && window.scrollMaxY)
  2486.         {
  2487.             x = document.body.scrollWidth;
  2488.             y = window.innerHeight+window.scrollMaxY;
  2489.         }
  2490.         else if (document.body.scrollHeight > document.body.offsetHeight)
  2491.         {
  2492.             x = document.body.scrollWidth;
  2493.             y = document.body.scrollHeight;
  2494.         }
  2495.         else
  2496.         {
  2497.             x = document.body.offsetWidth;
  2498.             y = document.body.offsetHeight;
  2499.         }
  2500.  
  2501.         if (self.innerHeight)
  2502.         {
  2503.             ww = self.innerWidth;
  2504.             wh = self.innerHeight;
  2505.         }
  2506.         else if (document.documentElement && document.documentElement.clientHeight)
  2507.         {
  2508.             ww = document.documentElement.clientWidth;
  2509.             wh = document.documentElement.clientHeight;
  2510.         }
  2511.         else if (document.body)
  2512.         {
  2513.             ww = document.body.clientWidth;
  2514.             wh = document.body.clientHeight;
  2515.         }
  2516.  
  2517.         pw = x;
  2518.         ph = y;
  2519.  
  2520.         if (y < wh)
  2521.         {
  2522.             ph = wh;
  2523.         }
  2524.  
  2525.         if (x < ww)
  2526.         {
  2527.             pw = ww;
  2528.         }
  2529.  
  2530.         return new Array(pw, ph, ww, wh);
  2531.     },
  2532.  
  2533.     checkForErrors: function( text, status )
  2534.     {
  2535.         if ( text.substring(0, 6) == 'error-' )
  2536.         {
  2537.             if ( status != null && status != '' )
  2538.             {
  2539.                 ipb.shoutbox.popupUpdateStatus( status );
  2540.             }
  2541.  
  2542.             ipb.shoutbox.produceError( text.substring(6) );
  2543.  
  2544.             return true;
  2545.         }
  2546.         else
  2547.         {
  2548.             return false;
  2549.         }
  2550.     },
  2551.  
  2552.     setupPopup: function(popup)
  2553.     {
  2554.         switch(popup)
  2555.         {
  2556.             case 'preferences':
  2557.                 ipb.shoutbox.in_prefs = true;
  2558.  
  2559.                 ipb.shoutbox.popupUpdateStatus('my_prefs_loaded');
  2560.  
  2561.                 /* Setup onclick for buttons */
  2562.                 $('myprefs_save').observe('click', ipb.shoutbox.myPrefsSave );
  2563.                 $('myprefs_restore').observe('click', ipb.shoutbox.myPrefsRestore );
  2564.  
  2565.                 /* Show it */
  2566.                 ipb.shoutbox.preferences.show();
  2567.                 break;
  2568.             case 'moderator':
  2569.                 ipb.shoutbox.in_mod = true;
  2570.  
  2571.                 /* Setup onclick for mod menu */
  2572.                 if ( $('edit_shout') )
  2573.                 {
  2574.                     $('edit_shout').observe('click', ipb.shoutbox.modOptsDo.bindAsEventListener(this) );
  2575.                 }
  2576.                 if ( $('editHistory_shout') )
  2577.                 {
  2578.                     $('editHistory_shout').observe('click', ipb.shoutbox.modOptsDo.bindAsEventListener(this) );
  2579.                 }
  2580.                 if ( $('delete_shout') )
  2581.                 {
  2582.                     $('delete_shout').observe('click', ipb.shoutbox.modOptsDo.bindAsEventListener(this) );
  2583.                 }
  2584.                 if ( $('deleteAll_shout') )
  2585.                 {
  2586.                     $('deleteAll_shout').observe('click', ipb.shoutbox.modOptsDo.bindAsEventListener(this) );
  2587.                 }
  2588.                 if ( $('ban_shout') )
  2589.                 {
  2590.                     $('ban_shout').observe('click', ipb.shoutbox.modOptsDo.bindAsEventListener(this) );
  2591.                 }
  2592.                 if ( $('ban24_shout') )
  2593.                 {
  2594.                     $('ban24_shout').observe('click', ipb.shoutbox.modOptsDo.bindAsEventListener(this) );
  2595.                 }
  2596.                 if ( $('ban48_shout') )
  2597.                 {
  2598.                     $('ban48_shout').observe('click', ipb.shoutbox.modOptsDo.bindAsEventListener(this) );
  2599.                 }
  2600.                 if ( $('unban_shout') )
  2601.                 {
  2602.                     $('unban_shout').observe('click', ipb.shoutbox.modOptsDo.bindAsEventListener(this) );
  2603.                 }
  2604.                 if ( $('removeMod_shout') )
  2605.                 {
  2606.                     $('removeMod_shout').observe('click', ipb.shoutbox.modOptsDo.bindAsEventListener(this) );
  2607.                 }
  2608.  
  2609.                 /* Show it */
  2610.                 ipb.shoutbox.modOpts.show();
  2611.                 break;
  2612.             case 'archive':
  2613.                 $('load-shoutbox-archive').stopObserving();
  2614.                 $('load-shoutbox-archive').observe( 'click', ipb.shoutbox.displayArchive );
  2615.  
  2616.                 ipb.shoutbox.in_archive = true;
  2617.  
  2618.                 ipb.shoutbox.popupUpdateStatus('sb_archive_loaded');
  2619.  
  2620.                 /* Show it */
  2621.                 ipb.shoutbox.archiveArea.show();
  2622.                 break;
  2623.             // Added in 1.1.1
  2624.             case 'editShout':
  2625.                 ipb.shoutbox.in_mod = true;
  2626.  
  2627.                 /* Observe buttons >_< */
  2628.                 $('mod_edit_shout_confirm').observe('click', ipb.shoutbox.mod_opts_do_edit_shout );
  2629.                 $('mod_edit_shout_clear').observe('click', ipb.shoutbox.modOptsEditClear );
  2630.                 $('mod_edit_shout_cancel').observe('click',
  2631.                     function()
  2632.                     {
  2633.                         ipb.shoutbox.closePopup('editShout');
  2634.                     }
  2635.                 );
  2636.                 /* Show it */
  2637.                 ipb.shoutbox.editShoutPopup.show();
  2638.                 break;
  2639.             default:
  2640.                 Debug.write("setupPopup called without a proper popup defined: "+popup);
  2641.                 break;
  2642.         }
  2643.     },
  2644.  
  2645.     closePopup: function(popup)
  2646.     {
  2647.         switch(popup)
  2648.         {
  2649.             case 'preferences':
  2650.                 ipb.shoutbox.preferences.hide();
  2651.  
  2652.                 ipb.shoutbox.in_prefs = false;
  2653.                 break;
  2654.             case 'moderator':
  2655.                 ipb.shoutbox.modOptsEditReset();
  2656.                 ipb.shoutbox.modOpts.hide();
  2657.  
  2658.                 ipb.shoutbox.in_mod = false;
  2659.                 ipb.shoutbox.mod_shout_id = 0;
  2660.                 ipb.shoutbox.mod_member_id = 0;
  2661.                 ipb.shoutbox.mod_in_action = false;
  2662.                 break;
  2663.             case 'archive':
  2664.                 ipb.shoutbox.archiveArea.hide();
  2665.  
  2666.                 ipb.shoutbox.in_archive = false;
  2667.                 ipb.shoutbox.archive_filtering = false;
  2668.                 break;
  2669.             // Added in 1.1.1
  2670.             case 'editShout':
  2671.                 ipb.shoutbox.editShoutPopup.hide();
  2672.  
  2673.                 ipb.shoutbox.in_mod = false;
  2674.                 ipb.shoutbox.mod_shout_id = 0;
  2675.                 ipb.shoutbox.mod_member_id = 0;
  2676.                 ipb.shoutbox.mod_in_action = false;
  2677.  
  2678.                 /* Empty the popup to avoid duplicate IDs in the main shoutbox  - 1.1.1 */
  2679.                 $('editShout_inner').update('');
  2680.                 break;
  2681.             default:
  2682.                 Debug.write("closePopup called without a proper popup defined: "+popup);
  2683.                 break;
  2684.         }
  2685.  
  2686.         /* We got inactive while a popup was open! =O */
  2687.         if ( ipb.shoutbox.inactiveWhenPopup )
  2688.         {
  2689.             ipb.shoutbox.inactiveWhenPopup = false;
  2690.  
  2691.             setTimeout("ipb.shoutbox.displayInactivePrompt()", 600);
  2692.         }
  2693.     },
  2694.  
  2695.     popupModeratorReset: function()
  2696.     {
  2697.         /* Update status/content */
  2698.         ipb.shoutbox.popupUpdateStatus('mod_opts_start_status');
  2699.         ipb.shoutbox.popupUpdateContent('mod_opts_start_content');
  2700.  
  2701.         /* Reset our mod vars */
  2702.         ipb.shoutbox.mod_in_action = false;
  2703.         ipb.shoutbox.mod_editor_id  = '';
  2704.         ipb.shoutbox.mod_editor_rte = 0;
  2705.     },
  2706.  
  2707.     updateLastActivity: function()
  2708.     {
  2709.         ipb.shoutbox.last_active = ipb.shoutbox.getTimestamp();
  2710.     },
  2711.  
  2712.     updateTotalShouts: function( newCount )
  2713.     {
  2714.         ipb.shoutbox.total_shouts = parseInt(newCount);
  2715.  
  2716.         if ( !ipb.shoutbox.global_on )
  2717.         {
  2718.             $('shoutbox-total-shouts').update( ipb.shoutbox.total_shouts );
  2719.  
  2720.             if ( ipb.shoutbox.enable_fade )
  2721.             {
  2722.                 new Effect.Highlight( $('shoutbox-total-shouts'), { startcolor: '#ffff99' } );
  2723.             }
  2724.         }
  2725.     },
  2726.  
  2727.     /**
  2728.      * Setup the toggle hide/show for the shoutbox
  2729.      */
  2730.     setupToggle: function()
  2731.     {
  2732.         if ( !ipb.shoutbox.global_on || !$('category_shoutbox') )
  2733.         {
  2734.             return false;
  2735.         }
  2736.  
  2737.         $('category_shoutbox').select('.toggle')[0].stopObserving();
  2738.         $('category_shoutbox').select('.toggle')[0].observe( 'click', ipb.shoutbox.toggleShoutbox );
  2739.  
  2740.         /* ipb.board not loaded? */
  2741.         if ( Object.isUndefined(ipb.board) )
  2742.         {
  2743.             cookie = ipb.Cookie.get('toggleCats');
  2744.  
  2745.             if( cookie )
  2746.             {
  2747.                 var cookies = cookie.split( ',' );
  2748.  
  2749.                 //-------------------------
  2750.                 // Little fun for you...
  2751.                 //-------------------------
  2752.                 for( var abcdefg=0; abcdefg < cookies.length; abcdefg++ )
  2753.                 {
  2754.                     if( cookies[ abcdefg ] == 'shoutbox' )
  2755.                     {
  2756.                         var wrapper = $('category_shoutbox').down('.table_wrap');
  2757.  
  2758.                         wrapper.hide();
  2759.                         $('category_shoutbox').addClassName('collapsed');
  2760.  
  2761.                         // Block there, we found our shoutbox :D
  2762.                         break;
  2763.                     }
  2764.                 }
  2765.             }
  2766.         }
  2767.     },
  2768.  
  2769.     /**
  2770.      * Show/hide the shoutbox
  2771.      *
  2772.      * @var     {event}     e   The event
  2773.      */
  2774.     toggleShoutbox: function(e)
  2775.     {
  2776.         if ( !ipb.shoutbox.global_on )
  2777.         {
  2778.             return false;
  2779.         }
  2780.  
  2781.         /* Code taked from the function ipb.board.toggleCat(e); because the board file is not loaded always */
  2782.         if( ipb.shoutbox.animatingGlobal || (!Object.isUndefined(ipb.board) && ipb.board.animating) ){ return false; }
  2783.  
  2784.         /* Init some vars */
  2785.         var click   = Event.element(e),
  2786.             remove  = $A(),
  2787.             wrapper = $( click ).up('.category_block').down('.table_wrap');
  2788.  
  2789.         $( wrapper ).identify(); // IE8 fix
  2790.  
  2791.         ipb.shoutbox.animatingGlobal = true;
  2792.  
  2793.         // Get cookie
  2794.         cookie = ipb.Cookie.get('toggleCats');
  2795.         if( cookie == null ){
  2796.             cookie = $A();
  2797.         } else {
  2798.             cookie = cookie.split(',');
  2799.         }
  2800.  
  2801.         Effect.toggle( wrapper, 'blind', {duration: 0.4, afterFinish: function(){ ipb.shoutbox.animatingGlobal = false; } } );
  2802.  
  2803.         if( $('category_shoutbox').hasClassName('collapsed') )
  2804.         {
  2805.             $('category_shoutbox').removeClassName('collapsed');
  2806.             remove.push('shoutbox');
  2807.  
  2808.             // Not inactive? load new shouts!
  2809.             if ( !ipb.shoutbox._inactive )
  2810.             {
  2811.                 ipb.shoutbox.reloadShouts(true);
  2812.             }
  2813.         }
  2814.         else
  2815.         {
  2816.             // Remove Shouts timer
  2817.             clearTimeout(ipb.shoutbox.timeoutShouts);
  2818.  
  2819.             new Effect.Morph( $('category_shoutbox'), {style: 'collapsed', duration: 0.4, afterFinish: function(){
  2820.                 $('category_shoutbox').addClassName('collapsed');
  2821.  
  2822.                 ipb.shoutbox.animatingGlobal = false;
  2823.             } });
  2824.             cookie.push('shoutbox');
  2825.         }
  2826.  
  2827.         cookie = "," + cookie.uniq().without( remove ).join(',') + ",";
  2828.         ipb.Cookie.set('toggleCats', cookie, 1);
  2829.  
  2830.         Event.stop( e );
  2831.     },
  2832.  
  2833.     /**
  2834.      * Show hidden shouts from ignored users
  2835.      *
  2836.      * @var     int     id      Shout ID
  2837.      */
  2838.     showHiddenShout: function(id)
  2839.     {
  2840.         if( $('hidden_shout_' + id ) )
  2841.         {
  2842.             elem = $('hidden_shout_' + id );
  2843.             new Effect.Parallel( [
  2844.                 new Effect.BlindDown( elem ),
  2845.                 new Effect.Appear( elem )
  2846.             ], { duration: 0.5 } );
  2847.         }
  2848.  
  2849.         if( $('unhide_shout_' + id ) )
  2850.         {
  2851.             $('unhide_shout_' + id ).hide();
  2852.         }
  2853.     },
  2854.  
  2855.     submitShout: function()
  2856.     {
  2857.         if ( ipb.shoutbox.submittingShout )
  2858.         {
  2859.             ipb.shoutbox.produceError('already_submitting');
  2860.             return false;
  2861.         }
  2862.  
  2863.         /**
  2864.          * Beta 3
  2865.          * Can only view shoutbox?
  2866.          */
  2867.         if ( !ipb.shoutbox.can_use )
  2868.         {
  2869.             return false;
  2870.         }
  2871.  
  2872.         var globalOn    = ( ipb.shoutbox.global_on ) ? '&global=1' : '',
  2873.             postedShout = ipb.shoutbox.getShout( false );
  2874.  
  2875.         if ( postedShout == '' )
  2876.         {
  2877.             ipb.shoutbox.produceError('blank_shout');
  2878.             return false;
  2879.         }
  2880.  
  2881.         if ( postedShout.length * 1024 > ipb.shoutbox.max_length )
  2882.         {
  2883.             ipb.shoutbox.produceError('shout_too_big');
  2884.             return false;
  2885.         }
  2886.  
  2887.         /**
  2888.          * Beta 3
  2889.          * Re-added flood check also JS side
  2890.          */
  2891.         if ( ipb.shoutbox.flood_limit && ipb.shoutbox.bypass_flood != 1 && ipb.shoutbox.my_last_shout )
  2892.         {
  2893.             var flood_check = ipb.shoutbox.getTimestamp() - ipb.shoutbox.my_last_shout;
  2894.  
  2895.             if (flood_check < ipb.shoutbox.flood_limit)
  2896.             {
  2897.                 ipb.shoutbox.produceError( ipb.shoutbox.errors['flooding'].replace( '{#EXTRA#}', ( ipb.shoutbox.flood_limit - flood_check ) ) );
  2898.                 return false;
  2899.             }
  2900.         }
  2901.  
  2902.         var c = ipb.shoutbox.checkForCommands();
  2903.  
  2904.         if ( c != null && c == 'doshout' )
  2905.         {
  2906.             /**
  2907.              * 1.1.0 Alpha
  2908.              *
  2909.              * Clear timeout to avoid loading twice the same shouts
  2910.              * And also setup a boolean value to stop new attempts
  2911.              */
  2912.             clearTimeout(ipb.shoutbox.timeoutShouts);
  2913.             ipb.shoutbox.submittingShout = true;
  2914.  
  2915.             /* /me code */
  2916.             if ( ipb.shoutbox.can_me_tag )
  2917.             {
  2918.                 postedShout = postedShout.replace( '/me ', ipb.shoutbox.member_name + ' ' );
  2919.             }
  2920.  
  2921.             // Take care of the other things
  2922.             ipb.shoutbox.clearShout();
  2923.             ipb.shoutbox.updateLastActivity();
  2924.             ipb.shoutbox.my_last_shout = ipb.shoutbox.last_active;
  2925.  
  2926.             /** Finally ajax it! =D **/
  2927.             new Ajax.Request( ipb.shoutbox.baseUrl + 'type=submit&lastid=' + ipb.shoutbox.last_shout_id + globalOn,
  2928.                 {
  2929.                     method: 'post',
  2930.                     encoding: ipb.vars['charset'],
  2931.                     parameters: {
  2932.                         shout:    postedShout.encodeParam()
  2933.                     },
  2934.                     onSuccess: function(s)
  2935.                     {
  2936.                         // Beta 3: process inactive prompt if we are submitting a new shout
  2937.                         if ( ipb.shoutbox.global_on && ipb.shoutbox._inactive )
  2938.                         {
  2939.                             ipb.shoutbox.processInactivePrompt();
  2940.                         }
  2941.  
  2942.                         if ( ipb.shoutbox.checkForErrors(s.responseText) )
  2943.                         {
  2944.                             ipb.shoutbox.restoreShout();
  2945.                             ipb.shoutbox.submittingShout = false;
  2946.                             return false;
  2947.                         }
  2948.  
  2949.                         /**
  2950.                          * 1.1.0 RC 1
  2951.                          * Everything is okay, reset our tempShout
  2952.                          */
  2953.                         ipb.shoutbox.tempShout = null;
  2954.  
  2955.                         /**
  2956.                          * 1.0.0 Final
  2957.                          * Fix no shouts message
  2958.                          */
  2959.                         if ( ipb.shoutbox.total_shouts <= 0 )
  2960.                         {
  2961.                             $('shoutbox-no-shouts-message').hide();
  2962.                         }
  2963.  
  2964.                         var shoutsDiv = $('shoutbox-shouts-table').down('tbody');
  2965.  
  2966.                         if ( ipb.shoutbox.shout_order == 'asc' )
  2967.                         {
  2968.                             shoutsDiv.update( shoutsDiv.innerHTML + s.responseText );
  2969.                         }
  2970.                         else
  2971.                         {
  2972.                             if ( ipb.shoutbox.total_shouts > 0 )
  2973.                             {
  2974.                                 shoutsDiv.down('tr').insert( { before: s.responseText } );
  2975.                             }
  2976.                             else
  2977.                             {
  2978.                                 shoutsDiv.update( s.responseText );
  2979.                             }
  2980.                         }
  2981.  
  2982.                         // Fix shout classes
  2983.                         ipb.shoutbox.rewriteShoutClasses();
  2984.  
  2985.                         // Remove the block
  2986.                         ipb.shoutbox.submittingShout = false;
  2987.  
  2988.                         // Setup latest ID
  2989.                         ipb.shoutbox.shoutsGetLastID();
  2990.  
  2991.                         if ( ipb.shoutbox.can_use && ipb.shoutbox.my_prefs['display_refresh_button'] == 1 )
  2992.                         {
  2993.                             $('shoutbox-refresh-button').show();
  2994.                         }
  2995.  
  2996.                         /**
  2997.                          * Beta 2
  2998.                          * Restart timer
  2999.                          */
  3000.                         ipb.shoutbox.timeoutShouts = setTimeout("ipb.shoutbox.reloadShouts(true)", ipb.shoutbox.shouts_refresh);
  3001.  
  3002.                         ipb.shoutbox.shoutsScrollThem();
  3003.  
  3004.                         if ( !globalOn && ipb.textEditor.getEditor().CKEditor )
  3005.                         {
  3006.                             ipb.textEditor.getEditor().CKEditor.focus();
  3007.                         }
  3008.                     }
  3009.                 }
  3010.             );
  3011.         }
  3012.     },
  3013.  
  3014.     reloadShouts: function(doLoad)
  3015.     {
  3016.         /**
  3017.          * Beta 2
  3018.          * Fix timeout with clearTimeout
  3019.          */
  3020.         clearTimeout( ipb.shoutbox.timeoutShouts );
  3021.  
  3022.         // If for any odd chance we get there while submitting block it!
  3023.         if ( ipb.shoutbox.submittingShout )
  3024.         {
  3025.             return false;
  3026.         }
  3027.  
  3028.         doLoad = (doLoad == true) ? true : false;
  3029.  
  3030.         if ( doLoad )
  3031.         {
  3032.             var globalOn = ( ipb.shoutbox.global_on ) ? '&global=1' : '';
  3033.  
  3034.             // Setup latest ID
  3035.             ipb.shoutbox.shoutsGetLastID();
  3036.  
  3037.             // Hide refresh button?
  3038.             if ( ipb.shoutbox.hide_refresh )
  3039.             {
  3040.                 $('shoutbox-refresh-button').hide();
  3041.             }
  3042.  
  3043.             new Ajax.Request( ipb.shoutbox.baseUrl + 'type=getShouts&lastid=' + ipb.shoutbox.last_shout_id + globalOn,
  3044.                 {
  3045.                     method: 'get',
  3046.                     encoding: ipb.vars['charset'],
  3047.                     hideLoader: ipb.shoutbox.img_disable ? true : false,
  3048.                     onSuccess: function(s)
  3049.                     {
  3050.                         ipb.shoutbox.updateShouts(s.responseText);
  3051.                         return true;
  3052.                     }
  3053.                 }
  3054.             );
  3055.         }
  3056.         else if ( ipb.shoutbox.isInactive() )
  3057.         {
  3058.             Debug.write("reloadShouts: shoutbox inactive, timer is activated again clicking I'm back now");
  3059.             return false;
  3060.         }
  3061.  
  3062.         /**
  3063.          * Beta 2
  3064.          * Set again timeout if we are not inactive :O
  3065.          */
  3066.         ipb.shoutbox.timeoutShouts = setTimeout("ipb.shoutbox.reloadShouts(true)", ipb.shoutbox.shouts_refresh);
  3067.     },
  3068.  
  3069.     updateShouts: function(response)
  3070.     {
  3071.         /* Show again the button! */
  3072.         if ( ipb.shoutbox.can_use && ipb.shoutbox.my_prefs['display_refresh_button'] == 1 )
  3073.         {
  3074.             $('shoutbox-refresh-button').show();
  3075.         }
  3076.  
  3077.         /** And reset timer **/
  3078.         ipb.shoutbox.reloadShouts();
  3079.  
  3080.         // Finally update shouts
  3081.         // Leave the code above there or it causes a bug | Terabyte
  3082.         if ( response != '' && response != '<!--nothing-->' && response != '0' )
  3083.         {
  3084.             if ( ipb.shoutbox.checkForErrors(response) )
  3085.             {
  3086.                 return false;
  3087.             }
  3088.  
  3089.             /**
  3090.              * 1.0.0 Final
  3091.              * Fix no shouts message
  3092.              */
  3093.             if ( ipb.shoutbox.total_shouts <= 0 )
  3094.             {
  3095.                 $('shoutbox-no-shouts-message').hide();
  3096.             }
  3097.  
  3098.             var shoutsDiv = $('shoutbox-shouts-table').down('tbody');
  3099.  
  3100.             if ( ipb.shoutbox.shout_order == 'asc' )
  3101.             {
  3102.                 shoutsDiv.update( shoutsDiv.innerHTML + response );
  3103.             }
  3104.             else
  3105.             {
  3106.                 if ( ipb.shoutbox.total_shouts > 0 )
  3107.                 {
  3108.                     shoutsDiv.down('tr').insert( { before: response } );
  3109.                 }
  3110.                 else
  3111.                 {
  3112.                     shoutsDiv.update( response );
  3113.                 }
  3114.             }
  3115.  
  3116.             // Fix shout classes
  3117.             ipb.shoutbox.rewriteShoutClasses(false);
  3118.  
  3119.             // Setup latest ID
  3120.             ipb.shoutbox.shoutsGetLastID();
  3121.  
  3122.             ipb.shoutbox.shoutsScrollThem();
  3123.         }
  3124.     },
  3125.  
  3126.     reloadMembers: function(doLoad)
  3127.     {
  3128.         /**
  3129.          * 1.1.0 Alpha
  3130.          * Fix timeout with clearTimeout
  3131.          */
  3132.         clearTimeout( ipb.shoutbox.timeoutMembers );
  3133.  
  3134.         doLoad = (doLoad == true) ? true : false;
  3135.  
  3136.         if ( doLoad )
  3137.         {
  3138.             new Ajax.Request( ipb.shoutbox.baseUrl + 'type=getMembers',
  3139.                 {
  3140.                     method: 'get',
  3141.                     evalJSON: 'force',
  3142.                     encoding: ipb.vars['charset'],
  3143.                     hideLoader: ipb.shoutbox.img_disable ? true : false,
  3144.                     onSuccess: function(d)
  3145.                     {
  3146.                         if( Object.isUndefined( d.responseJSON ) )
  3147.                         {
  3148.                             ipb.shoutbox.produceError('loading_members_viewing');
  3149.                         }
  3150.                         else
  3151.                         {
  3152.                             /* Update stats! =D */
  3153.                             $('shoutbox-active-total').update( d.responseJSON['TOTAL'] );
  3154.                             $('shoutbox-active-member').update( d.responseJSON['MEMBERS'] );
  3155.                             $('shoutbox-active-guests').update( d.responseJSON['GUESTS'] );
  3156.                             $('shoutbox-active-anon').update( d.responseJSON['ANON'] );
  3157.  
  3158.                             /* Sort out names */
  3159.                             if ( d.responseJSON['NAMES'] == '' )
  3160.                             {
  3161.                                 $('shoutbox-active-names').hide();
  3162.                             }
  3163.                             else
  3164.                             {
  3165.                                 $('shoutbox-active-names').update( d.responseJSON['NAMES'].join(', ') ).show();
  3166.                             }
  3167.  
  3168.                             /* Highligh the names! */
  3169.                             if ( ipb.shoutbox.enable_fade )
  3170.                             {
  3171.                                 new Effect.Highlight( $('shoutbox-active-names'),
  3172.                                     {
  3173.                                         startcolor: '#ffff99'
  3174.                                     }
  3175.                                 );
  3176.                             }
  3177.                         }
  3178.  
  3179.                         ipb.shoutbox.reloadMembers();
  3180.                         return true;
  3181.                     }
  3182.                 }
  3183.             );
  3184.         }
  3185.         else if ( ipb.shoutbox.isInactive() )
  3186.         {
  3187.             Debug.write("reloadMembers: shoutbox inactive, timer is activated again clicking I'm back now");
  3188.             return false;
  3189.         }
  3190.  
  3191.         /**
  3192.          * 1.1.0 Alpha
  3193.          * Set again timeout if we are not inactive :O
  3194.          */
  3195.         ipb.shoutbox.timeoutMembers = setTimeout("ipb.shoutbox.reloadMembers(true)", ipb.shoutbox.members_refresh);
  3196.     },
  3197.  
  3198.     myPrefsLoad: function()
  3199.     {
  3200.         if ( ipb.shoutbox.myMemberID <= 0 )
  3201.         {
  3202.             return false;
  3203.         }
  3204.  
  3205.         if ( ipb.shoutbox.blur )
  3206.         {
  3207.             ipb.shoutbox.blur();
  3208.         }
  3209.  
  3210.         if ( ipb.shoutbox.global_on )
  3211.         {
  3212.             ipb.shoutbox.setActionAndReload('myprefs');
  3213.             return false;
  3214.         }
  3215.  
  3216.         ipb.shoutbox.updateLastActivity();
  3217.  
  3218.         /* Popup already exist? */
  3219.         if ( $('myPrefs_popup') )
  3220.         {
  3221.             ipb.shoutbox.setupPopup('preferences');
  3222.             return true;
  3223.         }
  3224.  
  3225.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=prefs&action=load',
  3226.             {
  3227.                 method: 'get',
  3228.                 encoding: ipb.vars['charset'],
  3229.                 onSuccess: function(s)
  3230.                 {
  3231.                     if ( ipb.shoutbox.checkForErrors(s.responseText) )
  3232.                     {
  3233.                         return false;
  3234.                     }
  3235.  
  3236.                     ipb.shoutbox.preferences = new ipb.Popup( 'myPrefs',
  3237.                                     {
  3238.                                         type: 'pane',
  3239.                                         modal: true,
  3240.                                         w: '550px',
  3241.                                         h: 'auto',
  3242.                                         initial: s.responseText,
  3243.                                         hideAtStart: true,
  3244.                                         close: '.cancel'
  3245.                                     }
  3246.                                 );
  3247.  
  3248.                     /* Setup close button */
  3249.                     $('myPrefs_close').stopObserving();
  3250.                     $('myPrefs_close').observe( 'click',
  3251.                         function()
  3252.                         {
  3253.                             ipb.shoutbox.closePopup('preferences');
  3254.                         }
  3255.                     );
  3256.  
  3257.                     ipb.shoutbox.setupPopup('preferences');
  3258.                 }
  3259.             }
  3260.  
  3261.         );
  3262.  
  3263.         return false;
  3264.     },
  3265.  
  3266.     myPrefsSave: function()
  3267.     {
  3268.         if ( !ipb.shoutbox.myMemberID || ipb.shoutbox.global_on )
  3269.         {
  3270.             return false;
  3271.         }
  3272.  
  3273.         ipb.shoutbox.updateLastActivity();
  3274.  
  3275.         // Update our prefs on-fly
  3276.         ipb.shoutbox.my_prefs['global_display']         = ($('my_prefs_gsb_y').checked) ? 1 : 0;
  3277.         ipb.shoutbox.my_prefs['enter_key_shout']        = ($('my_prefs_ets_y').checked) ? 1 : 0;
  3278.         ipb.shoutbox.my_prefs['enable_quick_commands']  = ($('my_prefs_eqc_y').checked) ? 1 : 0;
  3279.         ipb.shoutbox.my_prefs['display_refresh_button'] = ($('my_prefs_drb_y').checked) ? 1 : 0;
  3280.         ipb.shoutbox.my_prefs['disable_sound']      = ($('my_prefs_snd_y').checked) ? 1 : 0;
  3281.         ipb.shoutbox.my_prefs['shoutbox_display_order'] = ($('my_prefs_sdo').value);
  3282.  
  3283.         // Setup status
  3284.         ipb.shoutbox.popupUpdateStatus('saving_prefs');
  3285.  
  3286.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=prefs&action=save',
  3287.             {
  3288.                 method: 'post',
  3289.                 encoding: ipb.vars['charset'],
  3290.                 parameters: {
  3291.                     prefs_gsb : ipb.shoutbox.my_prefs['global_display'],
  3292.                     prefs_ets : ipb.shoutbox.my_prefs['enter_key_shout'],
  3293.                     prefs_eqc : ipb.shoutbox.my_prefs['enable_quick_commands'],
  3294.                     prefs_drb : ipb.shoutbox.my_prefs['display_refresh_button'],
  3295.                     prefs_sdo : ipb.shoutbox.my_prefs['shoutbox_display_order'],
  3296.                     prefs_snd : ipb.shoutbox.my_prefs['disable_sound']
  3297.                 },
  3298.                 onSuccess: function(s)
  3299.                 {
  3300.                     if ( ipb.shoutbox.checkForErrors(s.responseText, 'my_prefs_loaded') )
  3301.                     {
  3302.                         return false;
  3303.                     }
  3304.  
  3305.                     // Run code and update prefs
  3306.                     s.responseText.evalScripts();
  3307.  
  3308.                     // Stop observing so we don't have double onclick events later
  3309.                     $('myprefs_save').stopObserving();
  3310.                     $('myprefs_restore').stopObserving();
  3311.  
  3312.                     ipb.shoutbox.preferences.hide();
  3313.                     ipb.shoutbox.in_prefs = false;
  3314.                 }
  3315.             }
  3316.  
  3317.         );
  3318.  
  3319.         return false;
  3320.     },
  3321.  
  3322.     myPrefsRestore: function()
  3323.     {
  3324.         if ( !ipb.shoutbox.myMemberID || ipb.shoutbox.global_on )
  3325.         {
  3326.             return false;
  3327.         }
  3328.  
  3329.         ipb.shoutbox.updateLastActivity();
  3330.  
  3331.         // Setup status
  3332.         ipb.shoutbox.popupUpdateStatus('processing');
  3333.  
  3334.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=prefs&action=restore',
  3335.             {
  3336.                 method: 'get',
  3337.                 encoding: ipb.vars['charset'],
  3338.                 onSuccess: function(s)
  3339.                 {
  3340.                     if ( ipb.shoutbox.checkForErrors(s.responseText, 'my_prefs_loaded') )
  3341.                     {
  3342.                         return false;
  3343.                     }
  3344.  
  3345.                     // Update popup and update prefs
  3346.                     $('myPrefs_inner').update( s.responseText );
  3347.  
  3348.                     ipb.shoutbox.preferences.hide();
  3349.                     ipb.shoutbox.in_prefs = false;
  3350.                 }
  3351.             }
  3352.         );
  3353.  
  3354.         return false;
  3355.     },
  3356.  
  3357.     myPrefsHeightSave: function( newHeight )
  3358.     {
  3359.         if ( !ipb.shoutbox.myMemberID || ipb.shoutbox.global_on )
  3360.         {
  3361.             return false;
  3362.         }
  3363.  
  3364.         ipb.shoutbox.updateLastActivity();
  3365.  
  3366.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=prefs&action=appHeight',
  3367.             {
  3368.                 method: 'post',
  3369.                 parameters: {
  3370.                     height:     newHeight
  3371.                 },
  3372.                 onSuccess: function(s)
  3373.                 {
  3374.                     if ( ipb.shoutbox.checkForErrors(s.responseText) )
  3375.                     {
  3376.                         return false;
  3377.                     }
  3378.                 }
  3379.             }
  3380.         );
  3381.  
  3382.         return false;
  3383.     },
  3384.  
  3385.     myPrefsGlobalHeightSave: function( newHeight )
  3386.     {
  3387.         if ( !ipb.shoutbox.myMemberID || !ipb.shoutbox.global_on )
  3388.         {
  3389.             return false;
  3390.         }
  3391.  
  3392.         ipb.shoutbox.updateLastActivity();
  3393.  
  3394.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=prefs&action=globalHeight',
  3395.             {
  3396.                 method: 'post',
  3397.                 parameters: {
  3398.                     height:     newHeight
  3399.                 },
  3400.                 onSuccess: function(s)
  3401.                 {
  3402.                     if ( ipb.shoutbox.checkForErrors(s.responseText) )
  3403.                     {
  3404.                         return false;
  3405.                     }
  3406.                 }
  3407.             }
  3408.         );
  3409.  
  3410.         return false;
  3411.     },
  3412.  
  3413.     /**
  3414.      * Load moderator popup for a shout
  3415.      */
  3416.     modOptsLoadShout: function(id)
  3417.     {
  3418.         if ( (!ipb.shoutbox.moderator && !ipb.shoutbox.can_edit) || ipb.shoutbox.mod_in_action )
  3419.         {
  3420.             return false;
  3421.         }
  3422.  
  3423.         if ( ipb.shoutbox.global_on )
  3424.         {
  3425.             ipb.shoutbox.setActionAndReload('mod|shout|'+id);
  3426.             return false;
  3427.         }
  3428.  
  3429.         /* We are in the archive? Let's close it then */
  3430.         if ( ipb.shoutbox.in_archive )
  3431.         {
  3432.             ipb.shoutbox.closePopup('archive');
  3433.         }
  3434.  
  3435.         ipb.shoutbox.updateLastActivity();
  3436.  
  3437.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=mod&action=loadShout&id=' + id,
  3438.             {
  3439.                 method: 'get',
  3440.                 onSuccess: function(s)
  3441.                 {
  3442.                     ipb.shoutbox.modOptsShow(s.responseText);
  3443.                 }
  3444.             }
  3445.         );
  3446.  
  3447.         return false;
  3448.     },
  3449.  
  3450.     /**
  3451.      * Load moderator popup for a member
  3452.      */
  3453.     modOptsLoadMember: function(id)
  3454.     {
  3455.         if ( !ipb.shoutbox.moderator || ipb.shoutbox.mod_in_action )
  3456.         {
  3457.             return false;
  3458.         }
  3459.  
  3460.         if ( ipb.shoutbox.global_on )
  3461.         {
  3462.             ipb.shoutbox.setActionAndReload('mod|member|number|'+id);
  3463.             return false;
  3464.         }
  3465.  
  3466.         /* We are in the archive? Let's close it then */
  3467.         if ( ipb.shoutbox.in_archive )
  3468.         {
  3469.             ipb.shoutbox.closePopup('archive');
  3470.         }
  3471.  
  3472.         ipb.shoutbox.updateLastActivity();
  3473.  
  3474.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=mod&action=loadMember&mid=' + id,
  3475.             {
  3476.                 method: 'get',
  3477.                 encoding: ipb.vars['charset'],
  3478.                 onSuccess: function(s)
  3479.                 {
  3480.                     ipb.shoutbox.modOptsShow(s.responseText);
  3481.                 }
  3482.             }
  3483.         );
  3484.  
  3485.         return false;
  3486.     },
  3487.  
  3488.     /**
  3489.      * Show the moderation popup
  3490.      */
  3491.     modOptsShow: function(response)
  3492.     {
  3493.         if ( (!ipb.shoutbox.moderator && !ipb.shoutbox.can_edit) || ipb.shoutbox.mod_in_action )
  3494.         {
  3495.             return false;
  3496.         }
  3497.  
  3498.         if ( ipb.shoutbox.checkForErrors(response) )
  3499.         {
  3500.             return false;
  3501.         }
  3502.  
  3503.         /* Popup already exist, show it! */
  3504.         if ( $('modOpts_popup') )
  3505.         {
  3506.             $('modOpts_inner').update( response );
  3507.         }
  3508.         else
  3509.         {
  3510.             ipb.shoutbox.modOpts    = new ipb.Popup( 'modOpts',
  3511.                             {
  3512.                                 type: 'pane',
  3513.                                 modal: true,
  3514.                                 w: '620px',
  3515.                                 h: 'auto',
  3516.                                 initial: response,
  3517.                                 hideAtStart: true,
  3518.                                 close: '.cancel'
  3519.                             }
  3520.                         );
  3521.  
  3522.             /* Setup close button */
  3523.             $('modOpts_close').stopObserving();
  3524.             $('modOpts_close').observe( 'click',
  3525.                 function()
  3526.                 {
  3527.                     ipb.shoutbox.closePopup('moderator');
  3528.                 }
  3529.             );
  3530.         }
  3531.  
  3532.         ipb.shoutbox.setupPopup('moderator');
  3533.     },
  3534.  
  3535.     /**
  3536.      * Do a moderator action
  3537.      */
  3538.     modOptsDo: function(event)
  3539.     {
  3540.         if ( (!ipb.shoutbox.moderator && !ipb.shoutbox.can_edit) || ipb.shoutbox.mod_in_action )
  3541.         {
  3542.             return false;
  3543.         }
  3544.  
  3545.         if ( ipb.shoutbox.blur )
  3546.         {
  3547.             ipb.shoutbox.blur();
  3548.         }
  3549.  
  3550.         var element = Event.element(event);
  3551.  
  3552.         /**
  3553.          * 1.1.0 Alpha
  3554.          *
  3555.          * Leave this if in place or clicking on images in the menu won't trigger the proper id
  3556.          */
  3557.         if ( element.tagName == 'IMG' )
  3558.         {
  3559.             element = element.up('li');
  3560.         }
  3561.  
  3562.         var modID = (ipb.shoutbox.mod_shout_id) ? ipb.shoutbox.mod_shout_id : ipb.shoutbox.mod_member_id;
  3563.         var type  = (ipb.shoutbox.mod_shout_id) ? 'shout' : 'member';
  3564.  
  3565.         // Se to true by default and set false if needed
  3566.         ipb.shoutbox.mod_in_action = true;
  3567.  
  3568.         /* Save our command and compare it with our choices */
  3569.         ipb.shoutbox.mod_command = element.id.sub( '_shout', '' );
  3570.  
  3571.         switch ( ipb.shoutbox.mod_command )
  3572.         {
  3573.             case 'edit':
  3574.             case 'delete':
  3575.             case 'deleteAll':
  3576.             case 'ban':
  3577.             case 'ban24':
  3578.             case 'ban48':
  3579.             case 'unban':
  3580.             case 'removeMod':
  3581.             case 'editHistory':
  3582.                 break;
  3583.             default:
  3584.                 ipb.shoutbox.mod_in_action = false;
  3585.                 ipb.shoutbox.produceError('mod_no_action');
  3586.                 return false; //Leave this return in place and don't change it with a break!
  3587.         }
  3588.  
  3589.         ipb.shoutbox.updateLastActivity();
  3590.  
  3591.         // Setup status
  3592.         ipb.shoutbox.popupUpdateStatus('processing');
  3593.  
  3594.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=mod&action=loadCommand&command=' + ipb.shoutbox.mod_command + '&modtype=' + type + '&id=' + modID,
  3595.             {
  3596.                 method: 'get',
  3597.                 encoding: ipb.vars['charset'],
  3598.                 onSuccess: function(s)
  3599.                 {
  3600.                     if ( ipb.shoutbox.checkForErrors(s.responseText) )
  3601.                     {
  3602.                         ipb.shoutbox.mod_in_action = false;
  3603.                         return false;
  3604.                     }
  3605.  
  3606.                     /* Update status & content */
  3607.                     ipb.shoutbox.popupUpdateStatus('mod_loaded_confirm');
  3608.                     $('shoutbox-popup-content').update( s.responseText );
  3609.  
  3610.                     /* Setup onclick events */
  3611.                     if ( ipb.shoutbox.mod_command == 'edit' )
  3612.                     {
  3613.                         // Change width & reposition
  3614.                         $('modOpts_inner').setStyle('width:750px;');
  3615.                         ipb.positionCenter( $('modOpts_popup') );
  3616.  
  3617.                         $('mod_edit_shout_confirm').observe('click', ipb.shoutbox.mod_opts_do_edit_shout );
  3618.                         $('mod_edit_shout_clear').observe('click', ipb.shoutbox.modOptsEditClear );
  3619.                         $('mod_edit_shout_cancel').observe('click', ipb.shoutbox.modOptsEditReset );
  3620.                     }
  3621.                     else if ( ipb.shoutbox.mod_command == 'editHistory' )
  3622.                     {
  3623.                         ipb.shoutbox.mod_in_action = false;
  3624.                         ipb.shoutbox.popupUpdateStatus('processed');
  3625.                     }
  3626.                     else
  3627.                     {
  3628.                         if ( $('confirm_option_yes') )
  3629.                         {
  3630.                             $('confirm_option_yes').observe('click', ipb.shoutbox.modOptsDoConfirm.bindAsEventListener(this) );
  3631.                         }
  3632.                         if ( $('confirm_option_no') )
  3633.                         {
  3634.                             $('confirm_option_no').observe('click', ipb.shoutbox.modOptsDoConfirm.bindAsEventListener(this) );
  3635.                         }
  3636.                     }
  3637.                 }
  3638.             }
  3639.         );
  3640.     },
  3641.  
  3642.     modOptsEditClear: function()
  3643.     {
  3644.         if ( !ipb.shoutbox.moderator && !ipb.shoutbox.can_edit )
  3645.         {
  3646.             return false;
  3647.         }
  3648.  
  3649.         ipb.shoutbox.updateLastActivity();
  3650.  
  3651.         // Update editor ^.^
  3652.         ipb.textEditor.getEditor().CKEditor.setData('');
  3653.     },
  3654.  
  3655.     modOptsEditReset: function()
  3656.     {
  3657.         ipb.shoutbox.popupModeratorReset();
  3658.  
  3659.         $('modOpts_inner').setStyle('width:550px;');
  3660.         ipb.positionCenter( $('modOpts_popup') );
  3661.     },
  3662.  
  3663.     modOptsDoConfirm: function(event)
  3664.     {
  3665.         if ( !ipb.shoutbox.moderator || !ipb.shoutbox.mod_in_action )
  3666.         {
  3667.             return false;
  3668.         }
  3669.  
  3670.         ipb.shoutbox.updateLastActivity();
  3671.  
  3672.         /* Get element from event */
  3673.         var element = Event.element(event);
  3674.  
  3675.         // Action confirmed?
  3676.         if ( element.id == 'confirm_option_yes' )
  3677.         {
  3678.             var modID = (ipb.shoutbox.mod_shout_id) ? ipb.shoutbox.mod_shout_id : ipb.shoutbox.mod_member_id;
  3679.             var type  = (ipb.shoutbox.mod_shout_id) ? 'shout' : 'member';
  3680.  
  3681.             // Setup status
  3682.             ipb.shoutbox.popupUpdateStatus('processing');
  3683.  
  3684.             new Ajax.Request( ipb.shoutbox.baseUrl + 'type=mod&action=performCommand&command=' + ipb.shoutbox.mod_command + '&modtype=' + type + '&id=' + modID,
  3685.                 {
  3686.                     method: 'get',
  3687.                     onSuccess: function(s)
  3688.                     {
  3689.                         if ( ipb.shoutbox.checkForErrors(s.responseText) )
  3690.                         {
  3691.                             ipb.shoutbox.mod_in_action = false;
  3692.                             return false;
  3693.                         }
  3694.  
  3695.                         ipb.shoutbox.popupUpdateStatus('processed');
  3696.  
  3697.                         // We have any action to perform?
  3698.                         switch ( ipb.shoutbox.mod_command )
  3699.                         {
  3700.                             case 'delete':
  3701.                                 $('shout-row-'+ipb.shoutbox.mod_shout_id).remove();
  3702.  
  3703.                                 ipb.shoutbox.rewriteShoutClasses();
  3704.  
  3705.                                 // Close popup, no need for it since the shout has been deleted
  3706.                                 ipb.shoutbox.closePopup('moderator');
  3707.  
  3708.                                 /** Update live total shouts count **/
  3709.                                 ipb.shoutbox.updateTotalShouts( ipb.shoutbox.total_shouts - 1 );
  3710.                                 break;
  3711.                             case 'deleteAll':
  3712.                                 var ids = s.responseText.split(",");
  3713.  
  3714.                                 ids.each( function(id) {
  3715.                                     if ( $('shout-row-'+id) )
  3716.                                     {
  3717.                                         $('shout-row-'+id).remove();
  3718.                                     }
  3719.                                 });
  3720.  
  3721.                                 ipb.shoutbox.closePopup('moderator');
  3722.  
  3723.                                 // Reload the page if we deleted all shouts >.<!
  3724.                                 if ( $('shoutbox-shouts-table').down('tbody').childElements().length < 1 )
  3725.                                 {
  3726.                                     window.location=window.location;
  3727.                                 }
  3728.  
  3729.                                 ipb.shoutbox.rewriteShoutClasses();
  3730.  
  3731.                                 /** Update live total shouts count **/
  3732.                                 ipb.shoutbox.updateTotalShouts( ipb.shoutbox.total_shouts - ids.length );
  3733.                                 break;
  3734.                             case 'ban':
  3735.                                 $('ban_shout').hide();
  3736.  
  3737.                                 if ( $('unban_shout') )
  3738.                                 {
  3739.                                     $('unban_shout').show();
  3740.                                 }
  3741.                                 break;
  3742.                             case 'ban':
  3743.                                 $('ban_shout').hide();
  3744.                                 $('ban24_shout').hide();
  3745.                                 $('ban48_shout').hide();
  3746.                                                    
  3747.                                 if ( $('unban_shout') )
  3748.                                 {
  3749.                                 $('unban_shout').show();
  3750.                                 }
  3751.                             break;
  3752.                             case 'ban24':
  3753.                             $('ban_shout').hide();
  3754.                                 $('ban24_shout').hide();
  3755.                                 $('ban48_shout').hide();
  3756.                                                            
  3757.                                 if ( $('unban_shout') )
  3758.                                 {
  3759.                                 $('unban_shout').show();
  3760.                             }
  3761.                             break;
  3762.                             case 'ban48':
  3763.                                 $('ban_shout').hide();
  3764.                                 $('ban24_shout').hide();
  3765.                                 $('ban48_shout').hide();
  3766.                                 if ( $('unban_shout') )
  3767.                                 {
  3768.                                     $('unban_shout').show();
  3769.                                 }
  3770.                             break;
  3771.                             case 'unban':
  3772.                                 $('unban_shout').hide();
  3773.  
  3774.                                 if ( $('ban_shout') )
  3775.                                 {
  3776.                                     $('ban_shout').show();
  3777.                                 }
  3778.                                 break;
  3779.                             default:
  3780.                                 break;
  3781.                         }
  3782.  
  3783.                         ipb.shoutbox.popupModeratorReset();
  3784.  
  3785.                         // Update properly our status after the reset
  3786.                         ipb.shoutbox.popupUpdateStatus( s.responseText, true );
  3787.                     }
  3788.                 }
  3789.             );
  3790.         }
  3791.         else
  3792.         {
  3793.             // Reset our popup so =O
  3794.             ipb.shoutbox.popupModeratorReset();
  3795.         }
  3796.     },
  3797.  
  3798.     /**
  3799.      * Edit shouts from the global shoutbox! :D
  3800.      * Added in 1.1.1
  3801.      */
  3802.     editShout: function(id)
  3803.     {
  3804.         if ( !id || !ipb.shoutbox.can_edit || ipb.shoutbox.mod_in_action )
  3805.         {
  3806.             return false;
  3807.         }
  3808.  
  3809.         if ( ipb.shoutbox.global_on )
  3810.         {
  3811.             ipb.shoutbox.setActionAndReload('edit|'+id);
  3812.             return false;
  3813.         }
  3814.  
  3815.         // Se to true by default and set false if needed
  3816.         ipb.shoutbox.mod_in_action = true;
  3817.  
  3818.         ipb.shoutbox.updateLastActivity();
  3819.  
  3820.         new Ajax.Request( ipb.shoutbox.baseUrl + 'type=mod&action=loadCommand&command=edit&modtype=shout&id=' + id + '&global=1',
  3821.             {
  3822.                 method: 'get',
  3823.                 encoding: ipb.vars['charset'],
  3824.                 onSuccess: function(s)
  3825.                 {
  3826.                     if ( ipb.shoutbox.checkForErrors(s.responseText) )
  3827.                     {
  3828.                         ipb.shoutbox.mod_in_action = false;
  3829.                         return false;
  3830.                     }
  3831.  
  3832.                     /* We have to setup here our vars or the edit will fail... */
  3833.                     ipb.shoutbox.mod_shout_id = id;
  3834.                     ipb.shoutbox.mod_command  = 'edit';
  3835.  
  3836.                     /* Popup already exist, show it! */
  3837.                     if ( $('editShout_popup') )
  3838.                     {
  3839.                         $('editShout_inner').update( s.responseText );
  3840.                     }
  3841.                     else
  3842.                     {
  3843.                         ipb.shoutbox.editShoutPopup = new ipb.Popup( 'editShout',
  3844.                                         {
  3845.                                             type: 'pane',
  3846.                                             modal: true,
  3847.                                             w: '750px',
  3848.                                             h: 'auto',
  3849.                                             initial: s.responseText,
  3850.                                             hideAtStart: true,
  3851.                                             close: '.cancel'
  3852.                                         }
  3853.                                     );
  3854.  
  3855.                         /* Hide close button */
  3856.                         $('editShout_close').stopObserving();
  3857.                         $('editShout_close').observe( 'click',
  3858.                             function()
  3859.                             {
  3860.                                 ipb.shoutbox.closePopup('editShout');
  3861.                             }
  3862.                         );
  3863.                     }
  3864.  
  3865.                     /* Run setup */
  3866.                     ipb.shoutbox.setupPopup('editShout');
  3867.                 }
  3868.             }
  3869.         );
  3870.  
  3871.         return false;
  3872.     }
  3873. }
  3874.  
  3875. ipb.shoutbox.initialize();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement