Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
fix #193: Reformat all the core files according to new eslint/prettie…
Browse files Browse the repository at this point in the history
…r config (#194)
  • Loading branch information
makkoncept committed Mar 13, 2020
1 parent ed35d53 commit 0ba8a76
Show file tree
Hide file tree
Showing 31 changed files with 165 additions and 225 deletions.
6 changes: 1 addition & 5 deletions src/manifest.chrome.json
Expand Up @@ -20,11 +20,7 @@
},
"default_popup": "popup/popup.html"
},
"permissions": [
"storage",
"https://api.creativecommons.engineering/*",
"https://*.behance.net/*"
],
"permissions": ["storage", "https://api.creativecommons.engineering/*", "https://*.behance.net/*"],
"options_ui": {
"page": "options/options.html",
"open_in_tab": true
Expand Down
6 changes: 1 addition & 5 deletions src/manifest.opera.json
Expand Up @@ -20,11 +20,7 @@
},
"default_popup": "popup/popup.html"
},
"permissions": [
"storage",
"https://api.creativecommons.engineering/*",
"https://*.behance.net/*"
],
"permissions": ["storage", "https://api.creativecommons.engineering/*", "https://*.behance.net/*"],
"options_ui": {
"page": "options/options.html",
"open_in_tab": true
Expand Down
8 changes: 4 additions & 4 deletions src/options/helper.js
Expand Up @@ -4,7 +4,7 @@ import { showNotification, getLatestSources } from '../utils';
export function restoreFilters(inputElements) {
for (let i = 0; i < inputElements.length; i += 1) {
const { id } = inputElements[i];
chrome.storage.sync.get({ [id]: false }, (items) => {
chrome.storage.sync.get({ [id]: false }, items => {
// default value is false
document.getElementById(id).checked = items[id];
});
Expand All @@ -19,7 +19,7 @@ function addProvidersToDom(providers) {
const { providerWrapper } = elements;
providerWrapper.innerText = '';

Object.keys(providers).forEach((key) => {
Object.keys(providers).forEach(key => {
const input = document.createElement('input');
input.type = 'checkbox';
input.id = providers[key];
Expand Down Expand Up @@ -69,9 +69,9 @@ export function saveFiltersOptions() {
}

export function updateBookmarks(newBookmarksids) {
chrome.storage.sync.get({ bookmarks: [] }, (items) => {
chrome.storage.sync.get({ bookmarks: [] }, items => {
const bookmarksArray = items.bookmarks;
newBookmarksids.forEach((bookmarkId) => {
newBookmarksids.forEach(bookmarkId => {
if (bookmarksArray.indexOf(bookmarkId) === -1) {
bookmarksArray.push(bookmarkId);
chrome.storage.sync.set({ bookmarks: bookmarksArray }, () => {
Expand Down
76 changes: 35 additions & 41 deletions src/options/options.js
@@ -1,7 +1,5 @@
import elements from './base';
import {
init, saveFiltersOptions, updateBookmarks, toggleAccordion,
} from './helper';
import { init, saveFiltersOptions, updateBookmarks, toggleAccordion } from './helper';
import { showNotification } from '../utils';

let enableSearchStorageOption = true;
Expand All @@ -12,21 +10,21 @@ document.addEventListener('DOMContentLoaded', init);
elements.saveFiltersButton.addEventListener('click', saveFiltersOptions);

// Making sure that only license or use-case is selected at the same time
Array.prototype.forEach.call(elements.useCaseInputs, (element) => {
element.addEventListener('click', (e) => {
Array.prototype.forEach.call(elements.useCaseInputs, element => {
element.addEventListener('click', e => {
if (e.target.checked) {
Array.prototype.forEach.call(elements.licenseInputs, (licenseElement) => {
Array.prototype.forEach.call(elements.licenseInputs, licenseElement => {
// eslint-disable-next-line no-param-reassign
licenseElement.checked = false;
});
}
});
});

Array.prototype.forEach.call(elements.licenseInputs, (element) => {
element.addEventListener('click', (e) => {
Array.prototype.forEach.call(elements.licenseInputs, element => {
element.addEventListener('click', e => {
if (e.target.checked) {
Array.prototype.forEach.call(elements.useCaseInputs, (licenseElement) => {
Array.prototype.forEach.call(elements.useCaseInputs, licenseElement => {
// eslint-disable-next-line no-param-reassign
licenseElement.checked = false;
});
Expand All @@ -35,37 +33,39 @@ Array.prototype.forEach.call(elements.licenseInputs, (element) => {
});

function initEnableSearchStorageButton() {
chrome.storage.sync.get(['enableSearchStorage'], (res) => {
chrome.storage.sync.get(['enableSearchStorage'], res => {
enableSearchStorageOption = res.enableSearchStorage;
elements.enableSearchStorageCheckbox.checked = enableSearchStorageOption;
});
}
initEnableSearchStorageButton();

elements.enableSearchStorageCheckbox.addEventListener(('click'), () => {
chrome.storage.sync.set({ enableSearchStorage: elements.enableSearchStorageCheckbox.checked },
() => {
showNotification('Settings Saved', 'positive', 'snackbar-options');
});
elements.enableSearchStorageCheckbox.addEventListener('click', () => {
chrome.storage.sync.set({ enableSearchStorage: elements.enableSearchStorageCheckbox.checked }, () => {
showNotification('Settings Saved', 'positive', 'snackbar-options');
});

// Clear Saved Search If user selects the option to not save their search.
if (!elements.enableSearchStorageCheckbox.checked) localStorage.clear();
});

function initEnableSearchClearConfirmButton() {
chrome.storage.sync.get(['enableSearchClearConfirm'], (res) => {
chrome.storage.sync.get(['enableSearchClearConfirm'], res => {
enableSearchClearConfirmOption = res.enableSearchClearConfirm;
elements.enableSearchClearConfirmCheckbox.checked = enableSearchClearConfirmOption;
});
}
initEnableSearchClearConfirmButton();

elements.enableSearchClearConfirmCheckbox.addEventListener(('click'), () => {
chrome.storage.sync.set({
enableSearchClearConfirm: elements.enableSearchClearConfirmCheckbox.checked,
}, () => {
showNotification('Settings Saved', 'positive', 'snackbar-options');
});
elements.enableSearchClearConfirmCheckbox.addEventListener('click', () => {
chrome.storage.sync.set(
{
enableSearchClearConfirm: elements.enableSearchClearConfirmCheckbox.checked,
},
() => {
showNotification('Settings Saved', 'positive', 'snackbar-options');
},
);
});

elements.importBookmarksButton.addEventListener('click', () => {
Expand All @@ -77,21 +77,18 @@ elements.importBookmarksButton.addEventListener('click', () => {
} else {
const reader = new FileReader();
reader.readAsText(file, 'UTF-8');
reader.onload = (evt) => {
reader.onload = evt => {
const fileContents = evt.target.result;
try {
const bookmarksArray = JSON.parse(fileContents);
if (Array.isArray(bookmarksArray)) {
if (!bookmarksArray.length > 0) showNotification('No bookmark ids found in file', 'negative', 'snackbar-options');
if (!bookmarksArray.length > 0)
showNotification('No bookmark ids found in file', 'negative', 'snackbar-options');
else {
updateBookmarks(bookmarksArray);
}
} else {
showNotification(
'Contents not in valid format of ["id1", "id2", ...]',
'negative',
'snackbar-options',
);
showNotification('Contents not in valid format of ["id1", "id2", ...]', 'negative', 'snackbar-options');
}
} catch (error) {
showNotification('This is not a valid JSON', 'negative', 'snackbar-options');
Expand All @@ -101,10 +98,10 @@ elements.importBookmarksButton.addEventListener('click', () => {
});

// tab switching logic
document.getElementById('vocab-tabbed-header').addEventListener('click', (e) => {
document.getElementById('vocab-tabbed-header').addEventListener('click', e => {
// removing active class
if (e.target.classList.contains('tab')) {
Array.prototype.forEach.call(e.currentTarget.getElementsByClassName('tab active'), (element) => {
Array.prototype.forEach.call(e.currentTarget.getElementsByClassName('tab active'), element => {
element.classList.remove('active');
});

Expand All @@ -115,16 +112,13 @@ document.getElementById('vocab-tabbed-header').addEventListener('click', (e) =>
let targetContentDiv;

// removing active class from any tab content div
Array.prototype.forEach.call(
document.getElementById('vocab-tabbed-contents').children,
(element) => {
element.classList.remove('active');
if (element.getAttribute('data-content-no') === tabNo) {
// saving the target content div
targetContentDiv = element;
}
},
);
Array.prototype.forEach.call(document.getElementById('vocab-tabbed-contents').children, element => {
element.classList.remove('active');
if (element.getAttribute('data-content-no') === tabNo) {
// saving the target content div
targetContentDiv = element;
}
});

// adding active class to target content div
targetContentDiv.classList.add('active');
Expand Down
2 changes: 1 addition & 1 deletion src/options/sass/base/_typography.scss
@@ -1,5 +1,5 @@
body {
font-family: "Lato", "Arial", sans-serif;
font-family: 'Lato', 'Arial', sans-serif;
font-weight: 500;
font-size: 1rem;
color: #383838;
Expand Down
2 changes: 1 addition & 1 deletion src/options/sass/base/_utilities.scss
Expand Up @@ -24,4 +24,4 @@

.margin-left-medium {
margin-left: 1rem !important;
}
}
4 changes: 2 additions & 2 deletions src/options/sass/components/_faq_tab.scss
@@ -1,4 +1,4 @@
.accordion{
.accordion {
.accordion-link {
position: relative;
display: -webkit-box;
Expand All @@ -14,7 +14,7 @@
width: 100%;
padding: 1rem 3rem 1rem 1rem;
color: $color-primary-light;
font-size: 1.20rem;
font-size: 1.2rem;
border-bottom: 1px solid #e5e5e5;
}

Expand Down
3 changes: 1 addition & 2 deletions src/options/sass/components/_options.scss
Expand Up @@ -9,8 +9,7 @@ ul {

.filter-checkboxes {
margin-left: 1rem;
input[type="checkbox"] {
input[type='checkbox'] {
margin-bottom: 0.2rem;
}
}

14 changes: 7 additions & 7 deletions src/options/sass/main.scss
@@ -1,9 +1,9 @@
@import "../../popup/sass/abstract/variables";
@import "../../popup/sass/components/snackbar";
@import '../../popup/sass/abstract/variables';
@import '../../popup/sass/components/snackbar';

@import "base/base";
@import "base/typography";
@import "base/utilities";
@import 'base/base';
@import 'base/typography';
@import 'base/utilities';

@import "components/options";
@import "components/faq_tab";
@import 'components/options';
@import 'components/faq_tab';
4 changes: 1 addition & 3 deletions src/popup/base.js
Expand Up @@ -10,9 +10,7 @@ export const elements = {
providerChooser: document.querySelector('#choose-provider'),
licenseChooserWrapper: document.querySelector('.section-filter__filter-wrapper--choose-license'),
useCaseChooserWrapper: document.querySelector('.section-filter__filter-wrapper--choose-usecase'),
providerChooserWrapper: document.querySelector(
'.section-filter__filter-wrapper--choose-provider',
),
providerChooserWrapper: document.querySelector('.section-filter__filter-wrapper--choose-provider'),
providerChooserLoadingMessage: document.querySelector('.section-filter__provider-loading-mes'),
filterResetButton: document.querySelector('.section-filter--reset-button'),
filterApplyButton: document.querySelector('.section-filter--apply-button'),
Expand Down

0 comments on commit 0ba8a76

Please sign in to comment.