annotate scripts/comment_parser.html @ 1103:2051868b21f0

Hotfix: Updated schema. <audioelement>, <surveyelement> and <commentquestion> have optional name attribute.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Wed, 09 Mar 2016 11:29:16 +0000
parents b5bf2f57187c
children
rev   line source
n@1102 1 <html lang="en">
n@1102 2 <head>
n@1102 3 <meta charset="utf-8" />
n@1102 4 <script type="text/javascript">
n@1102 5 function getXML()
n@1102 6 {
n@1102 7 var XMLHttp = new XMLHttpRequest();
n@1102 8 XMLHttp.open("GET","comment_parser.php?format=XML",true);
n@1102 9 XMLHttp.onload = function() {
n@1102 10 // Now we have the XML data, extract
n@1102 11 var parse = new DOMParser();
n@1102 12 var ajax = parse.parseFromString(XMLHttp.response,'text/xml');
n@1102 13
n@1102 14 var parent = document.createElement("div");
n@1102 15 parent.appendChild(ajax.children[0]);
n@1102 16 var file = [parent.innerHTML];
n@1102 17 var bb = new Blob(file,{type : 'application/xml'});
n@1102 18 generateLink(bb,".xml");
n@1102 19 }
n@1102 20 XMLHttp.send();
n@1102 21 }
n@1102 22
n@1102 23 function getJSON()
n@1102 24 {
n@1102 25 var XMLHttp = new XMLHttpRequest();
n@1102 26 XMLHttp.open("GET","comment_parser.php?format=JSON",true);
n@1102 27 XMLHttp.onload = function() {
n@1102 28 // Now we have the XML data, extract
n@1102 29 var file = [XMLHttp.response];
n@1102 30 var bb = new Blob(file,{type : 'application/json'});
n@1102 31 generateLink(bb,".json");
n@1102 32 }
n@1102 33 XMLHttp.send();
n@1102 34 }
n@1102 35
n@1102 36 function getCSV()
n@1102 37 {
n@1102 38 var XMLHttp = new XMLHttpRequest();
n@1102 39 XMLHttp.open("GET","comment_parser.php?format=CSV",true);
n@1102 40 XMLHttp.onload = function() {
n@1102 41 // Now we have the XML data, extract
n@1102 42 var file = [XMLHttp.response];
n@1102 43 var bb = new Blob(file,{type : 'text/csv'});
n@1102 44 generateLink(bb,".csv");
n@1102 45 }
n@1102 46 XMLHttp.send();
n@1102 47 }
n@1102 48
n@1102 49 function generateLink(blobfile,fmt)
n@1102 50 {
n@1102 51 var dnlk = window.URL.createObjectURL(blobfile);
n@1102 52 var a = document.createElement("a");
n@1102 53 a.hidden = '';
n@1102 54 a.href = dnlk;
n@1102 55 a.download = "save"+fmt;
n@1102 56 a.textContent = "Save File";
n@1102 57 document.getElementById("download").appendChild(a);
n@1102 58 }
n@1102 59 </script>
n@1102 60 </head>
n@1102 61 <body>
n@1102 62 <h1>WAET Test Results Analysis</h1>
n@1102 63 <h2>Comment Extraction</h2>
n@1102 64 <p>All of the XMLs in the server 'saves/' directory are automatically parsed and downloaded, extracting only the comments. Simply select the comments you wish to extract below and your desired data format.</p>
n@1102 65 <div id="download"></div>
n@1102 66 <div>
n@1102 67 <button onclick="getXML();">XML</button>
n@1102 68 <button onclick="getJSON();">JSON</button>
n@1102 69 <button onclick="getCSV();">CSV</button>
n@1102 70 </div>
n@1102 71 </body>
n@1102 72 </html>