Download Jar. Libraryless. Click here for Pure Java version (9113L/65K).
1 | !7 |
2 | |
3 | static SimpleLiveValue<S> input = new(S); |
4 | static L<SS> result; |
5 | static NotTooOften notTooOften = onlyEvery10Secs(); |
6 | static int maxInputLength = 120; |
7 | |
8 | static transient JTable table; |
9 | static transient ReliableSingleThread rst; |
10 | |
11 | static JComponent visualize() { ret dataToTable_uneditable(result, table = sexyTable()); } |
12 | static void unvisualize2() { table = null; } |
13 | |
14 | p { input.onChange(rst = ReliableSingleThread(r doIt)); } |
15 | |
16 | svoid update { |
17 | S s = (S) callOpt(creator(), 'getInterestingString); |
18 | if (nempty(s) && l(s) <= maxInputLength) { // TODO: more quality checks |
19 | print("Have input: " + s + ", old input: " + input!); |
20 | input.set(s); |
21 | } |
22 | } |
23 | |
24 | static void doIt() { |
25 | print("doIt"); |
26 | if (allowedToGoogleSomething()) |
27 | calc(); |
28 | } |
29 | |
30 | static void calc() { |
31 | L<T3<S>> l = quickGoogle2(input!); |
32 | result = map(l, func(T3<S> t) -> SS { |
33 | litorderedmap("Result" := second(t), "Desc" := third(t), "Link" := first(t)) |
34 | }); |
35 | JTable t = table; |
36 | if (t != null) |
37 | dataToTable_uneditable(result, t); |
38 | } |
39 | |
40 | sbool allowedToGoogleSomething() { |
41 | ret notTooOften.canDoAgain_willDoIfTrue(); |
42 | } |
Began life as a copy of #1015833
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1015866 |
Snippet name: | Google (Dyn Module, v1, works, but googles prematurely and never corrects it) |
Eternal ID of this version: | #1015866/2 |
Text MD5: | 4ebecfbc35e33458cae8537c0ceb5790 |
Transpilation MD5: | 325c36026ea447331d30d6f95dc03b65 |
Author: | stefan |
Category: | |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-05-29 13:14:18 |
Source code size: | 1130 bytes / 42 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 400 / 945 |
Version history: | 1 change(s) |
Referenced in: | [show references] |