From 0ec92e4959c9f2c3e9dde8f340dd495e503dae30 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Sat, 29 Apr 2017 19:17:44 +0300 Subject: [PATCH] Change about me scripts --- .editorconfig | 3 +++ gulpfile.js | 8 +++++++ source/_assets/about-me.js | 36 +++++++++++++++++++++++++++++++ source/_layouts/default.html.twig | 2 +- source/about/me.html.twig | 21 +----------------- 5 files changed, 49 insertions(+), 21 deletions(-) create mode 100644 source/_assets/about-me.js diff --git a/.editorconfig b/.editorconfig index 8e6f9f8..c01f262 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,5 +9,8 @@ indent_size = 4 [*.{html,twig,yml}] indent_size = 2 +[gulpfile.js] +indent_size = 2 + [Makefile] indent_style = tab diff --git a/gulpfile.js b/gulpfile.js index 47f6595..5978527 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,6 +9,10 @@ const SASS_SOURCE_PATH = './source/_assets/**/*.scss'; const SASS_DEST_PATH = `./output_${ENV}`; const SASS_FILE_NAME = 'app.css'; +const SCRIPT_SOURCE_PATH = './source/_assets/**/*.js'; +const SCRIPT_DEST_PATH = `./output_${ENV}`; +const SCRIPT_FILE_NAME = 'app.js'; + const SASS_OPTIONS = { outputStyle: ENV === 'prod' ? 'compressed' : 'expanded', }; @@ -24,6 +28,10 @@ gulp.task('build', function () { .pipe(concat(SASS_FILE_NAME)) .pipe(gulp.dest(SASS_DEST_PATH)) ; + gulp.src(SCRIPT_SOURCE_PATH) + .pipe(concat(SCRIPT_FILE_NAME)) + .pipe(gulp.dest(SCRIPT_DEST_PATH)) + ; }); // gulp.task('build:watch', function () { diff --git a/source/_assets/about-me.js b/source/_assets/about-me.js new file mode 100644 index 0000000..1d906d7 --- /dev/null +++ b/source/_assets/about-me.js @@ -0,0 +1,36 @@ +(function() { + 'use strict'; + + var notes = [ + 'Любимый фильм "Три идиота".', + 'Люблю кататься на велосипеде.', + 'Люблю читать фантастические книги.', + 'Люблю шоколад.', + 'На день рождения ко мне можно прийти без подарка.', + 'Не люблю пьяных людей.', + 'Предпочитаю ходить в кино на 2D-сеансы.', + 'Проехал на велосипеде 200 километров за день.', + 'Работаю программистом.', + 'Хотел бы побывать в горах.', + ]; + + function selectRandomNote() { + return notes[Math.floor(Math.random() * notes.length)]; + } + + function updateNode() { + document.getElementById('about-me-note').innerHTML = selectRandomNote(); + } + + function onKnowBetter(event) { + event.preventDefault(); + if (window.yaCounter41913764) { + window.yaCounter41913764.hit(location.href); + } + updateNode(); + } + + window.addEventListener('DOMContentLoaded', updateNode); + document.getElementById('know-better').addEventListener('click', onKnowBetter); + +}()); diff --git a/source/_layouts/default.html.twig b/source/_layouts/default.html.twig index 3bd53fd..ab35e2b 100644 --- a/source/_layouts/default.html.twig +++ b/source/_layouts/default.html.twig @@ -18,6 +18,6 @@ {% block content %}{% endblock %} {% include 'counters.twig' %} - + diff --git a/source/about/me.html.twig b/source/about/me.html.twig index 5325f7c..2541786 100644 --- a/source/about/me.html.twig +++ b/source/about/me.html.twig @@ -15,30 +15,11 @@ title: Обо мне На главную - - {% endblock %}