Change about me scripts

This commit is contained in:
Anton Vakhrushev 2017-04-29 19:17:44 +03:00
parent 6c5faf13cd
commit 0ec92e4959
5 changed files with 49 additions and 21 deletions

View File

@ -9,5 +9,8 @@ indent_size = 4
[*.{html,twig,yml}] [*.{html,twig,yml}]
indent_size = 2 indent_size = 2
[gulpfile.js]
indent_size = 2
[Makefile] [Makefile]
indent_style = tab indent_style = tab

View File

@ -9,6 +9,10 @@ const SASS_SOURCE_PATH = './source/_assets/**/*.scss';
const SASS_DEST_PATH = `./output_${ENV}`; const SASS_DEST_PATH = `./output_${ENV}`;
const SASS_FILE_NAME = 'app.css'; 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 = { const SASS_OPTIONS = {
outputStyle: ENV === 'prod' ? 'compressed' : 'expanded', outputStyle: ENV === 'prod' ? 'compressed' : 'expanded',
}; };
@ -24,6 +28,10 @@ gulp.task('build', function () {
.pipe(concat(SASS_FILE_NAME)) .pipe(concat(SASS_FILE_NAME))
.pipe(gulp.dest(SASS_DEST_PATH)) .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 () { // gulp.task('build:watch', function () {

View File

@ -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);
}());

View File

@ -18,6 +18,6 @@
{% block content %}{% endblock %} {% block content %}{% endblock %}
</main> </main>
{% include 'counters.twig' %} {% include 'counters.twig' %}
<script src="/static/app.js?v={{ date().timestamp }}"></script> <script src="/app.js?v={{ date().timestamp }}"></script>
</body> </body>
</html> </html>

View File

@ -15,30 +15,11 @@ title: Обо мне
<a href="/">На главную</a> <a href="/">На главную</a>
</li> </li>
<li class="about-me__link"> <li class="about-me__link">
<a href="">Узнать чуть лучше</a> <a id="know-better" href="#">Узнать чуть лучше</a>
</li> </li>
</ul> </ul>
</div> </div>
</section> </section>
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', function() {
var notes = [
'Любимый фильм "Три идиота".',
'Люблю кататься на велосипеде.',
'Люблю читать фантастические книги.',
'Люблю шоколад.',
'На день рождения ко мне можно прийти без подарка.',
'Не люблю пьяных людей.',
'Предпочитаю ходить в кино на 2D-сеансы.',
'Проехал на велосипеде 200 километров за день.',
'Работаю программистом.',
'Хотел бы побывать в горах.',
];
var note = notes[Math.floor(Math.random() * notes.length)];
document.getElementById('about-me-note').innerHTML = note;
});
</script>
{% endblock %} {% endblock %}