Lines 1-11
Link Here
|
1 |
var url_request = '/cgi-bin/koha/svc/elasticsearch/opac-elasticsearch.pl?q='; |
1 |
var url_request = '/cgi-bin/koha/svc/elasticsearch/opac-elasticsearch.pl?q='; |
2 |
|
2 |
|
3 |
//const url_param = '_search?filter_path=hits.total&source_content_type=application/json' |
|
|
4 |
/* Regex pour tous les URL avec un recherche */ |
5 |
var regex_es_link = "/cgi-bin/koha/opac-search.pl?q="; |
3 |
var regex_es_link = "/cgi-bin/koha/opac-search.pl?q="; |
6 |
/* key API */ |
|
|
7 |
var key_display = 'nb_notice'; |
4 |
var key_display = 'nb_notice'; |
8 |
/* idx de recherche */ |
|
|
9 |
var es_builder = { |
5 |
var es_builder = { |
10 |
'an' : 'koha-auth-number', |
6 |
'an' : 'koha-auth-number', |
11 |
'Provider' : 'provider', |
7 |
'Provider' : 'provider', |
Lines 13-20
var es_builder = {
Link Here
|
13 |
'au' : 'author', |
9 |
'au' : 'author', |
14 |
'su,complete-subfield' : 'subject' |
10 |
'su,complete-subfield' : 'subject' |
15 |
} |
11 |
} |
16 |
/* On remplace tous les caractères suivants */ |
|
|
17 |
//https://www.obkb.com/dcljr/charstxt.html |
18 |
var not_symbols = { |
12 |
var not_symbols = { |
19 |
'\'':'%27', |
13 |
'\'':'%27', |
20 |
'.':'%2E', |
14 |
'.':'%2E', |
Lines 46-66
var not_symbols = {
Link Here
|
46 |
|
40 |
|
47 |
function NumberResultsRecord(){ |
41 |
function NumberResultsRecord(){ |
48 |
|
42 |
|
49 |
var regex = 'a[href*="${' + regex_es_link + '}"]'; |
43 |
var regex = 'a[href*="' + regex_es_link + '"]'; |
50 |
var all_link = $(regex); |
44 |
var all_link = $(regex); |
51 |
/* array json data to server */ |
|
|
52 |
var json_data=[]; |
45 |
var json_data=[]; |
53 |
|
46 |
|
54 |
$.each( all_link, function( i, val ) { |
47 |
$.each( all_link, function( i, val ) { |
55 |
var url = ''; |
|
|
56 |
var str = val.href; |
48 |
var str = val.href; |
57 |
/* on prend param de q= */ |
|
|
58 |
str = decodeURIComponent(str.split('?q=').pop()); |
49 |
str = decodeURIComponent(str.split('?q=').pop()); |
59 |
/* split query for fields for search [0] */ |
50 |
var es_search = str.split(':'); |
60 |
var es_search = str.split(':'); |
51 |
var str_search = str.substring(str.indexOf(":") + 1); |
61 |
/* Remplacement pour un requete */ |
|
|
62 |
var str_search = str.substring(str.indexOf(":") + 1); |
63 |
/* [0] this is field for search */ |
64 |
str_search = str_search.replace(/[&\/\\#,+()$~%.'":;*?<>{}]/g, function(matched){ |
52 |
str_search = str_search.replace(/[&\/\\#,+()$~%.'":;*?<>{}]/g, function(matched){ |
65 |
return not_symbols[matched]; |
53 |
return not_symbols[matched]; |
66 |
}); |
54 |
}); |
Lines 74-83
function NumberResultsRecord(){
Link Here
|
74 |
type: 'GET', |
62 |
type: 'GET', |
75 |
url: url_request + JSON.stringify(json_data) + '&key=' + key_display, |
63 |
url: url_request + JSON.stringify(json_data) + '&key=' + key_display, |
76 |
success: function (data) { |
64 |
success: function (data) { |
77 |
//consoleconsole.log(data); |
|
|
78 |
jQuery.each( all_link, function( i, val ) { |
65 |
jQuery.each( all_link, function( i, val ) { |
79 |
$(val).after(" <span style=\"color:black\"><b>["+data[i]+"]</b></span>"); |
66 |
$(val).after(" <span style=\"color:black\"><b>["+data[i]+"]</b></span>"); |
80 |
//console.log(val); |
|
|
81 |
}); |
67 |
}); |
82 |
}, |
68 |
}, |
83 |
error: function (data) { |
69 |
error: function (data) { |