From ea6d21e51e12324f1b7b8cdb46726d5c4e77dc99 Mon Sep 17 00:00:00 2001 From: BlueAndi Date: Sat, 10 Aug 2024 14:53:40 +0200 Subject: [PATCH] Handle line feed in the input fields. Increase size of text input fields to 40. --- lib/IconTextLampPlugin/web/IconTextLampPlugin.html | 7 +++++-- lib/IconTextPlugin/web/IconTextPlugin.html | 7 +++++-- lib/JustTextPlugin/web/JustTextPlugin.html | 7 ++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/IconTextLampPlugin/web/IconTextLampPlugin.html b/lib/IconTextLampPlugin/web/IconTextLampPlugin.html index 5004ffa0..6badf554 100644 --- a/lib/IconTextLampPlugin/web/IconTextLampPlugin.html +++ b/lib/IconTextLampPlugin/web/IconTextLampPlugin.html @@ -111,7 +111,7 @@

Text

- +
@@ -276,7 +276,7 @@

Lamp

var justTextInput = document.getElementById(justTextId); var iconFullPathInput = document.getElementById(iconFullPathId); - justTextInput.value = rsp.data.text; + justTextInput.value = rsp.data.text.replaceAll("\n", "\\n"); iconFullPathInput.value = rsp.data.iconFullPath; }).catch(function(rsp) { @@ -289,6 +289,9 @@

Lamp

function setText(pluginUid, justText, iconFullPath) { disableUI(); + justText = justText.replaceAll("\\n", "\n"); + justText = justText.replaceAll("\\r", ""); + return utils.makeRequest({ method: "POST", url: "/rest/api/v1/display/uid/" + pluginUid + "/text", diff --git a/lib/IconTextPlugin/web/IconTextPlugin.html b/lib/IconTextPlugin/web/IconTextPlugin.html index 3b42702b..c1234d5b 100644 --- a/lib/IconTextPlugin/web/IconTextPlugin.html +++ b/lib/IconTextPlugin/web/IconTextPlugin.html @@ -95,7 +95,7 @@

Text

- +
@@ -233,7 +233,7 @@

Text

var justTextInput = document.getElementById(justTextId); var iconFullPathInput = document.getElementById(iconFullPathId); - justTextInput.value = rsp.data.text; + justTextInput.value = rsp.data.text.replaceAll("\n", "\\n"); iconFullPathInput.value = rsp.data.iconFullPath; }).catch(function(rsp) { @@ -246,6 +246,9 @@

Text

function setText(pluginUid, justText, iconFullPath) { disableUI(); + justText = justText.replaceAll("\\n", "\n"); + justText = justText.replaceAll("\\r", ""); + return utils.makeRequest({ method: "POST", url: "/rest/api/v1/display/uid/" + pluginUid + "/text", diff --git a/lib/JustTextPlugin/web/JustTextPlugin.html b/lib/JustTextPlugin/web/JustTextPlugin.html index bf4b1c3e..5b8dacf8 100644 --- a/lib/JustTextPlugin/web/JustTextPlugin.html +++ b/lib/JustTextPlugin/web/JustTextPlugin.html @@ -62,7 +62,7 @@

Text

- +
@@ -156,6 +156,8 @@

Text

justTextInput.value = rsp.data.text; + justTextInput.value = rsp.data.text.replaceAll("\n", "\\n"); + }).catch(function(rsp) { alert("Internal error."); }).finally(function() { @@ -166,6 +168,9 @@

Text

function setText(pluginUid, justText) { disableUI(); + justText = justText.replaceAll("\\n", "\n"); + justText = justText.replaceAll("\\r", ""); + return utils.makeRequest({ method: "POST", url: "/rest/api/v1/display/uid/" + pluginUid + "/text",