// common variable
var pageTab = 0;
var nav = 0;
var page;
var tab;
var xmldoc;
var testChance = 0;
var active = true;
var box;
// define
var submitActive = false;
var optIndex;
var $this;
var temp = "";
var audNav = 0;
var audScroll = 0;
var audName = [];
var audNext = true;
var audPrev = true;
var nextAnim;
var nextAnimflag = 0;
var footerTxt = "Introduction";
var nxt = 1;
var nextAnim = 0;
var storeAns;
var ansRight = 0;
// init
var ansWrong = 0;
// init
var solutionNav = 1;
var eventdata;
var uagent = navigator.userAgent.toLowerCase();
var platformAgent = navigator.platform.toLowerCase();
var timer;
var prev_ena = false;
var next_ena = true;
var audio_ena = true;
var audioFlag = false;
var nextAnim = 0;
var t1;
var t2;
var t3;
var t4;
var t5;
var t6;
var t7;
var t8;
var gameAud = document.getElementById('gameAud');
$(document).ready(function() {
if (navigator.platform == 'iPad' || uagent.search('android') > -1) {
eventdata = 'touchstart';
} else {
eventdata = 'click';
}
$("#page").show();
// page shown
//xmlLoad();// load xml document;
if (navigator.platform == 'iPad') {
//loadAud();
}
$('#header_bg ul li').live(eventdata, function() {
pageTab = $("#header_bg ul li").index(this);
updateHeaderAndFootBg(pageTab);
page = tab[pageTab].getElementsByTagName("section");
nav = 0;
loadContent(pageTab);
});
$("#prev").live(eventdata, function() {
if (prev_ena) {
prevPage();
updateContent();
prevupdatenav1();
prevupdatenav();
//pagenavtabUpdate();
if (pageTab == 0) {
$('#pagination li:eq(0)').show();
}
$('.topStrip1,.main_page').hide();
$('#topic').hide();
}
});
$("#next,.nextAnim").live(eventdata, function() {
if (next_ena) {
enablePrev();
nextPage();
updateContent();
nextupdatenav();
$('#topic').hide();
}
});
$("#pagination li").live(eventdata, function() {
nav = $("#pagination li").index(this);
pageContent(nav);
prevupdatenav();
prevupdatenav1();
nextupdatenav();
});
var gpLength = $('#pagination li').length;
//alert(gpLength);
if (gpLength > 10) {
$('#pagination li:gt(9)').hide();
}
$('#pageText,.topStrip').live(eventdata, function() {
$('#topic').hide();
})
});
function nextupdatenav() {
if (nav > 9) {
$('#pagination li:gt(19)').hide();
}
if (nav > 19) {
$('#pagination li:lt(20)').hide();
$('#pagination li:gt(19)').show();
}
}
function prevupdatenav() {
if (nav < 20 && nav > 10) {
$('#pagination li:lt(9)').hide();
$('#pagination li:gt(9)').show();
$('#pagination li:gt(19)').hide();
}
}
function prevupdatenav1() {
if (nav < 10) {
$('#pagination li:gt(9)').hide();
$('#pagination li:gt(19)').hide();
$('#pagination li:lt(9)').show();
}
}
$('#footlist').live('click', function() {
$('#topic,#cont').show();
});
function updateContent() {
displayState();
updateNav(nav);
pageContent(nav);
}
function updateNav(state) {
nxt = state;
//spanText.innerHTML = state;
footerTxt = $('#topic li').eq(nxt - 1).html();
//updateFooter(footerTxt);
displayState();
}
function updateFooter(txt) {
$('#footlist').html(txt);
}
$('#topic li').live('click', function() {
pageTab = $("#topic li").index(this);
page = tab[pageTab].getElementsByTagName("section");
nav = 0;
loadContent(pageTab);
for ( i = 0; i <= page.length - 1; i++) {
var count = $(".tcount").html(page.length);
}
$('.topStrip1,.main_page').hide();
$('#topic').hide();
});
function updateHeaderAndFootBg(pageTab) {
for (var i = 0; i <= $('#header_bg ul li').length - 1; i++) {
var inactive_menu = 'menu_bg_' + i;
var inactive_menu_normal = 'menu_normal_' + i;
var inactive_foot = 'foot_bg_' + i;
$('.' + inactive_menu).hide();
$('.' + inactive_menu_normal).show();
$('.' + inactive_foot).hide();
};
var menuBg = 'menu_bg_' + pageTab;
var menu_normal = 'menu_normal_' + pageTab;
var foot_bg = 'foot_bg_' + pageTab;
$('.' + menuBg).show();
$('.' + foot_bg).show();
$('.' + menu_normal).hide();
}
function xmlLoad() {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject(Microsoft.XMLHTTP);
}
xmlhttp.open('GET', 'main.xml', false);
xmlhttp.send();
xmldoc = xmlhttp.responseXML;
tab = xmldoc.getElementsByTagName("tab");
loadContent(tab);
}
function loadContent() {
page = tab[pageTab].getElementsByTagName('section');
$("#pagination li").remove();
for ( i = 0; i <= page.length - 1; i++) {
$("#pagination").append("<li>" + eval(i + 1) + "</li>");
var count = $(".tcount").html(page.length);
}
updateHeaderAndFootBg(pageTab);
pageContent(nav);
}
alert(page);
function prevPage() {// previous
if (nav <= 0 && pageTab <= 0) {// section first
nav = 0;
} else {
if (nav <= 0) {
pageTab--;
page = tab[pageTab].getElementsByTagName("section");
nav = page.length - 1;
// start from end
audNav = 0;
$(".count").html(nav + 1);
loadContent();
} else {
nav--;
if (nav < 10) {
$('#pagination li:lt(10)').show();
$('#pagination li:gt(9)').hide();
}
pageContent(nav);
}
}
}
function nextPage() {// next
if (nav >= page.length - 1 && pageTab >= tab.length - 1) {// section end
nav = page.length - 1;
} else {
if (nav >= page.length - 1) {
nav = 0;
// start from begining
//disablePrev();
pageTab++;
loadContent();
} else {
nav++;
if (nav > 9) {
$('#pagination li:lt(10)').hide();
$('#pagination li:gt(9)').show();
}
$(".count").html(nav + 1);
pageContent(nav);
}
}
}
function displayState() {
enablePrev();
enableNext();
if (pageTab == 4 && nav == 19) {
disableNext();
}
}
function showEndText() {
$('#pageText,#pagination').hide();
$("#feedback, #hidebg").hide();
$("#finished").show();
disableButtons();
}
function disableButtons() {
disablePrev();
disableNext();
disableAudio();
}
function enableButtons() {
enablePrev();
enableNext();
enableAudio();
}
function disablePrev() {
$('#prev').removeClass('prev_ena').addClass('prev_dis');
prev_ena = false;
}
function enablePrev() {
$('#prev').removeClass('prev_dis').addClass('prev_ena');
prev_ena = true;
}
function disableNext() {
$('#next').removeClass('next_ena').addClass('next_dis');
next_ena = false;
}
function enableNext() {
$('#next').removeClass('next_dis').addClass('next_ena');
next_ena = true;
}
function disableAudio() {
$('#play').css({
'opacity' : '0.4',
'cursor' : 'default'
});
audio_ena = false;
}
function enableAudio() {
$('#play').css({
'opacity' : '1',
'cursor' : 'pointer'
});
audio_ena = true;
}
function pageContent(nav) {
$(".count").html(nav + 1);
// Content
$("#pagination li").css({
'background' : 'url("images/pageing_bg.png") no-repeat scroll 0 -1px transparent',
'width' : '20px',
'height' : '20px',
'color' : '#000'
});
$("#pagination li:eq(" + nav + ")").css({
'background' : 'url("images/pageing_bg.png") no-repeat scroll 0 -21px transparent',
'width' : '20px',
'height' : '20px',
'color' : '#fff'
});
$("#feedback,#hidebg").empty().hide();
$('#pageText,#pagination').show();
enableButtons();
displayState();
$("#pageText").empty();
// clear the container;
stopNextAnimation();
clearInterval(nextAnim);
if (pageTab == 0 && nav == 0) {
disablePrev();
}
prevupdatenav();
prevupdatenav1();
nextupdatenav();
testChance = 0;
audNav = 0;
// audio play init
clearTimeout(timer);
flagInput = 0;
active = true;
submitActive = false;
// deactivate submit button loads
isDragDropTried5 = 0;
audioFlag = true;
// 03/05/12
contentEmbed();
if (page[nav].hasAttributeNS('', "interaction")) {// check for the interaction
$(".test li").prepend("<input type='radio' name='r1'/>");
}
var audPath = page[nav].getElementsByTagName('audio')[0].getAttribute('path');
// store audio path
if (audPath == 'noAudio') {
gameAudioStop();
disableAudio();
} else {
enableAudio();
audioPlay(uagent);
}
}
function contentEmbed() {
contentArray = page[nav].getElementsByTagName('details')[0].childNodes;
for ( i = 0; i <= contentArray.length - 1; i++) {
if (contentArray[i].nodeType == 1) {
serializerText(contentArray[i], box = "#pageText");
}
}
}
function serializerText(serialStr, box) {// Embed the relative Content
pageStr = (new XMLSerializer()).serializeToString(serialStr);
$(box).append(pageStr);
}
function checkAns(index, nav, $this) {// Activity
if (submitActive) {
storeAns = page[nav].getAttribute('answer');
if (page[nav].getAttribute('chance') == 'yes') {
testChance++;
switch (testChance) {// single choice chance
case 1:
if (index + 1 == storeAns) {
$(".test li").eq(index).attr('class', 'right');
embedFeed( xmlFeedTag = 'postive_feedback');
$("#done").hide();
testChance = 0;
nextAnimation();
} else {
embedFeed( xmlFeedTag = 'negative_feedback');
}
break;
case 2:
if (index + 1 == storeAns) {
$(".test li").eq(index).attr('class', 'right');
embedFeed( xmlFeedTag = 'postive_feedback');
} else {
$(".test li").eq(storeAns - 1).attr('class', 'right');
// Right Answer
embedFeed( xmlFeedTag = 'postive_comments');
}
testChance = 0;
$("#done").hide();
nextAnimation();
break;
}
} else {
/*True or false Script*/
}
}
}
function embedFeed(xmlFeedTag) {// feedback content embed
$("#feedback,#hidebg").empty().hide();
feedArray = page[nav].getElementsByTagName(xmlFeedTag)[0].childNodes;
for ( i = 0; i <= feedArray.length - 1; i++) {
if (feedArray[i].nodeType == 1) {
serializerText(feedArray[i], box = "#feedback");
}
}
timer = setTimeout(function() {
$("#feedback,#hidebg").show();
clearTimeout(timer);
}, 500);
}
function audioPlay(uagent) {
audPath = page[nav].getElementsByTagName('audio')[0].getAttribute('path');
// store audio path
if (audPath.indexOf(",") > 0) {
var audPathStr = audPath.split(',');
// store audio path in voiceText wise
audFile = audPathStr[audNav];
} else {
audFile = audPath;
}
if (navigator.platform == 'iPad') {
$('#gameAud').attr({
src : 'audio/' + audFile + '.mp3',
type : 'audio/mpeg'
});
loadAud();
} else if (uagent.search('android') > -1 || uagent.search('android') > -1 || platformAgent.search('android') > -1 || platformAgent.search('linux') > -1) {
if ($.browser.version > 534) {
$('#gameAud').attr({
src : 'audio/' + audFile + '.mp3',
type : 'audio/mp3'
});
loadAudAndroid();
// playAud();
} else {
var audioNamePath = 'audio/' + audFile + '.mp3';
var audioElement = document.getElementById('gameAud');
audioElement.setAttribute('src', audioNamePath);
audioElement.load();
audioElement.addEventListener("load", function() {
audioElement.play();
audStarted();
}, true);
}
} else if (uagent.search('firefox') > -1) {
$('#gameAud').attr({
src : 'audio/' + audFile + '.ogg',
type : 'audio/ogg'
});
loadAud();
} else {
$('#gameAud').attr({
src : 'audio/' + audFile + '.mp3',
type : 'audio/mpeg'
});
loadAud();
}
$("#audStop").attr({
src : 'images/pause_01.png'
});
}
function loadAud() {
gameAud.load();
gameAud.play();
audStarted();
}
function playAud() {
gameAud.play();
audStarted();
}
function loadAudAndroid() {
gameAud.load();
t = setTimeout(function() {
audStarted();
}, 1000);
}
// audio stop
$("#audStop").toggle(function() {
if (audio_ena) {
$(this).attr({
src : 'images/play_01.png'
});
gameAudioStop();
}
}, function() {
if (audio_ena) {
$(this).attr({
src : 'images/pause_01.png'
});
playAud();
}
});
function gameAudioStop() {
gameAud.pause();
}
window.onload = function() {
gameAud.addEventListener('ended', audEnded, false);
// bind audio ended
gameAud.addEventListener('playing', audStarted, false);
}
setInterval(function() {
if (gameAud.ended == true) {
audEnded();
}
}, 500);
function audioNext() {
enableAudio();
var audPathStr = audPath.split(',');
if (audPath.indexOf(",") > 0 && audPathStr.length > 1) {
if (audNav < audPathStr.length - 1) {
audNav++;
audioPlay(uagent);
}
}
}
function clearTimer() {
clearTimeout(t1);
clearTimeout(t2);
clearTimeout(t3);
clearTimeout(t4);
clearTimeout(t5);
clearTimeout(t6);
clearTimeout(t7);
clearTimeout(t8);
}
function nextAnimation() {
$('.nextAnim').show();
}
function stopNextAnimation() {
$('.nextAnim').hide();
}
var pageTab = 0;
var nav = 0;
var page;
var tab;
var xmldoc;
var testChance = 0;
var active = true;
var box;
// define
var submitActive = false;
var optIndex;
var $this;
var temp = "";
var audNav = 0;
var audScroll = 0;
var audName = [];
var audNext = true;
var audPrev = true;
var nextAnim;
var nextAnimflag = 0;
var footerTxt = "Introduction";
var nxt = 1;
var nextAnim = 0;
var storeAns;
var ansRight = 0;
// init
var ansWrong = 0;
// init
var solutionNav = 1;
var eventdata;
var uagent = navigator.userAgent.toLowerCase();
var platformAgent = navigator.platform.toLowerCase();
var timer;
var prev_ena = false;
var next_ena = true;
var audio_ena = true;
var audioFlag = false;
var nextAnim = 0;
var t1;
var t2;
var t3;
var t4;
var t5;
var t6;
var t7;
var t8;
var gameAud = document.getElementById('gameAud');
$(document).ready(function() {
if (navigator.platform == 'iPad' || uagent.search('android') > -1) {
eventdata = 'touchstart';
} else {
eventdata = 'click';
}
$("#page").show();
// page shown
//xmlLoad();// load xml document;
if (navigator.platform == 'iPad') {
//loadAud();
}
$('#header_bg ul li').live(eventdata, function() {
pageTab = $("#header_bg ul li").index(this);
updateHeaderAndFootBg(pageTab);
page = tab[pageTab].getElementsByTagName("section");
nav = 0;
loadContent(pageTab);
});
$("#prev").live(eventdata, function() {
if (prev_ena) {
prevPage();
updateContent();
prevupdatenav1();
prevupdatenav();
//pagenavtabUpdate();
if (pageTab == 0) {
$('#pagination li:eq(0)').show();
}
$('.topStrip1,.main_page').hide();
$('#topic').hide();
}
});
$("#next,.nextAnim").live(eventdata, function() {
if (next_ena) {
enablePrev();
nextPage();
updateContent();
nextupdatenav();
$('#topic').hide();
}
});
$("#pagination li").live(eventdata, function() {
nav = $("#pagination li").index(this);
pageContent(nav);
prevupdatenav();
prevupdatenav1();
nextupdatenav();
});
var gpLength = $('#pagination li').length;
//alert(gpLength);
if (gpLength > 10) {
$('#pagination li:gt(9)').hide();
}
$('#pageText,.topStrip').live(eventdata, function() {
$('#topic').hide();
})
});
function nextupdatenav() {
if (nav > 9) {
$('#pagination li:gt(19)').hide();
}
if (nav > 19) {
$('#pagination li:lt(20)').hide();
$('#pagination li:gt(19)').show();
}
}
function prevupdatenav() {
if (nav < 20 && nav > 10) {
$('#pagination li:lt(9)').hide();
$('#pagination li:gt(9)').show();
$('#pagination li:gt(19)').hide();
}
}
function prevupdatenav1() {
if (nav < 10) {
$('#pagination li:gt(9)').hide();
$('#pagination li:gt(19)').hide();
$('#pagination li:lt(9)').show();
}
}
$('#footlist').live('click', function() {
$('#topic,#cont').show();
});
function updateContent() {
displayState();
updateNav(nav);
pageContent(nav);
}
function updateNav(state) {
nxt = state;
//spanText.innerHTML = state;
footerTxt = $('#topic li').eq(nxt - 1).html();
//updateFooter(footerTxt);
displayState();
}
function updateFooter(txt) {
$('#footlist').html(txt);
}
$('#topic li').live('click', function() {
pageTab = $("#topic li").index(this);
page = tab[pageTab].getElementsByTagName("section");
nav = 0;
loadContent(pageTab);
for ( i = 0; i <= page.length - 1; i++) {
var count = $(".tcount").html(page.length);
}
$('.topStrip1,.main_page').hide();
$('#topic').hide();
});
function updateHeaderAndFootBg(pageTab) {
for (var i = 0; i <= $('#header_bg ul li').length - 1; i++) {
var inactive_menu = 'menu_bg_' + i;
var inactive_menu_normal = 'menu_normal_' + i;
var inactive_foot = 'foot_bg_' + i;
$('.' + inactive_menu).hide();
$('.' + inactive_menu_normal).show();
$('.' + inactive_foot).hide();
};
var menuBg = 'menu_bg_' + pageTab;
var menu_normal = 'menu_normal_' + pageTab;
var foot_bg = 'foot_bg_' + pageTab;
$('.' + menuBg).show();
$('.' + foot_bg).show();
$('.' + menu_normal).hide();
}
function xmlLoad() {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject(Microsoft.XMLHTTP);
}
xmlhttp.open('GET', 'main.xml', false);
xmlhttp.send();
xmldoc = xmlhttp.responseXML;
tab = xmldoc.getElementsByTagName("tab");
loadContent(tab);
}
function loadContent() {
page = tab[pageTab].getElementsByTagName('section');
$("#pagination li").remove();
for ( i = 0; i <= page.length - 1; i++) {
$("#pagination").append("<li>" + eval(i + 1) + "</li>");
var count = $(".tcount").html(page.length);
}
updateHeaderAndFootBg(pageTab);
pageContent(nav);
}
alert(page);
function prevPage() {// previous
if (nav <= 0 && pageTab <= 0) {// section first
nav = 0;
} else {
if (nav <= 0) {
pageTab--;
page = tab[pageTab].getElementsByTagName("section");
nav = page.length - 1;
// start from end
audNav = 0;
$(".count").html(nav + 1);
loadContent();
} else {
nav--;
if (nav < 10) {
$('#pagination li:lt(10)').show();
$('#pagination li:gt(9)').hide();
}
pageContent(nav);
}
}
}
function nextPage() {// next
if (nav >= page.length - 1 && pageTab >= tab.length - 1) {// section end
nav = page.length - 1;
} else {
if (nav >= page.length - 1) {
nav = 0;
// start from begining
//disablePrev();
pageTab++;
loadContent();
} else {
nav++;
if (nav > 9) {
$('#pagination li:lt(10)').hide();
$('#pagination li:gt(9)').show();
}
$(".count").html(nav + 1);
pageContent(nav);
}
}
}
function displayState() {
enablePrev();
enableNext();
if (pageTab == 4 && nav == 19) {
disableNext();
}
}
function showEndText() {
$('#pageText,#pagination').hide();
$("#feedback, #hidebg").hide();
$("#finished").show();
disableButtons();
}
function disableButtons() {
disablePrev();
disableNext();
disableAudio();
}
function enableButtons() {
enablePrev();
enableNext();
enableAudio();
}
function disablePrev() {
$('#prev').removeClass('prev_ena').addClass('prev_dis');
prev_ena = false;
}
function enablePrev() {
$('#prev').removeClass('prev_dis').addClass('prev_ena');
prev_ena = true;
}
function disableNext() {
$('#next').removeClass('next_ena').addClass('next_dis');
next_ena = false;
}
function enableNext() {
$('#next').removeClass('next_dis').addClass('next_ena');
next_ena = true;
}
function disableAudio() {
$('#play').css({
'opacity' : '0.4',
'cursor' : 'default'
});
audio_ena = false;
}
function enableAudio() {
$('#play').css({
'opacity' : '1',
'cursor' : 'pointer'
});
audio_ena = true;
}
function pageContent(nav) {
$(".count").html(nav + 1);
// Content
$("#pagination li").css({
'background' : 'url("images/pageing_bg.png") no-repeat scroll 0 -1px transparent',
'width' : '20px',
'height' : '20px',
'color' : '#000'
});
$("#pagination li:eq(" + nav + ")").css({
'background' : 'url("images/pageing_bg.png") no-repeat scroll 0 -21px transparent',
'width' : '20px',
'height' : '20px',
'color' : '#fff'
});
$("#feedback,#hidebg").empty().hide();
$('#pageText,#pagination').show();
enableButtons();
displayState();
$("#pageText").empty();
// clear the container;
stopNextAnimation();
clearInterval(nextAnim);
if (pageTab == 0 && nav == 0) {
disablePrev();
}
prevupdatenav();
prevupdatenav1();
nextupdatenav();
testChance = 0;
audNav = 0;
// audio play init
clearTimeout(timer);
flagInput = 0;
active = true;
submitActive = false;
// deactivate submit button loads
isDragDropTried5 = 0;
audioFlag = true;
// 03/05/12
contentEmbed();
if (page[nav].hasAttributeNS('', "interaction")) {// check for the interaction
$(".test li").prepend("<input type='radio' name='r1'/>");
}
var audPath = page[nav].getElementsByTagName('audio')[0].getAttribute('path');
// store audio path
if (audPath == 'noAudio') {
gameAudioStop();
disableAudio();
} else {
enableAudio();
audioPlay(uagent);
}
}
function contentEmbed() {
contentArray = page[nav].getElementsByTagName('details')[0].childNodes;
for ( i = 0; i <= contentArray.length - 1; i++) {
if (contentArray[i].nodeType == 1) {
serializerText(contentArray[i], box = "#pageText");
}
}
}
function serializerText(serialStr, box) {// Embed the relative Content
pageStr = (new XMLSerializer()).serializeToString(serialStr);
$(box).append(pageStr);
}
function checkAns(index, nav, $this) {// Activity
if (submitActive) {
storeAns = page[nav].getAttribute('answer');
if (page[nav].getAttribute('chance') == 'yes') {
testChance++;
switch (testChance) {// single choice chance
case 1:
if (index + 1 == storeAns) {
$(".test li").eq(index).attr('class', 'right');
embedFeed( xmlFeedTag = 'postive_feedback');
$("#done").hide();
testChance = 0;
nextAnimation();
} else {
embedFeed( xmlFeedTag = 'negative_feedback');
}
break;
case 2:
if (index + 1 == storeAns) {
$(".test li").eq(index).attr('class', 'right');
embedFeed( xmlFeedTag = 'postive_feedback');
} else {
$(".test li").eq(storeAns - 1).attr('class', 'right');
// Right Answer
embedFeed( xmlFeedTag = 'postive_comments');
}
testChance = 0;
$("#done").hide();
nextAnimation();
break;
}
} else {
/*True or false Script*/
}
}
}
function embedFeed(xmlFeedTag) {// feedback content embed
$("#feedback,#hidebg").empty().hide();
feedArray = page[nav].getElementsByTagName(xmlFeedTag)[0].childNodes;
for ( i = 0; i <= feedArray.length - 1; i++) {
if (feedArray[i].nodeType == 1) {
serializerText(feedArray[i], box = "#feedback");
}
}
timer = setTimeout(function() {
$("#feedback,#hidebg").show();
clearTimeout(timer);
}, 500);
}
function audioPlay(uagent) {
audPath = page[nav].getElementsByTagName('audio')[0].getAttribute('path');
// store audio path
if (audPath.indexOf(",") > 0) {
var audPathStr = audPath.split(',');
// store audio path in voiceText wise
audFile = audPathStr[audNav];
} else {
audFile = audPath;
}
if (navigator.platform == 'iPad') {
$('#gameAud').attr({
src : 'audio/' + audFile + '.mp3',
type : 'audio/mpeg'
});
loadAud();
} else if (uagent.search('android') > -1 || uagent.search('android') > -1 || platformAgent.search('android') > -1 || platformAgent.search('linux') > -1) {
if ($.browser.version > 534) {
$('#gameAud').attr({
src : 'audio/' + audFile + '.mp3',
type : 'audio/mp3'
});
loadAudAndroid();
// playAud();
} else {
var audioNamePath = 'audio/' + audFile + '.mp3';
var audioElement = document.getElementById('gameAud');
audioElement.setAttribute('src', audioNamePath);
audioElement.load();
audioElement.addEventListener("load", function() {
audioElement.play();
audStarted();
}, true);
}
} else if (uagent.search('firefox') > -1) {
$('#gameAud').attr({
src : 'audio/' + audFile + '.ogg',
type : 'audio/ogg'
});
loadAud();
} else {
$('#gameAud').attr({
src : 'audio/' + audFile + '.mp3',
type : 'audio/mpeg'
});
loadAud();
}
$("#audStop").attr({
src : 'images/pause_01.png'
});
}
function loadAud() {
gameAud.load();
gameAud.play();
audStarted();
}
function playAud() {
gameAud.play();
audStarted();
}
function loadAudAndroid() {
gameAud.load();
t = setTimeout(function() {
audStarted();
}, 1000);
}
// audio stop
$("#audStop").toggle(function() {
if (audio_ena) {
$(this).attr({
src : 'images/play_01.png'
});
gameAudioStop();
}
}, function() {
if (audio_ena) {
$(this).attr({
src : 'images/pause_01.png'
});
playAud();
}
});
function gameAudioStop() {
gameAud.pause();
}
window.onload = function() {
gameAud.addEventListener('ended', audEnded, false);
// bind audio ended
gameAud.addEventListener('playing', audStarted, false);
}
setInterval(function() {
if (gameAud.ended == true) {
audEnded();
}
}, 500);
function audioNext() {
enableAudio();
var audPathStr = audPath.split(',');
if (audPath.indexOf(",") > 0 && audPathStr.length > 1) {
if (audNav < audPathStr.length - 1) {
audNav++;
audioPlay(uagent);
}
}
}
function clearTimer() {
clearTimeout(t1);
clearTimeout(t2);
clearTimeout(t3);
clearTimeout(t4);
clearTimeout(t5);
clearTimeout(t6);
clearTimeout(t7);
clearTimeout(t8);
}
function nextAnimation() {
$('.nextAnim').show();
}
function stopNextAnimation() {
$('.nextAnim').hide();
}
No comments:
Post a Comment