-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (47 loc) · 1.66 KB
/
index.js
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
48
/*
** TRUE -- Manifesto of TRUE Software Engineering
** Copyright (c) 2019-2021 Dr. Ralf S. Engelschall <http://engelschall.com/>
** Licensed under CC-BY-NC-ND 4.0 <https://creativecommons.org/licenses/by-nc-nd/4.0/>
*/
$(document).ready(function () {
var page = "manifesto"
var lang = "en"
var updateHash = function () {
var hash = "#" + page + "-" + lang
if (window.location.hash !== hash)
window.location.hash = hash
}
var selectPage = function () {
$(".content > .page").css("display", "none")
$(".content > .page.page-" + page).css("display", "block")
$(".header .page").removeClass("active")
$(".header .page-" + page).addClass("active")
updateHash()
}
var selectLang = function () {
$("*[lang]").css("display", "none")
$("*[lang='" + lang + "']").css("display", "block")
$("span[lang='" + lang + "']").css("display", "inline")
$(".header .icon-lang").removeClass("active")
$(".header .icon-lang-" + lang).addClass("active")
updateHash()
}
$(".header a").click(function (ev) {
ev.preventDefault()
})
$(".header .pages .page").click(function (ev) {
page = $(ev.target).attr("class").replace(/^.*page-([a-z]+).*$/, "$1")
selectPage()
})
$(".header .langs .icon-lang").click(function (ev) {
lang = $(ev.target).attr("class").replace(/^.*icon-lang-([a-z]+).*$/, "$1")
selectLang()
})
var m
if ((m = window.location.hash.match(/^#(manifesto|tenets|about)-(en|de)$/)) !== null) {
page = m[1]
lang = m[2]
}
selectPage(page)
selectLang(lang)
})