refactoring of javascripts
This commit is contained in:
parent
a6a30078bb
commit
7d81521c8c
|
@ -1,17 +1,19 @@
|
||||||
const App = function (components) {
|
class App {
|
||||||
|
constructor(components) {
|
||||||
this.components = components || []
|
this.components = components || []
|
||||||
}
|
}
|
||||||
|
|
||||||
App.prototype.add = function (c) {
|
add(c) {
|
||||||
this.components.push(c)
|
this.components.push(c)
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
App.prototype.init = function () {
|
init() {
|
||||||
for (let u = 0, x = this.components.length; u < x; u++) {
|
for (let u = 0, x = this.components.length; u < x; u++) {
|
||||||
this.components[u].init()
|
this.components[u].init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = App
|
module.exports = App
|
||||||
|
|
|
@ -23,11 +23,12 @@ require('prismjs/plugins/keep-markup/prism-keep-markup')
|
||||||
require('prismjs/plugins/line-highlight/prism-line-highlight')
|
require('prismjs/plugins/line-highlight/prism-line-highlight')
|
||||||
require('prismjs/plugins/line-numbers/prism-line-numbers')
|
require('prismjs/plugins/line-numbers/prism-line-numbers')
|
||||||
|
|
||||||
const Code = function (w) {
|
class Code {
|
||||||
|
constructor(w) {
|
||||||
this.window = w
|
this.window = w
|
||||||
}
|
}
|
||||||
|
|
||||||
Code.prototype.init = function () {
|
init() {
|
||||||
Prism.highlightAllUnder(document)
|
Prism.highlightAllUnder(document)
|
||||||
let elements = this.window.document.querySelectorAll('code[data-title], div[data-title]')
|
let elements = this.window.document.querySelectorAll('code[data-title], div[data-title]')
|
||||||
|
|
||||||
|
@ -94,5 +95,6 @@ Code.prototype.init = function () {
|
||||||
post.insertBefore(win, pre)
|
post.insertBefore(win, pre)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = Code
|
module.exports = Code
|
|
@ -1,10 +1,11 @@
|
||||||
const Routing = require('./routing')
|
const Routing = require('./routing')
|
||||||
|
|
||||||
const FormPnw = function (w) {
|
class FormPnw {
|
||||||
|
constructor(w) {
|
||||||
this.window = w
|
this.window = w
|
||||||
}
|
}
|
||||||
|
|
||||||
FormPnw.prototype.init = function () {
|
init() {
|
||||||
const doc = this.window.document
|
const doc = this.window.document
|
||||||
|
|
||||||
doc.addEventListener('mousemove', function() {
|
doc.addEventListener('mousemove', function() {
|
||||||
|
@ -26,5 +27,6 @@ FormPnw.prototype.init = function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = FormPnw
|
module.exports = FormPnw
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
const Mario = require('../../images/mario.gif')
|
const Mario = require('../../images/mario.gif')
|
||||||
|
|
||||||
const Knmc = function (w) {
|
class Knmc {
|
||||||
|
constructor(w) {
|
||||||
this.window = w
|
this.window = w
|
||||||
}
|
}
|
||||||
|
|
||||||
Knmc.prototype.init = function () {
|
init() {
|
||||||
let chars = ''
|
let chars = ''
|
||||||
const seq = '38384040373937396665'
|
const seq = '38384040373937396665'
|
||||||
const body = this.window.document.querySelector('body')
|
const body = this.window.document.querySelector('body')
|
||||||
|
@ -30,5 +31,6 @@ Knmc.prototype.init = function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = Knmc
|
module.exports = Knmc
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
const lozad = require('lozad')
|
const lozad = require('lozad')
|
||||||
|
|
||||||
const LazyLoad = function () {
|
class LazyLoad {
|
||||||
}
|
init() {
|
||||||
|
|
||||||
LazyLoad.prototype.init = function () {
|
|
||||||
const observer = lozad('.lazy-img')
|
const observer = lozad('.lazy-img')
|
||||||
observer.observe()
|
observer.observe()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = LazyLoad
|
module.exports = LazyLoad
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
const tingle = require('tingle.js/src/tingle.js')
|
const tingle = require('tingle.js/src/tingle.js')
|
||||||
|
|
||||||
const MeshViewer = function (w) {
|
class MeshViewer {
|
||||||
|
constructor(w) {
|
||||||
this.window = w
|
this.window = w
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshViewer.prototype.init = function () {
|
init() {
|
||||||
const openers = this.window.document.querySelectorAll('*[data-modal]')
|
const openers = this.window.document.querySelectorAll('*[data-modal]')
|
||||||
|
|
||||||
for (let i = 0, len = openers.length; i < len; i++) {
|
for (let i = 0, len = openers.length; i < len; i++) {
|
||||||
|
@ -30,5 +31,6 @@ MeshViewer.prototype.init = function () {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = MeshViewer
|
module.exports = MeshViewer
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
require('particles.js')
|
require('particles.js')
|
||||||
|
|
||||||
const Particles = function (w) {
|
class Particles {
|
||||||
|
constructor(w) {
|
||||||
this.window = w
|
this.window = w
|
||||||
}
|
}
|
||||||
|
|
||||||
Particles.prototype.start = function () {
|
start() {
|
||||||
if (this.window.innerWidth < 708) {
|
if (this.window.innerWidth < 708) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -19,11 +20,11 @@ Particles.prototype.start = function () {
|
||||||
particlesJS.load('particles', '/js/particles.json?v=3')
|
particlesJS.load('particles', '/js/particles.json?v=3')
|
||||||
}
|
}
|
||||||
|
|
||||||
Particles.prototype.clean = function () {
|
clean() {
|
||||||
this.particles.innerHTML = ''
|
this.particles.innerHTML = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
Particles.prototype.init = function () {
|
init() {
|
||||||
this.particles = this.window.document.getElementById('particles')
|
this.particles = this.window.document.getElementById('particles')
|
||||||
|
|
||||||
if (!this.particles) {
|
if (!this.particles) {
|
||||||
|
@ -42,5 +43,6 @@ Particles.prototype.init = function () {
|
||||||
that.start()
|
that.start()
|
||||||
}, false)
|
}, false)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = Particles
|
module.exports = Particles
|
|
@ -1,10 +1,11 @@
|
||||||
const Routing = require('./routing')
|
const Routing = require('./routing')
|
||||||
|
|
||||||
const Post = function (w) {
|
class Post {
|
||||||
|
constructor(w) {
|
||||||
this.window = w
|
this.window = w
|
||||||
}
|
}
|
||||||
|
|
||||||
Post.prototype.commentsEvents = function () {
|
commentsEvents() {
|
||||||
const document = this.window.document
|
const document = this.window.document
|
||||||
|
|
||||||
const parentCommentIdField = document.getElementById('user_comment_parentCommentId')
|
const parentCommentIdField = document.getElementById('user_comment_parentCommentId')
|
||||||
|
@ -70,7 +71,7 @@ Post.prototype.commentsEvents = function () {
|
||||||
}, false)
|
}, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
Post.prototype.imagesEvents = function () {
|
imagesEvents() {
|
||||||
const document = this.window.document
|
const document = this.window.document
|
||||||
let isFullscreen = false
|
let isFullscreen = false
|
||||||
const images = document.querySelectorAll('.body img')
|
const images = document.querySelectorAll('.body img')
|
||||||
|
@ -112,9 +113,10 @@ Post.prototype.imagesEvents = function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Post.prototype.init = function () {
|
init() {
|
||||||
this.commentsEvents()
|
this.commentsEvents()
|
||||||
this.imagesEvents()
|
this.imagesEvents()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = Post
|
module.exports = Post
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
const QuickPost = function (w) {
|
class QuickPost {
|
||||||
|
constructor(w) {
|
||||||
this.window = w
|
this.window = w
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickPost.prototype.init = function () {
|
init() {
|
||||||
const doc = this.window.document
|
const doc = this.window.document
|
||||||
|
|
||||||
const images = doc.querySelectorAll('.quick-image img')
|
const images = doc.querySelectorAll('.quick-image img')
|
||||||
|
@ -21,5 +22,6 @@ QuickPost.prototype.init = function () {
|
||||||
})(images[i])
|
})(images[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = QuickPost
|
module.exports = QuickPost
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
const Routing = require('./routing')
|
const Routing = require('./routing')
|
||||||
|
|
||||||
const SmallMenu = function (w) {
|
class SmallMenu {
|
||||||
|
constructor(w) {
|
||||||
this.window = w
|
this.window = w
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallMenu.prototype.addEvent = function () {
|
addEvent() {
|
||||||
const document = this.window.document
|
const document = this.window.document
|
||||||
const menu = document.querySelector('.small-menu')
|
const menu = document.querySelector('.small-menu')
|
||||||
const opener = document.querySelector('.menu-opener')
|
const opener = document.querySelector('.menu-opener')
|
||||||
|
@ -15,8 +16,9 @@ SmallMenu.prototype.addEvent = function () {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallMenu.prototype.init = function () {
|
init() {
|
||||||
this.addEvent()
|
this.addEvent()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = SmallMenu
|
module.exports = SmallMenu
|
||||||
|
|
|
@ -1,38 +1,19 @@
|
||||||
const Stats = function () {
|
class Stats {
|
||||||
}
|
init() {
|
||||||
|
|
||||||
Stats.prototype.init = function () {
|
|
||||||
(function(f, a, t, h, o, m) {
|
(function(f, a, t, h, o, m) {
|
||||||
a[h] = a[h] || function() {
|
a[h] = a[h] || function() {
|
||||||
(a[h].q = a[h].q || []).push(arguments)
|
(a[h].q = a[h].q || []).push(arguments)
|
||||||
}
|
}
|
||||||
o = f.createElement('script'),
|
o = f.createElement('script'),
|
||||||
m = f.getElementsByTagName('script')[0]
|
m = f.getElementsByTagName('script')[0]
|
||||||
o.async = 1; o.src = t; o.id = 'fathom-script'
|
o.async = 1;
|
||||||
|
o.src = t;
|
||||||
|
o.id = 'fathom-script'
|
||||||
m.parentNode.insertBefore(o, m)
|
m.parentNode.insertBefore(o, m)
|
||||||
})(document, window, '//ftm.deblan.org/tracker.js', 'fathom')
|
})(document, window, '//ftm.deblan.org/tracker.js', 'fathom')
|
||||||
fathom('set', 'siteId', 'HQAWS')
|
fathom('set', 'siteId', 'HQAWS')
|
||||||
fathom('trackPageview')
|
fathom('trackPageview')
|
||||||
|
}
|
||||||
/*
|
|
||||||
var _paq = _paq || [];
|
|
||||||
_paq.push(['trackPageView']);
|
|
||||||
_paq.push(['enableLinkTracking']);
|
|
||||||
|
|
||||||
var u="//piwik.deblan.org/";
|
|
||||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
|
||||||
_paq.push(['setSiteId', '1']);
|
|
||||||
|
|
||||||
var d= document;
|
|
||||||
var g= d.createElement('script');
|
|
||||||
var s= d.getElementsByTagName('script')[0];
|
|
||||||
|
|
||||||
g.type='text/javascript';
|
|
||||||
g.async=true;
|
|
||||||
g.defer=true;
|
|
||||||
g.src=u+'piwik.js';
|
|
||||||
s.parentNode.insertBefore(g,s);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Stats
|
module.exports = Stats
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
const VideoRatio = function (w) {
|
class VideoRatio {
|
||||||
|
constructor(w) {
|
||||||
this.window = w
|
this.window = w
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoRatio.prototype.init = function () {
|
init() {
|
||||||
const videos = this.window.document.querySelectorAll('.video-ratio')
|
const videos = this.window.document.querySelectorAll('.video-ratio')
|
||||||
|
|
||||||
for (let i = 0, len = videos.length; i < len; i++) {
|
for (let i = 0, len = videos.length; i < len; i++) {
|
||||||
videos[i].style.paddingBottom = videos[i].getAttribute('data-ratio')
|
videos[i].style.paddingBottom = videos[i].getAttribute('data-ratio')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = VideoRatio
|
module.exports = VideoRatio
|
||||||
|
|
Loading…
Reference in a new issue