changeset 2855:6625f4ad24f4

Finished <survey> interpretation for test_creator.html
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Wed, 26 Apr 2017 17:43:52 +0100
parents aed359997687
children 5591d01adf1c
files test_create.html test_create/test_core.js
diffstat 2 files changed, 89 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test_create.html	Wed Apr 26 17:15:24 2017 +0100
+++ b/test_create.html	Wed Apr 26 17:43:52 2017 +0100
@@ -290,6 +290,53 @@
                     </div>
                 </div>
             </div>
+            <div id="globalinterface" class="node" ng-controller="interfaceNode" ng-init="interface = specification.interfaces">
+                <h2>Interface (Globals)</h2>
+                <div class="node interfaceOptions">
+                    <div class="attributes">
+                        <div class="attribute" name="fragmentPlayed" type="check">
+                            <span>Check all fragments played: </span>
+                            <input type="checkbox" ng-click="enableInterfaceOption($event)" />
+                        </div>
+                        <div class="attribute" name="fragmentFullPlayback" type="check">
+                            <span>Check all fragments fully played: </span>
+                            <input type="checkbox" ng-click="enableInterfaceOption($event)" />
+                        </div>
+                        <div class="attribute" name="fragmentMoved" type="check">
+                            <span>Check all fragments have been moved: </span>
+                            <input type="checkbox" ng-click="enableInterfaceOption($event)" />
+                        </div>
+                        <div class="attribute" name="fragmentComments" type="check">
+                            <span>Check all fragments have comments: </span>
+                            <input type="checkbox" ng-click="enableInterfaceOption($event)" />
+                        </div>
+                        <div class="attribute" name="scalerange" type="check">
+                            <span>Enforce a scale usage: </span>
+                            <input type="checkbox" ng-click="enableInterfaceOption($event)" />
+                            <span>Minimum:</span>
+                            <input type="number" min="0" max="100" name="min" />
+                            <span>Maximum:</span>
+                            <input type="number" min="0" max="100" name="max" />
+                        </div>
+                        <div class="attribute" name="volume" type="show">
+                            <span>Show master volume control: </span>
+                            <input type="checkbox" ng-click="enableInterfaceOption($event)" />
+                        </div>
+                        <div class="attribute" name="playhead" type="show">
+                            <span>Show playhead: </span>
+                            <input type="checkbox" ng-click="enableInterfaceOption($event)" />
+                        </div>
+                        <div class="attribute" name="page-count" type="show">
+                            <span>Show Page Count: </span>
+                            <input type="checkbox" ng-click="enableInterfaceOption($event)" />
+                        </div>
+                        <div class="attribute" name="comments" type="show">
+                            <span>Show Fragment Comments: </span>
+                            <input type="checkbox" ng-click="enableInterfaceOption($event)" />
+                        </div>
+                    </div>
+                </div>
+            </div>
         </div>
         <div id="popupHolder" ng-show="popupVisible">
             <div ng-controller="introduction" class="popup" ng-show="popupVisible">
--- a/test_create/test_core.js	Wed Apr 26 17:15:24 2017 +0100
+++ b/test_create/test_core.js	Wed Apr 26 17:43:52 2017 +0100
@@ -1,4 +1,4 @@
-/* globals angular, window, Promise, XMLHttpRequest, Specification */
+/* globals document, angular, window, Promise, XMLHttpRequest, Specification */
 function get(url) {
     // Return a new promise.
     return new Promise(function (resolve, reject) {
@@ -127,7 +127,7 @@
                 DOM.checked = true;
             }
         });
-    })
+    });
 
     $s.enableMetric = function ($event) {
         var metric = $event.currentTarget.value;
@@ -143,7 +143,7 @@
                 specification.metrics.enabled.splice(index, 1);
             }
         }
-    }
+    };
 }]);
 
 AngularInterface.controller("surveyOption", ['$scope', '$element', '$window', function ($s, $e, $w) {
@@ -162,5 +162,44 @@
             name: "",
             text: ""
         });
+    };
+}]);
+
+AngularInterface.controller("interfaceNode", ['$scope', '$element', '$window', function ($s, $e, $w) {
+    $s.$watch("interface.options.length", function () {
+        if (!$s.interface || !$s.interface.options) {
+            return;
+        }
+        var options = $e[0].querySelector(".interfaceOptions").querySelectorAll(".attribute");
+        options.forEach(function (option) {
+            var name = option.getAttribute("name");
+            var index = $s.interface.options.findIndex(function (io) {
+                return io.name == name;
+            });
+            option.querySelector("input").checked = (index >= 0);
+            if (name == "scalerange" && index >= 0) {
+                option.querySelector("[name=min]").value = $s.interface.options[index].min;
+                option.querySelector("[name=max]").value = $s.interface.options[index].max;
+            }
+        });
+    });
+    $s.enableInterfaceOption = function ($event) {
+        var name = $event.currentTarget.parentElement.getAttribute("name");
+        var type = $event.currentTarget.parentElement.getAttribute("type");
+        var index = $s.interface.options.findIndex(function (io) {
+            return io.name == name;
+        });
+        if (index == -1 && $event.currentTarget.checked) {
+            var obj = $s.interface.options.push({
+                name: name,
+                type: type
+            });
+            if (name == "scalerange") {
+                obj.min = $event.currentTarget.parentElement.querySelector("[name=min]").value;
+                obj.max = $event.currentTarget.parentElement.querySelector("[name=max]").value;
+            }
+        } else if (index >= 0 && !$event.currentTarget.checked) {
+            $s.interface.options.splice(index, 1);
+        }
     }
 }]);