home *** CD-ROM | disk | FTP | other *** search
/ Orthodox Religion Class (2nd Semester) / ReligieCls1Sem2.iso / js / games / GamesChooseRadioBox.js next >
Encoding:
JavaScript  |  2015-02-20  |  3.0 KB  |  92 lines

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