document.addEventListener("DOMContentLoaded",function() { document.getElementById("serverurl").addEventListener("input",updateServer); document.getElementById("apikey").addEventListener("input",updateAPIKey); document.getElementById("serverurl").addEventListener("change",checkServer); document.getElementById("apikey").addEventListener("change",checkServer); document.getElementById("serverurl").addEventListener("focusout",checkServer); document.getElementById("apikey").addEventListener("focusout",checkServer); chrome.runtime.onMessage.addListener(onInternalMessage); chrome.storage.local.get({"serverurl":"http://localhost:42010"},function(result) { document.getElementById("serverurl").value = result["serverurl"] checkServerMaybe() }); chrome.storage.local.get({"apikey":"BlackPinkInYourArea"},function(result) { document.getElementById("apikey").value = result["apikey"] checkServerMaybe() }); chrome.runtime.sendMessage({"type":"query"}) }); //this makes sure only the second call actually makes a request (the first request is pointless //when the other element isn't filled yet and might actually overwrite the correct result because //of a race condition) var done = 0 function checkServerMaybe() { done++; if (done == 2) { checkServer() } } function onInternalMessage(request,sender) { if (request.type == "response") { players = request.content html = ""; for (var i=0;i