Skip to content

Commit

Permalink
Handle line feed in the input fields. Increase size of text input fie…
Browse files Browse the repository at this point in the history
…lds to 40.
  • Loading branch information
BlueAndi committed Aug 10, 2024
1 parent a2618b4 commit ea6d21e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/IconTextLampPlugin/web/IconTextLampPlugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ <h3 class="mt-1">Text</h3>
</div>
<div class="form-group">
<label for="justText">Text:</label>
<input type="text" id="justText" name="justText" value="" size="20" />
<input type="text" id="justText" name="justText" value="" size="40" />
</div>
<div class="form-group">
<label for="iconFullPath">Icon full path:</label>
Expand Down Expand Up @@ -276,7 +276,7 @@ <h3 class="mt-1">Lamp</h3>
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) {
Expand All @@ -289,6 +289,9 @@ <h3 class="mt-1">Lamp</h3>
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",
Expand Down
7 changes: 5 additions & 2 deletions lib/IconTextPlugin/web/IconTextPlugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ <h3 class="mt-1">Text</h3>
</div>
<div class="form-group">
<label for="justText">Text:</label>
<input type="text" id="justText" name="justText" value="" size="20" />
<input type="text" id="justText" name="justText" value="" size="40" />
</div>
<div class="form-group">
<label for="iconFullPath">Icon full path:</label>
Expand Down Expand Up @@ -233,7 +233,7 @@ <h3 class="mt-1">Text</h3>
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) {
Expand All @@ -246,6 +246,9 @@ <h3 class="mt-1">Text</h3>
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",
Expand Down
7 changes: 6 additions & 1 deletion lib/JustTextPlugin/web/JustTextPlugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h3 class="mt-1">Text</h3>
</div>
<div class="form-group">
<label for="justText">Text:</label>
<input type="text" id="justText" name="justText" value="" size="20" />
<input type="text" id="justText" name="justText" value="" size="40" />
</div>
<input name="submit" type="submit" value="Update"/>
</form>
Expand Down Expand Up @@ -156,6 +156,8 @@ <h3 class="mt-1">Text</h3>

justTextInput.value = rsp.data.text;

justTextInput.value = rsp.data.text.replaceAll("\n", "\\n");

}).catch(function(rsp) {
alert("Internal error.");
}).finally(function() {
Expand All @@ -166,6 +168,9 @@ <h3 class="mt-1">Text</h3>
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",
Expand Down

0 comments on commit ea6d21e

Please sign in to comment.