export class SovTools { static log(value) { try { console.log(value) ; } catch {} } static arrayRemove(arr, value) { return arr.filter(function(ele){ return ele != value; }); } static toPlainText(html) { let scratchDiv = document.createElement('div'); scratchDiv.innerHTML = html; return scratchDiv.textContent; } static getDateFormatted(date, separator) { if(date) { var date = new Date(date); var _d = date.getDate(), d = _d > 9 ? _d : '0' + _d, _m = date.getMonth() + 1, m = _m > 9 ? _m : '0' + _m, formatted = d + separator + m + separator + date.getFullYear(); return formatted; } else { return ''; } } static getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } } static indexOfFirstDigit(input) { let i = 0; for (; input[i] < '0' || input[i] > '9'; i++) ; return i == input.length ? -1 : i; } static indexOfLastDigit(input) { let i = input.length - 1; for (; input[i] < '0' || input[i] > '9'; i--) ; return i == input.length ? -1 : i; } static formatNumber(number, toFixed){ if(number)return Number(number.replace(',', '.')).toFixed(toFixed); else return null; } static formatNumberWithoutFixed(number){ if(typeof number == 'string')number = number.replace(',', '.'); if(number)return Number(number); else return null; } static getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } }; static readFlashMessages(flashMessages){ var currentFlash =new Array(); for (var type in flashMessages) { for (var key in flashMessages[type]) { if(!currentFlash.includes(flashMessages[type][key])) { currentFlash.push(flashMessages[type][key]); SovNotification.add(type, flashMessages[type][key]); } } } } }