Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Fix vbShout Timezone problem Details »»
Fix vbShout Timezone problem
Version: 1.00, by newhere newhere is offline
Developer Last Online: Dec 2009 Show Printable Version Email this Page

Category: Chat Modifications - Version: 3.6.5 Rating:
Released: 04-09-2007 Last Update: Never Installs: 13
 
No support by the author.

This vbShout plugin: http://www.vbhackers.com/f76/ajax-fl...ut-2-1-a-4536/

Has a serious bug with Time Zone changing to that of the last person to post in the shout box.

Here is a fix so that each user will see the time in their local timezone correctly.

1. Open template forumhome_vbshout_shout
Find this (should be at the very beginning):
Code:
<tr>
After it add:
Code:
                                <td nowrap align="left" valign="top">
                                <font size="1">
                                    <date>{$Shout['time']}</date>
                                    
                                </font>
                                </td>
Make sure that the "date" and "/date" tags are on the same line, and with no spaces between them and the $Shout variable, just as above. These are not valid html tags, and we are going to write code to replace them ourselves.



2. Open template forumhome_vbshout
Find:
Code:
Shouts.innerHTML = '<table cellpadding="1" cellspacing="3" border="0" width="95%" align="left">' + ShoutRequest.handler.responseText + '</table>'
Replace it with:
Code:
                        var formatMe = ShoutRequest.handler.responseText
			formatMe = replaceDates(formatMe);
                        Shouts.innerHTML = '<table cellpadding="1" cellspacing="0" border="0" width="100%" align="left">' + formatMe + '</table>'
In the same template
Find this:
Code:
function sb_CollectHV(sbForm)
Before it add:
Code:
// replaces <date> tags
function replaceDates(s) {
            var ret = "";
            var matches = s.match(/<date>\d+<\/date>/g);
            for(var i = 0; matches != null && i < matches.length; i++) {
                var utc = matches[i].match(/\d+/);
                var date = new Date(utc * 1000);
                ret = ret + s.substr(0, s.indexOf(matches[i]));
                ret = ret + (date.getMonth()+1) + "/" +
                            date.getDate() + "/" +
                            date.getFullYear() + " " +
                            date.getHours() + ":" +
                            ((date.getMinutes() < 10) ? "0" : "") +
                            date.getMinutes() + ":" +
                            ((date.getSeconds() < 10) ? "0" : "") +
                            date.getSeconds() + " ";


                s = s.substr(s.indexOf(matches[i]) + matches[i].length);
            }
            ret = ret + s;
            return ret;
}



3. Open file vbshout.php
FInd this (There are similar code blocks, this should be in the function rewrite_shoutbox_flatfile() around line 226):
Code:
        $Shout['time']     = buildTime($Shout['s_time']);
        $Shout['s_shout']  = bbcodeparser($Shout['s_shout']);
        $Shout['style']    = '';
        $Shout['data']     = unserialize($Shout['s_data']);
        $Shout['username'] = fetch_musername($Shout, 'usergroupid');

        if (preg_match("#(\#)?0099FF#i", $Shout['data']['color']) && $Shout['s_by'] != 1)
        {
            $Shout['data']['color'] = '';
        }
Replace it with:
Code:
        // $Shout['time']     = buildTime($Shout['s_time']);
        $Shout['time']     = $Shout['s_time'];
        $Shout['s_shout']  = bbcodeparser($Shout['s_shout']);
        $Shout['style']    = '';
        $Shout['data']     = unserialize($Shout['s_data']);
        $Shout['username'] = fetch_musername($Shout, 'usergroupid');
        
        if (preg_match("#(\#)?0099FF#i", $Shout['data']['color']) && $Shout['s_by'] != 1)
        {
            $Shout['data']['color'] = '';
        }

This should now pass the date as UTC and JavaScript will convert it on the client side to the appropriate date.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 04-10-2007, 03:20 AM
newhere newhere is offline
 
Join Date: Mar 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tulsa View Post
Now how to get rid of the date and just have the time...
to get rid of the date and just have the time:

Code:
 ret = ret + "[" + date.getHours() + ":" +
                            ((date.getMinutes() < 10) ? "0" : "") +
                            date.getMinutes() + " " +
                            ((date.getSeconds() < 10) ? "0" : "") +
                            date.getSeconds() + "]";
Reply With Quote
  #23  
Old 04-10-2007, 03:37 AM
newhere newhere is offline
 
Join Date: Mar 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dbirosel View Post
Omg perfect!!!! Thanks alot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!
This isn't fully tested.
There might be a bug in this.

before
Code:
                if(hour > 12) {
you might want to add something like:
Code:
if(hour == 12) {
    append = "PM";
}
Otherwise 12 noon might show up as AM
Reply With Quote
  #24  
Old 04-10-2007, 03:41 AM
dbirosel dbirosel is offline
 
Join Date: Feb 2007
Location: San Diego
Posts: 587
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So is this how it suppose to look?

Code:
 var append = "AM";
                var hour = date.getHours();
				if(hour == 12) {
    				append = "PM";
				}
                if(hour > 12) {
                    hour = hour - 12;
                    append = "PM";
                }
                if(hour == 0) {
                    hour = 12;
                    append = "AM";
                }
                ret = ret + "[" + 
                            hour + ":" +
                            ((date.getMinutes() < 10) ? "0" : "") +
                            date.getMinutes() + ":" +
                            ((date.getSeconds() < 10) ? "0" : "") +
                            date.getSeconds() + " " + append + "]";
Reply With Quote
  #25  
Old 04-10-2007, 03:45 AM
newhere newhere is offline
 
Join Date: Mar 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dbirosel View Post
So is this how it suppose to look?

Code:
 var append = "AM";
                var hour = date.getHours();
		if(hour == 12) {
    			append = "PM";
		}
                if(hour > 12) {
                    hour = hour - 12;
                    append = "PM";
                }
                if(hour == 0) {
                    hour = 12;
                    append = "AM";
                }
                ret = ret + "[" + 
                            hour + ":" +
                            ((date.getMinutes() < 10) ? "0" : "") +
                            date.getMinutes() + ":" +
                            ((date.getSeconds() < 10) ? "0" : "") +
                            date.getSeconds() + " " + append + "]";
Sure I think that'll work.
Reply With Quote
  #26  
Old 04-10-2007, 03:58 AM
Tulsa Tulsa is offline
 
Join Date: Jul 2005
Location: Broken Arrow, Oklahoma
Posts: 475
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I didn't much care for the date and the seconds. I got rid of the bracket and put a simple dash between the time and the username.

Code:
var append = "AM";
                var hour = date.getHours();
                if(hour > 12) {
                    hour = hour - 12;
                    append = "PM";
                }
                if(hour == 0) {
                    hour = 12;
                    append = "AM";
                }
                ret = ret + hour + ":" +
                            ((date.getMinutes() < 10) ? "0" : "") +
                            date.getMinutes() + " " + append + " - ";
The shoutbox is finally fixed.. Thanks again newhere. :up:
Reply With Quote
  #27  
Old 04-10-2007, 04:03 AM
newhere newhere is offline
 
Join Date: Mar 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tulsa View Post
I didn't much care for the date and the seconds. I got rid of the bracket and put a simple dash between the time and the username.
Cool, whatever works for you. Thanks for posting your variation. I hope others do the same.
Reply With Quote
  #28  
Old 04-10-2007, 05:57 AM
dbirosel dbirosel is offline
 
Join Date: Feb 2007
Location: San Diego
Posts: 587
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's a bug...

When pruning (/prune) it doesn't ajax the original message when pruning. So we would need to refresh the page. So instead it would say "Loading....."
Reply With Quote
  #29  
Old 04-10-2007, 06:03 AM
newhere newhere is offline
 
Join Date: Mar 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dbirosel View Post
Here's a bug...


When pruning (/prune) it doesn't ajax the original message when pruning. So we would need to refresh the page. So instead it would say "Loading....."
I haven't seen this myself. If it's truly an AJAX bug, it may be related to the original mod. All this hack does is a small string replacement on whatever html the AJAX requests return before assigning it to the div's innerHTML.

What do you mean by "pruning"?
Reply With Quote
  #30  
Old 04-10-2007, 06:23 AM
dbirosel dbirosel is offline
 
Join Date: Feb 2007
Location: San Diego
Posts: 587
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by newhere View Post
I haven't seen this myself. If it's truly an AJAX bug, it may be related to the original mod. All this hack does is a small string replacement on whatever html the AJAX requests return before assigning it to the div's innerHTML.

What do you mean by "pruning"?
Well everything was operating just fine before this mod.

When people engage in conversations on the shoutbox, you can clear out all the recent messages by typing in "/prune".
Reply With Quote
  #31  
Old 04-10-2007, 06:28 AM
newhere newhere is offline
 
Join Date: Mar 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dbirosel View Post
Well everything was operating just fine before this mod.

When people engage in conversations on the shoutbox, you can clear out all the recent messages by typing in "/prune".
Hmm, okay I didn't know about this command, I just installed the shoutbox today. I'll look into this tomorrow if I can.

Thanks for your help and feedback.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:56 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.11501 seconds
  • Memory Usage 2,327KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (14)bbcode_code
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete