Reply To: html layout/event times/selector vs. scale/ compatibility

PennController for IBEX Forums Support html layout/event times/selector vs. scale/ compatibility Reply To: html layout/event times/selector vs. scale/ compatibility

#7990
HPI
Participant

Sorry I noticed I didn’t copy the whole function:

It was like that in the previous script:

function blank(a, b) {
  var sentence = b ? b : a;
   var n = b ? a : null;

   var seq = [""];
   var inBlank = false;
  for (var i = 0; i < sentence.length; ++i) {
      var c = sentence.charAt(i)
      if (inBlank) {
           if (c == '_')
               (seq[seq.length])++;
          else {
               seq.push(c);
               inBlank = true;
           }
       }
       else {
           if (c != '_')
               seq[seq.length-1] += c
          else {
               seq.push(1);
               inBlank = true;
           }
       }
   }

  var ihtml = "";
  var bcount = 0;
   for (var i = 0; i < seq.length; ++i) {
       if (typeof(seq[i]) == "number") {
           ++bcount;
           var input = " <input type='text' name='blank-" + bcount + "' size='" + (n ? n : seq[i]) + "'></input> ";
           ihtml += input;
       }
      else {
           ihtml += $("<div>").text(seq[i])[0].innerHTML;
       }
   }

   var e = "<p>";
   var validators = { };
  var bcount = 0;
  for (var i = 0; i < seq.length; ++i) {
       if (typeof(seq[i]) == "number") {
           ++bcount;
          e += "<label class='error' for='blank-" + bcount + "'></label>"
         ;
         validators['blank-' + bcount] = function (s) { if (s && !s.match(/^\s*$/)) return true; else return "You must fill in the blank."; }
       }
   }
  e += "</p>"

  return {
      html: "<p>" + ihtml + "</p>" + e,
      validators: validators
   };
}