apply linter

This commit is contained in:
Simon Vieille 2021-06-15 14:26:38 +02:00
parent c25be5fe63
commit 23ebe74102
12 changed files with 283 additions and 284 deletions

View File

@ -1,4 +1,4 @@
import '../css/app.scss';
import '../css/app.scss'
const App = require('./app/app')
const FormPnw = require('./app/form-pwn')
@ -12,17 +12,17 @@ const Stats = require('./app/stats')
const Particles = require('./app/particles')
const app = new App([
new FormPnw(window),
new Post(window),
new LazyLoad(window),
new QuickPost(window),
new Code(window),
new Knmc(window),
new VideoRatio(window),
//new Stats(),
new Particles(window),
]);
new FormPnw(window),
new Post(window),
new LazyLoad(window),
new QuickPost(window),
new Code(window),
new Knmc(window),
new VideoRatio(window),
// new Stats(),
new Particles(window)
])
window.addEventListener('load', function() {
app.init();
}, false);
window.addEventListener('load', function () {
app.init()
}, false)

View File

@ -1,17 +1,17 @@
const App = function(components) {
this.components = components || [];
const App = function (components) {
this.components = components || []
}
App.prototype.add = function(c) {
this.components.push(c);
App.prototype.add = function (c) {
this.components.push(c)
return this;
return this
}
App.prototype.init = function() {
for (var u = 0, x = this.components.length; u < x; u++) {
this.components[u].init();
}
App.prototype.init = function () {
for (let u = 0, x = this.components.length; u < x; u++) {
this.components[u].init()
}
}
module.exports = App

View File

@ -1,64 +1,64 @@
const Prism = require('prismjs');
const Prism = require('prismjs')
require('prismjs/plugins/line-numbers/prism-line-numbers.css');
require('prismjs/themes/prism-twilight.css');
require('prismjs/plugins/line-numbers/prism-line-numbers.css')
require('prismjs/themes/prism-twilight.css')
require('prismjs/components/prism-scss');
require('prismjs/components/prism-markup');
require('prismjs/components/prism-markup-templating');
require('prismjs/components/prism-css');
require('prismjs/components/prism-clike');
require('prismjs/components/prism-javascript');
require('prismjs/components/prism-bash');
require('prismjs/components/prism-markdown');
require('prismjs/components/prism-nginx');
require('prismjs/components/prism-php');
require('prismjs/components/prism-python');
require('prismjs/components/prism-sql');
require('prismjs/components/prism-yaml');
require('prismjs/components/prism-scss')
require('prismjs/components/prism-markup')
require('prismjs/components/prism-markup-templating')
require('prismjs/components/prism-css')
require('prismjs/components/prism-clike')
require('prismjs/components/prism-javascript')
require('prismjs/components/prism-bash')
require('prismjs/components/prism-markdown')
require('prismjs/components/prism-nginx')
require('prismjs/components/prism-php')
require('prismjs/components/prism-python')
require('prismjs/components/prism-sql')
require('prismjs/components/prism-yaml')
require('prismjs/plugins/keep-markup/prism-keep-markup');
require('prismjs/plugins/line-highlight/prism-line-highlight');
require('prismjs/plugins/line-numbers/prism-line-numbers');
require('prismjs/plugins/keep-markup/prism-keep-markup')
require('prismjs/plugins/line-highlight/prism-line-highlight')
require('prismjs/plugins/line-numbers/prism-line-numbers')
const Code = function(w) {
this.window = w;
const Code = function (w) {
this.window = w
}
Code.prototype.init = function() {
Prism.highlightAllUnder(document)
var elements = this.window.document.querySelectorAll('code[data-title], div[data-title]')
Code.prototype.init = function () {
Prism.highlightAllUnder(document)
const elements = this.window.document.querySelectorAll('code[data-title], div[data-title]')
for (var i = 0, len = elements.length; i < len; i++) {
var element = elements[i];
for (let i = 0, len = elements.length; i < len; i++) {
const element = elements[i]
if (element.tagName === 'CODE') {
var code = element;
var pre = code.parentNode;
var post = pre.parentNode;
} else {
var code = element.querySelector('code');
if (element.tagName === 'CODE') {
var code = element
var pre = code.parentNode
var post = pre.parentNode
} else {
var code = element.querySelector('code')
if (!code) {
continue;
}
if (!code) {
continue
}
var pre = code.parentNode;
var post = pre.parentNode;
}
if (!pre || !post) {
continue;
}
pre.classList.add('with-title');
var title = this.window.document.createElement('div');
title.classList.add('code-title');
title.textContent = element.getAttribute('data-title');
post.insertBefore(title, pre);
var pre = code.parentNode
var post = pre.parentNode
}
if (!pre || !post) {
continue
}
pre.classList.add('with-title')
const title = this.window.document.createElement('div')
title.classList.add('code-title')
title.textContent = element.getAttribute('data-title')
post.insertBefore(title, pre)
}
}
module.exports = Code

View File

@ -1,25 +1,25 @@
const Routing = require('./routing')
const FormPnw = function(w) {
this.window = w
const FormPnw = function (w) {
this.window = w
}
FormPnw.prototype.init = function() {
var doc = this.window.document
FormPnw.prototype.init = function () {
const doc = this.window.document
doc.addEventListener('mousemove', function() {
var forms = doc.querySelectorAll('form[data-form-bot]')
doc.addEventListener('mousemove', function () {
const forms = doc.querySelectorAll('form[data-form-bot]')
for (var i = 0, len = forms.length; i < len; i++) {
var form = forms[i]
var action = form.getAttribute('action')
action = action.replace(Routing.generate('blog_tech_form_without_javascript', [], false) + '?page=', '')
action = decodeURIComponent(action)
for (let i = 0, len = forms.length; i < len; i++) {
const form = forms[i]
let action = form.getAttribute('action')
action = action.replace(Routing.generate('blog_tech_form_without_javascript', [], false) + '?page=', '')
action = decodeURIComponent(action)
form.setAttribute('action', action)
form.removeAttribute('data-form-bot')
}
})
form.setAttribute('action', action)
form.removeAttribute('data-form-bot')
}
})
}
module.exports = FormPnw

View File

@ -1,34 +1,34 @@
const Mario = require('../../images/mario.gif')
const Knmc = function(w) {
this.window = w;
const Knmc = function (w) {
this.window = w
}
Knmc.prototype.init = function() {
var chars = '';
var seq = '38384040373937396665';
var body = this.window.document.querySelector('body');
Knmc.prototype.init = function () {
let chars = ''
const seq = '38384040373937396665'
const body = this.window.document.querySelector('body')
body.addEventListener('keyup', function(e) {
chars += e.keyCode.toString();
body.addEventListener('keyup', function (e) {
chars += e.keyCode.toString()
if (chars.indexOf(seq) !== -1) {
chars = '';
var url = Mario;
var image = new Image();
image.classList.add('fixed');
image.style.position = 'fixed';
image.style.bottom = '-11px';
image.style.left = '-256px';
if (chars.indexOf(seq) !== -1) {
chars = ''
const url = Mario
const image = new Image()
image.classList.add('fixed')
image.style.position = 'fixed'
image.style.bottom = '-11px'
image.style.left = '-256px'
image.onload = function() {
image.classList.add('knmc');
body.appendChild(image);
}
image.onload = function () {
image.classList.add('knmc')
body.appendChild(image)
}
image.src = url;
}
});
image.src = url
}
})
}
module.exports = Knmc

View File

@ -1,11 +1,11 @@
const lozad = require('lozad')
const LazyLoad = function() {
const LazyLoad = function () {
}
LazyLoad.prototype.init = function() {
var observer = lozad('.lazy-img');
observer.observe();
LazyLoad.prototype.init = function () {
const observer = lozad('.lazy-img')
observer.observe()
}
module.exports = LazyLoad

View File

@ -1,46 +1,46 @@
require('particles.js');
require('particles.js')
const Particles = function(w) {
this.window = w;
const Particles = function (w) {
this.window = w
}
Particles.prototype.start = function() {
if (this.window.innerWidth < 708) {
return;
}
Particles.prototype.start = function () {
if (this.window.innerWidth < 708) {
return
}
var height = this.header.offsetHeight;
var width = this.header.offsetWidth - 40;
var canvas;
const height = this.header.offsetHeight
const width = this.header.offsetWidth - 40
let canvas
this.particles.style.maxHeight = height + 'px';
this.particles.style.maxWidth = width + 'px';
this.particles.style.maxHeight = height + 'px'
this.particles.style.maxWidth = width + 'px'
particlesJS.load('particles', '/js/particles.json?v=3');
particlesJS.load('particles', '/js/particles.json?v=3')
}
Particles.prototype.clean = function() {
this.particles.innerHTML = '';
Particles.prototype.clean = function () {
this.particles.innerHTML = ''
}
Particles.prototype.init = function() {
this.particles = this.window.document.getElementById('particles');
Particles.prototype.init = function () {
this.particles = this.window.document.getElementById('particles')
if (!this.particles) {
return;
}
if (!this.particles) {
return
}
this.header = this.particles.parentNode;
this.header = this.particles.parentNode
this.clean();
this.start();
this.clean()
this.start()
var that = this;
const that = this
this.window.addEventListener('resize', function() {
that.clean();
that.start();
}, false);
this.window.addEventListener('resize', function () {
that.clean()
that.start()
}, false)
}
module.exports = Particles

View File

@ -1,120 +1,120 @@
const Routing = require('./routing')
const Post = function(w) {
this.window = w;
const Post = function (w) {
this.window = w
}
Post.prototype.commentsEvents = function() {
var document = this.window.document;
Post.prototype.commentsEvents = function () {
const document = this.window.document
var parentCommentIdField = document.getElementById('user_comment_parentCommentId');
const parentCommentIdField = document.getElementById('user_comment_parentCommentId')
if (!parentCommentIdField) {
return;
if (!parentCommentIdField) {
return
}
const isAnswerAlert = document.getElementById('answer-alert')
const cancelAnswerButton = document.getElementById('cancel-answer')
const toogleAnswerAlert = function () {
if (parentCommentIdField.value) {
isAnswerAlert.classList.remove('hidden')
} else {
isAnswerAlert.classList.add('hidden')
}
}
toogleAnswerAlert()
const answerButtons = document.querySelectorAll('a[data-answer]')
for (let i = 0, len = answerButtons.length; i < len; i++) {
answerButtons[i].addEventListener('click', function (e) {
parentCommentIdField.value = e.target.getAttribute('data-answer')
toogleAnswerAlert()
}, false)
}
cancelAnswerButton.addEventListener('click', function (e) {
e.preventDefault()
parentCommentIdField.value = null
toogleAnswerAlert()
}, false)
const previewButton = document.querySelector('.preview-button')
const previewRender = document.querySelector('#preview')
previewButton.addEventListener('click', function () {
if (previewRender.innerHTML === '') {
previewRender.innerHTML = '<p>Chargement en cours…</p>'
}
var isAnswerAlert = document.getElementById('answer-alert');
var cancelAnswerButton = document.getElementById('cancel-answer');
const content = document.querySelector('#user_comment_content').value
const httpRequest = new XMLHttpRequest()
var toogleAnswerAlert = function() {
if (parentCommentIdField.value) {
isAnswerAlert.classList.remove('hidden');
} else {
isAnswerAlert.classList.add('hidden');
}
httpRequest.onreadystatechange = function (data) {
if (httpRequest.readyState === 4 && httpRequest.status === 200) {
const json = JSON.parse(httpRequest.response)
previewRender.innerHTML = json.render
document.location.href = '#preview'
}
}
toogleAnswerAlert();
var answerButtons = document.querySelectorAll('a[data-answer]');
for (var i = 0, len = answerButtons.length; i < len; i++) {
answerButtons[i].addEventListener('click', function(e) {
parentCommentIdField.value = e.target.getAttribute('data-answer');
toogleAnswerAlert();
}, false);
}
cancelAnswerButton.addEventListener('click', function(e) {
e.preventDefault();
parentCommentIdField.value = null;
toogleAnswerAlert();
}, false);
var previewButton = document.querySelector('.preview-button');
var previewRender = document.querySelector('#preview');
previewButton.addEventListener('click', function() {
if (previewRender.innerHTML === '') {
previewRender.innerHTML = '<p>Chargement en cours…</p>';
}
var content = document.querySelector('#user_comment_content').value;
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function(data) {
if (httpRequest.readyState === 4 && httpRequest.status === 200) {
var json = JSON.parse(httpRequest.response);
previewRender.innerHTML = json.render;
document.location.href = '#preview';
}
};
httpRequest.open('POST', Routing.generate('api_blog_comment_preview'));
httpRequest.setRequestHeader(
'Content-Type',
'application/x-www-form-urlencoded'
);
httpRequest.send('content=' + encodeURIComponent(content));
}, false);
httpRequest.open('POST', Routing.generate('api_blog_comment_preview'))
httpRequest.setRequestHeader(
'Content-Type',
'application/x-www-form-urlencoded'
)
httpRequest.send('content=' + encodeURIComponent(content))
}, false)
}
Post.prototype.imagesEvents = function() {
var document = this.window.document;
var isFullscreen = false;
var images = document.querySelectorAll('.body img');
Post.prototype.imagesEvents = function () {
const document = this.window.document
let isFullscreen = false
const images = document.querySelectorAll('.body img')
var handleClick = function(image) {
if (isFullscreen) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
} else {
if (image.requestFullscreen) {
image.requestFullscreen();
} else if (image.webkitRequestFullscreen) {
image.webkitRequestFullscreen();
} else if (image.mozRequestFullScreen) {
image.mozRequestFullScreen();
}
}
isFullscreen = !isFullscreen;
};
for (var i = 0, len = images.length; i < len; i++) {
var image = images[i];
if (image.parentNode.tagName === 'A') {
continue;
}
(function(i) {
i.addEventListener('click', function() {
handleClick(i);
}, false);
})(image);
const handleClick = function (image) {
if (isFullscreen) {
if (document.exitFullscreen) {
document.exitFullscreen()
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen()
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen()
}
} else {
if (image.requestFullscreen) {
image.requestFullscreen()
} else if (image.webkitRequestFullscreen) {
image.webkitRequestFullscreen()
} else if (image.mozRequestFullScreen) {
image.mozRequestFullScreen()
}
}
isFullscreen = !isFullscreen
}
for (let i = 0, len = images.length; i < len; i++) {
const image = images[i]
if (image.parentNode.tagName === 'A') {
continue
}
(function (i) {
i.addEventListener('click', function () {
handleClick(i)
}, false)
})(image)
}
}
Post.prototype.init = function() {
this.commentsEvents();
this.imagesEvents();
Post.prototype.init = function () {
this.commentsEvents()
this.imagesEvents()
}
module.exports = Post

View File

@ -1,25 +1,25 @@
const QuickPost = function(w) {
this.window = w;
const QuickPost = function (w) {
this.window = w
}
QuickPost.prototype.init = function() {
var doc = this.window.document;
QuickPost.prototype.init = function () {
const doc = this.window.document
var images = doc.querySelectorAll('.quick-image img');
const images = doc.querySelectorAll('.quick-image img')
for (var i = 0, len = images.length; i < len; i++) {
(function(image) {
var source = image.getAttribute('data-src');
var loader = new Image();
for (let i = 0, len = images.length; i < len; i++) {
(function (image) {
const source = image.getAttribute('data-src')
const loader = new Image()
loader.onload = function() {
image.style.backgroundImage = 'url(' + source + ')';
image.style.backgroundSize = 'cover';
}
loader.onload = function () {
image.style.backgroundImage = 'url(' + source + ')'
image.style.backgroundSize = 'cover'
}
loader.src = source;
})(images[i]);
}
loader.src = source
})(images[i])
}
}
module.exports = QuickPost

View File

@ -1,8 +1,7 @@
const routes = require('../../../public/js/fos_js_routes.json');
const Routing = require('./../../../vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js');
const routes = require('../../../public/js/fos_js_routes.json')
const Routing = require('./../../../vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js')
Routing.setRoutingData(routes);
Routing.setRoutingData(routes)
Routing.setScheme(location.protocol.replace(':', ''))
module.exports = Routing

View File

@ -1,20 +1,20 @@
const Stats = function() {
const Stats = function () {
}
Stats.prototype.init = function() {
(function(f, a, t, h, o, m){
a[h]=a[h]||function(){
(a[h].q=a[h].q||[]).push(arguments)
};
o=f.createElement('script'),
m=f.getElementsByTagName('script')[0];
o.async=1; o.src=t; o.id='fathom-script';
m.parentNode.insertBefore(o,m)
})(document, window, '//ftm.deblan.org/tracker.js', 'fathom');
fathom('set', 'siteId', 'HQAWS');
fathom('trackPageview');
Stats.prototype.init = function () {
(function (f, a, t, h, o, m) {
a[h] = a[h] || function () {
(a[h].q = a[h].q || []).push(arguments)
}
o = f.createElement('script'),
m = f.getElementsByTagName('script')[0]
o.async = 1; o.src = t; o.id = 'fathom-script'
m.parentNode.insertBefore(o, m)
})(document, window, '//ftm.deblan.org/tracker.js', 'fathom')
fathom('set', 'siteId', 'HQAWS')
fathom('trackPageview')
/*
/*
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);

View File

@ -1,13 +1,13 @@
const VideoRatio = function(w) {
this.window = w;
const VideoRatio = function (w) {
this.window = w
}
VideoRatio.prototype.init = function() {
var videos = this.window.document.querySelectorAll('.video-ratio');
VideoRatio.prototype.init = function () {
const videos = this.window.document.querySelectorAll('.video-ratio')
for (var i = 0, len = videos.length; i < len; i++) {
videos[i].style.paddingBottom = videos[i].getAttribute('data-ratio');
}
for (let i = 0, len = videos.length; i < len; i++) {
videos[i].style.paddingBottom = videos[i].getAttribute('data-ratio')
}
}
module.exports = VideoRatio