# HG changeset patch # User Nicholas Jillings # Date 1493294251 -3600 # Node ID 79258b2a824512f918dd4871f7ed52456af3fccf # Parent 65b8d9ad75cc2a0034fa938ad36a8e7371e34506 Completed file upload for test_create diff -r 65b8d9ad75cc -r 79258b2a8245 test_create.html --- a/test_create.html Thu Apr 27 12:19:20 2017 +0100 +++ b/test_create.html Thu Apr 27 12:57:31 2017 +0100 @@ -1000,7 +1000,9 @@
Welcome to the WAET test creator tool. This will allow you to create a new test from scratch to suit your testing needs. If you wish to update a test file, please drag and drop the XML document into the area below for processing, otherwise press 'Next' to start a new test. This tool generates files for the WAET 1.2.1 version.
-
Upload XML here
+
+ +
diff -r 65b8d9ad75cc -r 79258b2a8245 test_create/test_core.js --- a/test_create/test_core.js Thu Apr 27 12:19:20 2017 +0100 +++ b/test_create/test_core.js Thu Apr 27 12:57:31 2017 +0100 @@ -1,4 +1,4 @@ -/* globals document, angular, window, Promise, XMLHttpRequest, Specification */ +/* globals document, angular, window, Promise, XMLHttpRequest, Specification, XMLSerializer, Blob, DOMParser*/ function get(url) { // Return a new promise. return new Promise(function (resolve, reject) { @@ -38,6 +38,12 @@ }; +function handleFiles(event) { + var s = angular.element(event.currentTarget).scope(); + s.handleFiles(event); + s.$apply(); +} + AngularInterface.controller("view", ['$scope', '$element', '$window', function ($s, $e, $w) { $s.popupVisible = true; @@ -66,14 +72,14 @@ }); var dnlk = window.URL.createObjectURL(bb); window.location.href = dnlk; - } + }; }]); AngularInterface.controller("introduction", ['$scope', '$element', '$window', function ($s, $e, $w) { $s.state = 0; $s.next = function () { $s.state++; - if ($s.state > 1) { + if ($s.state > 1 || $s.file) { $s.hidePopup(); } }; @@ -96,6 +102,7 @@ }; // Get the test interface specifications $s.interfaces = {}; + $s.file = undefined; $s.description = ""; var interfaceCollection = new Promise(function (resolve, reject) { var xml = new XMLHttpRequest(); @@ -115,6 +122,17 @@ $s.interfaces = data.interfaces; $s.$apply(); }); + + $s.handleFiles = function ($event) { + $s.file = $event.currentTarget.files[0]; + var r = new FileReader(); + r.onload = function () { + var p = new DOMParser(); + specification.decode(p.parseFromString(r.result, "text/xml")); + $s.$apply(); + } + r.readAsText($s.file); + }; }]); AngularInterface.controller("setup", ['$scope', '$element', '$window', function ($s, $e, $w) {