bruce-models 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4811,6 +4811,104 @@
4811
4811
  MathUtils.RandInt = RandInt;
4812
4812
  })(exports.MathUtils || (exports.MathUtils = {}));
4813
4813
 
4814
+ (function (UrlUtils) {
4815
+ function GetQueryString(doc) {
4816
+ var qs = {};
4817
+ var p0 = doc.location.href.indexOf("?");
4818
+ if (p0 >= 0) {
4819
+ var str = doc.location.href.substring(p0 + 1);
4820
+ var tokens = str.split("&");
4821
+ tokens.forEach(function (token) {
4822
+ var p = token.split("=");
4823
+ if (p.length == 2) {
4824
+ qs[p[0]] = p[1];
4825
+ }
4826
+ });
4827
+ }
4828
+ return qs;
4829
+ }
4830
+ UrlUtils.GetQueryString = GetQueryString;
4831
+ var Handler = /** @class */ (function () {
4832
+ function Handler(window, allowedKeys) {
4833
+ this._allowedKeys = null;
4834
+ this._window = window;
4835
+ this._allowedKeys = allowedKeys;
4836
+ }
4837
+ Object.defineProperty(Handler.prototype, "window", {
4838
+ get: function () {
4839
+ return this._window;
4840
+ },
4841
+ enumerable: false,
4842
+ configurable: true
4843
+ });
4844
+ Object.defineProperty(Handler.prototype, "document", {
4845
+ get: function () {
4846
+ var _a;
4847
+ return (_a = this.window) === null || _a === void 0 ? void 0 : _a.document;
4848
+ },
4849
+ enumerable: false,
4850
+ configurable: true
4851
+ });
4852
+ Object.defineProperty(Handler.prototype, "allowedKeys", {
4853
+ get: function () {
4854
+ return this._allowedKeys;
4855
+ },
4856
+ enumerable: false,
4857
+ configurable: true
4858
+ });
4859
+ Handler.prototype.UpdateAllowedKeys = function (allowedKeys) {
4860
+ this._allowedKeys = allowedKeys;
4861
+ var params = this.GetParams();
4862
+ this.refresh(params);
4863
+ };
4864
+ Handler.prototype.UpdateParam = function (key, value) {
4865
+ var params = this.GetParams();
4866
+ params[key + ""] = value + "";
4867
+ this.refresh(params);
4868
+ };
4869
+ Handler.prototype.RemoveParam = function (key) {
4870
+ var params = this.GetParams();
4871
+ params[key + ""] = null;
4872
+ this.refresh(params);
4873
+ };
4874
+ Handler.prototype.GetParamKeys = function () {
4875
+ var params = GetQueryString(this.document);
4876
+ return Object.keys(params);
4877
+ };
4878
+ Handler.prototype.GetParams = function () {
4879
+ return GetQueryString(this.document);
4880
+ };
4881
+ Handler.prototype.GetParam = function (key) {
4882
+ var params = this.GetParams();
4883
+ return params[key + ""];
4884
+ };
4885
+ Handler.prototype.Clear = function () {
4886
+ this.refresh({});
4887
+ };
4888
+ Handler.prototype.refresh = function (data) {
4889
+ var params = [];
4890
+ var keys = Object.keys(data);
4891
+ for (var i = 0; i < keys.length; i++) {
4892
+ var key = keys[i];
4893
+ if (this._allowedKeys == null || this._allowedKeys.includes(key)) {
4894
+ var val = data[key];
4895
+ if (!!val || val == 0) {
4896
+ params.push(key + "=" + val);
4897
+ }
4898
+ }
4899
+ }
4900
+ if (params.length > 0) {
4901
+ this.window.history.replaceState({}, null, "?" + params.join("&"));
4902
+ }
4903
+ else {
4904
+ this.window.history.replaceState({}, null, "");
4905
+ }
4906
+ };
4907
+ return Handler;
4908
+ }());
4909
+ UrlUtils.Handler = Handler;
4910
+ })(exports.UrlUtils || (exports.UrlUtils = {}));
4911
+
4814
4912
  exports.AbstractApi = AbstractApi;
4815
4913
  exports.BruceApi = BruceApi;
4816
4914
  exports.CamApi = CamApi;