}
var urls = hit['md-electronic-url'];
- that.warn("urls = " + mkws.$.toJSON(urls));
- var bestLink = null;
- var otherLinks = [];
- for (var j = 0; j < urls.length; j++) {
- var url = urls[j];
- if (!bestLink && url.match(/^(https?:)?\/\//)) {
- bestLink = url;
- } else {
- otherLinks.push(url);
+ if (urls) {
+ var bestLink = null;
+ var otherLinks = [];
+ for (var j = 0; j < urls.length; j++) {
+ var url = urls[j];
+ if (!url.match(/^(https?:)?\/\//)) {
+ that.warn("link '" + url + "' is not a valid URL");
+ } else if (!bestLink) {
+ bestLink = url;
+ } else {
+ otherLinks.push(url);
+ }
}
+ hit.bestLink = bestLink;
+ hit.otherLinks = otherLinks;
}
- hit.bestLink = bestLink;
- hit.otherLinks = otherLinks;
}
var template = team.loadTemplate(that.config.template || "records");
mkws.registerWidgetType('search-form', function() {
var team = this.team;
+ var that = this;
this.node.submit(function() {
var val = team.widget('query').value();
- team.newSearch(val);
+ team.newSearch(that, val);
return false;
});
});