Tidying up for Codacy

This commit is contained in:
Owen Stephens 2017-11-15 18:31:41 +00:00
parent 7ba110e31a
commit 319b6bcca5
2 changed files with 15 additions and 15 deletions

View File

@ -129,7 +129,7 @@ ListFacet.prototype.updateState = function(data) {
}; };
ListFacet.prototype._reSortChoices = function() { ListFacet.prototype._reSortChoices = function() {
this._data.choices.sort(this._options.sort == "name" ? this._data.choices.sort(this._options.sort === "name" ?
function(a, b) { function(a, b) {
return a.v.l.toLowerCase().localeCompare(b.v.l.toLowerCase()); return a.v.l.toLowerCase().localeCompare(b.v.l.toLowerCase());
} : } :
@ -279,7 +279,7 @@ ListFacet.prototype._update = function(resetScroll) {
//this._elmts.statusDiv.hide(); //this._elmts.statusDiv.hide();
this._elmts.controlsDiv.hide(); this._elmts.controlsDiv.hide();
if (this._data.error == "Too many choices") { if (this._data.error === "Too many choices") {
this._elmts.bodyInnerDiv.empty(); this._elmts.bodyInnerDiv.empty();
var messageDiv = $('<div>') var messageDiv = $('<div>')
@ -347,7 +347,7 @@ ListFacet.prototype._update = function(resetScroll) {
this._elmts.invertButton.hide(); this._elmts.invertButton.hide();
} }
if (this._options.sort == "name") { if (this._options.sort === "name") {
this._elmts.sortByNameLink.removeClass("action").addClass("selected"); this._elmts.sortByNameLink.removeClass("action").addClass("selected");
this._elmts.sortByCountLink.removeClass("selected").addClass("action"); this._elmts.sortByCountLink.removeClass("selected").addClass("action");
} else { } else {
@ -361,7 +361,7 @@ ListFacet.prototype._update = function(resetScroll) {
return temp.text(s).html(); return temp.text(s).html();
}; };
var renderEdit = this._config.expression == "value"; var renderEdit = this._config.expression === "value";
var renderChoice = function(index, choice, customLabel) { var renderChoice = function(index, choice, customLabel) {
var label = customLabel || choice.v.l; var label = customLabel || choice.v.l;
var count = choice.c; var count = choice.c;
@ -402,9 +402,9 @@ ListFacet.prototype._update = function(resetScroll) {
var getChoice = function(elmt) { var getChoice = function(elmt) {
var index = parseInt(elmt.attr("choiceIndex"),10); var index = parseInt(elmt.attr("choiceIndex"),10);
if (index == -1) { if (index === -1) {
return self._blankChoice; return self._blankChoice;
} else if (index == -2) { } else if (index === -2) {
return self._errorChoice; return self._errorChoice;
} else { } else {
return choices[index]; return choices[index];
@ -450,7 +450,7 @@ ListFacet.prototype._update = function(resetScroll) {
bodyInnerDiv.on('mouseenter mouseleave', '.facet-choice', function(e) { bodyInnerDiv.on('mouseenter mouseleave', '.facet-choice', function(e) {
e.preventDefault(); e.preventDefault();
var visibility = 'visible'; var visibility = 'visible';
if (e.type == 'mouseleave') { if (e.type === 'mouseleave') {
visibility = 'hidden'; visibility = 'hidden';
} }
$(this).find('.facet-choice-edit').css("visibility", visibility); $(this).find('.facet-choice-edit').css("visibility", visibility);
@ -579,7 +579,7 @@ ListFacet.prototype._editChoice = function(choice, choiceDiv) {
var gotSelection = false; var gotSelection = false;
for (var i = 0; i < self._selection.length; i++) { for (var i = 0; i < self._selection.length; i++) {
var choice = self._selection[i]; var choice = self._selection[i];
if (choice.v.v == originalContent) { if (choice.v.v === originalContent) {
if (gotSelection) { if (gotSelection) {
continue; continue;
} }
@ -599,9 +599,9 @@ ListFacet.prototype._editChoice = function(choice, choiceDiv) {
.text(originalContent) .text(originalContent)
.keydown(function(evt) { .keydown(function(evt) {
if (!evt.shiftKey) { if (!evt.shiftKey) {
if (evt.keyCode == 13) { if (evt.keyCode === 13) {
commit(); commit();
} else if (evt.keyCode == 27) { } else if (evt.keyCode === 27) {
MenuSystem.dismissAll(); MenuSystem.dismissAll();
} }
} }
@ -699,7 +699,7 @@ ListFacet.prototype._editExpression = function() {
self._elmts.expressionDiv.text(self._config.expression); self._elmts.expressionDiv.text(self._config.expression);
self._elmts.changeButton.attr("title", $.i18n._('core-facets')["current-exp"]+": " + self._config.expression); self._elmts.changeButton.attr("title", $.i18n._('core-facets')["current-exp"]+": " + self._config.expression);
if (self._config.expression == "value" || self._config.expression == "grel:value") { if (self._config.expression === "value" || self._config.expression === "grel:value") {
self._elmts.clusterLink.show(); self._elmts.clusterLink.show();
} else { } else {
self._elmts.clusterLink.hide(); self._elmts.clusterLink.hide();
@ -728,9 +728,9 @@ ListFacet.prototype._setChoiceCountLimit = function(choiceCount) {
value : n value : n
}, },
function(o) { function(o) {
if (o.code == "ok") { if (o.code === "ok") {
ui.browsingEngine.update(); ui.browsingEngine.update();
} else if (o.code == "error") { } else if (o.code === "error") {
alert(o.message); alert(o.message);
} }
}, },

View File

@ -113,7 +113,7 @@ TextSearchFacet.prototype._initializeUI = function() {
if (this._config.caseSensitive) { if (this._config.caseSensitive) {
this._elmts.caseSensitiveCheckbox.attr("checked", "true"); this._elmts.caseSensitiveCheckbox.attr("checked", "true");
} }
if (this._config.mode == "regex") { if (this._config.mode === "regex") {
this._elmts.regexCheckbox.attr("checked", "true"); this._elmts.regexCheckbox.attr("checked", "true");
} }
@ -192,7 +192,7 @@ TextSearchFacet.prototype._update = function () {
this._elmts.facetTitle.removeClass("facet-title-inverted"); this._elmts.facetTitle.removeClass("facet-title-inverted");
this._elmts.invertButton.removeClass("facet-mode-inverted"); this._elmts.invertButton.removeClass("facet-mode-inverted");
} }
} };
TextSearchFacet.prototype._scheduleUpdate = function() { TextSearchFacet.prototype._scheduleUpdate = function() {
if (!this._timerID) { if (!this._timerID) {