[Koha] Stopwords with Zebra using Javascript

spitaelsl spitaels.laurent at gmail.com
Fri May 3 20:03:39 NZST 2013


Good morning,

I maybe have a temporary solution about the stopwords and zebra.
You can use this following javascript and put in the global system
preferences of Koha.

The only thing you have to do is to paste the code in the "intranetuserjs"
and "opacuserjs" preferences.

Here is the code between the two lines with only 4 words. You can add as
many as you want.
-------------------
function removeStopwords(query) {
	var stopwords = new Array("A","ABOUT","ABOVE","ALL");
	var string = "";
	for ( var i = 0; i < stopwords.length; i++) {
		for ( var j = 0; j < query.length; j++) {
			if (query[j].toLowerCase() == stopwords[i].toLowerCase()) {
				query[j] = "";
			}
		}
	}
	for ( var i = 0; i < query.length; i++) {
		if (query[i] != "") {
			string += query[i] + " ";
		}
	}
	string = string.substring(0, string.length - 1);
	return string;
}

$(document).ready(function() {
	var number_form = $('form').length;
	if (number_form > 2){
		number_form = 1;
	}
	$('form').eq(number_form -1).submit(function(){
		var number_q = $("[name='q']").length;
		for (var i = 0; i < number_q; i++){
			$("[name='q']").eq(i).prop('value',
removeStopwords($("[name='q']").eq(i).val().split(' ')));
		}
	});
});
-------------------

Cheers



-----
Laurent Spitaels
www.vki.ac.be 
www.ipl.be 
--
View this message in context: http://koha.1045719.n5.nabble.com/Stopwords-with-Zebra-using-Javascript-tp5753423.html
Sent from the Koha-general mailing list archive at Nabble.com.


More information about the Koha mailing list