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.

74 lines
2.1 KiB

  1. function noFormat() {
  2. let elements: Array<string> = [
  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. ];
  23. var isDisabled = getHTMLInputElement("no_format").checked;
  24. elements.forEach(element => {
  25. var htmlElement = getHTMLInputElement(element + "_div");
  26. try {
  27. getHTMLInputElement(element).disabled = isDisabled;
  28. }
  29. catch{ }
  30. if (isDisabled) {
  31. htmlElement.className += " disabled";
  32. }
  33. else {
  34. htmlElement.className = htmlElement.className.replace(/\bdisabled\b/g, "");
  35. }
  36. });
  37. let radioButtons = <HTMLCollectionOf<HTMLInputElement>>document.getElementsByTagName("input");
  38. for (let i = 0; i < radioButtons.length; i++) {
  39. if ((<HTMLInputElement>radioButtons[i]).type == "radio") {
  40. (<HTMLInputElement>radioButtons[i]).disabled = isDisabled;
  41. }
  42. }
  43. }
  44. function getHTMLInputElement(id: string): HTMLInputElement {
  45. return <HTMLInputElement>document.getElementById(id);
  46. }
  47. function Compress(input: string) {
  48. input = input.replace(/\r\n/g, '');
  49. input = input.replace(/[\t ]+/g, ' ');
  50. input = input.replace(/[ ]?([&=:\-<>\+|])[ ]?/g, '$1');
  51. return input;
  52. }
  53. function MixLetters(input: string) {
  54. let arr = input.split("");
  55. for (var k = 0; k < arr.length; k++) {
  56. if (arr[k] === arr[k].toUpperCase() && Math.random() > 0.5) {
  57. arr[k] = arr[k].toLowerCase();
  58. } else if (Math.random() > 0.5) {
  59. arr[k] = arr[k].toUpperCase();
  60. }
  61. }
  62. return arr.join("");
  63. }
  64. function wordWrap() {
  65. var d = document.getElementById("result");
  66. if (d.className == "") {
  67. d.className = "wordwrap";
  68. } else {
  69. d.className = "";
  70. }
  71. }