4 Replies - 929 Views - Last Post: 14 March 2013 - 08:18 AM

#1 sadbuddy  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 28
  • Joined: 18-November 12

Can anyone explain this code to me ?

Posted 13 March 2013 - 05:30 PM

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>

<body onload="graffiti()">
<script>

var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</b></font></small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function graffiti()
{
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}

</script>
<span id="clock"></span>
</body>

</html>


*** EDIT ***
Please use code tags when posting ANY kind of code
:code:

This post has been edited by GunnerInc: 13 March 2013 - 05:31 PM
Reason for edit:: Added code tags


Is This A Good Question/Topic? 2
  • +

Replies To: Can anyone explain this code to me ?

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: Can anyone explain this code to me ?

Posted 13 March 2013 - 06:28 PM

That code isn't even C or C++. Why are you posting here? You are in a world of hurt if you can't even tell. You'll need more than just getting an explanation of that code.

This post has been edited by Skydiver: 13 March 2013 - 06:30 PM

Was This Post Helpful? 0
  • +
  • -

#3 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Can anyone explain this code to me ?

Posted 14 March 2013 - 04:22 AM

I believe I have seen it all.
Was This Post Helpful? 0
  • +
  • -

#4 Programmar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 13-March 13

Re: Can anyone explain this code to me ?

Posted 14 March 2013 - 07:57 AM

View Postsadbuddy, on 13 March 2013 - 05:30 PM, said:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>

<body onload="graffiti()">
<script>

var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</b></font></small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function graffiti()
{
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}

</script>
<span id="clock"></span>
</body>

</html>


*** EDIT ***
Please use code tags when posting ANY kind of code
:code:/>



----
I'm dissappointed in the answers you're getting. This, to me, looks like a mix of Javascript and HTML. At the top is information about the font, html, title, etc. If you go down more, you will see a tag <script>, where a Javascript code starts. The Javascript code looks to me like a clock. I just gave you a simple explanation of this code, if you want to learn more about Javascript and HTML go to www.codecademy.com
It has a series of many lessons on Javascript and HTML.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3814
  • View blog
  • Posts: 13,527
  • Joined: 12-December 12

Re: Can anyone explain this code to me ?

Posted 14 March 2013 - 08:18 AM

That code is very old: it uses the deprecated font tag, obsolete document.all, and Javascript code is semi-colon terminated. So I wouldn't bother studying this particular code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1