vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=38179

New vBCode Tags: [Countdown] and [Countup] timers for users
by KevinG
03 May 2002 05:01

Have you or any of your members ever had the need or desire to post a countdown or countup in a post?
Something that automatically shows the remaining days, hours, minutes and seconds of that upcoming Walt Disney World trip?
Or want to show everyone how many days, hours, minutes and seconds that the user has gone without a cigarette, drink, sex? - LOL

I came up with this one here. It basically gives your users two new vB Code Tags, [countdown] and [countup].
Now there is no need to worry that the user will mess up your threads with incorrect JavaScript.
All they have to do is use these tags, just like most other tags.

For counting down, they would just have to do the following:
[countdown=May 21, 2002 12:32 PM EST;We are off to see Mickey Mouse;RED]My Walt Disney World Trip Begins in [/countdown]

Same for counting up with just different text of course.

I guess this would qualify as a hack as you do need to change one field in the database to store this.
Luckily, it's in a very small table so it should not slow anything down in theory.


Modify the database
Modify the field bbcodereplacement in the bbcode table to increase the storage size.
Change the field properties from varchar(200) to LONGTEXT. This is needed for the new vB Code replacement to follow.
I used phpMyAdmin which is very easy to use for this change.

Add new JavaScript
Add the following JavaScript code to your Style under Head Insert preferrably at the bottom.
Be sure to do this for every style that you defined in your database.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Add the new vBCodes
Using the Admin CP, add the following;

vB Code tag
-----------------------------------------------------
countdown


vB Code replacement
-----------------------------------------------------

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

vB Code example
-----------------------------------------------------
[countdown="May 4, 2002;Currently At WDW Now;BLUE"]My Countdown to Disney World[/countdown]

vB Code explanation
-----------------------------------------------------
Enter any text you would like to say to your members here.

Use {option} ?
-----------------------------------------------------
Select YES


Add the [countup] tag next;
vB Code tag
-----------------------------------------------------
countup

vB Code replacement
-----------------------------------------------------

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

vB Code example
-----------------------------------------------------
[countup="May 4, 2002;Waiting for my last cigarette;RED"]Smokefree Days[/countup]

vB Code explanation
-----------------------------------------------------
Enter any text you would like to say to your members here.

Use {option} ?
-----------------------------------------------------
Select YES



There are many variations that can be use here for how the text field looks.
We can post suggestions here for everyone to share :)

I can post a screenshot tomorrow if you would like.
It's really just a text field containing the days, hours, minutes and seconds of the timers with the {param} text over it.

Edit:
Reformatting some of the text as the PHP blocks are very wide.
Also fixed a case conversion that the PHP code tag is making in my post.

RDX1 03 May 2002 05:48

demo or screen?

Sweet Cheeks 03 May 2002 06:07

OMG Kevin you are SO awesome! :cheeky: Thank you SO much, I will give you full credit on my site, You are too cool. :rambo: Thank you so much!!

MrLister 03 May 2002 06:09

wow great job. this is awsome.

Velocd 03 May 2002 06:23

I'm too lazy to install this unless I know what it actually looks like. Please post a demo or screenshot ;)

Neo 03 May 2002 07:19

1 Attachment(s)
Nice man. Here is a image.

JulianD 03 May 2002 08:58

ummsmm... Seems very interesting and useful! Thanks Kevin!

Floris 03 May 2002 09:49

Uhm, the countdown is managed by the javascript? Not client-side? - little bit disappointing.. but I most surely LIKE this .. would be very cool to have this on vB3 in the calendar in many ways I can think of :)

Logician 03 May 2002 09:57

It's a very useful hack and idea is very nice either, congratulations! :)

Just one tiny concern in my side: You (and your members) will use the vbcode for a few messages only, however the java code in the header will be loaded with every page (not just for messages either, with even in calender or user CP pages) in your board.

Maybe it could be nice to check the message inside "showthread.php" before displayed whether vbcode exits or not and if it exits, make the neccessary parsing inside the same script again.

This method both saves you from the java header and it could also be possible to count down according to thread reader's local time ;) Even if you wouldnt regard this method, adding the java code to a relevant template (which is related to thread displaying only) can help to get rid of it for at least unrelevant pages. Just my 0.2 cents.

Congratulations again! :)

Logician

Sparkz 03 May 2002 10:27

Quote:

Originally posted by xiphoid
Uhm, the countdown is managed by the javascript? Not client-side? - little bit disappointing..
Not that it has anything to do with the hack but javascript IS clientside :)

Oh, and for changing the field in the DB to LONGTEXT... Why on earth would you need to be able to fit 4 GB in there? Changing it to text should be MORE than sufficient, unless you plan on having replacements bigger than 64kb, which I doubt anyone would ever need...

Not that the field itself will end up bigger by the change, (unless you actually fill it, that is) but I was just wondering why it had to be LONGTEXT and not just text...

http://www.mysql.com/doc/n/o/node_368.html

Floris 03 May 2002 11:14

I meant server-side.
I hate client-side stuff. It gives complaints, because every system if different.

@kevinG
by Wildthinks
03 May 2002 12:43

@kevinG
Hi KevinG,

looks beautiful, but don't work with European time Format?

Could you explain me, how must I write the Statement that works with European Time? I have try so many, doesn't work...

The next one, works with Opera?
I don't know exactly...

The last ist, you should replace the
Quote:

<SCRIPT LANGUAGE="JavaScript">
with

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

,
because I get errors in my IE5.5....

KevinG 03 May 2002 14:40

Thanks for the compliments folks and thank you neo for the screenshot. :) If we apply some css to it, they can come out looking mush better.

Quote:

Originally posted by Sparkz


Not that it has anything to do with the hack but javascript IS clientside :)

Oh, and for changing the field in the DB to LONGTEXT... Why on earth would you need to be able to fit 4 GB in there? Changing it to text should be MORE than sufficient, unless you plan on having replacements bigger than 64kb, which I doubt anyone would ever need...

Not that the field itself will end up bigger by the change, (unless you actually fill it, that is) but I was just wondering why it had to be LONGTEXT and not just text...

http://www.mysql.com/doc/n/o/node_368.html

I really do not know why I used LONGTEXT. I could have used something smaller but as you said, it will not use any more than what you fill into that field. I just needed to increase that default to fit this one in. TEXT would give us more than enough for this one. Maybe we can use the LONGTEXT for [mp3=song.mp3]My Song[/mp3] - LOL


Quote:

Originally posted by Logician

Just one tiny concern in my side: You (and your members) will use the vbcode for a few messages only, however the java code in the header will be loaded with every page (not just for messages either, with even in calender or user CP pages) in your board.

Maybe it could be nice to check the message inside "showthread.php" before displayed whether vbcode exits or not and if it exits, make the neccessary parsing inside the same script again.

Ever seen a Disney site? These countdowns are wanted in their sigs :)
I just stuck it into the header so every page would have the ability to use the JS. By making it available in the header, the main code would not have to be repeated on every post that is using it. Like you said, I could have modified showthread but that would make installation of this a little bit harder and also make it just another re-mod when updates from vB come along again.
In other words, I was lazy :D

Quote:

Originally posted by Wildthinks

@kevinG
Hi KevinG,

looks beautiful, but don't work with European time Format?

Could you explain me, how must I write the Statement that works with European Time? I have try so many, doesn't work...

The next one, works with Opera?
I don't know exactly...

The last ist, you should replace the


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

with


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

,
because I get errors in my IE5.5....

I do not get any errors with my IE5.5 here. I'll try what you suggested. Can you tell me about "European time Format"? I do not know this and would like to get it working for you. The only browser I have is IE 5.5 and IE 5.0 here so I can not test the others but would appreciate anyone that can for us.

Kevin

Mr. Slugworth 03 May 2002 19:16

This is exactly what I have been waiting for. Thanks for your work! Just one problem, it isn't working for me. I followed all of the instructions, even typed the scripts in the right place, since if I copy them, it just messes everything up. They are exactly as they are shown above, but I can't get it to work. Isn't it supposed to show up along with the other vbcodes so that I can just click on it when replying or making a new post? Or, is it not supposed to show up?

Any help would be appreciated.

KevinG 03 May 2002 19:25

Thanks for trying it out.

I did not change anything on whether it shows up or not (buttons or help) when posting. They are just there to use.

I'm going to your site now to try them out.


All times are GMT. The time now is 20:31.

Powered by vBulletin® Version 3.8.14
Copyright © 2020, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.