mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 14:04:34 +00:00
NC polling: do not reload while wizard is open
This commit is contained in:
@@ -96,6 +96,12 @@
|
|||||||
var lastSeen=null;
|
var lastSeen=null;
|
||||||
var endpoint='plugins/bratonien_tools/nc-connector-status.php';
|
var endpoint='plugins/bratonien_tools/nc-connector-status.php';
|
||||||
|
|
||||||
|
function wizardIsOpen() {
|
||||||
|
var dialog=document.getElementById('bratonien-nc-wizard-dialog');
|
||||||
|
if(dialog && dialog.open) return true;
|
||||||
|
try { return sessionStorage.getItem('bratonienNcWizardOpen')==='1'; } catch(e) { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
function poll() {
|
function poll() {
|
||||||
fetch(endpoint+'?_='+Date.now(),{credentials:'same-origin',cache:'no-store'})
|
fetch(endpoint+'?_='+Date.now(),{credentials:'same-origin',cache:'no-store'})
|
||||||
.then(function(response){if(!response.ok) throw new Error('HTTP '+response.status); return response.json();})
|
.then(function(response){if(!response.ok) throw new Error('HTTP '+response.status); return response.json();})
|
||||||
@@ -106,7 +112,7 @@
|
|||||||
if(lastSeen===null) {
|
if(lastSeen===null) {
|
||||||
lastSeen=timestamp;
|
lastSeen=timestamp;
|
||||||
var resultVisible=section.textContent.indexOf('Letztes Ergebnis:')!==-1;
|
var resultVisible=section.textContent.indexOf('Letztes Ergebnis:')!==-1;
|
||||||
if(!resultVisible && data.message) {
|
if(!resultVisible && data.message && !wizardIsOpen()) {
|
||||||
var reloadKey='bratonien-nc-status-reload-'+timestamp;
|
var reloadKey='bratonien-nc-status-reload-'+timestamp;
|
||||||
try {
|
try {
|
||||||
if(sessionStorage.getItem(reloadKey)!=='1') {
|
if(sessionStorage.getItem(reloadKey)!=='1') {
|
||||||
@@ -120,7 +126,7 @@
|
|||||||
|
|
||||||
if(timestamp>lastSeen) {
|
if(timestamp>lastSeen) {
|
||||||
lastSeen=timestamp;
|
lastSeen=timestamp;
|
||||||
window.location.reload();
|
if(!wizardIsOpen()) window.location.reload();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function(){});
|
.catch(function(){});
|
||||||
|
|||||||
Reference in New Issue
Block a user