I have the following js code in a .php file:
var counter = 1;
function loadgame(wait_time) {
var loadtext=document.getElementById( 'progressbarloadtext' ).style;
var percentlimit = <?php echo tiguan_get_option( 'td_bar_textload_limit' ); ?>;
var speedindex = <?php echo tiguan_get_option( 'td_bar_speed' ); ?>;
var percentlimitstatus = "<?php echo tiguan_get_option( 'td_bar_textload_status' ); ?>";
speedindex = speedindex*2;
if ( counter < wait_time) {
counter = counter + 1;
document.getElementById("progressbarloadbg").style.width = counter + "px";
var percentage = Math.round( counter / wait_time * 100);
document.getElementById("progresstext").innerHTML = percentage+" %";
window.setTimeout("loadgame('" + wait_time + "')", speedindex );
if ( (percentage >= percentlimit) & (percentlimitstatus == 1 ) ) {
loadtext.display='block';
}
}
else {
counter = 1;
window.hide();
}
}
function hide() {
var showprogressbar=document.getElementById( 'showprogressbar' ).style;
var loadtext=document.getElementById( 'progressbarloadtext' ).style;
var game = document.getElementById( 'td-game-wrap' ).style;
showprogressbar.display='none';
loadtext.display='none';
game.width = '100%';
game.height = '100%';
counter = 400;
}
Now, this is the code included in a theme-scripts.js file:
jQuery(document).ready(function($) {
setTimeout('loadgame(400)', 0);
});
The loadgame function is defined in the single.php WordPress file.
Inspecting the code with Firebug I get this error:
Uncaught referenceerror loadgame is not defined
Any tips to avoid thie error?
Thanks