home *** CD-ROM | disk | FTP | other *** search
/ Orthodox Religion Class (2nd Semester) / ReligieCls1Sem2.iso / js / Main.js < prev    next >
Encoding:
JavaScript  |  2015-10-02  |  18.1 KB  |  595 lines

  1. var Page;
  2. var tdX = 0;
  3. var manifest = [];
  4. var queue;
  5. var localDates;
  6. var audioPath = "sounds/";
  7. var gd = new GameDates();
  8. var indexPage = 0;
  9. var pagesVisited = [ 1 ];
  10. var gamesVisited = [];
  11. var isVisited = false;
  12. var speedPage = 1000;
  13. // stage dimensions
  14. var ow = 3134; // 3050 your stage width
  15. var oh = 1974; // 1986your stage height
  16. var w;
  17. var h;
  18. var scale;
  19. var scaleP;
  20. var player;
  21. var videoPlayer;
  22. var soundsCommon = {};
  23. var imagesCommon = {};
  24. var pageWithoutNumber = 2;
  25. var timeOut = 1500;
  26. $(function() {///localStorage.clear();sessionStorage.clear();
  27.         
  28.     if ((navigator.platform.indexOf("iPhone") != -1)
  29.             || (navigator.platform.indexOf("iPad") != -1)) {
  30.         w = $(window).width();// screen.width;
  31.         h = $(window).height();// screen.height;
  32.     } else {
  33.         w = screen.width;
  34.         h = screen.height;
  35.     }
  36.  
  37.     scale = Math.min(w / ow, h / oh) - (Math.min(w / ow, h / oh) / 6);
  38.     scaleP = Math.min(w / ow, h / oh);
  39.     initImages();
  40.     initSounds();
  41.  
  42.     $("#showImage").dialog({
  43.         closeOnEscape: false,
  44.         autoOpen : false,
  45.         show : {
  46.             effect : "clip",
  47.             duration : 500
  48.         },
  49.         hide : {
  50.             effect : "clip",
  51.             duration : 500
  52.         },
  53.         modal : true,
  54.         resizable : false,
  55.         draggable : false,
  56.         width : 485,
  57.         height : 320,
  58.     });
  59.     $(".ui-dialog-titlebar").hide();
  60.  
  61.     function initSounds() {
  62.         manifest = gd.sounds;
  63.  
  64.         for (var i = 0; i < gd.sounds.length; i++) {
  65.             soundsCommon[gd.sounds[i].id] = "sounds/" + gd.sounds[i].src;
  66.         }
  67.         init();
  68.     }
  69.     function initImages() {
  70.         for (var i = 0; i < gd.images.length; i++) {
  71.             imagesCommon[gd.images[i].id] = gd.images[i].src;
  72.         }
  73.     }
  74.     
  75.     function init() {
  76.         $("#bb-bookblock")
  77.                 .append(
  78.                         "<div class='bb-item' style=\"position:absolute;\" id='bb-item1'>"
  79.                                 + "<table id='tab0' style=\"position:absolute;\">"
  80.                                 + "<tr>"
  81.                                 + "<td>"
  82.                                 + "<img id='pageImage1' src='' style='position:relative;left:36px;' alt='image02'/>"
  83.                                 + "</td>"
  84.                                 + "<td id='tdUmbra0' >"
  85.                                 + "</td>"
  86.                                 + "<td>"
  87.                                 + "<img  id='pageImage2' style='position:relative;right:44px;' src='' "
  88.                                 + " alt='image02'/>" + "</td>" + "</tr>"
  89.                                 + "</table>" + "</div>");
  90.  
  91.         $("#tab0").append("<img id='imgg' src='images/butoane_main/rama.png'"
  92.                                 + " style='position:absolute;left:0px;z-index:-1;top:6px;width:3109px' alt='image02'/>");
  93.         $("#tdUmbra0").append("<img id='umbra"
  94.                                 + "' src='images/butoane_main/umbra.png'"
  95.                                 + " style='position:relative;left:-4px;top:6px;z-index:2;' alt='image02'/>");
  96.  
  97.         $("#slider").slider({
  98.             value : 2,
  99.             min : 1,
  100.             max : 8,
  101.             step : 1,
  102.             slide : function(event, ui) {
  103.             }
  104.         });
  105.         $("#viewPage").val("");
  106.         initPage(gd, 0);
  107.         resize(2);
  108.         $("#bb-bookblock").attr("align", "right");
  109.  
  110.         
  111.  
  112.         var maxPage = (gd.main.pages.length * 2) - pageWithoutNumber;
  113.         $("#spanMaxPage").html("/" + (gd.main.maxPage));
  114.  
  115.         $("#next,#next1").click(function() {
  116.             if (indexPage < Math.round((maxPage + pageWithoutNumber) / 2)) {
  117.                 indexPage++;
  118.                 putPageNumber(indexPage);
  119.             }
  120.             initPag(indexPage);
  121.             if(indexPage==34){
  122.                 $("#avatar").remove();
  123.         }
  124.         });
  125.         
  126.         $("#prev,#prev1").click(function() {
  127.             if (indexPage > 0) {
  128.                 indexPage--;
  129.                 putPageNumber(indexPage);
  130.             }
  131.             initPag(indexPage);
  132.         });
  133.         $("#first").click(function() {
  134.             indexPage = 0;
  135.             putPageNumber(indexPage);
  136.             initPag(indexPage);
  137.         });
  138.         $("#last").click(function() {
  139.             //indexPage = ((gd.main.maxPage==64)?33:34);
  140.             indexPage = Math.round((maxPage + pageWithoutNumber) / 2);
  141.             putPageNumber(indexPage);
  142.             initPag(indexPage);
  143.             $("#avatar").remove();
  144.             
  145.         });
  146.         
  147.         
  148.         $("#viewPage").keypress(function(event) {
  149.                if (event.which == 13) {
  150.                 if ($("#viewPage").val() * 1 <= gd.main.maxPage) {
  151.                  indexPage = Math.round(($("#viewPage").val() * 1 + 1) / 2);
  152.                  initPag(indexPage);
  153.                 }
  154.                }
  155.               });
  156.             
  157.  
  158.         $("#btnMinus").click(function() {
  159.             reseizeStage(-1);
  160.         });
  161.         $("#btnPlus").click(function() {
  162.             reseizeStage(+1);
  163.         });
  164.  
  165.         function reseizeStage(index) {
  166.             if (!(($('#slider').slider("value")) == 8 && index == 1)
  167.                     && !(($('#slider').slider("value")) == 1 && index == -1)) {
  168.                 $('#slider').slider('value',
  169.                         $('#slider').slider("value") + index);
  170.                 $('#mySlider').html(getSlider($('#slider').slider("value")));
  171.                 resize($('#slider').slider("value"));
  172.             }
  173.         }
  174.  
  175.         function getSlider(index) {
  176.             var text = "";
  177.             for (var i = 0; i < index; i++)
  178.                 text += "-";
  179.             return text;
  180.         }
  181.  
  182.         $("#gameDialog").dialog({
  183.             closeOnEscape: false,
  184.             autoOpen : false,
  185.             position : [ 'midle', 0 ],
  186.             modal : true,
  187.             resizable : false,
  188.             draggable : false,
  189.             width : w - 5,
  190.             height : h - 101
  191.         });
  192.  
  193.         $(".ui-dialog-background ").removeClass("ui-dialog-background ");
  194.         $(".ui-dialog").css("padding", "0px");
  195.         $(".ui-dialog").css("border", "0px");
  196.         $(".ui-dialog-titlebar").remove();
  197.  
  198.         $("div.ui-dialog-titlebar").remove();
  199.  
  200.         $("#windowGameBackground").css("width", (ow * scale) + "px");
  201.         $("#windowGameBackground").css("height", (oh * scale) + "px");
  202.         $("#windowGameBackground").css("left", (w - ow * scale) / 2 + "px");
  203.         $("#windowGameBackground").css("top", (50*scale)+ "px");
  204.         
  205.         $("#windowGameBackgroundStatic").css("width", (ow * scale) + "px");
  206.         $("#windowGameBackgroundStatic").css("height", (oh * scale) + "px");
  207.         $("#windowGameBackgroundStatic").css("left", (w - ow * scale) / 2 + "px");
  208.         $("#windowGameBackgroundStatic").css("top", (50*scale)+ "px");
  209.         
  210.         $("#gameDiv").css("width", (ow * scale) + "px");
  211.         $("#gameDiv").css("height", (oh * scale) + "px");
  212.         $("#gameDiv").css("left", (w - ow * scale) / 2 + "px");
  213.         $("#gameDiv").css("top", (50*scale)+ "px");
  214.         
  215.         
  216.         $("#background_buttons").css("left", (w - 1012) / 2 + "px");
  217.         $("#header").css("left", (w - 1012) / 2 + "px");
  218.  
  219.         $(".ui-dialog").css("z-index", "100000");
  220.  
  221.     }
  222.     $("#rezultate").click(function() {
  223.         $("#pageImage1").attr("src", "images/pagina/pg_alba.jpg");
  224.         $("#pageImage2").attr("src", "images/pagina/pg_alba.jpg");
  225.         $("#bodyDiv").empty();
  226.         $("#blanket").remove();
  227.         new Util().getResult();
  228.         $("#closeBtnResult").click(function() {
  229.             initPag(indexPage);
  230.             //console.log("indexPage1="+indexPage);
  231.             if(indexPage==34){//remove avatar
  232.                 //console.log("indexPage="+indexPage);
  233.                 $("#avatar").remove();
  234.             }
  235.         });
  236.     });
  237.     $("#cuprins").click(function() {
  238.         indexPage=2;
  239.         putPageNumber(2);
  240.         initPag(2);
  241.     });
  242.     function resize(mySlider) {
  243.         mySlider += -3;
  244.         scaleP = Math.min(w / ow, h / oh) + (mySlider / 36);
  245.         tdX = ((w - (ow * scaleP)) / 2);
  246.         $("#bb-bookblock").css("-webkit-transform", "scale(" + scaleP + ")");
  247.         $("#bb-bookblock").css("transform", "scale(" + scaleP + ")");
  248.         if(mySlider<1)
  249.         $("#bb-bookblock").css("left", tdX + "px");
  250.         $("#headerDiv").css("left", "222px");
  251.  
  252.         var indent = 0;
  253.         if ((w - ow) > 0)
  254.             indent = ((w - ow) / 2) * 1;
  255.         $("#headerDiv").css("left", indent + "px");
  256.     }
  257.  
  258.     function initPage(gd, page) {
  259.         $("#bodyDiv").empty();
  260.         $("#bodyDiv").css("display", "none");
  261.         if( page == 0 || page == 34 ){
  262.             $("#tab0").hide();
  263.             $("#blanket").remove();
  264.             if($("#blanket").length==0){
  265.                 $("#bb-item1").append("<div id='blanket' style='cursor:pointer;width:2200px;align:center'>" +
  266.                     "<img  width=1567 height=1975 src='"+((page == 0)?gd.main.coperta:gd.main.coperta1)+"'></div>");
  267.                 if(page==0){
  268.                     $("#blanket").click(function(event) {
  269.                         indexPage=1;
  270.                         putPageNumber(1);
  271.                         initPag(1);
  272.                     });
  273.                 }
  274.             }
  275.             $("#viewPage").val("");
  276.         }else{
  277.             $("#blanket").remove();
  278.             $("#tab0").show();
  279.         var indexPage1 = page - 1;
  280.         var currentPage = gd.main.pages[indexPage1];
  281.         $("#pageImage1").attr("src", currentPage.pageImage);
  282.         $("#pageImage2").attr("src", currentPage.pageImage2);
  283.         if (currentPage.games !== undefined) {
  284.             for (var i = 0; i < currentPage.games.length; i++) {
  285.                 $("#bodyDiv").append("<img id='gamePage"+ i+ "'" +
  286.                         "class="+((currentPage.games[i].classCss==null)?"btn_games":currentPage.games[i].classCss) +
  287.                         " style='z-index:4000; position: absolute; "
  288.                             + setStyle(currentPage.games[i])
  289.                             + "'/>" );
  290.                 var game = {indexPage:indexPage1, id:i, type:"games"};
  291.                 $("#gamePage" + i).attr("value", JSON.stringify(game));
  292.                 
  293.                 $("#gamePage" + i).click(function(event) {
  294.                     if (currentPage.inputs !== undefined && currentPage.inputs !== null){
  295.                         if(util.checkRights(JSON.parse($(this).attr("value")).id)===false){
  296.                             event.stopPropagation();
  297.                             startGame(JSON.parse($(this).attr("value")));
  298.                         }
  299.                     }else{
  300.                         event.stopPropagation();
  301.                         startGame(JSON.parse($(this).attr("value")));
  302.                     }
  303.                 });
  304.             }
  305.         }
  306.         if (currentPage.btnImages !== undefined) {
  307.             for (var i = 0; i < currentPage.btnImages.length; i++) {
  308.                 $("#bodyDiv").append("<div class="+currentPage.btnImages[i].classCss +
  309.                         " style='z-index:4;position: absolute; "
  310.                             + setStyle(currentPage.btnImages[i])+ "'/>" );
  311.             }
  312.         }
  313.         
  314. ///    begin    
  315.     /*    $("#bodyDiv").append("<div id='ccc' style='position:absolute;z-index:1000;top:-100px;left:-100px;width:100px;height:100px;border-style:solid'>")    ;
  316.         var click = {
  317.             x: 0,
  318.             y: 0
  319.         };    
  320.         $("#ccc").resizable({  
  321.             resize: function( event, ui ) {
  322.                 $(this).css("width",ui.size.width+"px");
  323.                 $(this).css("height",ui.size.height+"px");
  324.         }});
  325.         //x : 940,y : 160,width : 400,height : 100,
  326.         $("#ccc").dblclick(function(e) {
  327.             console.log("x:"+Math.round(($(this)).offset().left/scaleP-$("#tab0").offset().left/scaleP)+",",
  328.                     "y:"+Math.round(($(this)).offset().top/scaleP-$("#tab0").offset().top/scaleP)+",",
  329.                     "width:"+($(this)).width()+",",
  330.                     "height:"+($(this)).height()+","
  331.                     //,"classCss:"+"\"btn_img1\"" 
  332.                     );
  333.          });
  334.         
  335.             $("#ccc").draggable({start: function(event) {
  336.                 click.x = event.clientX;
  337.                 click.y = event.clientY;
  338.             },
  339.  
  340.             drag: function(event, ui) {
  341.  
  342.                 // This is the parameter for scale()
  343.                 var zoom = scaleP;
  344.  
  345.                 var original = ui.originalPosition;
  346.  
  347.                 // jQuery will simply use the same object we alter here
  348.                 ui.position = {
  349.                     left: (event.clientX - click.x + original.left) / zoom,
  350.                     top:  (event.clientY - click.y + original.top ) / zoom
  351.                 };
  352.  
  353.          }});*/
  354. //end        
  355.         
  356.         if (currentPage.cuprins !== undefined) {
  357.             for (var i = 0; i < currentPage.cuprins.length; i++) {
  358.             $("#bodyDiv")
  359.             .append(
  360.             "<img id='cuprins"+i+"'class='btn_games' style='z-index: 3999; position: absolute; "
  361.             + setStyle(currentPage.cuprins[i])
  362.             + " ' value='"
  363.             + JSON.stringify(currentPage.cuprins[i].pageNumber)
  364.             + "'/>");
  365.             $("#cuprins"+i).click(function(event) {
  366.                 indexPage = JSON.parse($(this).attr("value"));
  367.                 putPageNumber(indexPage);
  368.                 initPag(indexPage);
  369.             });
  370.             }
  371.         }
  372.             
  373.         if (currentPage.videos !== undefined) {
  374.              for (var i = 0; i < currentPage.videos.length; i++) {
  375.                  $("#bodyDiv").append(
  376.                  "<button id='video"+i+"' class='btn_games' style='z-index: 4000; position: absolute; "
  377.                  + setStyle(currentPage.videos[i])
  378.                  + "' ></button>");
  379.                  var video = {indexPage:indexPage1, id:i, type:"videos"};
  380.                  $("#video" + i).attr("value",JSON.stringify(video));
  381.                  $("#video"+i).click(function(event) {
  382.                      event.stopPropagation();
  383.                      startGame(JSON.parse($(this).attr("value")));
  384.                  });
  385.              }
  386.         }
  387.         
  388.         if (currentPage.inputs !== undefined && currentPage.inputs != null) {
  389.              for (var i = 0; i < currentPage.inputs.length-1; i++) {
  390.                  $("#bodyDiv").append(
  391.                  "<div id='divEvl"+i+"' style='width:100px;height:100px;z-index: 3999;" +
  392.                          "backgroud:red;font-size:62px; position: absolute; "
  393.                  + setStyle(currentPage.inputs[i])
  394.                  + "' ></div>");
  395.              }
  396.              util.getPageResultEval(currentPage);
  397.              $("#bodyDiv").append(
  398.                      "<button id='btndivEvl' class='reset'"+ 
  399.                      "style='z-index: 3999;" +
  400.                              " position: absolute; "
  401.                      + setStyle(currentPage.inputs[5])
  402.                      + "' ></div>");
  403.              $("#btndivEvl").click(function(){
  404.                  util.newEvl();
  405.              });
  406.         }
  407.         
  408.  
  409.          $("#bodyDiv").append("<img src='images/logo/avatar.gif' id='avatar' style='position:absolute;z-index;19999;top:1500px;left:1400px;'" +
  410.                   " width=330px;height=330px/>");         
  411.         if (currentPage.corner !== undefined && currentPage.corner === true) {
  412.             $("#tab0").append(
  413.                     "<div id='corner_left_up' corner='' class='corner_left_up' "
  414.                             + " value='prev'></div>");
  415.             $("#tab0").append(
  416.                     "<div id='corner_left_down' corner=''class='corner_left_down'"
  417.                             + " value='prev'> </div>");
  418.             $("#tab0").append(
  419.                     "<div id='corner_right_up' corner='' class='corner_right_up'"
  420.                             + " value='next'> </div>");
  421.             $("#tab0").append(
  422.                     "<div id='corner_right_down' corner='' class='corner_right_down'"
  423.                             + " value='next'> </div>");
  424.             $("*[corner]").click(function(event) {
  425.                 $('#' + $(this).attr("value")).click();
  426.             });
  427.         }
  428.         }
  429.         $("#bodyDiv").delay(speedPage).fadeIn();
  430.     }
  431.  
  432.     function setStyle(dates) {
  433.         var styles = "";
  434.         if (dates.width !== undefined) {
  435.             styles = "width:" + dates.width + "px;";
  436.         }
  437.         if (dates.height !== undefined) {
  438.             styles += "height:" + dates.height + "px;";
  439.         }
  440.         if (dates.y !== undefined) {
  441.             styles += "top:" + dates.y + "px;";
  442.         }
  443.         if (dates.x !== undefined) {
  444.             styles += "left:" + dates.x + "px;";
  445.         }
  446.         if (dates.image !== undefined) {
  447.             styles += "background:url('" + dates.image
  448.                     + "');background-repeat: no-repeat;";
  449.         }
  450.         return styles;
  451.     }
  452.     util.validateInputNumber($("#viewPage"));
  453.     
  454.     
  455.     function putPageNumber(indexPage) {
  456.         if (indexPage * 2 - pageWithoutNumber == -2)
  457.             $("#viewPage").val("");
  458.         else if (indexPage * 2 - pageWithoutNumber == 0)
  459.             $("#viewPage").val("1");
  460.         else
  461.             $("#viewPage").val(indexPage * 2 - pageWithoutNumber);
  462.     }
  463.     function initPag(page) {
  464.         $("#bodyDiv").empty();
  465.         $("*[corner]").remove();
  466.         initPage(gd, page);
  467.     }
  468.     
  469. loginUser();
  470.     
  471. function loginUser(){
  472.         
  473.         var localStorage = new MyLocalStorage();
  474.         var sessionStorage = new MySessionStorage();
  475.         if(sessionStorage.getItem(gd.keys.userSession) == null){
  476.             if(localStorage.getItem(gd.keys.allUsers)!=null){
  477.                 $("#divForm").append("<b>Selecteaz─â un nume existent:</b> <select id='combo' class='inputName'></select>"+
  478.                 " <input type=button id='loginSelect' class='btn_login' value='Intr─â'/><br><br><br><br>");
  479.                 $.each(JSON.parse(localStorage.getItem(gd.keys.allUsers)), function(key, value){
  480.                     $("#combo").append("<option>"+key+"</option>");
  481.                 });
  482.             }
  483.  
  484.             $("#divForm").append("<b>Introdu numele t─âu</b>    <br><b>Nume:</b> <input type='text' class='inputName' id='idInputName'>" +
  485.             " <input type=button id='saveName' class='btn_login' value='Intr─â'/><br><br>");
  486.         }else{
  487.             $("#divForm").prepend("<br><b>Bine ai venit, "+sessionStorage.getItem(gd.keys.userSession) + 
  488.             "!</b>  <input type=button id='login' class='btn_login' value='Intr─â'/><br><br><br>");
  489.  
  490.             $("#divForm").append("<b>Selecteaz─â un nume existent:</b> <select id='combo' class='inputName'></select>  <input type=button id='loginSelect' class='btn_login' value='Intr─â'/>");
  491.             
  492.             $("#divForm").append("<br><br><b>Introdu numele t─âu:</b>    <br><b>Nume:</b> <input type='text' class='inputName' id='idInputName'>" +
  493.             "  <input type=button id='saveName' class='btn_login' value='Intr─â'/><br><br>");
  494.             
  495.             $.each(JSON.parse(localStorage.getItem(gd.keys.allUsers)), function(key, value){
  496.                 $("#combo").append("<option>"+key+"</option>");
  497.             });
  498.         }
  499.  
  500.         $("#login").click(function(){
  501.             $( "#divForm" ).dialog("close");
  502.             $( "#userName" ).text("Bine ai venit, " + sessionStorage.getItem(gd.keys.userSession));
  503.         });
  504.  
  505.         $("#loginSelect").click(function(){
  506.             sessionStorage.setItem(gd.keys.userSession, $('#combo :selected').text() );
  507.             $( "#userName" ).text("Bine ai venit, " + $('#combo :selected').text());
  508.             $( "#divForm" ).dialog("close");
  509.             initPag(indexPage);
  510.         });
  511.         
  512.  
  513.         
  514.  
  515.         $("#saveName").click(function(){
  516.             var user = $("#idInputName").val();
  517.             if(user == ""){
  518.                 alert("Trebuie s─â introduci numele t─âu!");
  519.             }else{
  520.                 allUsers = localStorage.getItem(gd.keys.allUsers);
  521.                 myUsers = {};
  522.                 if(allUsers != null)
  523.                     myUsers = JSON.parse(allUsers);
  524.                 if(myUsers[user]!=null){
  525.                     alert("Acest nume exist─â deja!");
  526.                 }else{    
  527.                     myUsers[user] = new Date();
  528.                     localStorage.setItem(gd.keys.allUsers, JSON.stringify(myUsers));
  529.                 }
  530.                 sessionStorage.setItem(gd.keys.userSession, user);
  531.                 $( "#divForm" ).dialog("close");
  532.                 $( "#userName" ).text("Bine ai venit, " + user);
  533.             }
  534.             initPag(indexPage);
  535.         });
  536.  
  537.         $( "#divForm" ).dialog({
  538.             closeOnEscape: false,
  539.             height: 340,
  540.             width:650,
  541.             buttons: null,
  542.             modal: true
  543.  
  544.         });
  545.         $("div.ui-dialog-titlebar").remove();
  546.         
  547.     }
  548.     $("#userName").click(function(){
  549.         $( "#divForm" ).empty();
  550.         $( "#divForm" ).dialog("open");
  551.         loginUser();
  552.     });
  553. //    function startGame(params) {
  554. //        var val = gd.main.pages[params.indexPage][params.type][params.id];
  555. //        switch (val.name) {
  556. //            case "video":
  557. //                new VideoPlayer(val.gameInstance);
  558. //            break;
  559. //            default :
  560. //                new window[val.name](val.gameInstance);
  561. //        }
  562. //    }
  563.     function startGame(params) {
  564.         var val = gd.main.pages[params.indexPage][params.type][params.id];
  565.         switch (val.name) {
  566.         case "audio":
  567.                 if($("#gameDiv").length==1 ){
  568.                      $("#gameDiv").append("<audio controls id='player' style='display:none'>" +
  569.                       "<source src='' type='audio/mpeg' ></audio>");
  570.                       player = new MediaElement('player', {});
  571.                 }
  572.                playSound(val.srcAudio);
  573.                break;    
  574.             case "video":
  575.                 new VideoPlayer(val.gameInstance);
  576.             break;
  577.             default :
  578.                 sarcina = val.gameInstance.sarcina;
  579.                 new window[val.name](val.gameInstance);
  580.         }
  581.     }
  582.  
  583. });
  584. function playSound(soundName) {
  585.     player.pause();
  586.     player.setSrc(soundName);
  587.     player.play();
  588. }
  589. function removeAllSound(soundName) {
  590.     $( "#player").remove();
  591.      $("#gameDiv").append("<audio controls id='player' style='display:none'>" +
  592.         "<source src='' type='audio/mpeg' ></audio>");
  593.      player = new MediaElement('player', {});
  594. }
  595.