home *** CD-ROM | disk | FTP | other *** search
/ Orthodox Religion Class (2nd Semester) / ReligieCls1Sem2.iso / js / games / GamesDiffCircle.js < prev    next >
Encoding:
JavaScript  |  2015-03-23  |  3.1 KB  |  87 lines

  1.  
  2. function GamesDiffCircle(config){
  3.     this.config = config;
  4. }
  5.  
  6. GamesDiffCircle.prototype.resetLevel = function() {
  7.     $("*[data-A-type='tick']").css("display","none");
  8.     $("*[data-val]").attr("data-val","0");
  9. };
  10.  
  11. GamesDiffCircle.prototype.checkIfFinish = function() {
  12.     var no = 0;
  13.     $("*[data-A-index]").each(function(){
  14.         if($("#Atick"+($(this)).attr("data-A-index")).css("display")!="none")
  15.             no++;
  16.     });
  17.     if(no!=(this.config.objects.length/this.config.column))
  18.         return true;
  19. };
  20.  
  21. GamesDiffCircle.prototype.getCorrectAnswer = function(){
  22.     $("*[data-A-type='tick']").css("display","none");
  23.     for (var j = 0; j < this.config.objects.length; j++) {
  24.         if(this.config.objects[j].response==1)
  25.             $("#Atick"+j).toggle();
  26.     }
  27. };
  28.  
  29. GamesDiffCircle.prototype.checkSingleResultIndex = function(index){
  30.     for (var j = 0; j < this.config.column; j++) {
  31.         if( (this.config.objects[j+index*this.config.column].response==1) ){
  32.             if($("#Atick"+(j+index*this.config.column)).css("display")=="none" )
  33.                 return false;
  34.         }
  35.     }
  36.     return true;
  37. };
  38.  
  39. GamesDiffCircle.prototype.getCheckLength = function(){
  40.     return this.config.objects.length/this.config.column;
  41. };
  42.  
  43. GamesDiffCircle.prototype.getResult = function(){
  44.     return this.config.result;
  45. };
  46.  
  47. GamesDiffCircle.prototype.initialize = function(){
  48.     var config=this.config;
  49.     if(this.config.fundal!=null){
  50.         $("#gameStage").append("<img id='fundal'>");
  51.         util.setImageStyle($("#fundal"), this.config.fundal);
  52.     }
  53.  
  54.     for (var i = 0; i < this.config.objects.length; i++) {
  55.         $("#gameStage").append("<div id='AidInput"+i+"' data-A-index='"+i+"' "+
  56.                 " onclick='"+((!isRepeatActive)?"return false":"")+ "' data-val=0 " +
  57.                 " style='z-index:2000;cursor:pointer;position:absolute;" +
  58.                 ((this.config.displayInput===undefined)?"border-style:solid;outline: none;  border-color:  #A77649; " +
  59.                         " box-shadow: 0 0 10px  #A77649;" : "")+
  60.                 "width:"+(this.config.input.width+5)+"px;height:"+(this.config.input.height+5)+"px;" +
  61.                 "top:"+this.config.objects[i].top+"px;" +
  62.                 "left:"+this.config.objects[i].left+"px;" +
  63.                 "background:transparent;'></div>" +
  64.                 "<img id='Atick"+i+"'  data-A-indexImg='"+((i<5)?0:1)+"' data-A-type='tick' " +
  65.                         "style='position:absolute;display:none;" + 
  66.                     "top:"+(this.config.objects[i].top+this.config.imgTick.top)+"px;" +
  67.                     "left:"+(this.config.objects[i].left+this.config.imgTick.left)+"px;" +
  68.                     "' src='"+((this.config.imgTick===undefined)?imagesCommon.tick:this.config.imgTick.src)+"' alt='' " +
  69.                     "width='"+this.config.objects[i].width+"' height='"+this.config.objects[i].height+"'/>");
  70.         if((i+1)%this.config.column==0){
  71.             util.setCheckImage(this.config.nameGame, this.config.objects[i], (i+1)/this.config.column-1 ,10,this.config.objects[i].width+135);
  72.         }
  73.     }
  74.     
  75.     
  76.     $("*[data-A-index]").click(function() {
  77.         if(!isActive)
  78.             return false;
  79.         $("*[data-A-indexImg='"+((($(this)).attr("data-A-index")<5)?0:1)+"']").css("display","none");
  80.         $("#Atick"+($(this)).attr("data-A-index")).css("display","");
  81.         $("#AidInput"+($(this)).attr("data-A-index")).attr("data-val",
  82.                 ($("#AidInput"+($(this)).attr("data-A-index")).attr("data-val")==0)?1:0);
  83.     });
  84.     
  85. };
  86.  
  87.