How to create a simple randomly greeting widget based on user's time of day
+3
Neptune-
YoshiGM
SarkZKalie
7 posters
Page 1 of 1
How to create a simple randomly greeting widget based on user's time of day
Hello, it's me again
Today, i will show you how to create a simple a randomly greeting widget based on user's time of day for your Forumotion site.
First of all, create a new widget (or put anywhere you want), copy and paste the following code :
Next step, replace the default text in Morning1-2-3, Afternoon1-2-3 and Evening1-2-3 to any word or text you want.
For example :
Enjoy!
Today, i will show you how to create a simple a randomly greeting widget based on user's time of day for your Forumotion site.
First of all, create a new widget (or put anywhere you want), copy and paste the following code :
- Code:
<p id="greeting"></p>
<script type="text/javascript">
greeta = ["Morning1", "Morning2", "Morning3"];
greetb = ["Afternoon1", "Afternoon2", "Afternoon3"];
greetc = ["Evening1", "Evening2", "Evening3"];
userz = '<a href="{USERLINK}"> {USERNAME} </a>';
greetza = Math.floor(Math.random() * greeta.length);
greetzb = Math.floor(Math.random() * greetb.length);
greetzc = Math.floor(Math.random() * greetc.length);
today = new Date()
if (today.getHours() >=6 && today.getHours() < 12) {
document.getElementById('greeting').innerHTML = greeta[greetza] + userz;
}
else
if (today.getHours() >= 12 && today.getHours() <= 17) {
document.getElementById('greeting').innerHTML = greetb[greetzb] + userz;
}
else
if (today.getHours() > 17 && today.getHours() <= 24) {
document.getElementById('greeting').innerHTML = greetc[greetzc] + userz;
}
else
document.getElementById('greeting').innerHTML = 'Sleep well zZz';
</script>
- Code:
#greeting {color:red}
#greeting a {color:blue}
Next step, replace the default text in Morning1-2-3, Afternoon1-2-3 and Evening1-2-3 to any word or text you want.
For example :
- Spoiler:
- greeta = ["Howdy", "Hello", "Bonjour"];
- Spoiler:
- greeta = ["Howdy", "Hallå", "Bonjour", "Konnichiwa", "Marhaba", "Namaskar", "Zdraveite", "Hola", "Guten tag", "Yasou"];
Enjoy!
Last edited by SarkZKalie on June 8th 2020, 12:18 am; edited 1 time in total
TonnyKamper, Jucarese, TheCrow and The Last Outlaw like this post
Re: How to create a simple randomly greeting widget based on user's time of day
Sounds interesing.
Thanks for the code and your hardwok @SarkZKalie
Thanks for the code and your hardwok @SarkZKalie
Re: How to create a simple randomly greeting widget based on user's time of day
Hello,
Nice job, but live demo seems to be broken (it worked few hours ago)
Nice job, but live demo seems to be broken (it worked few hours ago)
Re: How to create a simple randomly greeting widget based on user's time of day
Oy o/
Nice one, thanks.
You may want to fix this; there's a letter missing here (thread and live demo):
greetc[greetz] » greetc[greetzc]
Nice one, thanks.
You may want to fix this; there's a letter missing here (thread and live demo):
- Code:
if (today.getHours() > 17 && today.getHours() <= 24) {
document.getElementById('greeting').innerHTML = greetc[greetz] + userz;
}
greetc[greetz] » greetc[greetzc]
KimiD56 likes this post
Re: How to create a simple randomly greeting widget based on user's time of day
Hi guys, thank you. I've edited the first post
Hope you like it
Hope you like it
Re: How to create a simple randomly greeting widget based on user's time of day
@KimiD56 hi, you may find it in Admin Control Panel -> Display -> CSS
KimiD56 likes this post
SarkZKalie likes this post
Re: How to create a simple randomly greeting widget based on user's time of day
Thank you for sharing this @SarkZKalie,
I added this to my forum, in a different way, but it's a nice feature. Great work!
I added this to my forum, in a different way, but it's a nice feature. Great work!
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
BlackScorpion, SarkZKalie and The Last Outlaw like this post
Re: How to create a simple randomly greeting widget based on user's time of day
@TheCrow whaaaaaa that was great idea, my dear ))
TheCrow and The Last Outlaw like this post
Re: How to create a simple randomly greeting widget based on user's time of day
@SarkZKalie I want to do this the same way @TheCrow did it. I've tried it a few times and it didn't work like I wanted it to. Can you advise me as to how to set it all up?
Re: How to create a simple randomly greeting widget based on user's time of day
@The Last Outlaw, it is easy. You only add the html tags wherever you want in your template, and then you add the script as a javascript to your forum and it will be shown like mine. Nothing too difficult!
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
Re: How to create a simple randomly greeting widget based on user's time of day
TheCrow wrote:@The Last Outlaw, it is easy. You only add the html tags wherever you want in your template, and then you add the script as a javascript to your forum and it will be shown like mine. Nothing too difficult!
Which one? Overall Header?
Re: How to create a simple randomly greeting widget based on user's time of day
That depends on where you want this to appear. If you want it to the header of the forum like I did, then yes, overall_header would be the one.
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
Similar topics
» How do I display a Special rank and a post based rank on all applicable users at the same time?
» Scaling Widget Background Image Based on Widget Size/User Resolution
» Every Time I attempt to Create a new topic it redirects it to the 'my first thread'
» The online users list (IPs and time cut-off)
» How to create this widget
» Scaling Widget Background Image Based on Widget Size/User Resolution
» Every Time I attempt to Create a new topic it redirects it to the 'my first thread'
» The online users list (IPs and time cut-off)
» How to create this widget
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum