Code formatting according to standardjs

This commit is contained in:
Stephan 2019-03-31 21:30:46 +02:00
parent e2bbe9273a
commit 3d4eef5eb0
10 changed files with 44 additions and 44 deletions

View file

@ -90,34 +90,34 @@ if (fs.existsSync('source/templates/data.json')) {
// Create tasks // Create tasks
// Clean build folder // Clean build folder
function clean() { function clean () {
// You can use multiple globbing patterns as you would with `gulp.src`, // You can use multiple globbing patterns as you would with `gulp.src`,
// for example if you are using del 2.0 or above, return its promise // for example if you are using del 2.0 or above, return its promise
return del(output.root +'/**'); return del(output.root +'/**');
} }
// Automagically reload browsers // Automagically reload browsers
function reload(done) { function reload (done) {
server.reload(); server.reload();
done(); done();
} }
// Concatenate JSON files // Concatenate JSON files
function json() { function json () {
return src(input.data) return src(input.data)
.pipe(plumber()) .pipe(plumber())
.pipe(jsonConcat(hippie.jsonFile +'.json', function(data) { .pipe(jsonConcat(hippie.jsonFile +'.json', function (data) {
return new Buffer.from(JSON.stringify(data)); return new Buffer.from(JSON.stringify(data));
})) }))
.pipe(dest(output.data)); .pipe(dest(output.data));
} }
// Transpile HTML // Transpile HTML
function nunjucks() { function nunjucks () {
return src(input.screens) return src(input.screens)
.pipe(plumber()) .pipe(plumber())
.pipe(data(function() { .pipe(data(function () {
let data = JSON.parse(fs.readFileSync(input.templates +'/'+ hippie.data)); let data = JSON.parse(fs.readFileSync(input.templates +'/'+ hippie.data));
object = {hippie, data}; object = {hippie, data};
return object; return object;
@ -132,7 +132,7 @@ function nunjucks() {
} }
// Serve files to the browser // Serve files to the browser
function serve(done) { function serve (done) {
server.init({ server.init({
index: hippie.index, index: hippie.index,
open: false, open: false,
@ -143,7 +143,7 @@ function serve(done) {
} }
// This is for the looks // This is for the looks
function style() { function style () {
return src(input.style) return src(input.style)
.pipe(plumber()) .pipe(plumber())
// .pipe(plumbError('STYLE PROBLEM')) // .pipe(plumbError('STYLE PROBLEM'))
@ -159,7 +159,7 @@ function style() {
.pipe(dest(output.style)); .pipe(dest(output.style));
} }
// Linting // Linting
function styleLint() { function styleLint () {
var dir = output.reports; var dir = output.reports;
if (!fs.existsSync(dir)) { if (!fs.existsSync(dir)) {
fs.mkdirSync(dir); fs.mkdirSync(dir);
@ -175,7 +175,7 @@ function styleLint() {
})) }))
.pipe(sassLint.format(file)); .pipe(sassLint.format(file));
stream.on('finish', function() { stream.on('finish', function () {
file.end(); file.end();
}); });
@ -183,7 +183,7 @@ function styleLint() {
} }
// Javascript for the win // Javascript for the win
function code(cb) { function code (cb) {
pump([ pump([
src(input.code, { src(input.code, {
sourcemaps: true, sourcemaps: true,
@ -203,7 +203,7 @@ function code(cb) {
], cb); ], cb);
} }
// Linting // Linting
function codeLint() { function codeLint () {
return src(input.code, { allowEmpty: true }) return src(input.code, { allowEmpty: true })
.pipe(plumber()) .pipe(plumber())
.pipe(jshint()) .pipe(jshint())
@ -215,14 +215,14 @@ function codeLint() {
} }
// Fonts // Fonts
function fonts() { function fonts () {
return src(input.fonts) return src(input.fonts)
.pipe(plumber()) .pipe(plumber())
.pipe(dest(output.fonts)) .pipe(dest(output.fonts))
} }
// Add art // Add art
function art() { function art () {
// Move favicons to the root folder // Move favicons to the root folder
let favicons = src(input.art.favicons) let favicons = src(input.art.favicons)
.pipe(plumber()) .pipe(plumber())
@ -238,7 +238,7 @@ function art() {
return merge(favicons, images) return merge(favicons, images)
} }
function sprites() { function sprites () {
// Assemble sprites // Assemble sprites
let sprites = src(input.art.sprites) let sprites = src(input.art.sprites)
.pipe(plumber()) .pipe(plumber())
@ -262,13 +262,13 @@ function sprites() {
} }
// Gather dependencies for tools // Gather dependencies for tools
function vendor() { function vendor () {
return src(input.vendor) return src(input.vendor)
.pipe(plumber()) .pipe(plumber())
.pipe(dest(output.vendor)) .pipe(dest(output.vendor))
} }
function overview() { function overview () {
watch([input.templates, input.screens, input.demo.data], series(nunjucks, reload)); watch([input.templates, input.screens, input.demo.data], series(nunjucks, reload));
watch(input.style, series(styleLint, style, reload)); watch(input.style, series(styleLint, style, reload));
watch(input.code, series(codeLint, code, reload)); watch(input.code, series(codeLint, code, reload));

View file

@ -1,5 +1,5 @@
// This is called everytime // This is called everytime
function setup() { function setup () {
'use strict'; 'use strict';
console.info('\n', hippie.brand, '\n\n'); console.info('\n', hippie.brand, '\n\n');
if (debugOn) { if (debugOn) {
@ -12,14 +12,14 @@ function setup() {
} }
// MODULE Scroll navigation // MODULE Scroll navigation
function HippieScroll($el) { function HippieScroll ($el) {
'use strict'; 'use strict';
// this.$el = $el; // this.$el = $el;
// console.log('Elements:', $el, this.$el); // console.log('Elements:', $el, this.$el);
// Toggle display on scroll position // Toggle display on scroll position
// console.log('Scroll object added'); // console.log('Scroll object added');
this.check = function() { this.check = function () {
// console.log('Scroll position checked'); // console.log('Scroll position checked');
hippie.screen.y = Math.min($(document).scrollTop(), document.documentElement.scrollTop); hippie.screen.y = Math.min($(document).scrollTop(), document.documentElement.scrollTop);
if (hippie.screen.y > initY) { if (hippie.screen.y > initY) {
@ -37,14 +37,14 @@ function HippieScroll($el) {
} }
}; };
// Add events to navigation elements // Add events to navigation elements
$('.js_scrolltop').click(function(event) { $('.js_scrolltop').click(function (event) {
event.preventDefault(); event.preventDefault();
$('html, body').animate({ $('html, body').animate({
scrollTop: 0 scrollTop: 0
}, basicEase); }, basicEase);
// console.log('Scrolled to top'); // console.log('Scrolled to top');
}); });
$('.js_scrolldown').click(function(event) { $('.js_scrolldown').click(function (event) {
event.preventDefault(); event.preventDefault();
var pos = Math.max(hippie.screen.dh, hippie.body.h) - hippie.screen.vh; var pos = Math.max(hippie.screen.dh, hippie.body.h) - hippie.screen.vh;
$('html').scrollTop(pos); $('html').scrollTop(pos);
@ -54,7 +54,7 @@ function HippieScroll($el) {
} }
// get document coordinates of the element // get document coordinates of the element
// function getCoords(elem) { // function getCoords (elem) {
// let box = elem.getBoundingClientRect(); // let box = elem.getBoundingClientRect();
// //
// return { // return {
@ -64,7 +64,7 @@ function HippieScroll($el) {
// } // }
// https://stackoverflow.com/a/488073/1444149 // https://stackoverflow.com/a/488073/1444149
// function Utils() {} // function Utils () {}
// //
// Utils.prototype = { // Utils.prototype = {
// constructor: Utils, // constructor: Utils,
@ -86,9 +86,9 @@ function HippieScroll($el) {
// TEST // TEST
function scrollNav() { function scrollNav () {
'use strict'; 'use strict';
$('.nav a').click(function() { $('.nav a').click(function () {
//Toggle Class //Toggle Class
$(".active").removeClass("active"); $(".active").removeClass("active");
$(this).closest('li').addClass("active"); $(this).closest('li').addClass("active");

View file

@ -4,7 +4,7 @@ setup();
// DOM ready // DOM ready
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
$(document).ready(function() { $(document).ready(function () {
'use strict'; 'use strict';
// logPerf('DOM ready.'); // logPerf('DOM ready.');
@ -17,16 +17,16 @@ $(document).ready(function() {
// Displays explanation popup // Displays explanation popup
$('.js_pop').hover( $('.js_pop').hover(
function() { function () {
// if ($(this).attr('emmet')) { // if ($(this).attr('emmet')) {
// //
// } // }
$(this).next('.exp_pop').show(); $(this).next('.exp_pop').show();
}, function() { }, function () {
$(this).next('.exp_pop').hide(); $(this).next('.exp_pop').hide();
} }
).mousemove( ).mousemove(
function(event) { function (event) {
$(this).next('.exp_pop').css({ $(this).next('.exp_pop').css({
'top': event.pageY - $(this).next('.exp_pop').outerHeight() - 4, 'top': event.pageY - $(this).next('.exp_pop').outerHeight() - 4,
'left': event.pageX + 8 'left': event.pageX + 8
@ -39,13 +39,13 @@ $(document).ready(function() {
// WIP Activates layer with explanation elements // WIP Activates layer with explanation elements
// Besser ::after oder ::before benutzen // Besser ::after oder ::before benutzen
$('.js_showmeta').click(function(e) { $('.js_showmeta').click(function (e) {
var $wrap, $pop; var $wrap, $pop;
if (expMode !== true) { if (expMode !== true) {
expMode = true; expMode = true;
$('.js_pop').each(function(i, e) { $('.js_pop').each(function (i, e) {
if ($(this).css('position') === 'static') { if ($(this).css('position') === 'static') {
$(this).addClass('js_changed_pos'); $(this).addClass('js_changed_pos');
$(this).css('position', 'relative'); $(this).css('position', 'relative');
@ -57,7 +57,7 @@ $(document).ready(function() {
}); });
} else { } else {
$('.js_pop').each(function(i, e) { $('.js_pop').each(function (i, e) {
$wrap = $(this).parent('.exp_wrap'); $wrap = $(this).parent('.exp_wrap');
$pop = $wrap.next('.exp_pop').detach(); $pop = $wrap.next('.exp_pop').detach();
$wrap.find('.exp_marker_pop').remove(); $wrap.find('.exp_marker_pop').remove();
@ -78,7 +78,7 @@ $(document).ready(function() {
console.log('Explanation mode', expMode); console.log('Explanation mode', expMode);
}); });
$('#gameIcon').click(function(event) { $('#gameIcon').click(function (event) {
event.preventDefault(); event.preventDefault();
$(this).clone().appendTo('#gameDetail'); $(this).clone().appendTo('#gameDetail');
$(this).siblings().clone().appendTo('#gameDetail'); $(this).siblings().clone().appendTo('#gameDetail');

View file

@ -48,7 +48,7 @@
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
assetsLoaded = true; assetsLoaded = true;
logPerf('SCRIPT assets loaded.'); logPerf('SCRIPT assets loaded.');
$( document ).ready(function() { $( document ).ready(function () {
logPerf('JQ document \'ready\' event fired.'); logPerf('JQ document \'ready\' event fired.');
}); });
logPerf('Application ready.'); logPerf('Application ready.');

View file

@ -70,7 +70,7 @@
<script type="text/javascript"> <script type="text/javascript">
// Page specific // Page specific
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
$( document ).ready(function() { $( document ).ready(function () {
// jq-sticky-anything // jq-sticky-anything
$('#js_demo_fix').stickThis({ $('#js_demo_fix').stickThis({
pushup: '#js_demo_stop' pushup: '#js_demo_stop'

View file

@ -233,7 +233,7 @@
<script type="text/javascript"> <script type="text/javascript">
// Page specific // Page specific
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
$( document ).ready(function() { $( document ).ready(function () {
// jq-sticky-anything // jq-sticky-anything
$('#js_demo_fix').stickThis({ $('#js_demo_fix').stickThis({
pushup: '#js_demo_stop' pushup: '#js_demo_stop'

View file

@ -592,11 +592,11 @@ logPerf('Assets loaded.');
// Create instance of object made by contructor function // Create instance of object made by contructor function
var scrollUi = new HippieScroll($('.js_scrolltop')); var scrollUi = new HippieScroll($('.js_scrolltop'));
$(document).ready(function() { $(document).ready(function () {
logPerf('JQ document ready event fired.'); logPerf('JQ document ready event fired.');
}); });
$(document).scroll(function() { $(document).scroll(function () {
scrollUi.check(); scrollUi.check();
}); });
logPerf('Application ready.'); logPerf('Application ready.');

View file

@ -13,7 +13,7 @@
{% include "hippie/partials/_head_script.njk" %} {% include "hippie/partials/_head_script.njk" %}
<script> <script>
debugOn = true; debugOn = true;
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function () {
logPerf('Document \'DOMContentLoaded\' event fired.'); logPerf('Document \'DOMContentLoaded\' event fired.');
}); });
logPerf('On HEAD, starting...'); logPerf('On HEAD, starting...');

View file

@ -13,7 +13,7 @@
{% include "hippie/partials/_head_script.njk" %} {% include "hippie/partials/_head_script.njk" %}
<script> <script>
debugOn = true; debugOn = true;
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function () {
logPerf('Document \'DOMContentLoaded\' event fired.'); logPerf('Document \'DOMContentLoaded\' event fired.');
}); });
logPerf('On HEAD, starting...'); logPerf('On HEAD, starting...');

View file

@ -7,13 +7,13 @@ var assetsLoaded = false;
// Get the current time difference between page // Get the current time difference between page
// load and when this func was invoked // load and when this func was invoked
function getTimeDiff() { function getTimeDiff () {
return new Date().getTime() - performance.timing.navigationStart; return new Date().getTime() - performance.timing.navigationStart;
} }
// log message to console and add // log message to console and add
// performance measuring information // performance measuring information
function logPerf(msg) { function logPerf (msg) {
if (debugOn) { if (debugOn) {
if (debugOnScreen && assetsLoaded) { if (debugOnScreen && assetsLoaded) {
if (!$('#jsLogPerf').length) { if (!$('#jsLogPerf').length) {