Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var audio = document.getElementById('myAudio');
- var source = document.getElementById('audioSource');
- var CurrentIndex;
- // populate all pics
- var allImages = ''
- for (i = 0; i < 12; i++) {
- var eachPic =
- '<div class="col-sm-4" id="Pic' + i + '" onclick="flipOver(' + i + ')">'
- eachPic += '<img src="Pictures/' + i + '1.png"></div>'
- allImages += eachPic
- }
- document.getElementById('allpics').innerHTML = allImages
- function playAudio(index) {
- source.src = "Audio/" + index + "2.mp3";
- audio.load();
- audio.play();
- }
- function flipOver(index) {
- var name = (document.getElementById("Pic" + index).innerHTML).trim();
- var vertxt = '<img src="Pictures/' + index + '1.png">';
- var verimg = '<img src="Pictures/' + index + '0.jpg">';
- if (name[name.length - 7] == "1") {
- document.getElementById("Pic" + index).innerHTML = verimg
- setTimeout(FlipBack, 3000, index);
- CurrentIndex = index;
- playAudio(index);
- }
- }
- function FlipBack(Num) {
- var vertxt = '<img src="Pictures/' + Num + '1.png">';
- document.getElementById("Pic" + Num).innerHTML = vertxt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement