1 | function performRefinedSearch()
|
---|
2 | {
|
---|
3 | var allCheckBoxes = $("#facetSelector input");
|
---|
4 | var counts = new Array();
|
---|
5 | for(var i = 0; i < allCheckBoxes.length; i++)
|
---|
6 | {
|
---|
7 | var current = $(allCheckBoxes[i]);
|
---|
8 | if(current.prop("checked"))
|
---|
9 | {
|
---|
10 | counts.push(current.parent().parent().attr("indexName") + ":(\"" + current.siblings("span").first().html() + "\")");
|
---|
11 | }
|
---|
12 | }
|
---|
13 |
|
---|
14 | var searchString = "";
|
---|
15 | for(var key in gs.cgiParams)
|
---|
16 | {
|
---|
17 | if (gs.cgiParams.hasOwnProperty(key))
|
---|
18 | {
|
---|
19 | searchString += key.replace(/_/g, ".") + "=" + gs.cgiParams[key] + "&";
|
---|
20 | }
|
---|
21 | }
|
---|
22 |
|
---|
23 | var countsString = "s1.facetQueries=&";
|
---|
24 | if(counts.length > 0)
|
---|
25 | {
|
---|
26 | countsString = "s1.facetQueries=[";
|
---|
27 | var countsStringBuffer = "";
|
---|
28 | for(var i = 0; i < counts.length; i++)
|
---|
29 | {
|
---|
30 | // escape any apostrophes in facet query terms
|
---|
31 | // (ext/solr's Greenstone3SearchHandler does the other half of handling them)
|
---|
32 | countsStringBuffer += "\"" + encodeURI(counts[i]).replace(/'/g, "%2527") + "\"";
|
---|
33 | if(i < counts.length - 1)
|
---|
34 | {
|
---|
35 | countsStringBuffer += ", ";
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 | countsString += encodeURI(countsStringBuffer) + "]&";
|
---|
40 | }
|
---|
41 |
|
---|
42 | console.log("STRING IS " + countsString)
|
---|
43 |
|
---|
44 | $.ajax(gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/search/" + gs.cgiParams.s + "?" + searchString + countsString + "excerptid=resultsArea")
|
---|
45 | .done(function(response)
|
---|
46 | {
|
---|
47 | $("#resultsArea").html("");
|
---|
48 | $("#resultsArea").html(response.substring(response.indexOf(">") + 1, response.lastIndexOf("<")));
|
---|
49 | });
|
---|
50 | }
|
---|
51 |
|
---|
52 | function expandFacetList(indexName, countSize)
|
---|
53 | {
|
---|
54 | var tables = $(".facetTable");
|
---|
55 |
|
---|
56 | for(var i = 0; i < tables.length; i++)
|
---|
57 | {
|
---|
58 | var current = $(tables[i]);
|
---|
59 | if(current.attr("indexName") == indexName)
|
---|
60 | {
|
---|
61 | var items = current.children("li");
|
---|
62 |
|
---|
63 | for(var j = 0; j < items.length; j++)
|
---|
64 | {
|
---|
65 | $(items[j]).css("display", "block");
|
---|
66 | }
|
---|
67 |
|
---|
68 | break;
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|
72 | // the above code has made both see more and see less links display=block, so we need to hide
|
---|
73 | // see more
|
---|
74 | var morelink = $(".expandFacetList" + indexName);
|
---|
75 | morelink.css("display", "none");
|
---|
76 |
|
---|
77 | }
|
---|
78 |
|
---|
79 | function collapseFacetList(indexName, countSize)
|
---|
80 | {
|
---|
81 | var tables = $(".facetTable");
|
---|
82 |
|
---|
83 | for(var i = 0; i < tables.length; i++)
|
---|
84 | {
|
---|
85 | var current = $(tables[i]);
|
---|
86 | if(current.attr("indexName") == indexName)
|
---|
87 | {
|
---|
88 | var items = current.children("li");
|
---|
89 |
|
---|
90 | for(var j = 0; j < items.length; j++)
|
---|
91 | {
|
---|
92 | if(j > countSize)
|
---|
93 | {
|
---|
94 | $(items[j]).css("display", "none");
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | break;
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | // the above code has hidden both the see more and see less links.
|
---|
103 | // display the see more one
|
---|
104 | var morelink = $(".expandFacetList" + indexName);
|
---|
105 | morelink.css("display", "block");
|
---|
106 |
|
---|
107 | }
|
---|
108 |
|
---|