mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
HTTP Server: Support popups [#264]
This commit is contained in:
parent
2e5994788f
commit
38bdc95acf
@ -31,9 +31,10 @@ public class Js_wtr {
|
|||||||
bfr.Add_byte(Byte_ascii.Paren_end).Add_byte_semic();
|
bfr.Add_byte(Byte_ascii.Paren_end).Add_byte_semic();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Js_wtr Prm_bry(byte[] bry) {
|
public Js_wtr Prm_str(String v) {return Prm_bry(Bry_.new_u8(v));}
|
||||||
|
public Js_wtr Prm_bry(byte[] v) {
|
||||||
Prm_spr();
|
Prm_spr();
|
||||||
Write_val(bry);
|
Write_val(v);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Js_wtr Prm_obj_ary(Object[] ary) {
|
public Js_wtr Prm_obj_ary(Object[] ary) {
|
||||||
|
@ -113,6 +113,9 @@ public class Gfo_url_parser_tst {
|
|||||||
@Test public void Protocol_less__qargs() {
|
@Test public void Protocol_less__qargs() {
|
||||||
tstr.Exec__parse("Special:Search/Earth?fulltext=yes").Test__segs("Special:Search", "Earth").Test__page("Earth").Test__qargs("fulltext", "yes");
|
tstr.Exec__parse("Special:Search/Earth?fulltext=yes").Test__segs("Special:Search", "Earth").Test__page("Earth").Test__qargs("fulltext", "yes");
|
||||||
}
|
}
|
||||||
|
@Test public void Http_server() {
|
||||||
|
tstr.Exec__parse("/wiki/Page?A=B").Test__segs("wiki", "Page").Test__page("Page").Test__qargs("A", "B");
|
||||||
|
}
|
||||||
@Test public void Parse_site_fast() {
|
@Test public void Parse_site_fast() {
|
||||||
tstr.Test_Parse_site_fast("http://a.org/B" , "a.org");
|
tstr.Test_Parse_site_fast("http://a.org/B" , "a.org");
|
||||||
tstr.Test_Parse_site_fast("http://a.org" , "a.org");
|
tstr.Test_Parse_site_fast("http://a.org" , "a.org");
|
||||||
|
@ -16,7 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|||||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||||
import org.junit.*; import gplx.core.tests.*;
|
import org.junit.*; import gplx.core.tests.*;
|
||||||
public class Http_request_parser_tst {
|
public class Http_request_parser_tst {
|
||||||
@Before public void init() {fxt.Clear();} private final Http_request_parser_fxt fxt = new Http_request_parser_fxt();
|
@Before public void init() {fxt.Clear();} private final Http_request_parser_fxt fxt = new Http_request_parser_fxt();
|
||||||
@Test public void Type_post() {
|
@Test public void Type_post() {
|
||||||
fxt.Test_type_post("POST /url HTTP/1.1", Http_request_itm.Type_post, "/url", "HTTP/1.1");
|
fxt.Test_type_post("POST /url HTTP/1.1", Http_request_itm.Type_post, "/url", "HTTP/1.1");
|
||||||
}
|
}
|
||||||
@ -53,9 +53,9 @@ public class Http_request_parser_tst {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Http_request_parser_fxt {
|
class Http_request_parser_fxt {
|
||||||
private final Http_request_parser parser;
|
private final Http_request_parser parser;
|
||||||
private final Http_client_rdr client_rdr = Http_client_rdr_.new_mem();
|
private final Http_client_rdr client_rdr = Http_client_rdr_.new_mem();
|
||||||
private final Http_server_wtr__mock server_wtr = new Http_server_wtr__mock();
|
private final Http_server_wtr__mock server_wtr = new Http_server_wtr__mock();
|
||||||
public Http_request_parser_fxt() {
|
public Http_request_parser_fxt() {
|
||||||
this.parser = new Http_request_parser(server_wtr, false);
|
this.parser = new Http_request_parser(server_wtr, false);
|
||||||
}
|
}
|
||||||
|
@ -17,24 +17,26 @@ package gplx.xowa.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gp
|
|||||||
import org.junit.*; import gplx.core.tests.*;
|
import org.junit.*; import gplx.core.tests.*;
|
||||||
import gplx.xowa.addons.apps.cfgs.mgrs.types.*;
|
import gplx.xowa.addons.apps.cfgs.mgrs.types.*;
|
||||||
public class Xoedit_itm_html_tst {
|
public class Xoedit_itm_html_tst {
|
||||||
private final Xoedit_itm_html_fxt fxt = new Xoedit_itm_html_fxt();
|
private final Xoedit_itm_html_fxt fxt = new Xoedit_itm_html_fxt();
|
||||||
@Test public void Build_html__memo() {
|
@Test public void Build_html__memo() {
|
||||||
fxt.Type_("memo").Key_("key1").Name_("name1").Html_cls_("html_cls1").Html_atrs_("key1=val1");
|
fxt.Type_("memo").Key_("key1").Name_("name1").Html_cls_("html_cls1").Html_atrs_("key1=val1");
|
||||||
|
|
||||||
// normal
|
// normal
|
||||||
fxt.Val_("data1").Test__Build_html("\n<textarea id=\"key1\" data-xocfg-key=\"key1\" data-xocfg-type=\"memo\" accesskey=\"d\" class=\"xocfg_data__memo html_cls1\" key1=val1>"
|
fxt.Val_("data1")
|
||||||
|
.Test__Build_html("\n<textarea id=\"key1\" data-xocfg-key=\"key1\" data-xocfg-type=\"memo\" accesskey=\"d\" class=\"xocfg_data__memo html_cls1\" key1=val1>"
|
||||||
+ "data1"
|
+ "data1"
|
||||||
+ "</textarea>");
|
+ "</textarea>");
|
||||||
|
|
||||||
// xml-tags
|
// xml-tags
|
||||||
fxt.Val_("<pre>~{page_text}</pre>").Test__Build_html("\n<textarea id=\"key1\" data-xocfg-key=\"key1\" data-xocfg-type=\"memo\" accesskey=\"d\" class=\"xocfg_data__memo html_cls1\" key1=val1>"
|
fxt.Val_("<pre>~{page_text}</pre>")
|
||||||
|
.Test__Build_html("\n<textarea id=\"key1\" data-xocfg-key=\"key1\" data-xocfg-type=\"memo\" accesskey=\"d\" class=\"xocfg_data__memo html_cls1\" key1=val1>"
|
||||||
+ "<pre>~{page_text}</pre>"
|
+ "<pre>~{page_text}</pre>"
|
||||||
+ "</textarea>");
|
+ "</textarea>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Xoedit_itm_html_fxt {
|
class Xoedit_itm_html_fxt {
|
||||||
private final Xocfg_type_mgr type_mgr = new Xocfg_type_mgr();
|
private final Xocfg_type_mgr type_mgr = new Xocfg_type_mgr();
|
||||||
private final Bry_bfr bry = Bry_bfr_.New();
|
private final Bry_bfr bry = Bry_bfr_.New();
|
||||||
|
|
||||||
public Xoedit_itm_html_fxt Type_(String v) {this.type = v; return this;} private String type;
|
public Xoedit_itm_html_fxt Type_(String v) {this.type = v; return this;} private String type;
|
||||||
public Xoedit_itm_html_fxt Key_(String v) {this.key = v; return this;} private String key;
|
public Xoedit_itm_html_fxt Key_(String v) {this.key = v; return this;} private String key;
|
||||||
|
@ -33,13 +33,30 @@ public class Xocfg_maint_svc {
|
|||||||
// exec
|
// exec
|
||||||
Xocfg_db_app db_app = Xocfg_db_app.New(app);
|
Xocfg_db_app db_app = Xocfg_db_app.New(app);
|
||||||
db_app.Conn().Txn_bgn("xo__cfg_maint__upsert");
|
db_app.Conn().Txn_bgn("xo__cfg_maint__upsert");
|
||||||
byte[] anch_find_bry = Bry_.new_a7("<a "), anch_repl_bry = Bry_.new_a7("<a tabindex=\"-1\" ");
|
byte[] anch_find_bry = Bry_.new_a7("<a "), anch_repl_bry = Bry_.new_a7(" tabindex=\"-1\"");
|
||||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||||
for (Xocfg_maint_nde nde : ndes) {
|
for (Xocfg_maint_nde nde : ndes) {
|
||||||
// parse help to html
|
// parse help to html
|
||||||
parser_mgr.Main().Parse_text_to_html(tmp_bfr, parser_mgr.Ctx(), parser_mgr.Ctx().Page(), true, Bry_.new_u8(nde.Help()));
|
parser_mgr.Main().Parse_text_to_html(tmp_bfr, parser_mgr.Ctx(), parser_mgr.Ctx().Page(), true, Bry_.new_u8(nde.Help()));
|
||||||
byte[] help = tmp_bfr.To_bry_and_clear();
|
byte[] help = tmp_bfr.To_bry_and_clear();
|
||||||
help = Bry_.Replace(help, anch_find_bry, anch_repl_bry); // replace "<a " with "<a tabindex=-1 " else tabbing will go to hidden anchors in help text
|
|
||||||
|
// add "tabindex=-1" to "<a>" tages else tabbing will go to hidden anchors in help text
|
||||||
|
int help_pos = 0;
|
||||||
|
while (true) {
|
||||||
|
int a_bgn = Bry_find_.Find_fwd(help, anch_find_bry, help_pos, help.length);
|
||||||
|
if (a_bgn == Bry_find_.Not_found) break;
|
||||||
|
int a_end = Bry_find_.Find_fwd(help, Byte_ascii.Angle_end, a_bgn, help.length);
|
||||||
|
if (a_end == Bry_find_.Not_found) {
|
||||||
|
Gfo_usr_dlg_.Instance.Warn_many("", "", "could not find closing > after <a", "src", help);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp_bfr.Add_mid(help, 0, a_end);
|
||||||
|
tmp_bfr.Add(anch_repl_bry);
|
||||||
|
tmp_bfr.Add_mid(help, a_end, help.length);
|
||||||
|
help = tmp_bfr.To_bry_and_clear();
|
||||||
|
help_pos = a_end;
|
||||||
|
}
|
||||||
|
|
||||||
// do insert
|
// do insert
|
||||||
if (nde.Type_is_grp()) {
|
if (nde.Type_is_grp()) {
|
||||||
|
@ -18,7 +18,6 @@ public class Xoa_thread_ {
|
|||||||
public static final String
|
public static final String
|
||||||
Key_page_async = "xowa.page.async"
|
Key_page_async = "xowa.page.async"
|
||||||
, Key_page_redlink = "xowa.page.redlink"
|
, Key_page_redlink = "xowa.page.redlink"
|
||||||
, Key_page_popup = "xowa.page.popup"
|
|
||||||
, Key_http_server_main = "xowa.http_server.main"
|
, Key_http_server_main = "xowa.http_server.main"
|
||||||
, Key_bldr_download = "xowa.bldr.download"
|
, Key_bldr_download = "xowa.bldr.download"
|
||||||
, Key_special_search_db = "xowa.special.search.db"
|
, Key_special_search_db = "xowa.special.search.db"
|
||||||
|
@ -91,7 +91,7 @@ public class Http_server_mgr implements Gfo_invk {
|
|||||||
String cmd = url_converter.Decode_str(url_encoded_str);
|
String cmd = url_converter.Decode_str(url_encoded_str);
|
||||||
app.Gfs_mgr().Run_str(cmd);
|
app.Gfs_mgr().Run_str(cmd);
|
||||||
}
|
}
|
||||||
public String Parse_page_to_html(Http_data__client data__client, byte[] wiki_domain, byte[] ttl_bry, byte mode) {
|
public String Parse_page_to_html(Http_data__client data__client, byte[] wiki_domain, byte[] ttl_bry, byte mode, boolean popup_enabled, String popup_mode, String popup_id) {
|
||||||
synchronized (thread_lock) {
|
synchronized (thread_lock) {
|
||||||
// create a shim gui to automatically handle default XOWA gui JS calls
|
// create a shim gui to automatically handle default XOWA gui JS calls
|
||||||
if (init_gui_needed) {
|
if (init_gui_needed) {
|
||||||
@ -102,7 +102,7 @@ public class Http_server_mgr implements Gfo_invk {
|
|||||||
// get the wiki
|
// get the wiki
|
||||||
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_make_init_y(wiki_domain); // assert init for Main_Page; EX:click zh.w on wiki sidebar; DATE:2015-07-19
|
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_make_init_y(wiki_domain); // assert init for Main_Page; EX:click zh.w on wiki sidebar; DATE:2015-07-19
|
||||||
if (Runtime_.Memory_total() > Io_mgr.Len_gb) Xowe_wiki_.Rls_mem(wiki, true); // release memory at 1 GB; DATE:2015-09-11
|
if (Runtime_.Memory_total() > Io_mgr.Len_gb) Xowe_wiki_.Rls_mem(wiki, true); // release memory at 1 GB; DATE:2015-09-11
|
||||||
|
|
||||||
// get the url / ttl
|
// get the url / ttl
|
||||||
if (Bry_.Len_eq_0(ttl_bry)) ttl_bry = wiki.Props().Main_page();
|
if (Bry_.Len_eq_0(ttl_bry)) ttl_bry = wiki.Props().Main_page();
|
||||||
Xoa_url url = wiki.Utl__url_parser().Parse(ttl_bry);
|
Xoa_url url = wiki.Utl__url_parser().Parse(ttl_bry);
|
||||||
@ -119,22 +119,31 @@ public class Http_server_mgr implements Gfo_invk {
|
|||||||
page.Html_data().Head_mgr().Itm__server().Init_by_http(data__client).Enabled_y_();
|
page.Html_data().Head_mgr().Itm__server().Init_by_http(data__client).Enabled_y_();
|
||||||
|
|
||||||
// generate html
|
// generate html
|
||||||
String rv = String_.new_u8(wiki.Html_mgr().Page_wtr_mgr().Gen(page, mode)); // NOTE: must generate HTML now in order for "wait" and "async_server" to work with text_dbs; DATE:2016-07-10
|
String rv = null;
|
||||||
boolean rebuild_html = false;
|
if (popup_enabled) {
|
||||||
switch (retrieve_mode) {
|
if (String_.Eq(popup_mode, "more"))
|
||||||
case File_retrieve_mode.Mode_skip: // noop
|
rv = wiki.Html_mgr().Head_mgr().Popup_mgr().Show_more(popup_id);
|
||||||
break;
|
else
|
||||||
case File_retrieve_mode.Mode_async_server:
|
rv = wiki.Html_mgr().Head_mgr().Popup_mgr().Show_init(popup_id, ttl_bry, ttl_bry);
|
||||||
rebuild_html = true;
|
}
|
||||||
app.Gui_mgr().Browser_win().Page__async__bgn(tab);
|
else {
|
||||||
break;
|
rv = String_.new_u8(wiki.Html_mgr().Page_wtr_mgr().Gen(page, mode)); // NOTE: must generate HTML now in order for "wait" and "async_server" to work with text_dbs; DATE:2016-07-10
|
||||||
case File_retrieve_mode.Mode_wait:
|
boolean rebuild_html = false;
|
||||||
rebuild_html = true;
|
switch (retrieve_mode) {
|
||||||
gplx.xowa.guis.views.Xog_async_wkr.Async(page, tab.Html_itm());
|
case File_retrieve_mode.Mode_skip: // noop
|
||||||
page = wiki.Page_mgr().Load_page(url, ttl, tab); // HACK: fetch page again so that HTML will now include img data
|
break;
|
||||||
break;
|
case File_retrieve_mode.Mode_async_server:
|
||||||
|
rebuild_html = true;
|
||||||
|
app.Gui_mgr().Browser_win().Page__async__bgn(tab);
|
||||||
|
break;
|
||||||
|
case File_retrieve_mode.Mode_wait:
|
||||||
|
rebuild_html = true;
|
||||||
|
gplx.xowa.guis.views.Xog_async_wkr.Async(page, tab.Html_itm());
|
||||||
|
page = wiki.Page_mgr().Load_page(url, ttl, tab); // HACK: fetch page again so that HTML will now include img data
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (rebuild_html) rv = String_.new_u8(wiki.Html_mgr().Page_wtr_mgr().Gen(page, mode));
|
||||||
}
|
}
|
||||||
if (rebuild_html) rv = String_.new_u8(wiki.Html_mgr().Page_wtr_mgr().Gen(page, mode));
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ class Http_server_wkr implements Gfo_invk {
|
|||||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New_w_size(64);
|
private final Bry_bfr tmp_bfr = Bry_bfr_.New_w_size(64);
|
||||||
private Socket_adp socket;
|
private Socket_adp socket;
|
||||||
private Http_data__client data__client;
|
private Http_data__client data__client;
|
||||||
|
private final Gfo_url_parser url_parser = new Gfo_url_parser();
|
||||||
public Http_server_wkr(Http_server_mgr server_mgr, int uid){
|
public Http_server_wkr(Http_server_mgr server_mgr, int uid){
|
||||||
this.server_mgr = server_mgr; this.uid = uid;
|
this.server_mgr = server_mgr; this.uid = uid;
|
||||||
this.app = server_mgr.App(); this.server_wtr = server_mgr.Server_wtr(); this.url_encoder = server_mgr.Encoder();
|
this.app = server_mgr.App(); this.server_wtr = server_mgr.Server_wtr(); this.url_encoder = server_mgr.Encoder();
|
||||||
@ -105,7 +106,7 @@ class Http_server_wkr implements Gfo_invk {
|
|||||||
page_html = url_parser.Err_msg();
|
page_html = url_parser.Err_msg();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
page_html = app.Http_server().Parse_page_to_html(data__client, url_parser.Wiki(), url_parser.Page(), url_parser.Action());
|
page_html = app.Http_server().Parse_page_to_html(data__client, url_parser.Wiki(), url_parser.Page(), url_parser.Action(), url_parser.Popup(), url_parser.Popup_mode(), url_parser.Popup_id());
|
||||||
page_html = Convert_page(page_html, root_dir_http, String_.new_u8(url_parser.Wiki()));
|
page_html = Convert_page(page_html, root_dir_http, String_.new_u8(url_parser.Wiki()));
|
||||||
}
|
}
|
||||||
Xosrv_http_wkr_.Write_response_as_html(client_wtr, Bool_.N, page_html);
|
Xosrv_http_wkr_.Write_response_as_html(client_wtr, Bool_.N, page_html);
|
||||||
|
@ -14,6 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
|||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.apps.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
|
package gplx.xowa.apps.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
|
||||||
|
import gplx.core.net.*; import gplx.core.net.qargs.*;
|
||||||
import gplx.langs.htmls.encoders.*;
|
import gplx.langs.htmls.encoders.*;
|
||||||
import gplx.xowa.htmls.hrefs.*;
|
import gplx.xowa.htmls.hrefs.*;
|
||||||
import gplx.xowa.wikis.pages.*;
|
import gplx.xowa.wikis.pages.*;
|
||||||
@ -25,13 +26,17 @@ class Http_url_parser {
|
|||||||
public byte[] Wiki() {return wiki;} public Http_url_parser Wiki_(String v) {this.wiki = Bry_.new_u8(v); return this;} private byte[] wiki;
|
public byte[] Wiki() {return wiki;} public Http_url_parser Wiki_(String v) {this.wiki = Bry_.new_u8(v); return this;} private byte[] wiki;
|
||||||
public byte[] Page() {return page;} public Http_url_parser Page_(String v) {this.page = Bry_.new_u8(v); return this;} private byte[] page;
|
public byte[] Page() {return page;} public Http_url_parser Page_(String v) {this.page = Bry_.new_u8(v); return this;} private byte[] page;
|
||||||
public byte Action() {return action;} public Http_url_parser Action_(byte v) {this.action = v; return this;} private byte action;
|
public byte Action() {return action;} public Http_url_parser Action_(byte v) {this.action = v; return this;} private byte action;
|
||||||
|
public String Popup_mode() {return popup_mode;} public Http_url_parser Popup_mode_(String v) {this.popup_mode = v; return this;} private String popup_mode;
|
||||||
|
public boolean Popup() {return popup;} public Http_url_parser Popup_(boolean v) {this.popup = v; return this;} private boolean popup;
|
||||||
|
public String Popup_id() {return popup_id;} public Http_url_parser Popup_id_(String v) {this.popup_id = v; return this;} private String popup_id;
|
||||||
public String Err_msg() {return err_msg;} public Http_url_parser Err_msg_(String v) {this.err_msg = v; return this;} private String err_msg;
|
public String Err_msg() {return err_msg;} public Http_url_parser Err_msg_(String v) {this.err_msg = v; return this;} private String err_msg;
|
||||||
|
|
||||||
public String To_str() {
|
public String To_str() {
|
||||||
Bry_bfr bfr = Bry_bfr_.New();
|
Bry_bfr bfr = Bry_bfr_.New();
|
||||||
bfr.Add_str_a7("wiki=").Add_safe(wiki).Add_byte_nl();
|
bfr.Add_str_a7("wiki=").Add_safe(wiki).Add_byte_nl();
|
||||||
bfr.Add_str_a7("page=").Add_safe(page).Add_byte_nl();
|
bfr.Add_str_a7("page=").Add_safe(page).Add_byte_nl();
|
||||||
bfr.Add_str_a7("action=").Add_byte(action).Add_byte_nl();
|
bfr.Add_str_a7("action=").Add_byte_variable(action).Add_byte_nl();
|
||||||
|
bfr.Add_str_a7("popup=").Add_yn(popup).Add_byte_nl();
|
||||||
bfr.Add_str_a7("err_msg=").Add_str_u8_null(err_msg).Add_byte_nl();
|
bfr.Add_str_a7("err_msg=").Add_str_u8_null(err_msg).Add_byte_nl();
|
||||||
return bfr.To_str_and_clear();
|
return bfr.To_str_and_clear();
|
||||||
}
|
}
|
||||||
@ -40,11 +45,45 @@ class Http_url_parser {
|
|||||||
public boolean Parse(byte[] url) {
|
public boolean Parse(byte[] url) {
|
||||||
try {
|
try {
|
||||||
// initial validations
|
// initial validations
|
||||||
if (url == null) return Fail(url, "invalid url; url is null");
|
if (url == null) return Fail(null, "invalid url; url is null");
|
||||||
int url_len = url.length;
|
int url_len = url.length;
|
||||||
if (url_len == 0) return Fail(url, "invalid url; url is empty");
|
if (url_len == 0) return Fail(null, "invalid url; url is empty");
|
||||||
if (url[0] != Byte_ascii.Slash) return Fail(url, "invalid url; must start with '/'");
|
if (url[0] != Byte_ascii.Slash) return Fail(url, "invalid url; must start with '/'");
|
||||||
|
|
||||||
|
Gfo_url_parser url_parser = new Gfo_url_parser();
|
||||||
|
Gfo_url url_obj = url_parser.Parse(url);
|
||||||
|
this.wiki = url_obj.Segs()[0];
|
||||||
|
|
||||||
|
int segs_len = url_obj.Segs().length;
|
||||||
|
if (segs_len > 1) {
|
||||||
|
byte[] x = url_obj.Segs()[2];
|
||||||
|
if (segs_len > 2) {
|
||||||
|
Bry_bfr bfr = Bry_bfr_.New();
|
||||||
|
for (int i = 2; i < segs_len; i++) {
|
||||||
|
if (i != 2) bfr.Add_byte_slash();
|
||||||
|
bfr.Add(url_obj.Segs()[i]);
|
||||||
|
}
|
||||||
|
x = bfr.To_bry_and_clear();
|
||||||
|
}
|
||||||
|
this.page = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
Gfo_qarg_mgr qarg_mgr = new Gfo_qarg_mgr().Init(url_obj.Qargs());
|
||||||
|
byte[] action_val = qarg_mgr.Read_bry_or("action", Bry_.Empty);
|
||||||
|
if (Bry_.Eq(action_val, Xoa_url_.Qarg__action__read))
|
||||||
|
this.action = Xopg_page_.Tid_read;
|
||||||
|
else if (Bry_.Eq(action_val, Xoa_url_.Qarg__action__edit))
|
||||||
|
this.action = Xopg_page_.Tid_edit;
|
||||||
|
else if (Bry_.Eq(action_val, Xoa_url_.Qarg__action__html))
|
||||||
|
this.action = Xopg_page_.Tid_html;
|
||||||
|
else if (Bry_.Eq(action_val, Qarg__action__popup)) {
|
||||||
|
this.popup = true;
|
||||||
|
this.popup_id = qarg_mgr.Read_str_or_null(Bry_.new_a7("popup_id"));
|
||||||
|
this.popup_mode = qarg_mgr.Read_str_or_null(Bry_.new_a7("popup_mode"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
// get wiki
|
// get wiki
|
||||||
int wiki_bgn = 1; // skip initial "/"
|
int wiki_bgn = 1; // skip initial "/"
|
||||||
int wiki_end = Bry_find_.Find_fwd_or(url, Byte_ascii.Slash, wiki_bgn, url_len, url_len);
|
int wiki_end = Bry_find_.Find_fwd_or(url, Byte_ascii.Slash, wiki_bgn, url_len, url_len);
|
||||||
@ -73,13 +112,16 @@ class Http_url_parser {
|
|||||||
this.action = Xopg_page_.Tid_edit;
|
this.action = Xopg_page_.Tid_edit;
|
||||||
else if (Bry_.Eq(url, action_val_bgn, action_val_end, Xoa_url_.Qarg__action__html))
|
else if (Bry_.Eq(url, action_val_bgn, action_val_end, Xoa_url_.Qarg__action__html))
|
||||||
this.action = Xopg_page_.Tid_html;
|
this.action = Xopg_page_.Tid_html;
|
||||||
else
|
else if (Bry_.Eq(url, action_val_bgn, action_val_end, Qarg__action__popup))
|
||||||
|
this.popup = true;
|
||||||
|
else // no "?action=" found; ignore "?"; EX: "A?action=unknown"
|
||||||
trim_page = false;
|
trim_page = false;
|
||||||
if (trim_page)
|
if (trim_page)
|
||||||
page_end = action_key_bgn;
|
page_end = action_key_bgn;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.page = url_encoder.Decode(Bry_.Mid(url, page_bgn, page_end));
|
this.page = url_encoder.Decode(Bry_.Mid(url, page_bgn, page_end));
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@ -90,10 +132,13 @@ class Http_url_parser {
|
|||||||
private boolean Fail(byte[] url, String err_msg) {
|
private boolean Fail(byte[] url, String err_msg) {
|
||||||
this.wiki = null;
|
this.wiki = null;
|
||||||
this.page = null;
|
this.page = null;
|
||||||
this.err_msg = err_msg + "; url=" + String_.new_u8(url);
|
this.err_msg = err_msg;
|
||||||
|
if (url != null)
|
||||||
|
this.err_msg += "; url=" + String_.new_u8(url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private static final byte[]
|
private static final byte[]
|
||||||
Qarg__action__frag = Bry_.Add(Byte_ascii.Question_bry, Xoa_url_.Qarg__action, Byte_ascii.Eq_bry) // "?action="
|
Qarg__action__frag = Bry_.Add(Byte_ascii.Question_bry, Xoa_url_.Qarg__action, Byte_ascii.Eq_bry) // "?action="
|
||||||
|
, Qarg__action__popup = Bry_.new_a7("popup")
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -38,20 +38,24 @@ public class Http_url_parser_tst {
|
|||||||
// action=html
|
// action=html
|
||||||
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1?action=html", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1").Action_(Xopg_page_.Tid_html));
|
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1?action=html", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1").Action_(Xopg_page_.Tid_html));
|
||||||
|
|
||||||
|
// action=popup
|
||||||
|
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1?action=popup", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1").Popup_(true));
|
||||||
|
|
||||||
// action=N/A
|
// action=N/A
|
||||||
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1?action=a", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1?action=a"));
|
fxt.Test__parse("/en.wikipedia.org/wiki/Page_1?action=a", fxt.Make().Wiki_("en.wikipedia.org").Page_("Page_1"));
|
||||||
|
|
||||||
// fail: null
|
// fail: null
|
||||||
fxt.Test__parse(null, fxt.Make().Err_msg_("invalid url; url is null; url="));
|
fxt.Test__parse(null, fxt.Make().Err_msg_("invalid url; url is null"));
|
||||||
|
|
||||||
// fail: empty
|
// fail: empty
|
||||||
fxt.Test__parse("", fxt.Make().Err_msg_("invalid url; url is empty; url="));
|
fxt.Test__parse("", fxt.Make().Err_msg_("invalid url; url is empty"));
|
||||||
|
|
||||||
// fail: missing '/' at start
|
// fail: missing '/' at start
|
||||||
fxt.Test__parse("en.wikipedia.org", fxt.Make().Err_msg_("invalid url; must start with '/'; url=en.wikipedia.org"));
|
fxt.Test__parse("en.wikipedia.org", fxt.Make().Err_msg_("invalid url; must start with '/'; url=en.wikipedia.org"));
|
||||||
|
/*
|
||||||
// fail: missing '/wiki/'
|
// fail: missing '/wiki/'
|
||||||
fxt.Test__parse("/en.wikipedia.org/Page_1", fxt.Make().Err_msg_("invalid url; must have '/wiki/' after wiki_domain; url=/en.wikipedia.org/Page_1"));
|
fxt.Test__parse("/en.wikipedia.org/Page_1", fxt.Make().Err_msg_("invalid url; must have '/wiki/' after wiki_domain; url=/en.wikipedia.org/Page_1"));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Http_url_parser_fxt {
|
class Http_url_parser_fxt {
|
||||||
|
@ -142,8 +142,11 @@ public class Xog_tab_itm implements Gfo_invk {
|
|||||||
}
|
}
|
||||||
Tab_name_(new_tab_name);
|
Tab_name_(new_tab_name);
|
||||||
usr_dlg.Prog_one("", "", "loading: ~{0}", String_.new_u8(ttl.Raw()));
|
usr_dlg.Prog_one("", "", "loading: ~{0}", String_.new_u8(ttl.Raw()));
|
||||||
if (wiki.Html_mgr().Head_mgr().Popup_mgr().Enabled())
|
|
||||||
this.Html_box().Html_js_eval_script("if (window.xowa_popups_hide_all != null) window.xowa_popups_hide_all();"); // should be more configurable; DATE:2014-07-09
|
// DELETE: no longer seems needed; popups always disappear when navigating to new page; DATE:2018-11-11
|
||||||
|
// if (wiki.Html_mgr().Head_mgr().Popup_mgr().Enabled())
|
||||||
|
// this.Html_box().Html_js_eval_script("if (window.xowa_popups_hide_all != null) window.xowa_popups_hide_all();"); // should be more configurable; DATE:2014-07-09
|
||||||
|
|
||||||
app.Thread_mgr_old().Page_load_mgr().Add_at_end(new Load_page_wkr(this, wiki, url, ttl)).Run();
|
app.Thread_mgr_old().Page_load_mgr().Add_at_end(new Load_page_wkr(this, wiki, url, ttl)).Run();
|
||||||
}
|
}
|
||||||
private void Show_url_loaded(Load_page_wkr wkr) {
|
private void Show_url_loaded(Load_page_wkr wkr) {
|
||||||
|
@ -31,6 +31,7 @@ public class Xog_win_itm__prog_href_mgr {
|
|||||||
}
|
}
|
||||||
Xoa_url url = Xoa_url.blank();
|
Xoa_url url = Xoa_url.blank();
|
||||||
app.Html__href_parser().Parse_as_url(url, Bry_.new_u8(href), wiki, page.Ttl().Page_txt());
|
app.Html__href_parser().Parse_as_url(url, Bry_.new_u8(href), wiki, page.Ttl().Page_txt());
|
||||||
usr_dlg.Prog_direct(String_.new_u8(url.To_bry(!show_status_url, Bool_.Y)));
|
if (!app.Mode().Tid_is_http()) // if http_server, do not write to progress bar, else will show up in console output (b/c gui_wkr for http_server is console); DATE:2018-11-11
|
||||||
|
usr_dlg.Prog_direct(String_.new_u8(url.To_bry(!show_status_url, Bool_.Y)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class Xoh_head_itm__popups extends Xoh_head_itm__base {
|
|||||||
}
|
}
|
||||||
@Override public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
@Override public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||||
wtr.Write_js_line(Jquery_init); // NOTE: must assert that jquery is init'd, else popup.js will not compile after going back / forward; DATE:2014-09-10
|
wtr.Write_js_line(Jquery_init); // NOTE: must assert that jquery is init'd, else popup.js will not compile after going back / forward; DATE:2014-09-10
|
||||||
wtr.Write_js_tail_load_lib(app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "popups", "popups.js"));
|
wtr.Write_js_tail_load_lib(app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "popups", "xo.popup.js"));
|
||||||
} public static final byte[] Jquery_init = Bry_.new_a7("xowa.js.jquery.init();"), Mw_init = Bry_.new_a7("xowa.js.mediaWiki.init();");
|
} public static final byte[] Jquery_init = Bry_.new_a7("xowa.js.jquery.init();"), Mw_init = Bry_.new_a7("xowa.js.mediaWiki.init();");
|
||||||
private static byte[] Css_url_day, Css_url_night;
|
private static byte[] Css_url_day, Css_url_night;
|
||||||
private static final byte[]
|
private static final byte[]
|
||||||
|
@ -15,6 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|||||||
*/
|
*/
|
||||||
package gplx.xowa.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
package gplx.xowa.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||||
import gplx.core.bits.*;
|
import gplx.core.bits.*;
|
||||||
|
import gplx.xowa.wikis.pages.*;
|
||||||
public class Xoh_head_mgr implements gplx.core.brys.Bfr_arg {
|
public class Xoh_head_mgr implements gplx.core.brys.Bfr_arg {
|
||||||
private Xoae_app app; private Xowe_wiki wiki; private Xoae_page page;
|
private Xoae_app app; private Xowe_wiki wiki; private Xoae_page page;
|
||||||
private Xoh_head_itm__base[] itms; private int itms_len;
|
private Xoh_head_itm__base[] itms; private int itms_len;
|
||||||
@ -59,7 +60,7 @@ public class Xoh_head_mgr implements gplx.core.brys.Bfr_arg {
|
|||||||
this.app = app; this.wiki = wiki; this.page = page;
|
this.app = app; this.wiki = wiki; this.page = page;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Xoh_head_mgr Init_dflts() {
|
public Xoh_head_mgr Init_dflts(byte html_gen_tid) {
|
||||||
if (page.Wtxt().Toc().Enabled()) itm__toc.Enabled_y_();
|
if (page.Wtxt().Toc().Enabled()) itm__toc.Enabled_y_();
|
||||||
if (wiki.Html_mgr().Head_mgr().Itm__top_icon().Enabled_y()) itm__top_icon.Enabled_y_();
|
if (wiki.Html_mgr().Head_mgr().Itm__top_icon().Enabled_y()) itm__top_icon.Enabled_y_();
|
||||||
if (wiki.Html_mgr().Head_mgr().Itm__title_rewrite().Enabled_y()) itm__title_rewrite.Enabled_y_();
|
if (wiki.Html_mgr().Head_mgr().Itm__title_rewrite().Enabled_y()) itm__title_rewrite.Enabled_y_();
|
||||||
@ -70,9 +71,7 @@ public class Xoh_head_mgr implements gplx.core.brys.Bfr_arg {
|
|||||||
itm__xo_elem.Enabled_y_();
|
itm__xo_elem.Enabled_y_();
|
||||||
itm__collapsible.Enabled_y_();
|
itm__collapsible.Enabled_y_();
|
||||||
itm__navframe.Enabled_y_();
|
itm__navframe.Enabled_y_();
|
||||||
boolean popups_enabled
|
boolean popups_enabled = html_gen_tid != Xopg_page_.Tid_edit && wiki.Html_mgr().Head_mgr().Popup_mgr().Enabled();
|
||||||
= !app.Mode().Tid_is_http() // do not enable if http_server, else js errors when calling xowa_exec; DATE:2016-06-22
|
|
||||||
&& wiki.Html_mgr().Head_mgr().Popup_mgr().Enabled(); // check user_cfg
|
|
||||||
itm__popups.Enabled_(popups_enabled);
|
itm__popups.Enabled_(popups_enabled);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -123,6 +122,7 @@ public class Xoh_head_mgr implements gplx.core.brys.Bfr_arg {
|
|||||||
Xoh_head_itm__base itm = list__js_include.Get_at(i);
|
Xoh_head_itm__base itm = list__js_include.Get_at(i);
|
||||||
itm.Write_js_include(app, wiki, page, wtr);
|
itm.Write_js_include(app, wiki, page, wtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tail_script_len = list__js_tail_script.Len();
|
int tail_script_len = list__js_tail_script.Len();
|
||||||
int window_onload_len = list__js_window_onload.Len();
|
int window_onload_len = list__js_window_onload.Len();
|
||||||
if (tail_script_len + window_onload_len > 0) {
|
if (tail_script_len + window_onload_len > 0) {
|
||||||
|
@ -19,6 +19,7 @@ import gplx.langs.jsons.*;
|
|||||||
import gplx.xowa.htmls.js.*;
|
import gplx.xowa.htmls.js.*;
|
||||||
import gplx.xowa.guis.views.*;
|
import gplx.xowa.guis.views.*;
|
||||||
import gplx.xowa.parsers.*;
|
import gplx.xowa.parsers.*;
|
||||||
|
import gplx.xowa.htmls.modules.popups.*;
|
||||||
public class Xoh_js_cbk implements Gfo_invk {
|
public class Xoh_js_cbk implements Gfo_invk {
|
||||||
private Xoae_app app;
|
private Xoae_app app;
|
||||||
private Xog_html_itm html_itm;
|
private Xog_html_itm html_itm;
|
||||||
@ -67,19 +68,22 @@ public class Xoh_js_cbk implements Gfo_invk {
|
|||||||
return String_.new_u8(page.Db().Text().Text_bry());
|
return String_.new_u8(page.Db().Text().Text_bry());
|
||||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
} catch (Exception e) {Err_.Noop(e); return null;}
|
||||||
}
|
}
|
||||||
private String Popups_get_async_bgn(GfoMsg m) {
|
|
||||||
try {
|
|
||||||
byte[] js_cbk = m.Args_getAt(0).Val_to_bry();
|
|
||||||
byte[] href_bry = m.Args_getAt(1).Val_to_bry();
|
|
||||||
return html_itm.Owner_tab().Wiki().Html_mgr().Head_mgr().Popup_mgr().Get_async_bgn(js_cbk, href_bry);
|
|
||||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
|
||||||
}
|
|
||||||
private String Popups_get_html(GfoMsg m) {
|
private String Popups_get_html(GfoMsg m) {
|
||||||
try {
|
try {
|
||||||
int popups_id = Int_.By_double(Double_.cast(m.Args_getAt(0).Val()));
|
String mode = m.Args_getAt(0).Val_to_str_or_empty();
|
||||||
byte[] href_bry = m.Args_getAt(1).Val_to_bry();
|
String popups_id = m.Args_getAt(1).Val_to_str_or_empty();
|
||||||
byte[] tooltip_bry = m.Args_getAt(2).Val_to_bry();
|
|
||||||
return html_itm.Owner_tab().Wiki().Html_mgr().Head_mgr().Popup_mgr().Show_init(popups_id, href_bry, tooltip_bry);
|
Xow_popup_mgr popup_mgr = html_itm.Owner_tab().Wiki().Html_mgr().Head_mgr().Popup_mgr();
|
||||||
|
if (String_.Eq(mode, "init")) {
|
||||||
|
byte[] href_bry = m.Args_getAt(2).Val_to_bry();
|
||||||
|
byte[] tooltip_bry = m.Args_getAt(3).Val_to_bry();
|
||||||
|
return popup_mgr.Show_init(popups_id, href_bry, tooltip_bry);
|
||||||
|
}
|
||||||
|
else if (String_.Eq(mode, "more"))
|
||||||
|
return popup_mgr.Show_more(popups_id);
|
||||||
|
else if (String_.Eq(mode, "all"))
|
||||||
|
popup_mgr.Show_all(popups_id);
|
||||||
|
return "";
|
||||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
} catch (Exception e) {Err_.Noop(e); return null;}
|
||||||
}
|
}
|
||||||
private String[] Get_title_meta(Xowe_wiki wiki, byte[] ttl_bry) {
|
private String[] Get_title_meta(Xowe_wiki wiki, byte[] ttl_bry) {
|
||||||
@ -175,7 +179,6 @@ public class Xoh_js_cbk implements Gfo_invk {
|
|||||||
else if (ctx.Match(k, Invk_get_page)) return Get_page(m);
|
else if (ctx.Match(k, Invk_get_page)) return Get_page(m);
|
||||||
else if (ctx.MatchIn(k, Invk_cmd, Invk_scripts_exec)) return Scripts_exec(m);
|
else if (ctx.MatchIn(k, Invk_cmd, Invk_scripts_exec)) return Scripts_exec(m);
|
||||||
else if (ctx.Match(k, Invk_scripts_exec)) return Scripts_exec(m);
|
else if (ctx.Match(k, Invk_scripts_exec)) return Scripts_exec(m);
|
||||||
else if (ctx.Match(k, Invk_popups_get_async_bgn)) return Popups_get_async_bgn(m);
|
|
||||||
else if (ctx.Match(k, Invk_popups_get_html)) return Popups_get_html(m);
|
else if (ctx.Match(k, Invk_popups_get_html)) return Popups_get_html(m);
|
||||||
else if (ctx.Match(k, Invk_get_search_suggestions)) return Get_search_suggestions(m);
|
else if (ctx.Match(k, Invk_get_search_suggestions)) return Get_search_suggestions(m);
|
||||||
else if (ctx.Match(k, Invk_get_titles_meta)) return Get_titles_meta(m);
|
else if (ctx.Match(k, Invk_get_titles_meta)) return Get_titles_meta(m);
|
||||||
@ -190,7 +193,6 @@ public class Xoh_js_cbk implements Gfo_invk {
|
|||||||
public static final String Invk_parse_to_html = "parse_to_html", Invk_wikidata_get_label = "wikidata_get_label", Invk_get_page = "get_page", Invk_cmd = "cmd", Invk_scripts_exec = "scripts_exec"
|
public static final String Invk_parse_to_html = "parse_to_html", Invk_wikidata_get_label = "wikidata_get_label", Invk_get_page = "get_page", Invk_cmd = "cmd", Invk_scripts_exec = "scripts_exec"
|
||||||
, Invk_get_search_suggestions = "get_search_suggestions", Invk_get_titles_meta = "get_titles_meta", Invk_get_titles_exists = "get_titles_exists", Invk_get_current_url = "get_current_url"
|
, Invk_get_search_suggestions = "get_search_suggestions", Invk_get_titles_meta = "get_titles_meta", Invk_get_titles_exists = "get_titles_exists", Invk_get_current_url = "get_current_url"
|
||||||
, Invk_xowa_exec_test = "xowa_exec_test", Invk_xowa_exec_test_as_array = "xowa_exec_test_as_array"
|
, Invk_xowa_exec_test = "xowa_exec_test", Invk_xowa_exec_test_as_array = "xowa_exec_test_as_array"
|
||||||
, Invk_popups_get_async_bgn = "popups_get_async_bgn"
|
|
||||||
, Invk_popups_get_html = "popups_get_html"
|
, Invk_popups_get_html = "popups_get_html"
|
||||||
, Invk_exec_json = "exec_json"
|
, Invk_exec_json = "exec_json"
|
||||||
, Invk_bldr_exec = "bldr_exec"
|
, Invk_bldr_exec = "bldr_exec"
|
||||||
|
@ -26,6 +26,9 @@ public class Xow_popup_html_mkr {
|
|||||||
public void Output_tidy_(boolean v) {output_tidy = v;} private boolean output_tidy = true;
|
public void Output_tidy_(boolean v) {output_tidy = v;} private boolean output_tidy = true;
|
||||||
public void Ctor(Xoae_app app, Xowe_wiki wiki) {
|
public void Ctor(Xoae_app app, Xowe_wiki wiki) {
|
||||||
this.wiki = wiki; this.app = app;
|
this.wiki = wiki; this.app = app;
|
||||||
|
this.fmtr_popup = app.Mode().Tid_is_http() ?
|
||||||
|
Bry_fmtr.new_(Web_html_fmtr_popup, Dflt_html_fmtr_popup_keys) :
|
||||||
|
Bry_fmtr.new_(Dflt_html_fmtr_popup, Dflt_html_fmtr_popup_keys);
|
||||||
wiki.Eval_mgr().Eval_mgr_(fmtr_popup, fmtr_viewed, fmtr_wiki, fmtr_next_sect);
|
wiki.Eval_mgr().Eval_mgr_(fmtr_popup, fmtr_viewed, fmtr_wiki, fmtr_next_sect);
|
||||||
}
|
}
|
||||||
public byte[] Bld(Xowe_wiki cur_wiki, Xoae_page page, Xow_popup_itm popup_itm, Bry_bfr wrdx_bfr) {
|
public byte[] Bld(Xowe_wiki cur_wiki, Xoae_page page, Xow_popup_itm popup_itm, Bry_bfr wrdx_bfr) {
|
||||||
@ -79,6 +82,24 @@ public class Xow_popup_html_mkr {
|
|||||||
, Dflt_html_fmtr_viewed = Bry_.new_a7("\n <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.view_time-name');<>}</span><span class='data_val'>~{viewed_val}</span>")
|
, Dflt_html_fmtr_viewed = Bry_.new_a7("\n <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.view_time-name');<>}</span><span class='data_val'>~{viewed_val}</span>")
|
||||||
, Dflt_html_fmtr_wiki = Bry_.new_a7("\n <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.wiki-name');<>}</span><span class='data_val'>~{wiki_val}</span>")
|
, Dflt_html_fmtr_wiki = Bry_.new_a7("\n <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.wiki-name');<>}</span><span class='data_val'>~{wiki_val}</span>")
|
||||||
, Dflt_html_fmtr_next_sect = Bry_.new_a7("\n\n<span class='next_sect'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.next_sect-name');<>}~{next_sect_val}</span>")
|
, Dflt_html_fmtr_next_sect = Bry_.new_a7("\n\n<span class='next_sect'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.next_sect-name');<>}~{next_sect_val}</span>")
|
||||||
|
, Web_html_fmtr_popup = Bry_.new_a7(String_.Concat_lines_nl_skip_last
|
||||||
|
( "<div dir=~{page_lang_ltr}>"
|
||||||
|
, " <div>~{content}"
|
||||||
|
, " </div>"
|
||||||
|
, " <hr/>"
|
||||||
|
, " <div>"
|
||||||
|
, " <span class='data_val'><b>~{page_title}</b></span>~{wiki_item}"
|
||||||
|
, " <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.size-name');<>}</span><span class='data_val'>~{page_size}</span>"
|
||||||
|
, " <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.edited-name');<>}</span><span class='data_val'>~{edit_time}</span>~{view_time_item}"
|
||||||
|
, " </div>"
|
||||||
|
, " <hr/>"
|
||||||
|
, " <div style='float:bottom;'>"
|
||||||
|
, " <span><a href='/~{page_url}' title='~{<>msgs.get('api-xowa.gui.browser.url.exec-name');<>}' class='xowa-hover-off'><img src='~{xowa_root_dir}bin/any/xowa/file/app.menu/page/open.png'></a></span>"
|
||||||
|
, " <span><a href='/~{page_url}' title='~{<>msgs.get('api-xowa.gui.browser.tabs.new_link__at_dflt__focus_y-name');<>}' class='xowa-hover-off' target='_blank'><img src='~{xowa_root_dir}bin/any/xowa/file/app.menu/tabs/new.png'></a></span>"
|
||||||
|
// , " <span><a href='javascript:xowa.popups.FetchMore(\"~{popup_id}\");' title='~{<>msgs.get('api-xowa.html.modules.popups.show_more-tip');<>}'><img src='~{xowa_root_dir}bin/any/xowa/html/res/src/xowa/popups/imgs/show_more.png'></a></span>"
|
||||||
|
, " </div>"
|
||||||
|
, "</div>"
|
||||||
|
))
|
||||||
;
|
;
|
||||||
private static final String[]
|
private static final String[]
|
||||||
Dflt_html_fmtr_popup_keys = String_.Ary("content", "page_lang_ltr", "page_url", "page_title", "popup_id", "wiki_item", "page_size", "edit_time", "view_time_item", "xowa_root_dir")
|
Dflt_html_fmtr_popup_keys = String_.Ary("content", "page_lang_ltr", "page_url", "page_title", "popup_id", "wiki_item", "page_size", "edit_time", "view_time_item", "xowa_root_dir")
|
||||||
|
@ -15,8 +15,8 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|||||||
*/
|
*/
|
||||||
package gplx.xowa.htmls.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.modules.*;
|
package gplx.xowa.htmls.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.modules.*;
|
||||||
public class Xow_popup_itm implements Cancelable {
|
public class Xow_popup_itm implements Cancelable {
|
||||||
public Xow_popup_itm(int id, byte[] page_href, byte[] tooltip, int init_words_needed) {
|
public Xow_popup_itm(String popup_id, byte[] page_href, byte[] tooltip, int init_words_needed) {
|
||||||
this.popup_id = gplx.xowa.apps.Xoa_thread_.Key_page_popup + Int_.To_str(id);
|
this.popup_id = popup_id;
|
||||||
this.words_needed = init_words_needed;
|
this.words_needed = init_words_needed;
|
||||||
this.page_href = page_href;
|
this.page_href = page_href;
|
||||||
this.tooltip = tooltip;
|
this.tooltip = tooltip;
|
||||||
|
@ -26,7 +26,7 @@ public class Xow_popup_mgr implements Gfo_invk, Gfo_evt_itm {
|
|||||||
private Xoae_app app; private Xowe_wiki wiki; private Js_wtr js_wtr = new Js_wtr();
|
private Xoae_app app; private Xowe_wiki wiki; private Js_wtr js_wtr = new Js_wtr();
|
||||||
private int show_init_word_count, show_more_word_count;
|
private int show_init_word_count, show_more_word_count;
|
||||||
private Xoa_url tmp_url = Xoa_url.blank();
|
private Xoa_url tmp_url = Xoa_url.blank();
|
||||||
private static final Object thread_lock = new Object(); private Xow_popup_itm async_itm; private Gfo_invk async_cmd_show; private int async_id_next = 1;
|
private static final Object thread_lock = new Object();
|
||||||
public Xow_popup_mgr(Xowe_wiki wiki) {
|
public Xow_popup_mgr(Xowe_wiki wiki) {
|
||||||
this.wiki = wiki; this.app = wiki.Appe();
|
this.wiki = wiki; this.app = wiki.Appe();
|
||||||
ev_mgr = new Gfo_evt_mgr(this);
|
ev_mgr = new Gfo_evt_mgr(this);
|
||||||
@ -44,35 +44,27 @@ public class Xow_popup_mgr implements Gfo_invk, Gfo_evt_itm {
|
|||||||
, Cfg__ns_allowed, Cfg__xnde_ignore_ids, Cfg__scan_len, Cfg__scan_max
|
, Cfg__ns_allowed, Cfg__xnde_ignore_ids, Cfg__scan_len, Cfg__scan_max
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public String Show_init(int id, byte[] href, byte[] tooltip) {
|
public String Show_init(String popup_id, byte[] href, byte[] tooltip) {
|
||||||
Xoae_page cur_page = Cur_page();
|
Xoae_page cur_page = Cur_page();
|
||||||
Xog_tab_itm tab = cur_page.Tab_data().Tab();
|
Xog_tab_itm tab = cur_page.Tab_data().Tab();
|
||||||
if (tab != null && tab.Tab_is_loading()) return ""; // NOTE: tab is null when previewing
|
if (tab != null && tab.Tab_is_loading()) return ""; // NOTE: tab is null when previewing
|
||||||
Xow_popup_itm itm = new Xow_popup_itm(id, href, tooltip, show_init_word_count);
|
Xow_popup_itm itm = new Xow_popup_itm(popup_id, href, tooltip, show_init_word_count);
|
||||||
String rv = String_.new_u8(Get_popup_html(Cur_wiki(), cur_page, itm));
|
String rv = String_.new_u8(Get_popup_html(Cur_wiki(), cur_page, itm));
|
||||||
return tab != null && tab.Tab_is_loading() ? "" : rv;
|
return tab != null && tab.Tab_is_loading() ? "" : rv;
|
||||||
}
|
}
|
||||||
public void Show_more(String popup_id) {
|
public String Show_more(String popup_id) {
|
||||||
Xoae_page cur_page = Cur_page();
|
Xoae_page cur_page = Cur_page();
|
||||||
Xow_popup_itm popup_itm = Itms_get_or_null(cur_page, popup_id).Mode_more_(show_more_word_count);
|
Xow_popup_itm popup_itm = Itms_get_or_null(cur_page, popup_id).Mode_more_(show_more_word_count);
|
||||||
popup_itm.Popup_html_(Get_popup_html(Cur_wiki(), cur_page, popup_itm));
|
byte[] html = Get_popup_html(Cur_wiki(), cur_page, popup_itm);
|
||||||
Show_popup_html(Cbk_xowa_popups_show_update, Mode_show_more, popup_itm);
|
popup_itm.Popup_html_(html);
|
||||||
|
Show_popup_html(popup_itm, Cbk_update_popup_html, Mode_show_more);
|
||||||
|
return String_.new_u8(html);
|
||||||
}
|
}
|
||||||
public void Show_all(String popup_id) {
|
public void Show_all(String popup_id) {
|
||||||
Xoae_page cur_page = Cur_page();
|
Xoae_page cur_page = Cur_page();
|
||||||
Xow_popup_itm popup_itm = Itms_get_or_null(cur_page, popup_id).Mode_all_();
|
Xow_popup_itm popup_itm = Itms_get_or_null(cur_page, popup_id).Mode_all_();
|
||||||
popup_itm.Popup_html_(Get_popup_html(Cur_wiki(), cur_page, popup_itm));
|
popup_itm.Popup_html_(Get_popup_html(Cur_wiki(), cur_page, popup_itm));
|
||||||
Show_popup_html(Cbk_xowa_popups_show_update, Mode_show_all, popup_itm);
|
Show_popup_html(popup_itm, Cbk_update_popup_html, Mode_show_all);
|
||||||
}
|
|
||||||
public String Get_async_bgn(byte[] js_cbk, byte[] href) {
|
|
||||||
if (Bry_.Has_at_bgn(href, gplx.xowa.parsers.lnkes.Xop_lnke_wkr.Bry_xowa_protocol)) return null; // ignore xowa-cmd
|
|
||||||
synchronized (thread_lock) {
|
|
||||||
if (async_itm != null) async_itm.Cancel();
|
|
||||||
async_itm = new Xow_popup_itm(++async_id_next, href, Bry_.Empty, show_init_word_count);
|
|
||||||
String id_str = async_itm.Popup_id();
|
|
||||||
Thread_adp_.Start_by_key(id_str, this, Invk_show_popup_async);
|
|
||||||
return id_str;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public static boolean Running() {
|
public static boolean Running() {
|
||||||
boolean rv = false;
|
boolean rv = false;
|
||||||
@ -139,27 +131,18 @@ public class Xow_popup_mgr implements Gfo_invk, Gfo_evt_itm {
|
|||||||
href = Bry_.Add(tooltip);
|
href = Bry_.Add(tooltip);
|
||||||
Xog_win_itm__prog_href_mgr.Hover(app, app.Gui_mgr().Browser_win().Cfg().Status__show_short_url(), cur_wiki, cur_page, String_.new_u8(href)); // set page ttl again in prog bar; DATE:2014-06-28
|
Xog_win_itm__prog_href_mgr.Hover(app, app.Gui_mgr().Browser_win().Cfg().Status__show_short_url(), cur_wiki, cur_page, String_.new_u8(href)); // set page ttl again in prog bar; DATE:2014-06-28
|
||||||
}
|
}
|
||||||
public void Show_popup_html(String cbk, byte[] mode, Xow_popup_itm popup_itm) {
|
private void Show_popup_html(Xow_popup_itm popup_itm, String cbk, byte[] mode) {
|
||||||
|
// build js cmd
|
||||||
|
js_wtr.Func_init(cbk);
|
||||||
|
js_wtr.Prm_str(popup_itm.Popup_id());
|
||||||
|
js_wtr.Prm_bry(mode);
|
||||||
|
js_wtr.Prm_bry(popup_itm.Popup_html());
|
||||||
|
js_wtr.Func_term();
|
||||||
|
String js_cmd = js_wtr.To_str_and_clear();
|
||||||
|
|
||||||
|
// send it
|
||||||
Xog_tab_itm cur_tab = app.Gui_mgr().Browser_win().Active_tab();
|
Xog_tab_itm cur_tab = app.Gui_mgr().Browser_win().Active_tab();
|
||||||
cur_tab.Html_box().Html_js_eval_script(Xow_popup_mgr_.Bld_js_cmd(js_wtr, cbk, mode, popup_itm.Page_href(), popup_itm.Popup_html()));
|
cur_tab.Html_box().Html_js_eval_script(js_cmd);
|
||||||
}
|
|
||||||
private void Show_popup_async() {
|
|
||||||
try {
|
|
||||||
synchronized (thread_lock) {
|
|
||||||
Xoae_page cur_page = app.Gui_mgr().Browser_win().Active_page();
|
|
||||||
async_itm.Popup_html_(Get_popup_html(app.Gui_mgr().Browser_win().Active_wiki(), cur_page, async_itm));
|
|
||||||
}
|
|
||||||
if (async_cmd_show == null)
|
|
||||||
async_cmd_show = app.Gui_mgr().Kit().New_cmd_sync(this);
|
|
||||||
Gfo_invk_.Invk_by_key(async_cmd_show, Invk_show_popup);
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
app.Usr_dlg().Warn_many("", "", "failed to get popup: href=~{0} err=~{1}", async_itm.Page_href(), Err_.Message_gplx_full(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void Show_popup() {
|
|
||||||
if (async_itm.Canceled()) return;
|
|
||||||
Show_popup_html(Cbk_xowa_popups_show_create, Bry_.Empty, async_itm);
|
|
||||||
}
|
}
|
||||||
public void Ns_allowed_(byte[] raw) {
|
public void Ns_allowed_(byte[] raw) {
|
||||||
ns_allowed_regy.Clear();
|
ns_allowed_regy.Clear();
|
||||||
@ -195,10 +178,7 @@ public class Xow_popup_mgr implements Gfo_invk, Gfo_evt_itm {
|
|||||||
private Xowe_wiki Cur_wiki() {return app.Gui_mgr().Browser_win().Active_tab().Wiki();}
|
private Xowe_wiki Cur_wiki() {return app.Gui_mgr().Browser_win().Active_tab().Wiki();}
|
||||||
private Xow_popup_itm Itms_get_or_null(Xoae_page page, String popup_id) {return (Xow_popup_itm)page.Popup_mgr().Itms().Get_by(popup_id);}
|
private Xow_popup_itm Itms_get_or_null(Xoae_page page, String popup_id) {return (Xow_popup_itm)page.Popup_mgr().Itms().Get_by(popup_id);}
|
||||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||||
if (ctx.Match(k, Invk_show_popup_async)) Show_popup_async();
|
if (ctx.Match(k, Cfg__enabled)) enabled = m.ReadYn("v");
|
||||||
else if (ctx.Match(k, Invk_show_popup)) Show_popup();
|
|
||||||
|
|
||||||
else if (ctx.Match(k, Cfg__enabled)) enabled = m.ReadYn("v");
|
|
||||||
else if (ctx.Match(k, Cfg__show_init_word_count)) show_init_word_count = m.ReadInt("v");
|
else if (ctx.Match(k, Cfg__show_init_word_count)) show_init_word_count = m.ReadInt("v");
|
||||||
else if (ctx.Match(k, Cfg__show_more_word_count)) show_more_word_count = m.ReadInt("v");
|
else if (ctx.Match(k, Cfg__show_more_word_count)) show_more_word_count = m.ReadInt("v");
|
||||||
else if (ctx.Match(k, Cfg__show_all_if_less_than)) parser.Cfg().Show_all_if_less_than_(m.ReadInt("v"));
|
else if (ctx.Match(k, Cfg__show_all_if_less_than)) parser.Cfg().Show_all_if_less_than_(m.ReadInt("v"));
|
||||||
@ -214,10 +194,8 @@ public class Xow_popup_mgr implements Gfo_invk, Gfo_evt_itm {
|
|||||||
else return Gfo_invk_.Rv_unhandled;
|
else return Gfo_invk_.Rv_unhandled;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public static final String Invk_show_popup_async = "show_popup_async", Invk_show_popup = "show_popup";
|
|
||||||
private static final String
|
private static final String
|
||||||
Cbk_xowa_popups_show_update = "xowa_popups_show_update"
|
Cbk_update_popup_html = "window.xowa.popups.UpdatePopupHtml"
|
||||||
, Cbk_xowa_popups_show_create = "xowa_popups_show_create"
|
|
||||||
;
|
;
|
||||||
private static final byte[]
|
private static final byte[]
|
||||||
Mode_show_more = Bry_.new_a7("more")
|
Mode_show_more = Bry_.new_a7("more")
|
||||||
|
@ -16,16 +16,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|||||||
package gplx.xowa.htmls.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.modules.*;
|
package gplx.xowa.htmls.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.modules.*;
|
||||||
import gplx.core.threads.*; import gplx.core.primitives.*; import gplx.core.js.*;
|
import gplx.core.threads.*; import gplx.core.primitives.*; import gplx.core.js.*;
|
||||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.specials.*;
|
import gplx.xowa.wikis.nss.*; import gplx.xowa.specials.*;
|
||||||
class Xow_popup_mgr_ {
|
|
||||||
public static String Bld_js_cmd(Js_wtr js_wtr, String cbk, byte[] mode, byte[] href, byte[] html) {
|
|
||||||
js_wtr.Func_init(cbk);
|
|
||||||
js_wtr.Prm_bry(mode);
|
|
||||||
js_wtr.Prm_bry(href);
|
|
||||||
js_wtr.Prm_bry(html);
|
|
||||||
js_wtr.Func_term();
|
|
||||||
return js_wtr.To_str_and_clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Load_popup_wkr implements Gfo_thread_wkr {
|
class Load_popup_wkr implements Gfo_thread_wkr {
|
||||||
private Xow_popup_itm itm; private Xoae_page cur_page; private Xoa_url tmp_url;
|
private Xow_popup_itm itm; private Xoae_page cur_page; private Xoa_url tmp_url;
|
||||||
private Hash_adp ns_allowed_regy;
|
private Hash_adp ns_allowed_regy;
|
||||||
|
@ -506,7 +506,7 @@ class Xop_popup_parser_fxt {
|
|||||||
public void Test_parse(String raw, String ttl, String expd) {
|
public void Test_parse(String raw, String ttl, String expd) {
|
||||||
Xoae_page page = Xoae_page.New_edit(wiki, Xoa_ttl.Parse(wiki, Bry_.new_a7(ttl)));
|
Xoae_page page = Xoae_page.New_edit(wiki, Xoa_ttl.Parse(wiki, Bry_.new_a7(ttl)));
|
||||||
page.Db().Text().Text_bry_(Bry_.new_u8(raw));
|
page.Db().Text().Text_bry_(Bry_.new_u8(raw));
|
||||||
Xow_popup_itm itm = new Xow_popup_itm(1, Bry_.new_u8(raw), Bry_.Empty, word_min);
|
Xow_popup_itm itm = new Xow_popup_itm("popup_1", Bry_.new_u8(raw), Bry_.Empty, word_min);
|
||||||
itm.Init(wiki.Domain_bry(), page.Ttl());
|
itm.Init(wiki.Domain_bry(), page.Ttl());
|
||||||
byte[] actl = parser.Parse(wiki, page, null, itm);
|
byte[] actl = parser.Parse(wiki, page, null, itm);
|
||||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||||
|
@ -243,11 +243,9 @@
|
|||||||
|
|
||||||
// bind update and popups
|
// bind update and popups
|
||||||
xo.cfg_edit.cfg_val__bind_all();
|
xo.cfg_edit.cfg_val__bind_all();
|
||||||
try {
|
xowa.js.doc.evtElemAdd.pub(document);
|
||||||
xowa_popups_bind_to_owner(document);
|
|
||||||
} catch (err) {}
|
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {alert(err);}
|
} catch (err) {alert('xo.cfg_edit:' + err);}
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
@ -24,13 +24,14 @@
|
|||||||
// onload fires multiple times on drd; only run once
|
// onload fires multiple times on drd; only run once
|
||||||
if (this.loaded) return;
|
if (this.loaded) return;
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
|
|
||||||
// init notify anchor; focus search_btn
|
// init notify anchor; focus search_btn
|
||||||
xo.notify.elem_anchor = '#main_div';
|
xo.notify.elem_anchor = '#main_div';
|
||||||
xo.elem.get('search_txt').focus();
|
xo.elem.get('search_txt').focus();
|
||||||
|
|
||||||
// run search
|
// run search
|
||||||
var query = xo.elem.get_val_or_null('search_txt');
|
var query = xo.elem.get_val_or_null('search_txt');
|
||||||
|
|
||||||
if (query && query.length > 0) {
|
if (query && query.length > 0) {
|
||||||
this.search_run();
|
this.search_run();
|
||||||
}
|
}
|
||||||
@ -61,7 +62,6 @@
|
|||||||
// get search_text
|
// get search_text
|
||||||
var search_text = xo.elem.get_val_or_null('search_txt');
|
var search_text = xo.elem.get_val_or_null('search_txt');
|
||||||
search_text = search_text.replace(/ /g, "_"); // replace " " with "_"; this replacement is done automatically in drd.WebView, but is done manually here with swt.swtbrowser for consistency
|
search_text = search_text.replace(/ /g, "_"); // replace " " with "_"; this replacement is done automatically in drd.WebView, but is done manually here with swt.swtbrowser for consistency
|
||||||
|
|
||||||
// get data specified by user
|
// get data specified by user
|
||||||
var msg =
|
var msg =
|
||||||
{ search: xo.elem.get_val_or_null('search_txt')
|
{ search: xo.elem.get_val_or_null('search_txt')
|
||||||
@ -100,6 +100,7 @@
|
|||||||
try {
|
try {
|
||||||
// get search_text
|
// get search_text
|
||||||
var search_text = xo.elem.get_val_or_null('search_txt');
|
var search_text = xo.elem.get_val_or_null('search_txt');
|
||||||
|
search_text = encodeURI(search_text);
|
||||||
|
|
||||||
// if search_text has changed, reset offsets; EX: on 21-40 of 'earth'; changing search to 'moon' should start from 1, not 21
|
// if search_text has changed, reset offsets; EX: on 21-40 of 'earth'; changing search to 'moon' should start from 1, not 21
|
||||||
if (search_text !== xo.elem.get_val_or_null('qarg_search')) {
|
if (search_text !== xo.elem.get_val_or_null('qarg_search')) {
|
||||||
@ -127,7 +128,6 @@
|
|||||||
// get qarg / dflt values
|
// get qarg / dflt values
|
||||||
var qarg_val = xo.elem.get_val_or_null('qarg_' + key);
|
var qarg_val = xo.elem.get_val_or_null('qarg_' + key);
|
||||||
var dflt_val = xo.elem.get_val_or_null('dflt_' + key);
|
var dflt_val = xo.elem.get_val_or_null('dflt_' + key);
|
||||||
|
|
||||||
// if qarg === dflt, return url
|
// if qarg === dflt, return url
|
||||||
if (qarg_val === dflt_val) {
|
if (qarg_val === dflt_val) {
|
||||||
return url;
|
return url;
|
||||||
@ -308,7 +308,7 @@
|
|||||||
// publish elem_add event for popups
|
// publish elem_add event for popups
|
||||||
var page_elem_key = 'results_wiki_' + wiki + '_page_' + msg.page_id;
|
var page_elem_key = 'results_wiki_' + wiki + '_page_' + msg.page_id;
|
||||||
var page_elem = xo.elem.get(page_elem_key);
|
var page_elem = xo.elem.get(page_elem_key);
|
||||||
xo.elem.elem_add__pub(page_elem);
|
xowa.js.doc.evtElemAdd.pub(page_elem);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.handle_err(err + " proc=results__page__add; msg=" + JSON.stringify(msg));
|
this.handle_err(err + " proc=results__page__add; msg=" + JSON.stringify(msg));
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,25 @@
|
|||||||
|
// Add Event Manager for simple pub/sub pattern; DATE:2018-11-11
|
||||||
|
var XoEvtMgr = (function(){
|
||||||
|
var funcs = [];
|
||||||
|
function XoEvtMgr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
XoEvtMgr.prototype.sub = function(func) {
|
||||||
|
funcs.push(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
XoEvtMgr.prototype.pub = function() {
|
||||||
|
var funcsIdx = 0;
|
||||||
|
var funcsLen = funcs.length;
|
||||||
|
for (funcsIdx = 0; funcsIdx < funcsLen; funcsIdx++) {
|
||||||
|
var func = funcs[funcsIdx];
|
||||||
|
func(arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return XoEvtMgr;
|
||||||
|
}());
|
||||||
|
|
||||||
if (!window.xowa) {
|
if (!window.xowa) {
|
||||||
window.xowa = {
|
window.xowa = {
|
||||||
root_dir : xowa_root_dir,
|
root_dir : xowa_root_dir,
|
||||||
@ -409,6 +431,8 @@ if (!window.xowa) {
|
|||||||
return or_val;
|
return or_val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
xowa.js.doc.evtElemAdd = new XoEvtMgr();
|
||||||
|
|
||||||
// PURPOSE: used when clicking on file to get xowa_title
|
// PURPOSE: used when clicking on file to get xowa_title
|
||||||
xowa.js.doc.root_html_get = function() {
|
xowa.js.doc.root_html_get = function() {
|
||||||
return document.getElementsByTagName("html")[0].innerHTML;
|
return document.getElementsByTagName("html")[0].innerHTML;
|
||||||
@ -435,11 +459,12 @@ if (!window.xowa) {
|
|||||||
|
|
||||||
xowa.js.doc.process_new_elem(elem.parentNode); // NOTE: elem is placeholder item; html is inserted after it; need to call process_new_elem on parentNode; DATE:2015-08-03
|
xowa.js.doc.process_new_elem(elem.parentNode); // NOTE: elem is placeholder item; html is inserted after it; need to call process_new_elem on parentNode; DATE:2015-08-03
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
|
xowa.js.doc.ElemAdd.publish()
|
||||||
|
*/
|
||||||
// PURPOSE: process new element such as adding bindings; DATE:2015-07-09
|
// PURPOSE: process new element such as adding bindings; DATE:2015-07-09
|
||||||
xowa.js.doc.process_new_elem = function(elem) {
|
xowa.js.doc.process_new_elem = function(elem) {
|
||||||
if (elem == null) elem = document;
|
xowa.js.doc.EvtElemAdd.pub(elem);
|
||||||
xowa_popups_bind_to_owner($(elem));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PURPOSE: async search; gallery; imap
|
// PURPOSE: async search; gallery; imap
|
||||||
|
614
res/bin/any/xowa/html/res/src/xowa/popups/mocks/basic.html
Normal file
614
res/bin/any/xowa/html/res/src/xowa/popups/mocks/basic.html
Normal file
@ -0,0 +1,614 @@
|
|||||||
|
<!--
|
||||||
|
PURPOSE: standalone file to test basic popup functionality without running XOWA
|
||||||
|
* Install XOWA to root; WNT: "C:\xowa"; LNX: "/xowa/"
|
||||||
|
* Launch chrome with arguments "--disable-web-security --user-data-dir"
|
||||||
|
* Navigate to: file:///C:/xowa/bin/any/xowa/html/res/src/xowa/popups/mocks/basic.html
|
||||||
|
* Hover over "blog" which will read file from "pages/Blog.init.html"
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
* To change base dir, do find-and-replace for href="/xowa/"
|
||||||
|
* <base> tag not useful due to anchors: https://stackoverflow.com/questions/1889076/what-are-the-recommendations-for-html-base-tag
|
||||||
|
-->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!-- CSS: wikipedia look-and-feel; needed for popups css -->
|
||||||
|
<link type="text/css" href="/xowa/user/anonymous/wiki/home/html/xowa_common.css" rel="stylesheet" />
|
||||||
|
<link type="text/css" href="/xowa/user/anonymous/wiki/home/html/xowa_wiki.css" rel="stylesheet" />
|
||||||
|
<link type="text/css" href="/xowa/bin/any/xowa/html/res/src/xowa/popups/popups.css" rel="stylesheet" />
|
||||||
|
|
||||||
|
<!-- JS: xo.core -->
|
||||||
|
<script>
|
||||||
|
window.xowa_root_dir = 'must specifiy, else core.js will fail';
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="/xowa/bin/any/xowa/html/res/src/xowa/core/core.js"></script>
|
||||||
|
<script>
|
||||||
|
window.xowa.app.mode = 'mock';
|
||||||
|
window.xowa.cfg.get = function(key) {
|
||||||
|
switch (key) {
|
||||||
|
case 'popups-win-show_delay': return 200;
|
||||||
|
case 'popups-win-hide_delay': return 500;
|
||||||
|
case 'popups-win-max_w': return 800;
|
||||||
|
case 'popups-win-max_h': return 600;
|
||||||
|
case 'popups-win-show_all_max_w': return 1200;
|
||||||
|
case 'popups-win-bind_focus_blur': return true;
|
||||||
|
case 'popups-win-bind_hover_area': return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- JS:util -->
|
||||||
|
<script>
|
||||||
|
function readFile(file, func) {
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
req.open("GET", file);
|
||||||
|
req.onreadystatechange = function() {
|
||||||
|
if(req.readyState === 4 && (req.status === 200 || req.status == 0)) {
|
||||||
|
func(req.responseText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
req.send(null);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- JS:xo.popups -->
|
||||||
|
<script type="text/javascript" src="/xowa/bin/any/xowa/html/res/lib/jquery/jquery-1.11.3.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/xowa/bin/any/xowa/html/res/src/xowa/popups/xo.popup.js"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
xowa.popups.Mock_popups_get_html = function(mgr, showMode, popupItm, href)
|
||||||
|
{
|
||||||
|
readFile
|
||||||
|
( href
|
||||||
|
, function(s)
|
||||||
|
{
|
||||||
|
mgr.UpdatePopupHtml(popupItm.Id, showMode, s);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body spellcheck="false" class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-Main_Page skin-vector action-submit vector-animateLayout">
|
||||||
|
<div class="noprint" id="mw-page-base"></div>
|
||||||
|
<div class="noprint" id="mw-head-base"></div>
|
||||||
|
<div class="mw-body" id="content">
|
||||||
|
<div style="display:none; color:red; white-space:pre; display:block; unicode-bidi:embed;" class="xowa_err" id="xowa_err_div"></div><h1 class="firstHeading" id="firstHeading">Main Page</h1>
|
||||||
|
<div class="mw-body-content" id="bodyContent">
|
||||||
|
<div id="siteSub">From XOWA: the free, open-source, offline wiki application</div>
|
||||||
|
<div class="visible" id="contentSub"></div>
|
||||||
|
<div class="mw-jump" id="jump-to-nav">Jump to:<a href="#mw-navigation">navigation</a>, <a href="#p-search">search</a></div>
|
||||||
|
<div lang="en" class="mw-content-ltr" dir="ltr" id="mw-content-text">
|
||||||
|
<div class="toc" id="toc">
|
||||||
|
<div class="toctitle" id="toctitle">
|
||||||
|
<h2>
|
||||||
|
Contents
|
||||||
|
</h2>
|
||||||
|
<span class="toctoggle"> [<a id="togglelink" class="internal" href="#">hide</a>] </span></div>
|
||||||
|
<ul>
|
||||||
|
<li class="toclevel-1 tocsection-1">
|
||||||
|
<a href="#Disclaimer"><span class="tocnumber">1</span> <span class="toctext">Disclaimer</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="toclevel-1 tocsection-2">
|
||||||
|
<a href="#Release_notes"><span class="tocnumber">2</span> <span class="toctext">Release notes</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="toclevel-1 tocsection-3">
|
||||||
|
<a href="#New_users"><span class="tocnumber">3</span> <span class="toctext">New users</span></a>
|
||||||
|
<ul>
|
||||||
|
<li class="toclevel-2 tocsection-4">
|
||||||
|
<a href="#Build_a_wiki_while_online"><span class="tocnumber">3.1</span> <span class="toctext">Build a wiki while online</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="toclevel-2 tocsection-5">
|
||||||
|
<a href="#Build_a_wiki_while_offline"><span class="tocnumber">3.2</span> <span class="toctext">Build a wiki while offline</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="toclevel-2 tocsection-6">
|
||||||
|
<a href="#Download_pre-built_wikis_within_XOWA"><span class="tocnumber">3.3</span> <span class="toctext">Download pre-built wikis within XOWA</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="toclevel-2 tocsection-7">
|
||||||
|
<a href="#Download_pre-built_wikis_within_a_browser"><span class="tocnumber">3.4</span> <span class="toctext">Download pre-built wikis within a browser</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="toclevel-2 tocsection-8">
|
||||||
|
<a href="#Creating_a_personal_wiki"><span class="tocnumber">3.5</span> <span class="toctext">Creating a personal wiki</span></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="toclevel-1 tocsection-9">
|
||||||
|
<a href="#Upgrade_users"><span class="tocnumber">4</span> <span class="toctext">Upgrade users</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="toclevel-1 tocsection-10">
|
||||||
|
<a href="#Tips"><span class="tocnumber">5</span> <span class="toctext">Tips</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="toclevel-1 tocsection-11">
|
||||||
|
<a href="#Notes"><span class="tocnumber">6</span> <span class="toctext">Notes</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="toclevel-1 tocsection-12">
|
||||||
|
<a href="#Links"><span class="tocnumber">7</span> <span class="toctext">Links</span></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<h2>
|
||||||
|
<span id="Disclaimer" class="mw-headline">Disclaimer</span>
|
||||||
|
</h2>
|
||||||
|
<p>
|
||||||
|
Please note that this program is beta software. Although it is my best hope that you find this program functional and useful, I make no assurances regarding stability or fitness of purpose. For more details, see <a class="xowa-visited" title="Help/License/Code" id="xolnki_2" href="/wiki/Help/License/Code">Help/License/Code</a>.
|
||||||
|
</p>
|
||||||
|
<h2>
|
||||||
|
<span id="Release_notes" class="mw-headline">Release notes</span>
|
||||||
|
</h2>
|
||||||
|
<p>
|
||||||
|
v4.5.21.1808 features the following:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
(Wiki) Publish 2018-07 English Wikipedia
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
(PC) Fix multiple script errors due to Wikibase and Scribunto.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
For more details about this release, please see the <a title="" id="xolnki_3" href="pages/Blog.init.html">blog</a> and the <a class="xowa-visited" title="Change log" id="xolnki_4" href="/wiki/Change_log">change log</a>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
For more details about the release schedule, please see <a class="xowa-visited" title="Help/Release schedule" id="xolnki_5" href="/wiki/Help/Release_schedule">the release schedule</a>.
|
||||||
|
</p>
|
||||||
|
<h2>
|
||||||
|
<span id="New_users" class="mw-headline">New users</span>
|
||||||
|
</h2>
|
||||||
|
<p>
|
||||||
|
If this is the first time you've run XOWA, then please choose from the following:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
Build a wiki while online
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Build a wiki while offline
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Download pre-built wikis within XOWA
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Download pre-built wikis within a browser
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
In addition, XOWA now supports creation of your own personal wiki.
|
||||||
|
</p>
|
||||||
|
<h5>
|
||||||
|
<span id="Build_a_wiki_while_online" class="mw-headline">Build a wiki while online</span>
|
||||||
|
</h5>
|
||||||
|
<hr />
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<b>Import Simple Wikipedia</b>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
Simple Wikipedia is a small wiki that fits in about 200 MB and sets up in about 3 minutes.
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
When you are ready to start, click this link:
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
<a href="xowa-cmd:%0Aapp.setup.cmds%0A.dump_add_many%28%27simple.wikipedia.org%27%2C%20%27latest%27%2C%20%27pages-articles%27%2C%20%27wiki.custom%27%29.owner%0A.run;%0A">Set up Simple Wikipedia<img src="file:///C:/xowa/bin/any/xowa/file/app.general/xowa_exec.png" /></a>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
Feel free to look around during the import process. You can start at <a class="xowa-visited" title="Help/Contents" id="xolnki_6" href="/wiki/Help/Contents">Help/Contents</a>. When the process completes, it will open Simple Wikipedia.
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
After the setup completes, you can visit these pages:
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
<a title="Gothic architecture" id="xolnki_7" href="/site/simple.wikipedia.org/wiki/Gothic_architecture">Gothic architecture</a>
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
<a title="Saturn (planet)" id="xolnki_8" href="/site/simple.wikipedia.org/wiki/Saturn_%28planet%29">Saturn (planet)</a>
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
<a title="Chess" id="xolnki_9" href="/site/simple.wikipedia.org/wiki/Chess">Chess</a>
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
<a title="World History" id="xolnki_10" href="/site/simple.wikipedia.org/wiki/World_History">World History</a>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<b>Import other wikis</b>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
After exploring Simple Wikipedia, you may want to import another wiki such as English Wikipedia, French Wiktionary, German Wikisource, Wikidata, Commons, etc.
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
To import another wiki, please visit <a class="xowa-visited" title="Dashboard/Import/Online" id="xolnki_11" href="/wiki/Dashboard/Import/Online">import online</a>.
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<h5>
|
||||||
|
<span id="Build_a_wiki_while_offline" class="mw-headline">Build a wiki while offline</span>
|
||||||
|
</h5>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<b>Import from a dump file</b>: See <a class="xowa-visited" title="Dashboard/Import/Offline" id="xolnki_12" href="/wiki/Dashboard/Import/Offline">import offline</a>.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h5>
|
||||||
|
<span id="Download_pre-built_wikis_within_XOWA" class="mw-headline">Download pre-built wikis within XOWA</span>
|
||||||
|
</h5>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
Go to <a class="xowa-visited" title="Special:XowaDownloadCentral" id="xolnki_13" href="/wiki/Special:XowaDownloadCentral">Special:XowaDownloadCentral</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Add your wikis to the Queue
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Press Run
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
For more instructions, see <a title="App/Import/Download Central" id="xolnki_14" href="/wiki/App/Import/Download_Central">App/Import/Download_Central</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h5>
|
||||||
|
<span id="Download_pre-built_wikis_within_a_browser" class="mw-headline">Download pre-built wikis within a browser</span>
|
||||||
|
</h5>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
Go to <a title="Wiki setup/Listing" id="xolnki_15" href="/wiki/Wiki_setup/Listing">Wiki_setup/Listing</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Navigate to your wiki page from the list
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Download the listed urls
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h5>
|
||||||
|
<span id="Creating_a_personal_wiki" class="mw-headline">Creating a personal wiki</span>
|
||||||
|
</h5>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
From the main menu, choose <code>Personal wikis</code> -> <code>New personal wiki</code>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Fill in domain, name, and folder
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Press the <code>Save icon</code>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h2>
|
||||||
|
<span id="Upgrade_users" class="mw-headline">Upgrade users</span>
|
||||||
|
</h2>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
v4.5.0 features full-text search for all wikis. See <a class="xowa-visited" title="App/Full-text search" id="xolnki_16" href="/wiki/App/Full-text_search">App/Full-text_search</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v4.4.0 features night-mode. See <a title="App/UI/Night mode" id="xolnki_17" href="/wiki/App/UI/Night_mode">App/UI/Night_mode</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v4.2.0 features personal wiki support. See <a title="App/Personal wikis" id="xolnki_18" href="/wiki/App/Personal_wikis">App/Personal_wikis</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v4.1.0 features a new in app update system. See <a title="App/Setup/Update/In-app" id="xolnki_19" href="/wiki/App/Setup/Update/In-app">App/Setup/Update/In-app</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v4.0.0 features a new Options system. See <a title="Options" id="xolnki_20" href="/wiki/Options">Options</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v3.9.2 features a new Category system. See <a title="App/Category" id="xolnki_21" href="/wiki/App/Category">Category Overview</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v3.6.3 features a Download page. See <a class="xowa-visited" title="Special:XowaDownloadCentral" id="xolnki_22" href="/wiki/Special:XowaDownloadCentral">Download Central</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v3.3.4 features an auto-complete address bar. It also has a faster Search system. See <a title="App/Search" id="xolnki_23" href="/wiki/App/Search">App/Search</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
v3.3.4 uses sqlite 3.8.2
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
v3.1.3 features the XOWA Android application
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v2.8.1 has a language converter dropdown for the Chinese wikis.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v2.7.3 introduces a new Bookmarks page. See <a title="Special:XowaBookmarks" id="xolnki_24" href="/wiki/Special:XowaBookmarks">Special:XowaBookmarks</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v2.6.5 uses SWT v4.5 and XULRunner v24. See <a title="Dev/SWT" id="xolnki_25" href="/wiki/Dev/SWT">Dev/SWT</a> and <a title="App/UI/HTML Browser" id="xolnki_26" href="/wiki/App/UI/HTML_Browser">HTML Browser</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v2.6.3 uses WebKit for MacOSX. For more info, see <a title="Blog" id="xolnki_27" href="/wiki/Blog">Blog</a><br />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
v2.6.3 also fully supports multiple-word-highlight when using find. Press Ctrl+F and try it out.
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
v2.5.4 has changed online file downloads. Among other things, ImageMagick and Inkscape are no longer required. For more info, see <a title="App/Basics/Files" id="xolnki_28" href="/wiki/App/Basics/Files">Files</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v2.4.2 has improved Search performance and v2.4.4 has added multi-wiki Search. For more info, see <a title="App/Search" id="xolnki_29" href="/wiki/App/Search">App/Search</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
v2.4.1 has introduced major database layout changes. For more info, see <a title="Dev/Design/Database" id="xolnki_30" href="/wiki/Dev/Design/Database">Database</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h2>
|
||||||
|
<span id="Tips" class="mw-headline">Tips</span>
|
||||||
|
</h2>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<b>Autocomplete address bar</b>: The address bar supports autocomplete. Type something like "search" and see the results.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Navigation buttons</b>: The arrow icons in the upper left-hand corner represent the back and forward button. Click on them just like you would in a web browser. You can also use Alt+Left and Alt+Right.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Font size</b>:
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
If the font size is too small, right-click and choose Font Increase
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
If you need more control over the font, customize it on the <a title="Special:XowaCfg?grp=xowa.gui.general" id="xolnki_31" href="/wiki/Special:XowaCfg%3Fgrp%3Dxowa.gui.general">Options: Gui - Window</a> and <a title="Special:XowaCfg?grp=xowa.html.css" id="xolnki_32" href="/wiki/Special:XowaCfg%3Fgrp%3Dxowa.html.css">Options: HTML - CSS</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Find box</b>: Press Ctrl+F on your keyboard. This will show the Find box (in the lower left-hand corner). Type "tips". Notice that the word "Tips" is highlighted above. Note that Alt+P (Previous) and Alt+N (Next) will change search direction. See <a title="App/UI/Find box" id="xolnki_33" href="/wiki/App/UI/Find_box">Find Box</a> for more info.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Address bar</b>: Press Alt+D or Ctrl+L on your keyboard. This will take you to the Address bar at the top of the screen. Type "s.w:Earth" (no quotes) and press Enter. This will open the Simple Wikipedia page for Earth. See <a title="App/UI/Address bar/Shortcuts" id="xolnki_34" href="/wiki/App/UI/Address_bar/Shortcuts#Default_shortcuts">Address bar/Shortcuts</a> for more shortcuts.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Middle-click in address bar</b>: Copy and paste urls directly into the address bar with the middle mouse button to open the page. For example:
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
Right-click the following url: <code><a href="/site/simple.wikipedia.org/wiki/World_history">http://simple.wikipedia.org/wiki/World_history</a></code>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Select "Copy"
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Click the middle mouse button in the address bar above. The "World history" page in "Simple Wikipedia" will open.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
<dl>
|
||||||
|
<dd>
|
||||||
|
Now you can copy and paste any Wikipedia url directly into XOWA and its page will open (and all its images will download.) See <a title="App/UI/Address bar/URLs" id="xolnki_35" href="/wiki/App/UI/Address_bar/URLs">Address_bar/URLs</a> for more info
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<b>Middle-click on link</b>: Open a tab in a new link by middle-clicking on it. Try middle-clicking the following: <a title="Options" id="xolnki_36" href="/wiki/Options">Options</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Right-click</b>: Right click on an image and click save as file
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h2>
|
||||||
|
<span id="Notes" class="mw-headline">Notes</span>
|
||||||
|
</h2>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<b>Wikidata</b>: If you're seeing {{#property}} in your wikis you should also set up Wikidata. See <a title="App/Wiki types/Wikidata" id="xolnki_37" href="/wiki/App/Wiki_types/Wikidata">App/Wiki_types/Wikidata</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h2>
|
||||||
|
<span id="Links" class="mw-headline">Links</span>
|
||||||
|
</h2>
|
||||||
|
<table class="wikitable">
|
||||||
|
<tbody><tr>
|
||||||
|
<td>
|
||||||
|
<a class="xowa-visited" title="Special:XowaDownloadCentral" id="xolnki_38" href="/wiki/Special:XowaDownloadCentral">Download Central</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Download an Android-ready wiki with images from archive.org
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a class="xowa-visited" title="Dashboard/Import/Online" id="xolnki_39" href="/wiki/Dashboard/Import/Online">Import Online</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Import a wiki from a list of 829 known Wikimedia Foundation wikis
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a class="xowa-visited" title="Dashboard/Import/Offline" id="xolnki_40" href="/wiki/Dashboard/Import/Offline">Import Offline</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Import a wiki through a dump; import also through script; also upgrade category to version 2
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a title="Dashboard/Image databases" id="xolnki_41" href="/wiki/Dashboard/Image_databases">Image databases</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Download image databases for your wiki
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a title="Dashboard/Wiki maintenance" id="xolnki_42" href="/wiki/Dashboard/Wiki_maintenance">Wiki Maintenance</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Update your wikis if they are outdated
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a title="Help/FAQs" id="xolnki_43" href="/wiki/Help/FAQs">FAQs</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
View questions asked by other users
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a class="xowa-visited" title="Help/Contents" id="xolnki_44" href="/wiki/Help/Contents">Contents</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
View all help topics
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a title="Options" id="xolnki_45" href="/wiki/Options">Options</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Configure XOWA options
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a class="xowa-visited" title="Change log" id="xolnki_46" href="/wiki/Change_log">Change log</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
View changes for each XOWA release
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a class="xowa-visited" title="Diagnostics" id="xolnki_47" href="/wiki/Diagnostics">Diagnostics</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Run test pages to make sure that XOWA works on your system.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a class="external text" rel="nofollow" href="https://github.com/gnosygnu/xowa/issues">Report issues</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Report bugs / issues on Github
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody></table>
|
||||||
|
|
||||||
|
<div class="visualClear">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div role="contentinfo" id="footer">
|
||||||
|
<ul id="footer-info">
|
||||||
|
<li id="footer-info-lastmod"> This page was last modified on 2018-08-05, at 21:08.</li>
|
||||||
|
<li id="footer-info-copyright">Text is available under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution/Share-Alike License</a>;
|
||||||
|
additional terms may apply.
|
||||||
|
See <a href="https://wikimediafoundation.org/wiki/Terms_of_Use">Terms of Use</a> for details.
|
||||||
|
</li></ul>
|
||||||
|
<ul id="footer-places">
|
||||||
|
<li id="footer-places-privacy"><a title="Privacy policy" class="extiw" href="/wiki/Project:Privacy%20policy">Privacy policy</a></li>
|
||||||
|
<li id="footer-places-about"><a title="Wikipedia:About" href="/wiki/">About home</a></li>
|
||||||
|
<li id="footer-places-disclaimer"><a title="Disclaimers" href="/wiki/Project:General%20disclaimer">Disclaimers</a></li>
|
||||||
|
<li id="footer-places-developers"><a href="https://www.mediawiki.org/wiki/Special:MyLanguage/How_to_contribute">Developers</a></li>
|
||||||
|
<li id="footer-places-cookiestatement"><a href="https://wikimediafoundation.org/wiki/Cookie_statement">Cookie statement</a></li>
|
||||||
|
</ul>
|
||||||
|
<ul style="height:10px" class="noprint" id="footer-icons">
|
||||||
|
<li id="footer-copyrightico">
|
||||||
|
<a href="https://wikimediafoundation.org/"><img width="88" height="31" alt="Wikimedia Foundation" src="file:///C:/xowa//bin/any/xowa/html/css/footer/wikimedia-button.png" /></a>
|
||||||
|
</li>
|
||||||
|
<li id="footer-poweredbyico">
|
||||||
|
<a href="//www.mediawiki.org/"><img width="88" height="31" alt="Powered by MediaWiki" src="file:///C:/xowa//bin/any/xowa/html/css/footer/poweredby_mediawiki_88x31.png" /></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul style="clear:both; float:left;">
|
||||||
|
<li>Generated by <a href="/wiki/home/Help/About">XOWA</a>: v4.5.26.1810 (2018-11-14 02:19:20)</li>
|
||||||
|
</ul>
|
||||||
|
<div style="clear:both"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="noprint" id="mw-head">
|
||||||
|
<div class="" id="p-personal">
|
||||||
|
<h3>Personal tools</h3>
|
||||||
|
</div>
|
||||||
|
<div id="left-navigation">
|
||||||
|
<div class="vectorTabs" id="p-namespaces">
|
||||||
|
<h3>Namespaces</h3>
|
||||||
|
<ul>
|
||||||
|
<li class="selected" id="ca-nstab-main"><span><a title="View the content page [c]" accesskey="c" class="xowa-hover-off" id="ca-nstab-main-href" href="/wiki/Main_Page">Page</a></span></li>
|
||||||
|
<li class="xowa_display_none" id="ca-talk"><span><a title="Discussion about the content page [t]" accesskey="t" class="xowa-hover-off" href="/wiki/Talk:Main_Page">Discussion</a></span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="right-navigation">
|
||||||
|
<div class="vectorTabs" id="p-views">
|
||||||
|
<h3>Views</h3>
|
||||||
|
<ul>
|
||||||
|
<li class="selected" id="ca-view"><span><a class="xowa-hover-off" href="/wiki/Main_Page">Read</a></span></li>
|
||||||
|
<li class="" id="ca-edit"><span><a title="You can edit this page. Please use the preview button before saving [e]" accesskey="e" class="xowa-hover-off" href="/wiki/Main_Page?action=edit">Edit</a></span></li>
|
||||||
|
<li class="" id="ca-history"><span><a title="View HTML source for this page [h]" accesskey="h" class="xowa-hover-off" href="/wiki/Main_Page?action=html">View HTML</a></span></li>
|
||||||
|
<li role="search" id="p-search">
|
||||||
|
<form action="/wiki/Special:XowaSearch" id="searchform">
|
||||||
|
<div id="simpleSearch">
|
||||||
|
<input type="search" autocomplete="off" value="" title="Search home [f]" accesskey="f" id="searchInput" placeholder="Search" name="search" />
|
||||||
|
<input type="hidden" value="y" name="fulltext" />
|
||||||
|
<input type="submit" class="searchButton mw-fallbackSearchButton" id="mw-searchButton" title="Search home [f]" accesskey="f" />
|
||||||
|
<input type="submit" class="searchButton" id="searchButton" title="Go to a page with this exact name if exists" value="Go" name="go" />
|
||||||
|
<ul id="xowa-search-suggestions" style="display: none;"></ul></div>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="noprint" id="mw-panel">
|
||||||
|
<div id="p-logo">
|
||||||
|
<a title="Visit the main page" class="xowa-hover-off" href="/site/home/wiki/" style="background-image: url(file:///C:/xowa/user/anonymous/wiki/home/html/logo.png);"></a>
|
||||||
|
</div>
|
||||||
|
<div class="portal"><h3></h3></div><!-- empty heading else wikipedia css will hide next <h3> after <div id='p-logo'>; DATE:2016-04-12-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="portal" id="xowa-portal-wikis">
|
||||||
|
<h3><a style="text-decoration: none !important;" href='javascript:xowa_toggle_visible("offline-wikis");'>Wikis<img title="" src="file:///C:/xowa/bin/any/xowa/file/app.general/twisty_down.png" id="offline-wikis-toggle-icon" /></a></h3>
|
||||||
|
<div class="body">
|
||||||
|
<ul style="display:;" id="offline-wikis-toggle-elem">
|
||||||
|
<li><a class="xowa-hover-off" href="/site/commons.wikimedia.org/">commons.wikimedia.org</a></li>
|
||||||
|
<li><a class="xowa-hover-off" href="/site/en.wikipedia.org/">en.wikipedia.org</a></li>
|
||||||
|
<li><a class="xowa-hover-off" href="/site/simple.wikipedia.org/">simple.wikipedia.org</a></li>
|
||||||
|
<li><a class="xowa-hover-off" href="/site/www.wikidata.org/">www.wikidata.org</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="border:0px !important" class="mw-body xo-popup-div" id="xo-popup-div-id"></div>
|
||||||
|
<!-- xo-popup-div-id
|
||||||
|
* must be placed as peer to <div id="content">, not as sub-child, else will have overlap problems with search bar
|
||||||
|
* must use mw-body class to have same text-styling
|
||||||
|
* border:0px to suppress blue border b/c of mw-body
|
||||||
|
-->
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,75 @@
|
|||||||
|
<div dir=ltr>
|
||||||
|
<div>
|
||||||
|
<h2>
|
||||||
|
<span class="mw-headline" id="Release:_v4.8.21.1808_.282018-08-06_21:00_Mon.29">Release: v4.8.21.1808 (2018-08-06 21:00 Mon)</span>
|
||||||
|
</h2>
|
||||||
|
<p>
|
||||||
|
The PC version is a minor release. It fixes parsing issues for 2018-07 English Wikipedia
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The Android version is a trivial release. It updates the list of wikis for Download Central.
|
||||||
|
</p>
|
||||||
|
<h3>
|
||||||
|
<span class="mw-headline" id=".28Wiki.29_Publish_2018-08_English_Wikipedia">(Wiki) Publish 2018-08 English Wikipedia</span>
|
||||||
|
</h3>
|
||||||
|
<p>
|
||||||
|
You can get them from Download Central or see the following links:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="/site/home/wiki/Wiki_setup/English_wikis" id="xolnki_2" title="Wiki setup/English wikis" class="xowa-visited">Wiki_setup/English_wikis</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="/site/home/wiki/Wiki_setup/German_wikis" id="xolnki_3" title="Wiki setup/German wikis" class="xowa-visited">Wiki_setup/German_wikis</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h3>
|
||||||
|
<span class="mw-headline" id=".28PC.29_Fix_multiple_script_errors_due_to_Wikibase_and_Scribunto">(PC) Fix multiple script errors due to Wikibase and Scribunto</span>
|
||||||
|
</h3>
|
||||||
|
<p>
|
||||||
|
There were a handful of parsing issues with English and German Wikipedia. In brief:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
Graph: Support v2 (some pages can only be viewable in HTTP_Server; EX: en.w:Obesity)
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Wikibase: Add isValidEntityId and getSetting
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Scribunto: Add stripNoWiki
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Scribunto: Return empty string for invalid languages
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Scribunto: Add better support for balanced pairs
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Parser: Cache ifexist calls
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
<span class='next_sect'>Next section: Next release</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<hr/>
|
||||||
|
<div>
|
||||||
|
<span class='data_val'><b>Blog/2018-01</b></span>
|
||||||
|
<span class='data_key'>size:</span><span class='data_val'>2.288 KB</span>
|
||||||
|
<span class='data_key'>edited:</span><span class='data_val'>2018-08-05 21:16:54</span>
|
||||||
|
<span class='data_key'></span><span class='data_val'>2018-08-12 21:37:03</span>
|
||||||
|
</div>
|
||||||
|
<hr/>
|
||||||
|
<div style='float:bottom;'>
|
||||||
|
<span><a href='xowa-cmd:xowa.api.nav.goto("home/wiki/Blog/2018-01");' title='Go to the Address'><img src='file:///C:/xowa/bin/any/xowa/file/app.menu/page/open.png'></a></span>
|
||||||
|
<span><a href='xowa-cmd:xowa.api.gui.browser.tabs.new_link__at_dflt__focus_y("home/wiki/Blog/2018-01");' title='Open Link in New Tab and Follow'><img src='file:///C:/xowa/bin/any/xowa/file/app.menu/tabs/new.png'></a></span>
|
||||||
|
<span><a href='xowa-cmd:xowa.api.gui.browser.tabs.new_link__at_dflt__focus_n("home/wiki/Blog/2018-01");' title='Open Link in New Tab'><img src='file:///C:/xowa/bin/any/xowa/file/app.menu/tabs/new_background.png'></a></span>
|
||||||
|
<span><a href='xowa-cmd:xowa.api.usr.bookmarks.add("home/wiki/Blog/2018-01");' title='Bookmark this Page'><img src='file:///C:/xowa/bin/any/xowa/file/app.menu/bookmarks/add.png'></a></span>
|
||||||
|
<span><a href='xowa-cmd:xowa.api.html.modules.popups.show_more("popup_1");' title='Show more text for the page'><img src='file:///C:/xowa/bin/any/xowa/html/res/src/xowa/popups/imgs/show_more.png'></a></span>
|
||||||
|
<span><a href='xowa-cmd:xowa.api.html.modules.popups.show_all ("popup_1");' title='Show all text for the page'> <img src='file:///C:/xowa/bin/any/xowa/html/res/src/xowa/popups/imgs/show_all.png' ></a></span>
|
||||||
|
<span><a href='/wiki/Special:XowaPopupHistory' title=''><img src='file:///C:/xowa/bin/any/xowa/file/app.menu/history/show.png'></a></span>
|
||||||
|
<span><a href='xowa-cmd:xowa.api.gui.browser.tabs.new_link__at_dflt__focus_y("home/wiki/Options/Popups");' title='Options'><img src='file:///C:/xowa/bin/any/xowa/file/app.menu/tools/options.png'></a></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,277 +0,0 @@
|
|||||||
/*
|
|
||||||
Based on Schnark's javascript for Reference tooltips
|
|
||||||
*/
|
|
||||||
(function($){
|
|
||||||
var cfg = {
|
|
||||||
show_delay : xowa.cfg.get('popups-win-show_delay'),
|
|
||||||
hide_delay : xowa.cfg.get('popups-win-hide_delay'),
|
|
||||||
max_w : xowa.cfg.get('popups-win-max_w'),
|
|
||||||
max_h : xowa.cfg.get('popups-win-max_h'),
|
|
||||||
show_all_max_w : xowa.cfg.get('popups-win-show_all_max_w'),
|
|
||||||
bind_focus_blur : xowa.cfg.get('popups-win-bind_focus_blur'),
|
|
||||||
bind_hover_area : xowa.cfg.get('popups-win-bind_hover_area'),
|
|
||||||
};
|
|
||||||
var fudge_size = 8;
|
|
||||||
|
|
||||||
if (window.xowa_popups_show_update == null) {
|
|
||||||
window.xowa_popups_show_update = xowa_popups_show_update;
|
|
||||||
}
|
|
||||||
if (window.xowa_popups_hide_all == null) {
|
|
||||||
window.xowa_popups_hide_all = xowa_popups_hide_all;
|
|
||||||
}
|
|
||||||
if (window.xowa_popups_bind_doc == null) {
|
|
||||||
window.xowa_popups_bind_doc = bind_hover_to_doc;
|
|
||||||
}
|
|
||||||
if (window.xowa_popups_bind_to_owner == null) {
|
|
||||||
window.xowa_popups_bind_to_owner = bind_hover_to_owner;
|
|
||||||
}
|
|
||||||
if (window.xowa_popups_bind_to_owner_js == null) {
|
|
||||||
window.xowa_popups_bind_to_owner_js = bind_hover_to_owner_js;
|
|
||||||
|
|
||||||
// subscribe to elem_add notifications
|
|
||||||
if (window.xo != null && window.xo.elem != null) {
|
|
||||||
xo.elem.elem_add__sub(window.xowa_popups_bind_to_owner_js);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (window.xowa_popups_bind_elem == null) {
|
|
||||||
window.xowa_popups_bind_elem = bind_hover_to;
|
|
||||||
}
|
|
||||||
var popup_cache = {};
|
|
||||||
var popup_next_id = 1;
|
|
||||||
var protocol_pattern = /^(((http|https|ftp):\/\/)|(javascript:|xowa-cmd:)|#cite_)/;
|
|
||||||
function show_init(elem, popup_itm, anchor_x, anchor_y) {
|
|
||||||
var elem_is_area = elem.prop('tagName') === 'AREA';
|
|
||||||
var popup_tooltip = elem_is_area ? elem.data('title') : ''; // only show tooltip if area
|
|
||||||
if (elem_is_area) {
|
|
||||||
window.status = popup_tooltip;
|
|
||||||
}
|
|
||||||
if (!popup_itm.html || popup_itm.href === '/wiki/Special:XowaPopupHistory') {
|
|
||||||
var html = xowa_exec('popups_get_html', popup_next_id, popup_itm.href, popup_tooltip);
|
|
||||||
if (!html) { // html is null; occurs for protocols such as http: and xowa-cmd:
|
|
||||||
elem.attr('title', elem.data('title')); // restore tooltip
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
popup_itm.html = html;
|
|
||||||
}
|
|
||||||
var popup_id = 'popup_' + (popup_next_id++).toString();
|
|
||||||
popup_itm.id = popup_id;
|
|
||||||
/*
|
|
||||||
*/
|
|
||||||
// insert popup to body else Read / Edit / View HTML will show on top; use multiple div wrappers to inherit same text styles from MW style sheet; DATE:2015-07-31
|
|
||||||
// var $wrapper_1 = $('<div/>',{'class':'mw-body'}) .appendTo('body'); // TOMBSTONE: do not dynamically add element; just use pre-existing item; DATE:2016-12-13
|
|
||||||
var $wrapper_1 = $('#xo-popup-div-id');
|
|
||||||
var $wrapper_2 = $('<div/>',{'class':'mw-body-content'}).appendTo($wrapper_1);
|
|
||||||
var $wrapper_3 = $('<div/>',{'class':'mw-content-ltr'}) .appendTo($wrapper_2);
|
|
||||||
var $popup = $('<div/>').attr('id', popup_id).addClass('xowa_popup').append(popup_itm.html).appendTo($wrapper_3);
|
|
||||||
// var $popup = $('<div>').attr('id', popup_id).addClass('xowa_popup').append(popup_itm.html).appendTo($('#mw-content-text'));
|
|
||||||
var window_max_w = cfg.max_w;
|
|
||||||
if (popup_itm.show_all_anchor_x) {
|
|
||||||
anchor_x = popup_itm.show_all_anchor_x;
|
|
||||||
window_max_w = popup_itm.show_all_max_w;
|
|
||||||
}
|
|
||||||
return show_popup(popup_itm, $popup, anchor_x, anchor_y, window_max_w);
|
|
||||||
}
|
|
||||||
function xowa_popups_show_update(mode, href, html) {
|
|
||||||
var popup_itm = popup_cache[href];
|
|
||||||
if (!popup_itm) return; // shouldn't happen
|
|
||||||
var $popup = $("#" + popup_itm.id);
|
|
||||||
$popup.html(html);
|
|
||||||
popup_itm.html = html;
|
|
||||||
var $window = $(window);
|
|
||||||
var $anchor = $(popup_itm.anchor);
|
|
||||||
var anchor_x = $popup.offset().left;
|
|
||||||
var popup_max_w = cfg.max_w;
|
|
||||||
if (mode == 'all' && cfg.show_all_max_w != -1) {
|
|
||||||
popup_max_w = cfg.show_all_max_w;
|
|
||||||
var window_width = $window.width();
|
|
||||||
if (anchor_x + popup_max_w > window_width)
|
|
||||||
anchor_x = window_width - popup_max_w;
|
|
||||||
if (anchor_x < 0) anchor_x = 0;
|
|
||||||
popup_itm.show_all_anchor_x = anchor_x;
|
|
||||||
popup_itm.show_all_max_w = popup_max_w;
|
|
||||||
}
|
|
||||||
var anchor_y = $anchor.offset().top - $window.scrollTop();
|
|
||||||
if (anchor_y < 0) anchor_y = 0; // sometimes < 0; not sure why
|
|
||||||
show_popup(popup_itm, $popup, anchor_x - fudge_size, anchor_y, popup_max_w); // need to subtract fudge_size, or else popup drifts rightwards
|
|
||||||
}
|
|
||||||
function xowa_popups_hide_all() {
|
|
||||||
var now_time = new Date().getTime();
|
|
||||||
for (var popup_key in popup_cache) {
|
|
||||||
var popup_itm = popup_cache[popup_key];
|
|
||||||
if (now_time - popup_itm.show_time < cfg.show_delay) // hide popup only if shown recently; allows popups that were showing to still show while page is loaded
|
|
||||||
popup_itm.popup.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function show_focus ($this) {
|
|
||||||
var ev = {
|
|
||||||
clientX : $this.offset().left - $(window).scrollLeft(),
|
|
||||||
clientY : $this.offset().top - $(window).scrollTop(),
|
|
||||||
}
|
|
||||||
show($this, ev);
|
|
||||||
}
|
|
||||||
function show ($this, ev) {
|
|
||||||
var href = $this.attr('href');
|
|
||||||
if (!href || href.length == 0) return;
|
|
||||||
if (href.charAt(0) === '#') return; // ignore "#" which is used for javascript; DATE:2014-08-21
|
|
||||||
if (protocol_pattern.test(href)) return; // ignore hrefs with absolute protocol of "http:", etc. which won't point to XOWA content
|
|
||||||
if ($this.hasClass('xowa-hover-off')) return; // ignore href if "xowa-hover-off" (for sidebar itms)
|
|
||||||
var popup_itm = popup_cache[href];
|
|
||||||
if (!popup_itm) {
|
|
||||||
popup_itm = {
|
|
||||||
href : href,
|
|
||||||
anchor : $this,
|
|
||||||
};
|
|
||||||
popup_cache[href] = popup_itm;
|
|
||||||
}
|
|
||||||
data = $this.data();
|
|
||||||
if (data.willShow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data.willHide) {
|
|
||||||
$this.data('willHide', false);
|
|
||||||
window.clearTimeout(data.hideTimer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data.popupVisible) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!$this.data('title')) {
|
|
||||||
$this.data('title', $this.attr('title'));
|
|
||||||
$this.attr('title', '');
|
|
||||||
}
|
|
||||||
$this.data({
|
|
||||||
willShow: true,
|
|
||||||
showTimer: window.setTimeout(function () {
|
|
||||||
$this.data({
|
|
||||||
willShow: false,
|
|
||||||
popupVisible: true,
|
|
||||||
popupRef: show_init($this, popup_itm, ev.clientX, ev.clientY).hover(
|
|
||||||
function () {
|
|
||||||
show($this, ev);
|
|
||||||
}, function () {
|
|
||||||
hide($this);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}, cfg.show_delay)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function show_popup(popup_itm, $popup, anchor_x, anchor_y, popup_max_w) {
|
|
||||||
var $window = $(window);
|
|
||||||
var popup_pos = calc_popup_pos(anchor_x, anchor_y, $popup.outerWidth(), $popup.outerHeight(), $window.width(), $window.height());
|
|
||||||
if (window.xowa.js.mathJax == null)
|
|
||||||
window.xowa.js.load_lib(xowa.root_dir + 'bin/any/javascript/xowa/mathjax/xowa_mathjax.js', xowa_mathjax_run); // note that this will only load mathjax if math items are on page
|
|
||||||
else
|
|
||||||
xowa_mathjax_run();
|
|
||||||
bind_hover_to($('a', $popup));
|
|
||||||
$popup.css({
|
|
||||||
left: popup_pos.x,
|
|
||||||
top : popup_pos.y,
|
|
||||||
});
|
|
||||||
if (popup_max_w > 0)
|
|
||||||
$popup.css({maxWidth: popup_max_w});
|
|
||||||
else
|
|
||||||
$popup.css({maxWidth : cfg.max_w});
|
|
||||||
var max_h = $window.height() - 20; //margin, border, padding + noch ein bisschen Sicherheit
|
|
||||||
if (cfg.max_h > 0 && cfg.max_h < max_h)
|
|
||||||
max_h = cfg.max_h;
|
|
||||||
$popup.css({maxHeight: max_h});
|
|
||||||
popup_itm.popup = $popup;
|
|
||||||
popup_itm.show_time = new Date().getTime();
|
|
||||||
return $popup.hide().fadeIn('fast');
|
|
||||||
}
|
|
||||||
function xowa_mathjax_run() { // NOTE: need indirection via function else null ref when window.xowa.js.mathJax == null
|
|
||||||
window.xowa.js.mathJax.run();
|
|
||||||
}
|
|
||||||
function calc_popup_pos (x, y, w, h, W, H) {
|
|
||||||
var d = fudge_size; // increase distance to prevent popup from overlapping with link
|
|
||||||
if (x + d + w > W) {
|
|
||||||
x = W - w - 2;
|
|
||||||
d = 20;
|
|
||||||
if (x < 0) {
|
|
||||||
x = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
x = x + d;
|
|
||||||
}
|
|
||||||
if (y < h + d) {
|
|
||||||
if (y + d + h < H) {
|
|
||||||
y = y + d;
|
|
||||||
} else {
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
y = y - h - d;
|
|
||||||
}
|
|
||||||
return {x: x, y: y};
|
|
||||||
}
|
|
||||||
function hide ($this) {
|
|
||||||
var data = $this.data();
|
|
||||||
if (data.willHide) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data.willShow) {
|
|
||||||
$this.data('willShow', false);
|
|
||||||
window.clearTimeout(data.showTimer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!data.popupVisible) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this.data({
|
|
||||||
willHide: true,
|
|
||||||
hideTimer: window.setTimeout(function () {
|
|
||||||
$this.data({
|
|
||||||
willHide: false,
|
|
||||||
popupVisible: false
|
|
||||||
});
|
|
||||||
reallyHide(data.popupRef);
|
|
||||||
}, cfg.hide_delay)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function reallyHide ($popup) {
|
|
||||||
$popup.fadeOut('fast', function () {
|
|
||||||
if ($popup.find('a').length) {
|
|
||||||
$popup.detach();
|
|
||||||
} else {
|
|
||||||
$popup.remove();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function bind_hover_to_doc() {
|
|
||||||
bind_hover_to($('a'));
|
|
||||||
if (cfg.bind_hover_area)
|
|
||||||
bind_hover_to($('area'));
|
|
||||||
}
|
|
||||||
function bind_hover_to_owner_js(owner) {
|
|
||||||
bind_hover_to_owner(owner);
|
|
||||||
}
|
|
||||||
function bind_hover_to_owner(owner) {
|
|
||||||
bind_hover_to($(owner).find('a'));
|
|
||||||
if (cfg.bind_hover_area)
|
|
||||||
bind_hover_to($(owner).find('a'));
|
|
||||||
}
|
|
||||||
function bind_hover_to(elems) {
|
|
||||||
elems.hover(
|
|
||||||
function (e) {
|
|
||||||
show($(this), e);
|
|
||||||
}, function () {
|
|
||||||
hide($(this));
|
|
||||||
});
|
|
||||||
if (cfg.bind_focus_blur) {
|
|
||||||
elems.focus(
|
|
||||||
function (e) {
|
|
||||||
show_focus($(this), e);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
elems.blur(
|
|
||||||
function (e) {
|
|
||||||
hide($(this), e);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$(bind_hover_to_doc);
|
|
||||||
|
|
||||||
})(jQuery);
|
|
454
res/bin/any/xowa/html/res/src/xowa/popups/xo.popup.js
Normal file
454
res/bin/any/xowa/html/res/src/xowa/popups/xo.popup.js
Normal file
@ -0,0 +1,454 @@
|
|||||||
|
(function($){ // self-invoking anonymous function to reduce pollution of global namespace
|
||||||
|
|
||||||
|
var XoPopupMode = {
|
||||||
|
Hidden: 'hidden'
|
||||||
|
, ShowConfirming: 'confirmingShow'
|
||||||
|
, Shown: 'shown'
|
||||||
|
, HideConfirming: 'confirmingHide'
|
||||||
|
}
|
||||||
|
Object.freeze(XoPopupMode);
|
||||||
|
|
||||||
|
var XoPopupItm = (function(){
|
||||||
|
XoPopupItm.prototype.Html = null;
|
||||||
|
XoPopupItm.prototype.Mode = XoPopupMode.Hidden;
|
||||||
|
XoPopupItm.prototype.AnchorElem = null;
|
||||||
|
XoPopupItm.prototype.AnchorTitle = null;
|
||||||
|
XoPopupItm.prototype.PopupElem = null;
|
||||||
|
XoPopupItm.prototype.ShowConfirmedCbk = null;
|
||||||
|
XoPopupItm.prototype.HideConfirmedCbk = null;
|
||||||
|
XoPopupItm.prototype.HoverX = 0;
|
||||||
|
XoPopupItm.prototype.HoverY = 0;
|
||||||
|
|
||||||
|
function XoPopupItm(AnchorElem) {
|
||||||
|
this.Id = 'popup_' + (XoPopupItm.IdNext++).toString();
|
||||||
|
this.AnchorElem = AnchorElem;
|
||||||
|
}
|
||||||
|
|
||||||
|
XoPopupItm.IdNext = 1;
|
||||||
|
return XoPopupItm;
|
||||||
|
}());
|
||||||
|
|
||||||
|
var XoPopupCfg = (function(){
|
||||||
|
function XoPopupCfg() {
|
||||||
|
this.WriteLogEnabled = false;
|
||||||
|
this.ShowConfirmingDelay = xowa.cfg.get('popups-win-show_delay');
|
||||||
|
this.HideConfirmingDelay = xowa.cfg.get('popups-win-hide_delay');
|
||||||
|
this.MaxW = xowa.cfg.get('popups-win-max_w');
|
||||||
|
this.MaxH = xowa.cfg.get('popups-win-max_h');
|
||||||
|
this.ShowAllMaxW = xowa.cfg.get('popups-win-show_all_max_w');
|
||||||
|
this.AllowPopupsForKeyboardTabbing = xowa.cfg.get('popups-win-bind_focus_blur');
|
||||||
|
this.BindHoverArea = xowa.cfg.get('popups-win-bind_hover_area');
|
||||||
|
}
|
||||||
|
return XoPopupCfg;
|
||||||
|
}());
|
||||||
|
|
||||||
|
var XoPopupMgr = (function(){
|
||||||
|
// ----------------------------------
|
||||||
|
// Ctor; props
|
||||||
|
// ----------------------------------
|
||||||
|
function XoPopupMgr() {
|
||||||
|
this.BindHoverToDoc();
|
||||||
|
|
||||||
|
// subscribe to callback
|
||||||
|
var mgr = this;
|
||||||
|
xowa.js.doc.evtElemAdd.sub(
|
||||||
|
function(elem) {
|
||||||
|
var anchs = $('a', $(elem));
|
||||||
|
mgr.BindHoverTo(anchs);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
XoPopupMgr.prototype.Cfg = new XoPopupCfg();
|
||||||
|
XoPopupMgr.prototype.Cache = {};
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// Bind <a> / <area> to hover
|
||||||
|
// ----------------------------------
|
||||||
|
XoPopupMgr.prototype.BindHoverToDoc = function() {
|
||||||
|
this.BindHoverTo($('a'));
|
||||||
|
if (this.Cfg.BindHoverArea) { // <area> tags have href param; REF:en.w:Samuel_Johnson
|
||||||
|
this.BindHoverTo($('area'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XoPopupMgr.prototype.BindHoverTo = function(elems) {
|
||||||
|
elems = this.BindHoverToFilter(elems);
|
||||||
|
elems.hover
|
||||||
|
( function(ev) {XoPopupMgr.prototype.ShowConfirming($(this), ev);}
|
||||||
|
, function() {XoPopupMgr.prototype.HideConfirming($(this));}
|
||||||
|
);
|
||||||
|
if (this.Cfg.AllowPopupsForKeyboardTabbing){
|
||||||
|
elems.focus(function(ev) {XoPopupMgr.prototype.ShowFocus($(this), ev);});
|
||||||
|
elems.blur (function(ev) {XoPopupMgr.prototype.Hide($(this), ev);});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// NOTE: ".*/wiki/File:" is for HTTP: ("/en.wikipedia.org/wiki/File:...") and SWT ("/wiki/File:...")
|
||||||
|
XoPopupMgr.ProtocolPattern = /^(((http|https|ftp):\/\/)|(javascript:|xowa-cmd:|.*\/wiki\/File:|.*\/wiki\/Image:)|#cite_)/;
|
||||||
|
XoPopupMgr.prototype.BindHoverToFilter = function(elems) {
|
||||||
|
var array = [];
|
||||||
|
var len = elems.length;
|
||||||
|
for (var i = 0; i < len; i++) {
|
||||||
|
var $anch = $(elems[i]);
|
||||||
|
var href = $anch.attr('href');
|
||||||
|
if (!href || href.length == 0) continue; // ignore empty anch; EX: '<a>'
|
||||||
|
if (href.charAt(0) === '#') continue; // ignore "#" which is used for javascript; DATE:2014-08-21
|
||||||
|
if (XoPopupMgr.ProtocolPattern.test(href)) continue; // ignore hrefs with absolute protocol of "http:", etc. which won't point to XOWA content
|
||||||
|
if ($anch.hasClass('xowa-hover-off')) continue; // ignore href if "xowa-hover-off" (for sidebar itms)
|
||||||
|
array.push($anch);
|
||||||
|
}
|
||||||
|
return $(array).map (function () {return this.toArray();}); // REF:https://stackoverflow.com/questions/6867184/turn-array-of-jquery-elements-into-jquery-wrapped-set-of-elements
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// Show / hide
|
||||||
|
// ----------------------------------
|
||||||
|
XoPopupMgr.prototype.ShowConfirming = function($anch, ev) {
|
||||||
|
if (this.Cfg.WriteLogEnabled) this.WriteLogByAnch($anch, 'XoPopupMgr.ShowConfirming.Bgn');
|
||||||
|
|
||||||
|
// exit unless mode is hidden
|
||||||
|
var popupItm = this.GetItmOrNew($anch);
|
||||||
|
switch (popupItm.Mode) {
|
||||||
|
case XoPopupMode.Hidden:
|
||||||
|
popupItm.Mode = XoPopupMode.ShowConfirming;
|
||||||
|
break;
|
||||||
|
case XoPopupMode.HideConfirming:
|
||||||
|
popupItm.Mode = XoPopupMode.Shown;
|
||||||
|
window.clearTimeout(popupItm.HideConfirmedCbk);
|
||||||
|
return;
|
||||||
|
case XoPopupMode.ShowConfirming:
|
||||||
|
case XoPopupMode.Shown:
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
console.log('XoPopupMgr.ShowConfirming:unknown ' + popupItm.Mode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set title to '' b/c we don't want it to show before popup does
|
||||||
|
if (!popupItm.AnchorTitle) {
|
||||||
|
popupItm.AnchorTitle = $anch.attr('title');
|
||||||
|
$anch.attr('title', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// cache X,Y of mouse pointer
|
||||||
|
popupItm.HoverX = ev.clientX;
|
||||||
|
popupItm.HoverY = ev.clientY;
|
||||||
|
|
||||||
|
// set-up callback
|
||||||
|
var mgr = this;
|
||||||
|
popupItm.ShowConfirmedCbk = window.setTimeout(
|
||||||
|
function() {mgr.ShowConfirmed($anch, popupItm);}
|
||||||
|
, this.Cfg.ShowConfirmingDelay
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.Cfg.WriteLogEnabled) this.WriteLogByAnch($anch, 'XoPopupMgr.ShowConfirming.End');
|
||||||
|
}
|
||||||
|
|
||||||
|
XoPopupMgr.prototype.ShowConfirmed = function($anch, popupItm) {
|
||||||
|
if (this.Cfg.WriteLogEnabled) this.WriteLogByAnch($anch, 'XoPopupMgr.ShowConfirmed.Bgn');
|
||||||
|
|
||||||
|
// set mode to shown
|
||||||
|
popupItm.Mode = XoPopupMode.Shown;
|
||||||
|
|
||||||
|
// create popup
|
||||||
|
var html = popupItm.Html;
|
||||||
|
if (!html) html = 'retrieving data'
|
||||||
|
this.CreatePopup(true, popupItm, popupItm.AnchorElem, html);
|
||||||
|
|
||||||
|
// no cached html; call XOWA
|
||||||
|
if (!popupItm.Html) {
|
||||||
|
var href = $anch.attr('href');
|
||||||
|
var mgr = this;
|
||||||
|
var showMode = 'init';
|
||||||
|
switch (xowa.app.mode) {
|
||||||
|
case 'http_server':
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
if (href.startsWith('/wiki/')) href = xowa.page.wiki + href; // Special:XowaCfg and other pages use AJAX to update page content which won't pass through Convert_page; DATE:2018-11-11
|
||||||
|
var path = href + '?action=popup&popup_mode=init&popup_id=' + popupItm.Id;
|
||||||
|
req.onload = function(e) {
|
||||||
|
mgr.UpdatePopupHtml(popupItm.Id, showMode, req.responseText);
|
||||||
|
}
|
||||||
|
req.open("GET", path, true); // 'false': synchronous.
|
||||||
|
req.send(null);
|
||||||
|
break;
|
||||||
|
case 'mock':
|
||||||
|
xowa.popups.Mock_popups_get_html(mgr, 'init', popupItm, href); // NOTE: must be "xowa.popups", not "this", b/c "this" will call prototype first
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
var elemIsArea = $anch.prop('tagName') === 'AREA';
|
||||||
|
var popupTooltip = elemIsArea ? $anch.attr('title') : ''; // only show tooltip if area
|
||||||
|
mgr.UpdatePopupHtml(popupItm.Id, showMode, xowa_exec('popups_get_html', "init", popupItm.Id, href, popupTooltip));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Cfg.WriteLogEnabled) this.WriteLogByAnch($anch, 'XoPopupMgr.ShowConfirmed.End');
|
||||||
|
}
|
||||||
|
|
||||||
|
XoPopupMgr.prototype.HideConfirming = function($anch) {
|
||||||
|
if (this.Cfg.WriteLogEnabled) this.WriteLogByAnch($anch, 'XoPopupMgr.HideConfirming.Bgn');
|
||||||
|
|
||||||
|
// exit unless mode is Shown
|
||||||
|
var popupItm = this.GetItmOrNew($anch);
|
||||||
|
switch (popupItm.Mode) {
|
||||||
|
case XoPopupMode.Shown:
|
||||||
|
popupItm.Mode = XoPopupMode.HideConfirming;
|
||||||
|
break;
|
||||||
|
case XoPopupMode.ShowConfirming:
|
||||||
|
popupItm.Mode = XoPopupMode.Hidden;
|
||||||
|
window.clearTimeout(popupItm.ShowConfirmedCbk);
|
||||||
|
return;
|
||||||
|
case XoPopupMode.HideConfirming:
|
||||||
|
case XoPopupMode.Hidden:
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
console.log('XoPopupMgr.HideConfirming:unknown ' + popupItm.Mode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set-up callback
|
||||||
|
var mgr = this;
|
||||||
|
popupItm.HideConfirmedCbk = window.setTimeout(function () {mgr.HideConfirmed($anch, popupItm);}, this.Cfg.HideConfirmingDelay);
|
||||||
|
|
||||||
|
if (this.Cfg.WriteLogEnabled) this.WriteLogByAnch($anch, 'XoPopupMgr.HideConfirming.End');
|
||||||
|
}
|
||||||
|
|
||||||
|
XoPopupMgr.prototype.HideConfirmed = function($anch, popupItm) {
|
||||||
|
if (this.Cfg.WriteLogEnabled) this.WriteLogByAnch($anch, 'XoPopupMgr.HideConfirmed.Bgn');
|
||||||
|
|
||||||
|
// set to hidden
|
||||||
|
popupItm.Mode = XoPopupMode.Hidden;
|
||||||
|
|
||||||
|
// fade item out
|
||||||
|
var $popup = popupItm.PopupElem;
|
||||||
|
if ($popup) {
|
||||||
|
$popup.fadeOut('fast', function () {
|
||||||
|
$('#' + popupItm.Id + '_body').remove();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Cfg.WriteLogEnabled) this.WriteLogByAnch($anch, 'XoPopupMgr.HideConfirmed.End');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// create / update popup html
|
||||||
|
// ----------------------------------
|
||||||
|
XoPopupMgr.prototype.CreatePopup = function(create, popupItm, $anch, html) {
|
||||||
|
// create popup
|
||||||
|
// insert popup to body, else "Read / Edit / View HTML" will show on top; use multiple div wrappers to inherit same text styles from MW style sheet; DATE:2015-07-31
|
||||||
|
// var $wrapper_1 = $('<div/>',{'class':'mw-body'}).appendTo('body'); // TOMBSTONE: do not dynamically add element; just use pre-existing item; DATE:2016-12-13
|
||||||
|
var $popup = null;
|
||||||
|
|
||||||
|
if (create) {
|
||||||
|
var $wrapper_1 = $('#xo-popup-div-id');
|
||||||
|
var $wrapper_2 = $('<div/>',{'class':'mw-body-content', 'id':popupItm.Id + '_body'}).appendTo($wrapper_1);
|
||||||
|
var $wrapper_3 = $('<div/>',{'class':'mw-content-ltr'}) .appendTo($wrapper_2);
|
||||||
|
$popup = $('<div/>').attr('id', popupItm.Id).addClass('xowa_popup').append(html).appendTo($wrapper_3);
|
||||||
|
// var $popup = $('<div>').attr('id', popup_id).addClass('xowa_popup').append(popupItm.html).appendTo($('#mw-content-text'));
|
||||||
|
popupItm.PopupElem = $popup;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$popup = popupItm.PopupElem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// calc position
|
||||||
|
var popupX = popupItm.HoverX;
|
||||||
|
var popupY = popupItm.HoverY;
|
||||||
|
|
||||||
|
// set popup's left / top
|
||||||
|
var $window = $(window);
|
||||||
|
var popupPos = XoPopupMgr.AdjustPopupPos(popupX, popupY, $popup.outerWidth(), $popup.outerHeight(), $window.width(), $window.height());
|
||||||
|
$popup.css({
|
||||||
|
left: popupPos.X,
|
||||||
|
top : popupPos.Y,
|
||||||
|
});
|
||||||
|
|
||||||
|
// default maxW to this.Cfg.MaxW which is ordinarily "-1" which means fit to html; if "all", default to window.width
|
||||||
|
var popupMaxW = this.Cfg.MaxW;
|
||||||
|
if (popupItm.ShowMode === 'all') {
|
||||||
|
popupMaxW = $window.width() - 20; //margin, border, padding
|
||||||
|
}
|
||||||
|
$popup.css({maxWidth: popupMaxW});
|
||||||
|
|
||||||
|
// default maxH to window.height(); can't be -1, else div won't scroll
|
||||||
|
var popupMaxH = $window.height() - 20; //margin, border, padding + noch ein bisschen Sicherheit
|
||||||
|
if (this.Cfg.MaxH > 0) { // NOTE: > 0 b/c defaults to -1
|
||||||
|
popupMaxH = this.Cfg.MaxH;
|
||||||
|
}
|
||||||
|
$popup.css({maxHeight: popupMaxH});
|
||||||
|
|
||||||
|
// allow popups for any anchor in popup
|
||||||
|
this.BindHoverTo($('a', $popup));
|
||||||
|
|
||||||
|
// bind popup's hover to anch; allows hovering over popup to keep popup open
|
||||||
|
$popup.hover(
|
||||||
|
function(ev) {XoPopupMgr.prototype.ShowConfirming($anch, ev);}
|
||||||
|
, function() {XoPopupMgr.prototype.HideConfirming($anch);}
|
||||||
|
);
|
||||||
|
|
||||||
|
$popup.fadeIn('fast');
|
||||||
|
}
|
||||||
|
|
||||||
|
XoPopupMgr.prototype.UpdatePopupHtml = function(popupItmId, showMode, html) {
|
||||||
|
// get $anch
|
||||||
|
var popupItm = this.Cache[popupItmId];
|
||||||
|
var $anch = popupItm.AnchorElem;
|
||||||
|
if (this.Cfg.WriteLogEnabled) this.WriteLogByAnch($anch, 'XoPopupMgr.UpdatePopupHtml.Bgn');
|
||||||
|
|
||||||
|
// set html
|
||||||
|
if (!html) { // html is null; occurs for protocols such as http: and xowa-cmd:
|
||||||
|
$anch.attr('title', popupItm.AnchorTitle); // restore tooltip
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var mgr = this;
|
||||||
|
|
||||||
|
// update html
|
||||||
|
var popupHtmlElem = $('#' + popupItm.Id);
|
||||||
|
popupHtmlElem.fadeOut('fast', function() {
|
||||||
|
popupItm.ShowMode = showMode;
|
||||||
|
popupItm.Html = html;
|
||||||
|
popupHtmlElem.html(html);
|
||||||
|
mgr.CreatePopup(false, popupItm, popupItm.AnchorElem, html);
|
||||||
|
popupHtmlElem.fadeIn('fast');
|
||||||
|
xowa.js.doc.evtElemAdd.pub(popupItm.PopupElem[0]); // "[0]" -> REF:https://learn.jquery.com/using-jquery-core/faq/how-do-i-pull-a-native-dom-element-from-a-jquery-object/
|
||||||
|
});
|
||||||
|
|
||||||
|
// only show tooltip if area
|
||||||
|
if ($anch.prop('tagName') === 'AREA') {
|
||||||
|
window.status = $anch.data('title');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Cfg.WriteLogEnabled) this.WriteLogByAnch($anch, 'XoPopupMgr.UpdatePopupHtml.End');
|
||||||
|
}
|
||||||
|
|
||||||
|
XoPopupMgr.AdjustPopupPos = function(popupX, popupY, popupW, popupH, windowW, windowH) {
|
||||||
|
// if popupX causes popup to not show entirely on screen, right-align to window-right
|
||||||
|
var offsetX = 8;
|
||||||
|
if (popupX + popupW + offsetX > windowW) {
|
||||||
|
popupX = windowW - popupW - offsetX;
|
||||||
|
if (popupX < 0) {
|
||||||
|
popupX = 0;
|
||||||
|
}
|
||||||
|
// else just nudge it by offset to prevent popup from overlapping with link
|
||||||
|
} else {
|
||||||
|
popupX = popupX + offsetX;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if popupY causes popup to not show entirely on screen, bottom-align to window-bottom
|
||||||
|
var offsetY = 20; // adjust for statusBar
|
||||||
|
if (popupY + popupH + offsetY > windowH) {
|
||||||
|
popupY = windowH - popupH - offsetY;
|
||||||
|
if (popupY < 0) {
|
||||||
|
popupY = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else just nudge it by offset to prevent popup from overlapping with link
|
||||||
|
else {
|
||||||
|
popupY = popupY + offsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {X: popupX, Y: popupY};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// Utility
|
||||||
|
// ----------------------------------
|
||||||
|
XoPopupMgr.prototype.GetItmOrNew = function($anch) {
|
||||||
|
var popupId = $anch.attr('xo_popup_id');
|
||||||
|
if (popupId) {
|
||||||
|
popupItm = this.Cache[popupId];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
popupItm = new XoPopupItm($anch);
|
||||||
|
$anch.attr('xo_popup_id', popupItm.Id);
|
||||||
|
this.Cache[popupItm.Id] = popupItm;
|
||||||
|
}
|
||||||
|
return popupItm;
|
||||||
|
}
|
||||||
|
|
||||||
|
XoPopupMgr.prototype.WriteLogByAnch = function($anch, message) {
|
||||||
|
console.log(message + ':' + ' id=' + $anch.attr('xo_popup_id') + ' href=' + $anch.attr('href'));
|
||||||
|
}
|
||||||
|
|
||||||
|
XoPopupMgr.prototype.dbg = function() {
|
||||||
|
var args_len = arguments.length;
|
||||||
|
var elem = document.getElementById('siteSub');
|
||||||
|
for (var i = 0; i < args_len; i++) {
|
||||||
|
elem.innerHTML += ' ' + arguments[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
XoPopupMgr.prototype.FetchMore = function(popupItmId) {
|
||||||
|
var popupItm = this.Cache[popupItmId];
|
||||||
|
switch (xowa.app.mode) {
|
||||||
|
case 'http_server':
|
||||||
|
var href = popupItm.AnchorElem.attr('href');
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
if (href.startsWith('/wiki/')) href = xowa.page.wiki + href; // Special:XowaCfg and other pages use AJAX to update page content which won't pass through Convert_page; DATE:2018-11-11
|
||||||
|
var path = href + '?action=popup&popup_mode=more&popup_id=' + popupItmId;
|
||||||
|
req.onload = function(e) {
|
||||||
|
mgr.UpdatePopupHtml(popupItm.Id, req.responseText);
|
||||||
|
}
|
||||||
|
req.open("GET", path, true); // 'false': synchronous.
|
||||||
|
req.send(null);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.UpdatePopupHtml(popupItm.Id, xowa_exec('popups_get_html', "more", popupItm.Id));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return XoPopupMgr;
|
||||||
|
}());
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
window.xowa.popups = new XoPopupMgr();
|
||||||
|
});
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
/*
|
||||||
|
# TESTING
|
||||||
|
## SWT
|
||||||
|
### en.w:Earth
|
||||||
|
Basic popup
|
||||||
|
* Hover over planet -> popup
|
||||||
|
* Hover over Sun -> popup
|
||||||
|
* Hover over planet -> cached, and still planet (not sun)
|
||||||
|
* Hover over Sun -> cached, and still planet (not sun)
|
||||||
|
* Double hover: hover over any link in Sun popup
|
||||||
|
|
||||||
|
Show more
|
||||||
|
* Show more a few times -> make sure vertical scroll bar
|
||||||
|
* Show all -> make sure popup widens
|
||||||
|
|
||||||
|
Ignored links
|
||||||
|
* xowa-hover-off links should not show
|
||||||
|
** any link in sidebar
|
||||||
|
** Article / Talk
|
||||||
|
** Read, Edit, View HTML
|
||||||
|
* Http links (scroll down to any link in references)
|
||||||
|
* Images
|
||||||
|
* Reference links (should show Reference tool tip)
|
||||||
|
|
||||||
|
### en.w:Samuel_Johnson
|
||||||
|
Image map via area
|
||||||
|
(NOTE: this behavior only works in XULRunner; latest Chrome / Firefox no longer captures onmouseenter / onmouseexit for <area>)
|
||||||
|
* Scroll down to "A literary party... The Club" and hover over any of the figures
|
||||||
|
|
||||||
|
### Special:XowaSearch?search=test&fulltext=y
|
||||||
|
Full-text search
|
||||||
|
* Hover over any of the search results
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## HTTP server (Firefox)
|
||||||
|
### http://localhost:8080/en.wikipedia.org/wiki/Earth
|
||||||
|
|
||||||
|
Basic popup
|
||||||
|
* Same as SWT/Basic_popup above
|
||||||
|
|
||||||
|
Hover over image -> should not show "retrieving data"
|
||||||
|
|
||||||
|
### http://localhost:8080/home/wiki/Special:XowaCfg?grp=xowa.addon.popups
|
||||||
|
AJAX: b/c HTML comes from AJAX which doesn't pass through Convert_page
|
||||||
|
*/
|
@ -2,11 +2,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
xo.mode_is_debug = false;
|
xo.mode_is_debug = false;
|
||||||
|
|
||||||
// NOTE: xo.elem is now init'd by default on all pages
|
|
||||||
// it will then be init'd a 2nd time for special pages
|
|
||||||
// ignore 2nd init else elem_add_subs will be cleared
|
|
||||||
if (xo.elem) return;
|
|
||||||
|
|
||||||
// standard creation
|
// standard creation
|
||||||
xo.elem = new function () {
|
xo.elem = new function () {
|
||||||
this.get = function (elem_id) {
|
this.get = function (elem_id) {
|
||||||
@ -60,20 +55,10 @@
|
|||||||
|
|
||||||
this.insert_html_above = function(elem_id, html) {
|
this.insert_html_above = function(elem_id, html) {
|
||||||
var elem = document.getElementById(elem_id);
|
var elem = document.getElementById(elem_id);
|
||||||
elem.insertAdjacentHTML('beforebegin', html);
|
elem.insertAdjacentHTML('beforebegin', html);
|
||||||
xo.elem.elem_add__pub(elem.parentNode);
|
xowa.js.doc.evtElemAdd.pub(elem);
|
||||||
};
|
};
|
||||||
this.elem_add__subs = [];
|
|
||||||
this.elem_add__pub = function(elem) {
|
|
||||||
if (elem == null) elem = document;
|
|
||||||
var len = xo.elem.elem_add__subs.length;
|
|
||||||
for (var i = 0; i < len; i++) {
|
|
||||||
xo.elem.elem_add__subs[i](elem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.elem_add__sub = function(func) {
|
|
||||||
xo.elem.elem_add__subs.push(func);
|
|
||||||
}
|
|
||||||
this.selectbox__selected_set = function(sel_id) {
|
this.selectbox__selected_set = function(sel_id) {
|
||||||
try {
|
try {
|
||||||
var sel = document.getElementById(sel_id);
|
var sel = document.getElementById(sel_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user