Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ethancunt committed Oct 30, 2020
2 parents c81f248 + 735fdc6 commit 7c37c7a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 35 deletions.
71 changes: 37 additions & 34 deletions src/static/js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

$(document).ready(function (){
$(document).ready(function () {
//connect to the socket server.
var socket = io.connect('http://' + document.domain + ':' + location.port + '/socket');

Expand All @@ -10,62 +10,65 @@ $(document).ready(function (){
$('#total_flagged').html(msg.total_flagged.toString());
});

$("#save").click(function(e){
$("#save").click(function (e) {
e.preventDefault();
var btn = document.getElementById("save");
var status = document.getElementById("status");
var save = btn.innerHTML;
console.log(save);
if (btn.innerHTML == "Save"){
if (btn.innerHTML == "Save") {
btn.innerHTML = "Stop Saving";
status.innerHTML ="Capturing"
}else{
status.innerHTML = "Capturing"
} else {
console.log("change to Save");
btn.innerHTML = "Save";
status.innerHTML = "Monitoring"
}
var a = {'data':save};
var a = { 'data': save };
$.ajax({
type:'post',
url:'/save',
type: 'post',
url: '/save',
contentType: "application/json",
data:JSON.stringify(a),
success:function(data){
data: JSON.stringify(a),
success: function (data) {
}
});
});

});

$(".payload").click(function(){
var a = {'data':$(this).val()};
$(".payload").click(function () {
var a = { 'data': $(this).val() };
$.ajax({

type:'post',
url:'/flagged',
type: 'post',
url: '/flagged',
contentType: "application/json",
data:JSON.stringify(a),
success:function(data){
data: JSON.stringify(a),
success: function (data) {
document.getElementById("payload").innerHTML = data;
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
}

});
});

});
function update() {
if (window.location.pathname == "/logs") {
$.ajax({
type: 'POST',
url: '/logs',
success: function (data) {
var a = document.getElementById('output');
a.innerHTML = data;
},
});
}

}

var refInterval = window.setInterval(function () { update();}, 1000);

});

// var update = function() {
// $.ajax({
// type : 'POST',
// url : '/logs',
// success : function(data){
// var a = document.getElementById('output');
// a.innerHTML = data;
// },
// });
// };
// update();
// var refInterval = window.setInterval('update()', 1000); // 30 seconds
});
2 changes: 1 addition & 1 deletion src/templates/logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ <h6 class="m-0 font-weight-bold text-primary">Program Logs</h6>
<!-- Card Body -->
<div class="card-body">
<pre id="output"></pre>

</div>
</div>
</div>



{% endblock content%}

</body>
Expand Down

0 comments on commit 7c37c7a

Please sign in to comment.