Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions wled00/data/edit.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
<meta name="author" content="DedeHai, based on editor by Me-No-Dev">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"><!-- prevent too much scaling on mobile -->
<link rel="shortcut icon" href="favicon.ico">
<link href="style.css" rel="stylesheet">
<!-- Optional lightweight JSON editor - fallback to textarea if CDN is unavailable -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.23.4/ace.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.23.4/mode-json.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.23.4/theme-monokai.min.js"></script>
<script src="common.js"></script>
<style>
/* Editor-specific styles */
body {
Expand Down Expand Up @@ -113,6 +107,33 @@
@keyframes spin { to { transform: rotate(360deg); } }
</style>
<script>
// load common.js with retry on error, then load Ace editor from CDN with retries, then load style.css
function loadFiles(u, r, cb) {
var s = document.createElement('script'),
// set 1s timeout if retry count is less than 10 (i.e. for Ace scripts)
tm = r < 10 ? setTimeout(() => { s.onload=s.onerror=null; cb(); }, 1000) : 0;
s.src = u;
s.onload = () => { clearTimeout(tm); cb(); };
s.onerror = () => {
clearTimeout(tm);
if (r !== 0) setTimeout(() => loadFiles(u, r < 0 ? r : r - 1, cb), 100); // if r is -1 or > 0 try again
else cb();
};
document.head.appendChild(s);
}

loadFiles('common.js', -1, () => {
const cdn = "https://cdnjs.cloudflare.com/ajax/libs/ace/1.23.4/";
// load external scripts in sequence (3 retries each)
loadFiles(cdn + 'ace.min.js', 3, () => {
loadFiles(cdn + 'mode-json.min.js', 3, () => {
loadFiles(cdn + 'theme-monokai.min.js', 3, () => {
// all scripts loaded (or skipped) load style.css
if (window.loadResources) loadResources(['style.css'], S);
});
});
});
});
var QueuedRequester = function(){ this.q=[]; this.r=false; this.x=null; }
QueuedRequester.prototype = {
_request: function(req){
Expand Down Expand Up @@ -558,7 +579,7 @@
};
}

function onBodyLoad(){
function S(){
var vars={};
window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(m,k,v){
vars[decodeURIComponent(k)]=decodeURIComponent(v);
Expand All @@ -577,7 +598,7 @@
}
</script>
</head>
<body onload="onBodyLoad()">
<body>
<div id="toast"></div>
<div id="loader"><div class="loader"></div></div>
<div id="top"></div>
Expand Down