annotate scripts/comment_parser.html @ 1232:bf8716341ed6

WAC2016 review updated PDF
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 25 Feb 2016 11:57:24 +0000
parents d2afd2ee8684
children
rev   line source
n@1105 1 <html lang="en">
n@1105 2 <head>
n@1105 3 <meta charset="utf-8" />
n@1105 4 <script type="text/javascript">
n@1105 5 function getXML()
n@1105 6 {
n@1105 7 var XMLHttp = new XMLHttpRequest();
n@1105 8 XMLHttp.open("GET","comment_parser.php?format=XML",true);
n@1105 9 XMLHttp.onload = function() {
n@1105 10 // Now we have the XML data, extract
n@1105 11 var parse = new DOMParser();
n@1105 12 var ajax = parse.parseFromString(XMLHttp.response,'text/xml');
n@1105 13
n@1105 14 var parent = document.createElement("div");
n@1105 15 parent.appendChild(ajax.children[0]);
n@1105 16 var file = [parent.innerHTML];
n@1105 17 var bb = new Blob(file,{type : 'application/xml'});
n@1105 18 generateLink(bb,".xml");
n@1105 19 }
n@1105 20 XMLHttp.send();
n@1105 21 }
n@1105 22
n@1105 23 function getJSON()
n@1105 24 {
n@1105 25 var XMLHttp = new XMLHttpRequest();
n@1105 26 XMLHttp.open("GET","comment_parser.php?format=JSON",true);
n@1105 27 XMLHttp.onload = function() {
n@1105 28 // Now we have the XML data, extract
n@1105 29 var file = [XMLHttp.response];
n@1105 30 var bb = new Blob(file,{type : 'application/json'});
n@1105 31 generateLink(bb,".json");
n@1105 32 }
n@1105 33 XMLHttp.send();
n@1105 34 }
n@1105 35
n@1105 36 function getCSV()
n@1105 37 {
n@1105 38 var XMLHttp = new XMLHttpRequest();
n@1105 39 XMLHttp.open("GET","comment_parser.php?format=CSV",true);
n@1105 40 XMLHttp.onload = function() {
n@1105 41 // Now we have the XML data, extract
n@1105 42 var file = [XMLHttp.response];
n@1105 43 var bb = new Blob(file,{type : 'text/csv'});
n@1105 44 generateLink(bb,".csv");
n@1105 45 }
n@1105 46 XMLHttp.send();
n@1105 47 }
n@1105 48
n@1105 49 function generateLink(blobfile,fmt)
n@1105 50 {
n@1105 51 var dnlk = window.URL.createObjectURL(blobfile);
n@1105 52 var a = document.createElement("a");
n@1105 53 a.hidden = '';
n@1105 54 a.href = dnlk;
n@1105 55 a.download = "save"+fmt;
n@1105 56 a.textContent = "Save File";
n@1105 57 document.getElementById("download").appendChild(a);
n@1105 58 }
n@1105 59 </script>
n@1105 60 </head>
n@1105 61 <body>
n@1105 62 <h1>WAET Test Results Analysis</h1>
n@1105 63 <h2>Comment Extraction</h2>
n@1105 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@1105 65 <div id="download"></div>
n@1105 66 <div>
n@1105 67 <button onclick="getXML();">XML</button>
n@1105 68 <button onclick="getJSON();">JSON</button>
n@1105 69 <button onclick="getCSV();">CSV</button>
n@1105 70 </div>
n@1105 71 </body>
n@1105 72 </html>