Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

42
LINES

< > BotCompany Repo | #1015866 // Google (Dyn Module, v1, works, but googles prematurely and never corrects it)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (9113L/65K).

!7

static SimpleLiveValue<S> input = new(S);
static L<SS> result;
static NotTooOften notTooOften = onlyEvery10Secs();
static int maxInputLength = 120;

static transient JTable table;
static transient ReliableSingleThread rst;

static JComponent visualize() { ret dataToTable_uneditable(result, table = sexyTable()); }
static void unvisualize2() { table = null; }  

p { input.onChange(rst = ReliableSingleThread(r doIt)); }

svoid update {
  S s = (S) callOpt(creator(), 'getInterestingString);
  if (nempty(s) && l(s) <= maxInputLength) { // TODO: more quality checks
    print("Have input: " + s + ", old input: " + input!);
    input.set(s);
  }
}

static void doIt() {
  print("doIt");
  if (allowedToGoogleSomething())
    calc();
}
  
static void calc() {
  L<T3<S>> l = quickGoogle2(input!);
  result = map(l, func(T3<S> t) -> SS {
    litorderedmap("Result" := second(t), "Desc" := third(t), "Link" := first(t))
  });
  JTable t = table;
  if (t != null)
    dataToTable_uneditable(result, t);
}

sbool allowedToGoogleSomething() {
  ret notTooOften.canDoAgain_willDoIfTrue();
}

Author comment

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: 290 / 674
Version history: 1 change(s)
Referenced in: [show references]