Warning: session_start(): open(/var/lib/php/sessions/sess_2iauvbms7n8b3qn4asvi2h219u, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass HInputField {
S id = aGlobalID(), name, text;
bool useWebSocket = true, debug;
new MapSO params; // for tag
!include #1028121 // setField + change()
bool requiresWebSocket() { ret useWebSocket; }
bool requiresJQuery() { true; }
S html() {
new LS out;
out.add(tag input("", paramsPlus(params,
type := "text",
+name,
value := text,
+id)));
if (useWebSocket)
out.add(hjs_escapedDollarVars([[
(function() {
if (typeof wsSend === 'undefined') return;
var field = $("#" + $id);
if (field.length == 0) return;
var lastValue = field.val();
field.on('change keydown paste input', function() {
var value = field.val();
if (lastValue == value) return;
lastValue = value;
wsSend(JSON.stringify({inputFieldText: {id: $id, text: value}}));
});
})();
]], +id));
ret lines(out);
}
void onWebSocketJSON(Map map) {
Map map2 = optCast Map(map.get("inputFieldText")), ret if null;
S id = cast map2.get("id");
if (!eq(id, this.id)) ret;
S text = cast map2.get("text");
if (text != null) {
if (debug) print("Setting HInputField text: " + quote(text));
setField(+text);
}
}
}