• Page 1 of 1
  • 1
Forum moderator: bigblog  
uCoz Community » For Webmasters » Custom Solutions » Greetings $code$ (Inquiry)
Greetings $code$
Cyberdasm
Posts: 611
Reputation: 7

Message # 1 | 10:56 AM
Is there a code that will say "Good Morning" "Good Afternoon" "Good Evening" that depends on the time of the user?
Actually I needed this kind of code.

I mean like this:
$day$ = Tuesday

If there isn't a code like this, is there a possibility that it will be implemented?

1F4BF3B
Post edited by Cyberdasm - Wednesday, 2016-10-19, 6:10 PM
bigblog
Twink
Posts: 1537
Reputation: 72

Message # 2 | 10:40 AM
Cyberdasm, you can do it with JavaScript:
Code
<script type="text/javascript> currentTime = new Date();      
   if (currentTime.getHours() >= 6 && currentTime.getHours() <= 11 ) document.write("Good morning");      
   if (currentTime.getHours() >= 12 && currentTime.getHours() <= 17 ) document.write("Good afternoon");      
   if (currentTime.getHours() >= 18 && currentTime.getHours() <= 23) document.write("Good evening");      
   if (currentTime.getHours() >= 0 && currentTime.getHours() <= 5) document.write("You should go to sleep");      
   </script>!

hey i'm joe and i'm a twink, please enjoy your stay

i do not work for the company anymore, sorry for the late replies
icon by Nathan Butler
Cyberdasm
Posts: 611
Reputation: 7

Message # 3 | 11:14 AM
bigblog, thank you for your script. +1
1F4BF3B
Soldierdevil
Posts: 124
Reputation: 0

Message # 4 | 6:31 AM
bigblog, wherre do i install this exactly?..it does not display anything where i have put it!
I hate politics, people who do not make an effort with people and those who try hard to be cool
bigblog
Twink
Posts: 1537
Reputation: 72

Message # 5 | 8:23 AM
Soldierdevil, that's weird. It should work literally everywhere where you can use HTML tags. Can you show me an URL of the page where you've inserted the code?
hey i'm joe and i'm a twink, please enjoy your stay

i do not work for the company anymore, sorry for the late replies
icon by Nathan Butler
Cyberdasm
Posts: 611
Reputation: 7

Message # 6 | 2:31 AM
Soldierdevil, you need to know first the Javascript DDS so that you could understand how it works. Yes i will say that I am confused at first how that code works since I am not familiar with javascript. But later on I figured it out. Here is the finished product.

The script doesn't have a call function make one then it works. Here's mine.
My function
Code
<span id="demo"></span>


My Script
Code

<script>
currentTime = new Date, currentTime.getHours() >= 6 && currentTime.getHours() <= 11 && document.write("<span class='navbar-brand'><b>Good Morning, $USERNAME$</b></span>"),
currentTime.getHours() >= 12 && currentTime.getHours() <= 17 && document.write("<span class='navbar-brand'><b>Good Afternoon, $USERNAME$</b></span>"),
currentTime.getHours() >= 18 && currentTime.getHours() <= 23 && document.write("<span class='navbar-brand'><b>Good evening, $USERNAME$</b></span>"),
currentTime.getHours() >= 0 && currentTime.getHours() <= 5 && document.write("<span class='navbar-brand'><b>You should go to sleep, $USERNAME$</b></span>"),
document.getElementById("demo").innerHTML = x.write;
</script>

1F4BF3B
Post edited by Cyberdasm - Monday, 2016-10-31, 3:01 AM
Soldierdevil
Posts: 124
Reputation: 0

Message # 7 | 5:43 AM
Cyberdasm,
Quote
The script doesn't have a call function make one then it works.
Make one for me too, just requesting..pleaseee!!! I dont get anything with javascript i am even so much afraid of that language..looks complicated but does nice things. Please help me create an ID from this..because even get what you mean my ID

I hate politics, people who do not make an effort with people and those who try hard to be cool
Cyberdasm
Posts: 611
Reputation: 7

Message # 8 | 5:54 AM
change the demo make it as what you want to call it.
document.getElementById("demo").innerHTML = x.write;

Added (2016-10-31, 5:54 AM)
---------------------------------------------
Its like this, post this code to where you want the "Good morning Mr. Blank" will be seen.
<span id="editme"></span>

usually the javascript is at the bottom of the page.
paste this code there.
Code
<script>
currentTime = new Date, currentTime.getHours() >= 6 && currentTime.getHours() <= 11 && document.write("<b>Good Morning, $USERNAME$</b>"),
currentTime.getHours() >= 12 && currentTime.getHours() <= 17 && document.write("<b>Good Afternoon, $USERNAME$</b></span>"),
currentTime.getHours() >= 18 && currentTime.getHours() <= 23 && document.write("<b>Good evening, $USERNAME$</b>"),
currentTime.getHours() >= 0 && currentTime.getHours() <= 5 && document.write("<b>You should go to sleep, $USERNAME$</b>"),
document.getElementById("editme").innerHTML = x.write;
</script>

1F4BF3B
Post edited by Cyberdasm - Monday, 2016-10-31, 5:57 AM
Soldierdevil
Posts: 124
Reputation: 0

Message # 9 | 6:39 AM
Cyberdasm, thank you so much its working! I love you guys. Only that i wanna add on some images like a sine rise at good morning and also align all texts at the center of the page.
I hate politics, people who do not make an effort with people and those who try hard to be cool
bigblog
Twink
Posts: 1537
Reputation: 72

Message # 10 | 4:46 PM
Soldierdevil, you can do that, too, but make sure you use apostrophes instead of quotation marks when they are needed.
hey i'm joe and i'm a twink, please enjoy your stay

i do not work for the company anymore, sorry for the late replies
icon by Nathan Butler
uCoz Community » For Webmasters » Custom Solutions » Greetings $code$ (Inquiry)
  • Page 1 of 1
  • 1
Search: