annotate scripts/comment_parser.html @ 1108:a6cd19323345

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