Skip to content

Commit

Permalink
Fix dynamic replacements for other pages
Browse files Browse the repository at this point in the history
  • Loading branch information
huksley committed May 17, 2020
1 parent 190db80 commit 0346871
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 111 deletions.
29 changes: 26 additions & 3 deletions tools/cdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ writeChunks(
str
.replace(/\<link rel="stylesheet".*\>/gms, "")
.replace(/\<style\>.*\<\/style\>/gms, "%CSS%%SCSS%")
.replace(
/function GetV().*\<\/script\>/gms,
"function GetV() {var d=document;\n"
)
},
{
file: "settings_leds.htm",
Expand All @@ -187,6 +191,10 @@ writeChunks(
str
.replace(/\<link rel="stylesheet".*\>/gms, "")
.replace(/\<style\>.*\<\/style\>/gms, "%CSS%%SCSS%")
.replace(
/function GetV().*\<\/script\>/gms,
"function GetV() {var d=document;\n"
)
},
{
file: "settings_dmx.htm",
Expand All @@ -198,7 +206,11 @@ writeChunks(
mangle: str => {
const nocss = str
.replace(/\<link rel="stylesheet".*\>/gms, "")
.replace(/\<style\>.*\<\/style\>/gms, "%CSS%%SCSS%");
.replace(/\<style\>.*\<\/style\>/gms, "%CSS%%SCSS%")
.replace(
/function GetV().*\<\/script\>/gms,
"function GetV() {var d=document;\n"
);
return `
#ifdef WLED_ENABLE_DMX
${nocss}
Expand All @@ -219,6 +231,10 @@ const char PAGE_settings_dmx[] PROGMEM = R"=====()=====";
str
.replace(/\<link rel="stylesheet".*\>/gms, "")
.replace(/\<style\>.*\<\/style\>/gms, "%CSS%%SCSS%")
.replace(
/function GetV().*\<\/script\>/gms,
"function GetV() {var d=document;\n"
)
},
{
file: "settings_sync.htm",
Expand All @@ -231,6 +247,7 @@ const char PAGE_settings_dmx[] PROGMEM = R"=====()=====";
str
.replace(/\<link rel="stylesheet".*\>/gms, "")
.replace(/\<style\>.*\<\/style\>/gms, "%CSS%%SCSS%")
.replace(/function GetV().*\<\/script\>/gms, "function GetV() {\n")
},
{
file: "settings_time.htm",
Expand All @@ -243,6 +260,7 @@ const char PAGE_settings_dmx[] PROGMEM = R"=====()=====";
str
.replace(/\<link rel="stylesheet".*\>/gms, "")
.replace(/\<style\>.*\<\/style\>/gms, "%CSS%%SCSS%")
.replace(/function GetV().*\<\/script\>/gms, "function GetV() {\n")
},
{
file: "settings_sec.htm",
Expand All @@ -255,6 +273,10 @@ const char PAGE_settings_dmx[] PROGMEM = R"=====()=====";
str
.replace(/\<link rel="stylesheet".*\>/gms, "")
.replace(/\<style\>.*\<\/style\>/gms, "%CSS%%SCSS%")
.replace(
/function GetV().*\<\/script\>/gms,
"function GetV() {var d=document;\n"
)
}
],
"wled00/html_settings.h"
Expand All @@ -277,7 +299,8 @@ writeChunks(
prepend: "=====(",
append: ")=====",
method: "plaintext",
filter: "html-minify"
filter: "html-minify",
mangle: str => str.replace(/\<h2\>.*\<\/body\>/gms, "<h2>%MSG%</body>")
},
{
file: "dmxmap.htm",
Expand All @@ -288,7 +311,7 @@ writeChunks(
filter: "html-minify",
mangle: str => `
#ifdef WLED_ENABLE_DMX
${str}
${str.replace(/function FM\(\)[ ]?\{/gms, "function FM() {%DMXVARS%\n")}
#else
const char PAGE_dmxmap[] PROGMEM = R"=====()=====";
#endif
Expand Down
2 changes: 1 addition & 1 deletion wled00/data/dmxmap.htm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html><head><meta content='width=device-width' name='viewport'>
<title>DMX Map</title>
<script>function B(){window.history.back()};function RS(){window.location = "/settings";}function RP(){top.location.href="/";}function FM() {%DMXVARS%
<script>function B(){window.history.back()};function RS(){window.location = "/settings";}function RP(){top.location.href="/";}function FM() {
var dmxlabels = ["SET 0","RED","GREEN","BLUE","WHITE","SHUTTER","SET 255", "DISABLED"];
var dmxchans = [];
for (i=0;i<512;i++) {
Expand Down
60 changes: 20 additions & 40 deletions wled00/data/msg.htm
Original file line number Diff line number Diff line change
@@ -1,56 +1,36 @@
<!DOCTYPE html>
<html><head>
<html>

<head>
<meta content='width=device-width' name='viewport'>
<title>WLED Message</title>
<script>
function B() {
window.history.back();
}
function RS() {
window.location = "/settings";
}
function RP() {
top.location.href="/";
}
</script>
<script>function B() { window.history.back() }; function RS() { window.location = "/settings"; } function RP() { top.location.href = "/"; }</script>
<style>
:root {
--aCol: #D9B310;
--bCol: #0B3C5D;
--cCol: #1D2731;
--dCol: #328CC1;
--sCol: #000;
--tCol: #328CC1;
--cFn: Verdana;
}
.bt {
background: var(--bCol);
color: var(--tCol);
border: 0.3ch solid var(--bCol);
background: #333;
color: #fff;
font-family: Verdana, sans-serif;
border: .3ch solid #333;
display: inline-block;
filter: drop-shadow( -5px -5px 5px var(--sCol) );
font-family: var(--cFn), sans-serif;
font-size: 20px;
margin: 8px;
margin-top: 12px;
margin-top: 12px
}
input[type=file] {
font-size: 16px;
}

body {
font-family: var(--cFn), sans-serif;
font-family: Verdana, sans-serif;
text-align: center;
background: var(--cCol);
color: var(--tCol);
line-height: 200%;
margin: 0;
background-attachment: fixed;
background: #222;
color: #fff;
line-height: 200%%;
margin: 0
}
</style>
</head>

<body>
<h2>Sample message.</h2>
Sample detail.
<h2>Sample Message.</h2>
Sample Detail.
</body>
</html>

</html>
27 changes: 8 additions & 19 deletions wled00/data/settings.htm
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,23 @@
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>WLED Settings</title>
<style>
:root {
--aCol: #D9B310;
--bCol: #0B3C5D;
--cCol: #1D2731;
--dCol: #328CC1;
--sCol: #000;
--tCol: #328CC1;
--cFn: Verdana;
}
body {
text-align: center;
background: var(--cCol);
height: 100%;
background: #222;
height: 100;
margin: 0;
background-attachment: fixed;
}
html {
--h:11.55vh;
--h: 11.55vh;
}
button {
background: var(--bCol);
color: var(--tCol);
font-family: var(--cFn), Helvetica, sans-serif;
border: 0.3ch solid var(--bCol);
background: #333;
color: #fff;
font-family: Verdana, Helvetica, sans-serif;
border: 0.3ch solid #333;
display: inline-block;
filter: drop-shadow( -5px -5px 5px var(--sCol) );
font-size: 8vmin;
height:var(--h);
height: var(--h);
width: 95%;
margin-top: 2.4vh;
}
Expand Down
1 change: 1 addition & 0 deletions wled00/data/settings_dmx.htm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
}
}
function S(){GCH(15);GetV();mMap();}function H(){window.open("https://github.com/Aircoookie/WLED/wiki/DMX");}function B(){window.history.back();}
function GetV(){}
</script>
</head>
<body onload="S()">
Expand Down
2 changes: 1 addition & 1 deletion wled00/data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ body {
text-align: center;
background: #222;
color: #fff;
line-height: 200%%;
line-height: 200%;
margin: 0;
}
hr {
Expand Down
45 changes: 42 additions & 3 deletions wled00/data/update.htm
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
<!DOCTYPE html>
<html><head><meta content='width=device-width' name='viewport'><title>WLED Message</title><script>function B(){window.history.back()}</script>
<style>:root{--aCol:#D9B310;--bCol:#0B3C5D;--cCol:#1D2731;--dCol:#328CC1;--sCol:#000;--tCol:#328CC1;--cFn:Verdana;}.bt{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%}</style></head>
<body><h2>WLED Software Update</h2>Installed version: 0.8.5-dev<br>Download the latest binary: <a href="https://github.com/Aircoookie/WLED/releases"><img src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square"></a><br><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' class="bt" name='update' required><br><input type='submit' class="bt" value='Update!'></form><button type="button" class="bt" onclick="B()">Back</button></body></html>
<html>

<head>
<meta content='width=device-width' name='viewport'>
<title>WLED Update</title>
<script>function B() { window.history.back() }</script>
<style>
.bt {
background: #333;
color: #fff;
font-family: Verdana, sans-serif;
border: .3ch solid #333;
display: inline-block;
font-size: 20px;
margin: 8px;
margin-top: 12px
}

input[type=file] {
font-size: 16px
}

body {
font-family: Verdana, sans-serif;
text-align: center;
background: #222;
color: #fff;
line-height: 200%
}
</style>
</head>

<body>
<h2>WLED Software Update</h2>Installed version: 0.10.0<br>Download the latest binary: <a
href="https://github.com/Aircoookie/WLED/releases"><img
src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square"></a><br>
<form method='POST' action='/update' enctype='multipart/form-data'><input type='file' class="bt" name='update'
required><br><input type='submit' class="bt" value='Update!'></form><button type="button" class="bt"
onclick="B()">Back</button>
</body>

</html>
37 changes: 9 additions & 28 deletions wled00/html_other.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,18 @@ const char PAGE_msg[] PROGMEM = R"=====(<!DOCTYPE html><html><head><meta content
<title>WLED Message</title><script>
function B(){window.history.back()}function RS(){window.location="/settings"}function RP(){top.location.href="/"}
</script><style>
:root{--aCol:#D9B310;--bCol:#0B3C5D;--cCol:#1D2731;--dCol:#328CC1;--sCol:#000;--tCol:#328CC1;--cFn:Verdana}.bt{background:var(--bCol);color:var(--tCol);border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow( -5px -5px 5px var(--sCol) );font-family:var(--cFn),sans-serif;font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%;margin:0;background-attachment:fixed}
</style></head><body><h2>Sample message.</h2>Sample detail.</body></html>)=====";
.bt{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.3ch solid #333;display:inline-block;font-size:20px;margin:8px;margin-top:12px}body{font-family:Verdana,sans-serif;text-align:center;background:#222;color:#fff;line-height:200%%;margin:0}
</style></head><body><h2>%MSG%</body></html>)=====";


#ifdef WLED_ENABLE_DMX

// Autogenerated from wled00/data/dmxmap.htm, do not edit!!
const char PAGE_dmxmap[] PROGMEM = R"=====(<!DOCTYPE html><html><head><meta content="width=device-width" name="viewport">
<title>DMX Map</title><script>
function B(){window.history.back()};function RS(){window.location = "/settings";}function RP(){top.location.href="/";}function FM() {%DMXVARS%
var dmxlabels = ["SET 0","RED","GREEN","BLUE","WHITE","SHUTTER","SET 255", "DISABLED"];
var dmxchans = []; for (i=0;i<512;i++) {
dmxchans.push(7); // set all to DISABLED
}
for (i=0;i<LC;i++) {
FS = CS + (CG * i);
for (j=0;j<CN;j++) {
DA=FS+j;
dmxchans[DA-1] = CH[j];
}
}
DMXMap = "";
for (i=0;i<512;i++) {
isstart = "";
if ((i+1) % 10 == 0) {
isstart="S"
}
DMXMap += "<div class=\"anytype " + isstart + " type" + dmxchans[i] + "\">" + String(i+1) + "<br />" + dmxlabels[dmxchans[i]] + "</div>";
}
document.getElementById("map").innerHTML = DMXMap;
}</script><style>
function B(){window.history.back()}function RS(){window.location="/settings"}function RP(){top.location.href="/"}function FM() {%DMXVARS%
var t=["SET 0","RED","GREEN","BLUE","WHITE","SHUTTER","SET 255","DISABLED"],n=[];for(i=0;i<512;i++)n.push(7);for(i=0;i<LC;i++)for(FS=CS+CG*i,j=0;j<CN;j++)DA=FS+j,n[DA-1]=CH[j];for(DMXMap="",i=0;i<512;i++)isstart="",(i+1)%10==0&&(isstart="S"),DMXMap+='<div class="anytype '+isstart+" type"+n[i]+'">'+String(i+1)+"<br />"+t[n[i]]+"</div>";document.getElementById("map").innerHTML=DMXMap}
</script><style>
.anytype{border:1px solid #fff;margin:1px;float:left;width:100px;height:100px}.S{margin:0;border:2px solid #fff}.type7{color:#888;border:1px dotted grey}.type6{color:#fff}.type4{color:#fff;font-weight:700}.type3{color:#00f;font-weight:700}.type2{color:#0f0;font-weight:700}.type1{color:red;font-weight:700}.bt{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.3ch solid #333;display:inline-block;font-size:20px;margin:8px;margin-top:12px}body{font-family:Verdana,sans-serif;text-align:center;background:#222;color:#fff;line-height:200%%;margin:0}
</style></head><body onload="FM()"><div id="map">...</div></body></html>)=====";

Expand All @@ -49,11 +30,11 @@ const char PAGE_dmxmap[] PROGMEM = R"=====()=====";

// Autogenerated from wled00/data/update.htm, do not edit!!
const char PAGE_update[] PROGMEM = R"=====(<!DOCTYPE html><html><head><meta content="width=device-width" name="viewport">
<title>WLED Message</title><script>function B(){window.history.back()}</script>
<title>WLED Update</title><script>function B(){window.history.back()}</script>
<style>
:root{--aCol:#D9B310;--bCol:#0B3C5D;--cCol:#1D2731;--dCol:#328CC1;--sCol:#000;--tCol:#328CC1;--cFn:Verdana}.bt{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%}
</style></head><body><h2>WLED Software Update</h2>Installed version: 0.8.5-dev
<br>Download the latest binary: <a
.bt{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.3ch solid #333;display:inline-block;font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:Verdana,sans-serif;text-align:center;background:#222;color:#fff;line-height:200%}
</style></head><body><h2>WLED Software Update</h2>Installed version: 0.10.0<br>
Download the latest binary: <a
href="https://github.com/Aircoookie/WLED/releases"><img
src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square">
</a><br><form method="POST" action="/update" enctype="multipart/form-data">
Expand Down
Loading

0 comments on commit 0346871

Please sign in to comment.