mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
HTTP Server: Support popups [#264]
This commit is contained in:
@@ -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 gplx.xowa.addons.apps.cfgs.mgrs.types.*;
|
||||
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() {
|
||||
fxt.Type_("memo").Key_("key1").Name_("name1").Html_cls_("html_cls1").Html_atrs_("key1=val1");
|
||||
|
||||
// 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"
|
||||
+ "</textarea>");
|
||||
|
||||
// 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>"
|
||||
+ "</textarea>");
|
||||
}
|
||||
}
|
||||
class Xoedit_itm_html_fxt {
|
||||
private final Xocfg_type_mgr type_mgr = new Xocfg_type_mgr();
|
||||
private final Bry_bfr bry = Bry_bfr_.New();
|
||||
private final Xocfg_type_mgr type_mgr = new Xocfg_type_mgr();
|
||||
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 Key_(String v) {this.key = v; return this;} private String key;
|
||||
|
||||
@@ -33,13 +33,30 @@ public class Xocfg_maint_svc {
|
||||
// exec
|
||||
Xocfg_db_app db_app = Xocfg_db_app.New(app);
|
||||
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();
|
||||
for (Xocfg_maint_nde nde : ndes) {
|
||||
// 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()));
|
||||
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
|
||||
if (nde.Type_is_grp()) {
|
||||
|
||||
Reference in New Issue
Block a user