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.

57 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. function log(msg) {
  21. try {
  22. console.log(msg);
  23. } catch (e) {
  24. }
  25. }
  26. var getUrlParameter = function getUrlParameter(sParam) {
  27. var sPageURL = window.location.search.substring(1),
  28. sURLVariables = sPageURL.split('&'),
  29. sParameterName,
  30. i;
  31. for (i = 0; i < sURLVariables.length; i++) {
  32. sParameterName = sURLVariables[i].split('=');
  33. if (sParameterName[0] === sParam) {
  34. return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
  35. }
  36. }
  37. };
  38. function indexOfFirstDigit(input) {
  39. let i = 0;
  40. for (; input[i] < '0' || input[i] > '9'; i++) ;
  41. return i == input.length ? -1 : i;
  42. }
  43. function indexOfLastDigit(input) {
  44. let i = input.length - 1;
  45. for (; input[i] < '0' || input[i] > '9'; i--) ;
  46. return i == input.length ? -1 : i;
  47. }