!7 cmodule Google { S query; L result; switchable S language = "lang_en"; transient int maxInputLength = 120; transient NotTooOften notTooOften = onlyEvery10Secs(); transient WaitForStableValue waitForStableValue = new(5.0); transient volatile bool calculating; transient JTable table; transient SimpleLiveValue 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 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(); } }