@osovitny/anatoly 3.17.2 → 3.17.3

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.
@@ -12,7 +12,7 @@ import { MSAL_GUARD_CONFIG, MsalGuard, MsalInterceptor, MSAL_INTERCEPTOR_CONFIG,
12
12
  import { BrowserUtils, EventType, InteractionStatus, InteractionType, InteractionRequiredAuthError, PromptValue, PublicClientApplication, LogLevel } from '@azure/msal-browser';
13
13
  import * as i1$2 from '@angular/common';
14
14
  import { LOCATION_INITIALIZED, DOCUMENT, CommonModule } from '@angular/common';
15
- import { isValid, format, formatDistance, formatDistanceToNow } from 'date-fns';
15
+ import { format, formatDistance, formatDistanceToNow } from 'date-fns';
16
16
  import { utcToZonedTime } from 'date-fns-tz';
17
17
  import enUS from 'date-fns/locale/en-US';
18
18
  import * as i1$3 from '@ngx-translate/core';
@@ -95,6 +95,11 @@ const ClientApps = AppCoreSettings?.clientApps;
95
95
  //ClientApp
96
96
  const AppName = document.getElementById('appName').getAttribute('data-appname');
97
97
  const AppSettings = getAppSettingsByName(AppName);
98
+ //DateFormats
99
+ const DateFormats = {
100
+ date: 'dd MMM yyyy',
101
+ dateTime: 'dd MMM yyyy HH:mm'
102
+ };
98
103
 
99
104
  /*
100
105
  <file>
@@ -191,7 +196,40 @@ class Convert {
191
196
  return Boolean(value);
192
197
  }
193
198
  }
194
- /* Date ---------------------------------------------------------------------BEGIN*/
199
+ }
200
+
201
+ /*
202
+ <file>
203
+ Project:
204
+ @osovitny/anatoly
205
+
206
+ Authors:
207
+ Vadim Osovitny vadim@osovitny.com
208
+ Anatoly Osovitny anatoly@osovitny.com
209
+
210
+ Created:
211
+ 09 Feb 2024
212
+
213
+ Source:
214
+ https://github.com/date-fns/date-fns/blob/main/src/toDate/index.ts
215
+
216
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
217
+ </file>
218
+ */
219
+ class DateConvert {
220
+ static toDate(argument) {
221
+ const argStr = Object.prototype.toString.call(argument);
222
+ if (argument instanceof Date || (typeof argument === "object" && argStr === "[object Date]")) {
223
+ return argument;
224
+ }
225
+ else if (typeof argument === "number" || argStr === "[object Number]" ||
226
+ typeof argument === "string" || argStr === "[object String]") {
227
+ return new Date(argument);
228
+ }
229
+ else {
230
+ return new Date(NaN);
231
+ }
232
+ }
195
233
  static localToUtcDate(value) {
196
234
  if (value) {
197
235
  return new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate());
@@ -216,14 +254,6 @@ class Convert {
216
254
  }
217
255
  return null;
218
256
  }
219
- static dateToString(date) {
220
- return date.getFullYear() +
221
- '-' + this.pad(date.getMonth() + 1) +
222
- '-' + this.pad(date.getDate()) +
223
- ' ' + this.pad(date.getHours()) +
224
- ':' + this.pad(date.getMinutes()) +
225
- ':' + this.pad(date.getSeconds());
226
- }
227
257
  }
228
258
 
229
259
  /*
@@ -1615,92 +1645,74 @@ class Subs {
1615
1645
  Anatoly Osovitny anatoly@osovitny.com
1616
1646
 
1617
1647
  Created:
1618
- 19 March 2020
1648
+ 09 Feb 2024
1649
+
1650
+ Sources:
1651
+ https://github.com/date-fns/date-fns/blob/main/src/isDate/index.ts
1652
+ https://github.com/date-fns/date-fns/blob/main/src/isValid/index.ts
1619
1653
 
1620
1654
  Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1621
1655
  </file>
1622
1656
  */
1623
- class Utils {
1624
- static idExistsInQS() {
1625
- let id = Utils.getValueByNameInQS("id");
1626
- if (id)
1627
- return true;
1628
- return false;
1629
- }
1630
- static getValueByNameInQS(name) {
1631
- return Utils.getValueByName(location.search, name);
1632
- }
1633
- static getValueByName(url, name) {
1634
- name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
1635
- // tslint:disable-next-line:one-variable-per-declaration
1636
- const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), results = regex.exec(url);
1637
- return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
1657
+ class is {
1658
+ /**
1659
+ * @name isDate
1660
+ * @summary Is the given value a date?
1661
+ */
1662
+ static date(value) {
1663
+ return (value instanceof Date ||
1664
+ (typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"));
1638
1665
  }
1639
- static copyToClipBoard(event, val) {
1640
- event.preventDefault();
1641
- const selBox = document.createElement('textarea');
1642
- selBox.style.position = 'fixed';
1643
- selBox.style.left = '0';
1644
- selBox.style.top = '0';
1645
- selBox.style.opacity = '0';
1646
- selBox.value = val;
1647
- document.body.appendChild(selBox);
1648
- selBox.focus();
1649
- selBox.select();
1650
- document.execCommand('copy');
1651
- document.body.removeChild(selBox);
1666
+ /**
1667
+ * @name isDateValid
1668
+ * @summary Is the given date valid?
1669
+ */
1670
+ static dateValid(date) {
1671
+ if (!is.date(date) && typeof date !== "number") {
1672
+ return false;
1673
+ }
1674
+ let d = new Date(date);
1675
+ return !isNaN(Number(d));
1652
1676
  }
1653
- static downloadFile(name, url) {
1654
- const link = document.createElement('a');
1655
- link.download = name;
1656
- link.href = url;
1657
- link.click();
1677
+ static dateInvalid(date) {
1678
+ return !is.dateValid(date);
1658
1679
  }
1659
- static downloadBlobFile(value, fileName) {
1660
- const nav = window.navigator;
1661
- if (nav.msSaveOrOpenBlob) {
1662
- nav.msSaveOrOpenBlob(value, fileName);
1663
- }
1664
- else {
1665
- const downloadURL = window.URL.createObjectURL(value);
1666
- Utils.downloadFile(fileName, downloadURL);
1667
- }
1680
+ static string(value) {
1681
+ return (typeof value === 'string' || value instanceof String);
1668
1682
  }
1669
- /*
1670
- Author:
1671
- https://medium.com/@mhagemann/the-ultimate-way-to-slugify-a-url-string-in-javascript-b8e4a0d849e1
1672
- */
1673
- static slugify(text, prefix = '', postfix = '') {
1674
- const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;';
1675
- const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------';
1676
- const p = new RegExp(a.split('').join('|'), 'g');
1677
- /*
1678
- https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
1679
- https://stackoverflow.com/questions/822452/strip-html-from-text-javascript
1680
- */
1681
- text = text.replace(/(<([^>]+)>)/gi, '');
1682
- let result = text
1683
- .toString()
1684
- .toLowerCase()
1685
- .replace(/\s+/g, '-') // Replace spaces with -
1686
- .replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
1687
- .replace(/&/g, '-and-') // Replace & with 'and'
1688
- .replace(/[^\w\-]+/g, '') // Remove all non-word characters
1689
- .replace(/\-\-+/g, '-') // Replace multiple - with single -
1690
- .replace(/^-+/, '') // Trim - from start of text
1691
- .replace(/-+$/, ''); // Trim - from end of text
1692
- return prefix + result + postfix;
1683
+ static number(value) {
1684
+ return (typeof value === 'number');
1693
1685
  }
1694
- static generateRandom(start, end) {
1695
- return Math.floor(Math.random() * (end - start + 1)) + start;
1686
+ static boolean(value) {
1687
+ return (typeof value === 'boolean');
1696
1688
  }
1697
- static isObjectNullOrEmpty(obj) {
1689
+ static objectNullOrEmpty(obj) {
1698
1690
  return !obj || Object.keys(obj).length == 0;
1699
1691
  }
1700
- static isString(value) {
1701
- return typeof value === 'string' || value instanceof String;
1702
- }
1703
1692
  }
1693
+ /*
1694
+
1695
+ is = {
1696
+ DONE string: function (obj) { return (typeof obj === 'string'); },
1697
+ DONE number: function (obj) { return (typeof obj === 'number'); },
1698
+ DONE bool: function (obj) { return (typeof obj === 'boolean'); },
1699
+ array: function (obj) { return (obj instanceof Array); },
1700
+ undefined: function (obj) { return (typeof obj === 'undefined'); },
1701
+ 'null': function (obj) { return (obj === null); },
1702
+ notNull: function (obj) { return (obj !== null); },
1703
+ invalid: function (obj) { return (is['null'](obj) || is.undefined(obj)); },
1704
+ valid: function (obj) { return (!is['null'](obj) && !is.undefined(obj)); },
1705
+ emptyString: function (obj) { return (is.string(obj) && (obj.length == 0)); },
1706
+ nonEmptyString: function (obj) { return (is.string(obj) && (obj.length > 0)); },
1707
+ emptyArray: function (obj) { return (is.array(obj) && (obj.length == 0)); },
1708
+ nonEmptyArray: function (obj) { return (is.array(obj) && (obj.length > 0)); },
1709
+ document: function (obj) { return (obj === document); },
1710
+ window: function (obj) { return (obj === window); },
1711
+ element: function (obj) { return (obj instanceof HTMLElement); },
1712
+ event: function (obj) { return (obj instanceof Event); },
1713
+ link: function (obj) { return (is.element(obj) && (obj.tagName == 'A')); }
1714
+ };
1715
+ */
1704
1716
 
1705
1717
  /*
1706
1718
  <file>
@@ -1714,6 +1726,10 @@ class Utils {
1714
1726
  Created:
1715
1727
  05 May 2020
1716
1728
 
1729
+ Source:
1730
+ https://date-fns.org/v3.3.1/docs/formatDistance
1731
+ https://date-fns.org/v3.3.1/docs/formatDistanceToNow
1732
+
1717
1733
  Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1718
1734
  </file>
1719
1735
  */
@@ -1778,7 +1794,7 @@ class LocalizationService {
1778
1794
  }
1779
1795
  return dfnLocale;
1780
1796
  }
1781
- //getLocalized...
1797
+ //getLocalized
1782
1798
  getLocalizedValue(key, params) {
1783
1799
  const value = this.translate.instant(key);
1784
1800
  if (!params || params.length === 0) {
@@ -1786,91 +1802,36 @@ class LocalizationService {
1786
1802
  }
1787
1803
  return this.format(value, params);
1788
1804
  }
1789
- getLocalizedDate(key) {
1790
- let date = new Date(key);
1791
- if (isValid(date)) {
1792
- let localDate = Convert.utcToLocalDate(date);
1793
- return format(localDate, 'dd MMM yyyy', this.dateFnsLocale);
1805
+ getLocalizedDate(value) {
1806
+ let date = DateConvert.toDate(value);
1807
+ if (is.dateInvalid(date)) {
1808
+ return "Invalid Date";
1794
1809
  }
1795
- return "Invalid Date";
1810
+ return format(date, DateFormats.date, this.dateFnsLocale);
1796
1811
  }
1797
- getLocalizedDateTime(key) {
1798
- let date = new Date(key);
1799
- if (isValid(date)) {
1800
- let localDate = Convert.utcToLocalDateTime(date);
1801
- return format(localDate, 'dd MMM yyyy HH:mm', this.dateFnsLocale);
1812
+ getLocalizedDateTime(value) {
1813
+ let date = DateConvert.toDate(value);
1814
+ if (is.dateInvalid(date)) {
1815
+ return "Invalid Date";
1802
1816
  }
1803
- return "Invalid Date";
1817
+ return format(date, DateFormats.dateTime, this.dateFnsLocale);
1804
1818
  }
1805
- getLocalizedDistanceInWords(endedDate, startedDate) {
1806
- if (isValid(new Date(endedDate)) && isValid(new Date(startedDate))) {
1807
- return formatDistance(new Date(endedDate), new Date(startedDate), this.dateFnsLocale);
1808
- }
1809
- return "Invalid Date";
1819
+ //UTC ---------------------------------------------------------------------BEGIN
1820
+ getUTCToLocalizedDate(value) {
1821
+ return this.safeUtcToZonedTime(value, DateFormats.date);
1810
1822
  }
1811
- getLocalizedDistanceToNowInWords(date) {
1812
- if (isValid(new Date(date))) {
1813
- return formatDistanceToNow(new Date(date), this.dateFnsLocale);
1814
- }
1815
- return "Invalid Date";
1823
+ getUTCToLocalizedDateTime(value) {
1824
+ return this.safeUtcToZonedTime(value, DateFormats.dateTime);
1816
1825
  }
1817
- //UTC Operations --------------------------------------------------------------
1818
- getUTCToLocalizedDate(key) {
1819
- if (!Utils.isString(key)) {
1820
- key = key.toString();
1821
- }
1822
- if (key) {
1823
- if (key.indexOf("T") == -1) {
1824
- key = key.replace(" ", "T");
1825
- }
1826
- if (key.indexOf("Z") == -1) {
1827
- key = key + "Z";
1828
- }
1829
- }
1830
- let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1831
- if (browserTimeZone) {
1832
- let localDateTime = utcToZonedTime(key, browserTimeZone);
1833
- return format(localDateTime, 'dd.MM.yyyy', this.dateFnsLocale);
1834
- }
1835
- else {
1836
- return format(new Date(key), 'dd.MM.yyyy', this.dateFnsLocale);
1837
- }
1838
- }
1839
- getUTCToLocalizedDateTime(key) {
1840
- if (!Utils.isString(key)) {
1841
- key = key.toString();
1842
- }
1843
- if (key) {
1844
- if (key.indexOf("T") == -1) {
1845
- key = key.replace(" ", "T");
1846
- }
1847
- if (key.indexOf("Z") == -1) {
1848
- key = key + "Z";
1849
- }
1850
- }
1851
- let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1852
- if (browserTimeZone) {
1853
- let localDateTime = utcToZonedTime(key, browserTimeZone);
1854
- return format(localDateTime, 'dd.MM.yyyy HH:mm', this.dateFnsLocale);
1855
- }
1856
- else {
1857
- return format(new Date(key), 'dd.MM.yyyy HH:mm', this.dateFnsLocale);
1858
- }
1859
- }
1860
- //https://date-fns.org/v1.30.1/docs/distanceInWords
1861
- getUTCToLocalizedDistanceToNowInWords(date) {
1862
- date = this.safeUtcToZonedTime(date);
1863
- if (isValid(new Date(date))) {
1864
- return formatDistanceToNow(new Date(date), this.dateFnsLocale);
1826
+ safeUtcToZonedTime(date, conversionFormat = null) {
1827
+ if (!date) {
1828
+ return null;
1865
1829
  }
1866
- return "Invalid Date";
1867
- }
1868
- safeUtcToZonedTime(date) {
1869
1830
  let result = date;
1870
1831
  try {
1871
- if (date) {
1872
- if (date.indexOf("T") == -1) {
1873
- date = date.replace(" ", "T");
1832
+ if (typeof date === 'string') {
1833
+ if (date.indexOf("T") > -1) {
1834
+ date = date.replace("T", " ");
1874
1835
  }
1875
1836
  if (date.indexOf("Z") == -1) {
1876
1837
  date = date + "Z";
@@ -1878,19 +1839,45 @@ class LocalizationService {
1878
1839
  }
1879
1840
  let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1880
1841
  if (browserTimeZone) {
1881
- result = utcToZonedTime(date, browserTimeZone).toString();
1842
+ if (conversionFormat) {
1843
+ result = utcToZonedTime(date, browserTimeZone);
1844
+ result = format(result, conversionFormat, this.dateFnsLocale);
1845
+ }
1846
+ else {
1847
+ result = utcToZonedTime(date, browserTimeZone).toString();
1848
+ }
1882
1849
  }
1883
1850
  else {
1884
- result = new Date(date).toString();
1851
+ if (conversionFormat) {
1852
+ result = format(new Date(date), conversionFormat, this.dateFnsLocale);
1853
+ }
1854
+ else {
1855
+ result = new Date(date).toString();
1856
+ }
1885
1857
  }
1886
1858
  }
1887
1859
  catch {
1888
- if (date) {
1889
- console.log("UTC to Local conversion failed for :" + date.toString());
1890
- }
1860
+ result = "Invalid Date";
1891
1861
  }
1892
1862
  return result;
1893
1863
  }
1864
+ //UTC ---------------------------------------------------------------------END
1865
+ //Distance ----------------------------------------------------------------BEGIN
1866
+ getLocalizedDistanceInWords(endedDateStr, startedDateStr) {
1867
+ let endedDate = DateConvert.toDate(endedDateStr);
1868
+ let startedDate = DateConvert.toDate(startedDateStr);
1869
+ if (is.dateInvalid(endedDate) || is.dateInvalid(startedDate)) {
1870
+ return "Invalid Date";
1871
+ }
1872
+ return formatDistance(endedDate, startedDate, this.dateFnsLocale);
1873
+ }
1874
+ getLocalizedDistanceToNowInWords(value) {
1875
+ let date = DateConvert.toDate(value);
1876
+ if (is.dateInvalid(date)) {
1877
+ return "Invalid Date";
1878
+ }
1879
+ return formatDistanceToNow(date, this.dateFnsLocale);
1880
+ }
1894
1881
  static { this.ɵfac = function LocalizationService_Factory(t) { return new (t || LocalizationService)(i0.ɵɵinject(i1$3.TranslateService)); }; }
1895
1882
  static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LocalizationService, factory: LocalizationService.ɵfac, providedIn: 'root' }); }
1896
1883
  }
@@ -1942,6 +1929,17 @@ class LocalizePipe {
1942
1929
  if (type === 'dt') {
1943
1930
  return this.localizeService.getLocalizedDateTime(inputData);
1944
1931
  }
1932
+ //UTC ---------------------------------------------------------------------BEGIN
1933
+ //Date
1934
+ if (type === 'utc2d') {
1935
+ return this.localizeService.getUTCToLocalizedDate(inputData);
1936
+ }
1937
+ //DateTime
1938
+ if (type === 'utc2dt') {
1939
+ return this.localizeService.getUTCToLocalizedDateTime(inputData);
1940
+ }
1941
+ //UTC ---------------------------------------------------------------------END
1942
+ //Distance ----------------------------------------------------------------BEGIN
1945
1943
  //DistanceInWords
1946
1944
  if (type === 'dis') {
1947
1945
  return this.localizeService.getLocalizedDistanceInWords(inputData, param2);
@@ -1950,19 +1948,7 @@ class LocalizePipe {
1950
1948
  if (type === 'dis2now') {
1951
1949
  return this.localizeService.getLocalizedDistanceToNowInWords(inputData);
1952
1950
  }
1953
- //UTC Operations --------------------------------------------------------------
1954
- //UTC Date
1955
- if (type === 'utcd') {
1956
- return this.localizeService.getUTCToLocalizedDate(inputData);
1957
- }
1958
- //UTC DateTime
1959
- if (type === 'utcdt') {
1960
- return this.localizeService.getUTCToLocalizedDateTime(inputData);
1961
- }
1962
- //UTC DistanceToNowInWords
1963
- if (type === 'utcdis2now') {
1964
- return this.localizeService.getUTCToLocalizedDistanceToNowInWords(inputData);
1965
- }
1951
+ //Distance ----------------------------------------------------------------END
1966
1952
  return inputData;
1967
1953
  }
1968
1954
  static { this.ɵfac = function LocalizePipe_Factory(t) { return new (t || LocalizePipe)(i0.ɵɵdirectiveInject(LocalizationService, 16)); }; }
@@ -2648,7 +2634,7 @@ class StarterServiceBase extends ApiServiceBase {
2648
2634
  }
2649
2635
  applicationStarting() {
2650
2636
  let context = this.appContext.current;
2651
- if (!Utils.isObjectNullOrEmpty(context)) {
2637
+ if (!is.objectNullOrEmpty(context)) {
2652
2638
  this.appContext.init(context);
2653
2639
  return of(context);
2654
2640
  }
@@ -2901,6 +2887,97 @@ class Guid {
2901
2887
  }
2902
2888
  }
2903
2889
 
2890
+ /*
2891
+ <file>
2892
+ Project:
2893
+ @osovitny/anatoly
2894
+
2895
+ Authors:
2896
+ Vadim Osovitny vadim@osovitny.com
2897
+ Anatoly Osovitny anatoly@osovitny.com
2898
+
2899
+ Created:
2900
+ 19 March 2020
2901
+
2902
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
2903
+ </file>
2904
+ */
2905
+ class Utils {
2906
+ static idExistsInQS() {
2907
+ let id = Utils.getValueByNameInQS("id");
2908
+ if (id)
2909
+ return true;
2910
+ return false;
2911
+ }
2912
+ static getValueByNameInQS(name) {
2913
+ return Utils.getValueByName(location.search, name);
2914
+ }
2915
+ static getValueByName(url, name) {
2916
+ name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
2917
+ // tslint:disable-next-line:one-variable-per-declaration
2918
+ const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), results = regex.exec(url);
2919
+ return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
2920
+ }
2921
+ static copyToClipBoard(event, val) {
2922
+ event.preventDefault();
2923
+ const selBox = document.createElement('textarea');
2924
+ selBox.style.position = 'fixed';
2925
+ selBox.style.left = '0';
2926
+ selBox.style.top = '0';
2927
+ selBox.style.opacity = '0';
2928
+ selBox.value = val;
2929
+ document.body.appendChild(selBox);
2930
+ selBox.focus();
2931
+ selBox.select();
2932
+ document.execCommand('copy');
2933
+ document.body.removeChild(selBox);
2934
+ }
2935
+ static downloadFile(name, url) {
2936
+ const link = document.createElement('a');
2937
+ link.download = name;
2938
+ link.href = url;
2939
+ link.click();
2940
+ }
2941
+ static downloadBlobFile(value, fileName) {
2942
+ const nav = window.navigator;
2943
+ if (nav.msSaveOrOpenBlob) {
2944
+ nav.msSaveOrOpenBlob(value, fileName);
2945
+ }
2946
+ else {
2947
+ const downloadURL = window.URL.createObjectURL(value);
2948
+ Utils.downloadFile(fileName, downloadURL);
2949
+ }
2950
+ }
2951
+ /*
2952
+ Author:
2953
+ https://medium.com/@mhagemann/the-ultimate-way-to-slugify-a-url-string-in-javascript-b8e4a0d849e1
2954
+ */
2955
+ static slugify(text, prefix = '', postfix = '') {
2956
+ const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;';
2957
+ const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------';
2958
+ const p = new RegExp(a.split('').join('|'), 'g');
2959
+ /*
2960
+ https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
2961
+ https://stackoverflow.com/questions/822452/strip-html-from-text-javascript
2962
+ */
2963
+ text = text.replace(/(<([^>]+)>)/gi, '');
2964
+ let result = text
2965
+ .toString()
2966
+ .toLowerCase()
2967
+ .replace(/\s+/g, '-') // Replace spaces with -
2968
+ .replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
2969
+ .replace(/&/g, '-and-') // Replace & with 'and'
2970
+ .replace(/[^\w\-]+/g, '') // Remove all non-word characters
2971
+ .replace(/\-\-+/g, '-') // Replace multiple - with single -
2972
+ .replace(/^-+/, '') // Trim - from start of text
2973
+ .replace(/-+$/, ''); // Trim - from end of text
2974
+ return prefix + result + postfix;
2975
+ }
2976
+ static generateRandom(start, end) {
2977
+ return Math.floor(Math.random() * (end - start + 1)) + start;
2978
+ }
2979
+ }
2980
+
2904
2981
  /*
2905
2982
  <file>
2906
2983
  Project:
@@ -7355,5 +7432,5 @@ class AnatolyModule {
7355
7432
  * Generated bundle index. Do not edit.
7356
7433
  */
7357
7434
 
7358
- export { AddressComponent, AdminGuard, Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyIAMModule, AnatolyIAMPagesModule, AnatolyModule, AnatolyUIModule, ApiServiceBase, ApiUrl, AppContextService, AppCoreSettings, AppName, AppSettings, AppVersion, AuthService, AuthenticationGuard, BaseGoService, Browser, BuyAccessButtonComponent, CardBodyComponent, CardComponent, CardFooterComponent, CardHeaderComponent, CheckIconComponent, ClientApps, CompanyComponent, ComponentBase, ContactUsDialog, ContactUsForm, Convert, Copy2ClipboardComponent, CoreApiService, CountryDropdownlist, DOM, DataPagerComponent, DefaultEditorOptions, DialogBase, DigitalMarketingService, EditComponentBase, EditPageBase, EmailsApiService, EnumEditComponentBase, FileSizePipe, FormValidationSummaryComponent, FormsHtmlEditorComponent, GlobalErrorHandler, GoogleAnalyticsService, GridEditServiceBase, GridReadServiceBase, Guid, HoveringDirective, HtmlEditorComponent, HtmlEditorComponentBase, IdleService, InjectorInstance, ItemValidationSummaryComponent, L10NUrl, ListBase, LoadingComponent, LoadingService, LocalStorageService, LocalizationInjectorInstance, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, MSALUtils, NativeElementDirective, NodataComponent, NotificationService, PageBase, PageSpinnerComponent, PagedPageBase, ReplaceTextPipe, SafeHtmlPipe, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, StarterServiceBase, Stopwatch, Subs, SubscribePlanButtonComponent, TimezoneDropdownlist, UrlSlugComponent, Utils, ValidationSummaryComponent, XmlFormatter, getAppSettingsById, getAppSettingsByName, localizationInitializerFactory, throwIfAlreadyLoaded, translateLoaderFactory };
7435
+ export { AddressComponent, AdminGuard, Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyIAMModule, AnatolyIAMPagesModule, AnatolyModule, AnatolyUIModule, ApiServiceBase, ApiUrl, AppContextService, AppCoreSettings, AppName, AppSettings, AppVersion, AuthService, AuthenticationGuard, BaseGoService, Browser, BuyAccessButtonComponent, CardBodyComponent, CardComponent, CardFooterComponent, CardHeaderComponent, CheckIconComponent, ClientApps, CompanyComponent, ComponentBase, ContactUsDialog, ContactUsForm, Convert, Copy2ClipboardComponent, CoreApiService, CountryDropdownlist, DOM, DataPagerComponent, DateConvert, DateFormats, DefaultEditorOptions, DialogBase, DigitalMarketingService, EditComponentBase, EditPageBase, EmailsApiService, EnumEditComponentBase, FileSizePipe, FormValidationSummaryComponent, FormsHtmlEditorComponent, GlobalErrorHandler, GoogleAnalyticsService, GridEditServiceBase, GridReadServiceBase, Guid, HoveringDirective, HtmlEditorComponent, HtmlEditorComponentBase, IdleService, InjectorInstance, ItemValidationSummaryComponent, L10NUrl, ListBase, LoadingComponent, LoadingService, LocalStorageService, LocalizationInjectorInstance, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, MSALUtils, NativeElementDirective, NodataComponent, NotificationService, PageBase, PageSpinnerComponent, PagedPageBase, ReplaceTextPipe, SafeHtmlPipe, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, StarterServiceBase, Stopwatch, Subs, SubscribePlanButtonComponent, TimezoneDropdownlist, UrlSlugComponent, Utils, ValidationSummaryComponent, XmlFormatter, getAppSettingsById, getAppSettingsByName, is, localizationInitializerFactory, throwIfAlreadyLoaded, translateLoaderFactory };
7359
7436
  //# sourceMappingURL=osovitny-anatoly.mjs.map