Mercurial > libervia-templates
view default/input/field.html @ 84:b2ef34e602cf
base, js (websocket), css (main style): dynamic pages implementation, first draft:
this patch introduces the browser part of dynamic pages.
Dynamic pages work by establishing a websocket between server and the current page, if requested by server (which means that needed arguments are present in template).
Once the connection is established, the server can, for now, reload the page, append HTML elements, or receive arbitrary data (without reloading the page, in opposition to data post).
If connection can't be established, a popup will be displayed and connection will be retried many times after variable timeouts.
The browser will finally give up and display an alert to client if the number of retries is too high (20 for now).
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 03 Jan 2018 01:12:16 +0100 |
parents | f76ec90e0e1e |
children | 92ca411ee635 |
line wrap: on
line source
{% macro choices(name, choices_list, checked=none) %} {% for choice, label in choices_list %} <div class="form_input"> <input id="{{name|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}><label for="{{name|cur_gidx}}">{{label}}</label> </div> {% endfor %} {% endmacro %} {% macro int(name, label="", init=0) %} <span class="form_input"> <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="number" name="{{name}}" value="{{init}}" step="1" min="0"> </span> {% endmacro %} {% macro text(name, label="", placeholder="", required=false) %} {# single line text field additional kwargs will be passed as attributes #} <span class="form_input"> <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="text" name="{{name}}" placeholder="{{placeholder}}" {{"required" if required}} {{kwargs|xmlattr}}> </span> {% endmacro %} {% macro password(name, label="", required=false) %} {# password field additional kwargs will be passed as attributes #} <span class="form_input"> <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="password" name="{{name}}" {{"required" if required}} {{kwargs|xmlattr}}> </span> {% endmacro %} {% macro email(name, label="", required=false) %} {# email field additional kwargs will be passed as attributes #} <span class="form_input"> <label id="{{name|next_gidx}}">{{label}}</label><input id="{{name|cur_gidx}}" type="email" name="{{name}}" {{"required" if required}} {{kwargs|xmlattr}}> </span> {% endmacro %} {% macro textarea(name, rows=10, cols=50, placeholder='') %} <textarea name="{{name}}" rows="{{rows}}" cols="{{cols}}" placeholder="{{placeholder}}"></textarea> {% endmacro %} {% macro meta(name, value) %} <input type="hidden" name="{{name}}" value="{{value}}"> {% endmacro %} {% macro submit(text=_("Send")) %} <input class="form_submit button" type="submit" value="{{text}}"> {% endmacro %}