diff --git a/README.md b/README.md
index 0db6daf..56cb888 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,12 @@ VHDL formatter web online written in javascript
## Release Notes
+### 2.5 [2018-03-13]
+
+- keep the front page concise
+- add `style.css`
+- support all browsers (do not use `RegExp Lookbehind Assertions`)
+
### 2.4 [2018-02-23]
- use local storage to store settings
diff --git a/VHDLFormatter.js b/VHDLFormatter.js
index cde5b79..4c9b847 100644
--- a/VHDLFormatter.js
+++ b/VHDLFormatter.js
@@ -144,7 +144,7 @@ function SetNewLinesAfterSymbols(text, newLineSettings) {
var rexString = "(" + upper + ")[ ]?([^ \r\n@])";
let regex = null;
if (upper.regexStartsWith(/\w/)) {
- regex = new RegExp("(?
VHDL Beautifier, Formatter Online
-
+
@@ -557,8 +370,34 @@
hljs.highlightBlock(document.getElementById("vhdl"));
return;
}
- var remove_comments = document.getElementById("remove_comments").checked;
+
var remove_lines = document.getElementById("remove_lines").checked;
+ var mix_letter = document.getElementById("mix_letter").checked;
+ [beautifierSettings, compress] = CreateSettings();
+ vhdlSettings = new VhdlSettings(beautifierSettings, remove_lines, compress, mix_letter);
+ saveSetting(vhdlSettings);
+
+ input = beautify(input, beautifierSettings);
+
+ if (remove_lines) {
+ input = input.replace(/(\r\n)*[ \t]*\r\n/g, '\r\n');
+ }
+
+ if (compress) {
+ input = Compress(input);
+ }
+
+ if (mix_letter) {
+ input = MixLetters(input);
+ }
+
+ document.getElementById("vhdl").innerHTML = input;
+ document.querySelector(".show").style.display = "inline-block";
+ hljs.highlightBlock(document.getElementById("vhdl"));
+ }
+
+ function CreateSettings() {
+ var remove_comments = document.getElementById("remove_comments").checked;
var remove_report = document.getElementById("remove_report").checked;
var check_alias = document.getElementById("check_alias").checked;
var sign_align_port = document.getElementById("sign_align_port").checked;
@@ -576,8 +415,7 @@
var compress = document.getElementById("compress").checked;
var cust_indent = document.getElementById("customise_indentation").value;
var keywordcase = document.getElementById("keyword_div").elements.namedItem("keywordcase").value;
- var typenamecase = document.getElementById("typename_div").elements.namedItem("typenamecase").value;
- var mix_letter = document.getElementById("mix_letter").checked;
+ var typenamecase = document.getElementById("typename_div").elements.namedItem("typenamecase").value;
var endOfLine = document.getElementById("cust_eol").value;
endOfLine = endOfLine.replace(/\\r/g, "\r");
endOfLine = endOfLine.replace(/\\n/g, "\n");
@@ -625,26 +463,13 @@
newLineSettings,
endOfLine);
- vhdlSettings = new VhdlSettings(beautifierSettings, remove_lines, compress, mix_letter);
- saveSetting(vhdlSettings);
-
- input = beautify(input, beautifierSettings);
-
- if (remove_lines) {
- input = input.replace(/(\r\n)*[ \t]*\r\n/g, '\r\n');
- }
-
- if (compress) {
- input = Compress(input);
- }
-
- if (mix_letter) {
- input = MixLetters(input);
- }
+ return [beautifierSettings, compress];
+ }
- document.getElementById("vhdl").innerHTML = input;
- document.querySelector(".show").style.display = "inline-block";
- hljs.highlightBlock(document.getElementById("vhdl"));
+ function outputSetting() {
+ [beautifierSettings, compress] = CreateSettings();
+ var json = JSON.stringify(beautifierSettings, null, 4);
+ document.getElementById("vhdl").innerHTML = json;
}
function saveSetting(setting) {
@@ -679,6 +504,54 @@
this.mixLetter = mixLetter;
}
}
+
+ var warning = document.getElementById('warning');
+ var info = document.getElementById('info');
+ var happy = document.getElementById('happy');
+
+ var closeInfo = document.getElementById("close-info");
+ var closeWarning = document.getElementById("close-warning");
+ var closeHappy = document.getElementById("close-happy");
+
+ function showWarning() {
+ warning.style.display = "block";
+ }
+
+ function showInfo() {
+ info.style.display = "block";
+ }
+
+ function showHappy() {
+ happy.style.display = "block";
+ }
+
+ closeInfo.onclick = function() {
+ hidePopups();
+ }
+
+ closeWarning.onclick = function() {
+ hidePopups();
+ }
+
+ closeHappy.onclick = function(){
+ hidePopups();
+ }
+
+ function hidePopups() {
+ warning.style.display = "none";
+ info.style.display = "none";
+ happy.style.display = "none";
+ }
+
+ // When the user clicks anywhere outside of the modal, close it
+ window.onclick = function(event) {
+ var target = event.target;
+ if (target == warning
+ || target == info
+ || target == happy) {
+ hidePopups();
+ }
+ }