[25834] | 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 |
|
---|
[33016] | 23 | var countsString = "s1.facetQueries=";
|
---|
[25834] | 24 | if(counts.length > 0)
|
---|
| 25 | {
|
---|
[33016] | 26 | var countsStringBuffer = "[";
|
---|
[25834] | 27 | for(var i = 0; i < counts.length; i++)
|
---|
| 28 | {
|
---|
[32110] | 29 | // escape any apostrophes in facet query terms
|
---|
| 30 | // (ext/solr's Greenstone3SearchHandler does the other half of handling them)
|
---|
[33016] | 31 | //countsStringBuffer += "\"" + encodeURI(counts[i]).replace(/'/g, "%2527") + "\"";
|
---|
| 32 | // calling makeURLSafe() here will ensure percent signs are escaped away too
|
---|
| 33 | // by the end of makeURLComponentSafe() call below
|
---|
| 34 | countsStringBuffer += "\"" + makeURLSafe(counts[i]).replace(/'/g, "%2527") + "\"";
|
---|
[25834] | 35 | if(i < counts.length - 1)
|
---|
| 36 | {
|
---|
| 37 | countsStringBuffer += ", ";
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 |
|
---|
[33016] | 41 | countsStringBuffer += "]";
|
---|
| 42 |
|
---|
| 43 | // We need to ensure that the *value* of s1.facetQueries (so everything after
|
---|
| 44 | // s1.facetQueries= and before the connecting &) are safe, which requires escaping,
|
---|
| 45 | // and are further also escaped to not be mistaken for their reserved meaning.
|
---|
| 46 | // : is a reserved character in URLs, [] are unsafe characters. All need escaping.
|
---|
| 47 | // So call makeURLComponentSafe(), not makeURLSafe()
|
---|
| 48 | countsString = countsString + makeURLComponentSafe(countsStringBuffer, 1);
|
---|
[25834] | 49 | }
|
---|
| 50 |
|
---|
[33016] | 51 | countsString += "&";
|
---|
| 52 | console.log("STRING IS " + countsString);
|
---|
[32110] | 53 |
|
---|
[25834] | 54 | $.ajax(gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/search/" + gs.cgiParams.s + "?" + searchString + countsString + "excerptid=resultsArea")
|
---|
| 55 | .done(function(response)
|
---|
| 56 | {
|
---|
| 57 | $("#resultsArea").html("");
|
---|
| 58 | $("#resultsArea").html(response.substring(response.indexOf(">") + 1, response.lastIndexOf("<")));
|
---|
| 59 | });
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | function expandFacetList(indexName, countSize)
|
---|
| 63 | {
|
---|
| 64 | var tables = $(".facetTable");
|
---|
| 65 |
|
---|
| 66 | for(var i = 0; i < tables.length; i++)
|
---|
| 67 | {
|
---|
| 68 | var current = $(tables[i]);
|
---|
| 69 | if(current.attr("indexName") == indexName)
|
---|
| 70 | {
|
---|
| 71 | var items = current.children("li");
|
---|
| 72 |
|
---|
| 73 | for(var j = 0; j < items.length; j++)
|
---|
| 74 | {
|
---|
| 75 | $(items[j]).css("display", "block");
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | break;
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 |
|
---|
[30771] | 82 | // the above code has made both see more and see less links display=block, so we need to hide
|
---|
| 83 | // see more
|
---|
| 84 | var morelink = $(".expandFacetList" + indexName);
|
---|
| 85 | morelink.css("display", "none");
|
---|
| 86 |
|
---|
[25834] | 87 | }
|
---|
| 88 |
|
---|
| 89 | function collapseFacetList(indexName, countSize)
|
---|
| 90 | {
|
---|
| 91 | var tables = $(".facetTable");
|
---|
| 92 |
|
---|
| 93 | for(var i = 0; i < tables.length; i++)
|
---|
| 94 | {
|
---|
| 95 | var current = $(tables[i]);
|
---|
| 96 | if(current.attr("indexName") == indexName)
|
---|
| 97 | {
|
---|
| 98 | var items = current.children("li");
|
---|
| 99 |
|
---|
| 100 | for(var j = 0; j < items.length; j++)
|
---|
| 101 | {
|
---|
[30771] | 102 | if(j > countSize)
|
---|
| 103 | {
|
---|
| 104 | $(items[j]).css("display", "none");
|
---|
| 105 | }
|
---|
[25834] | 106 | }
|
---|
[30771] | 107 |
|
---|
[25834] | 108 | break;
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 |
|
---|
[30771] | 112 | // the above code has hidden both the see more and see less links.
|
---|
| 113 | // display the see more one
|
---|
| 114 | var morelink = $(".expandFacetList" + indexName);
|
---|
| 115 | morelink.css("display", "block");
|
---|
| 116 |
|
---|
| 117 | }
|
---|
| 118 |
|
---|