-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
127 lines (117 loc) · 2.69 KB
/
index.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>bahttext.js</title>
<link href='//fonts.googleapis.com/css?family=Raleway:400,300,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
<link rel="stylesheet" href="//cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<style>
table {
table-layout: fixed
}
td {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<h2>bahttext.js</h2>
<hr>
<input type="text" id="number" class="u-full-width" placeholder="number">
<div id="result" class="u-full-width"></div><br>
<button id="random">
Random
</button>
<hr>
<h4>Example</h4>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>category</th>
<th>case</th>
<th>number</th>
<th>text</th>
</tr>
</thead>
<tfoot>
<tr>
<th>category</th>
<th>case</th>
<th>number</th>
<th>text</th>
</tr>
</tfoot>
</table>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/random-js/1.0.8/random.min.js"></script>
<script src="./src/index.js"></script>
<script>
// random
const r = new Random(Random.engines.mt19937().autoSeed())
const $number = $('#number')
const $result = $('#result')
const $random = $('#random')
const $exmaple = $('#example')
function updateResult() {
const val = $number.val()
const num = parseFloat(val)
const html = bahttext(num)
$result.html(html)
}
function randomNumber() {
const num = r.real(Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER)
$number.val(num)
updateResult()
}
$(document).ready(function() {
// init
randomNumber()
// number
$number.on('input', function(e) {
updateResult()
})
// random
$random.click(function(e) {
randomNumber()
})
// example
$exmaple.DataTable({
paging: false,
searching: false,
ordering: false,
ajax: {
url: 'misc/testcases.json',
dataSrc: ''
},
columns: [
{
data: 'category',
width: '10%'
},
{
data: 'case',
width: '16%'
},
{
data: 'number',
width: '22%'
},
{
data: 'text'
}
]
})
})
</script>
</body>
</html>