Skip to content

Commit 7d565ec

Browse files
authored
Merge pull request BruceDevices#1694 from emericklaw/theme-builder-color-fix-and-new-author-url-fields
Theme builder LED color fix and new author and url fields
2 parents fd8e4bc + 23d5ac5 commit 7d565ec

File tree

1 file changed

+48
-27
lines changed

1 file changed

+48
-27
lines changed

static/build_theme.html

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,14 @@ <h1>Bruce Theme Builder</h1>
526526
<label for="themeNameInput">Theme Name:</label>
527527
<input type="text" id="themeNameInput" class="form-text" />
528528
</div>
529+
<div class="control-item">
530+
<label for="themeAuthorInput">Theme Author:</label>
531+
<input type="text" id="themeAuthorInput" class="form-text" />
532+
</div>
533+
<div class="control-item">
534+
<label for="themeUrlInput">Theme URL:</label>
535+
<input type="text" id="themeUrlInput" class="form-text" />
536+
</div>
529537
<div class="control-item">
530538
<label for="heightInput">Target Device:</label>
531539
<select id="heightInput" class="form-select"
@@ -543,27 +551,25 @@ <h1>Bruce Theme Builder</h1>
543551
<input type="text" id="heightInputCustom" class="form-text" value="105,140,180,222" />
544552
</div>
545553
<div class="control-item">
546-
<label for="qualityInput">Quality:</label>
554+
<label for="qualityInput">Image Quality:</label>
547555
<input type="range" id="qualityInput" min="0" max="1" step="0.1" value="0.8"
548556
oninput="updateQualityValue(this.value)">
549557
<div id="qualityValue" class="quality-value">0.8</div>
550558
</div>
551559
</div>
552560

553561
<div class="control-group">
554-
<div class="colors-group">
555-
<div class="control-item">
556-
<label for="priColor">Primary Color:</label>
557-
<input type="color" id="priColor" value="#ad007b" onchange="updateColorDisplay()">
558-
</div>
559-
<div class="control-item">
560-
<label for="secColor">Secondary Color:</label>
561-
<input type="color" id="secColor" value="#8c007b" onchange="updateColorDisplay()">
562-
</div>
563-
<div class="control-item">
564-
<label for="bgColor">Background Color:</label>
565-
<input type="color" id="bgColor" value="#000000" onchange="updateColorDisplay()">
566-
</div>
562+
<div class="control-item">
563+
<label for="priColor">Primary Color:</label>
564+
<input type="color" id="priColor" value="#ad007b" onchange="updateColorDisplay()">
565+
</div>
566+
<div class="control-item">
567+
<label for="secColor">Secondary Color:</label>
568+
<input type="color" id="secColor" value="#8c007b" onchange="updateColorDisplay()">
569+
</div>
570+
<div class="control-item">
571+
<label for="bgColor">Background Color:</label>
572+
<input type="color" id="bgColor" value="#000000" onchange="updateColorDisplay()">
567573
</div>
568574
<div class="border-control">
569575
<input type="checkbox" id="border" checked>
@@ -781,16 +787,26 @@ <h1>Bruce Theme Builder</h1>
781787
}
782788

783789
function getCommonMapping() {
784-
return {
785-
priColor: rgbToRGB565(document.getElementById('priColor').value),
786-
secColor: rgbToRGB565(document.getElementById('secColor').value),
787-
bgColor: rgbToRGB565(document.getElementById('bgColor').value),
788-
ledBright: document.getElementById('ledBrightnessInput').value,
789-
ledColor: document.getElementById('ledColor').value.substring(0, 7),
790-
ledEffect: document.getElementById('ledEffectInput').value,
791-
ledEffectSpeed: document.getElementById('ledSyncToEncoder').checked ? 11 : document.getElementById('ledEffectSpeedInput').value,
792-
ledEffectDirection: document.getElementById('ledEffectDirection').checked ? -1 : 1
793-
};
790+
const mapping = {};
791+
792+
const name = document.getElementById("themeNameInput").value.trim();
793+
const author = document.getElementById("themeAuthorInput").value.trim();
794+
const url = document.getElementById("themeUrlInput").value.trim();
795+
796+
if (name) mapping.name = name;
797+
if (author) mapping.author = author;
798+
if (url) mapping.url = url;
799+
800+
mapping.priColor = rgbToRGB565(document.getElementById('priColor').value);
801+
mapping.secColor = rgbToRGB565(document.getElementById('secColor').value);
802+
mapping.bgColor = rgbToRGB565(document.getElementById('bgColor').value);
803+
mapping.ledBright = document.getElementById('ledBrightnessInput').value;
804+
mapping.ledColor = document.getElementById('ledColor').value.substring(1, 7);
805+
mapping.ledEffect = document.getElementById('ledEffectInput').value;
806+
mapping.ledEffectSpeed = document.getElementById('ledSyncToEncoder').checked ? 11 : document.getElementById('ledEffectSpeedInput').value;
807+
mapping.ledEffectDirection = document.getElementById('ledEffectDirection').checked ? -1 : 1;
808+
809+
return mapping;
794810
}
795811

796812
async function generateAndDownload() {
@@ -846,11 +862,11 @@ <h1>Bruce Theme Builder</h1>
846862

847863
let fileType = file.type;
848864
let fileExtension = fileType.split('/')[1];
849-
const baseName = file.name.substring(0, file.name.lastIndexOf(".")) || file.name;
850865
let imageDataUrl = canvas.toDataURL(fileType, quality);
851866

867+
const baseName = file.name.substring(0, file.name.lastIndexOf(".")) || file.name;
852868
const blob = await fetch(imageDataUrl).then(res => res.blob());
853-
const fileName = `${baseName}.${fileExtension}`;
869+
const fileName = isGuid(baseName) ? `${name}.${fileExtension}` : `${baseName}.${fileExtension}`;
854870
jsonMapping[name] = fileName;
855871
imageFolder.file(fileName, blob);
856872
totalProcessed++;
@@ -1010,10 +1026,15 @@ <h1>Bruce Theme Builder</h1>
10101026
});
10111027
}
10121028

1029+
function isGuid(str) {
1030+
const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
1031+
return guidRegex.test(str);
1032+
}
1033+
10131034
createFileInputs();
10141035
setupDragAndDrop();
10151036
updateColorDisplay();
10161037
</script>
10171038
</body>
10181039

1019-
</html>
1040+
</html>

0 commit comments

Comments
 (0)