-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert_nt_string.html
65 lines (55 loc) · 1.61 KB
/
convert_nt_string.html
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Convert \n\t</title>
<style>
.item {
padding: 5px;
}
.item textarea {
font-size: 16px;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<div>
<div class="item">
<label for="input-g">convert \n\t</label>
<div>
<textarea name="str" id="input-g" cols="100" rows="30"></textarea>
</div>
</div>
<div class="item">
<button id="convert-btn">convert</button>
</div>
<div class="item hidden" id="result">
<label for="result-str">result</label>
<div>
<textarea name="" id="result-str" cols="230" rows="200"></textarea>
</div>
</div>
</div>
<script>
window.onload = function () {
var btn = document.getElementById("convert-btn");
btn.addEventListener("click", function () {
var inputG = document.getElementById("input-g");
var result = document.getElementById("result");
var resultText = document.getElementById("result-str");
var inputStr = inputG.value;
var res = convert(inputStr);
resultText.value = res;
result.style.display = "block";
});
}
function convert(inputStr) {
console.log(inputStr)
return inputStr.replace(/\\n/g, "\n").replace(/\\t/g, " ")
}
</script>
</body>
</html>