window.onload = function(){ var container = document.getElementById("widguana-container"); var content = ''; /* Style */ content += ''; /* HTML */ content += '
'; content += ''; content += '
'; content += '

WidGuana

'; content += '

Sends HTTP Request To Iguna Agent.

'; content += ''; content += ''; content += '

Send Request

'; content += ''; content += '

Response:

'; content += '

'; content += 'Click here to [close]'; content += '
'; container.innerHTML = content; } /* Modal */ function overlay() { el = document.getElementById("widguana-overlay"); el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"; } /* XMLHttpRequest */ function httpGetIguna() { var xhttp; var request; var el = document.getElementById("widguana-requests"); var selected = el.options[el.selectedIndex].value; var response_cont = document.getElementById("widguana-response"); request = '//127.0.0.1:7778' + selected ; if (window.XMLHttpRequest){ xhttp = new XMLHttpRequest(); }else{ xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { //response.innerHTML = ''; //response = JSON.parse(xhttp.responseText); response = xhttp.responseText; console.log(response); response_cont.innerHTML = response; } }; xhttp.open("GET", request, true); xhttp.onprogress = function(){ response.innerHTML = 'Status: ' + xhttp.status; } xhttp.send(); }