code consistency

This commit is contained in:
Gerome Matilla 2020-06-09 12:26:02 +08:00
parent 2c3f2dfc3f
commit 24b7d4ff0f
6 changed files with 12 additions and 11 deletions

View File

@ -33,7 +33,7 @@ class AutoSuggestion {
this._searchBox.focus();
} else if ((e.key == 'ArrowDown') || e.key == 'ArrowRight') {
} else if ((e.key === 'ArrowDown') || e.key === 'ArrowRight') {
e.preventDefault();
@ -42,7 +42,7 @@ class AutoSuggestion {
const phraseButton = phraseButtons[phraseIndex];
phraseButton.focus();
} else if ((e.key == 'ArrowUp') || e.key == 'ArrowLeft') {
} else if ((e.key === 'ArrowUp') || e.key === 'ArrowLeft') {
e.preventDefault();
@ -105,6 +105,7 @@ class AutoSuggestion {
const endpoint = 'https://duckduckgo.com/ac/';
const callback = 'autocompleteCallback'
const searchQuery = String(this._searchBox.value);
window[callback] = res => {
// Passed the suggestion object to process it
this._autocompleteCallback(res);
@ -113,7 +114,7 @@ class AutoSuggestion {
// Fetch from duckduckgo
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = `${endpoint}?callback=${callback}&q=` + String(this._searchBox.value);
script.src = `${endpoint}?callback=${callback}&q=${searchQuery}`;
document.querySelector('head').appendChild(script);
}

View File

@ -26,7 +26,7 @@ class Clock {
// Assigning
midDay = (hour >= 12) ? 'PM' : 'AM';
hour = (hour == 0) ? 12 : ((hour > 12) ? (hour - 12) : hour);
hour = (hour === 0) ? 12 : ((hour > 12) ? (hour - 12) : hour);
hour = this._appendZero(hour);
min = this._appendZero(min);

View File

@ -15,10 +15,10 @@ class SwipeEventCallbacks extends SwipeEventManager {
} else if (d === 'down') {
// Swiping down will open search box
searchBoxShow.toggleSearchBox();
} else if (d == 'right') {
} else if (d === 'right') {
// Swiping right will open web menu
webMenu.toggleWebMenu();
} else if (d == 'up') {
} else if (d === 'up') {
// Swiping up will open weather screen
weatherScreen.toggleWeatherScreen();
}
@ -46,7 +46,7 @@ class SwipeEventCallbacks extends SwipeEventManager {
_webMenuSwipeEvent = (el, d) => {
// Swiping left will close web menu
if (d == 'left') {
if (d === 'left') {
webMenu.toggleWebMenu();
}
}
@ -55,7 +55,7 @@ class SwipeEventCallbacks extends SwipeEventManager {
_weatherScreenSwipeEvent = (el, d) => {
// Swiping left will the weather screem
if (d == 'left') {
if (d === 'left') {
weatherScreen.toggleWeatherScreen();
}
}

View File

@ -59,7 +59,7 @@ class SwipeEventManager {
this._yDown = null;
if (dir !== ''){
if (typeof callback == 'function') {
if (typeof callback === 'function') {
callback(el, dir);
}
}

View File

@ -58,7 +58,7 @@ class ThemeEngine {
return colorStr.replace(/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/, '#$1$1$2$2$3$3');
// If three-charactered HEX Color(#RGB) with AA - (#RGBAA)
} else if (colorStr.length == 6) {
} else if (colorStr.length === 6) {
const bg = colorStr.slice(0, -2);
const op = colorStr.slice(-2);

View File

@ -128,7 +128,7 @@ class WebMenu {
for (let i = 0; i < compare.length; i++) {
string.indexOf(compare[i]) > -1 ? matches += 1 : matches -=1;
}
return ((matches / this.length) >= ratio || term == '');
return ((matches / this.length) >= ratio || term === '');
};
}