Libraryless. Click here for Pure Java version (5586L/32K).
sclass HSlider { S id = aGlobalID(), name, label, unit; double min, max, value, step = 1; bool useWebSocket = true; !include #1028121 // setField + change() bool requiresWebSocket() { true; } // ID of numerical value display S valueID() { ret id + "_value"; } S html() { ret div(span(str(value), id := valueID()) + prependSpaceIfNempty(unit), style := "width: 8ch; display: inline-block; text-align: right") + " " + tag input("", type := "range", +id, +name, +min, +max, +value, +step, oninput := !useWebSocket ? null : jsDollarVars([[ document.getElementById($valueID).innerHTML = this.value; if (typeof wsSend !== 'undefined') wsSend(JSON.stringify({sliderValue: {id: $id, value: this.value}})); ]], +id, +valueID())) + " " + hlabelFor(id, label); } void onWebSocketJSON(Map map) { Map map2 = optCast Map(map.get("sliderValue")), ret if null; S id = cast map2.get("id"); if (!eq(id, this.id)) ret; Number value = cast map2.get("value"); setField(value := toDouble(value)); } }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032454 |
Snippet name: | HSlider - HTML range slider |
Eternal ID of this version: | #1032454/21 |
Text MD5: | 82c0cd3e024b4f7f9350d2b6ff438878 |
Transpilation MD5: | 5dec1d692c2e84217fe9fdd393a0be15 |
Author: | stefan |
Category: | javax / html |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-24 15:53:46 |
Source code size: | 1122 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 197 / 368 |
Version history: | 20 change(s) |
Referenced in: | #1032598 - HInputField - HTML input field with WebSocket support [dev.] #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |