annotate scripts/comment_parser.html @ 1308:d23de1f2229e

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