I'm having difficulties making these two scripts operate together.
The first script changes numbers 0-9 to its respective image, while the second displays a count-up occurring at a set interval/increment. What I need these to do is output the result of the count-up (which works like a charm on its own) but change each number into an image.
What I know: I need to pass the number that gets spit out through the counterimages function. But I'm a noob! How would I accomplish this? Do I have to make the second script a function and plug it into the input of the first function?
(function counterimages(INPUT) {
var output = ""
for (var i = 0; i < input.length; i++) {
var chr = input.substring(i, i + 1)
if (chr == '£') {
output += '<img border="0" src="img/pound.gif">';
} else if (chr == '.') {
output += '<img border="0" src="img/dot.gif">';
} else {
output += '<img border="0" src="http://eatiply3.staging.wpengine.com/wp-content/uploads/2013/05/'+(chr+1)+'.png">';
}
return output;
}
})()
var START_DATE = new Date("October 21, 2012 22:30:00"); // put in the starting date here
var INTERVAL = 1; // refresh interval in seconds
var INCREMENT = 769.2; // increase per tick (1/0.0013 ~ 769)
var START_VALUE = 35000; // initial value when it's the start date
var count = 0;
jQuery(document).ready(function($) {
var msInterval = INTERVAL * 1000;
var now = new Date();
count = parseInt((now - START_DATE)/msInterval) * INCREMENT + START_VALUE;
$('#counter').html(count.toFixed(0));
window.setInterval( function(){
count += INCREMENT;
$('#counter').html(count.toFixed(0));
}, msInterval);
});