Summary Files Commits Branches @commit @diff @stats
path: root / Year 4 / Web technologies / referat / javascript / navbar-shrink.js
blob: 648ccf4a124702716007a26247077a6e92b5a006 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const nav = document.getElementById('contents');
const author = document.getElementById('author');

function change_nav_names() {
    if (window.screen.width < 970) {
        nav.children[0].innerText = 'Във';
        nav.children[1].innerText = 'Инст';
        nav.children[2].innerText = 'Арх';
        nav.children[3].innerText = 'ВХ';
        nav.children[4].innerText = 'Конф';
    }
    else {
        nav.children[0].innerText = 'Въведение';
        nav.children[1].innerText = 'Инсталиране';
        nav.children[2].innerText = 'Архитектура';
        nav.children[3].innerText = 'Виртуални хостове';
        nav.children[4].innerText = 'Конфигуриране';
    }

    if (window.screen.width < 570) {
        author.firstChild.innerText = '';
        author.lastChild.classList.remove('none');
        author.classList.add('clickable');
    }
    else {
        author.firstChild.innerText = 'Камен Младенов - 0MI0800028';
        author.lastChild.classList.add('none');
        author.classList.remove('clickable');
    }
}

window.addEventListener('resize', change_nav_names);
change_nav_names();

author.addEventListener('click', function() {
    if (window.screen.width >= 570)               { return; }
    if (document.getSelection().type === 'Range') { return; }

    if (author.firstChild.innerText === '') {
        author.firstChild.innerText = 'Камен Младенов 0MI0800028';
    }
    else {
        author.firstChild.innerText = '';
    }
    author.lastChild.classList.toggle('none');
    author.classList.toggle('clickable');
});