-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglib.js
74 lines (51 loc) · 1.75 KB
/
glib.js
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
$.getJSON("data.json", function(json) {
generateBooks(json);
});
var tmp = '';
function generateBooks(data) {
data.forEach(function(value, key){
if (!value["url"].toLowerCase().includes('user:')) {
var preremove = RegExp(/<pre>|<.pre>/gus);
tmp += '<div class="col px-0 book"><div class="card"><div class="card-body"><h5 class="card-title"><a href="' + value["url"] + '" target="_blank" class="link">' + value["title"] + '</h5></a><div class="card-text">' + value["txt"].replace(preremove, "").replace('<p><br />', '<p>') + '</div></div></div></div>';
}
})
$('#books').append(tmp);
}
$(document).ready(function(){
$('.form-control').on("keypress", function(e) {
if(e.which === 13) {
var value = $(this).val().toLowerCase();
$(".book").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
var mark = function() {
// Read the keyword
var keyword = value;
// Determine selected options
var options = {"separateWordSearch": true, "diacritics": true};
// Remove previous marked elements and mark
// the new keyword inside the context
$(".book:visible").unmark({
done: function() {
$(".book:visible").mark(keyword, options);
}
});
};
mark();
}
});
});
var mark = function() {
// Read the keyword
var keyword = $('.form-control').val();
// Determine selected options
var options = {"separateWordSearch": true, "diacritics": true};
// Remove previous marked elements and mark
// the new keyword inside the context
$(".book").unmark({
done: function() {
$(".book").mark(keyword, options);
}
});
};
// $('.form-control').on("input", mark);