2018-12-26 06:14:05 +00:00
|
|
|
webpassword = ''
|
2018-12-27 05:27:46 +00:00
|
|
|
requested = []
|
|
|
|
|
|
|
|
document.getElementById('webpassWindow').style.display = 'block';
|
|
|
|
|
|
|
|
var windowHeight = window.innerHeight;
|
|
|
|
document.getElementById('webpassWindow').style.height = windowHeight + "px";
|
2018-12-26 06:14:05 +00:00
|
|
|
|
|
|
|
function httpGet(theUrl) {
|
|
|
|
var xmlHttp = new XMLHttpRequest()
|
|
|
|
xmlHttp.open( "GET", theUrl, false ) // false for synchronous request
|
|
|
|
xmlHttp.setRequestHeader('token', webpassword)
|
|
|
|
xmlHttp.send( null )
|
2018-12-27 05:27:46 +00:00
|
|
|
if (xmlHttp.status == 200){
|
|
|
|
return xmlHttp.responseText
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
return "";
|
|
|
|
}
|
2018-12-26 06:14:05 +00:00
|
|
|
}
|
|
|
|
function appendMessages(msg){
|
2018-12-27 05:27:46 +00:00
|
|
|
el = document.createElement('div')
|
|
|
|
el.className = 'entry'
|
|
|
|
el.innerText = msg
|
|
|
|
document.getElementById('feed').appendChild(el)
|
2018-12-26 06:14:05 +00:00
|
|
|
document.getElementById('feed').appendChild(document.createElement('br'))
|
|
|
|
}
|
|
|
|
|
|
|
|
function getBlocks(){
|
2018-12-27 05:27:46 +00:00
|
|
|
if (document.getElementById('none') !== null){
|
|
|
|
document.getElementById('none').remove();
|
|
|
|
|
|
|
|
}
|
2018-12-26 06:14:05 +00:00
|
|
|
var feedText = httpGet('/getblocksbytype/txt')
|
|
|
|
var blockList = feedText.split(',')
|
|
|
|
for (i = 0; i < blockList.length; i++){
|
2018-12-27 05:27:46 +00:00
|
|
|
if (! requested.includes(blockList[i])){
|
|
|
|
bl = httpGet('/gethtmlsafeblockdata/' + blockList[i])
|
|
|
|
appendMessages(bl)
|
|
|
|
requested.push(blockList[i])
|
|
|
|
}
|
|
|
|
}
|
2018-12-26 06:14:05 +00:00
|
|
|
}
|
|
|
|
|
2018-12-27 05:27:46 +00:00
|
|
|
document.getElementById('registerPassword').onclick = function(){
|
2018-12-26 06:14:05 +00:00
|
|
|
webpassword = document.getElementById('webpassword').value
|
2018-12-27 05:27:46 +00:00
|
|
|
if (httpGet('/ping') === 'pong!'){
|
|
|
|
document.getElementById('webpassWindow').style.display = 'none'
|
|
|
|
getBlocks()
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
alert('Sorry, but that password appears invalid.')
|
|
|
|
}
|
2018-12-26 06:14:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById('refreshFeed').onclick = function(){
|
|
|
|
getBlocks()
|
|
|
|
}
|