1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-09 16:06:21 +02:00

eslint fixes :|

This commit is contained in:
Kushagra Gour
2017-02-05 17:29:50 +05:30
parent f0978bf634
commit 145c476abe
3 changed files with 47 additions and 59 deletions

View File

@ -8,7 +8,7 @@
"accessor-pairs": "error", "accessor-pairs": "error",
"array-bracket-spacing": "off", "array-bracket-spacing": "off",
"array-callback-return": "error", "array-callback-return": "error",
"arrow-body-style": "error", "arrow-body-style": "off",
"arrow-parens": "error", "arrow-parens": "error",
"arrow-spacing": "error", "arrow-spacing": "error",
"block-scoped-var": "error", "block-scoped-var": "error",
@ -120,7 +120,7 @@
"no-native-reassign": "error", "no-native-reassign": "error",
"no-negated-condition": "off", "no-negated-condition": "off",
"no-nested-ternary": "off", "no-nested-ternary": "off",
"no-new": "error", "no-new": "off",
"no-new-func": "error", "no-new-func": "error",
"no-new-object": "error", "no-new-object": "error",
"no-new-require": "error", "no-new-require": "error",
@ -246,6 +246,8 @@
] ]
}, },
"globals": { "globals": {
"ArrayBuffer": true,
"Uint8Array": true,
"chrome": true, "chrome": true,
"CodeMirror": true, "CodeMirror": true,
"Split": true, "Split": true,

View File

@ -3,7 +3,8 @@
onboardModal, layoutBtn1, layoutBtn2, layoutBtn3, layoutBtn4, helpBtn, onboardModal, onboardModal, onboardModal, layoutBtn1, layoutBtn2, layoutBtn3, layoutBtn4, helpBtn, onboardModal, onboardModal,
addLibraryModal, addLibraryModal, notificationsBtn, notificationsModal, notificationsModal, addLibraryModal, addLibraryModal, notificationsBtn, notificationsModal, notificationsModal,
notificationsModal, notificationsBtn, codepenBtn, saveHtmlBtn, openBtn, saveBtn, newBtn, notificationsModal, notificationsBtn, codepenBtn, saveHtmlBtn, openBtn, saveBtn, newBtn,
settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardDontShowInTabOptionBtn */ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardDontShowInTabOptionBtn
TextareaAutoComplete */
/* eslint-disable no-extra-semi */ /* eslint-disable no-extra-semi */
;(function (alertsService) { ;(function (alertsService) {
@ -762,8 +763,8 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
// cursorScrollMargin: '20', has issue with scrolling // cursorScrollMargin: '20', has issue with scrolling
profile: options.profile || '', profile: options.profile || '',
extraKeys: { extraKeys: {
"Shift-Tab": function(cm) { "Shift-Tab": function(editor) {
CodeMirror.commands.indentAuto(cm); CodeMirror.commands.indentAuto(editor);
} }
} }
}); });
@ -844,7 +845,7 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
} }
// create a blob for writing to a file // create a blob for writing to a file
var blob = new Blob([ab], {type: mimeString}); var blob = new Blob([ab], { type: mimeString });
var size = blob.size + (1024 / 2); var size = blob.size + (1024 / 2);
var d = new Date(); var d = new Date();
@ -870,9 +871,9 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
} }
// create a blob for writing to a file // create a blob for writing to a file
window.webkitRequestFileSystem(window.TEMPORARY, size, fs => { window.webkitRequestFileSystem(window.TEMPORARY, size, (fs) => {
fs.root.getFile(fileName, { create: true }, fileEntry => { fs.root.getFile(fileName, { create: true }, (fileEntry) => {
fileEntry.createWriter(function(fileWriter) { fileEntry.createWriter((fileWriter) => {
fileWriter.onwriteend = onWriteEnd; fileWriter.onwriteend = onWriteEnd;
fileWriter.write(blob); fileWriter.write(blob);
}, errorHandler); }, errorHandler);
@ -886,28 +887,26 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
s.textContent = '[class*="hint"]:after, [class*="hint"]:before { display: none!important; }'; s.textContent = '[class*="hint"]:after, [class*="hint"]:before { display: none!important; }';
document.body.appendChild(s); document.body.appendChild(s);
setTimeout(() => { function onImgLoad(image) {
chrome.tabs.captureVisibleTab(
null, { format: 'png', quality: 100 }, function(dataURI) {
s.remove();
if (dataURI) {
var image = new Image();
function onImgLoad() {
var c = document.createElement('canvas'); var c = document.createElement('canvas');
var iframeBounds = frame.getBoundingClientRect(); var iframeBounds = frame.getBoundingClientRect();
c.width = iframeBounds.width; c.width = iframeBounds.width;
c.height = iframeBounds.height; c.height = iframeBounds.height;
utils.log(c, iframeBounds) var ctx = c.getContext('2d');
ctx = c.getContext('2d');
ctx.drawImage(image, ctx.drawImage(image,
iframeBounds.left, iframeBounds.top, iframeBounds.width, iframeBounds.height, iframeBounds.left, iframeBounds.top, iframeBounds.width, iframeBounds.height,
0, 0, iframeBounds.width, iframeBounds.height); 0, 0, iframeBounds.width, iframeBounds.height);
image.removeEventListener('load', onImgLoad); image.removeEventListener('load', onImgLoad);
saveScreenshot(c.toDataURL()); saveScreenshot(c.toDataURL());
}; }
setTimeout(() => {
chrome.tabs.captureVisibleTab(null, { format: 'png', quality: 100 }, function(dataURI) {
s.remove();
if (dataURI) {
var image = new Image();
image.src = dataURI; image.src = dataURI;
image.addEventListener('load', onImgLoad); image.addEventListener('load', () => onImgLoad(image, dataURI));
} }
}); });
}, 50); }, 50);
@ -1067,6 +1066,7 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
}); });
window.addEventListener('keydown', function (event) { window.addEventListener('keydown', function (event) {
var selectedItemElement;
// Ctrl/⌘ + S // Ctrl/⌘ + S
if ((event.ctrlKey || event.metaKey) && (event.keyCode === 83)) { if ((event.ctrlKey || event.metaKey) && (event.keyCode === 83)) {
event.preventDefault(); event.preventDefault();
@ -1083,7 +1083,7 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
closeAllOverlays(); closeAllOverlays();
} }
if (event.keyCode === 40 && savedItemsPane.classList.contains('is-open')) { if (event.keyCode === 40 && savedItemsPane.classList.contains('is-open')) {
var selectedItemElement = $('.js-saved-item-tile.selected'); selectedItemElement = $('.js-saved-item-tile.selected');
if (selectedItemElement) { if (selectedItemElement) {
selectedItemElement.classList.remove('selected'); selectedItemElement.classList.remove('selected');
selectedItemElement.nextElementSibling.classList.add('selected'); selectedItemElement.nextElementSibling.classList.add('selected');
@ -1091,7 +1091,7 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
$('.js-saved-item-tile:first-child').classList.add('selected'); $('.js-saved-item-tile:first-child').classList.add('selected');
} }
} else if (event.keyCode === 38 && savedItemsPane.classList.contains('is-open')) { } else if (event.keyCode === 38 && savedItemsPane.classList.contains('is-open')) {
var selectedItemElement = $('.js-saved-item-tile.selected'); selectedItemElement = $('.js-saved-item-tile.selected');
if (selectedItemElement) { if (selectedItemElement) {
selectedItemElement.classList.remove('selected'); selectedItemElement.classList.remove('selected');
selectedItemElement.previousElementSibling.classList.add('selected'); selectedItemElement.previousElementSibling.classList.add('selected');
@ -1099,7 +1099,7 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
$('.js-saved-item-tile:first-child').classList.add('selected'); $('.js-saved-item-tile:first-child').classList.add('selected');
} }
} else if (event.keyCode === 13 && savedItemsPane.classList.contains('is-open')) { } else if (event.keyCode === 13 && savedItemsPane.classList.contains('is-open')) {
var selectedItemElement = $('.js-saved-item-tile.selected'); selectedItemElement = $('.js-saved-item-tile.selected');
setTimeout(function () { setTimeout(function () {
openItem(selectedItemElement.dataset.itemId); openItem(selectedItemElement.dataset.itemId);
}, 350); }, 350);
@ -1144,8 +1144,8 @@ settingsBtn, onboardModal, notificationsBtn, onboardShowInTabOptionBtn, onboardD
externalJsTextarea.addEventListener('blur', onExternalLibChange); externalJsTextarea.addEventListener('blur', onExternalLibChange);
externalCssTextarea.addEventListener('blur', onExternalLibChange); externalCssTextarea.addEventListener('blur', onExternalLibChange);
new TextareaAutoComplete(externalJsTextarea, obj => obj.latest.match(/\.js$/)); new TextareaAutoComplete(externalJsTextarea, (obj) => obj.latest.match(/\.js$/));
new TextareaAutoComplete(externalCssTextarea, obj => obj.latest.match(/\.css$/)); new TextareaAutoComplete(externalCssTextarea, (obj) => obj.latest.match(/\.css$/));
chrome.storage.local.get({ chrome.storage.local.get({
layoutMode: 1, layoutMode: 1,

View File

@ -1,10 +1,6 @@
// textarea-autocomplete.js // textarea-autocomplete.js
(function() { (function() {
var timeout;
var t, list;
var isShowingSuggestions = false;
class TextareaAutoComplete { class TextareaAutoComplete {
constructor (textarea, filter) { constructor (textarea, filter) {
@ -34,10 +30,10 @@
}); });
},100); },100);
this.t.addEventListener('input', e => this.onInput(e)); this.t.addEventListener('input', (e) => this.onInput(e));
this.t.addEventListener('keydown', e => this.onKeyDown(e)); this.t.addEventListener('keydown', (e) => this.onKeyDown(e));
this.t.addEventListener('blur', e => this.closeSuggestions()); this.t.addEventListener('blur', (e) => this.closeSuggestions(e));
this.list.addEventListener('mousedown', e => this.onListMouseDown(e)); this.list.addEventListener('mousedown', (e) => this.onListMouseDown(e));
} }
get currentLineNumber() { get currentLineNumber() {
@ -52,23 +48,10 @@
this.isShowingSuggestions = false; this.isShowingSuggestions = false;
} }
getList(input) { getList(input) {
// return new Promise((resolve) => {
// resolve([
// { name: 'asdsd', latest: 'dsfdsfsdf/sdf/sd/f/df'},
// { name: 'asdsd', latest: 'dsfdsfsdf/sdf/sd/f/df'},
// { name: 'asdsd', latest: 'dsfdsfsdf/sdf/sd/f/df'},
// { name: 'asdsd', latest: 'dsfdsfsdf/sdf/sd/f/df'},
// { name: 'asdsd', latest: 'dsfdsfsdf/sdf/sd/f/df'},
// { name: 'asdsd', latest: 'dsfdsfsdf/sdf/sd/f/df'},
// { name: 'asdsd', latest: 'dsfdsfsdf/sdf/sd/f/df'},
// { name: 'asdsd', latest: 'dsfdsfsdf/sdf/sd/f/df'},
// { name: 'asdsd', latest: 'dsfdsfsdf/sdf/sd/f/df'},
// ])
// })
var url = 'https://api.cdnjs.com/libraries?search='; var url = 'https://api.cdnjs.com/libraries?search=';
return fetch(url + input) return fetch(url + input)
.then(response => { .then((response) => {
return response.json().then(json => json.results); return response.json().then((json) => json.results);
}); });
} }
replaceCurrentLine(val) { replaceCurrentLine(val) {
@ -83,7 +66,7 @@
clearTimeout(this.timeout); clearTimeout(this.timeout);
this.timeout = setTimeout(() => { this.timeout = setTimeout(() => {
this.loader.style.display = 'block'; this.loader.style.display = 'block';
this.getList(currentLine).then(arr => { this.getList(currentLine).then((arr) => {
this.loader.style.display = 'none'; this.loader.style.display = 'none';
if (!arr.length) { if (!arr.length) {
this.closeSuggestions(); this.closeSuggestions();
@ -91,6 +74,8 @@
} }
this.list.innerHTML = ''; this.list.innerHTML = '';
if (this.filter) { if (this.filter) {
/* eslint-disable no-param-reassign */
arr = arr.filter(this.filter); arr = arr.filter(this.filter);
} }
for (var i = 0; i < Math.min(arr.length, 10); i++) { for (var i = 0; i < Math.min(arr.length, 10); i++) {
@ -109,6 +94,7 @@
} }
} }
onKeyDown(event) { onKeyDown(event) {
var selectedItemElement;
if (!this.isShowingSuggestions) { return; } if (!this.isShowingSuggestions) { return; }
if (event.keyCode === 27) { if (event.keyCode === 27) {
@ -116,7 +102,7 @@
event.stopPropagation(); event.stopPropagation();
} }
if (event.keyCode === 40 && this.isShowingSuggestions) { if (event.keyCode === 40 && this.isShowingSuggestions) {
var selectedItemElement = this.list.querySelector('.selected'); selectedItemElement = this.list.querySelector('.selected');
if (selectedItemElement) { if (selectedItemElement) {
selectedItemElement.classList.remove('selected'); selectedItemElement.classList.remove('selected');
selectedItemElement.nextElementSibling.classList.add('selected'); selectedItemElement.nextElementSibling.classList.add('selected');
@ -125,7 +111,7 @@
} }
event.preventDefault(); event.preventDefault();
} else if (event.keyCode === 38 && this.isShowingSuggestions) { } else if (event.keyCode === 38 && this.isShowingSuggestions) {
var selectedItemElement = this.list.querySelector('.selected'); selectedItemElement = this.list.querySelector('.selected');
if (selectedItemElement) { if (selectedItemElement) {
selectedItemElement.classList.remove('selected'); selectedItemElement.classList.remove('selected');
selectedItemElement.previousElementSibling.classList.add('selected'); selectedItemElement.previousElementSibling.classList.add('selected');
@ -134,7 +120,7 @@
} }
event.preventDefault(); event.preventDefault();
} else if (event.keyCode === 13 && this.isShowingSuggestions) { } else if (event.keyCode === 13 && this.isShowingSuggestions) {
var selectedItemElement = this.list.querySelector('.selected'); selectedItemElement = this.list.querySelector('.selected');
this.replaceCurrentLine(selectedItemElement.dataset.url) this.replaceCurrentLine(selectedItemElement.dataset.url)
this.closeSuggestions(); this.closeSuggestions();
} }