Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

helpers.js 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. const uid = function () {
  2. return Date.now().toString(36) + Math.random().toString(36).substr(2);
  3. }
  4. function loadScript(src) {
  5. return new Promise(function (resolve, reject) {
  6. var s;
  7. s = document.createElement('script');
  8. s.src = src;
  9. s.onload = resolve;
  10. s.onerror = reject;
  11. document.head.appendChild(s);
  12. });
  13. }
  14. function shuffleArray(array) {
  15. for (let i = array.length - 1; i > 0; i--) {
  16. const j = Math.floor(Math.random() * (i + 1));
  17. [array[i], array[j]] = [array[j], array[i]];
  18. }
  19. }
  20. function debounce(func, delay=500) {
  21. let timeoutId;
  22. return function(...args) {
  23. const context = this;
  24. clearTimeout(timeoutId);
  25. timeoutId = setTimeout(() => {
  26. func.apply(context, args);
  27. }, delay);
  28. };
  29. }
  30. function getCurrencySymbol(value = 0) {
  31. let type = 'INR'
  32. if (type) {
  33. const ans = new Intl.NumberFormat('en-IN', { style: 'currency', currency: type }).format(value);;
  34. const res = ans.split(/(\D+)/);
  35. const currencySymbol = res[1];
  36. const amount = res.slice(2, res.length).join('')
  37. return [currencySymbol, amount]
  38. } else {
  39. console.log("errrrrrrrrrrrrrrrrrrrrrrrrr", type);
  40. return ['', 0];
  41. }
  42. }
  43. function toasterHelper(type, message, align = 'toast-top-center') {
  44. // toasterOpts()
  45. debugger;
  46. toastr.clear()
  47. toasterOpts(align);
  48. Command: toastr[type](message);
  49. function toasterOpts(align) {
  50. toastr.options = {
  51. "closeButton": true,
  52. "debug": false,
  53. "newestOnTop": true,
  54. "progressBar": true,
  55. "positionClass": align,
  56. "preventDuplicates": true,
  57. "onclick": null,
  58. "showDuration": "300",
  59. "hideDuration": "1000",
  60. "timeOut": "5000",
  61. "extendedTimeOut": "1000",
  62. "showEasing": "swing",
  63. "hideEasing": "linear",
  64. "showMethod": "fadeIn",
  65. "hideMethod": "fadeOut"
  66. }
  67. }
  68. }
  69. async function getMulFileToGetBase64(event) {
  70. let files = event.target.files;
  71. let filePromise = [];
  72. for (let i = 0; i < files.length; i++) {
  73. let currFile = files[i];
  74. let currFilePromise = new Promise((resolve, reject) => {
  75. const reader = new FileReader();
  76. reader.readAsDataURL(currFile);
  77. // Wait till complete
  78. reader.onloadend = function () {
  79. let base64String = reader.result
  80. .toString()
  81. .replace(/^data:.+;base64,/, "");
  82. let fileReq = {
  83. FileData: base64String,
  84. FileName: currFile.name.split(".").slice(0, -1).join("."),
  85. FileType: currFile.name.split(".").pop(),
  86. RefId: 0,
  87. "ByteData": null,
  88. "FilePath": ""
  89. };
  90. resolve(fileReq);
  91. };
  92. // Make sure to handle error states
  93. reader.onerror = function (e) {
  94. reject(e);
  95. };
  96. });
  97. filePromise.push(currFilePromise)
  98. }
  99. return Promise.all(filePromise);
  100. }
  101. function containsSpecialCharsHelper(str) {
  102. const specialChars = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
  103. return specialChars.test(str);
  104. }
  105. const isUpperCaseHelper = (string) => /^(?=.*[A-Z])/.test(string);
  106. const isLowerCaseHelper = (string) => /^(?=.*[a-z])/.test(string);
  107. const isNumberContainsHelper = (string) => /\d/.test(string);
  108. function swapSectionsVideo(){
  109. function swapSections() {
  110. var sectionOne = document.querySelector('.section-one');
  111. var sectionTwo = document.querySelector('.section-two');
  112. let nextSibling = sectionOne.nextSibling;
  113. var isMobile = window.matchMedia("(max-width: 768px)").matches;
  114. if(!isMobile) return;
  115. if(nextSibling){
  116. sectionOne.insertAdjacentElement("beforeBegin",sectionTwo)
  117. }else{
  118. sectionOne.parentNode.insertBefore(sectionOne, sectionTwo);
  119. }
  120. // sectionOne.parentNode.insertBefore(sectionOne, sectionTwo);
  121. }
  122. swapSections();
  123. // Call the swapSections function on load and resize
  124. // window.addEventListener('load', swapSections);
  125. window.addEventListener('resize', swapSections);
  126. setTimeout(function (){
  127. document.querySelector('auth-loader').hide();
  128. $('.loading-main').removeClass('d-none');
  129. },1000);
  130. }