You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4KB

  1. function arrayRemove(arr, value) { return arr.filter(function(ele){ return ele != value; });}
  2. const scratchDiv = document.createElement('div');
  3. function toPlainText(html) {
  4. scratchDiv.innerHTML = html;
  5. return scratchDiv.textContent;
  6. }
  7. function getDateFormatted(date, separator) {
  8. if(date) {
  9. var date = new Date(date);
  10. var _d = date.getDate(),
  11. d = _d > 9 ? _d : '0' + _d,
  12. _m = date.getMonth() + 1,
  13. m = _m > 9 ? _m : '0' + _m,
  14. formatted = d + separator + m + separator + date.getFullYear();
  15. return formatted;
  16. }else{
  17. return '';
  18. }
  19. }
  20. var getUrlParameter = function getUrlParameter(sParam) {
  21. var sPageURL = window.location.search.substring(1),
  22. sURLVariables = sPageURL.split('&'),
  23. sParameterName,
  24. i;
  25. for (i = 0; i < sURLVariables.length; i++) {
  26. sParameterName = sURLVariables[i].split('=');
  27. if (sParameterName[0] === sParam) {
  28. return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
  29. }
  30. }
  31. };
  32. function indexOfFirstDigit(input) {
  33. let i = 0;
  34. for (; input[i] < '0' || input[i] > '9'; i++) ;
  35. return i == input.length ? -1 : i;
  36. }
  37. function indexOfLastDigit(input) {
  38. let i = input.length - 1;
  39. for (; input[i] < '0' || input[i] > '9'; i--) ;
  40. return i == input.length ? -1 : i;
  41. }