Warning: session_start(): open(/var/lib/php/sessions/sess_kk36cr0l6h3gkf19va0tudh15t, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
sclass UniversalSearch extends DynModule {
S query;
transient L result;
transient Q q;
transient int maxInputLength = 120;
transient WaitForStableValue waitForStableValue = new(1.0);
transient volatile bool calculating;
transient JTable table;
transient SimpleLiveValue lvQuery = stringLiveValue();
JComponent visualize() {
ret jLiveValueSection(lvQuery, dataToTable_uneditable(result, table = sexyTable()));
}
void unvisualize() { table = null; }
void start {
lvQuery.set(query);
q = startQ();
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))
this.q.add(r { calc(q) });
}
void calc(S q) {
if (eq(query, q)) ret;
result = null;
lvQuery.set(query = q);
temp tempSetField(this, calculating := true);
L> l = dm_universalSearch(q);
result = map(l, func(Pair p) -> SS {
litorderedmap("Result" := str(first(p)), "From Module" := second(p))
});
dataToTable_uneditable_ifHasTable(result, table);
}
}