1 | |
function toDwarfMonth(t){
|
2 | |
return(t.replace('January','Granite')
|
3 | |
.replace('February','Slate')
|
4 | |
.replace('March','Felsite')
|
5 | |
.replace('April','Hematite')
|
6 | |
.replace('May','Malachite')
|
7 | |
.replace('June','Galena')
|
8 | |
.replace('July','Limestone')
|
9 | |
.replace('August','Sandstone')
|
10 | |
.replace('September','Timber')
|
11 | |
.replace('October','Moonstone')
|
12 | |
.replace('November','Opal')
|
13 | |
.replace('December','Obsidian'));
|
14 | |
};
|
15 | |
|
16 | |
function fromDwarfMonth(t) {
|
17 | |
return(t.replace('Granite','January')
|
18 | |
.replace('Slate','February')
|
19 | |
.replace('Felsite','March')
|
20 | |
.replace('Hematite','April')
|
21 | |
.replace('Malachite','May')
|
22 | |
.replace('Galena','June')
|
23 | |
.replace('Limestone','July')
|
24 | |
.replace('Sandstone','August')
|
25 | |
.replace('Timber','September')
|
26 | |
.replace('Moonstone','October')
|
27 | |
.replace('Opal','November')
|
28 | |
.replace('Obsidian','December'));
|
29 | |
};
|
30 | |
|
31 | |
function dateReplace(f){
|
32 | |
var spans=document.getElementsByTagName('span');
|
| 1 |
functionateReplace(toDwarvish){
|
| 2 |
var spans=document.getElementsByClassName('bilingual');
|
33 | 3 |
for(var i in spans) {
|
34 | |
if(spans[i].className&&spans[i].className.search('date')!== -1)
|
35 | |
spans[i].innerHTML=f(spans[i].innerHTML);
|
| 4 |
var elem = spans[i];
|
| 5 |
if (! (elem && elem.dataset)) continue;
|
| 6 |
|
| 7 |
if (toDwarvish)
|
| 8 |
elem.innerHTML = elem.dataset['dwarvish'];
|
| 9 |
else
|
| 10 |
elem.innerHTML = elem.dataset['english'];
|
36 | 11 |
}
|
37 | 12 |
};
|
38 | 13 |
|
|
41 | 16 |
is_dwarf=!is_dwarf;
|
42 | 17 |
if (window.localStorage)
|
43 | 18 |
window.localStorage.setItem('dwarvish',is_dwarf);
|
44 | |
dateReplace(is_dwarf?toDwarfMonth:fromDwarfMonth);
|
| 19 |
dateReplace(is_dwarf);
|
45 | 20 |
};
|
46 | 21 |
function scroll() {
|
47 | 22 |
var posY=( document.documentElement.scrollTop
|
|
51 | 26 |
};
|
52 | 27 |
var bg=document.getElementById('bg');
|
53 | 28 |
var is_dwarf=(window.localStorage&&window.localStorage.getItem('dwarvish')=='true');
|
54 | |
var spans=document.getElementsByTagName('span');
|
55 | |
for (var i in spans) {
|
56 | |
if (spans[i].className&&spans[i].className.search('date')!==-1) {
|
57 | |
spans[i].onclick=toggle
|
58 | |
}
|
| 29 |
var elems=document.getElementsByClassName('bilingual');
|
| 30 |
for (var i in elems) {
|
| 31 |
elems[i].onclick=toggle;
|
59 | 32 |
}
|
60 | |
dateReplace(is_dwarf?toDwarfMonth:fromDwarfMonth);
|
| 33 |
dateReplace(is_dwarf);
|
61 | 34 |
scroll();
|
62 | 35 |
|
63 | 36 |
window.onscroll=scroll;
|