-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
30 lines (30 loc) · 989 Bytes
/
script.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
"use strict";
var $ = document.querySelector.bind(document);
var fieldInput;
var fieldOutput;
var fieldSearch;
var fieldReplace;
function replaceText(input, search, replace) {
var re = new RegExp(search, 'g');
return input.replace(re, replace);
}
function handleSubmit(event) {
event.preventDefault();
var input = fieldInput.value;
var search = fieldSearch.value;
var replace = fieldReplace.value;
fieldOutput.value = replaceText(input, search, replace);
}
document.addEventListener('DOMContentLoaded', function () {
var _a;
(_a = $('#ui')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', handleSubmit);
fieldInput = $('#input-text');
fieldOutput = $('#output-text');
fieldSearch = $('#search-string');
fieldReplace = $('#replace-string');
fieldInput.value =
fieldOutput.value =
fieldSearch.value =
fieldReplace.value =
'';
});