Advertisement
Guest User

Untitled

a guest
May 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Inferno Shoutbox Javascript Engine
  3.  * Created By Inferno Technologies
  4.  * All Rights Reserved
  5.  * * * * * * * * * * * * * * *
  6.  */
  7. function oc(a) {
  8.     var o = {};
  9.     for(var i=0;i<a.length;i++) {
  10.         o[a[i]]='';
  11.     }
  12.     return o;
  13. }
  14.  
  15. _ishout = function()
  16. {
  17.     this.titles = new Array();
  18.     this.newestbottom = 0;
  19.     this.script = '';
  20.     this.editor = '';
  21.     this.loader = '';
  22.     this.notice = '';
  23.     this.parsebreaker = '<<~~PARSE_^_BREAKER~~>>';
  24.     this.activity = '';
  25.     this.noticemessage = '';
  26.     this.shoutframe = '';
  27.     this.userframe = '';
  28.     this.styleprops = '';
  29.     this.styleprop = new Object;
  30.     this.fetchshout = new Object;
  31.     this.fetchusers = new Object;
  32.     this.fetchcontent = new Object;
  33.     this.fetchtabs = new Object;
  34.     this.editshout = new Object;
  35.     this.fetchsmilies = new Object;
  36.     this.fetchashout = new Object;
  37.     this.fetchaop = new Object;
  38.     this.editshoutform = '';
  39.     this.editshouteditor = '';
  40.     this.smiliesbox = '';
  41.     this.smiliesrow = '';
  42.     this.shout = new Object;
  43.     this.idle = false;
  44.     this.idletimelimit = 0;
  45.     this.loaded = false;
  46.     this.idletime = 0;
  47.     this.floodtime = 0;
  48.     this.fetchingsmilies = false;
  49.     this.showing = 'shoutbox';
  50.     this.detached = false;
  51.     this.aop = false;
  52.     this.aoptime = -1;
  53.     this.refreshspeed = 0;
  54.     this.styleproperties = {
  55.         'fontWeight' : ['bold', false],
  56.         'textDecoration' : ['underline', false],
  57.         'fontStyle' : ['italic', false]
  58.     };
  59. this.initiate = function(thisscript, idletime, dobold, doitalic, dounderline, newestbottom, floodtime, shoutheight, refreshspeed)
  60.     {
  61.         this.newestbottom = parseInt(newestbottom);
  62.         this.editor = fetch_object('vbshout_pro_shoutbox_editor');
  63.         this.notice = fetch_object('shoutbox_notice');
  64.         this.noticemessage = fetch_object('shoutbox_notice_message');
  65.         this.userframe = fetch_object('shoutbox_users_frame');
  66.         this.editshouteditor = fetch_object('shoutbox_editshout');
  67.         this.editshoutform = document.forms['editshoutform'];
  68.         this.smiliesbox = fetch_object('shoutbox_smilies');
  69.         this.smiliesrow = fetch_object('shoutbox_smilies_row');
  70.         this.tabs = fetch_object('vbshout_pro_tabs');
  71.         this.shoutwindow = fetch_object('shoutbox_window');
  72.         this.tabhistory = new Array();
  73.         this.shoutheight = shoutheight;
  74.         this.refresh_speed = refreshspeed;
  75. this.append_tab('<a href="?" onclick="return InfernoShoutbox.show(\'shoutbox\');">Shoutbox</a>');
  76. this.append_tab('<a href="?" onclick="return InfernoShoutbox.show(\'activeusers\');">Active Users</a>: <span id="shoutbox_activity">0</span>');
  77. this.fetch_tabs();
  78.  
  79.  
  80.  
  81.         this.activity = fetch_object('shoutbox_activity');
  82.         this.floodtime = floodtime;
  83.         this.script = thisscript;
  84.         this.load_editor_settings(parseInt(dobold), parseInt(doitalic), parseInt(dounderline));
  85.         this.idletimelimit = idletime;
  86.         this.idlecheck();
  87.  
  88.         this.set_shout_params('shoutbox_frame', '', '', '');
  89.  
  90.         this.fetch_shouts();
  91.  
  92.         if (this.aop)
  93.         {
  94.             this.get_shouts = setInterval("InfernoShoutbox.fetch_aop();", refreshspeed);
  95.         }
  96.         if (this.what == 'shoutbox')
  97.         {
  98.             this.get_shouts = setInterval("InfernoShoutbox.fetch_shouts();", refreshspeed);
  99.         }
  100.     }
  101.  
  102.     this.load_editor_settings = function(dobold, doitalic, dounderline)
  103.     {
  104.         if (fetch_object('sb_color_mem'))
  105.         {
  106.             this.adjust_property_selection('color', fetch_object('sb_color_mem'), false);
  107.         }
  108.  
  109.         if (fetch_object('sb_font_mem'))
  110.         {
  111.             this.adjust_property_selection('fontFamily', fetch_object('sb_font_mem'), false);
  112.         }
  113.  
  114.         if (dobold && fetch_object('sb_mem_bold'))
  115.         {
  116.             this.adjust_property('fontWeight', this.styleproperties['fontWeight'][0], fetch_object('sb_mem_bold'), false);
  117.         }
  118.  
  119.         if (doitalic && fetch_object('sb_mem_italic'))
  120.         {
  121.             this.adjust_property('fontStyle', this.styleproperties['fontStyle'][0], fetch_object('sb_mem_italic'), false);
  122.         }
  123.  
  124.         if (dounderline && fetch_object('sb_mem_underline'))
  125.         {
  126.             this.adjust_property('textDecoration', this.styleproperties['textDecoration'][0], fetch_object('sb_mem_underline'), false);
  127.         }
  128.     }
  129.     this.clear = function()
  130.     {
  131.         this.editor.value = '';
  132.     }
  133.  
  134.     this.assign_styleprop = function(prop, sobj)
  135.     {
  136.         switch (prop)
  137.         {
  138.             case 'fontWeight':
  139.             case 'textDecoration':
  140.             case 'fontStyle':
  141.             {
  142.                 this.adjust_property(prop, this.styleproperties[prop][0], sobj, true);
  143.                 return false;
  144.             }
  145.  
  146.             case 'color':
  147.             case 'fontFamily':
  148.             {
  149.                 this.adjust_property_selection(prop, sobj, true);
  150.                 return false;
  151.             }
  152.         }
  153.     }
  154.  
  155.     this.adjust_property_selection = function(property, sobj, update)
  156.     {
  157.         value = sobj.options[sobj.options.selectedIndex].value;
  158.  
  159.         if (!this.styleproperties[property])
  160.         {
  161.             this.styleproperties[property] = [];
  162.         }
  163.  
  164.         this.styleproperties[property][1] = value;
  165.  
  166.         eval('this.editor.style.' + property + ' = "' + value + '";');
  167.  
  168.         if (update)
  169.         {
  170.             this.update_styleprops();
  171.         }
  172.     }
  173.  
  174.     this.adjust_property = function(property, value, sobj, update)
  175.     {
  176.         sobj.value = sobj.value + '*';
  177.  
  178.         if (this.styleproperties[property][1])
  179.         {
  180.             value = '';
  181.             sobj.value = sobj.value.replace(/\*/g, '');
  182.         }
  183.  
  184.         this.styleproperties[property][1] = !this.styleproperties[property][1];
  185.  
  186.         eval('this.editor.style.' + property + ' = "' + value + '";');
  187.  
  188.         if (update)
  189.         {
  190.             this.update_styleprops();
  191.         }
  192.     }
  193.    
  194.     this.fetch_tabs = function()
  195.     {
  196.         this.set_loader('');
  197.         this.fetchtabs.ajax = new vB_AJAX_Handler(true);
  198.         this.fetchtabs.ajax.onreadystatechange(this.fetch_tabs_completed);
  199.         this.fetchtabs.ajax.send('infernoshout/browser/shoutbox/feeds.php?titles=all', '');
  200.     }
  201.  
  202.     this.fetch_tabs_completed = function()
  203.     {
  204.         ajax = this.fetchtabs.ajax;
  205.  
  206.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  207.         {
  208.             var title;
  209.             alert(ajax.reponseText);
  210.             this.titles = ajax.responseText.split("|");
  211.             for(title in titles) {
  212.                 this.append_tab('<a href="?" onclick="return InfernoShoutbox.show(\''+titles[title]+'\');">' + titles[title] + '</a>');
  213.             }
  214.         }
  215.     }
  216.  
  217.     this.set_shout_params = function(windowid, shoutprefix, shoutsuffix, fetchtype)
  218.     {
  219.         this.shout_params = new Object;
  220.         this.shout_params.prefix = shoutprefix;
  221.         this.shout_params.suffix = shoutsuffix;
  222.         this.shout_params.fetchtype = fetchtype;
  223.  
  224.         this.shoutframe = fetch_object(windowid);
  225.     }
  226.  
  227.     this.shout = function()
  228.     {
  229.         if (this.posting_shout)
  230.         {
  231.             this.show_notice('A previous message is still being submitted.');
  232.  
  233.             return false;
  234.         }
  235.  
  236.         if (this.idle)
  237.         {
  238.             this.hide_notice();
  239.         }
  240.  
  241.         this.idle = false;
  242.         this.idletime = 0;
  243.  
  244.         message = PHP.trim(this.editor.value);
  245.  
  246.         if (message == '')
  247.         {
  248.             this.show_notice('Please enter a message first.');
  249.  
  250.             return false;
  251.         }
  252.  
  253.         message = this.shout_params.prefix + message + this.shout_params.suffix;
  254.  
  255.         this.posting_shout = true;
  256.  
  257.         this.set_loader('');
  258.  
  259.         this.shout.ajax = new vB_AJAX_Handler(true);
  260.         this.shout.ajax.onreadystatechange(InfernoShoutbox.shout_posted);
  261.         this.shout.ajax.send('infernoshout.php', 'do=shout&message=' + PHP.urlencode(message));
  262.  
  263.         this.clear();
  264.  
  265.         return false;
  266.     }
  267.  
  268.     this.shout2 = function()
  269.     {
  270.  
  271.         if (this.idle)
  272.         {
  273.             this.hide_notice();
  274.         }
  275.  
  276.         this.idle = false;
  277.         this.idletime = 0;
  278.  
  279.         message = PHP.trim(this.editor.value);
  280.  
  281.         if (message == '')
  282.         {
  283.             this.show_notice('Please enter a message first.');
  284.  
  285.             return false;
  286.         }
  287.  
  288.         message = this.shout_params.prefix + message + this.shout_params.suffix;
  289.  
  290.         this.set_loader('');
  291.  
  292.         this.shout.ajax = new vB_AJAX_Handler(true);
  293.         this.shout.ajax.send('chattest.php', 'message=' + PHP.urlencode(message));
  294.  
  295.         this.clear();
  296.  
  297.         return false;
  298.     }
  299.     this.unidle = function()
  300.     {
  301.         this.idletime = 0;
  302.         this.idle = false;
  303.         this.hide_notice();
  304.  
  305.         return false;
  306.     }
  307.  
  308.     this.idlecheck = function()
  309.     {
  310.         if (this.idle || this.idletime > this.idletimelimit)
  311.         {
  312.             setTimeout("InfernoShoutbox.idlecheck()", 1000);
  313.             return false;
  314.         }
  315.  
  316.         this.idletime++;
  317.  
  318.         if (this.idletime > this.idletimelimit)
  319.         {
  320.             this.idle = true;
  321.         }
  322.  
  323.         setTimeout("InfernoShoutbox.idlecheck()", 1000);
  324.     }
  325.  
  326.     this.shout_posted = function()
  327.     {
  328.         ajax = InfernoShoutbox.shout.ajax;
  329.  
  330.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  331.         {
  332.             if (PHP.trim(ajax.handler.responseText) == 'completed')
  333.             {
  334.                 InfernoShoutbox.force_fetch = true;
  335.                 InfernoShoutbox.fetch_shouts();
  336.             }
  337.             else if(PHP.trim(ajax.handler.responseText) == 'flood')
  338.             {
  339.                 InfernoShoutbox.show_notice('You must wait ' + InfernoShoutbox.floodtime + ' seconds between shouts.');
  340.                 InfernoShoutbox.posting_shout = false;
  341.             }
  342.             else
  343.             {
  344.                 InfernoShoutbox.show_notice('Your shout failed to send.');
  345.                 InfernoShoutbox.posting_shout = false;
  346.             }
  347.         }
  348.     }
  349.  
  350.     this.update_styleprops = function()
  351.     {
  352.         this.set_loader('');
  353.  
  354.         var bold    = this.styleproperties['fontWeight'][1] ? 1 : 0;
  355.         var italic  = this.styleproperties['fontStyle'][1] ? 1 : 0;
  356.         var underline   = this.styleproperties['textDecoration'][1] ? 1 : 0;
  357.         var colour  = '';
  358.         var fontfamily  = '';
  359.  
  360.         if (this.styleproperties['color'])
  361.         {
  362.             colour = this.styleproperties['color'][1];
  363.         }
  364.  
  365.         if (this.styleproperties['fontFamily'])
  366.         {
  367.             fontfamily = this.styleproperties['fontFamily'][1];
  368.         }
  369.  
  370.         styleproperties = new Array(
  371.             'bold=' + bold,
  372.             'italic=' + italic,
  373.             'underline=' + underline,
  374.             'colour=' + colour,
  375.             'fontfamily=' + fontfamily
  376.         );
  377.  
  378.         styleproperties = styleproperties.join('&');
  379.  
  380.         this.styleprop.ajax = new vB_AJAX_Handler(true);
  381.         this.styleprop.ajax.onreadystatechange(InfernoShoutbox.styleprops_updated);
  382.         this.styleprop.ajax.send('infernoshout.php', 'do=styleprops&' + styleproperties);
  383.     }
  384.  
  385.     this.styleprops_updated = function()
  386.     {
  387.         ajax = InfernoShoutbox.styleprop.ajax;
  388.  
  389.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  390.         {
  391.             InfernoShoutbox.set_loader('none');
  392.             InfernoShoutbox.show_notice('Your style properties have been updated.');
  393.         }
  394.     }
  395.  
  396.     this.fetch_aop = function()
  397.     {
  398.         if (this.fetching_aop)
  399.         {
  400.             if (this.failure_count('fetching_aop'))
  401.             {
  402.                 this.fetching_aop = false;
  403.             }
  404.  
  405.             return false;
  406.         }
  407.  
  408.         if (InfernoShoutbox.new_aoptime)
  409.         {
  410.             this.fetch_shouts();
  411.  
  412.             return false;
  413.         }
  414.  
  415.         this.fetching_aop = true;
  416.  
  417.         if (!this.fetchaop.ajax)
  418.         {
  419.             this.fetchaop.ajax = new vB_AJAX_Handler(true);
  420.             this.fetchaop.ajax.onreadystatechange(InfernoShoutbox.fetch_aop_done);
  421.         }
  422.  
  423.         this.fetchaop.ajax.send('infernoshout/aop/aop.php', '');
  424.     }
  425.  
  426.     this.fetch_aop_done = function()
  427.     {
  428.         ajax = InfernoShoutbox.fetchaop.ajax;
  429.         InfernoShoutbox.fetching_aop = false;
  430.  
  431.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  432.         {
  433.             new_aop_time = parseInt(ajax.handler.responseText);
  434.  
  435.             if (new_aop_time > InfernoShoutbox.aoptime)
  436.             {
  437.                 InfernoShoutbox.new_aoptime = new_aop_time;
  438.                 InfernoShoutbox.fetch_shouts();
  439.             }
  440.         }
  441.     }
  442.  
  443.     this.fetch_shouts = function()
  444.     {
  445.         if (this.posting_shout && !this.force_fetch)
  446.         {
  447.             if (this.failure_count('posting_shout'))
  448.             {
  449.                 this.posting_shout = false;
  450.             }
  451.  
  452.             return false;
  453.         }
  454.  
  455.         if (this.fetching_shouts)
  456.         {
  457.             if (this.failure_count('fetching_shouts'))
  458.             {
  459.                 this.fetching_shouts = false;
  460.             }
  461.  
  462.             return false;
  463.         }
  464.  
  465.         if (this.idle && this.loaded)
  466.         {
  467.             if(!this.showing in oc(this.titles)) {
  468.                 this.show_notice('You are currently idle in the shoutbox. Click <a href="?" onclick="return InfernoShoutbox.unidle();">here</a> to un-idle yourself.');
  469.                 clearTimeout(InfernoShoutbox.kill_notice); // Don't hide this notice
  470.             }
  471.  
  472.             return false;
  473.         }
  474.  
  475.         this.fetching_shouts = true;
  476.         this.force_fetch = false;
  477.         this.loaded = true;
  478.  
  479.         this.set_loader('');
  480.  
  481.         this.fetchshout.ajax = new vB_AJAX_Handler(true);
  482.         this.fetchshout.ajax.onreadystatechange(InfernoShoutbox.fetch_shouts_completed);
  483.         this.fetchshout.ajax.send('infernoshout.php', 'do=messages' + ((this.detached) ? '&detach=true' : '') + '&fetchtype=' + this.shout_params.fetchtype);
  484.     }
  485.  
  486.     this.fetch_shouts_completed = function()
  487.     {
  488.         ajax = InfernoShoutbox.fetchshout.ajax;
  489.  
  490.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  491.         {
  492.             data = ajax.handler.responseXML.documentElement;
  493.             data = data.getElementsByTagName('data')[0].firstChild.data;
  494.             data = data.split(InfernoShoutbox.parsebreaker);
  495.  
  496.             InfernoShoutbox.update_shouts(PHP.trim(data[0]));
  497.  
  498.             if (data[1])
  499.             {
  500.                 InfernoShoutbox.activity.innerHTML = PHP.trim(data[1]);
  501.             }
  502.  
  503.             // Posting a shout now finishes here, when shouts have been refetched
  504.             if (InfernoShoutbox.posting_shout)
  505.             {
  506.                 InfernoShoutbox.posting_shout = false;
  507.             }
  508.  
  509.             InfernoShoutbox.set_loader('none');
  510.             InfernoShoutbox.fetching_shouts = false;
  511.  
  512.             if (InfernoShoutbox.new_aoptime)
  513.             {
  514.                 InfernoShoutbox.aoptime = InfernoShoutbox.new_aoptime;
  515.                 InfernoShoutbox.new_aoptime = false;
  516.             }
  517.         }
  518.     }
  519.  
  520.     this.update_shouts = function(shouts)
  521.     {
  522.         this.shoutframe.innerHTML = '';
  523.         this.shoutframe.innerHTML = shouts;
  524.  
  525.         if (this.newestbottom && this.shoutframe.scrollTop < this.shoutframe.scrollHeight)
  526.         {
  527.             this.shoutframe.scrollTop = this.shoutframe.scrollHeight;
  528.         }
  529.     }
  530.  
  531.     this.set_loader = function(set)
  532.     {
  533.         //this.loader.style.display = set;
  534.     }
  535.  
  536.     this.show_notice = function(message)
  537.     {
  538.         clearTimeout(InfernoShoutbox.kill_notice);
  539.         InfernoShoutbox.kill_notice = setTimeout("InfernoShoutbox.hide_notice()", 5000);
  540.  
  541.         this.noticemessage.innerHTML = message;
  542.         this.notice.style.display = '';
  543.     }
  544.  
  545.     this.hide_notice = function()
  546.     {
  547.         this.notice.style.display = 'none';
  548.     }
  549.     this.show = function(what)
  550.     {
  551.         if (what == this.showing)
  552.         {
  553.             return false;
  554.         }
  555.         this.showing = what;
  556.         if (what == 'shoutbox')
  557.         {
  558.             this.idle = false;
  559.             this.goto_pm_window('shoutbox_frame');
  560.             //this.shoutframe.style.display = 'block';
  561.             this.userframe.style.display = 'none';
  562.         }
  563.         else if (what == 'activeusers')
  564.         {
  565.             this.idle = false;
  566.             this.fetch_users();
  567.             this.shoutframe.innerHTML = "<div id=\'users\'></div>";
  568.             //this.shoutframe.style.display = 'block';
  569.             this.userframe.style.display = 'none';
  570.         } else if(what in oc(this.titles)) {
  571.             this.idle = true;
  572.             this.fetch_content();
  573.             this.shoutframe.innerHTML = "<div id=\'content_box\'></div>";
  574.             this.userframe.style.display = 'none';
  575.         }
  576.  
  577.         return false;
  578.     }
  579.     this.fetch_content = function()
  580.     {
  581.         this.set_loader('');
  582.         this.fetchcontent.ajax = new vB_AJAX_Handler(true);
  583.         this.fetchcontent.ajax.onreadystatechange(InfernoShoutbox.fetch_content_completed);
  584.         this.fetchcontent.ajax.send('infernoshout/browser/shoutbox/feeds.php?content=' + this.showing, '');
  585.     }
  586.  
  587.     this.fetch_content_completed = function()
  588.     {
  589.         ajax = InfernoShoutbox.fetchcontent.ajax;
  590.  
  591.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  592.         {
  593.                 document.getElementById("content_box").innerHTML = ajax.handler.responseText;
  594.         }
  595.     }
  596.     this.fetch_users = function()
  597.     {
  598.         this.set_loader('');
  599.  
  600.         this.fetchusers.ajax = new vB_AJAX_Handler(true);
  601.         this.fetchusers.ajax.onreadystatechange(InfernoShoutbox.fetch_users_completed);
  602.         this.fetchusers.ajax.send('infernoshout.php', 'do=userlist');
  603.     }
  604.  
  605.     this.fetch_users_completed = function()
  606.     {
  607.         ajax = InfernoShoutbox.fetchusers.ajax;
  608.  
  609.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  610.         {
  611.                 document.getElementById("users").innerHTML = ajax.handler.responseText;
  612.         }
  613.     }
  614.  
  615.     this.pm_user = function(username)
  616.     {
  617.         this.editor.value = '/pm ' + username + '; Your message here';
  618.  
  619.         return false;
  620.     }
  621.  
  622.     this.edit_shout = function(shoutid)
  623.     {
  624.         this.posting_shout = true;
  625.  
  626.         this.editshout.ajax = new vB_AJAX_Handler(true);
  627.         this.editshout.ajax.onreadystatechange(InfernoShoutbox.edit_shout_fetched);
  628.         this.editshout.ajax.send('infernoshout.php', 'do=editshout&shoutid=' + shoutid);
  629.  
  630.         this.set_loader('');
  631.  
  632.         return false;
  633.     }
  634.  
  635.     this.edit_shout_fetched = function()
  636.     {
  637.         ajax = InfernoShoutbox.editshout.ajax;
  638.  
  639.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  640.         {
  641.             InfernoShoutbox.set_loader('none');
  642.  
  643.             data = ajax.handler.responseXML.documentElement;
  644.             data = data.getElementsByTagName('data')[0].firstChild.data;
  645.  
  646.             if (data != 'deny')
  647.             {
  648.                 InfernoShoutbox.show_edit_shout(data.split(InfernoShoutbox.parsebreaker));
  649.             }
  650.             else
  651.             {
  652.                 InfernoShoutbox.posting_shout = false;
  653.             }
  654.         }
  655.     }
  656.  
  657.     this.show_edit_shout = function(data)
  658.     {
  659.         theshout = PHP.trim(data[0]);
  660.         shoutid = parseInt(data[1]);
  661.  
  662.         if (this.archive)
  663.         {
  664.             fetch_object('shout_' + shoutid).style.display = 'none';
  665.             fetch_object('shout_edit_' + shoutid).style.display = '';
  666.             fetch_tags(fetch_object('shout_edit_' + shoutid), 'input')[0].value = this.unescapeHTML(theshout);
  667.  
  668.             if (theshout.length < 60)
  669.             {
  670.                 fetch_tags(fetch_object('shout_edit_' + shoutid), 'input')[0].size = (theshout.length + 1);
  671.             }
  672.             else
  673.             {
  674.                 fetch_tags(fetch_object('shout_edit_' + shoutid), 'input')[0].size = 60;
  675.             }
  676.         }
  677.         else
  678.         {
  679.             this.editshouteditor.style.display = '';
  680.             this.editshoutform.shoutid.value = shoutid;
  681.             this.editshoutform.editshout.value = this.unescapeHTML(theshout);
  682.         }
  683.     }
  684.  
  685.     this.cancel_edit_shout = function(shoutid)
  686.     {
  687.         if (this.archive)
  688.         {
  689.             fetch_object('shout_' + shoutid).style.display = '';
  690.             fetch_object('shout_edit_' + shoutid).style.display = 'none';
  691.  
  692.             return false;
  693.         }
  694.         else
  695.         {
  696.             this.editshouteditor.style.display = 'none';
  697.             this.posting_shout = false;
  698.         }
  699.     }
  700.  
  701.     this.archive_edit_shout = function(shoutid, dodelete)
  702.     {
  703.         if (typeof dodelete != 'undefined')
  704.         {
  705.             dodelete = 1;
  706.         }
  707.         else
  708.         {
  709.             dodelete = 0;
  710.         }
  711.  
  712.         shout = PHP.urlencode(PHP.trim(fetch_tags(fetch_object('shout_edit_' + shoutid), 'input')[0].value));
  713.  
  714.         this.editshout.ajax = new vB_AJAX_Handler(true);
  715.         this.editshout.ajax.shoutid = shoutid;
  716.         this.editshout.ajax.dodelete = dodelete;
  717.         this.editshout.ajax.onreadystatechange(InfernoShoutbox.edit_shout_done);
  718.         this.editshout.ajax.send('infernoshout.php', 'do=doeditshout&shoutid=' + shoutid + '&shout=' + shout + '&delete=' + dodelete);
  719.  
  720.         return false;
  721.     }
  722.  
  723.     this.do_edit_shout = function(dodelete)
  724.     {
  725.         if (typeof dodelete != 'undefined')
  726.         {
  727.             dodelete = 1;
  728.         }
  729.         else
  730.         {
  731.             dodelete = 0;
  732.         }
  733.  
  734.         shout = PHP.urlencode(PHP.trim(this.editshoutform.editshout.value));
  735.         shoutid = parseInt(this.editshoutform.shoutid.value);
  736.  
  737.         this.editshout.ajax = new vB_AJAX_Handler(true);
  738.         this.editshout.ajax.shoutid = shoutid;
  739.         this.editshout.ajax.onreadystatechange(InfernoShoutbox.edit_shout_done);
  740.         this.editshout.ajax.send('infernoshout.php', 'do=doeditshout&shoutid=' + shoutid + '&shout=' + shout + '&delete=' + dodelete);
  741.  
  742.         this.editshouteditor.style.display = 'none';
  743.         this.set_loader('');
  744.  
  745.         return false;
  746.     }
  747.  
  748.     this.fetch_archive_shout = function(shoutid)
  749.     {
  750.         this.fetchashout.ajax = new vB_AJAX_Handler(true);
  751.         this.fetchashout.ajax.shoutid = shoutid;
  752.         this.fetchashout.ajax.onreadystatechange(InfernoShoutbox.fetch_archive_shout_done);
  753.         this.fetchashout.ajax.send('infernoshout.php', 'do=getarchiveshout&shoutid=' + shoutid);
  754.     }
  755.  
  756.     this.fetch_archive_shout_done = function()
  757.     {
  758.         ajax = InfernoShoutbox.fetchashout.ajax;
  759.  
  760.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  761.         {
  762.             data = ajax.handler.responseXML.documentElement;
  763.             data = data.getElementsByTagName('data')[0].firstChild.data;
  764.  
  765.             fetch_object('shout_shell_' + ajax.shoutid).innerHTML = data;
  766.         }
  767.     }
  768.  
  769.     this.edit_shout_done = function()
  770.     {
  771.         ajax = InfernoShoutbox.editshout.ajax;
  772.  
  773.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  774.         {
  775.             if (InfernoShoutbox.archive)
  776.             {
  777.                 if (!ajax.dodelete)
  778.                 {
  779.                     InfernoShoutbox.fetch_archive_shout(ajax.shoutid);
  780.                 }
  781.                 else
  782.                 {
  783.                     fetch_object('shout_row_' + ajax.shoutid).parentNode.removeChild(fetch_object('shout_row_' + ajax.shoutid));
  784.                 }
  785.             }
  786.             else
  787.             {
  788.                 InfernoShoutbox.set_loader('none');
  789.                 InfernoShoutbox.posting_shout = false;
  790.                 InfernoShoutbox.fetch_shouts();
  791.             }
  792.         }
  793.     }
  794.  
  795.     this.smilies = function()
  796.     {
  797.         if (this.fetchingsmilies)
  798.         {
  799.             return false;
  800.         }
  801.  
  802.         if (this.smiliesbox.style.display == '')
  803.         {
  804.             this.smiliesbox.style.display = 'none';
  805.             return false;
  806.         }
  807.  
  808.         this.fetchingsmilies = true;
  809.         this.fetchsmilies.ajax = new vB_AJAX_Handler(true);
  810.         this.fetchsmilies.ajax.onreadystatechange(InfernoShoutbox.smilies_fetched);
  811.         this.fetchsmilies.ajax.send('infernoshout.php', 'do=fetchsmilies');
  812.         this.set_loader('');
  813.     }
  814.  
  815.     this.smilies_fetched = function()
  816.     {
  817.         ajax = InfernoShoutbox.fetchsmilies.ajax;
  818.  
  819.         if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  820.         {
  821.             InfernoShoutbox.set_loader('none');
  822.             InfernoShoutbox.fetchingsmilies = false;
  823.             InfernoShoutbox.smiliesbox.style.display = '';
  824.             InfernoShoutbox.smiliesrow.innerHTML = ajax.handler.responseText;
  825.         }
  826.     }
  827.  
  828.     this.append_smilie = function(code)
  829.     {
  830.         applyto = this.editshouteditor.style.display == '' ? this.editshoutform.editshout : this.editor;
  831.  
  832.         if (PHP.trim(applyto.value) == '')
  833.         {
  834.             applyto.value = code + ' ';
  835.         }
  836.         else
  837.         {
  838.             spacer = applyto.value.substring(applyto.value.length - 1) == ' ' ? '' : ' ';
  839.             applyto.value += spacer + code + ' ';
  840.         }
  841.  
  842.         try
  843.         {
  844.             applyto.focus();
  845.         }
  846.         catch(e)
  847.         {
  848.         }
  849.     }
  850.  
  851.     this.make_curve = function(class_a, class_b)
  852.     {
  853.         curve = '<div class="alt2" style="border: 0px !important; margin: 0px; padding: 0px;">';
  854.         curve += '<span style="float: right; border: 0px !important; margin: 0px; padding: 0px;">';
  855.         curve += '<span class="alt1" style="display: block; border: 0px !important; margin: 0px; padding: 0px;">';
  856.         curve += '<span class="alt2" style="width: 1px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  857.         curve += '<span class="alt2" style="width: 2px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  858.         curve += '<span class="alt2" style="width: 3px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  859.         curve += '</span></span>';
  860.         curve += '<span class="alt1" style="width: 3px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  861.         curve += '<span class="alt1" style="width: 2px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  862.         curve += '<span class="alt1" style="width: 1px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  863.         curve += '</div>';
  864.         curve += '';
  865.  
  866.         return curve;
  867.     }
  868.  
  869.     this.append_tab = function(html, canclose)
  870.     {
  871.         if (canclose)
  872.         {
  873.             html += ' [<a href="#" onclick="return InfernoShoutbox.close_tab(this);">X</a>]';
  874.         }
  875.  
  876.         html = this.make_curve('', '') + '<div class="smallfont" style="text-align: center; white-space: nowrap; padding: 5px; padding-top: 0px; padding-bottom: 4px; background: transparent; margin: 0px; border: 0px !important;">' + html + '</div>';
  877.  
  878.         cellposition = this.tabs.rows[0].cells.length - 1;
  879.         newtab = this.tabs.rows[0].insertCell(cellposition);
  880.         newtab.className = 'alt2';
  881.         newtab.innerHTML = html;
  882.         newtab.style.cssText = "border: 0px !important; margin: 0px; padding: 0px;";
  883.  
  884.         if (this.tabhistory[newtab.innerHTML])
  885.         {
  886.             newtab.parentNode.removeChild(newtab);
  887.             return false;
  888.         }
  889.  
  890.         this.tabhistory[newtab.innerHTML] = 1;
  891.  
  892.         cellposition = this.tabs.rows[0].cells.length - 1;
  893.         newtab = this.tabs.rows[0].insertCell(cellposition);
  894.         newtab.className = 'alt1';
  895.         newtab.innerHTML = '&nbsp;';
  896.         newtab.style.cssText = "border: 0px !important; margin: 0px; padding: 0px;";
  897.     }
  898.  
  899.     this.close_tab = function(tabobj)
  900.     {
  901.         this.tabhistory[tabobj.parentNode.parentNode.innerHTML] = 0;
  902.  
  903.         tabobj.parentNode.parentNode.parentNode.removeChild(tabobj.parentNode.parentNode);
  904.  
  905.         this.clean_tab_spacing();
  906.  
  907.         if (this.showing != 'activeusers')
  908.         {
  909.             this.goto_pm_window('shoutbox_frame');
  910.         }
  911.         return false;
  912.     }
  913.  
  914.     this.clean_tab_spacing = function()
  915.     {
  916.         for (var c = 0; c < this.tabs.rows[0].cells.length; c++)
  917.         {
  918.             if (this.tabs.rows[0].cells[c + 1])
  919.             {
  920.                 if (this.tabs.rows[0].cells[c].innerHTML == this.tabs.rows[0].cells[c + 1].innerHTML && this.tabs.rows[0].cells[c].innerHTML == '&nbsp;')
  921.                 {
  922.                     this.tabs.rows[0].removeChild(this.tabs.rows[0].cells[c]);
  923.                     break;
  924.                 }
  925.             }
  926.         }
  927.     }
  928.  
  929.     this.open_pm_tab = function(pmid, username)
  930.     {
  931.         if (!this.pm_tabs)
  932.         {
  933.             this.pm_tabs = {};
  934.         }
  935.  
  936.         if (this.pm_tabs[pmid])
  937.         {
  938.             this.goto_pm_window(pmid);
  939.             return false;
  940.         }
  941.  
  942.         // Create the tab
  943.         this.append_tab('<a href="#" onclick="return InfernoShoutbox.goto_pm_window(\'' + pmid + '\');">' + username + '</a>', 1);
  944.  
  945.         // Create the window
  946.         this.append_shout_window(pmid, '/pm ' + username + '; ', '', 'pmonly&pmid=' + pmid.split('_')[1]);
  947.  
  948.         // Switch to the window
  949.         this.goto_pm_window(pmid);
  950.  
  951.         return false;
  952.     }
  953.  
  954.     this.set_default_window = function(windowid)
  955.     {
  956.         this.shout_windows[windowid] = new Object;
  957.         this.shout_windows[windowid].suffix = '';
  958.         this.shout_windows[windowid].prefix = '';
  959.         this.shout_windows[windowid].fetchtype = '';
  960.     }
  961.  
  962.     this.goto_pm_window = function(windowid)
  963.     {
  964.         if (!this.shout_windows)
  965.         {
  966.             this.shout_windows = {};
  967.             this.set_default_window('shoutbox_frame');
  968.         }
  969.  
  970.         if (!this.shout_windows[windowid])
  971.         {
  972.             return false;
  973.         }
  974.  
  975.         this.userframe.style.display = 'none';
  976.         this.shoutframe.style.display = 'none';
  977.  
  978.         this.set_shout_params(windowid, this.shout_windows[windowid].prefix, this.shout_windows[windowid].suffix, this.shout_windows[windowid].fetchtype);
  979.  
  980.         this.shoutframe.innerHTML = 'Loading...';
  981.         this.shoutframe.style.display = 'block';
  982.         this.showing = windowid;
  983.  
  984.         if (this.idle)
  985.         {
  986.             this.hide_notice();
  987.         }
  988.  
  989.         this.idle = false;
  990.  
  991.         this.fetch_shouts();
  992.  
  993.         return false;
  994.     }
  995.  
  996.     this.append_shout_window = function(windowid, shoutprefix, shoutsuffix, fetchtype)
  997.     {
  998.         if (!this.shout_windows)
  999.         {
  1000.             this.shout_windows = {};
  1001.             this.set_default_window('shoutbox_frame');
  1002.         }
  1003.  
  1004.         if (this.shout_windows[windowid])
  1005.         {
  1006.             // This window has already been placed, don't remake it.
  1007.             return false;
  1008.         }
  1009.  
  1010.         this.shout_windows[windowid] = new Object;
  1011.         this.shout_windows[windowid].prefix = shoutprefix;
  1012.         this.shout_windows[windowid].suffix = shoutsuffix;
  1013.         this.shout_windows[windowid].fetchtype = fetchtype;
  1014.  
  1015.         swindow = document.createElement('span');
  1016.         swindow.style.display = 'none';
  1017.         swindow.style.padding = '3px';
  1018.         swindow.style.height = parseInt(this.shoutheight) + 'px';
  1019.         swindow.style.overflow = 'auto';
  1020.         swindow.style.width = '99%';
  1021.         swindow.innerHTML = 'Loading...';
  1022.         swindow.id = windowid;
  1023.  
  1024.         this.shoutwindow.appendChild(swindow);
  1025.     }
  1026.  
  1027.     this.goto_options = function()
  1028.     {
  1029.         window.location.href = 'infernoshout.php?' + SESSIONURL + 'do=options';
  1030.     }
  1031.  
  1032.     this.detach = function()
  1033.     {
  1034.         detachwin = window.open('infernoshout.php?' + SESSIONURL + 'do=detach', '_ishout_detach');
  1035.         try
  1036.         {
  1037.             detachwin.focus();
  1038.         }
  1039.         catch(e){}
  1040.     }
  1041.  
  1042.     // AJAX lock-ups...  love 'em =D
  1043.     this.failure_count = function(failure_type)
  1044.     {
  1045.         if (!this.failure_log)
  1046.         {
  1047.             this.failure_log = new Array();
  1048.         }
  1049.  
  1050.         if (!this.failure_log[failure_type])
  1051.         {
  1052.             this.failure_log[failure_type] = 0;
  1053.         }
  1054.  
  1055.         this.failure_log[failure_type]++;
  1056.  
  1057.         if (this.failure_log[failure_type] > 2)
  1058.         {
  1059.             this.failure_log[failure_type] = 0;
  1060.             return true;
  1061.         }
  1062.  
  1063.         return false;
  1064.     }
  1065.  
  1066.     this.unescapeHTML = function(html)
  1067.     {
  1068.         tmpdiv = document.createElement('div');
  1069.         tmpdiv.innerHTML = html;
  1070.  
  1071.         return tmpdiv.childNodes[0] ? tmpdiv.childNodes[0].nodeValue : '';
  1072.     }
  1073. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement