Transpiled version (3428L) is out of date.
sclass HTMLSuggestor { S makeData = "{}"; S ajaxURL = ""; int delay = 1000; S installTriggers = ""; S onGotResult = ""; bool verbose; S html() { if (empty(ajaxURL)) fail("Need ajaxURL"); ret hscript(replaceDollarVars([[ var sugVerbose = $verbose; var sugLoading = false, sugTriggerAgain = false; function sugTrigger() { //if (sugVerbose) console.log("sugTrigger"); if (sugLoading) { sugTriggerAgain = true; return; } // get form data as JSON var data = $makeData; const url = $calcURL; if (sugVerbose) { const urlWithParams = url + "?" + new URLSearchParams(data); console.log("Loading " + urlWithParams); } sugLoading = true; $.post(url, data, function(result) { if (sugVerbose) console.log("Suggestor result: " + result); const answer = !result ? "" : JSON.parse(result).answer; $onGotResult if (answer) { $("#liveResult .sectionContents").html(answer); $("#liveResult").show(); } else $("#liveResult").hide(); //$("#suggestorResult").html(answer ? "Suggestor says: " + answer : ""); } ).always(function() { if (sugVerbose) console.log("sug loading done"); setTimeout(function() { sugLoading = false; if (sugTriggerAgain) { sugTriggerAgain = false; sugTrigger(); } }, $delay); }); } $(document).ready(function() { $installTriggers sugTrigger(); }); ]], +verbose, +delay, +makeData, calcURL := jsQuote(ajaxURL), +installTriggers, +onGotResult)); } }
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031628 |
Snippet name: | HTMLSuggestor |
Eternal ID of this version: | #1031628/12 |
Text MD5: | ed2263f465ea2cfbb99989239eef3389 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-24 17:10:02 |
Source code size: | 1809 bytes / 57 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 194 / 504 |
Version history: | 11 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |