mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Full-text search: Add ooui-js call
This commit is contained in:
parent
879ef3a7d0
commit
477929e559
@ -59,6 +59,7 @@ class Xofulltext_searcher_html extends Xow_special_wtr__base implements Mustache
|
||||
Xopg_tag_wtr_.Add__xonotify (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__mustache (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_alertify_.Add_tags (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__ooui (head_tags, app.Fsys_mgr().Http_root());
|
||||
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xofulltext_searcher.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("bin", "xofulltext_searcher.js")));
|
||||
|
@ -43,28 +43,6 @@ class Xofulltext_searcher_svc implements Gfo_invk {
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void Compress(Ordered_hash wkr_hash) {
|
||||
int max = 2;
|
||||
int len = wkr_hash.Len();
|
||||
if (len > max) {
|
||||
synchronized (wkr_hash) {
|
||||
// create list for deleted items; in general, this list will never be more than 1
|
||||
List_adp deleted = List_adp_.New();
|
||||
|
||||
int bgn = len - max;
|
||||
for (int i = 0; i < bgn; i++) {
|
||||
Xofulltext_args_qry args = (Xofulltext_args_qry)wkr_hash.Get_at(i);
|
||||
deleted.Add(args);
|
||||
}
|
||||
|
||||
len = deleted.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xofulltext_args_qry args = (Xofulltext_args_qry)deleted.Get_at(i);
|
||||
wkr_hash.Del(args.page_guid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Search(Json_nde args) {
|
||||
// get search_args
|
||||
Xofulltext_args_qry search_args = Xofulltext_args_qry.New_by_json(args);
|
||||
@ -72,7 +50,7 @@ class Xofulltext_searcher_svc implements Gfo_invk {
|
||||
|
||||
// cancel any existing searches
|
||||
this.Cancel(search_args.page_guid);
|
||||
Compress(wkr_hash);
|
||||
Compress_cache(wkr_hash);
|
||||
synchronized (wkr_hash) {
|
||||
wkr_hash.Add(search_args.page_guid, search_args);
|
||||
}
|
||||
@ -186,6 +164,28 @@ class Xofulltext_searcher_svc implements Gfo_invk {
|
||||
private Xofulltext_cache_mgr Cache_mgr() {
|
||||
return Xosearch_fulltext_addon.Get_by_app(app).Cache_mgr();
|
||||
}
|
||||
private static void Compress_cache(Ordered_hash wkr_hash) {
|
||||
int max = 8; // cache no more than 8 tabs worth of queries
|
||||
int len = wkr_hash.Len();
|
||||
if (len > max) {
|
||||
synchronized (wkr_hash) {
|
||||
// create list for deleted items; in general, this list will never be more than 1
|
||||
List_adp deleted = List_adp_.New();
|
||||
|
||||
int bgn = len - max;
|
||||
for (int i = 0; i < bgn; i++) {
|
||||
Xofulltext_args_qry args = (Xofulltext_args_qry)wkr_hash.Get_at(i);
|
||||
deleted.Add(args);
|
||||
}
|
||||
|
||||
len = deleted.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xofulltext_args_qry args = (Xofulltext_args_qry)deleted.Get_at(i);
|
||||
wkr_hash.Del(args.page_guid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__search)) this.Search((Xofulltext_args_qry)m.ReadObj("v"));
|
||||
|
@ -63,6 +63,10 @@ public class Xopg_tag_wtr_ {
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("Progbar.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("Progbar_util.js")));
|
||||
}
|
||||
public static void Add__ooui(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "lib", "oojs-ui");
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(dir.GenSubFil_nest("oojs-ui-mediawiki.css")));
|
||||
}
|
||||
private static String Get_app_js_file(Xoa_app app) {
|
||||
if (app.Mode().Tid_is_http()) return "xo.app.http_server.js";
|
||||
return gplx.core.envs.Op_sys.Cur().Tid_is_drd() ? "xo.app.drd.js" : "xo.app.swt.js";
|
||||
|
Loading…
Reference in New Issue
Block a user