$(function () {
var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var dayOfWeekIndex = (new Date()).getDay();
var dayOfWeek = weekdays[dayOfWeekIndex];
var dayOfWeekPastIndex = Math.floor(weekdays.length * Math.random());
var dayOfWeekPast;
var hourOfDay = new Date().getHours();
var timeOfDay;
// choose day of week other than current one
if (dayOfWeekPastIndex == dayOfWeekIndex) {
dayOfWeekPast = weekdays[(dayOfWeekPastIndex + 1) % weekdays.length];
} else {
dayOfWeekPast = weekdays[dayOfWeekPastIndex];
}
// assign time of day to the hour
if ((hourOfDay >= 4) && (hourOfDay <= 11)) {
timeOfDay = "morning";
} else if ((hourOfDay >= 12) && (hourOfDay <= 16)) {
timeOfDay = "afternoon";
} else {
timeOfDay = "evening";
}
// make conversation
$('#story').typed({
strings: ["Well, here we are.^2000 \nAin't much to look at, is it?^2000 \nCame here on a " + dayOfWeekPast + " night once.^1000 \nIt was actually pretty crowded.^1000 \nBut on a " + dayOfWeek + " " + timeOfDay + " .^300 .^300 .^1000 \nI guess it's just you^1000 and me.^3000 \nHeh."],
typeSpeed: 20,
backDelay: 500,
loop: false,
loopCount: false,
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.