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.

98 lines
3.0 KiB

  1. function noFormat() {
  2. let elements = [
  3. "remove_comments",
  4. "remove_lines",
  5. "remove_report",
  6. "check_alias",
  7. "sign_align_in",
  8. "sign_align_port",
  9. "sign_align_generic",
  10. "sign_align_function",
  11. "sign_align_procedure",
  12. "sign_align_all",
  13. "new_line_after",
  14. "use_space",
  15. "customise_indentation",
  16. "compress",
  17. "mix_letter",
  18. "cust_eol",
  19. "sign_align_mode",
  20. "keyword",
  21. "typename",
  22. "align_comments",
  23. "add_extraEOL"
  24. ];
  25. var isDisabled = getHTMLInputElement("no_format").checked;
  26. changeStateOfElements(elements, isDisabled);
  27. let radioButtons = document.getElementsByTagName("input");
  28. for (let i = 0; i < radioButtons.length; i++) {
  29. if (radioButtons[i].type == "radio") {
  30. radioButtons[i].disabled = isDisabled;
  31. }
  32. }
  33. }
  34. function changeStateOfElements(elements, isDisabled) {
  35. elements.forEach(element => {
  36. var htmlElement = getHTMLInputElement(element + "_div");
  37. try {
  38. getHTMLInputElement(element).disabled = isDisabled;
  39. }
  40. catch (_a) { }
  41. if (isDisabled) {
  42. htmlElement.className += " disabled";
  43. }
  44. else {
  45. htmlElement.className = htmlElement.className.replace(/\bdisabled\b/g, "");
  46. }
  47. });
  48. }
  49. function getHTMLInputElement(id) {
  50. return document.getElementById(id);
  51. }
  52. function Compress(input) {
  53. input = input.replace(/\r\n/g, '');
  54. input = input.replace(/[\t ]+/g, ' ');
  55. input = input.replace(/[ ]?([&=:\-<>\+|])[ ]?/g, '$1');
  56. return input;
  57. }
  58. function MixLetters(input) {
  59. let arr = input.split("");
  60. for (var k = 0; k < arr.length; k++) {
  61. if (arr[k] === arr[k].toUpperCase() && Math.random() > 0.5) {
  62. arr[k] = arr[k].toLowerCase();
  63. }
  64. else if (Math.random() > 0.5) {
  65. arr[k] = arr[k].toUpperCase();
  66. }
  67. }
  68. return arr.join("");
  69. }
  70. function wordWrap() {
  71. let d = getHTMLInputElement("result");
  72. if (d.className == "") {
  73. d.className = "wordwrap";
  74. }
  75. else {
  76. d.className = "";
  77. }
  78. }
  79. function alignAllSigns(alignAll) {
  80. if (alignAll) {
  81. getHTMLInputElement("sign_align_port").checked = false;
  82. getHTMLInputElement("sign_align_generic").checked = false;
  83. getHTMLInputElement("sign_align_procedure").checked = false;
  84. getHTMLInputElement("sign_align_function").checked = false;
  85. getHTMLInputElement("sign_align_mode_div").disabled = false;
  86. }
  87. else {
  88. getHTMLInputElement("sign_align_all").checked = false;
  89. }
  90. let isDisabled = !alignAll;
  91. changeStateOfElements(["sign_align_mode"], isDisabled);
  92. let radioButtons = document.querySelectorAll("#sign_align_mode_div input[type=radio]");
  93. for (let i = 0; i < radioButtons.length; i++) {
  94. if (radioButtons[i].type == "radio") {
  95. radioButtons[i].disabled = isDisabled;
  96. }
  97. }
  98. }
  99. //# sourceMappingURL=main.js.map