--- a/client/js/wikipedia-bin.js Wed Jul 03 13:42:59 2013 +0200
+++ b/client/js/wikipedia-bin.js Thu Jul 04 12:43:30 2013 +0200
@@ -50,13 +50,11 @@
this.refresh();
};
-Rkns.Wikipedia.Bin.prototype.render = function(searchstr) {
- var _rgxp = new RegExp('('+(searchstr || this.search).replace(/(\W)/g,'\\$1')+')','gi');
- if (searchstr) {
- var rxtest = new RegExp(searchstr.replace(/(\W)/g,'\\$1'),'i');
- }
+Rkns.Wikipedia.Bin.prototype.render = function(searchbase) {
+ var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
+ var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);
function highlight(_text) {
- return _text.replace(_rgxp, "<span class='searchmatch'>$1</span>");
+ return highlightrx.replace(_(_text).escape(), "<span class='searchmatch'>$1</span>");
}
var _html = "",
_this = this,
@@ -65,7 +63,7 @@
var title = _result.title,
url = "http://" + _this.lang + ".wikipedia.org/wiki/" + encodeURI(title.replace(/ /g,"_")),
description = Rkns.$('<div>').html(_result.snippet).text();
- if (searchstr && !rxtest.test(title) && !rxtest.test(description)) {
+ if (!search.isempty && !search.test(title) && !search.test(description)) {
return;
}
count++;
@@ -79,12 +77,12 @@
});
});
_this.main_$.html(_html);
- if (searchstr && count) {
+ if (!search.isempty && count) {
this.count_$.text(count).show();
} else {
this.count_$.hide();
}
- if (searchstr && !count) {
+ if (!search.isempty && !count) {
this.$.hide();
} else {
this.$.show();