2 * Copyright 2015 ByWater Solutions
4 * This file is part of Koha.
6 * Koha is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * Koha is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Koha; if not, see <http://www.gnu.org/licenses>.
20 define( [ 'marc-record' ], function( MARC ) {
26 author: '1=1004', // s=al',
29 date: '1=30', // r=r',
34 music_identifier: '1=51',
35 standard_identifier: '1=1007',
36 subject: '1=21', // s=al',
37 term: '1=1016', // t=l,r s=al',
38 title: '1=4', // s=al',
42 Init: function( options ) {
45 JoinTerms: function( terms ) {
48 $.each( terms, function( i, term ) {
49 var term = '@attr ' + _pqfMapping[ term[0] ] + ' "' + term[1].replace( '"', '\\"' ) + '"'
52 q = '@and ' + q + ' ' + term;
60 Run: function( servers, q, options ) {
64 }, _options, options );
66 Search.includedServers = [];
74 $.each( servers, function ( id, info ) {
75 if ( info.checked ) Search.includedServers.push( id );
79 '/cgi-bin/koha/svc/cataloguing/metasearch',
82 servers: Search.includedServers.join( ',' ),
83 offset: options.offset,
84 page_size: options.page_size,
85 sort_direction: options.sort_direction,
86 sort_key: options.sort_key,
87 resultset: options.resultset,
90 .done( function( data ) {
91 _last.options.resultset = data.resultset;
92 $.each( data.hits, function( undef, hit ) {
93 var record = new MARC.Record();
94 record.loadMARCXML( hit.record );
98 _options.onresults( data );
100 .fail( function( error ) {
101 _options.onerror( error );
106 Fetch: function( options ) {
107 if ( !_last ) return;
108 $.extend( _last.options, options );
109 Search.Run( _last.servers, _last.q, _last.options );