A card using manually created HTML elements #1050
lisz8
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
cheers...! |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was told to show a real-world example using hand-crafted HTML elements. The purpose of the card is to list files containing text. This is a wrapper around
shell_command
that callsgrep
(I have a HAOS installation; theshell_command
may not work in other installation types). The card code includes predefined options: where to search, subfolders to exclude, and filename masks to include. These options can then be enabled/disabled for each search.Using HTML elements requires noticeably more code than using just yaml; I have a template containing repeatable code and I added part of that template (the whole template is large). I'm not a professional programmer, so keep that in mind :) I'd be grateful for any opinions and advice.
The idea is that the template creates an object in the window containing all the helper functions and data. The object name is the _UUID variable, and each card using the template should have it set to an unique string. The object should also be extended by adding at least a few functions that will be called by the template when an UI event occurs. The function names are just convention: tabChange2, btnPress2, etc. Within such a function, elements can be distinguished by their IDs.
Shell command
Template:
Card:
Beta Was this translation helpful? Give feedback.
All reactions