1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-01-29 10:37:59 +01: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",
"array-bracket-spacing": "off",
"array-callback-return": "error",
"arrow-body-style": "error",
"arrow-body-style": "off",
"arrow-parens": "error",
"arrow-spacing": "error",
"block-scoped-var": "error",
@ -120,7 +120,7 @@
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-nested-ternary": "off",
"no-new": "error",
"no-new": "off",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
@ -246,6 +246,8 @@
]
},
"globals": {
"ArrayBuffer": true,
"Uint8Array": true,
"chrome": true,
"CodeMirror": true,
"Split": true,

View File

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

View File

@ -1,15 +1,11 @@
// textarea-autocomplete.js
(function() {
var timeout;
var t, list;
var isShowingSuggestions = false;
class TextareaAutoComplete {
constructor (textarea, filter) {
this.t = textarea;
this.filter = filter;
this.filter = filter;
var wrap = document.createElement('div');
wrap.classList.add('btn-group');
textarea.parentElement.insertBefore(wrap, textarea);
@ -34,10 +30,10 @@
});
},100);
this.t.addEventListener('input', e => this.onInput(e));
this.t.addEventListener('keydown', e => this.onKeyDown(e));
this.t.addEventListener('blur', e => this.closeSuggestions());
this.list.addEventListener('mousedown', e => this.onListMouseDown(e));
this.t.addEventListener('input', (e) => this.onInput(e));
this.t.addEventListener('keydown', (e) => this.onKeyDown(e));
this.t.addEventListener('blur', (e) => this.closeSuggestions(e));
this.list.addEventListener('mousedown', (e) => this.onListMouseDown(e));
}
get currentLineNumber() {
@ -52,23 +48,10 @@
this.isShowingSuggestions = false;
}
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=';
return fetch(url + input)
.then(response => {
return response.json().then(json => json.results);
.then((response) => {
return response.json().then((json) => json.results);
});
}
replaceCurrentLine(val) {
@ -83,7 +66,7 @@
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
this.loader.style.display = 'block';
this.getList(currentLine).then(arr => {
this.getList(currentLine).then((arr) => {
this.loader.style.display = 'none';
if (!arr.length) {
this.closeSuggestions();
@ -91,6 +74,8 @@
}
this.list.innerHTML = '';
if (this.filter) {
/* eslint-disable no-param-reassign */
arr = arr.filter(this.filter);
}
for (var i = 0; i < Math.min(arr.length, 10); i++) {
@ -109,6 +94,7 @@
}
}
onKeyDown(event) {
var selectedItemElement;
if (!this.isShowingSuggestions) { return; }
if (event.keyCode === 27) {
@ -116,7 +102,7 @@
event.stopPropagation();
}
if (event.keyCode === 40 && this.isShowingSuggestions) {
var selectedItemElement = this.list.querySelector('.selected');
selectedItemElement = this.list.querySelector('.selected');
if (selectedItemElement) {
selectedItemElement.classList.remove('selected');
selectedItemElement.nextElementSibling.classList.add('selected');
@ -125,7 +111,7 @@
}
event.preventDefault();
} else if (event.keyCode === 38 && this.isShowingSuggestions) {
var selectedItemElement = this.list.querySelector('.selected');
selectedItemElement = this.list.querySelector('.selected');
if (selectedItemElement) {
selectedItemElement.classList.remove('selected');
selectedItemElement.previousElementSibling.classList.add('selected');
@ -134,7 +120,7 @@
}
event.preventDefault();
} else if (event.keyCode === 13 && this.isShowingSuggestions) {
var selectedItemElement = this.list.querySelector('.selected');
selectedItemElement = this.list.querySelector('.selected');
this.replaceCurrentLine(selectedItemElement.dataset.url)
this.closeSuggestions();
}