-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.html
145 lines (129 loc) · 3.74 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!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>leo-profanity.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>leo-profanity.js</h2>
<hr>
<div>
<div class="two columns">
<label for="nbLetters">nbLetters</label>
<input type="number" id="nbLetters" class="u-full-width input" value="0">
</div>
<div class="two columns">
<label for="replaceKey">replaceKey</label>
<input type="text" id="replaceKey" class="u-full-width input" value="*">
</div>
<div class="eight columns">
<label for="input">input</label>
<input type="text" id="input" class="u-full-width input">
</div>
</div>
<div>
<label for="result">result</label>
<div id="result" class="u-full-width"></div>
</div>
<hr>
<h4>Example</h4>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Input</th>
<th>Result</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Input</th>
<th>Result</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="./src/index.js"></script>
<script>
const filter = LeoProfanity
const $nbLetters = $('#nbLetters')
const $replaceKey = $('#replaceKey')
const $input = $('#input')
const $inputs = $('.input')
const $result = $('#result')
const $example = $('#example')
const initInput = "This asshole text contains some bad words like b00b, butt"
const exampleItems = [
"",
"I have 2 eyes",
"I have boob, etc.",
"2g1c",
"zoophilia",
"lorem 2g1c ipsum",
"lorem zoophilia ipsum",
"I have BoOb",
"I have BoOb,",
"I have BoOb.",
"I have boob,boob, ass, and etc.",
"Buy classic watches online",
"I hav ,e BoOb, ",
",I h a. v e BoOb.",
".",
]
function updateResult() {
const input = $input.val()
const nbLetters = parseInt($nbLetters.val())
const replaceKey = $replaceKey.val()
const result = filter.clean(input, replaceKey, nbLetters)
$result.html(result)
}
function onDataReady(words) {
// filter setup
filter.clearList()
filter.add(words)
// initial input value
$input.val(initInput)
$input.attr("placeholder", initInput)
updateResult()
// watch input change
$inputs.on('input', function (e) {
updateResult()
})
// example
$example.DataTable({
paging: false,
searching: false,
ordering: false,
data: exampleItems.map((input) => [input, filter.clean(input)]),
})
}
$(document).ready(function () {
// update word list
fetch('dictionary/default.json')
.then(response => response.json())
.then(data => {
onDataReady(data)
})
})
</script>
</body>
</html>