Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
Function init has 34 lines of code (exceeds 25 allowed). Consider ref…
Browse files Browse the repository at this point in the history
…actoring.

 🐿 v2.8.0
  • Loading branch information
Braimbridge, Adam authored and Braimbridge, Adam committed Apr 18, 2018
1 parent bf6af33 commit 59bb3ff
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions components/n-ui/evenMoreJanky/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
// Then over time, allow them to resume their intended hight, thus creating a "janky" effect;
// That is, the content "stutters" up/down the web page as the page layout updates.

function init (flags) {
if (!flags || !flags.get('evenMoreJanky')) {
return;
}

const addStyles = () => {
const styleNode = document.createElement('style');
styleNode.type = 'text/css';
const styleText = document.createTextNode(`
Expand All @@ -18,7 +14,9 @@ function init (flags) {
`);
styleNode.appendChild(styleText);
document.getElementsByTagName('head')[0].appendChild(styleNode);
};

const crankThatJank = () => {
[
'#o-cookie-message',
'#top-gpt',
Expand All @@ -31,15 +29,25 @@ function init (flags) {
'.article__content',
'.article-info',
]
.forEach(selector => {
document.querySelectorAll(selector).forEach(element => {
element.className += ' janky';
setTimeout(() => {
element.className = element.className.replace(new RegExp(/ janky/, 'g'), '');
},
.forEach(selector => {
document.querySelectorAll(selector).forEach(element => {
element.className += ' janky';
setTimeout(() => {
element.className = element.className.replace(new RegExp(/ janky/, 'g'), '');
},
Math.floor(Math.random() * 4000) + 1000);
});
});
});
};

function init (flags) {
if (!flags || !flags.get('evenMoreJanky')) {
return;
}
else {
addStyles();
crankThatJank();
}
}

module.exports = { init };

0 comments on commit 59bb3ff

Please sign in to comment.