comparison js/core.js @ 2774:2fc62a50d593

#145. Added minWait to all <surveyx> elements. Specify the amount of time to wait in seconds.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Fri, 21 Apr 2017 14:03:51 +0100
parents 9d31ddedae2b
children 87d71c41c174
comparison
equal deleted inserted replaced
2773:e31b3e1716f1 2774:2fc62a50d593
551 this.buttonPrevious = null; 551 this.buttonPrevious = null;
552 this.popupOptions = null; 552 this.popupOptions = null;
553 this.currentIndex = null; 553 this.currentIndex = null;
554 this.node = null; 554 this.node = null;
555 this.store = null; 555 this.store = null;
556 var lastNodeStart = undefined;
556 $(window).keypress(function (e) { 557 $(window).keypress(function (e) {
557 if (e.keyCode == 13 && popup.popup.style.visibility == 'visible') { 558 if (e.keyCode == 13 && popup.popup.style.visibility == 'visible') {
558 console.log(e); 559 console.log(e);
559 popup.buttonProceed.onclick(); 560 popup.buttonProceed.onclick();
560 e.preventDefault(); 561 e.preventDefault();
1046 this.postNode = function () { 1047 this.postNode = function () {
1047 // This will take the node from the popupOptions and display it 1048 // This will take the node from the popupOptions and display it
1048 var node = this.popupOptions[this.currentIndex], 1049 var node = this.popupOptions[this.currentIndex],
1049 converter = new showdown.Converter(), 1050 converter = new showdown.Converter(),
1050 p = new DOMParser(); 1051 p = new DOMParser();
1052 lastNodeStart = new Date();
1051 this.popupResponse.innerHTML = ""; 1053 this.popupResponse.innerHTML = "";
1052 this.popupTitle.innerHTML = ""; 1054 this.popupTitle.innerHTML = "";
1053 this.popupTitle.appendChild(p.parseFromString(converter.makeHtml(node.specification.statement), "text/html").getElementsByTagName("body")[0].firstElementChild); 1055 this.popupTitle.appendChild(p.parseFromString(converter.makeHtml(node.specification.statement), "text/html").getElementsByTagName("body")[0].firstElementChild);
1054 if (node.specification.type == 'question') { 1056 if (node.specification.type == 'question') {
1055 postQuestion.call(this, node); 1057 postQuestion.call(this, node);
1108 interfaceContext.calibrationModuleObject.collect(); 1110 interfaceContext.calibrationModuleObject.collect();
1109 advanceState(); 1111 advanceState();
1110 return; 1112 return;
1111 } 1113 }
1112 var node = this.popupOptions[this.currentIndex], 1114 var node = this.popupOptions[this.currentIndex],
1113 pass = true; 1115 pass = true,
1116 timeDelta = (new Date() - lastNodeStart)/1000.0;
1117 if (timeDelta < node.specification.minWait) {
1118 interfaceContext.lightbox.post("Error", "Not enough time has elapsed, please wait "+(node.specification.minWait-timeDelta).toFixed(0)+" seconds");
1119 return;
1120 }
1114 if (node.specification.type == 'question') { 1121 if (node.specification.type == 'question') {
1115 // Must extract the question data 1122 // Must extract the question data
1116 pass = processQuestion.call(this, node); 1123 pass = processQuestion.call(this, node);
1117 } else if (node.specification.type == 'checkbox') { 1124 } else if (node.specification.type == 'checkbox') {
1118 // Must extract checkbox data 1125 // Must extract checkbox data