Made "Text Alignment" a global setting instead of a per line setting

This commit is contained in:
nutty
2026-08-29 12:19:08 +10:00
parent acc187d072
commit f7b703007f
2 changed files with 20 additions and 50 deletions
+7 -8
View File
@@ -26,10 +26,12 @@ const line3 = document.getElementById('line3');
// OPTIONS // // OPTIONS //
///////////// /////////////
const font = urlParams.get("font") || "";
const language = urlParams.get("language") || "en"; const language = urlParams.get("language") || "en";
const timezone = urlParams.get("timezone") || ""; const timezone = urlParams.get("timezone") || "";
const font = urlParams.get("font") || "";
const textAlignment = urlParams.get("textAlignment") || "center";
const enableLine1 = GetBooleanParam("enableLine1", true); const enableLine1 = GetBooleanParam("enableLine1", true);
const line1Format = urlParams.get("line1Format") || "hh:mm:ss A"; const line1Format = urlParams.get("line1Format") || "hh:mm:ss A";
const line1FontSize = GetIntParam("line1FontSize", 50); const line1FontSize = GetIntParam("line1FontSize", 50);
@@ -37,7 +39,6 @@ const line1FontWeight = urlParams.get("line1FontWeight") || "700";
const line1FontColor = urlParams.get("line1FontColor") || "#ffffff"; const line1FontColor = urlParams.get("line1FontColor") || "#ffffff";
const line1FontOpacity = urlParams.get("line1FontOpacity") || "1"; const line1FontOpacity = urlParams.get("line1FontOpacity") || "1";
const line1TextTransform = urlParams.get("line1TextTransform") || "none"; const line1TextTransform = urlParams.get("line1TextTransform") || "none";
const line1TextAlignment = urlParams.get("line1TextAlignment") || "center";
const enableLine2 = GetBooleanParam("enableLine2", true); const enableLine2 = GetBooleanParam("enableLine2", true);
const line2Format = urlParams.get("line2Format") || "ddd, MMM D"; const line2Format = urlParams.get("line2Format") || "ddd, MMM D";
@@ -46,7 +47,6 @@ const line2FontWeight = urlParams.get("line2FontWeight") || "400";
const line2FontColor = urlParams.get("line2FontColor") || "#ffffff"; const line2FontColor = urlParams.get("line2FontColor") || "#ffffff";
const line2FontOpacity = urlParams.get("line2FontOpacity") || "0.7"; const line2FontOpacity = urlParams.get("line2FontOpacity") || "0.7";
const line2TextTransform = urlParams.get("line2TextTransform") || "none"; const line2TextTransform = urlParams.get("line2TextTransform") || "none";
const line2TextAlignment = urlParams.get("line2TextAlignment") || "center";
const enableLine3 = GetBooleanParam("enableLine3", false); const enableLine3 = GetBooleanParam("enableLine3", false);
const line3Format = urlParams.get("line3Format") || "ddd DD MMM YYYY hh:mm:ss A z"; const line3Format = urlParams.get("line3Format") || "ddd DD MMM YYYY hh:mm:ss A z";
@@ -55,7 +55,6 @@ const line3FontWeight = urlParams.get("line3FontWeight") || "600";
const line3FontColor = urlParams.get("line3FontColor") || "#ffffff"; const line3FontColor = urlParams.get("line3FontColor") || "#ffffff";
const line3FontOpacity = urlParams.get("line3FontOpacity") || "1"; const line3FontOpacity = urlParams.get("line3FontOpacity") || "1";
const line3TextTransform = urlParams.get("line3TextTransform") || "none"; const line3TextTransform = urlParams.get("line3TextTransform") || "none";
const line3TextAlignment = urlParams.get("line3TextAlignment") || "center";
@@ -130,7 +129,7 @@ document.head.appendChild(script);
// STYLING // // STYLING //
///////////// /////////////
function ApplyStyling(el, fontSize, fontWeight, fontColor, fontOpacity, textTransform, textAlignment) { function ApplyStyling(el, fontSize, fontWeight, fontColor, fontOpacity, textTransform) {
el.style.fontSize = fontSize + "px"; el.style.fontSize = fontSize + "px";
el.style.fontWeight = fontWeight; el.style.fontWeight = fontWeight;
el.style.color = fontColor; el.style.color = fontColor;
@@ -139,6 +138,6 @@ function ApplyStyling(el, fontSize, fontWeight, fontColor, fontOpacity, textTran
el.style.textAlign = textAlignment; el.style.textAlign = textAlignment;
} }
ApplyStyling(line1, line1FontSize, line1FontWeight, line1FontColor, line1FontOpacity, line1TextTransform, line1TextAlignment); ApplyStyling(line1, line1FontSize, line1FontWeight, line1FontColor, line1FontOpacity, line1TextTransform);
ApplyStyling(line2, line2FontSize, line2FontWeight, line2FontColor, line2FontOpacity, line2TextTransform, line2TextAlignment); ApplyStyling(line2, line2FontSize, line2FontWeight, line2FontColor, line2FontOpacity, line2TextTransform);
ApplyStyling(line3, line3FontSize, line3FontWeight, line3FontColor, line3FontOpacity, line3TextTransform, line3TextAlignment); ApplyStyling(line3, line3FontSize, line3FontWeight, line3FontColor, line3FontOpacity, line3TextTransform);
+13 -42
View File
@@ -57,6 +57,19 @@
"defaultValue": "", "defaultValue": "",
"group": "Appearance" "group": "Appearance"
}, },
{
"id": "textAlignment",
"label": "Text Alignment",
"description": "",
"type": "select",
"options": [
{ "value": "left", "label": "Left" },
{ "value": "center", "label": "Center" },
{ "value": "right", "label": "Right" }
],
"defaultValue": "center",
"group": "Appearance"
},
{ {
"id": "enableLine1", "id": "enableLine1",
"label": "Enable Line 1", "label": "Enable Line 1",
@@ -141,20 +154,6 @@
"showIf": "enableLine1", "showIf": "enableLine1",
"group": "Appearance" "group": "Appearance"
}, },
{
"id": "line1TextAlignment",
"label": "Text Alignment",
"description": "",
"type": "select",
"options": [
{ "value": "left", "label": "Left" },
{ "value": "center", "label": "Center" },
{ "value": "right", "label": "Right" }
],
"defaultValue": "center",
"showIf": "enableLine1",
"group": "Appearance"
},
{ {
"id": "enableLine2", "id": "enableLine2",
"label": "Enable Line 2", "label": "Enable Line 2",
@@ -239,20 +238,6 @@
"showIf": "enableLine2", "showIf": "enableLine2",
"group": "Appearance" "group": "Appearance"
}, },
{
"id": "line2TextAlignment",
"label": "Text Alignment",
"description": "",
"type": "select",
"options": [
{ "value": "left", "label": "Left" },
{ "value": "center", "label": "Center" },
{ "value": "right", "label": "Right" }
],
"defaultValue": "center",
"showIf": "enableLine2",
"group": "Appearance"
},
{ {
"id": "enableLine3", "id": "enableLine3",
"label": "Enable Line 3", "label": "Enable Line 3",
@@ -336,20 +321,6 @@
"defaultValue": "none", "defaultValue": "none",
"showIf": "enableLine3", "showIf": "enableLine3",
"group": "Appearance" "group": "Appearance"
},
{
"id": "line3TextAlignment",
"label": "Text Alignment",
"description": "",
"type": "select",
"options": [
{ "value": "left", "label": "Left" },
{ "value": "center", "label": "Center" },
{ "value": "right", "label": "Right" }
],
"defaultValue": "center",
"showIf": "enableLine3",
"group": "Appearance"
} }
] ]
} }