-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (27 loc) · 943 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// AnyMini script start form here
var notMini = document.querySelector(".notMini"),
mini = document.querySelector(".mini"),
result = '';
var minify = function() {
if (notMini.value) {
var singleMultiCmnt = /(\/\/.{0,})|(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)/g;
var singleCmntRmv = notMini.value.replace(singleMultiCmnt, "");
var whiteSpace = singleCmntRmv.replace(/\n/g, "");
var extraSpace = whiteSpace.replace(/\s{2,3}/g, "");
result = extraSpace.replace(/\s{0,}=\s{0,}/g, "=");
mini.value = result;
} else {
alert("No Input Detected. Write Something!!");
notMini.focus();
}
};
notMini.addEventListener("keydown", function(e) {
mini.value = "typing...";
});
notMini.addEventListener("keyup", function(e) {
mini.value = "";
});
mini.onclick = function() {
this.setSelectionRange(0, this.value.length);
};
// AnyMini script ends here