Mercurial > hg > webaudioevaluationtool
changeset 1173:d4348ae0bc02
Drag and drop area defined for updating a project file in test creator.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Wed, 10 Feb 2016 16:33:41 +0000 |
parents | e3b16bb23a50 |
children | dd7ba3054bf9 |
files | core.js test_create/style.css test_create/test_core.js test_create/test_create.html |
diffstat | 4 files changed, 76 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/core.js Wed Feb 10 14:46:57 2016 +0000 +++ b/core.js Wed Feb 10 16:33:41 2016 +0000 @@ -1714,7 +1714,7 @@ // Handles the decoding of the project specification XML into a simple JavaScript Object. this.interface = null; - this.projectReturn = null; + this.projectReturn = "null"; this.randomiseOrder = null; this.testPages = null; this.pages = [];
--- a/test_create/style.css Wed Feb 10 14:46:57 2016 +0000 +++ b/test_create/style.css Wed Feb 10 16:33:41 2016 +0000 @@ -34,6 +34,25 @@ bottom: 10px; } +div.drag-area { + border: 3px black dashed; +} +div.drag-over { + background-color: aquamarine; +} +div.drag-dropped { + background-color: aqua; +} +div.drag-error { + background-color: coral +} + +div#project-drop { + width: 99%; + height: 50px; + margin: 10px 0px; +} + div.popup-checkbox { padding: 5px; }
--- a/test_create/test_core.js Wed Feb 10 14:46:57 2016 +0000 +++ b/test_create/test_core.js Wed Feb 10 16:33:41 2016 +0000 @@ -195,8 +195,32 @@ span.textContent = "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.0 version." this.content.appendChild(span); this.dragArea = document.createElement("div"); - this.dragArea.classList = "drag-area"; + this.dragArea.className = "drag-area"; + this.dragArea.id = "project-drop"; this.content.appendChild(this.dragArea); + + this.dragArea.addEventListener('dragenter',function(e){ + e.stopPropagation(); + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + e.currentTarget.className = "drag-area drag-over"; + }); + + this.dragArea.addEventListener('dragexit',function(e){ + e.stopPropagation(); + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + e.currentTarget.className = "drag-area"; + }); + + this.dragArea.addEventListener('drop',function(e){ + e.stopPropagation(); + e.preventDefault(); + e.currentTarget.className = "drag-area drag-dropped"; + var files = e.dataTransfer.files[0]; + + }); + this.continue = function() { @@ -779,7 +803,7 @@ break; } var value; - eval("value = specification."+this.name) + eval("value = node."+this.name) if (value != undefined) { this.input.value = value; @@ -826,6 +850,35 @@ //Performs the actual conversion using the given root DOM as the root this.injectDOM = root; + // Build the export button + var exportButton = document.createElement("button"); + exportButton.textContent = "Export to XML"; + exportButton.onclick = function() + { + var doc = specification.encode(); + var obj = {}; + obj.title = "Export"; + obj.content = document.createElement("div"); + obj.content.id = "finish"; + var span = document.createElement("span"); + span.textContent = "Your XML document is linked below. On most browsers, simply right click on the link and select 'Save As'. Or clicking on the link may download the file directly." + obj.content.appendChild(span); + var link = document.createElement("div"); + link.appendChild(doc.children[0]); + var file = [link.innerHTML]; + var bb = new Blob(file,{type : 'application/xml'}); + var dnlk = window.URL.createObjectURL(bb); + var a = document.createElement("a"); + a.hidden = ''; + a.href = dnlk; + a.download = "project-specification.xml"; + a.textContent = "Save File"; + obj.content.appendChild(a); + popupObject.show(); + popupObject.postNode(obj); + } + this.injectDOM.appendChild(exportButton); + // First perform the setupNode; var setupSchema = specification.schema.getAllElementsByName('setup')[0]; this.setupDOM = new this.createGeneralNodeDOM('setup','setup',null);
--- a/test_create/test_create.html Wed Feb 10 14:46:57 2016 +0000 +++ b/test_create/test_create.html Wed Feb 10 16:33:41 2016 +0000 @@ -8,7 +8,7 @@ // Handles the decoding of the project specification XML into a simple JavaScript Object. this.interface = null; - this.projectReturn = null; + this.projectReturn = "null"; this.randomiseOrder = null; this.testPages = null; this.pages = [];