rubygoldberg-tracker/client/index.js
2019-09-27 15:20:10 +02:00

20 lines
699 B
JavaScript

let call_backend = function(e) {
type = event.target.getAttribute('name');
var url_base = document.forms["link"]["url-field"].value;
var run = document.forms["link"]["run-field"].value;
var link = document.forms["link"]["link-field"].value;
x = new XMLHttpRequest();
x.onreadystatechange = function() {
if (x.readyState === 4) {
console.log("response: " + x.responseText);
document.getElementById("result").innerHTML = x.responseText;
};
};
var url = "http://" + url_base + "/link/" + (type === "start" ? "start" : "handoff") + "/" + run + "/" + link;
// console.log(url);
x.open("GET", url, true);
x.send();
};