This repository has been archived by the owner on Sep 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
isdal.html
335 lines (310 loc) · 16.9 KB
/
isdal.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Isdal Woman Destroyed name-finder</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> </head>
<style type="text/css">
/* Sticky footer styles
-------------------------------------------------- */
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by it's height */
margin: 0 auto -60px;
}
/* Set the fixed height of the footer here */
#push,
#footer {
height: 60px;
}
#footer {
background-color: #f5f5f5;
}
/* Lastly, apply responsive CSS fixes as necessary */
@media (max-width: 767px) {
#footer {
margin-left: -20px;
margin-right: -20px;
padding-left: 20px;
padding-right: 20px;
}
}
.vcenter {
display: inline-block;
vertical-align: middle;
float: none;
}
</style>
<body>
<div id="wrap">
<main role="main" class="container">
<h1>Isdal Woman Destroyed name-finder</h1>
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item"> <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Pattern</a> </li>
<li class="nav-item"> <a class="nav-link" id="presets-tab" data-toggle="tab" href="#presets" role="tab" aria-controls="presets" aria-selected="false">Presets</a> </li>
<li class="nav-item"> <a class="nav-link" id="profile-tab" data-toggle="tab" href="#names" role="tab" aria-controls="names" aria-selected="false">Names <span class="badge badge-info" id="name_count"></span></a> </li>
<li class="nav-item"> <a class="nav-link" id="results-tab" data-toggle="tab" href="#result" role="tab" aria-controls="result" aria-selected="false">Results <span class="badge badge-warning" id="result_count"></span></a> </li>
</ul> <br>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<form>
<div class="container">
<div class="row">
<div class="col-sm"> <small>First name</small>
<div class="form-group"> <label for="first_name_characters">Number of characters</label> <input type="number" name="first_name_characters" id="first_name_characters" min="1" max="16" value=7> </div>
</div>
<div class="col-sm"> <input type="checkbox" class="form-check-input" id="enable_last_name"> <small>Last name</small> <br/> <input type="checkbox" class="form-check-input" id="fixed" checked> <small><label for="fixed">Fixed length names</label></small>
<div class="form-group"> <label for="last_name_characters">Number of characters</label> <input type="number" name="last_name_characters" id="last_name_characters" min="1" max="16" value=5 disabled> </div>
</div>
</div>
</div>
</form>
<div class="container">
<div class="row">
<div class="col-sm" id="first_name_div"> </div>
<div class="col-sm" id="last_name_div"> </div>
</div>
</div>
</div>
<div class="tab-pane fade show" id="presets" role="tabpanel" aria-labelledby="presets-tab">
<div class="col-sm"> <br> <button type="button" id="myidea1">My idea 1</button> <br> <button type="button" id="aske">D. Aske</button><br> <button type="button" id="minimal">Minimal</button></div>
</div>
<div class="tab-pane fade" id="names" role="tabpanel" aria-labelledby="names-tab">
<div class="col-sm"> <input type="checkbox" class="form-check-input" id="fvarious" checked> <small><label for="fvarious">Various female first names</label></small><br> <input type="checkbox" class="form-check-input" id="ffirst" checked> <small><label for="ffirst">French female first names 1926-30</label></small><br> <input type="checkbox" class="form-check-input" id="gfirst" checked> <small><label for="gfirst">German female first names 1926-34</label></small><br> <input type="checkbox" class="form-check-input" id="gvarious" checked> <small><label for="gvarious">German various names ~1930</label></small><br> <input type="checkbox" class="form-check-input" id="ffamily" checked> <small><label for="ffamily">Various french family names</label></small><br> <input type="checkbox" class="form-check-input" id="belgien" checked> <small><label for="belgien">Belgian locations + Flemish/Dutch names</label></small><br> <input type="checkbox" class="form-check-input" id="ukrainianFirstnames" checked> <small><label for="ukrainianFirstnames">Ukrainian first names</label></small><br> <input type="checkbox" class="form-check-input" id="ukrainianLastnames" checked> <small><label for="ukrainianLastnames">Ukrainian last names</label></small><br><br> <small>Additional names, separated by comma</small> <input type="text" name="fname" id="extra_names"> </div>
</div>
<div class="tab-pane fade" id="result" role="tabpanel" aria-labelledby="result-tab">
<div class="container">
<div class="row"> <textarea rows="25" cols="120" id="results" readonly></textarea> </div>
</div>
</div>
</div>
</main>
<div id="push"></div>
</div>
<div id="footer">
<div class="container"> Based on the idea described in <strong>Dennis Zacher Aske - Kvinnen i Isdalen</strong>, ISBN 9788241916601</div>
</div>
<!-- /.container -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="names.js"></script>
<script language='javascript' type='text/javascript'>
var allNames = '';
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function normalizeArray(list) {
for (var i = 0; i < list.length; i++) list[i] = list[i].trim();
return list.join(' ');
}
function addNames(sset, list) {
list.forEach(function (item) {
sset.add(capitalizeFirstLetter(item));
});
}
function initNames() {
var allRawNames = new Set();
if ($('#fvarious').is(':checked')) addNames(allRawNames, variousNames);
if ($('#ffirst').is(':checked')) addNames(allRawNames, frenchWomanNames);
if ($('#gfirst').is(':checked')) addNames(allRawNames, germanWomanNames);
if ($('#gvarious').is(':checked')) addNames(allRawNames, germanVariousNames);
if ($('#ffamily').is(':checked')) addNames(allRawNames, frenchFamilyNames);
if ($('#belgien').is(':checked')) addNames(allRawNames, belgiumTowns);
if ($('#ukrainianFirstnames').is(':checked')) addNames(allRawNames, ukrainianFirstnames);
if ($('#ukrainianLastnames').is(':checked')) addNames(allRawNames, ukrainianLastnames);
if ($('#extra_names').val()) {
var extranames = $('#extra_names').val().split(',');
addNames(allRawNames, extranames);
}
allNames = normalizeArray(Array.from(allRawNames));
console.log(String(allNames.length) + ' names.');
$('#name_count').text(allNames.length);
}
function addNamebox(div, name, i) {
var nameboxName = name + String(i);
div.append('<pre class="' + nameboxName + '">' + String(i) + ' <input size = "15" type="text" class="' + nameboxName + '"></pre>');
return $('#' + nameboxName);
}
function createRegex(name) {
var wildcard;
if ($('#fixed').is(':checked')) {
wildcard = '\\S';
} else {
wildcard = '\\S?';
}
alphanumeric = new RegExp('[a-z|A-Z]');
var allWildcard = true;
var regexx = '';
for (var i = 1; i <= $('#' + name + '_characters').val(); i++) {
var textValue = $('input.' + name + String(i)).val();
if (alphanumeric.test(textValue)) {
regexx += '[' + textValue + ']';
allWildcard = false;
} else regexx += wildcard;
}
if (!allWildcard) {
console.log('Regex: ' + regexx);
return new RegExp('\\b' + regexx + '\\b', 'gi');
} else {
return null;
}
}
function getHits(names, regex) {
var results = [];
if (regex == null) return results;
do {
m = regex.exec(names);
if (m) {
results.push(m);
}
} while (m);
return [...new Set(results)];
}
function resetNameBoxes() {
var names = ['first_name'];
if ($('#enable_last_name').is(':checked')) {
names.push('last_name');
}
names.forEach(function (name) {
var i = 1;
for (; i <= 16; i++) {
var divName = '#' + name + '_div';
if ($('.' + name + String(i)).length) {
$('.' + name + String(i)).val('');
}
}
});
}
function placeNameBoxes() {
var names = ['first_name', 'last_name'];
names.forEach(function (name) {
var i = 1;
for (; i <= $('#' + name + '_characters').val(); i++) {
if (name == 'last_name' && !$('#enable_last_name').is(':checked')) {
break;
}
var divName = '#' + name + '_div';
if ($('.' + name + String(i)).length) {
$('.' + name + String(i)).show();
} else {
addNamebox($(divName), name, i);
}
}
while ($('.' + name + String(i)).length) {
$('.' + name + String(i++)).hide();
}
});
}
var uniqueArray = function (arrArg) {
// https://gist.github.com/telekosmos/3b62a31a5c43f40849bb
return arrArg.filter(function (elem, pos, arr) {
return arr.indexOf(elem) == pos;
});
};
function findNames() {
var combinations = [];
var firstNameHits = getHits(allNames, createRegex('first_name'));
var lastNameHits = [];
if ($('#enable_last_name').is(':checked')) {
lastNameHits = getHits(allNames, createRegex('last_name'));
firstNameHits.forEach(function (a1) {
lastNameHits.forEach(function (a2) {
combinations.push(a1 + ' ' + a2);
});
});
} else {
combinations = firstNameHits;
}
combinations.sort();
uResults = uniqueArray(combinations);
$('#results').val(uResults.join('\n'));
$('#result_count').text(uResults.length);
}
function doSearch() {
placeNameBoxes();
findNames();
}
$(document).ready(function () {
initNames();
$('#myidea1').click(function () {
$('#extra_names').val('');
resetNameBoxes();
$("#enable_last_name").prop("checked", true);
$("#fixed").prop("checked", true);
$('#last_name_characters').prop('disabled', false);
$("#first_name_characters").val(7);
$("#last_name_characters").val(5);
placeNameBoxes();
$("input.first_name1").val("OCGUVQ");
$("input.first_name2").val("Ilidf");
$("input.first_name3").val("seaonc");
$("input.first_name4").val("eaugr");
$("input.first_name5").val("lditIf");
$("input.first_name7").val("aoe");
$("input.last_name2").val("i");
findNames();
});
$('#aske').click(function () {
$('#extra_names').val('');
resetNameBoxes();
$("#enable_last_name").prop("checked", true);
$("#fixed").prop("checked", true);
$('#last_name_characters').prop('disabled', false);
$("#first_name_characters").val(7);
$("#last_name_characters").val(5);
placeNameBoxes();
$("input.first_name1").val("OGedCa");
$("input.first_name2").val("Il");
$("input.first_name3").val("a");
$("input.first_name4").val("u");
$("input.first_name5").val("d");
$("input.first_name7").val("Cba");
$("input.last_name1").val("TI");
$("input.last_name2").val("tIida");
$("input.last_name5").val("tl");
findNames();
});
$('#minimal').click(function () {
$('#extra_names').val('');
resetNameBoxes();
$("#enable_last_name").prop("checked", false);
$("#fixed").prop("checked", false);
$('#last_name_characters').prop('disabled', true);
$("#first_name_characters").val(7);
placeNameBoxes();
$("input.first_name1").val("OCGUQ");
$("input.first_name2").val("Ilidf");
findNames();
});
$('#enable_last_name').change(function () {
if (this.checked) $('#last_name_characters').prop('disabled', false);
else $('#last_name_characters').prop('disabled', true);
placeNameBoxes();
findNames();
});
placeNameBoxes();
$("input[type='checkbox']").change(function () {
initNames();
placeNameBoxes();
doSearch();
});
$("input[type='text']").change(function () {
doSearch();
});
});
</script>
</body>
</html>