autoscroll sidebar log
This commit is contained in:
parent
60c7e6cb37
commit
8f52fa4669
@ -6,4 +6,9 @@
|
|||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#logfileOutput{
|
||||||
|
max-height: 700px;
|
||||||
|
overflow-y: scroll;
|
||||||
}
|
}
|
@ -20,8 +20,8 @@
|
|||||||
Add Peer
|
Add Peer
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<pre id="logfileOutput"></pre>
|
|
||||||
</div>
|
</div>
|
||||||
|
<pre id="logfileOutput"></pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,7 +10,12 @@ fetch('/shared/sidebar/sidebar.html', {
|
|||||||
sidebarAddPeerRegister()
|
sidebarAddPeerRegister()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var sidebarActive = false
|
||||||
var lastLogOffset = 0
|
var lastLogOffset = 0
|
||||||
|
|
||||||
|
var logActive = false
|
||||||
|
|
||||||
|
|
||||||
async function showLog(){
|
async function showLog(){
|
||||||
fetch('/readfileoffset/onionr.log?offset=' + lastLogOffset, {
|
fetch('/readfileoffset/onionr.log?offset=' + lastLogOffset, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@ -20,8 +25,12 @@ async function showLog(){
|
|||||||
.then((resp) => resp.json())
|
.then((resp) => resp.json())
|
||||||
.then(function(resp){
|
.then(function(resp){
|
||||||
lastLogOffset = resp['new_offset']
|
lastLogOffset = resp['new_offset']
|
||||||
document.getElementById('logfileOutput').innerText += resp.data.replace(
|
var logfileOutputEl = document.getElementById('logfileOutput')
|
||||||
|
logfileOutputEl.innerText += resp.data.replace(
|
||||||
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '')
|
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '')
|
||||||
|
if (!logActive){
|
||||||
|
logfileOutputEl.scrollTop = logfileOutputEl.scrollHeight;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,11 +81,20 @@ function sidebarAddPeerRegister(){
|
|||||||
|
|
||||||
window.addEventListener("keydown", function(event) {
|
window.addEventListener("keydown", function(event) {
|
||||||
var refreshSideBarInterval = null
|
var refreshSideBarInterval = null
|
||||||
|
document.getElementById('logfileOutput').onmouseenter = function(e){
|
||||||
|
logActive = true
|
||||||
|
}
|
||||||
|
document.getElementById('logfileOutput').onmouseleave = function(e){
|
||||||
|
logActive = false
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementsByClassName('closeSidebar')[0].onclick = function(){
|
document.getElementsByClassName('closeSidebar')[0].onclick = function(){
|
||||||
|
sidebarActive = false
|
||||||
clearInterval(sidebarLogInterval)
|
clearInterval(sidebarLogInterval)
|
||||||
clearInterval(refreshSideBarInterval)
|
clearInterval(refreshSideBarInterval)
|
||||||
}
|
}
|
||||||
if (event.key === "s"){
|
if (event.key === "s"){
|
||||||
|
sidebarActive = true
|
||||||
if (document.activeElement.nodeName == "TEXTAREA" || document.activeElement.nodeName == "INPUT"){
|
if (document.activeElement.nodeName == "TEXTAREA" || document.activeElement.nodeName == "INPUT"){
|
||||||
if (! document.activeElement.hasAttribute("readonly")){
|
if (! document.activeElement.hasAttribute("readonly")){
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user