supla-device
Loading...
Searching...
No Matches
Supla::WebSender Class Referenceabstract
Inheritance diagram for Supla::WebSender:

Public Member Functions

virtual ~WebSender ()
 Base interface for emitting generated HTML.
virtual void send (const char *, int size=-1)=0
virtual void sendSafe (const char *, int size=-1)
virtual void send (int number)
virtual void send (int number, int precision)
virtual void sendNameAndId (const char *id)
virtual void sendLabelFor (const char *id, const char *label)
virtual void sendSelectItem (int value, const char *label, bool selected, bool emptyValue=false)
virtual void sendHidden (bool hidden)
virtual void sendReadonly (bool readonly)
virtual void sendDisabled (bool disabled)
virtual void sendTimestamp (uint32_t timestamp)
template<typename Fn>
void formField (Fn &&fn, const char *className="form-field")
 Emit a <div class="form-field">...</div> block.
template<typename Fn>
void labeledField (const char *id, const char *text, Fn &&fn, const char *className="form-field")
 Emit a labeled field wrapper.
template<typename Fn>
void toggleBox (const char *id, bool visible, Fn &&fn, const char *className=nullptr)
 Emit a <div> whose visibility is controlled via display.
template<typename Fn>
void selectInput (const char *name, const char *id, Fn &&fn)
 Emit a <select> block with optional name and id.
HtmlTag selectTag (const char *name, const char *id)
 Start a <select> tag builder.
void labelFor (const char *id, const char *text)
 Emit a <label for="...">...</label> pair.
void textInput (const char *name, const char *id, const char *value=nullptr, int maxLength=-1)
 Emit a text input control.
void passwordInput (const char *name, const char *id)
 Emit a password input control.
void checkboxInput (const char *name, const char *id, bool checked, const char *value="on")
 Emit a checkbox input control.
void numberInput (const char *key, const NumericInputSpec &spec, const char *cssClass=nullptr)
 Emit a numeric input control.
void rangeInput (const char *key, const NumericInputSpec &spec, const char *cssClass=nullptr)
 Emit a range input control.
void numberInput (const char *name, const char *id, const NumericInputSpec &spec, const char *cssClass=nullptr)
 Emit a numeric input control with separate name and id.
void rangeInput (const char *name, const char *id, const NumericInputSpec &spec, const char *cssClass=nullptr)
 Emit a range input control with separate name and id.
void selectOption (int value, int text, bool selected=false)
 Emit a single <option> element.
void selectOption (int value, const char *text, bool selected=false)
void selectOption (const char *value, int text, bool selected=false)
void selectOption (const char *value, const char *text, bool selected=false)
HtmlTag tag (const char *tagName, bool paired=true)
 Start an HTML tag builder.
HtmlTag voidTag (const char *tagName)
 Start a builder for a void HTML tag such as <input>.

Constructor & Destructor Documentation

◆ ~WebSender()

Supla::WebSender::~WebSender ( )
virtual

Base interface for emitting generated HTML.

The class exposes low-level send() primitives plus a small streaming HTML builder. The builder is designed for embedded targets and avoids dynamic string assembly.

Example:

sender->formField([&]() {
sender->labelFor("ssid", "Wi-Fi name");
sender->textInput("ssid", "ssid", currentSsid);
});

Use the lower-level tag() / voidTag() helpers when you need direct control over the generated markup.

Member Function Documentation

◆ checkboxInput()

void Supla::WebSender::checkboxInput ( const char * name,
const char * id,
bool checked,
const char * value = "on" )

Emit a checkbox input control.

The value attribute defaults to on, which matches standard HTML checkbox semantics.

◆ formField()

template<typename Fn>
void Supla::WebSender::formField ( Fn && fn,
const char * className = "form-field" )
inline

Emit a <div class="form-field">...</div> block.

The default class name is form-field, but it can be overridden when a different wrapper class is needed.

◆ labeledField()

template<typename Fn>
void Supla::WebSender::labeledField ( const char * id,
const char * text,
Fn && fn,
const char * className = "form-field" )
inline

Emit a labeled field wrapper.

This couples the label and the control into one semantic unit, which keeps the HTML classes shorter and avoids repeating the for/id pairing.

◆ numberInput()

void Supla::WebSender::numberInput ( const char * key,
const NumericInputSpec & spec,
const char * cssClass = nullptr )

Emit a numeric input control.

The FixedValue fields allow integer and fixed-point values without forcing call sites to preformat strings.

◆ rangeInput()

void Supla::WebSender::rangeInput ( const char * key,
const NumericInputSpec & spec,
const char * cssClass = nullptr )

Emit a range input control.

This mirrors numberInput but uses type="range" for slider-style controls.

◆ selectTag()

HtmlTag Supla::WebSender::selectTag ( const char * name,
const char * id )
inline

Start a <select> tag builder.

This is the low-level variant when extra attributes such as onchange need to be chained manually before calling HtmlTag::body().

◆ tag()

HtmlTag Supla::WebSender::tag ( const char * tagName,
bool paired = true )
inline

Start an HTML tag builder.

The returned object emits <tagName immediately and finishes the tag automatically at scope exit if it has not already been completed.

◆ textInput()

void Supla::WebSender::textInput ( const char * name,
const char * id,
const char * value = nullptr,
int maxLength = -1 )

Emit a text input control.

Generates an <input type="text"> element. The value attribute is emitted only when value != nullptr.

◆ toggleBox()

template<typename Fn>
void Supla::WebSender::toggleBox ( const char * id,
bool visible,
Fn && fn,
const char * className = nullptr )
inline

Emit a <div> whose visibility is controlled via display.

The helper is useful for UI sections that are shown or hidden as a block depending on a checkbox or another configuration value.


The documentation for this class was generated from the following files: