diff test_create/test_core.js @ 2864:df1823dbfb93

Add use scale to test_create
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 27 Apr 2017 14:19:25 +0100
parents b8795a6452f8
children d5e7f45b15e7
line wrap: on
line diff
--- a/test_create/test_core.js	Thu Apr 27 13:55:40 2017 +0100
+++ b/test_create/test_core.js	Thu Apr 27 14:19:25 2017 +0100
@@ -46,6 +46,28 @@
 
 AngularInterface.controller("view", ['$scope', '$element', '$window', function ($s, $e, $w) {
     $s.popupVisible = true;
+    $s.testSpecifications = {};
+
+    (function () {
+        new Promise(function (resolve, reject) {
+            var xml = new XMLHttpRequest();
+            xml.open("GET", "test_create/interfaces/specifications.json");
+            xml.onload = function () {
+                if (xml.status === 200) {
+                    resolve(xml.responseText);
+                    return;
+                }
+                reject(xml.status);
+            };
+            xml.onerror = function () {
+                reject(new Error("Network Error"));
+            };
+            xml.send();
+        }).then(JSON.parse).then(function (data) {
+            $s.testSpecifications = data;
+            $s.$apply();
+        })
+    })();
 
     $s.showPopup = function () {
         $s.popupVisible = true;
@@ -97,7 +119,7 @@
         $s.state--;
     };
     $s.mouseover = function (name) {
-        var obj = $s.interfaces.find(function (i) {
+        var obj = $s.testSpecifications.interfaces.find(function (i) {
             return i.name == name;
         });
         if (obj) {
@@ -111,27 +133,8 @@
         specification.interface = obj.interface;
     };
     // Get the test interface specifications
-    $s.interfaces = {};
     $s.file = undefined;
     $s.description = "";
-    var interfaceCollection = new Promise(function (resolve, reject) {
-        var xml = new XMLHttpRequest();
-        xml.open("GET", "test_create/interfaces/specifications.json");
-        xml.onload = function () {
-            if (xml.status === 200) {
-                resolve(xml.responseText);
-                return;
-            }
-            reject(xml.status);
-        };
-        xml.onerror = function () {
-            reject(new Error("Network Error"));
-        };
-        xml.send();
-    }).then(JSON.parse).then(function (data) {
-        $s.interfaces = data.interfaces;
-        $s.$apply();
-    });
 
     $s.handleFiles = function ($event) {
         $s.file = $event.currentTarget.files[0];
@@ -292,6 +295,15 @@
             text: undefined
         });
     };
+    $s.clearScales = function () {
+        $s.interface.scales = [];
+    };
+    $s.useScales = function (scales) {
+        $s.clearScales();
+        scales.forEach(function (s) {
+            $s.interface.scales.push(s);
+        });
+    };
 }]);
 AngularInterface.controller("page", ['$scope', '$element', '$window', function ($s, $e, $w) {
     $s.addInterface = function () {