The URI of TUHH Docker Registry changed from "docker.rz.tu-harburg.de:5000" to "docker.rz.tu-harburg.de". Please update your gitlab-ci.yml files if you use images from this registry.

Commit 20fa97b9 authored by Tobias Zeumer's avatar Tobias Zeumer

Search: fix signature lookup with search field; #42

parent cf446769
......@@ -674,16 +674,43 @@ function find_and_highlight(cssSelector) {
/**
* Find signature in svg by classes set to shelves (this is meant to be used for
* linking from catalogs/discovery systems.
* @todo: Always selects first matching reading room. If something (e.g. scanners)
* is on first and second floor it's not obvious for the user...
* linking from catalogs/discovery systems.
*
* @param {string} sig Any signature ("TI:TIA-123", "TI TIA 123", "LBS-NTN-606", "TIA-123", "NTN 606", "CHA123")
* @return False if sig could not be matched to any of the above pattern, the css selector if matching was successful
*/
function split_signature(sig) {
var res = sig.toLowerCase();
var css, res;
// 2017-10-30: add 0-9 for closed stack (for now)
res = res.match(/([a-z]*)\W([0-9a-z_]*)\W([\d]*)/);
// 2018-07-19: Match for perfect signature like nt:ntn-606 or lbs:tia-123 (length == 4)
// Also allow ls1:ntn-606 (because that is what tub.find buttons show)
res = sig.toLowerCase().match(/^([a-z12]*)\W([0-9a-z_]{3})\W([\d]{3})$/);
// Got no perfect signature? Something like ntn-606. Try without loc (length == 3)
if (!res) {
res = sig.toLowerCase().match(/^([0-9a-z_]{3})\W([\d]{3})$/);
}
if (res.length == 4) {
// Last try for something like ntn606
if (!res) {
res = sig.toLowerCase().match(/^([0-9a-z_]{3})([\d]{3})$/);
}
// Still false? Pretty sure that no signature was searched for
if (!res) {
return false;
}
// Show both text book collection and/or reading room location
else if (res.length == 3) {
var sig_sys = res[1];
var sig_num = res[2];
css = "." + sig_sys;
return css;
}
// Show exact location: text book collection or reading room
else if (res.length == 4) {
var sig_loc = res[1];
var sig_sys = res[2];
var sig_num = res[3];
......@@ -726,7 +753,7 @@ function split_signature(sig) {
}
*/
let css = "." + sig_loc + "." + sig_sys;
css = "." + sig_loc + "." + sig_sys;
return css;
}
......@@ -844,6 +871,15 @@ function search_init() {
* entry name is submitted exactly as in menu (uppercase important)
*/
function search(input_value) {
var result;
// First of all: dumb try if it is a signature
let sig = split_signature(input_value);
if (sig) {
result = find_and_highlight(sig);
if (Object.keys(result).length > 0) return true;
}
// Find the css value for the search term in the search_terms object array (@see search_terms())
// Also allow directly using the css value (sValue) in the search
var css = search_terms.find(o => o.term === input_value || o.sValue === input_value);
......@@ -861,7 +897,7 @@ function search(input_value) {
css = input_value.toLowerCase();
}
var result = find_and_highlight("." + css);
result = find_and_highlight("." + css);
// If nothing is found in the map, then open discovery in modal and hope that
// the patron thought that this was the intended use of the search field
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment