algoliasearch-rails 1.10.1 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/VERSION +1 -1
- data/algoliasearch-rails.gemspec +1 -1
- data/lib/algoliasearch-rails.rb +2 -1
- data/lib/algoliasearch/configuration.rb +1 -1
- data/vendor/assets/javascripts/algolia/algoliasearch.js +660 -57
- data/vendor/assets/javascripts/algolia/algoliasearch.min.js +2 -2
- metadata +23 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6196220d77f0814eb40d2b9bd099bca91a2324fa
|
4
|
+
data.tar.gz: 63f5d687166324650b122dd41d3662bbdcfefa31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9487f03e8c3ff584f7765d912181cd91a1d2d114f331de301e5065d08a78d9dc9d52f8a0ec645a6c421a09d23e6cdbabd601638a6466268b8678184eef75a20
|
7
|
+
data.tar.gz: cffab279a78865d7974113f629be7833ce1c7cd074ae56838336a67b2b6a55266089615faa817afe8e5fbabb1d084e02683edb024296d3ad23d1d48fef80485a
|
data/ChangeLog
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
|
3
|
+
2014-05-09 1.10.2
|
4
|
+
|
5
|
+
* Expose synoyms/placeholders features
|
6
|
+
* Upgrade to algoliasearch-client-js 2.5.0 (fallback on JSONP if CORS is not available)
|
7
|
+
|
3
8
|
2014-04-29 1.10.1
|
4
9
|
|
5
10
|
* Use :if and :unless constraints to detect if a record has changed as well
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.10.
|
1
|
+
1.10.2
|
data/algoliasearch-rails.gemspec
CHANGED
data/lib/algoliasearch-rails.rb
CHANGED
@@ -52,7 +52,8 @@ module AlgoliaSearch
|
|
52
52
|
:attributesToHighlight, :attributesToSnippet, :attributesToIndex,
|
53
53
|
:highlightPreTag, :highlightPostTag,
|
54
54
|
:ranking, :customRanking, :queryType, :attributesForFaceting,
|
55
|
-
:separatorsToIndex, :optionalWords, :attributeForDistinct
|
55
|
+
:separatorsToIndex, :optionalWords, :attributeForDistinct,
|
56
|
+
:synonyms, :placeholders]
|
56
57
|
OPTIONS.each do |k|
|
57
58
|
define_method k do |v|
|
58
59
|
instance_variable_set("@#{k}", v)
|
@@ -6,7 +6,7 @@ module AlgoliaSearch
|
|
6
6
|
|
7
7
|
def configuration=(configuration)
|
8
8
|
@@configuration = configuration
|
9
|
-
Algolia.init :application_id => @@configuration[:application_id], :api_key => @@configuration[:api_key]
|
9
|
+
Algolia.init :application_id => @@configuration[:application_id], :api_key => @@configuration[:api_key], :hosts => @@configuration[:hosts]
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -21,7 +21,7 @@
|
|
21
21
|
* THE SOFTWARE.
|
22
22
|
*/
|
23
23
|
|
24
|
-
var ALGOLIA_VERSION = '2.
|
24
|
+
var ALGOLIA_VERSION = '2.5.0';
|
25
25
|
|
26
26
|
/*
|
27
27
|
* Copyright (c) 2013 Algolia
|
@@ -56,6 +56,7 @@ var ALGOLIA_VERSION = '2.4.5';
|
|
56
56
|
* @param hostsArray (optionnal) the list of hosts that you have received for the service
|
57
57
|
*/
|
58
58
|
var AlgoliaSearch = function(applicationID, apiKey, method, resolveDNS, hostsArray) {
|
59
|
+
var self = this;
|
59
60
|
this.applicationID = applicationID;
|
60
61
|
this.apiKey = apiKey;
|
61
62
|
|
@@ -81,11 +82,17 @@ var AlgoliaSearch = function(applicationID, apiKey, method, resolveDNS, hostsArr
|
|
81
82
|
if (Math.random() > 0.5) {
|
82
83
|
this.hosts.reverse();
|
83
84
|
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
|
86
|
+
// resolve DNS + check CORS support (JSONP fallback)
|
87
|
+
this.jsonp = null;
|
88
|
+
this.jsonpWait = 0;
|
89
|
+
this._jsonRequest({
|
90
|
+
method: 'GET',
|
91
|
+
url: '/1/isalive',
|
92
|
+
callback: function(success, content) {
|
93
|
+
self.jsonp = !success;
|
94
|
+
}
|
95
|
+
});
|
89
96
|
this.extraHeaders = [];
|
90
97
|
};
|
91
98
|
|
@@ -362,7 +369,7 @@ AlgoliaSearch.prototype = {
|
|
362
369
|
}
|
363
370
|
tags = strTags.join(',');
|
364
371
|
}
|
365
|
-
this.
|
372
|
+
this.tagFilters = tags;
|
366
373
|
},
|
367
374
|
|
368
375
|
/**
|
@@ -370,7 +377,7 @@ AlgoliaSearch.prototype = {
|
|
370
377
|
* @param {string} userToken The token identifying a uniq user (used to apply rate limits)
|
371
378
|
*/
|
372
379
|
setUserToken: function(userToken) {
|
373
|
-
|
380
|
+
this.userToken = userToken;
|
374
381
|
},
|
375
382
|
|
376
383
|
/*
|
@@ -420,6 +427,10 @@ AlgoliaSearch.prototype = {
|
|
420
427
|
sendQueriesBatch: function(callback, delay) {
|
421
428
|
var as = this;
|
422
429
|
var params = {requests: [], apiKey: this.apiKey, appID: this.applicationID};
|
430
|
+
if (this.userToken)
|
431
|
+
params['X-Algolia-UserToken'] = this.userToken;
|
432
|
+
if (this.tagFilters)
|
433
|
+
params['X-Algolia-TagFilters'] = this.tagFilters;
|
423
434
|
for (var i = 0; i < as.batch.length; ++i) {
|
424
435
|
params.requests.push(as.batch[i]);
|
425
436
|
}
|
@@ -449,11 +460,29 @@ AlgoliaSearch.prototype = {
|
|
449
460
|
},
|
450
461
|
|
451
462
|
_sendQueriesBatch: function(params, callback) {
|
452
|
-
this.
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
463
|
+
if (this.jsonp == null) {
|
464
|
+
var self = this;
|
465
|
+
this._waitReady(function() { self._sendQueriesBatch(params, callback); });
|
466
|
+
return;
|
467
|
+
}
|
468
|
+
if (this.jsonp) {
|
469
|
+
var jsonpParams = '';
|
470
|
+
for (var i = 0; i < params.requests.length; ++i) {
|
471
|
+
var q = '/1/indexes/' + encodeURIComponent(params.requests[i].indexName) + '?' + params.requests[i].params;
|
472
|
+
jsonpParams += i + '=' + encodeURIComponent(q) + '&';
|
473
|
+
}
|
474
|
+
this._jsonRequest({ cache: this.cache,
|
475
|
+
method: 'GET', jsonp: true,
|
476
|
+
url: '/1/indexes/*',
|
477
|
+
body: { params: jsonpParams },
|
478
|
+
callback: callback });
|
479
|
+
} else {
|
480
|
+
this._jsonRequest({ cache: this.cache,
|
481
|
+
method: 'POST',
|
482
|
+
url: '/1/indexes/*/queries',
|
483
|
+
body: params,
|
484
|
+
callback: callback });
|
485
|
+
}
|
457
486
|
},
|
458
487
|
/*
|
459
488
|
* Wrapper that try all hosts to maximize the quality of service
|
@@ -489,7 +518,7 @@ AlgoliaSearch.prototype = {
|
|
489
518
|
}
|
490
519
|
opts.callback = function(retry, success, res, body) {
|
491
520
|
if (!success && !self._isUndefined(body)) {
|
492
|
-
console.log('Error: ' + body.message);
|
521
|
+
if (window.console) { console.log('Error: ' + body.message); }
|
493
522
|
}
|
494
523
|
if (success && !self._isUndefined(opts.cache)) {
|
495
524
|
cache[cacheID] = body;
|
@@ -509,47 +538,108 @@ AlgoliaSearch.prototype = {
|
|
509
538
|
},
|
510
539
|
|
511
540
|
_jsonRequestByHost: function(opts) {
|
512
|
-
var body = null;
|
513
541
|
var self = this;
|
514
|
-
if (!this._isUndefined(opts.body)) {
|
515
|
-
body = JSON.stringify(opts.body);
|
516
|
-
}
|
517
542
|
var url = opts.hostname + opts.url;
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
543
|
+
|
544
|
+
if (this.jsonp) {
|
545
|
+
if (!opts.jsonp) {
|
546
|
+
opts.callback(true, false, null, { 'message': 'Method ' + opts.method + ' ' + url + ' is not supported by JSONP.' });
|
547
|
+
return;
|
548
|
+
}
|
549
|
+
this.jsonpCounter = this.jsonpCounter || 0;
|
550
|
+
this.jsonpCounter += 1;
|
551
|
+
var cb = 'algoliaJSONP_' + this.jsonpCounter;
|
552
|
+
window[cb] = function(data) {
|
553
|
+
opts.callback(false, true, null, data);
|
554
|
+
try { delete window[cb]; } catch (e) { window[cb] = undefined; }
|
555
|
+
};
|
556
|
+
var script = document.createElement('script');
|
557
|
+
script.type = 'text/javascript';
|
558
|
+
script.src = url + '?callback=' + cb + ',' + this.applicationID + ',' + this.apiKey;
|
559
|
+
if (opts['X-Algolia-TagFilters']) {
|
560
|
+
script.src += '&X-Algolia-TagFilters=' + opts['X-Algolia-TagFilters'];
|
527
561
|
}
|
528
|
-
if (
|
529
|
-
|
562
|
+
if (opts['X-Algolia-UserToken']) {
|
563
|
+
script.src += '&X-Algolia-UserToken=' + opts['X-Algolia-UserToken'];
|
530
564
|
}
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
565
|
+
if (opts.body && opts.body.params) {
|
566
|
+
script.src += '&' + opts.body.params;
|
567
|
+
}
|
568
|
+
var head = document.getElementsByTagName('head')[0];
|
569
|
+
script.onerror = function() {
|
570
|
+
opts.callback(true, false, null, { 'message': 'Failed to load JSONP script.' });
|
571
|
+
head.removeChild(script);
|
572
|
+
try { delete window[cb]; } catch (e) { window[cb] = undefined; }
|
573
|
+
};
|
574
|
+
var done = false;
|
575
|
+
script.onload = script.onreadystatechange = function() {
|
576
|
+
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
|
577
|
+
done = true;
|
578
|
+
if (typeof window[cb + '_loaded'] === 'undefined') {
|
579
|
+
opts.callback(true, false, null, { 'message': 'Failed to load JSONP script.' });
|
580
|
+
try { delete window[cb]; } catch (e) { window[cb] = undefined; }
|
581
|
+
} else {
|
582
|
+
try { delete window[cb + '_loaded']; } catch (e) { window[cb + '_loaded'] = undefined; }
|
583
|
+
}
|
584
|
+
script.onload = script.onreadystatechange = null; // Handle memory leak in IE
|
585
|
+
head.removeChild(script);
|
586
|
+
}
|
587
|
+
};
|
588
|
+
head.appendChild(script);
|
536
589
|
} else {
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
if (
|
543
|
-
|
544
|
-
|
545
|
-
|
590
|
+
var body = null;
|
591
|
+
if (!this._isUndefined(opts.body)) {
|
592
|
+
body = JSON.stringify(opts.body);
|
593
|
+
}
|
594
|
+
var xmlHttp = window.XMLHttpRequest ? new XMLHttpRequest() : {};
|
595
|
+
if ('withCredentials' in xmlHttp) {
|
596
|
+
xmlHttp.open(opts.method, url , true);
|
597
|
+
xmlHttp.setRequestHeader('X-Algolia-API-Key', this.apiKey);
|
598
|
+
xmlHttp.setRequestHeader('X-Algolia-Application-Id', this.applicationID);
|
599
|
+
for (var i = 0; i < this.extraHeaders.length; ++i) {
|
600
|
+
xmlHttp.setRequestHeader(this.extraHeaders[i].key, this.extraHeaders[i].value);
|
601
|
+
}
|
602
|
+
if (body != null) {
|
603
|
+
xmlHttp.setRequestHeader('Content-type', 'application/json');
|
604
|
+
}
|
605
|
+
} else if (typeof XDomainRequest != 'undefined') {
|
606
|
+
// Handle IE8/IE9
|
607
|
+
// XDomainRequest only exists in IE, and is IE's way of making CORS requests.
|
608
|
+
xmlHttp = new XDomainRequest();
|
609
|
+
xmlHttp.open(opts.method, url);
|
546
610
|
} else {
|
547
|
-
|
611
|
+
// very old browser, not supported
|
612
|
+
if (window.console) { console.log('Your browser is too old to support CORS requests'); }
|
613
|
+
opts.callback(false, false, null, { 'message': 'CORS not supported' });
|
614
|
+
return;
|
548
615
|
}
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
616
|
+
xmlHttp.send(body);
|
617
|
+
xmlHttp.onload = function(event) {
|
618
|
+
if (!self._isUndefined(event) && event.target != null) {
|
619
|
+
var retry = (event.target.status === 0 || event.target.status === 503);
|
620
|
+
var success = (event.target.status === 200 || event.target.status === 201);
|
621
|
+
opts.callback(retry, success, event.target, event.target.response != null ? JSON.parse(event.target.response) : null);
|
622
|
+
} else {
|
623
|
+
opts.callback(false, true, event, JSON.parse(xmlHttp.responseText));
|
624
|
+
}
|
625
|
+
};
|
626
|
+
xmlHttp.onerror = function(event) {
|
627
|
+
opts.callback(true, false, null, { 'message': 'Could not connect to host', 'error': event } );
|
628
|
+
};
|
629
|
+
}
|
630
|
+
},
|
631
|
+
|
632
|
+
/**
|
633
|
+
* Wait until JSONP flag has been set to perform the first query
|
634
|
+
*/
|
635
|
+
_waitReady: function(cb) {
|
636
|
+
if (this.jsonp == null) {
|
637
|
+
this.jsonpWait += 100;
|
638
|
+
if (this.jsonpWait > 2000) {
|
639
|
+
this.jsonp = true;
|
640
|
+
}
|
641
|
+
setTimeout(cb, 100);
|
642
|
+
}
|
553
643
|
},
|
554
644
|
|
555
645
|
/*
|
@@ -574,6 +664,8 @@ AlgoliaSearch.prototype = {
|
|
574
664
|
/// internal attributes
|
575
665
|
applicationID: null,
|
576
666
|
apiKey: null,
|
667
|
+
tagFilters: null,
|
668
|
+
userToken: null,
|
577
669
|
hosts: [],
|
578
670
|
cache: {},
|
579
671
|
extraHeaders: []
|
@@ -646,6 +738,11 @@ AlgoliaSearch.prototype.Index.prototype = {
|
|
646
738
|
* @param attributes (optional) if set, contains the array of attribute names to retrieve
|
647
739
|
*/
|
648
740
|
getObject: function(objectID, callback, attributes) {
|
741
|
+
if (this.as.jsonp == null) {
|
742
|
+
var self = this;
|
743
|
+
this.as._waitReady(function() { self.getObject(objectID, callback, attributes); });
|
744
|
+
return;
|
745
|
+
}
|
649
746
|
var indexObj = this;
|
650
747
|
var params = '';
|
651
748
|
if (!this.as._isUndefined(attributes)) {
|
@@ -657,7 +754,7 @@ AlgoliaSearch.prototype.Index.prototype = {
|
|
657
754
|
params += attributes[i];
|
658
755
|
}
|
659
756
|
}
|
660
|
-
this.as._jsonRequest({ method: 'GET',
|
757
|
+
this.as._jsonRequest({ method: 'GET', jsonp: true,
|
661
758
|
url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(objectID) + params,
|
662
759
|
callback: callback });
|
663
760
|
},
|
@@ -1084,11 +1181,29 @@ AlgoliaSearch.prototype.Index.prototype = {
|
|
1084
1181
|
/// Internal methods only after this line
|
1085
1182
|
///
|
1086
1183
|
_search: function(params, callback) {
|
1087
|
-
this.as.
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1184
|
+
if (this.as.jsonp == null) {
|
1185
|
+
var self = this;
|
1186
|
+
this.as._waitReady(function() { self._search(params, callback); });
|
1187
|
+
return;
|
1188
|
+
}
|
1189
|
+
var pObj = {params: params, apiKey: this.as.apiKey, appID: this.as.applicationID};
|
1190
|
+
if (this.as.tagFilters)
|
1191
|
+
pObj['X-Algolia-TagFilters'] = this.as.tagFilters;
|
1192
|
+
if (this.as.userToken)
|
1193
|
+
pObj['X-Algolia-UserToken'] = this.as.userToken;
|
1194
|
+
if (this.as.jsonp) {
|
1195
|
+
this.as._jsonRequest({ cache: this.cache,
|
1196
|
+
method: 'GET', jsonp: true,
|
1197
|
+
url: '/1/indexes/' + encodeURIComponent(this.indexName),
|
1198
|
+
body: pObj,
|
1199
|
+
callback: callback });
|
1200
|
+
} else {
|
1201
|
+
this.as._jsonRequest({ cache: this.cache,
|
1202
|
+
method: 'POST',
|
1203
|
+
url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/query',
|
1204
|
+
body: pObj,
|
1205
|
+
callback: callback });
|
1206
|
+
}
|
1092
1207
|
},
|
1093
1208
|
|
1094
1209
|
// internal attributes
|
@@ -1124,8 +1239,6 @@ AlgoliaSearch.prototype.Index.prototype = {
|
|
1124
1239
|
*/
|
1125
1240
|
|
1126
1241
|
(function($) {
|
1127
|
-
var self;
|
1128
|
-
|
1129
1242
|
var extend = function(out) {
|
1130
1243
|
out = out || {};
|
1131
1244
|
for (var i = 1; i < arguments.length; i++) {
|
@@ -1156,7 +1269,6 @@ AlgoliaSearch.prototype.Index.prototype = {
|
|
1156
1269
|
};
|
1157
1270
|
|
1158
1271
|
this.init(client, index, extend({}, defaults, options));
|
1159
|
-
self = this;
|
1160
1272
|
};
|
1161
1273
|
|
1162
1274
|
AlgoliaSearchHelper.prototype = {
|
@@ -1274,6 +1386,7 @@ AlgoliaSearch.prototype.Index.prototype = {
|
|
1274
1386
|
for (var i = 0; i < this.options.disjunctiveFacets.length; ++i) {
|
1275
1387
|
this.client.addQueryInBatch(this.index, this.q, this._getDisjunctiveFacetSearchParams(this.options.disjunctiveFacets[i]));
|
1276
1388
|
}
|
1389
|
+
var self = this;
|
1277
1390
|
this.client.sendQueriesBatch(function(success, content) {
|
1278
1391
|
if (!success) {
|
1279
1392
|
self.searchCallback(false, content);
|
@@ -1353,3 +1466,493 @@ AlgoliaSearch.prototype.Index.prototype = {
|
|
1353
1466
|
}
|
1354
1467
|
};
|
1355
1468
|
})();
|
1469
|
+
|
1470
|
+
/*
|
1471
|
+
json2.js
|
1472
|
+
2014-02-04
|
1473
|
+
|
1474
|
+
Public Domain.
|
1475
|
+
|
1476
|
+
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
1477
|
+
|
1478
|
+
See http://www.JSON.org/js.html
|
1479
|
+
|
1480
|
+
|
1481
|
+
This code should be minified before deployment.
|
1482
|
+
See http://javascript.crockford.com/jsmin.html
|
1483
|
+
|
1484
|
+
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
|
1485
|
+
NOT CONTROL.
|
1486
|
+
|
1487
|
+
|
1488
|
+
This file creates a global JSON object containing two methods: stringify
|
1489
|
+
and parse.
|
1490
|
+
|
1491
|
+
JSON.stringify(value, replacer, space)
|
1492
|
+
value any JavaScript value, usually an object or array.
|
1493
|
+
|
1494
|
+
replacer an optional parameter that determines how object
|
1495
|
+
values are stringified for objects. It can be a
|
1496
|
+
function or an array of strings.
|
1497
|
+
|
1498
|
+
space an optional parameter that specifies the indentation
|
1499
|
+
of nested structures. If it is omitted, the text will
|
1500
|
+
be packed without extra whitespace. If it is a number,
|
1501
|
+
it will specify the number of spaces to indent at each
|
1502
|
+
level. If it is a string (such as '\t' or ' '),
|
1503
|
+
it contains the characters used to indent at each level.
|
1504
|
+
|
1505
|
+
This method produces a JSON text from a JavaScript value.
|
1506
|
+
|
1507
|
+
When an object value is found, if the object contains a toJSON
|
1508
|
+
method, its toJSON method will be called and the result will be
|
1509
|
+
stringified. A toJSON method does not serialize: it returns the
|
1510
|
+
value represented by the name/value pair that should be serialized,
|
1511
|
+
or undefined if nothing should be serialized. The toJSON method
|
1512
|
+
will be passed the key associated with the value, and this will be
|
1513
|
+
bound to the value
|
1514
|
+
|
1515
|
+
For example, this would serialize Dates as ISO strings.
|
1516
|
+
|
1517
|
+
Date.prototype.toJSON = function (key) {
|
1518
|
+
function f(n) {
|
1519
|
+
// Format integers to have at least two digits.
|
1520
|
+
return n < 10 ? '0' + n : n;
|
1521
|
+
}
|
1522
|
+
|
1523
|
+
return this.getUTCFullYear() + '-' +
|
1524
|
+
f(this.getUTCMonth() + 1) + '-' +
|
1525
|
+
f(this.getUTCDate()) + 'T' +
|
1526
|
+
f(this.getUTCHours()) + ':' +
|
1527
|
+
f(this.getUTCMinutes()) + ':' +
|
1528
|
+
f(this.getUTCSeconds()) + 'Z';
|
1529
|
+
};
|
1530
|
+
|
1531
|
+
You can provide an optional replacer method. It will be passed the
|
1532
|
+
key and value of each member, with this bound to the containing
|
1533
|
+
object. The value that is returned from your method will be
|
1534
|
+
serialized. If your method returns undefined, then the member will
|
1535
|
+
be excluded from the serialization.
|
1536
|
+
|
1537
|
+
If the replacer parameter is an array of strings, then it will be
|
1538
|
+
used to select the members to be serialized. It filters the results
|
1539
|
+
such that only members with keys listed in the replacer array are
|
1540
|
+
stringified.
|
1541
|
+
|
1542
|
+
Values that do not have JSON representations, such as undefined or
|
1543
|
+
functions, will not be serialized. Such values in objects will be
|
1544
|
+
dropped; in arrays they will be replaced with null. You can use
|
1545
|
+
a replacer function to replace those with JSON values.
|
1546
|
+
JSON.stringify(undefined) returns undefined.
|
1547
|
+
|
1548
|
+
The optional space parameter produces a stringification of the
|
1549
|
+
value that is filled with line breaks and indentation to make it
|
1550
|
+
easier to read.
|
1551
|
+
|
1552
|
+
If the space parameter is a non-empty string, then that string will
|
1553
|
+
be used for indentation. If the space parameter is a number, then
|
1554
|
+
the indentation will be that many spaces.
|
1555
|
+
|
1556
|
+
Example:
|
1557
|
+
|
1558
|
+
text = JSON.stringify(['e', {pluribus: 'unum'}]);
|
1559
|
+
// text is '["e",{"pluribus":"unum"}]'
|
1560
|
+
|
1561
|
+
|
1562
|
+
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
|
1563
|
+
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
|
1564
|
+
|
1565
|
+
text = JSON.stringify([new Date()], function (key, value) {
|
1566
|
+
return this[key] instanceof Date ?
|
1567
|
+
'Date(' + this[key] + ')' : value;
|
1568
|
+
});
|
1569
|
+
// text is '["Date(---current time---)"]'
|
1570
|
+
|
1571
|
+
|
1572
|
+
JSON.parse(text, reviver)
|
1573
|
+
This method parses a JSON text to produce an object or array.
|
1574
|
+
It can throw a SyntaxError exception.
|
1575
|
+
|
1576
|
+
The optional reviver parameter is a function that can filter and
|
1577
|
+
transform the results. It receives each of the keys and values,
|
1578
|
+
and its return value is used instead of the original value.
|
1579
|
+
If it returns what it received, then the structure is not modified.
|
1580
|
+
If it returns undefined then the member is deleted.
|
1581
|
+
|
1582
|
+
Example:
|
1583
|
+
|
1584
|
+
// Parse the text. Values that look like ISO date strings will
|
1585
|
+
// be converted to Date objects.
|
1586
|
+
|
1587
|
+
myData = JSON.parse(text, function (key, value) {
|
1588
|
+
var a;
|
1589
|
+
if (typeof value === 'string') {
|
1590
|
+
a =
|
1591
|
+
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
|
1592
|
+
if (a) {
|
1593
|
+
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
|
1594
|
+
+a[5], +a[6]));
|
1595
|
+
}
|
1596
|
+
}
|
1597
|
+
return value;
|
1598
|
+
});
|
1599
|
+
|
1600
|
+
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
|
1601
|
+
var d;
|
1602
|
+
if (typeof value === 'string' &&
|
1603
|
+
value.slice(0, 5) === 'Date(' &&
|
1604
|
+
value.slice(-1) === ')') {
|
1605
|
+
d = new Date(value.slice(5, -1));
|
1606
|
+
if (d) {
|
1607
|
+
return d;
|
1608
|
+
}
|
1609
|
+
}
|
1610
|
+
return value;
|
1611
|
+
});
|
1612
|
+
|
1613
|
+
|
1614
|
+
This is a reference implementation. You are free to copy, modify, or
|
1615
|
+
redistribute.
|
1616
|
+
*/
|
1617
|
+
|
1618
|
+
/*jslint evil: true, regexp: true */
|
1619
|
+
|
1620
|
+
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
1621
|
+
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
1622
|
+
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
1623
|
+
lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
1624
|
+
test, toJSON, toString, valueOf
|
1625
|
+
*/
|
1626
|
+
|
1627
|
+
|
1628
|
+
// Create a JSON object only if one does not already exist. We create the
|
1629
|
+
// methods in a closure to avoid creating global variables.
|
1630
|
+
|
1631
|
+
if (typeof JSON !== 'object') {
|
1632
|
+
JSON = {};
|
1633
|
+
}
|
1634
|
+
|
1635
|
+
(function () {
|
1636
|
+
'use strict';
|
1637
|
+
|
1638
|
+
function f(n) {
|
1639
|
+
// Format integers to have at least two digits.
|
1640
|
+
return n < 10 ? '0' + n : n;
|
1641
|
+
}
|
1642
|
+
|
1643
|
+
if (typeof Date.prototype.toJSON !== 'function') {
|
1644
|
+
|
1645
|
+
Date.prototype.toJSON = function () {
|
1646
|
+
|
1647
|
+
return isFinite(this.valueOf())
|
1648
|
+
? this.getUTCFullYear() + '-' +
|
1649
|
+
f(this.getUTCMonth() + 1) + '-' +
|
1650
|
+
f(this.getUTCDate()) + 'T' +
|
1651
|
+
f(this.getUTCHours()) + ':' +
|
1652
|
+
f(this.getUTCMinutes()) + ':' +
|
1653
|
+
f(this.getUTCSeconds()) + 'Z'
|
1654
|
+
: null;
|
1655
|
+
};
|
1656
|
+
|
1657
|
+
String.prototype.toJSON =
|
1658
|
+
Number.prototype.toJSON =
|
1659
|
+
Boolean.prototype.toJSON = function () {
|
1660
|
+
return this.valueOf();
|
1661
|
+
};
|
1662
|
+
}
|
1663
|
+
|
1664
|
+
var cx,
|
1665
|
+
escapable,
|
1666
|
+
gap,
|
1667
|
+
indent,
|
1668
|
+
meta,
|
1669
|
+
rep;
|
1670
|
+
|
1671
|
+
|
1672
|
+
function quote(string) {
|
1673
|
+
|
1674
|
+
// If the string contains no control characters, no quote characters, and no
|
1675
|
+
// backslash characters, then we can safely slap some quotes around it.
|
1676
|
+
// Otherwise we must also replace the offending characters with safe escape
|
1677
|
+
// sequences.
|
1678
|
+
|
1679
|
+
escapable.lastIndex = 0;
|
1680
|
+
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
1681
|
+
var c = meta[a];
|
1682
|
+
return typeof c === 'string'
|
1683
|
+
? c
|
1684
|
+
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
1685
|
+
}) + '"' : '"' + string + '"';
|
1686
|
+
}
|
1687
|
+
|
1688
|
+
|
1689
|
+
function str(key, holder) {
|
1690
|
+
|
1691
|
+
// Produce a string from holder[key].
|
1692
|
+
|
1693
|
+
var i, // The loop counter.
|
1694
|
+
k, // The member key.
|
1695
|
+
v, // The member value.
|
1696
|
+
length,
|
1697
|
+
mind = gap,
|
1698
|
+
partial,
|
1699
|
+
value = holder[key];
|
1700
|
+
|
1701
|
+
// If the value has a toJSON method, call it to obtain a replacement value.
|
1702
|
+
|
1703
|
+
if (value && typeof value === 'object' &&
|
1704
|
+
typeof value.toJSON === 'function') {
|
1705
|
+
value = value.toJSON(key);
|
1706
|
+
}
|
1707
|
+
|
1708
|
+
// If we were called with a replacer function, then call the replacer to
|
1709
|
+
// obtain a replacement value.
|
1710
|
+
|
1711
|
+
if (typeof rep === 'function') {
|
1712
|
+
value = rep.call(holder, key, value);
|
1713
|
+
}
|
1714
|
+
|
1715
|
+
// What happens next depends on the value's type.
|
1716
|
+
|
1717
|
+
switch (typeof value) {
|
1718
|
+
case 'string':
|
1719
|
+
return quote(value);
|
1720
|
+
|
1721
|
+
case 'number':
|
1722
|
+
|
1723
|
+
// JSON numbers must be finite. Encode non-finite numbers as null.
|
1724
|
+
|
1725
|
+
return isFinite(value) ? String(value) : 'null';
|
1726
|
+
|
1727
|
+
case 'boolean':
|
1728
|
+
case 'null':
|
1729
|
+
|
1730
|
+
// If the value is a boolean or null, convert it to a string. Note:
|
1731
|
+
// typeof null does not produce 'null'. The case is included here in
|
1732
|
+
// the remote chance that this gets fixed someday.
|
1733
|
+
|
1734
|
+
return String(value);
|
1735
|
+
|
1736
|
+
// If the type is 'object', we might be dealing with an object or an array or
|
1737
|
+
// null.
|
1738
|
+
|
1739
|
+
case 'object':
|
1740
|
+
|
1741
|
+
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
1742
|
+
// so watch out for that case.
|
1743
|
+
|
1744
|
+
if (!value) {
|
1745
|
+
return 'null';
|
1746
|
+
}
|
1747
|
+
|
1748
|
+
// Make an array to hold the partial results of stringifying this object value.
|
1749
|
+
|
1750
|
+
gap += indent;
|
1751
|
+
partial = [];
|
1752
|
+
|
1753
|
+
// Is the value an array?
|
1754
|
+
|
1755
|
+
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
1756
|
+
|
1757
|
+
// The value is an array. Stringify every element. Use null as a placeholder
|
1758
|
+
// for non-JSON values.
|
1759
|
+
|
1760
|
+
length = value.length;
|
1761
|
+
for (i = 0; i < length; i += 1) {
|
1762
|
+
partial[i] = str(i, value) || 'null';
|
1763
|
+
}
|
1764
|
+
|
1765
|
+
// Join all of the elements together, separated with commas, and wrap them in
|
1766
|
+
// brackets.
|
1767
|
+
|
1768
|
+
v = partial.length === 0
|
1769
|
+
? '[]'
|
1770
|
+
: gap
|
1771
|
+
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
|
1772
|
+
: '[' + partial.join(',') + ']';
|
1773
|
+
gap = mind;
|
1774
|
+
return v;
|
1775
|
+
}
|
1776
|
+
|
1777
|
+
// If the replacer is an array, use it to select the members to be stringified.
|
1778
|
+
|
1779
|
+
if (rep && typeof rep === 'object') {
|
1780
|
+
length = rep.length;
|
1781
|
+
for (i = 0; i < length; i += 1) {
|
1782
|
+
if (typeof rep[i] === 'string') {
|
1783
|
+
k = rep[i];
|
1784
|
+
v = str(k, value);
|
1785
|
+
if (v) {
|
1786
|
+
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
1787
|
+
}
|
1788
|
+
}
|
1789
|
+
}
|
1790
|
+
} else {
|
1791
|
+
|
1792
|
+
// Otherwise, iterate through all of the keys in the object.
|
1793
|
+
|
1794
|
+
for (k in value) {
|
1795
|
+
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
1796
|
+
v = str(k, value);
|
1797
|
+
if (v) {
|
1798
|
+
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
1799
|
+
}
|
1800
|
+
}
|
1801
|
+
}
|
1802
|
+
}
|
1803
|
+
|
1804
|
+
// Join all of the member texts together, separated with commas,
|
1805
|
+
// and wrap them in braces.
|
1806
|
+
|
1807
|
+
v = partial.length === 0
|
1808
|
+
? '{}'
|
1809
|
+
: gap
|
1810
|
+
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
|
1811
|
+
: '{' + partial.join(',') + '}';
|
1812
|
+
gap = mind;
|
1813
|
+
return v;
|
1814
|
+
}
|
1815
|
+
}
|
1816
|
+
|
1817
|
+
// If the JSON object does not yet have a stringify method, give it one.
|
1818
|
+
|
1819
|
+
if (typeof JSON.stringify !== 'function') {
|
1820
|
+
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
1821
|
+
meta = { // table of character substitutions
|
1822
|
+
'\b': '\\b',
|
1823
|
+
'\t': '\\t',
|
1824
|
+
'\n': '\\n',
|
1825
|
+
'\f': '\\f',
|
1826
|
+
'\r': '\\r',
|
1827
|
+
'"' : '\\"',
|
1828
|
+
'\\': '\\\\'
|
1829
|
+
};
|
1830
|
+
JSON.stringify = function (value, replacer, space) {
|
1831
|
+
|
1832
|
+
// The stringify method takes a value and an optional replacer, and an optional
|
1833
|
+
// space parameter, and returns a JSON text. The replacer can be a function
|
1834
|
+
// that can replace values, or an array of strings that will select the keys.
|
1835
|
+
// A default replacer method can be provided. Use of the space parameter can
|
1836
|
+
// produce text that is more easily readable.
|
1837
|
+
|
1838
|
+
var i;
|
1839
|
+
gap = '';
|
1840
|
+
indent = '';
|
1841
|
+
|
1842
|
+
// If the space parameter is a number, make an indent string containing that
|
1843
|
+
// many spaces.
|
1844
|
+
|
1845
|
+
if (typeof space === 'number') {
|
1846
|
+
for (i = 0; i < space; i += 1) {
|
1847
|
+
indent += ' ';
|
1848
|
+
}
|
1849
|
+
|
1850
|
+
// If the space parameter is a string, it will be used as the indent string.
|
1851
|
+
|
1852
|
+
} else if (typeof space === 'string') {
|
1853
|
+
indent = space;
|
1854
|
+
}
|
1855
|
+
|
1856
|
+
// If there is a replacer, it must be a function or an array.
|
1857
|
+
// Otherwise, throw an error.
|
1858
|
+
|
1859
|
+
rep = replacer;
|
1860
|
+
if (replacer && typeof replacer !== 'function' &&
|
1861
|
+
(typeof replacer !== 'object' ||
|
1862
|
+
typeof replacer.length !== 'number')) {
|
1863
|
+
throw new Error('JSON.stringify');
|
1864
|
+
}
|
1865
|
+
|
1866
|
+
// Make a fake root object containing our value under the key of ''.
|
1867
|
+
// Return the result of stringifying the value.
|
1868
|
+
|
1869
|
+
return str('', {'': value});
|
1870
|
+
};
|
1871
|
+
}
|
1872
|
+
|
1873
|
+
|
1874
|
+
// If the JSON object does not yet have a parse method, give it one.
|
1875
|
+
|
1876
|
+
if (typeof JSON.parse !== 'function') {
|
1877
|
+
cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
1878
|
+
JSON.parse = function (text, reviver) {
|
1879
|
+
|
1880
|
+
// The parse method takes a text and an optional reviver function, and returns
|
1881
|
+
// a JavaScript value if the text is a valid JSON text.
|
1882
|
+
|
1883
|
+
var j;
|
1884
|
+
|
1885
|
+
function walk(holder, key) {
|
1886
|
+
|
1887
|
+
// The walk method is used to recursively walk the resulting structure so
|
1888
|
+
// that modifications can be made.
|
1889
|
+
|
1890
|
+
var k, v, value = holder[key];
|
1891
|
+
if (value && typeof value === 'object') {
|
1892
|
+
for (k in value) {
|
1893
|
+
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
1894
|
+
v = walk(value, k);
|
1895
|
+
if (v !== undefined) {
|
1896
|
+
value[k] = v;
|
1897
|
+
} else {
|
1898
|
+
delete value[k];
|
1899
|
+
}
|
1900
|
+
}
|
1901
|
+
}
|
1902
|
+
}
|
1903
|
+
return reviver.call(holder, key, value);
|
1904
|
+
}
|
1905
|
+
|
1906
|
+
|
1907
|
+
// Parsing happens in four stages. In the first stage, we replace certain
|
1908
|
+
// Unicode characters with escape sequences. JavaScript handles many characters
|
1909
|
+
// incorrectly, either silently deleting them, or treating them as line endings.
|
1910
|
+
|
1911
|
+
text = String(text);
|
1912
|
+
cx.lastIndex = 0;
|
1913
|
+
if (cx.test(text)) {
|
1914
|
+
text = text.replace(cx, function (a) {
|
1915
|
+
return '\\u' +
|
1916
|
+
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
1917
|
+
});
|
1918
|
+
}
|
1919
|
+
|
1920
|
+
// In the second stage, we run the text against regular expressions that look
|
1921
|
+
// for non-JSON patterns. We are especially concerned with '()' and 'new'
|
1922
|
+
// because they can cause invocation, and '=' because it can cause mutation.
|
1923
|
+
// But just to be safe, we want to reject all unexpected forms.
|
1924
|
+
|
1925
|
+
// We split the second stage into 4 regexp operations in order to work around
|
1926
|
+
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
1927
|
+
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
|
1928
|
+
// replace all simple value tokens with ']' characters. Third, we delete all
|
1929
|
+
// open brackets that follow a colon or comma or that begin the text. Finally,
|
1930
|
+
// we look to see that the remaining characters are only whitespace or ']' or
|
1931
|
+
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
|
1932
|
+
|
1933
|
+
if (/^[\],:{}\s]*$/
|
1934
|
+
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
|
1935
|
+
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
|
1936
|
+
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
1937
|
+
|
1938
|
+
// In the third stage we use the eval function to compile the text into a
|
1939
|
+
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
|
1940
|
+
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
1941
|
+
// in parens to eliminate the ambiguity.
|
1942
|
+
|
1943
|
+
j = eval('(' + text + ')');
|
1944
|
+
|
1945
|
+
// In the optional fourth stage, we recursively walk the new structure, passing
|
1946
|
+
// each name/value pair to a reviver function for possible transformation.
|
1947
|
+
|
1948
|
+
return typeof reviver === 'function'
|
1949
|
+
? walk({'': j}, '')
|
1950
|
+
: j;
|
1951
|
+
}
|
1952
|
+
|
1953
|
+
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
1954
|
+
|
1955
|
+
throw new SyntaxError('JSON.parse');
|
1956
|
+
};
|
1957
|
+
}
|
1958
|
+
}());
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*!
|
2
|
-
* algoliasearch 2.
|
2
|
+
* algoliasearch 2.5.0
|
3
3
|
* https://github.com/algolia/algoliasearch-client-js
|
4
4
|
* Copyright 2014 Algolia SAS; Licensed MIT
|
5
5
|
*/
|
6
6
|
|
7
|
-
function AlgoliaExplainResults(a,b,c){function d(a,b){var c=[];if("object"==typeof a&&"matchedWords"in a&&"value"in a){for(var e=!1,f=0;f<a.matchedWords.length;++f){var g=a.matchedWords[f];g in b||(b[g]=1,e=!0)}e&&c.push(a.value)}else if("[object Array]"===Object.prototype.toString.call(a))for(var h=0;h<a.length;++h){var i=d(a[h],b);c=c.concat(i)}else if("object"==typeof a)for(var j in a)a.hasOwnProperty(j)&&(c=c.concat(d(a[j],b)));return c}function e(a,b,c){var f=a._highlightResult||a;if(-1===c.indexOf("."))return c in f?d(f[c],b):[];for(var g=c.split("."),h=f,i=0;i<g.length;++i){if("[object Array]"===Object.prototype.toString.call(h)){for(var j=[],k=0;k<h.length;++k)j=j.concat(e(h[k],b,g.slice(i).join(".")));return j}if(!(g[i]in h))return[];h=h[g[i]]}return d(h,b)}var f={},g={},h=e(a,g,b);if(f.title=h.length>0?h[0]:"",f.subtitles=[],"undefined"!=typeof c)for(var i=0;i<c.length;++i)for(var j=e(a,g,c[i]),k=0;k<j.length;++k)f.subtitles.push({attr:c[i],value:j[k]});return f}var ALGOLIA_VERSION="2.4.5",AlgoliaSearch=function(a,b,c,d,e){this.applicationID=a,this.apiKey=b,this._isUndefined(e)&&(e=[a+"-1.algolia.io",a+"-2.algolia.io",a+"-3.algolia.io"]),this.hosts=[];for(var f=0;f<e.length;++f)Math.random()>.5&&this.hosts.reverse(),this._isUndefined(c)||null==c?this.hosts.push(("https:"==document.location.protocol?"https":"http")+"://"+e[f]):"https"===c||"HTTPS"===c?this.hosts.push("https://"+e[f]):this.hosts.push("http://"+e[f]);Math.random()>.5&&this.hosts.reverse(),(this._isUndefined(d)||d)&&this._jsonRequest({method:"GET",url:"/1/isalive"}),this.extraHeaders=[]};AlgoliaSearch.prototype={deleteIndex:function(a,b){this._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(a),callback:b})},moveIndex:function(a,b,c){var d={operation:"move",destination:b};this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(a)+"/operation",body:d,callback:c})},copyIndex:function(a,b,c){var d={operation:"copy",destination:b};this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(a)+"/operation",body:d,callback:c})},getLogs:function(a,b,c){this._isUndefined(b)&&(b=0),this._isUndefined(c)&&(c=10),this._jsonRequest({method:"GET",url:"/1/logs?offset="+b+"&length="+c,callback:a})},listIndexes:function(a){this._jsonRequest({method:"GET",url:"/1/indexes/",callback:a})},initIndex:function(a){return new this.Index(this,a)},listUserKeys:function(a){this._jsonRequest({method:"GET",url:"/1/keys",callback:a})},getUserKeyACL:function(a,b){this._jsonRequest({method:"GET",url:"/1/keys/"+a,callback:b})},deleteUserKey:function(a,b){this._jsonRequest({method:"DELETE",url:"/1/keys/"+a,callback:b})},addUserKey:function(a,b){var c={};c.acl=a,this._jsonRequest({method:"POST",url:"/1/keys",body:c,callback:b})},addUserKeyWithValidity:function(a,b,c,d,e){var f=this,g={};g.acl=a,g.validity=b,g.maxQueriesPerIPPerHour=c,g.maxHitsPerQuery=d,this._jsonRequest({method:"POST",url:"/1/indexes/"+f.indexName+"/keys",body:g,callback:e})},setSecurityTags:function(a){if("[object Array]"===Object.prototype.toString.call(a)){for(var b=[],c=0;c<a.length;++c)if("[object Array]"===Object.prototype.toString.call(a[c])){for(var d=[],e=0;e<a[c].length;++e)d.push(a[c][e]);b.push("("+d.join(",")+")")}else b.push(a[c]);a=b.join(",")}this.setExtraHeader("X-Algolia-TagFilters",a)},setUserToken:function(a){this.setExtraHeader("X-Algolia-UserToken",a)},startQueriesBatch:function(){this.batch=[]},addQueryInBatch:function(a,b,c){var d="query="+encodeURIComponent(b);this._isUndefined(c)||null==c||(d=this._getSearchParams(c,d)),this.batch.push({indexName:a,params:d})},clearCache:function(){this.cache={}},sendQueriesBatch:function(a,b){for(var c=this,d={requests:[],apiKey:this.apiKey,appID:this.applicationID},e=0;e<c.batch.length;++e)d.requests.push(c.batch[e]);if(window.clearTimeout(c.onDelayTrigger),!this._isUndefined(b)&&null!=b&&b>0){var f=window.setTimeout(function(){c._sendQueriesBatch(d,a)},b);c.onDelayTrigger=f}else this._sendQueriesBatch(d,a)},Index:function(a,b){this.indexName=b,this.as=a,this.typeAheadArgs=null,this.typeAheadValueOption=null},setExtraHeader:function(a,b){this.extraHeaders.push({key:a,value:b})},_sendQueriesBatch:function(a,b){this._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/*/queries",body:a,callback:b})},_jsonRequest:function(a){var b=this,c=a.callback,d=null,e=a.url;if(this._isUndefined(a.body)||(e=a.url+"_body_"+JSON.stringify(a.body)),!this._isUndefined(a.cache)&&(d=a.cache,!this._isUndefined(d[e])))return this._isUndefined(c)||c(!0,d[e]),void 0;var f=function(g){var h=0;return b._isUndefined(g)||(h=g),b.hosts.length<=h?(b._isUndefined(c)||c(!1,{message:"Cannot contact server"}),void 0):(a.callback=function(g,i,j,k){i||b._isUndefined(k)||console.log("Error: "+k.message),i&&!b._isUndefined(a.cache)&&(d[e]=k),!i&&g&&h+1<b.hosts.length?f(h+1):b._isUndefined(c)||c(i,k)},a.hostname=b.hosts[h],b._jsonRequestByHost(a),void 0)};f()},_jsonRequestByHost:function(a){var b=null,c=this;this._isUndefined(a.body)||(b=JSON.stringify(a.body));var d=a.hostname+a.url,e=null;if(e=new XMLHttpRequest,"withCredentials"in e){e.open(a.method,d,!0),e.setRequestHeader("X-Algolia-API-Key",this.apiKey),e.setRequestHeader("X-Algolia-Application-Id",this.applicationID);for(var f=0;f<this.extraHeaders.length;++f)e.setRequestHeader(this.extraHeaders[f].key,this.extraHeaders[f].value);null!=b&&e.setRequestHeader("Content-type","application/json")}else"undefined"!=typeof XDomainRequest?(e=new XDomainRequest,e.open(a.method,d)):console.log("your browser is too old to support CORS requests");e.send(b),e.onload=function(b){if(c._isUndefined(b)||null==b.target)a.callback(!1,!0,b,JSON.parse(e.responseText));else{var d=0===b.target.status||503===b.target.status,f=200===b.target.status||201===b.target.status;a.callback(d,f,b.target,null!=b.target.response?JSON.parse(b.target.response):null)}},e.onerror=function(){a.callback(!0,!1,null,{message:"Could not connect to Host"})}},_getSearchParams:function(a,b){if(this._isUndefined(a)||null==a)return b;for(var c in a)null!=c&&a.hasOwnProperty(c)&&(b+=0===b.length?"?":"&",b+=c+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(a[c])?JSON.stringify(a[c]):a[c]));return b},_isUndefined:function(a){return void 0===a},applicationID:null,apiKey:null,hosts:[],cache:{},extraHeaders:[]},AlgoliaSearch.prototype.Index.prototype={clearCache:function(){this.cache={}},addObject:function(a,b,c){var d=this;this.as._isUndefined(c)?this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(d.indexName),body:a,callback:b}):this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(d.indexName)+"/"+encodeURIComponent(c),body:a,callback:b})},addObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"addObject",body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},getObject:function(a,b,c){var d=this,e="";if(!this.as._isUndefined(c)){e="?attributes=";for(var f=0;f<c.length;++f)0!==f&&(e+=","),e+=c[f]}this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(d.indexName)+"/"+encodeURIComponent(a)+e,callback:b})},partialUpdateObject:function(a,b){var c=this;this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a.objectID)+"/partial",body:a,callback:b})},partialUpdateObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"partialUpdateObject",objectID:a[e].objectID,body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},saveObject:function(a,b){var c=this;this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a.objectID),body:a,callback:b})},saveObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"updateObject",objectID:a[e].objectID,body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},deleteObject:function(a,b){if(null==a||0===a.length)return b(!1,{message:"empty objectID"}),void 0;var c=this;this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a),callback:b})},search:function(a,b,c,d){var e=this,f="query="+encodeURIComponent(a);if(this.as._isUndefined(c)||null==c||(f=this.as._getSearchParams(c,f)),window.clearTimeout(e.onDelayTrigger),!this.as._isUndefined(d)&&null!=d&&d>0){var g=window.setTimeout(function(){e._search(f,b)},d);e.onDelayTrigger=g}else this._search(f,b)},browse:function(a,b,c){var d=this,e="?page="+a;_.isUndefined(c)||(e+="&hitsPerPage="+c),this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(d.indexName)+"/browse"+e,callback:b})},ttAdapter:function(a){var b=this;return function(c,d){b.search(c,function(a,b){a&&d(b.hits)},a)}},waitTask:function(a,b){var c=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/task/"+a,callback:function(d,e){d?"published"===e.status?b(!0,e):setTimeout(function(){c.waitTask(a,b)},100):b(!1,e)}})},clearIndex:function(a){var b=this;this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/clear",callback:a})},getSettings:function(a){var b=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/settings",callback:a})},setSettings:function(a,b){var c=this;this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/settings",body:a,callback:b})},listUserKeys:function(a){var b=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/keys",callback:a})},getUserKeyACL:function(a,b){var c=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys/"+a,callback:b})},deleteUserKey:function(a,b){var c=this;this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys/"+a,callback:b})},addUserKey:function(a,b){var c=this,d={};d.acl=a,this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys",body:d,callback:b})},addUserKeyWithValidity:function(a,b,c,d,e){var f=this,g={};g.acl=a,g.validity=b,g.maxQueriesPerIPPerHour=c,g.maxHitsPerQuery=d,this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(f.indexName)+"/keys",body:g,callback:e})},_search:function(a,b){this.as._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/query",body:{params:a,apiKey:this.as.apiKey,appID:this.as.applicationID},callback:b})},as:null,indexName:null,cache:{},typeAheadArgs:null,typeAheadValueOption:null,emptyConstructor:function(){}},function(){var a,b=function(a){a=a||{};for(var b=1;b<arguments.length;b++)if(arguments[b])for(var c in arguments[b])arguments[b].hasOwnProperty(c)&&(a[c]=arguments[b][c]);return a};window.AlgoliaSearchHelper=function(c,d,e){var f={facets:[],disjunctiveFacets:[],hitsPerPage:20};this.init(c,d,b({},f,e)),a=this},AlgoliaSearchHelper.prototype={init:function(a,b,c){this.client=a,this.index=b,this.options=c,this.page=0,this.refinements={},this.disjunctiveRefinements={}},search:function(a,b,c){this.q=a,this.searchCallback=b,this.searchParams=c||{},this.page=this.page||0,this.refinements=this.refinements||{},this.disjunctiveRefinements=this.disjunctiveRefinements||{},this._search()},toggleRefine:function(a,b){for(var c=0;c<this.options.facets.length;++c)if(this.options.facets[c]==a){var d=a+":"+b;return this.refinements[d]=!this.refinements[d],this.page=0,this._search(),!0}this.disjunctiveRefinements[a]=this.disjunctiveRefinements[a]||{};for(var e=0;e<this.options.disjunctiveFacets.length;++e)if(this.options.disjunctiveFacets[e]==a)return this.disjunctiveRefinements[a][b]=!this.disjunctiveRefinements[a][b],this.page=0,this._search(),!0;return!1},isRefined:function(a,b){var c=a+":"+b;return this.refinements[c]?!0:this.disjunctiveRefinements[a]&&this.disjunctiveRefinements[a][b]?!0:!1},nextPage:function(){this._gotoPage(this.page+1)},previousPage:function(){this.page>0&&this._gotoPage(this.page-1)},_gotoPage:function(a){this.page=a,this._search()},_search:function(){this.client.startQueriesBatch(),this.client.addQueryInBatch(this.index,this.q,this._getHitsSearchParams());for(var b=0;b<this.options.disjunctiveFacets.length;++b)this.client.addQueryInBatch(this.index,this.q,this._getDisjunctiveFacetSearchParams(this.options.disjunctiveFacets[b]));this.client.sendQueriesBatch(function(b,c){if(!b)return a.searchCallback(!1,c),void 0;var d=c.results[0];d.disjunctiveFacets={};for(var e=1;e<c.results.length;++e)for(var f in c.results[e].facets)if(d.disjunctiveFacets[f]=c.results[e].facets[f],a.disjunctiveRefinements[f])for(var g in a.disjunctiveRefinements[f])!d.disjunctiveFacets[f][g]&&a.disjunctiveRefinements[f][g]&&(d.disjunctiveFacets[f][g]=0);a.searchCallback(!0,d)})},_getHitsSearchParams:function(){return b({},this.searchParams,{hitsPerPage:this.options.hitsPerPage,page:this.page,facets:this.options.facets,facetFilters:this._getFacetFilters()})},_getDisjunctiveFacetSearchParams:function(a){return b({},this.searchParams,{hitsPerPage:1,page:0,facets:a,facetFilters:this._getFacetFilters(a)})},_getFacetFilters:function(a){var b=[];for(var c in this.refinements)this.refinements[c]&&b.push(c);for(var d in this.disjunctiveRefinements)if(d!=a){var e=[];for(var f in this.disjunctiveRefinements[d])this.disjunctiveRefinements[d][f]&&e.push(d+":"+f);e.length>0&&b.push(e)}return b}}}();
|
7
|
+
function AlgoliaExplainResults(a,b,c){function d(a,b){var c=[];if("object"==typeof a&&"matchedWords"in a&&"value"in a){for(var e=!1,f=0;f<a.matchedWords.length;++f){var g=a.matchedWords[f];g in b||(b[g]=1,e=!0)}e&&c.push(a.value)}else if("[object Array]"===Object.prototype.toString.call(a))for(var h=0;h<a.length;++h){var i=d(a[h],b);c=c.concat(i)}else if("object"==typeof a)for(var j in a)a.hasOwnProperty(j)&&(c=c.concat(d(a[j],b)));return c}function e(a,b,c){var f=a._highlightResult||a;if(-1===c.indexOf("."))return c in f?d(f[c],b):[];for(var g=c.split("."),h=f,i=0;i<g.length;++i){if("[object Array]"===Object.prototype.toString.call(h)){for(var j=[],k=0;k<h.length;++k)j=j.concat(e(h[k],b,g.slice(i).join(".")));return j}if(!(g[i]in h))return[];h=h[g[i]]}return d(h,b)}var f={},g={},h=e(a,g,b);if(f.title=h.length>0?h[0]:"",f.subtitles=[],"undefined"!=typeof c)for(var i=0;i<c.length;++i)for(var j=e(a,g,c[i]),k=0;k<j.length;++k)f.subtitles.push({attr:c[i],value:j[k]});return f}var ALGOLIA_VERSION="2.5.0",AlgoliaSearch=function(a,b,c,d,e){var f=this;this.applicationID=a,this.apiKey=b,this._isUndefined(e)&&(e=[a+"-1.algolia.io",a+"-2.algolia.io",a+"-3.algolia.io"]),this.hosts=[];for(var g=0;g<e.length;++g)Math.random()>.5&&this.hosts.reverse(),this._isUndefined(c)||null==c?this.hosts.push(("https:"==document.location.protocol?"https":"http")+"://"+e[g]):"https"===c||"HTTPS"===c?this.hosts.push("https://"+e[g]):this.hosts.push("http://"+e[g]);Math.random()>.5&&this.hosts.reverse(),this.jsonp=null,this.jsonpWait=0,this._jsonRequest({method:"GET",url:"/1/isalive",callback:function(a){f.jsonp=!a}}),this.extraHeaders=[]};AlgoliaSearch.prototype={deleteIndex:function(a,b){this._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(a),callback:b})},moveIndex:function(a,b,c){var d={operation:"move",destination:b};this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(a)+"/operation",body:d,callback:c})},copyIndex:function(a,b,c){var d={operation:"copy",destination:b};this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(a)+"/operation",body:d,callback:c})},getLogs:function(a,b,c){this._isUndefined(b)&&(b=0),this._isUndefined(c)&&(c=10),this._jsonRequest({method:"GET",url:"/1/logs?offset="+b+"&length="+c,callback:a})},listIndexes:function(a){this._jsonRequest({method:"GET",url:"/1/indexes/",callback:a})},initIndex:function(a){return new this.Index(this,a)},listUserKeys:function(a){this._jsonRequest({method:"GET",url:"/1/keys",callback:a})},getUserKeyACL:function(a,b){this._jsonRequest({method:"GET",url:"/1/keys/"+a,callback:b})},deleteUserKey:function(a,b){this._jsonRequest({method:"DELETE",url:"/1/keys/"+a,callback:b})},addUserKey:function(a,b){var c={};c.acl=a,this._jsonRequest({method:"POST",url:"/1/keys",body:c,callback:b})},addUserKeyWithValidity:function(a,b,c,d,e){var f=this,g={};g.acl=a,g.validity=b,g.maxQueriesPerIPPerHour=c,g.maxHitsPerQuery=d,this._jsonRequest({method:"POST",url:"/1/indexes/"+f.indexName+"/keys",body:g,callback:e})},setSecurityTags:function(a){if("[object Array]"===Object.prototype.toString.call(a)){for(var b=[],c=0;c<a.length;++c)if("[object Array]"===Object.prototype.toString.call(a[c])){for(var d=[],e=0;e<a[c].length;++e)d.push(a[c][e]);b.push("("+d.join(",")+")")}else b.push(a[c]);a=b.join(",")}this.tagFilters=a},setUserToken:function(a){this.userToken=a},startQueriesBatch:function(){this.batch=[]},addQueryInBatch:function(a,b,c){var d="query="+encodeURIComponent(b);this._isUndefined(c)||null==c||(d=this._getSearchParams(c,d)),this.batch.push({indexName:a,params:d})},clearCache:function(){this.cache={}},sendQueriesBatch:function(a,b){var c=this,d={requests:[],apiKey:this.apiKey,appID:this.applicationID};this.userToken&&(d["X-Algolia-UserToken"]=this.userToken),this.tagFilters&&(d["X-Algolia-TagFilters"]=this.tagFilters);for(var e=0;e<c.batch.length;++e)d.requests.push(c.batch[e]);if(window.clearTimeout(c.onDelayTrigger),!this._isUndefined(b)&&null!=b&&b>0){var f=window.setTimeout(function(){c._sendQueriesBatch(d,a)},b);c.onDelayTrigger=f}else this._sendQueriesBatch(d,a)},Index:function(a,b){this.indexName=b,this.as=a,this.typeAheadArgs=null,this.typeAheadValueOption=null},setExtraHeader:function(a,b){this.extraHeaders.push({key:a,value:b})},_sendQueriesBatch:function(a,b){if(null==this.jsonp){var c=this;return this._waitReady(function(){c._sendQueriesBatch(a,b)}),void 0}if(this.jsonp){for(var d="",e=0;e<a.requests.length;++e){var f="/1/indexes/"+encodeURIComponent(a.requests[e].indexName)+"?"+a.requests[e].params;d+=e+"="+encodeURIComponent(f)+"&"}this._jsonRequest({cache:this.cache,method:"GET",jsonp:!0,url:"/1/indexes/*",body:{params:d},callback:b})}else this._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/*/queries",body:a,callback:b})},_jsonRequest:function(a){var b=this,c=a.callback,d=null,e=a.url;if(this._isUndefined(a.body)||(e=a.url+"_body_"+JSON.stringify(a.body)),!this._isUndefined(a.cache)&&(d=a.cache,!this._isUndefined(d[e])))return this._isUndefined(c)||c(!0,d[e]),void 0;var f=function(g){var h=0;return b._isUndefined(g)||(h=g),b.hosts.length<=h?(b._isUndefined(c)||c(!1,{message:"Cannot contact server"}),void 0):(a.callback=function(g,i,j,k){i||b._isUndefined(k)||window.console&&console.log("Error: "+k.message),i&&!b._isUndefined(a.cache)&&(d[e]=k),!i&&g&&h+1<b.hosts.length?f(h+1):b._isUndefined(c)||c(i,k)},a.hostname=b.hosts[h],b._jsonRequestByHost(a),void 0)};f()},_jsonRequestByHost:function(a){var b=this,c=a.hostname+a.url;if(this.jsonp){if(!a.jsonp)return a.callback(!0,!1,null,{message:"Method "+a.method+" "+c+" is not supported by JSONP."}),void 0;this.jsonpCounter=this.jsonpCounter||0,this.jsonpCounter+=1;var d="algoliaJSONP_"+this.jsonpCounter;window[d]=function(b){a.callback(!1,!0,null,b);try{delete window[d]}catch(c){window[d]=void 0}};var e=document.createElement("script");e.type="text/javascript",e.src=c+"?callback="+d+","+this.applicationID+","+this.apiKey,a["X-Algolia-TagFilters"]&&(e.src+="&X-Algolia-TagFilters="+a["X-Algolia-TagFilters"]),a["X-Algolia-UserToken"]&&(e.src+="&X-Algolia-UserToken="+a["X-Algolia-UserToken"]),a.body&&a.body.params&&(e.src+="&"+a.body.params);var f=document.getElementsByTagName("head")[0];e.onerror=function(){a.callback(!0,!1,null,{message:"Failed to load JSONP script."}),f.removeChild(e);try{delete window[d]}catch(b){window[d]=void 0}};var g=!1;e.onload=e.onreadystatechange=function(){if(!(g||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState)){if(g=!0,"undefined"==typeof window[d+"_loaded"]){a.callback(!0,!1,null,{message:"Failed to load JSONP script."});try{delete window[d]}catch(b){window[d]=void 0}}else try{delete window[d+"_loaded"]}catch(b){window[d+"_loaded"]=void 0}e.onload=e.onreadystatechange=null,f.removeChild(e)}},f.appendChild(e)}else{var h=null;this._isUndefined(a.body)||(h=JSON.stringify(a.body));var i=window.XMLHttpRequest?new XMLHttpRequest:{};if("withCredentials"in i){i.open(a.method,c,!0),i.setRequestHeader("X-Algolia-API-Key",this.apiKey),i.setRequestHeader("X-Algolia-Application-Id",this.applicationID);for(var j=0;j<this.extraHeaders.length;++j)i.setRequestHeader(this.extraHeaders[j].key,this.extraHeaders[j].value);null!=h&&i.setRequestHeader("Content-type","application/json")}else{if("undefined"==typeof XDomainRequest)return window.console&&console.log("Your browser is too old to support CORS requests"),a.callback(!1,!1,null,{message:"CORS not supported"}),void 0;i=new XDomainRequest,i.open(a.method,c)}i.send(h),i.onload=function(c){if(b._isUndefined(c)||null==c.target)a.callback(!1,!0,c,JSON.parse(i.responseText));else{var d=0===c.target.status||503===c.target.status,e=200===c.target.status||201===c.target.status;a.callback(d,e,c.target,null!=c.target.response?JSON.parse(c.target.response):null)}},i.onerror=function(b){a.callback(!0,!1,null,{message:"Could not connect to host",error:b})}}},_waitReady:function(a){null==this.jsonp&&(this.jsonpWait+=100,this.jsonpWait>2e3&&(this.jsonp=!0),setTimeout(a,100))},_getSearchParams:function(a,b){if(this._isUndefined(a)||null==a)return b;for(var c in a)null!=c&&a.hasOwnProperty(c)&&(b+=0===b.length?"?":"&",b+=c+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(a[c])?JSON.stringify(a[c]):a[c]));return b},_isUndefined:function(a){return void 0===a},applicationID:null,apiKey:null,tagFilters:null,userToken:null,hosts:[],cache:{},extraHeaders:[]},AlgoliaSearch.prototype.Index.prototype={clearCache:function(){this.cache={}},addObject:function(a,b,c){var d=this;this.as._isUndefined(c)?this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(d.indexName),body:a,callback:b}):this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(d.indexName)+"/"+encodeURIComponent(c),body:a,callback:b})},addObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"addObject",body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},getObject:function(a,b,c){if(null==this.as.jsonp){var d=this;return this.as._waitReady(function(){d.getObject(a,b,c)}),void 0}var e=this,f="";if(!this.as._isUndefined(c)){f="?attributes=";for(var g=0;g<c.length;++g)0!==g&&(f+=","),f+=c[g]}this.as._jsonRequest({method:"GET",jsonp:!0,url:"/1/indexes/"+encodeURIComponent(e.indexName)+"/"+encodeURIComponent(a)+f,callback:b})},partialUpdateObject:function(a,b){var c=this;this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a.objectID)+"/partial",body:a,callback:b})},partialUpdateObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"partialUpdateObject",objectID:a[e].objectID,body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},saveObject:function(a,b){var c=this;this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a.objectID),body:a,callback:b})},saveObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"updateObject",objectID:a[e].objectID,body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},deleteObject:function(a,b){if(null==a||0===a.length)return b(!1,{message:"empty objectID"}),void 0;var c=this;this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a),callback:b})},search:function(a,b,c,d){var e=this,f="query="+encodeURIComponent(a);if(this.as._isUndefined(c)||null==c||(f=this.as._getSearchParams(c,f)),window.clearTimeout(e.onDelayTrigger),!this.as._isUndefined(d)&&null!=d&&d>0){var g=window.setTimeout(function(){e._search(f,b)},d);e.onDelayTrigger=g}else this._search(f,b)},browse:function(a,b,c){var d=this,e="?page="+a;_.isUndefined(c)||(e+="&hitsPerPage="+c),this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(d.indexName)+"/browse"+e,callback:b})},ttAdapter:function(a){var b=this;return function(c,d){b.search(c,function(a,b){a&&d(b.hits)},a)}},waitTask:function(a,b){var c=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/task/"+a,callback:function(d,e){d?"published"===e.status?b(!0,e):setTimeout(function(){c.waitTask(a,b)},100):b(!1,e)}})},clearIndex:function(a){var b=this;this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/clear",callback:a})},getSettings:function(a){var b=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/settings",callback:a})},setSettings:function(a,b){var c=this;this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/settings",body:a,callback:b})},listUserKeys:function(a){var b=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/keys",callback:a})},getUserKeyACL:function(a,b){var c=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys/"+a,callback:b})},deleteUserKey:function(a,b){var c=this;this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys/"+a,callback:b})},addUserKey:function(a,b){var c=this,d={};d.acl=a,this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys",body:d,callback:b})},addUserKeyWithValidity:function(a,b,c,d,e){var f=this,g={};g.acl=a,g.validity=b,g.maxQueriesPerIPPerHour=c,g.maxHitsPerQuery=d,this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(f.indexName)+"/keys",body:g,callback:e})},_search:function(a,b){if(null==this.as.jsonp){var c=this;return this.as._waitReady(function(){c._search(a,b)}),void 0}var d={params:a,apiKey:this.as.apiKey,appID:this.as.applicationID};this.as.tagFilters&&(d["X-Algolia-TagFilters"]=this.as.tagFilters),this.as.userToken&&(d["X-Algolia-UserToken"]=this.as.userToken),this.as.jsonp?this.as._jsonRequest({cache:this.cache,method:"GET",jsonp:!0,url:"/1/indexes/"+encodeURIComponent(this.indexName),body:d,callback:b}):this.as._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/query",body:d,callback:b})},as:null,indexName:null,cache:{},typeAheadArgs:null,typeAheadValueOption:null,emptyConstructor:function(){}},function(){var a=function(a){a=a||{};for(var b=1;b<arguments.length;b++)if(arguments[b])for(var c in arguments[b])arguments[b].hasOwnProperty(c)&&(a[c]=arguments[b][c]);return a};window.AlgoliaSearchHelper=function(b,c,d){var e={facets:[],disjunctiveFacets:[],hitsPerPage:20};this.init(b,c,a({},e,d))},AlgoliaSearchHelper.prototype={init:function(a,b,c){this.client=a,this.index=b,this.options=c,this.page=0,this.refinements={},this.disjunctiveRefinements={}},search:function(a,b,c){this.q=a,this.searchCallback=b,this.searchParams=c||{},this.page=this.page||0,this.refinements=this.refinements||{},this.disjunctiveRefinements=this.disjunctiveRefinements||{},this._search()},toggleRefine:function(a,b){for(var c=0;c<this.options.facets.length;++c)if(this.options.facets[c]==a){var d=a+":"+b;return this.refinements[d]=!this.refinements[d],this.page=0,this._search(),!0}this.disjunctiveRefinements[a]=this.disjunctiveRefinements[a]||{};for(var e=0;e<this.options.disjunctiveFacets.length;++e)if(this.options.disjunctiveFacets[e]==a)return this.disjunctiveRefinements[a][b]=!this.disjunctiveRefinements[a][b],this.page=0,this._search(),!0;return!1},isRefined:function(a,b){var c=a+":"+b;return this.refinements[c]?!0:this.disjunctiveRefinements[a]&&this.disjunctiveRefinements[a][b]?!0:!1},nextPage:function(){this._gotoPage(this.page+1)},previousPage:function(){this.page>0&&this._gotoPage(this.page-1)},_gotoPage:function(a){this.page=a,this._search()},_search:function(){this.client.startQueriesBatch(),this.client.addQueryInBatch(this.index,this.q,this._getHitsSearchParams());for(var a=0;a<this.options.disjunctiveFacets.length;++a)this.client.addQueryInBatch(this.index,this.q,this._getDisjunctiveFacetSearchParams(this.options.disjunctiveFacets[a]));var b=this;this.client.sendQueriesBatch(function(a,c){if(!a)return b.searchCallback(!1,c),void 0;var d=c.results[0];d.disjunctiveFacets={};for(var e=1;e<c.results.length;++e)for(var f in c.results[e].facets)if(d.disjunctiveFacets[f]=c.results[e].facets[f],b.disjunctiveRefinements[f])for(var g in b.disjunctiveRefinements[f])!d.disjunctiveFacets[f][g]&&b.disjunctiveRefinements[f][g]&&(d.disjunctiveFacets[f][g]=0);b.searchCallback(!0,d)})},_getHitsSearchParams:function(){return a({},this.searchParams,{hitsPerPage:this.options.hitsPerPage,page:this.page,facets:this.options.facets,facetFilters:this._getFacetFilters()})},_getDisjunctiveFacetSearchParams:function(b){return a({},this.searchParams,{hitsPerPage:1,page:0,facets:b,facetFilters:this._getFacetFilters(b)})},_getFacetFilters:function(a){var b=[];for(var c in this.refinements)this.refinements[c]&&b.push(c);for(var d in this.disjunctiveRefinements)if(d!=a){var e=[];for(var f in this.disjunctiveRefinements[d])this.disjunctiveRefinements[d][f]&&e.push(d+":"+f);e.length>0&&b.push(e)}return b}}}(),"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(a){return 10>a?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx,escapable,gap,indent,meta,rep;"function"!=typeof JSON.stringify&&(escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}();
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
@@ -14,98 +14,98 @@ dependencies:
|
|
14
14
|
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.5.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.5.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: algoliasearch
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.2.5
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.2.5
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: will_paginate
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 2.3.15
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.3.15
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: kaminari
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: travis
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rdoc
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: AlgoliaSearch integration to your favorite ORM
|
@@ -117,9 +117,9 @@ extra_rdoc_files:
|
|
117
117
|
- LICENSE
|
118
118
|
- README.md
|
119
119
|
files:
|
120
|
-
-
|
121
|
-
-
|
122
|
-
-
|
120
|
+
- .document
|
121
|
+
- .rspec
|
122
|
+
- .travis.yml
|
123
123
|
- ChangeLog
|
124
124
|
- Gemfile
|
125
125
|
- Gemfile.lock
|
@@ -140,10 +140,10 @@ files:
|
|
140
140
|
- spec/utilities_spec.rb
|
141
141
|
- vendor/assets/javascripts/algolia/algoliasearch.js
|
142
142
|
- vendor/assets/javascripts/algolia/algoliasearch.min.js
|
143
|
-
- vendor/assets/javascripts/algolia/
|
143
|
+
- vendor/assets/javascripts/algolia/typeahead.jquery.js
|
144
144
|
- vendor/assets/javascripts/algolia/typeahead.bundle.js
|
145
145
|
- vendor/assets/javascripts/algolia/typeahead.bundle.min.js
|
146
|
-
- vendor/assets/javascripts/algolia/
|
146
|
+
- vendor/assets/javascripts/algolia/bloodhound.js
|
147
147
|
homepage: http://github.com/algolia/algoliasearch-rails
|
148
148
|
licenses:
|
149
149
|
- MIT
|
@@ -154,17 +154,17 @@ require_paths:
|
|
154
154
|
- lib
|
155
155
|
required_ruby_version: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - '>='
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
161
|
requirements:
|
162
|
-
- -
|
162
|
+
- - '>='
|
163
163
|
- !ruby/object:Gem::Version
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.1.11
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: AlgoliaSearch integration to your favorite ORM
|