this.authorBox = new Box();
this.authorBox.init("Relevant Authors", true, true, 15);
- this.authorBox.sortByCount();
+ this.authorBox.sortByKey();
this.subjectBox = new Box();
this.subjectBox.init("Relevant Subjects", true, true, 15);
this.seriesBox = new Box();
this.seriesBox.init("Relevant Series", true, true, 15);
- this.seriesBox.sortByCount();
+ this.seriesBox.sortByKey();
this.sidebarBox = getById("record_sidebar_box");
var pic_cell = title_row.insertCell(0);
- this.buildRecordImage( pic_cell, record, page_id );
+ this.buildRecordImage( pic_cell, record, page_id, record.title());
var title_cell = title_row.insertCell(title_row.cells.length);
title_cell.id = "record_result_title_box_" + id;
title = normalize(record.title());
}
+
var author = "";
if( record.author() ) {
if(record.author().length > tlength) {
author = normalize(record.author());
}
- title_cell.appendChild(this.mkLink(record.doc_id(), "title", title ));
+ title_cell.appendChild(this.mkLink(record.doc_id(), "title", title, record.title() ));
author_cell.innerHTML = " ";
author_cell.appendChild(this.mkLink(record.doc_id(), "author", author ));
"&mr_search_location=" + this.searchLocation);
href.appendChild(createAppTextNode(auth));
+ href.title = "Author search for " + auth;
return href;
}
var href = createAppElement("a");
add_css_class(href,"record_result_sidebar_link");
+ debug("Series: " + series + " : " + encodeURIComponent(series));
+
href.setAttribute("href",
"?target=mr_result&mr_search_type=series&page=0&mr_search_query=" +
encodeURIComponent(series) +
"&mr_search_location=" + this.searchLocation);
href.appendChild(createAppTextNode(series));
+ href.title = "Series search for " + series;
return href;
}
"&mr_search_depth=" + this.searchDepth +
"&mr_search_location=" + this.searchLocation);
href.appendChild(createAppTextNode(sub));
+ href.title = "Subject search for " + sub;
return href;
}
return;
this.finalized = true;
+
this.subjectBox.finalize();
this.authorBox.finalize();
this.seriesBox.finalize();
/* in case we're hidden */
showMe(this.bigOlBox);
+ showMe(getById("hit_count_cell_2"));
}
cell.innerHTML = copy_counts[i].available + " / " + copy_counts[i].count;
cell.setAttribute("rowspan","3");
cell.rowSpan = 3;
+ cell.title = " Availabie Copies / Total Copies";
titlerow.appendChild(cell);
}
max = this.hitCount;
var hcell = getById("hit_count_cell");
+ var hcell2 = getById("hit_count_cell_2");
+ hideMe(hcell2);
+
+ var ident = "Titles";
+ if(instanceOf(this, MRResultPage))
+ ident = "Title Groups";
hcell.appendChild(
- createAppTextNode( "Displaying " +
+ createAppTextNode( "Displaying " + ident + " " +
( parseInt(i) + 1 ) + " to " + max + " of " + this.hitCount));
hcell.appendChild(createAppTextNode(" "));
hcell.appendChild(span);
hcell.appendChild(next);
-
+ hcell2.innerHTML = hcell.innerHTML;
}
c.childNodes[index].appendChild(pic);
}
-AbstractRecordResultPage.prototype.buildRecordImage = function(pic_cell, record, page_id) {
+AbstractRecordResultPage.prototype.buildRecordImage = function(pic_cell, record, page_id, title) {
var isbn = record.isbn();
if(isbn) isbn = isbn.replace(/\s+/,"");
add_css_class(d, "relevance");
rankBox.appendChild(d);
- rankBox.setAttribute("title", (100 - parseInt(per)) + "% Relevant");
+ rankBox.setAttribute("title", parseInt((100 - parseInt(per))) + "% Relevant");
}
/* use amazon for now */
big_div.style.left = 0;
- var anch = this.mkLink(record.doc_id(), "img" );
+ var anch = this.mkLink(record.doc_id(), "img", title );
anch.appendChild(big_pic);
big_div.appendChild(anch);
pic_cell.appendChild(big_div);
this.tcnText = getById("adv_tcn_text");
this.ISBNText = getById("adv_isbn_text");
this.barcodeText = getById("adv_barcode_text");
+ var refinedButton = getById("adv_search_refined_submit");
this.globalSearchButton.onclick = doGlobalSearch;
+ refinedButton.onclick = doGlobalSearch;
}
/* resets the page */
return;
}
+ var allWords = getById("adv_all_words").value;
+ var exactWords = getById("adv_exact_words").value;
+ var noneWords = getById("adv_none_words").value;
+ var type = getById("adv_search_type").value;
+ if(allWords || exactWords || noneWords) {
+ var search_string = obj.buildRefinedSearch(allWords, exactWords, noneWords);
+ debug("Refined search string is [ " + search_string + " ] and type " + type);
+
+ url_redirect ([
+ "target", "mr_result",
+ "mr_search_type", type,
+ "mr_search_query", search_string,
+ "page", 0
+ ]);
+
+ }
+
+}
+
+AdvancedSearchPage.prototype.buildRefinedSearch =
+ function(allWords, exactWords, noneWords) {
+
+ var string = "";
+
+ if(allWords) {
+ string = allWords;
+ }
+
+ if(exactWords) {
+ if(exactWords.indexOf('"') > -1)
+ string += " " + exactWords;
+ else
+ string += " \"" + exactWords + "\"";
+
+ }
+
+ if(noneWords) {
+ var words = noneWords.split(" ");
+ for(var i in words)
+ string += " -" + words[i];
+ }
+
+ return string;
}
var globalSelectedLocation = null;
var globalSearchDepth = null;
var globalMenuManager = null;
+var locationStack = new Array();
+
+var lastSearchString = null;
+var lastSearchType = null;
+
var loaded = false;
+
function isXUL() {
try {
if(IAMXUL)
}
}
+function addLocation(type, title) {
+ try {
+ if(globalAppFrame) {
+ var obj = new Object();
+ obj.location = globalAppFrame.location.href;
+ obj.title = title;
+ locationStack[type] = obj;
+ }
+ } catch(E){}
+
+}
+
function globalInit() {
debug(" --- XUL IS " + isXUL() );
+
+ if( isXUL() && globalAppFrame )
+ globalAppFrame.document.body.style.background = "#FFF";
+
var page_name = globalPageTarget;
if(!page_name)
case "start":
globalPage = new OPACStartPage();
+ addLocation("start", "Home");
+ locationStack["advanced_search"] = null;
break;
case "advanced_search":
globalPage = new AdvancedSearchPage();
+ addLocation("advanced_search", "Advanced Search");
+ locationStack["start"] = null;
break;
case "mr_result":
globalPage = new MRResultPage();
+ addLocation("mr_result", "Title Group Results");
break;
case "record_result":
globalPage = new RecordResultPage();
+ addLocation("record_result", "Title Results");
break;
case "login":
case "record_detail":
globalPage = new RecordDetailPage();
+ addLocation("record_detail", "Title Details");
break;
case "about":
globalPage.init();
globalPage.setLocDisplay();
globalPage.locationTree = globalOrgTreeWidget;
+ globalPage.setPageTrail();
if(globalSearchBarChunk)
globalSearchBarChunk.reset();
return new MRResultPage();
}
+
+MRResultPage.prototype.setPageTrail = function() {
+
+ var box = getById("page_trail");
+ if(!box) return;
+
+ var d = this.buildTrailLink("start",true);
+ if(d) {
+ box.appendChild(d);
+ } else {
+ d = this.buildTrailLink("advanced_search", true);
+ if(d)
+ box.appendChild(d);
+ }
+
+ box.appendChild(this.buildDivider());
+ box.appendChild(
+ this.buildTrailLink("mr_result", false));
+
+}
+
+
MRResultPage.prototype.next = function() {
var location = globalSelectedLocation;
];
}
-MRResultPage.prototype.mkLink = function(id, type, value) {
+MRResultPage.prototype.mkLink = function(id, type, value, title) {
var href;
+ var t = title;
+ if(!t) t = value;
+
+ debug("T: " + t);
+
switch(type) {
case "title":
"?target=record_result&page=0&mrid=" + id +
"&hits_per_page=" + this.hitsPerPage);
href.appendChild(createAppTextNode(value));
+ href.title = "View titles for " + t + "";
break;
case "img":
href.setAttribute("href",
"?target=record_result&page=0&mrid=" + id +
"&hits_per_page=" + this.hitsPerPage);
+ href.title = "View titles for " + t + "";
break;
"?target=mr_result&mr_search_type=author&page=0&mr_search_query=" +
encodeURIComponent(value));
href.appendChild(createAppTextNode(value));
+ href.title = "Author search for " + t + "";
break;
default:
var depth = paramObj.__mr_search_depth;
var hitsper = paramObj.__hits_per_page;
+ lastSearchString = string;
+ lastSearchType = stype;
+
if(hitsper)
this.hitsPerPage = parseInt(hitsper);
}
else throw E;
}
+
+ var row = getById("hourglass_row");
+ if(row)
+ row.parentNode.removeChild(row);
if(obj.hitCount > 0) obj.buildNextLinks();
else obj.noHits();
"open-ils.search", method,
obj.stype, obj.string,
obj.searchLocation,
- obj.searchDepth, "100", obj.searchOffset );
+ obj.searchDepth, "50", obj.searchOffset );
request.setCompleteCallback(
function(req) {
var i = this.searchOffset;
+ var row = getById("hourglass_row");
+ if(row)
+ row.parentNode.removeChild(row);
+
while( i < (this.searchOffset + this.hitsPerPage) ) {
var id = this.recordIDs[i];
url_redirect( [
"target", "mr_result",
- "mr_search_type", obj.stype,
- "mr_search_query", obj.string,
+ "mr_search_type", lastSearchType,
+ "mr_search_query", lastSearchString,
"mr_search_location", location,
"mr_search_depth", globalSearchDepth,
"page", 0
}
+
+
+
+Page.prototype.setPageTrail = function() {
+ debug("Falling back to Page.setPageTrail");
+}
+
+
+Page.prototype.buildTrailLink = function(type, active) {
+
+ var obj = locationStack[type];
+ if(obj == null) return;
+
+ var div = createAppElement("div");
+
+ if(active) {
+ add_css_class(div,"page_trail_word");
+ var a = createAppElement("a");
+ a.setAttribute("href", obj.location);
+ a.appendChild(createAppTextNode(obj.title));
+ a.title = obj.title;
+ div.appendChild(a);
+
+ } else {
+ add_css_class(div,"page_trail_word_inactive");
+ div.appendChild(createAppTextNode(obj.title));
+ }
+
+ return div;
+}
+
+Page.prototype.buildDivider = function() {
+ var div = createAppElement("div");
+ div.className = "page_trail_divider";
+ var text = createAppTextNode(" / ");
+ div.appendChild(text);
+ return div;
+}
+
RecordDetailPage.prototype.init = function() {
debug("Initing RecordDetailPage");
}
+
+RecordDetailPage.prototype.setPageTrail = function() {
+ var box = getById("page_trail");
+ if(!box) return;
+
+ var d = this.buildTrailLink("start",true);
+ if(d) {
+ box.appendChild(d);
+ } else {
+ d = this.buildTrailLink("advanced_search",true);
+ if(d)
+ box.appendChild(d);
+ }
+
+ var b = this.buildTrailLink("mr_result", true);
+
+ if(b) {
+ box.appendChild(this.buildDivider());
+ box.appendChild(b);
+ }
+
+ box.appendChild(this.buildDivider());
+ box.appendChild(this.buildTrailLink("record_result", true));
+
+ box.appendChild(this.buildDivider());
+ box.appendChild(
+ this.buildTrailLink("record_detail",false));
+}
+
+
+
+
debug("in RecordResultPage()");
+ var row = getById("hourglass_row");
+ if(row)
+ row.parentNode.removeChild(row);
+
if( globalRecordResultPage != null ) {
debug("globalRecordResultPage already exists: " +
globalRecordResultPage.toString() );
globalRecordResultPage = this;
this.resetSearch();
debug("Built a new RecordResultPage()");
+
+ var row = getById("hourglass_row");
+ if(row)
+ row.parentNode.removeChild(row);
+}
+
+
+RecordResultPage.prototype.setPageTrail = function() {
+ var box = getById("page_trail");
+ if(!box) return;
+
+ var d = this.buildTrailLink("start", true);
+ if(d) {
+ box.appendChild(d);
+ } else {
+ d = this.buildTrailLink("advanced_search", true);
+ if(d)
+ box.appendChild(d);
+ }
+
+ var b = this.buildTrailLink("mr_result", true);
+
+ if(b) {
+ box.appendChild(this.buildDivider());
+ box.appendChild(b);
+ }
+
+ box.appendChild(this.buildDivider());
+ box.appendChild(
+ this.buildTrailLink("record_result",false));
}
+
+
+
/* returns the global instance. builds the instance if necessary. All client
* code should use this method */
RecordResultPage.instance = function() {
+
+ var row = getById("hourglass_row");
+ if(row)
+ row.parentNode.removeChild(row);
+
if( globalRecordResultPage != null ) {
return globalRecordResultPage;
}
add_css_class(href,"record_result_title_link");
href.setAttribute("href","?target=record_detail&record=" + id );
href.appendChild(createAppTextNode(value));
+ href.title = "View title details for " + value;
break;
case "author":
href.setAttribute("href","?target=mr_result&mr_search_type=author&mr_search_query=" +
encodeURIComponent(value));
href.appendChild(createAppTextNode(value));
+ href.title = "Author search for " + value + "";
break;
case "img":
href = createAppElement("a");
add_css_class(href,"record_result_image_link");
href.setAttribute("href","?target=record_detail&page=0&mrid=" + id );
+ href.title = "View title details for " + value;
break;
default:
this.search_type.onkeydown = mrSearchSubmitOnEnter;
- if(paramObj.__mr_search_query)
- this.search_query.value = paramObj.__mr_search_query;
-
- if(paramObj.__mr_search_type)
- this.search_type.value = paramObj.__mr_search_type;
+ var s = paramObj.__mr_search_query;
+ if(!s) s = lastSearchString;
+ var t = paramObj.__mr_search_type;
+ if(!t) t = lastSearchType;
+ if(s) this.search_query.value = s;
+ if(t) this.search_type.value = t;
try{ this.search_query.focus(); } catch(E) {}
}
-/*
-SearchBarFormChunk.prototype.resetRange = function() {
-
- this.searchRange = getById("search_range_select");
- var orgunit = globalSelectedLocation;
- if(!orgunit)
- orgunit = globalLocation;
-
- if(this.searchRange) {
- for( var index in globalOrgTypes ) {
- var otype = globalOrgTypes[index];
-
- if( otype.depth() > orgunit.ou_type() )
- continue;
-
- var select = new Option(otype.name(), otype.depth());
-
- debug("org depth " + otype.name() + " : " + otype.depth() );
- if( otype.depth() == globalSearchDepth ) {
- debug("Building range selector with depth "
- + globalSearchDepth + " and name " + otype.name() );
- select.selected = true;
- }
-
- this.searchRange.options[index] = select;
- }
- }
-}
-*/
-
function mrSearchSubmitForm() {
var search_query = getById("mr_search_query").value;
debug("Communication Error: [" + E + "]");
if(object.sendCount >= XML_HTTP_MAX_TRIES ) {
- alert("Arrrgghh, Matey! Error communicating:\n" +
+ if(isXUL()) {
+ throw object;
+ } else {
+ alert("Arrrgghh, Matey! Error communicating:\n" +
E + "\n" + object.param_string);
+ }
} else {
object.buildXMLRequest();
object.send();
this.max = null;
}
+Box.prototype.sortMyKeys = function() {
+
+ var keys = new Array();
+
+ for( var i in this.items)
+ keys.push(this.items[i].getKey());
+
+ keys = keys.sort();
+ debug("Keys: " + keys);
+
+ /* drop all of the children */
+ while(this.contentNode.childNodes.length > 0 )
+ this.contentNode.removeChild(
+ this.contentNode.lastChild);
+
+ for(var k in keys) {
+ var node = this.findByKey(keys[k]);
+ if(node)
+ this.contentNode.appendChild(node.getNode());
+ }
+
+}
+
+
+Box.prototype.sortMyCounts = function() {
+
+ var counts = new Array();
+ for( var x in this.itemCount) {
+ counts.push(this.itemCount[x]);
+ }
+
+
+ /* remove all of the divs */
+ while(this.contentNode.childNodes.length > 0 )
+ this.contentNode.removeChild(
+ this.contentNode.lastChild);
+
+ /* then re-insert in order of the sorted counts array*/
+ counts = counts.sort().reverse();
+ for(var i in counts) {
+ for( var c in this.itemCount ) {
+ if(this.itemCount[c] == counts[i]) {
+ var item = this.findByKey(c);
+ this.contentNode.appendChild(item.getNode());
+ }
+ }
+ }
+
+}
+
+
+Box.prototype.sortMyBoth = function() {
+}
+
+Box.prototype.findByKey = function(key) {
+ for( var i in this.items) {
+ if( this.items[i] && this.items[i].getKey() == key)
+ return this.items[i];
+ }
+ return null;
+}
+
/* checks for sorting order/max items and does the final
div drawing. Sets hidden to false */
Box.prototype.finalize = function() {
/* first sort if necessary */
- if(this.sortCounts){
- /*remove all childrens*/
- }
+ if(this.sortCounts && this.sortKeys)
+ this.sortMyBoth();
- if(this.sortKeys){
- }
+ else if(this.sortKeys)
+ this.sortMyKeys();
+ else if(this.sortCounts)
+ this.sortMyCounts();
/* then trim */
if( this.max ) {
this.percentDiv = createAppElement("div");
add_css_class(this.percentDiv, "progress_percent");
- var divWidth = 100 / parseInt(size);
+ var divWidth = parseInt(100 / parseInt(size));
for( i = 0; i!= size; i++ ) {
var div = createAppElement("div");
div.className = "progress_bar_chunk";
this.is_running = false;
this.current = this.size;
clearTimeout(this.timeoutId);
+ /*
for(var i in this.div.childNodes) {
this.div.childNodes[i].className = "progress_bar_chunk_active";
}
+ */
add_css_class(this.percentDiv, "hide_me");
+ add_css_class(this.div, "progress_bar_done");
this.percentDiv.innerHTML = "";
}
this.current = parseInt(this.current) + 1;
}
- this.percentDiv.innerHTML = (parseInt(this.current) / parseInt(this.size) * 100) + "%";
+ this.percentDiv.innerHTML = parseInt((parseInt(this.current) / parseInt(this.size) * 100)) + "%";
}
debug("Retrieving random survey asynchronously");
var c = function(req) {
var surveys = req.getResultObject();
+ if(!surveys) return null;
if( typeof surveys != 'object' ||
surveys.constructor != Array )