comparison 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
comparison
equal deleted inserted replaced
2863:7b1c05a9514a 2864:df1823dbfb93
44 s.$apply(); 44 s.$apply();
45 } 45 }
46 46
47 AngularInterface.controller("view", ['$scope', '$element', '$window', function ($s, $e, $w) { 47 AngularInterface.controller("view", ['$scope', '$element', '$window', function ($s, $e, $w) {
48 $s.popupVisible = true; 48 $s.popupVisible = true;
49 $s.testSpecifications = {};
50
51 (function () {
52 new Promise(function (resolve, reject) {
53 var xml = new XMLHttpRequest();
54 xml.open("GET", "test_create/interfaces/specifications.json");
55 xml.onload = function () {
56 if (xml.status === 200) {
57 resolve(xml.responseText);
58 return;
59 }
60 reject(xml.status);
61 };
62 xml.onerror = function () {
63 reject(new Error("Network Error"));
64 };
65 xml.send();
66 }).then(JSON.parse).then(function (data) {
67 $s.testSpecifications = data;
68 $s.$apply();
69 })
70 })();
49 71
50 $s.showPopup = function () { 72 $s.showPopup = function () {
51 $s.popupVisible = true; 73 $s.popupVisible = true;
52 }; 74 };
53 $s.hidePopup = function () { 75 $s.hidePopup = function () {
95 }; 117 };
96 $s.back = function () { 118 $s.back = function () {
97 $s.state--; 119 $s.state--;
98 }; 120 };
99 $s.mouseover = function (name) { 121 $s.mouseover = function (name) {
100 var obj = $s.interfaces.find(function (i) { 122 var obj = $s.testSpecifications.interfaces.find(function (i) {
101 return i.name == name; 123 return i.name == name;
102 }); 124 });
103 if (obj) { 125 if (obj) {
104 $s.description = obj.description.en; 126 $s.description = obj.description.en;
105 } 127 }
109 return i.name == name; 131 return i.name == name;
110 }); 132 });
111 specification.interface = obj.interface; 133 specification.interface = obj.interface;
112 }; 134 };
113 // Get the test interface specifications 135 // Get the test interface specifications
114 $s.interfaces = {};
115 $s.file = undefined; 136 $s.file = undefined;
116 $s.description = ""; 137 $s.description = "";
117 var interfaceCollection = new Promise(function (resolve, reject) {
118 var xml = new XMLHttpRequest();
119 xml.open("GET", "test_create/interfaces/specifications.json");
120 xml.onload = function () {
121 if (xml.status === 200) {
122 resolve(xml.responseText);
123 return;
124 }
125 reject(xml.status);
126 };
127 xml.onerror = function () {
128 reject(new Error("Network Error"));
129 };
130 xml.send();
131 }).then(JSON.parse).then(function (data) {
132 $s.interfaces = data.interfaces;
133 $s.$apply();
134 });
135 138
136 $s.handleFiles = function ($event) { 139 $s.handleFiles = function ($event) {
137 $s.file = $event.currentTarget.files[0]; 140 $s.file = $event.currentTarget.files[0];
138 var r = new FileReader(); 141 var r = new FileReader();
139 r.onload = function () { 142 r.onload = function () {
290 $s.interface.scales.push({ 293 $s.interface.scales.push({
291 position: undefined, 294 position: undefined,
292 text: undefined 295 text: undefined
293 }); 296 });
294 }; 297 };
298 $s.clearScales = function () {
299 $s.interface.scales = [];
300 };
301 $s.useScales = function (scales) {
302 $s.clearScales();
303 scales.forEach(function (s) {
304 $s.interface.scales.push(s);
305 });
306 };
295 }]); 307 }]);
296 AngularInterface.controller("page", ['$scope', '$element', '$window', function ($s, $e, $w) { 308 AngularInterface.controller("page", ['$scope', '$element', '$window', function ($s, $e, $w) {
297 $s.addInterface = function () { 309 $s.addInterface = function () {
298 $s.page.addInterface(); 310 $s.page.addInterface();
299 }; 311 };