changeset 3063:6b95437ae672

Close #109
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 31 Oct 2017 16:21:58 +0000
parents e441e3d5c7e7
children a504a17dcf9f
files interfaces/ape.js js/core.js
diffstat 2 files changed, 47 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/interfaces/ape.js	Tue Oct 31 15:55:07 2017 +0000
+++ b/interfaces/ape.js	Tue Oct 31 16:21:58 2017 +0000
@@ -341,7 +341,7 @@
             this.exportXMLDOM = function () {
                 var node = storage.document.createElement('value');
                 node.setAttribute("interface-name", axisInterface.name)
-                node.textContent = this.value();
+                node.textContent = this.value;
                 return node;
             }
             this.error = function () {
@@ -400,6 +400,9 @@
                         return label;
                     },
                     "set": function () {}
+                },
+                "metric": {
+                    "value": metric
                 }
             });
         }
@@ -558,6 +561,7 @@
             UI.startTime = undefined;
         }
         this.handleEvent = function (event) {
+            var time = audioEngineContext.timer.getTestTime();
             if (event.preventDefault) {
                 event.preventDefault();
             }
@@ -570,12 +574,14 @@
                 move = Math.max(50, move);
                 move = Math.min(w, move);
                 UI.selected.value = (move / w);
+                UI.selected.metric.moved(time, UI.selected.value);
             } else if (event.type == "touchmove") {
                 var move = event.originalEvent.targetTouches[0].clientX - 6;
                 var w = $(event.currentTarget).width();
                 move = Math.max(50, move);
                 move = Math.min(w, move);
                 UI.selected.value = (move / w);
+                UI.selected.metric.moved(time, UI.selected.value);
             }
         }
         this.checkAllMoved = function () {
--- a/js/core.js	Tue Oct 31 15:55:07 2017 +0000
+++ b/js/core.js	Tue Oct 31 16:21:58 2017 +0000
@@ -2711,6 +2711,12 @@
             this.textArea.style.width = boxwidth - 6 + "px";
         };
         this.resize();
+        this.check = function () {
+            if (this.specification.mandatory && this.textArea.value.length == 0) {
+                return false;
+            }
+            return true;
+        }
     };
 
     this.radioBox = function (commentQuestion) {
@@ -2785,6 +2791,15 @@
             }
             this.holder.style.width = boxwidth + "px";
         };
+        this.check = function () {
+            var anyChecked = this.options.some(function (a) {
+                return a.checked;
+            });
+            if (this.specification.mandatory && anyChecked == false) {
+                return false;
+            }
+            return true;
+        }
         this.resize();
     };
 
@@ -2851,6 +2866,15 @@
             }
             this.holder.style.width = boxwidth + "px";
         };
+        this.check = function () {
+            var anyChecked = this.options.some(function (a) {
+                return a.checked;
+            });
+            if (this.specification.mandatory && anyChecked == false) {
+                return false;
+            }
+            return true;
+        };
         this.resize();
     };
 
@@ -2908,6 +2932,9 @@
             this.holder.style.width = boxwidth + "px";
             this.slider.style.width = boxwidth - 24 + "px";
         };
+        this.check = function () {
+            return true;
+        }
         this.resize();
     };
 
@@ -2930,6 +2957,19 @@
         this.commentQuestions = [];
     };
 
+    this.checkCommentQuestions = function () {
+        var errored = this.commentQuestions.reduce(function (a, cq) {
+            if (cq.check() == false) {
+                a.push(cq);
+            }
+            return a;
+        }, []);
+        if (errored.length == 0) {
+            return true;
+        }
+        interfaceContext.lightbox.post("Message", "Not all the mandatory comment boxes below have been filled.");
+    }
+
     this.outsideReferenceDOM = function (audioObject, index, inject) {
         this.parent = audioObject;
         this.outsideReferenceHolder = document.createElement('button');