Skip to content

Commit b6aa2da

Browse files
committed
✨ Transpiled ES5 code to ES6/ES7
1 parent 38a8346 commit b6aa2da

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

index.js

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
const mouseUp = () => {
2-
let mark = document.getElementById('getm'),
3-
lineno = document.getElementById('lineno'),
4-
colno = document.getElementById('colno'),
5-
textLines = mark.value.substr(0, mark.selectionStart).split("\n");
6-
lineno.innerHTML = "Line " + textLines.length;
7-
colno.innerHTML = "Col " + textLines[textLines.length - 1].length;
2+
let mark = document.getElementById('getm');
3+
let lineno = document.getElementById('lineno');
4+
let colno = document.getElementById('colno');
5+
let textLines = mark.value.substr(0, mark.selectionStart).split("\n");
6+
lineno.innerHTML = `Line ${textLines.length}`;
7+
colno.innerHTML = `Col ${textLines[textLines.length - 1].length}`;
88
}
99
const keyUp = () => {
10-
let mark = document.getElementById('getm').value,
11-
viewer = document.getElementById('viewer'),
12-
wordcount = document.getElementById('wordcount'),
13-
charcount = document.getElementById('charcount'),
14-
save = document.getElementById('save'),
15-
regex = /\s+/gi;
10+
let mark = document.getElementById('getm').value;
11+
let viewer = document.getElementById('viewer');
12+
let wordcount = document.getElementById('wordcount');
13+
let charcount = document.getElementById('charcount');
14+
let save = document.getElementById('save');
15+
let regex = /\s+/gi;
1616
if (mark !== '') {
1717
viewer.innerHTML = marked(mark);
18-
let wordCount = viewer.innerText.trim().replace(regex, ' ').split(' ').length,
19-
charCount = viewer.innerText.replace(regex, '').length;
20-
wordcount.innerHTML = wordCount + " words";
21-
charcount.innerHTML = charCount + " chars";
18+
let wordCount = viewer.innerText.trim().replace(regex, ' ').split(' ').length;
19+
let charCount = viewer.innerText.replace(regex, '').length;
20+
wordcount.innerHTML = `${wordCount} words`;
21+
charcount.innerHTML = `${charCount} chars`;
2222
save.disabled = false;
2323
document.querySelectorAll('pre code').forEach((block) => {
2424
hljs.highlightBlock(block);
@@ -32,8 +32,10 @@ const keyUp = () => {
3232
}
3333
}
3434
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
35-
const switchTheme = (e) => {
36-
if (e.target.checked) {
35+
const switchTheme = ({
36+
target
37+
}) => {
38+
if (target.checked) {
3739
document.documentElement.setAttribute('data-theme', 'dark');
3840
} else {
3941
document.documentElement.setAttribute('data-theme', 'light');
@@ -55,8 +57,10 @@ const download = () => {
5557
anchor.click();
5658
document.body.removeChild(anchor);
5759
}
58-
let openFile = (e) => {
59-
let input = e.target;
60+
let openFile = ({
61+
target
62+
}) => {
63+
let input = target;
6064
let reader = new FileReader();
6165
reader.onload = () => {
6266
document.getElementById('getm').value = reader.result;
@@ -65,16 +69,20 @@ let openFile = (e) => {
6569
};
6670
reader.readAsText(input.files[0]);
6771
};
68-
document.onkeyup = (e) => {
69-
if (e.altKey && e.which == 79) {
72+
document.onkeyup = ({
73+
altKey,
74+
which
75+
}) => {
76+
if (altKey && which == 79) {
7077
document.getElementById("file").click();
71-
} else if (e.altKey && e.which == 83) {
78+
} else if (altKey && which == 83) {
7279
document.getElementById("save").click();
7380
}
7481
};
7582
const apply = (e) => {
76-
let myField = document.getElementById("getm"),
77-
myValueBefore, myValueAfter;
83+
let myField = document.getElementById("getm");
84+
let myValueBefore;
85+
let myValueAfter;
7886
switch (e) {
7987
case 'bold':
8088
myValueBefore = "**";
@@ -141,8 +149,8 @@ const apply = (e) => {
141149
myField.focus();
142150
document.selection.createRange().text = myValueBefore + document.selection.createRange().text + myValueAfter;
143151
} else if (myField.selectionStart || myField.selectionStart == '0') {
144-
let startPos = myField.selectionStart,
145-
endPos = myField.selectionEnd;
152+
let startPos = myField.selectionStart;
153+
let endPos = myField.selectionEnd;
146154
myField.value = myField.value.substring(0, startPos) + myValueBefore + myField.value.substring(startPos, endPos) + myValueAfter + myField.value.substring(endPos, myField.value.length);
147155
myField.selectionStart = startPos + myValueBefore.length;
148156
myField.selectionEnd = endPos + myValueBefore.length;

0 commit comments

Comments
 (0)