Loading web/index.html +6 −6 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ <title>Spam Hunter</title> <!-- Meat 'n potatoes --> <body onload="getTopFiveAlgorithms()"> <body onload="initializeIndex()"> <div id="interactivity" class="jumbotron"> <!-- User interactivity portion --> <h3>Type your message here:</h3> Loading @@ -24,11 +24,11 @@ <div id="spam_words_list"> <p>Top 5 words most commonly used in spam: <ol> <li>Sex</li> <li>Prize</li> <li>Singles</li> <li>Larry</li> <li>Win</li> <li id="top1">Sex</li> <li id="top2">Prize</li> <li id="top3">Singles</li> <li id="top4">Larry</li> <li id="top5">Win</li> </ol> </p> </div> Loading web/js/main.js +47 −4 Original line number Diff line number Diff line Loading @@ -63,8 +63,51 @@ function getTopFiveAlgorithms() { } // for debug purposes until the server communication is implemented var placeholder_name = "qaoweifj"; var placeholder_f1 = "75.43%"; document.getElementById("alg1_name").innerText = placeholder_name; document.getElementById("alg1_f1").innerText = placeholder_f1; //var placeholder_name = "qaoweifj"; //var placeholder_f1 = "75.43%"; //document.getElementById("alg1_name").innerText = placeholder_name; //document.getElementById("alg1_f1").innerText = placeholder_f1; } function getTopFiveWords() { var url = "http://localhost:8080" var endpoint = "/getWords" var http = new XMLHttpRequest(); http.open("GET", url + endpoint, true); http.onreadystatechange = function () { var DONE = 4; // 4 means that the request is done var OK = 200; // 200 means a successful return if (http.readyState == DONE && http.status == OK && http.responseText) { // JSON string replyString = http.responseText; // JSON -> JS object replyObj = JSON.parse(replyString); // put the algorithm names in their ranked order document.getElementById("alg1_name").innerText = replyObj.name[0]; document.getElementById("alg2_name").innerText = replyObj.name[1]; document.getElementById("alg3_name").innerText = replyObj.name[2]; document.getElementById("alg4_name").innerText = replyObj.name[3]; document.getElementById("alg5_name").innerText = replyObj.name[4]; // put the algorithms' F1 scores in their ranked order document.getElementById("alg1_f1").innerText = replyObj.f1[0]; document.getElementById("alg2_f1").innerText = replyObj.f1[1]; document.getElementById("alg3_f1").innerText = replyObj.f1[2]; document.getElementById("alg4_f1").innerText = replyObj.f1[3]; document.getElementById("alg5_f1").innerText = replyObj.f1[4]; } else { console.log("Error getting ranked algorithms/F1 scores from the backend server. (Is it running?)"); } } function initializeIndex() { getTopFiveAlgorithms(); getTopFiveWords(); } No newline at end of file Loading
web/index.html +6 −6 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ <title>Spam Hunter</title> <!-- Meat 'n potatoes --> <body onload="getTopFiveAlgorithms()"> <body onload="initializeIndex()"> <div id="interactivity" class="jumbotron"> <!-- User interactivity portion --> <h3>Type your message here:</h3> Loading @@ -24,11 +24,11 @@ <div id="spam_words_list"> <p>Top 5 words most commonly used in spam: <ol> <li>Sex</li> <li>Prize</li> <li>Singles</li> <li>Larry</li> <li>Win</li> <li id="top1">Sex</li> <li id="top2">Prize</li> <li id="top3">Singles</li> <li id="top4">Larry</li> <li id="top5">Win</li> </ol> </p> </div> Loading
web/js/main.js +47 −4 Original line number Diff line number Diff line Loading @@ -63,8 +63,51 @@ function getTopFiveAlgorithms() { } // for debug purposes until the server communication is implemented var placeholder_name = "qaoweifj"; var placeholder_f1 = "75.43%"; document.getElementById("alg1_name").innerText = placeholder_name; document.getElementById("alg1_f1").innerText = placeholder_f1; //var placeholder_name = "qaoweifj"; //var placeholder_f1 = "75.43%"; //document.getElementById("alg1_name").innerText = placeholder_name; //document.getElementById("alg1_f1").innerText = placeholder_f1; } function getTopFiveWords() { var url = "http://localhost:8080" var endpoint = "/getWords" var http = new XMLHttpRequest(); http.open("GET", url + endpoint, true); http.onreadystatechange = function () { var DONE = 4; // 4 means that the request is done var OK = 200; // 200 means a successful return if (http.readyState == DONE && http.status == OK && http.responseText) { // JSON string replyString = http.responseText; // JSON -> JS object replyObj = JSON.parse(replyString); // put the algorithm names in their ranked order document.getElementById("alg1_name").innerText = replyObj.name[0]; document.getElementById("alg2_name").innerText = replyObj.name[1]; document.getElementById("alg3_name").innerText = replyObj.name[2]; document.getElementById("alg4_name").innerText = replyObj.name[3]; document.getElementById("alg5_name").innerText = replyObj.name[4]; // put the algorithms' F1 scores in their ranked order document.getElementById("alg1_f1").innerText = replyObj.f1[0]; document.getElementById("alg2_f1").innerText = replyObj.f1[1]; document.getElementById("alg3_f1").innerText = replyObj.f1[2]; document.getElementById("alg4_f1").innerText = replyObj.f1[3]; document.getElementById("alg5_f1").innerText = replyObj.f1[4]; } else { console.log("Error getting ranked algorithms/F1 scores from the backend server. (Is it running?)"); } } function initializeIndex() { getTopFiveAlgorithms(); getTopFiveWords(); } No newline at end of file