Last active
December 5, 2018 13:08
-
-
Save theCaptain420/21e80c1b18c8d4eb0afec754cb4ea0d1 to your computer and use it in GitHub Desktop.
skrrt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>Hello world</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" type="text/css" media="screen" href="main.css" /> | |
<script src="main.js"></script> | |
<style> | |
table { | |
font-family: arial, sans-serif; | |
border-collapse: collapse; | |
width: 100%; | |
} | |
td, | |
th { | |
border: 1px solid white; | |
text-align: left; | |
padding: 8px; | |
} | |
tr:nth-child(even) { | |
background-color: grey; | |
} | |
</style> | |
</head> | |
<body> | |
<script src="https://code.jquery.com/jquery-1.11.1.js"></script> | |
<button onclick="hentpare()">skrret</button> | |
<table style="width:100%"> | |
<ul id="liste"></ul> | |
</table> | |
<script> | |
hentpare(); | |
function hentpare() { | |
var xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange = function () { | |
if (this.readyState == 4 && this.status == 200) { | |
console.log("virket") | |
console.log("response" + this.response); | |
//laver det om til object | |
var obj = JSON.parse(this.response) | |
var startappend = "<tr><th>onoff</th><th>normiel strøm</th><th>aktuel strøm</th><th>lysintensitet</th><th>farve</th><th>uniktID</th><th>hardwareID</th><th>softwareID</th></tr> " | |
$('#liste').append($(startappend)); | |
for (let index = 0; index < obj.length; index++) { | |
var start = '<tr>'; | |
var onoff = '<td>'+ obj[index].onoff+' </td>' | |
var normiel = '<td>'+ obj[index].normielStrom +' </td>' | |
var aktuel = '<td>'+ obj[index].aktuelStrom +' </td>' | |
var farve = '<td>'+ obj[index].farve +' </td>' | |
var uniktID = '<td>'+ obj[index].uniktID +' </td>' | |
var hardwareID = '<td>'+ obj[index].hardwareID +' </td>' | |
var softwareID = '<td>'+ obj[index].softwareID +' </td>' | |
var lysintensitet = '<td>'+ obj[index].lysintensitet +' </td>' | |
var slut = '</tr>' | |
var finallinje = start+onoff+normiel+aktuel+lysintensitet+farve+uniktID+hardwareID+softwareID+slut; | |
$('#liste').append($(finallinje)); | |
} | |
} | |
} | |
xmlhttp.open("GET", "http://localhost:8080/hent", true); | |
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | |
xmlhttp.send(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment