What day were you born?

14 08 2015

Simple JavaScript function that calculates your birthday day of week:

function getBirthday(myDay)
{
var daysOfWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; //array with the days of week
alert("I was born in a: " + daysOfWeek[myDay.getDay()]); //getDay returns the days of week (0-6 day of week. 0 == sunday)
}

var myDay = new Date(1969,10,25);
getBirthday(myDay);

Result:
Screenshot from 2015-08-15 00:18:03





Simple Digital Watch (JavaScript)

29 05 2010

Bellow is a simple JavaScript code to implement a digital watch.

When the page is loaded, the function start_watch() is called and then, Date object is used in conjunction with getHours(), getMinutes() and getSeconds() methods, to keep updating the actual time, per second. To do that, is used the setTimeout function which is calling the start_watch() method every second (or every 1000 milliseconds):

Simple JavaScript digital watch (click on the image to enlarge)





Countdown to save the world (JavaScript)

29 05 2010

There is a simple JavaScript countdown digital clock, below (click on the image to enlarge it). It’s an example of JavaScript code, using time events, which you can easily manage it, to start and stop, using the functions setTimeout and clearTimeout:

Simple JavaScript countdown

Result of the code above

To test it, just copy the code above to your preferred text editor and save it with a .html/.htm extension.





Password Generator (JavaScript example)

25 05 2010

Do you always forget your passwords?
If yes, you shouldn’t :), anyway here is an example to transform a familiar word into a strong password (click on the image to get better resolution):

Password Generator (Javascript+HTML)

The example of code above, was developed using JavaScript and transforms chars into char codes on even chars of the string, as well as the opposite on odd chars.

For instance, from the i4MK string is generated the following password: 104676M

Now when you forget your password, you can use this program, writing your familiar word into the text box.

I hope this can be useful to somebody.

Cheers!