From b95811e4dab26d770c6d972a456ac0b31b39ca53 Mon Sep 17 00:00:00 2001 From: Fabrice Leal Date: Mon, 9 Jul 2018 22:34:11 +0100 Subject: offsetX, offsetY --- lib/js/urweb.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/js/urweb.js') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 99b45ec9..ff4c7b7e 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -553,6 +553,8 @@ function uw_mouseEvent() { _ScreenY : firstGood(ev.screenY, 0), _ClientX : firstGood(ev.clientX, 0), _ClientY : firstGood(ev.clientY, 0), + _OffsetX : firstGood(ev.offsetX, 0), + _OffsetY : firstGood(ev.offsetY, 0), _CtrlKey : firstGood(ev.ctrlKey, false), _ShiftKey : firstGood(ev.shiftKey, false), _AltKey : firstGood(ev.altKey, false), -- cgit v1.2.3 From eb86dffeeec897d17905f3adff84e6acfd018330 Mon Sep 17 00:00:00 2001 From: Denis Redozubov Date: Wed, 22 Aug 2018 15:11:32 +0300 Subject: Rough same page anchors --- include/urweb/urweb_cpp.h | 1 + lib/js/urweb.js | 4 ++++ lib/ur/basis.urs | 1 + src/c/urweb.c | 4 ++++ src/settings.sml | 1 + 5 files changed, 11 insertions(+) (limited to 'lib/js/urweb.js') diff --git a/include/urweb/urweb_cpp.h b/include/urweb/urweb_cpp.h index 5f1144b8..1351cfbc 100644 --- a/include/urweb/urweb_cpp.h +++ b/include/urweb/urweb_cpp.h @@ -242,6 +242,7 @@ uw_Basis_string uw_Basis_blessEnvVar(struct uw_context *, uw_Basis_string); uw_Basis_string uw_Basis_blessMeta(struct uw_context *, uw_Basis_string); uw_Basis_string uw_Basis_checkUrl(struct uw_context *, uw_Basis_string); +uw_Basis_string uw_Basis_anchorUrl(struct uw_context *, uw_Basis_string); uw_Basis_string uw_Basis_checkMime(struct uw_context *, uw_Basis_string); uw_Basis_string uw_Basis_checkRequestHeader(struct uw_context *, uw_Basis_string); uw_Basis_string uw_Basis_checkResponseHeader(struct uw_context *, uw_Basis_string); diff --git a/lib/js/urweb.js b/lib/js/urweb.js index ff4c7b7e..cd1b7005 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -2278,5 +2278,9 @@ function giveFocus(id) { er("Tried to give focus to ID not used in document: " + id); } +function anchorUrl(id) { + return "#" + id; +} + // App-specific code diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index 3b67946f..a416ba48 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -803,6 +803,7 @@ type id val fresh : transaction id val giveFocus : id -> transaction unit val show_id : show id +val anchorUrl : id -> url val dyn : ctx ::: {Unit} -> use ::: {Type} -> bind ::: {Type} -> [ctx ~ [Dyn]] => unit -> tag [Signal = signal (xml ([Dyn] ++ ctx) use bind)] ([Dyn] ++ ctx) [] use bind diff --git a/src/c/urweb.c b/src/c/urweb.c index e7efae38..ce6f4dfb 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -4407,6 +4407,10 @@ uw_Basis_string uw_Basis_currentUrl(uw_context ctx) { return ctx->current_url; } +uw_Basis_string uw_Basis_anchorUrl(uw_context ctx, uw_Basis_string s) { + return uw_Basis_strcat(ctx, uw_Basis_strcat(ctx, ctx->current_url, "#"), s); +} + void uw_set_currentUrl(uw_context ctx, char *s) { ctx->current_url = s; } diff --git a/src/settings.sml b/src/settings.sml index cfbe98a5..c023a851 100644 --- a/src/settings.sml +++ b/src/settings.sml @@ -321,6 +321,7 @@ val jsFuncsBase = basisM [("alert", "alert"), ("ord", "ord"), ("checkUrl", "checkUrl"), + ("anchorUrl", "anchorUrl"), ("bless", "bless"), ("blessData", "blessData"), -- cgit v1.2.3 From 5eaaa94db962bbc3e42578bce3463ff2f942d602 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Fri, 12 Oct 2018 10:57:26 -0400 Subject: Catch when a cselect has an unavailable value set --- lib/js/urweb.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/js/urweb.js') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index ff4c7b7e..199f5001 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -1230,11 +1230,14 @@ function selectValue(x) { function setSelectValue(x, v) { for (var i = 0; i < x.options.length; ++i) { - if(x.options[i].value == v) { + if (x.options[i].value == v) { x.selectedIndex = i; return; } } + + if (v != "") + er("Setting " + content + ""; - var x = input(dummy.firstChild, s, function(x) { return function(v) { if (selectValue(x) != v) setSelectValue(x, v); }; }); + var x = dummy.firstChild; for (var i = 0; i < x.options.length; ++i) { if (x.options[i].value == "") x.options[i].value = x.options[i].text; @@ -1252,6 +1255,8 @@ function sel(s, content) { x.options[i].value = x.options[i].value.substring(1); } + x = input(x, s, function(x) { return function(v) { if (selectValue(x) != v) setSelectValue(x, v); }; }); + setSelectValue(x, s.data); if (selectValue(x) != s.data) sv(s, selectValue(x)); -- cgit v1.2.3 From 1a4a8b5ab8eb499ee2217c966f7fbb7716adf9e9 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Fri, 19 Oct 2018 16:03:57 -0400 Subject: Client-side escaping of HTML should be prepared for structured HTML trees, not just strings (closes #141) --- lib/js/urweb.js | 2 +- tests/a_case_of_the_splits.ur | 17 +++++++++++++++++ tests/a_case_of_the_splits.urp | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/a_case_of_the_splits.ur create mode 100644 tests/a_case_of_the_splits.urp (limited to 'lib/js/urweb.js') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 199f5001..bf20cfd4 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -1439,7 +1439,7 @@ function eh(x) { if (x == null) return "NULL"; else - return x.split("&").join("&").split("<").join("<").split(">").join(">"); + return flattenLocal(x).split("&").join("&").split("<").join("<").split(">").join(">"); } function ts(x) { return x.toString() } diff --git a/tests/a_case_of_the_splits.ur b/tests/a_case_of_the_splits.ur new file mode 100644 index 00000000..2029729e --- /dev/null +++ b/tests/a_case_of_the_splits.ur @@ -0,0 +1,17 @@ +fun newCounter () : transaction xbody = + x <- source 0; + return + {[n]}}/> + + +fun main () : transaction page = + ls <- source ([] : list xbody); + return + +