home *** CD-ROM | disk | FTP | other *** search
/ Orthodox Religion Class (2nd Semester) / ReligieCls1Sem2.iso / js / games / GamesWriteNumbers.js < prev   
Encoding:
JavaScript  |  2014-10-02  |  3.1 KB  |  99 lines

  1.  
  2. function GamesWriteNumbers(config){
  3.     this.config = config;
  4. }
  5.  
  6. GamesWriteNumbers.prototype.resetLevel = function() {
  7.     $("#gameStage>input").val("");
  8.     $("#gameStage>input").prop('readonly', false);
  9. };
  10.  
  11. GamesWriteNumbers.prototype.checkIfFinish = function() {
  12.     var notFinish = false;
  13.     $("#gameStage>input").each(function() {
  14.         if ($(this).val() == "") {
  15.            notFinish = true;
  16.         }
  17.     });
  18.     return notFinish;
  19. };
  20.  
  21. GamesWriteNumbers.prototype.getCorrectAnswer = function(){
  22.     for (var j = 0; j < this.config.objects.length; j++) {
  23.         $("#CidInput" + j).val(this.config.objects[j].response);
  24.     }
  25. };
  26.  
  27. GamesWriteNumbers.prototype.checkSingleResultIndex = function(index){
  28.     //return (this.config.objects[index].response == $("#CidInput"+index).val());
  29.     if(this.config.xx!=undefined){
  30.         if(this.config.objects[index].response.indexOf($("#CidInput"+index).val())!=-1){
  31.             return true;
  32.         }else{
  33.             return false;
  34.         }
  35.     }else{
  36.         return (this.config.objects[index].response == $("#CidInput"+index).val());
  37.     }
  38. };
  39.  
  40. GamesWriteNumbers.prototype.getCheckLength = function(){
  41.     return this.config.objects.length;
  42. };
  43.  
  44. GamesWriteNumbers.prototype.getResult = function(){
  45.     return this.config.result;
  46. };
  47.  
  48. GamesWriteNumbers.prototype.initialize = function(){
  49.    var config=this.config;
  50.     if(this.config.fundal!=null){
  51.         $("#gameStage").append("<img id='fundal'>");
  52.         util.setImageStyle($("#fundal"), this.config.fundal);
  53.     }
  54.     for (var i = 0; i < this.config.objects.length; i++) {
  55.         $("#gameStage").append(
  56.                 "<input type='text' id='CidInput"+i+"' data-C-type='number' maxlength="+this.config.objects[i].maxlength+" style='position:absolute;padding: 0;" +
  57.                         "text-align:center; outline: none; " +
  58.                         ((this.config.colorInput==undefined)?
  59.                                 ("font-size:23px;border-color: #ffeeaa;  " +
  60.                         "box-shadow: 0 0 10px #ffeeaa;border-radius:50%50%50%50%;border:1;"):
  61.                         (this.config.colorInput)) +
  62.                         "z-index:99;" +
  63.                         "top:"+this.config.objects[i].top+"px;" +
  64.                         "left:"+this.config.objects[i].left+"px;" +
  65.                         "width:"+this.config.objects[i].width+"px;" +
  66.                         "height:"+this.config.objects[i].height+"px;"+
  67.         "'/>");
  68.         util.setCheckImage(this.config.nameGame,this.config.objects[i],i,0,30);
  69.     }
  70.     $("*[data-C-type]").mouseover(function() {
  71.           if(!isActive)
  72.            return false;
  73.           if(config.displayInput==undefined){
  74.              if(config.overColor===undefined)            
  75.                 ($(this)).css("box-shadow","0 0 10px orange");
  76.             }else{alert();
  77.                 ($(this)).css("box-shadow",+config.overColor);
  78.             } 
  79.          });
  80.          
  81.          $("*[data-C-type]").mouseout(function() {
  82.           if(!isActive)
  83.            return false;
  84.           if(config.displayInput==undefined){
  85.               if(config.outColor===undefined)              
  86.                   ($(this)).css("box-shadow","0 0 10px #ffeeaa");
  87.               }else{
  88.                   alert()
  89.                   ($(this)).css("box-shadow", config.outColor);
  90.               }
  91.           
  92.          });
  93.     util.validateInputNumber($("*[data-C-type='number']"));
  94.     $("#gameStage").click(function(e) {
  95.         console.log("left:"+Math.round((e.pageX-$("#gameStage").offset().left)/scale/3)+",top:"+
  96.         Math.round((e.pageY-$("#gameStage").offset().top)/scale/3)+"");}); 
  97. };
  98.  
  99.