2020-08-05 03:35:45 +00:00
|
|
|
fetch('/shared/sidebar/sidebar.html', {
|
|
|
|
"method": "get",
|
|
|
|
headers: {
|
|
|
|
"token": webpass
|
|
|
|
}})
|
|
|
|
.then((resp) => resp.text())
|
|
|
|
.then(function(resp) {
|
|
|
|
document.getElementById('sidebarContainer').innerHTML = resp
|
2020-08-21 14:57:59 +00:00
|
|
|
var quickviews = bulmaQuickview.attach()
|
2020-10-03 22:43:18 +00:00
|
|
|
sidebarAddPeerRegister()
|
2020-08-05 03:35:45 +00:00
|
|
|
})
|
|
|
|
|
2020-10-03 22:43:18 +00:00
|
|
|
function sidebarAddPeerRegister(){
|
|
|
|
document.getElementById('addPeerBtn').onclick = function(){
|
|
|
|
let newPeer = document.getElementById('addPeerInput').value
|
|
|
|
fetch('/addpeer/' + newPeer, {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
"token": webpass
|
|
|
|
}})
|
|
|
|
.then((resp) => resp.text())
|
|
|
|
.then(function(data) {
|
|
|
|
if (data == "success"){
|
|
|
|
PNotify.success({
|
|
|
|
text: 'Peer added'
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
else if(data == "already added"){
|
|
|
|
PNotify.notice({
|
|
|
|
text: 'Peer already added'
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
PNotify.error({text: data})
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-05 03:35:45 +00:00
|
|
|
window.addEventListener("keydown", function(event) {
|
|
|
|
if (event.key === "s"){
|
2020-08-21 14:57:59 +00:00
|
|
|
if (document.activeElement.nodeName == "TEXTAREA" || document.activeElement.nodeName == "INPUT"){
|
|
|
|
if (! document.activeElement.hasAttribute("readonly")){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let refreshSideBar = function(){
|
|
|
|
if (document.hidden){return}
|
|
|
|
var existingValue = document.getElementById("insertingBlocks").innerText
|
2020-08-23 10:53:43 +00:00
|
|
|
var existingUploadValue = document.getElementById("uploadBlocks")
|
2020-08-21 14:57:59 +00:00
|
|
|
fetch('/getgeneratingblocks', {
|
|
|
|
"method": "get",
|
|
|
|
headers: {
|
|
|
|
"token": webpass
|
|
|
|
}})
|
|
|
|
.then((resp) => resp.text())
|
|
|
|
.then(function(resp) {
|
|
|
|
console.debug(resp.length, existingValue)
|
|
|
|
if (resp.length <= 2 && existingValue !== "0"){
|
|
|
|
document.getElementById("insertingBlocks").innerText = "0"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (existingValue === resp.split(',').length){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
document.getElementById("insertingBlocks").innerText = resp.split(',').length - 1
|
|
|
|
})
|
2020-08-23 10:53:43 +00:00
|
|
|
fetch('/getblockstoupload', {
|
|
|
|
"method": "get",
|
|
|
|
headers: {
|
|
|
|
"token": webpass
|
|
|
|
}})
|
|
|
|
.then((resp) => resp.text())
|
|
|
|
.then(function(resp) {
|
|
|
|
if (resp.length <= 2 && existingUploadValue !== "0"){
|
|
|
|
document.getElementById("uploadBlocks").innerText = "0"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (existingUploadValue === resp.split(',').length){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
document.getElementById("uploadBlocks").innerText = resp.split(',').length - 1
|
|
|
|
})
|
2020-08-21 14:57:59 +00:00
|
|
|
}
|
|
|
|
setInterval(refreshSideBar, 3000)
|
|
|
|
|
|
|
|
setTimeout(function(){document.getElementsByClassName('sidebarBtn')[0].click()}, 300)
|
2020-08-05 03:35:45 +00:00
|
|
|
}
|
|
|
|
}, true)
|