Uses 911K of libraries. Click here for Pure Java version (11407L/63K).
!7 cmodule Google { S query; L<SS> result; switchable S language = "lang_en"; transient int maxInputLength = 120; transient NotTooOften notTooOften = onlyEvery10Secs(); transient WaitForStableValue<S> waitForStableValue = new(5.0); transient volatile bool calculating; transient JTable table; transient SimpleLiveValue<S> lvQuery = stringLiveValue(); visual jLiveValueSection(lvQuery, dataToTable_uneditable(result, table = sexyTable())); void unvisualize() { table = null; } start { lvQuery.set(query); ownTimer(doEvery(1000, r updateMe)); } void update { S s = dm_getInterestingString(); if (nempty(s) && l(s) <= maxInputLength) { // TODO: more quality checks? waitForStableValue.set(s); } fS q = waitForStableValue!; if (nempty(q) && neq(q, query) && allowedToGoogleSomething()) dm_q(r { calc(q) }); } void calc(S q) { if (eq(query, q)) ret; query = q; result = null; lvQuery.set(q); temp tempSetField(this, calculating := true); L<T3S> l = quickGoogle2(q, language); result = map(l, func(T3S t) -> SS { litorderedmap("Result" := second(t), "Desc" := nullOnEmpty(third(t)), "Link" := first(t)) }); dataToTable_uneditable_ifHasTable(result, table); } bool allowedToGoogleSomething() { ret notTooOften.canDoAgain_willDoIfTrue(); } }
Began life as a copy of #1015833
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, vpdwwinrgdga
No comments. add comment
Snippet ID: | #1015891 |
Snippet name: | Google Search (Dyn Module v2, OK) |
Eternal ID of this version: | #1015891/18 |
Text MD5: | 317e223faea3ea1793093124488431b8 |
Transpilation MD5: | fb0b2f1adec7621a6a4bf1f2087a8a5b |
Author: | stefan |
Category: | |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-06-03 16:09:08 |
Source code size: | 1427 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 602 / 60990 |
Version history: | 17 change(s) |
Referenced in: | [show references] |