-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (46 loc) · 1.28 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function isCss(a) {
if (/\w+\s*?\{[\s\S]+?\}/.test(a) && !/<(style).*?>[\s\S]+?<\/\1>/.test(a)) {
return true
}
}
function isJs(a) {
if ((/function\s*?\w+\s*?\(.*?\)\s*?\{[\s\S]+?\}/.test(a) || /var\s*?\w+\s*?\=/.test(a)) && !/<(script).*?>[\s\S]+?<\/\1>/.test(a)) {
return true
}
}
function isHtml(a) {
if (/<(\w+).*?>[\s\S]+?<\/\1>/.test(a)) {
return true
}
}
function unminify() {
var a = document.getElementById('textarea').value;
if (isCss(a) && !isJs(a)) {
console.log('Css');
a = css_beautify(a)
} else if (isJs(a)) {
console.log('Js');
a = js_beautify(a)
} else if (isHtml(a)) {
console.log('Html');
a = html_beautify(a)
} else {
a = html_beautify(a)
}
document.getElementById('textarea').value = a;
document.querySelector('#textarea').style.color = "#34495e"
}
function copyUnminify() {
var a = document.querySelector('#textarea');
a.select();
try {
var b = document.execCommand('copy');
var c = b ? 'Success' : 'Unsuccess';
alert(c + '! Copied successfully. Please paste anywhere.')
} catch (err) {
alert('Oops, unable to copy !')
}
}
function eraseText() {
document.getElementById("textarea").value = ""
}