Post by Wormopolis on Jul 25, 2009 14:05:36 GMT -8
Browser Tested: IE and FF
placement: footer (wherever you want it to show)
Creates a pseudo-random selection from an array of weather types. There are 2 arrays, one for images, and one for influence.
how influence works:
The array sets up each month with a short list of weather types you want to appear in that month. If you want a certain weather type to appear more often, just add it in more. if you want all weather types to have the same chance of being picked, just include them once.
The code will insert your image, and the date into a div with id="weather" that you can place anywhere on your page, with the stipulation that the div appears before the code is ran.
code:
Live Preview: www.wormocodes.proboards.com/index.cgi?board=codedb&action=display&thread=238
EDIT: fixed preview link
placement: footer (wherever you want it to show)
Creates a pseudo-random selection from an array of weather types. There are 2 arrays, one for images, and one for influence.
how influence works:
The array sets up each month with a short list of weather types you want to appear in that month. If you want a certain weather type to appear more often, just add it in more. if you want all weather types to have the same chance of being picked, just include them once.
The code will insert your image, and the date into a div with id="weather" that you can place anywhere on your page, with the stipulation that the div appears before the code is ran.
code:
<script type="text/javascript">
<!--
// Pseudo-Random weather generator
// By Wormopolis - wormocodes.proboards.com
// Keep Header Intact
var weatherImageArray = [
["sunny", "http://i197./aa250/WORMOPOLIS/sunny.jpg"],
["rainy", "http://i197./aa250/WORMOPOLIS/rainy.jpg"],
["windy", "http://i197./aa250/WORMOPOLIS/windy.jpg"],
["snowing", "http://i197./aa250/WORMOPOLIS/snowing.jpg"],
["storming","http://i197./aa250/WORMOPOLIS/storming.jpg"],
["scorching","http://i197./aa250/WORMOPOLIS/scorching.jpg"] //no comma last entry
];
var weatherInfluenceArray = [
// month, list of weather types seperated by commas. repeat weather types if you want to influence results
["January","sunny,sunny,snowing,snowing,snowing,windy"],
["February","sunny,snowing,snowing,snowing,windy,rainy"],
["March","snowing,rainy,rainy,sunny,windy,rainy"],
["April","rainy,rainy,sunny,sunny,windy"],
["May","rainy,sunny,sunny,windy,storming,sunny"],
["June","rainy,sunny,sunny,sunny,storming,windy,storming"],
["July","sunny,scorching,windy,rainy,scorching,storming"],
["August","sunny,scorching,scorching,storming,scorching"],
["September","sunny,windy,windy,rainy,scorching"],
["October","sunny,windy,windy,snowing,windy,snowing"],
["November","sunny,windy,snowing,windy"],
["December","sunny,snowing,snowing,windy,snowing"] //no comma here
];
// no need to edit below, unless you know what you are doing.
var dt=new Date();
dayseed=Math.floor(dt.getTime()/(1000*60*60*24));
dayseed=Math.floor(Math.abs(Math.cos(dayseed)*dayseed));
sel=dt.getMonth();
keepday=dt.getDate();
keepmonth=weatherInfluenceArray[sel][0];
var weatherTypes = weatherInfluenceArray[sel][1];
monthWeatherArray=weatherTypes.split(',');
pseudoRandomNumber=dayseed%monthWeatherArray.length;
dailyWeather=monthWeatherArray[pseudoRandomNumber];
for (w=0;w<weatherImageArray.length; w++) if (weatherImageArray[w][0]==dailyWeather) keep=weatherImageArray[w][1];
suff=(keepday.toString().substr(keepday.toString().length-1));
suff=(suff=='1'?'st':suff=='2'?'nd':suff=='3'?'rd':'th');
datelabel=document.createTextNode(keepmonth+" "+keepday+suff);
dispImg=document.createElement('img');
dispImg.src=keep;
dispImg.border=0;
document.getElementById('weather').appendChild(dispImg);
document.getElementById('weather').appendChild(document.createElement('br'));
document.getElementById('weather').appendChild(datelabel);
document.getElementById('weather').style.display="";
// -->
</script>
Live Preview: www.wormocodes.proboards.com/index.cgi?board=codedb&action=display&thread=238
EDIT: fixed preview link