-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupper-lower.html
88 lines (79 loc) · 2.83 KB
/
upper-lower.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bower/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="bower/font-awesome/css/font-awesome.min.css" />
<title>Convert Upper / Lower</title>
</head>
<body>
<div class="container">
<h2>
<i class="fa fa-pencil-square-o" aria-hidden="true"></i> Convert Upper / Lower
<a href="index.html" class="btn btn-default">
<i class="fa fa-fa-reply" aria-hidden="true"></i> Back to Menu
</a>
</h2>
<div class="row">
<div class="col-xs-12" style="margin-bottom:10px;">
<label>
<input type="radio" name="convType" id="convTypeUpper" value="upper" checked> Upper
</label>
<label>
<input type="radio" name="convType" id="convTypeLower" value="lower"> Lower
</label>
<button id="reset" class="btn btn-warning">
<i class="fa fa-eraser" aria-hidden="true"></i> Reset
</button>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<textarea class="form-control" rows="13" id="text" placeholder="Input Text"></textarea>
</div>
<div class="col-xs-6">
<textarea class="form-control" rows="13" id="result" readonly placeholder="Convert Result"></textarea>
</div>
</div>
</div>
<script src="bower/jquery/dist/jquery.min.js"></script>
<script src="bower/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower/json5/lib/json5.js"></script>
<script>
var convert = function () {
var text = $('#text').val();
if (!text) {
$('#result').val('');
return;
}
try {
var type = $('input[name=convType]:checked').val();
console.log(type);
if (type === 'lower') {
$('#result').val(text.toLocaleLowerCase());
} else {
$('#result').val(text.toLocaleUpperCase());
}
} catch (e) {
$('#result').val(e);
}
};
$(document).ready(function () {
$('#text').keyup(function (e) {
convert();
});
$('#text').change(function () {
convert();
});
$('input[name=convType]').change(function () {
convert();
});
$('#reset').click(function() {
$('#text').val('');
convert();
});
});
</script>
</body>
</html>