[open-ils-commits] r838 - conifer/branches/rel_1_6_0/web/opac/skin/default/js (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 18 12:35:29 EDT 2010
Author: dbs
Date: 2010-03-18 12:35:26 -0400 (Thu, 18 Mar 2010)
New Revision: 838
Modified:
conifer/branches/rel_1_6_0/web/opac/skin/default/js/result_common.js
Log:
More generic "extra search services" implementation: supports multiple services
Modified: conifer/branches/rel_1_6_0/web/opac/skin/default/js/result_common.js
===================================================================
--- conifer/branches/rel_1_6_0/web/opac/skin/default/js/result_common.js 2010-03-17 21:53:26 UTC (rev 837)
+++ conifer/branches/rel_1_6_0/web/opac/skin/default/js/result_common.js 2010-03-18 16:35:26 UTC (rev 838)
@@ -5,9 +5,28 @@
var isbnList = '';
var googleBooksLink = true;
var enableHoldsOnAvailable = false;
-var enableEbooksLowHits = false;
+var enableExtraSearchesLowHits = false;
var localProxyPrefix = '';
+/* an array of the extra services to which we want to direct people, in order of priority:
+Properties:
+ url: will be proxied via localProxyPrefix
+ description: will be used in the OPAC display
+ termTransform: a function name that transforms Evergreen compiled searches to the target search format
+*/
+var externalSearchServices = [
+ {
+ "url": "http://books.scholarsportal.info/search.html?searchField=All+Fields&limit=full_text&sortBy=relevance&collection=all&searchTerm=",
+ "description": "Search ScholarsPortal ebooks",
+ "termTransform": "allKeywords"
+ },
+ {
+ "url": "http://scholar.google.com/scholar?q=",
+ "description": "Search Google Scholar",
+ "termTransform": "allKeywords"
+ }
+];
+
var resultFetchAllRecords = false;
var resultCompiledSearch = null;
@@ -213,8 +232,8 @@
resultSuggestSearchClass();
- if (enableEbooksLowHits) {
- resultSuggestEbooks();
+ if (enableExtraSearchesLowHits) {
+ resultSuggestExtraSearches();
}
if(getTerm()) resultExpandSearch(); /* advanced search */
@@ -257,8 +276,8 @@
unHideMe($('result_low_hits'));
unHideMe($('result_zero_hits_msg'));
- if (enableEbooksLowHits) {
- resultSuggestEbooks();
+ if (enableExtraSearchesLowHits) {
+ resultSuggestExtraSearches();
}
//if(getTerm()) resultExpandSearch(); /* advanced search */
}
@@ -282,19 +301,33 @@
}
}
-/* For now we only generate a link to ScholarsPortal ebook platform */
-function resultSuggestEbooks() {
- var ebook_search = localProxyPrefix + 'http://books.scholarsportal.info/search.html?searchField=All+Fields&limit=full_text&sortBy=relevance&collection=all&searchTerm=';
- var ebook_terms = '';
- for (var key in resultCompiledSearch.searches) {
- ebook_search += resultCompiledSearch.searches[key].term.replace(/ /g, '+') + '+';
- ebook_terms += resultCompiledSearch.searches[key].term + ' ';
- }
- ebook_search.replace('+$', '');
- ebook_terms.replace(' $', '');
- dojo.place("<div style='text-align: center; width: 100%; margin-left: auto; margin-right: auto;'><strong>Search ScholarsPortal ebooks</strong>: <a class='classic_link' href='" + ebook_search + "'>" + ebook_terms + "</a><div>", "result_low_hits", "child");
+/* Generate links to our extra search services */
+function resultSuggestExtraSearches() {
+ dojo.forEach(externalSearchServices, function(esItem) {
+ var extraSearchStuff = this[esItem.termTransform].apply(this, [esItem.url]);
+ dojo.place("<div style='text-align: center; width: 100%; margin-left: auto; margin-right: auto;'><strong>" +
+ esItem.description + "</strong>: <a class='classic_link' href='" +
+ extraSearchStuff.searchTerms + "'>" + extraSearchStuff.displayTerms + "</a><div>", "result_low_hits", "child"
+ );
+ });
}
+/* Transform everything in the Evergreen search to plain old keywords */
+function allKeywords(esUrl) {
+ var ebook_search = localProxyPrefix + esUrl;
+ var ebook_terms = '';
+ for (var key in resultCompiledSearch.searches) {
+ ebook_search += resultCompiledSearch.searches[key].term + '+';
+ ebook_terms += resultCompiledSearch.searches[key].term + ' ';
+ }
+ ebook_search = ebook_search.replace(/ /g, '+');
+ ebook_search = ebook_search.replace(/\%20/g, '+');
+ ebook_search = ebook_search.replace(/\+$/g, '');
+ ebook_terms = ebook_terms.replace(/ $/g, '');
+ var extraSuggestion = {"displayTerms": ebook_terms, "searchTerms": ebook_search};
+ return extraSuggestion;
+}
+
function resultSuggestSearchClass() {
var stype = getStype();
if(stype == STYPE_KEYWORD) return;
More information about the open-ils-commits
mailing list