@bbn/bbn 2.0.228 → 2.0.230

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.
package/dist/env.d.ts CHANGED
@@ -6,6 +6,7 @@ declare const _default: {
6
6
  host: string;
7
7
  url: string;
8
8
  old_path: any;
9
+ getParameters: {};
9
10
  loading: boolean;
10
11
  _enumerated: any[];
11
12
  readonly isEnumerating: boolean;
package/dist/env.js CHANGED
@@ -10,6 +10,7 @@ export default {
10
10
  host: ((_b = globalThis.location) === null || _b === void 0 ? void 0 : _b.protocol) + '//' + ((_c = globalThis.location) === null || _c === void 0 ? void 0 : _c.hostname),
11
11
  url: (_d = globalThis.location) === null || _d === void 0 ? void 0 : _d.href,
12
12
  old_path: null,
13
+ getParameters: {},
13
14
  /* True when non asynchronous Ajax loads */
14
15
  loading: false,
15
16
  _enumerated: [],
@@ -21,4 +21,4 @@
21
21
  *
22
22
  * @returns {void}
23
23
  */
24
- export default function setNavigationVars(url: any, title: any, data?: any, repl?: boolean): void;
24
+ export default function setNavigationVars(url: string, title: string, data?: object | null, replace?: boolean): void;
@@ -24,13 +24,20 @@ import html2text from '../html/html2text.js';
24
24
  *
25
25
  * @returns {void}
26
26
  */
27
- export default function setNavigationVars(url, title, data = null, repl = false) {
27
+ export default function setNavigationVars(url, title, data = null, replace = false) {
28
28
  // Current path becomes old path
29
29
  bbn.env.old_path = bbn.env.path;
30
30
  // URL includes the domain
31
31
  bbn.env.url = ['https:/', 'http://'].includes(substr(url, 0, 7)) ? url : bbn.env.root + url;
32
32
  // Path does not
33
- bbn.env.path = substr(bbn.env.url, bbn.env.root.length);
33
+ const [path, getParams] = bbn.env.url.split('?');
34
+ const getParameters = getParams ? getParams.split('&').reduce((acc, param) => {
35
+ const [key, value] = param.split('=');
36
+ acc[key] = value;
37
+ return acc;
38
+ }, {}) : {};
39
+ bbn.env.getParameters = getParameters;
40
+ bbn.env.path = substr(path, bbn.env.root.length);
34
41
  // Params will include each part of the URL
35
42
  bbn.env.params = bbn.env.path.split('/').filter(v => v !== '');
36
43
  // Managing history
@@ -53,7 +60,7 @@ export default function setNavigationVars(url, title, data = null, repl = false)
53
60
  if (state.title && !title) {
54
61
  title = state.title;
55
62
  }
56
- repl = true;
63
+ replace = true;
57
64
  }
58
65
  // If no title the global title
59
66
  if (!title) {
@@ -64,7 +71,7 @@ export default function setNavigationVars(url, title, data = null, repl = false)
64
71
  title = html2text(title);
65
72
  }
66
73
  // Replacing state
67
- if (repl) {
74
+ if (replace) {
68
75
  obj.reload = true;
69
76
  h.replaceState(obj, title, bbn.env.url);
70
77
  }
package/dist/fn/init.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import substr from './string/substr.js';
2
- import each from './loop/each.js';
3
2
  import extend from './object/extend.js';
4
3
  import addColors from './style/addColors.js';
5
4
  import link from './ajax/link.js';
@@ -57,7 +56,6 @@ const onActivity = (e) => {
57
56
  */
58
57
  export default function init(cfg, force) {
59
58
  var _a, _b;
60
- let parts;
61
59
  if (!bbn.env.isInit) {
62
60
  bbn.env.root = ((_b = (_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.baseURI) === null || _b === void 0 ? void 0 : _b.length) ? globalThis.document.baseURI : bbn.env.host;
63
61
  if (bbn.env.root.length && substr(bbn.env.root, -1) !== "/") {
@@ -67,15 +65,16 @@ export default function init(cfg, force) {
67
65
  if (typeof cfg === "object") {
68
66
  extend(true, bbn, cfg);
69
67
  }
70
- bbn.env.path = substr(bbn.env.url, bbn.env.root.length);
71
- parts = bbn.env.path.split("/");
72
- //$.each(parts, function(i, v){
73
- each(parts, (v) => {
74
- v = decodeURI(v.trim());
75
- if (v !== "") {
76
- bbn.env.params.push(v);
77
- }
78
- });
68
+ const [path, getParams] = bbn.env.url.split('?');
69
+ const getParameters = getParams ? getParams.split('&').reduce((acc, param) => {
70
+ const [key, value] = param.split('=');
71
+ acc[key] = value;
72
+ return acc;
73
+ }, {}) : {};
74
+ bbn.env.getParameters = getParameters;
75
+ bbn.env.path = substr(path, bbn.env.root.length);
76
+ // Params will include each part of the URL
77
+ bbn.env.params = bbn.env.path.split('/').filter(v => v !== '');
79
78
  setupIntl();
80
79
  if (globalThis.document) {
81
80
  if (bbn.var.colors) {
@@ -152,9 +151,6 @@ export default function init(cfg, force) {
152
151
  bbn.env.isInit = true;
153
152
  document.dispatchEvent(new Event("bbninit"));
154
153
  }
155
- if (bbn.env.logging) {
156
- log("Logging in bbn is enabled");
157
- }
158
154
  }
159
155
  }
160
156
  ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.228",
3
+ "version": "2.0.230",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",