update documentation

This commit is contained in:
Leon van Kammen 2023-03-09 22:39:59 +01:00
parent 5b296c5d22
commit 66fe5ee5a0
3 changed files with 34 additions and 2 deletions

View file

@ -1,8 +1,7 @@
-dce full -dce full
-cp src -cp src
xrfragment.Url xrfragment
xrfragment.Query
-D shallow-expose -D shallow-expose
-js dist/xrfragment.js -js dist/xrfragment.js

28
dist/xrfragment.js vendored
View file

@ -14,6 +14,10 @@ EReg.prototype = {
this.r.s = s; this.r.s = s;
return this.r.m != null; return this.r.m != null;
} }
,split: function(s) {
var d = "#__delim__#";
return s.replace(this.r,d).split(d);
}
}; };
var HxOverrides = function() { }; var HxOverrides = function() { };
HxOverrides.substr = function(s,pos,len) { HxOverrides.substr = function(s,pos,len) {
@ -72,6 +76,9 @@ Std.parseInt = function(x) {
} }
return null; return null;
}; };
var haxe_ds_StringMap = function() {
this.h = Object.create(null);
};
var haxe_iterators_ArrayIterator = function(array) { var haxe_iterators_ArrayIterator = function(array) {
this.current = 0; this.current = 0;
this.array = array; 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) { if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
HxOverrides.now = performance.now.bind(performance); HxOverrides.now = performance.now.bind(performance);
} }

View file

@ -1,9 +1,14 @@
package xrfragment; package xrfragment;
@:expose // <- makes the class reachable from plain JavaScript
@:keep // <- avoids accidental removal by dead code elimination
class Url { class Url {
@:keep
private static var map:Map<String, String>; private static var map:Map<String, String>;
@:keep
private static function parseQueryMap(qs:String):Map<String, String> { private static function parseQueryMap(qs:String):Map<String, String> {
var splitArray:Array<String> = qs.split('&'); var splitArray:Array<String> = qs.split('&');
var regexPlus = ~/\+/g; // Regex for replacing addition symbol with a space var regexPlus = ~/\+/g; // Regex for replacing addition symbol with a space