-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rename liveReloadForce to livereloadForce
- Loading branch information
1 parent
8404bc3
commit ee17e88
Showing
3 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,60 @@ | ||
setTimeout(()=>{let isModal=!!document.querySelector("body.modal");if(isModal)return;let reloading=!1;if(window.self!==window.top)return;let redirecttimeout=0;let evtSource;let startStream=function(){let url=LiveReloadUrl+"?rockfrontend-livereload="+LiveReloadSecret;evtSource=new EventSource(url,{withCredentials:!0});evtSource.onmessage=function(event){let changed=event.data;if(!changed)return;if(reloading)return;if(document.hidden)return;console.log(changed);if(LiveReloadForce){document.querySelectorAll(".InputfieldStateChanged").forEach((input)=>{input.classList.remove("InputfieldStateChanged")})}else{if(document.querySelectorAll(".InputfieldStateChanged").length){console.log("detected change - unsaved changes prevent reload");setTimeout(()=>{UIkit.notification({message:"Unsaved changes prevent reload - use $config->liveReloadForce to force reload.",status:"warning",pos:"top-center",timeout:0,})},200);return} | ||
if(document.querySelectorAll("#pw-panel-shade").length){console.log("detected change - open panel prevents reload");UIkit.notification({message:"Open panel prevents reload - use $config->liveReloadForce to force reload.",status:"warning",pos:"top-center",timeout:0,});return}} | ||
let cnt=localStorage.getItem("livereload-count")||0;localStorage.setItem("livereload-count",++cnt);console.log("detected change - reloading "+cnt);reloading=!0;setTimeout(()=>{document.location.reload(!0)},redirecttimeout)}};startStream();console.log("RockFrontend is listening for file changes...")},1000) | ||
setTimeout(() => { | ||
let isModal = !!document.querySelector("body.modal"); | ||
if (isModal) return; | ||
let reloading = !1; | ||
if (window.self !== window.top) return; | ||
let redirecttimeout = 0; | ||
let evtSource; | ||
let startStream = function () { | ||
let url = LiveReloadUrl + "?rockfrontend-livereload=" + LiveReloadSecret; | ||
evtSource = new EventSource(url, { withCredentials: !0 }); | ||
evtSource.onmessage = function (event) { | ||
let changed = event.data; | ||
if (!changed) return; | ||
if (reloading) return; | ||
if (document.hidden) return; | ||
console.log(changed); | ||
if (LiveReloadForce) { | ||
document | ||
.querySelectorAll(".InputfieldStateChanged") | ||
.forEach((input) => { | ||
input.classList.remove("InputfieldStateChanged"); | ||
}); | ||
} else { | ||
if (document.querySelectorAll(".InputfieldStateChanged").length) { | ||
console.log("detected change - unsaved changes prevent reload"); | ||
setTimeout(() => { | ||
UIkit.notification({ | ||
message: | ||
"Unsaved changes prevent reload - use $config->livereloadForce to force reload.", | ||
status: "warning", | ||
pos: "top-center", | ||
timeout: 0, | ||
}); | ||
}, 200); | ||
return; | ||
} | ||
if (document.querySelectorAll("#pw-panel-shade").length) { | ||
console.log("detected change - open panel prevents reload"); | ||
UIkit.notification({ | ||
message: | ||
"Open panel prevents reload - use $config->livereloadForce to force reload.", | ||
status: "warning", | ||
pos: "top-center", | ||
timeout: 0, | ||
}); | ||
return; | ||
} | ||
} | ||
let cnt = localStorage.getItem("livereload-count") || 0; | ||
localStorage.setItem("livereload-count", ++cnt); | ||
console.log("detected change - reloading " + cnt); | ||
reloading = !0; | ||
setTimeout(() => { | ||
document.location.reload(!0); | ||
}, redirecttimeout); | ||
}; | ||
}; | ||
startStream(); | ||
console.log("RockFrontend is listening for file changes..."); | ||
}, 1000); |