home *** CD-ROM | disk | FTP | other *** search
/ Orthodox Religion Class (2nd Semester) / ReligieCls1Sem2.iso / js / MainGame.js < prev    next >
Encoding:
JavaScript  |  2015-03-05  |  6.1 KB  |  167 lines

  1. var s;
  2. var index;
  3. var datesMain;
  4. function MainGame( title ){
  5.     this.title = title;
  6.     if($.find("#acasa").length == 0)
  7.         this.setMainButtons();
  8.     //this.disabledGameButtons();
  9. }
  10. var helpSound = "";
  11. MainGame.prototype.setMainButtons = function(){
  12.     $("#gameDiv").css("width", (ow * scale) + "px");
  13.     $("#gameDiv").css("left", (w - ow * scale) / 2 + "px");
  14.     timeOut = 1500;
  15.     $("#bb-bookblock").hide();
  16.     $("#gameDiv").append("<audio controls id='player' style='display:none;visibility:hidden;z-index:-1'>" +
  17.     "<source src='' type='audio/mpeg' ></audio>");
  18.     player = new MediaElement('player', {});
  19.     
  20.     $("#gameDiv").append("<div id='bodyGame' style='position:relative;width:100%;top:"
  21.             +(((navigator.platform.indexOf("iPhone") != -1)|| (navigator.platform.indexOf("iPad") != -1))?(210*scale):(230*scale))
  22.             +"px;left:"+(0*scale)+"px;align:center'></div>");
  23.             $("#gameDiv").append("<div id='footerGame' style='z-index:5000;position:absolute;bottom:"+(5*scale)+"px;left:"+(100*scale)+"px; '></div>");
  24.         
  25.         
  26.             $("#gameDiv").append("<button id='closeBtn'  class='close' style='top:"+(scale*20)+"px;right:"+(scale*5)+"px;'></button>");
  27.         
  28.         $("#footerGame").empty();
  29.         $("#footerGame").append("<div id='acasa'  class='acasa'  ></div> ");
  30.         $("#footerGame").append("<div id='ajutor' class='ajutor'></div> ");
  31.         $("#footerGame").append("<div id='repeta' class='repeta' ></div> ");
  32.         $("#footerGame").append("<div id='verifica' class='verifica'></div>");
  33.             
  34.         $("#title").remove();
  35.         if((this.title != null) && (this.title.text != "gameDialog") && (this.title.text != undefined)){
  36.                $("#gameDiv").append("<div id='title' class='title' style='top:"+(scale*(20))+"px; " +
  37.                     ((this.title.position.leftLast!=null)?("left:"+(scale*this.title.position.leftLast )+"px;"):"") +
  38.                     "' ></div>");
  39.                
  40.                $.each(this.title, function(key, value){
  41.                    if(value===true)
  42.                        $("#title").append("<img src='images/ico/"+key+".png' " +
  43.                                " style='width:"+(scale*100)+"px; height:"+(scale*100)+"px;' />");
  44.                    if(key=="text")
  45.                        $("#title").append("<span>"+ value +"</span>");
  46. //                   if(key=="text1")
  47. //         $("#title").append("<span style='position:absolute;align:center;top:"+(scale*(value.y))+"px;" +
  48. //                 "left:"+(scale*(value.x))+"px;width:500px;" +
  49. //                 "font-family:Georgia; font-style:italic; font-size:20px;color:rgb(182,66,4);'>"+ value.text +"</span>");
  50. //                
  51.                });
  52.                
  53.                if((this.title.logo!=null) && (this.title.logo!=undefined)){ 
  54.                    $("#gameDiv").append("<img src='images/logo/"+this.title.logo+".gif' " +
  55.                           " style='position:absolute;z-index:1000;" +
  56.                           " width:"+(scale*this.title.position.widthLogo)+"px; " +
  57.                           " height:"+(scale*this.title.position.heightLogo)+"px;" +
  58.                         " top:"+(scale*this.title.position.topLogo)+"px; " +
  59.                         " left:"+(scale*this.title.position.leftLogo )+"px;' />");
  60.                }   
  61.              
  62.         }
  63.            
  64.     $("#acasa, #closeBtn").click(function() {
  65.         
  66.         index = 200;
  67.         $("#player").remove();
  68.         $("#bodyGame").empty();
  69.         $("#gameDiv").empty();
  70.         $("#helpDialog").empty();
  71.         $("#gameDialog").dialog('close');
  72.         $("#helpDialog").dialog('close');
  73.         $("#bb-bookblock").show();
  74.         $("#windowGameBackgroundStatic").css("visibility","hidden");
  75.         $("#windowGameBackground").css("visibility","");
  76.         $("#gameDiv").css("background","transparent");
  77.     });
  78.     
  79.     $("#helpDialog").dialog({
  80.         autoOpen : false,
  81.         modal:true,
  82.         resizable : false,
  83.         draggable : false,
  84.         close: function() {player.pause();},
  85.         modal : true,
  86.         width : 585,
  87.         height : 450,//320
  88.     });
  89.     $(".ui-dialog-titlebar").hide();
  90.     
  91.     $('html').click(function() {
  92.         if ($("#helpDialog").dialog( "isOpen" )===true) {
  93.             $("#helpDialog").dialog( "close" );
  94.         }
  95.     });
  96.     $('#helpDialog').click(function(event){
  97.             event.stopPropagation();
  98.     });
  99.     
  100.  
  101.     
  102.     
  103.     $('.ui-icon').css('display','none');
  104.     $("#helpDialog").append("<div id='gameDivHelp' style='z-index:2000;border-style:solid;border:2px;background:rgb(230,152,83);top:0px;width:585px;height:50px'></div>");
  105.     $("#gameDivHelp").append("<button id='closeBtnHelp'  class='close' style='top:"+(scale*10)+"px;right:"+(scale*5)+"px;'></button>");
  106.     
  107.     $("#closeBtnHelp").click(function() {
  108.         player.pause();
  109.        });
  110.     
  111.     $("#ajutor").click(function(event) {
  112.         if(isActive!=null)
  113.                if(isActive===false)
  114.                 return false;
  115.         event.stopPropagation();
  116.         $("#helpDialog").dialog('open');
  117.         if( $('#player1').length )    
  118.                player1.pause();
  119.         playSound(helpSound);
  120.         $(".ui-dialog").css("z-index","200000");
  121.     });
  122.     
  123.     $("#helpDialog").append("<div align='justify' style=''><article id='headerHelp'  style='z-index:9999;height:200px;line-height: 1.7;' ></div>");
  124.     $("#helpDialog").append("<img align='center' src='images/logo/avatar.gif' width=150px;height=150px />");
  125.     
  126.     if((this.title != null) && (this.title.help != "gameDialog") && (this.title.help != undefined)){
  127.         var text = this.title.help.text;
  128.         var images = [{name:" ├ÄNCHIDE",src:"images/butoane_fereastra_joc/close1.png",width:30,height:30},
  129.                       {name:" REPET─é JOCUL",src:"images/butoane_fereastra_joc/repeta1.png",width:44,height:30},
  130.                       {name:" VERIFIC─é",src:"images/butoane_fereastra_joc/verifica1.png",width:44,height:30}
  131.     
  132.         ];    
  133.         
  134.         for(var i=0;i<images.length;i++){
  135.             text = text.replace(images[i].name , "</span><img src='"+images[i].src+"'" +
  136.                     " style='width:"+images[i].width+"px;height:"+images[i].height+"px;'><span>");
  137.         }
  138.         
  139.         $("#headerHelp").append(text);
  140.         helpSound = this.title.help.src;
  141.         
  142.         
  143.     }
  144.     
  145.  
  146.  
  147.  
  148. $("#closeBtnHelp").click(function() {
  149.     $("#helpDialog").dialog('close');
  150. });
  151.     
  152.     
  153. };
  154.  
  155.  
  156. MainGame.prototype.disabledGameButtons = function(){
  157.     $("#acasa,#ajutor,#verifica,#repeta").attr("disabled", "disabled");
  158. };
  159. MainGame.prototype.enabledGameButtons = function(){
  160.     $("#acasa,#ajutor,#verifica, #repeta").prop("disabled", "");
  161. };
  162. MainGame.prototype.partialEnabledGameButtons = function(){
  163.     $("#acasa,#ajutor,#repeta").prop('disabled', "disabled");
  164. };
  165. MainGame.prototype.partialDisabledGameButtons = function(){
  166.     $("#ajutor,#verifica,#repeta").off('click');
  167. };