From 66fe5ee5a0cd210f97425c9ca6c3b28d4bc25f2d Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Thu, 9 Mar 2023 22:39:59 +0100 Subject: [PATCH] update documentation --- build.hxml | 3 +-- dist/xrfragment.js | 28 ++++++++++++++++++++++++++++ src/xrfragment/Url.hx | 5 +++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/build.hxml b/build.hxml index 9a54475..1397590 100644 --- a/build.hxml +++ b/build.hxml @@ -1,8 +1,7 @@ -dce full -cp src -xrfragment.Url -xrfragment.Query +xrfragment -D shallow-expose -js dist/xrfragment.js diff --git a/dist/xrfragment.js b/dist/xrfragment.js index 5e46f45..2506405 100644 --- a/dist/xrfragment.js +++ b/dist/xrfragment.js @@ -14,6 +14,10 @@ EReg.prototype = { this.r.s = s; return this.r.m != null; } + ,split: function(s) { + var d = "#__delim__#"; + return s.replace(this.r,d).split(d); + } }; var HxOverrides = function() { }; HxOverrides.substr = function(s,pos,len) { @@ -72,6 +76,9 @@ Std.parseInt = function(x) { } return null; }; +var haxe_ds_StringMap = function() { + this.h = Object.create(null); +}; var haxe_iterators_ArrayIterator = function(array) { this.current = 0; this.array = array; @@ -276,6 +283,27 @@ xrfragment_Query.prototype = { } } }; +var xrfragment_Url = $hx_exports["xrfragment"]["Url"] = function() { }; +xrfragment_Url.parseQueryMap = function(qs) { + var splitArray = qs.split("&"); + var regexPlus = new EReg("\\+","g"); + var resultMap = new haxe_ds_StringMap(); + var _g = 0; + var _g1 = splitArray.length; + while(_g < _g1) { + var i = _g++; + var splitByEqual = splitArray[i].split("="); + var key = splitByEqual[0]; + if(splitByEqual.length == 1) { + resultMap.h[key] = ""; + } else { + var s = regexPlus.split(splitByEqual[1]).join(" "); + var value = decodeURIComponent(s.split("+").join(" ")); + resultMap.h[key] = value; + } + } + return resultMap; +}; if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) { HxOverrides.now = performance.now.bind(performance); } diff --git a/src/xrfragment/Url.hx b/src/xrfragment/Url.hx index dd8c42a..61de6f0 100644 --- a/src/xrfragment/Url.hx +++ b/src/xrfragment/Url.hx @@ -1,9 +1,14 @@ package xrfragment; +@:expose // <- makes the class reachable from plain JavaScript +@:keep // <- avoids accidental removal by dead code elimination + class Url { + @:keep private static var map:Map; + @:keep private static function parseQueryMap(qs:String):Map { var splitArray:Array = qs.split('&'); var regexPlus = ~/\+/g; // Regex for replacing addition symbol with a space