-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
189 lines (158 loc) · 8.3 KB
/
index.html
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Pony Express</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link rel="stylesheet" href="site.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"
crossorigin="anonymous"></script>
</head>
<body>
<div>
<div>
<div class="d-flex">
<h1 class="header" style="flex: 5;">The Pony Express</h1>
<p style="flex: 1; font-size: 0.7vw;">
WEATHER <br />
<span id="js-weather">
Chargement... Weather map on accuweather.com</span> <a onclick="trans()"
href="javascript:void(0);">Translate to Neighlish</a>
</p>
</div>
<div class="headerInfoBox">
<p>
<a style="cursor: pointer; color: steelblue; user-select: none;" id="js-back"">< PREV</a>
<span id="js-volume">VOL. CLXVII ... No 57,-/-/-</span>
<a style="cursor: pointer; color: steelblue; user-select: none;" id="js-forward"">NEXT ></a>
</p>
<p style="font-size: 10px;" class="align-middle hiddenOnMobile">The Pony Express Company</p>
<p id="js-date">PONY PLANET, -----, ---- ---, ----</p>
<div style="width: 100%;"></div>
<p id="js-price" class="text-end hiddenOnMobile">$-.--</p>
</div>
</div>
<div class="body">
<div>
<h2 id="js-header1">Chargement...</h2>
<hr>
<h3 id="js-header2">...</h3>
<hr>
<p>
<div id="js-authors1" class="authors">
By --- <br />
and ----
</div>
<p id="js-content1"></p>
</p>
</div>
<div>
<img id="js-midImg" src="shark.jpg" style="width: 100%; aspect-ratio: 1.2/1; object-fit: cover;">
<p id="js-midImgCredit" style="font-size: 10px;" class="text-end">---</p>
<hr />
<h2 id="js-midTitle">Chargement...</h2>
<div class="midStory">
<div class="text-center">
<hr />
<strong id="js-author">By ---</strong>
<p class="text-start" id="js-midText1"></p>
</div>
<p id="js-midText2"></p>
<p id="js-midText3"></p>
</div>
</div>
<div>
<h1 id="js-rightTitle">Chargement...</h1>
<hr>
<h3 id="js-rightSubhead">....</h3>
<hr>
<div class="twoColumStory">
<p id="js-rightText1"></p>
<p id="js-rightText2"></p>
</div>
</div>
</div>
</div>
<script type="module">
import { articles } from './content/index.js';
let currentId = articles.total;
document.getElementById('js-back').onclick = () => loadArticle(currentId - 1);
document.getElementById('js-forward').onclick = () => loadArticle(currentId + 1);
function loadArticle(id = 0) {
fetch(`./content/${articles[id]}`).then(raw => raw.json().then(data => {
document.getElementById('js-volume').innerText = data.volume;
document.getElementById('js-date').innerText = data.date;
document.getElementById('js-weather').innerText = data.weather;
document.getElementById('js-price').innerText = data.price;
document.getElementById('js-header1').innerText = data.leftArticle.title;
document.getElementById('js-header2').innerText = data.leftArticle.subheading;
document.getElementById('js-authors1').innerText = data.leftArticle.authors;
document.getElementById('js-content1').innerText = data.leftArticle.content;
document.getElementById('js-midImg').src = data.middleArticle.imageURL;
document.getElementById('js-midImgCredit').innerText = data.middleArticle.imageCredit;
document.getElementById('js-author').innerText = data.middleArticle.author;
document.getElementById('js-midTitle').innerText = data.middleArticle.heading;
if (window.matchMedia("(min-width: 2000px)")) {
document.getElementById('js-midText1').innerText = data.middleArticle.content.substr(0, data.middleArticle.content.length / 3);
document.getElementById('js-midText2').innerText = data.middleArticle.content.substr(data.middleArticle.content.length / 3, data.middleArticle.content.length / 1.5);
document.getElementById('js-midText3').innerText = data.middleArticle.content.substr((data.middleArticle.content.length / 3) * 2, data.middleArticle.content.length);
}
else {
document.getElementById('js-midText1').innerText = data.middleArticle.content.substr(0, data.middleArticle.content.length / 2);
document.getElementById('js-midText2').innerText = data.middleArticle.content.substr(data.middleArticle.content.length / 2, data.middleArticle.content.length / 2);
}
document.getElementById('js-rightTitle').innerText = data.rightArticle.title;
document.getElementById('js-rightSubhead').innerText = data.rightArticle.subheading;
document.getElementById('js-rightText1').innerText = data.rightArticle.content.substr(0, data.rightArticle.content.length / 2);
document.getElementById('js-rightText2').innerText = data.rightArticle.content.substr(data.rightArticle.content.length / 2, data.rightArticle.content.length);
currentId = id;
}));
}
window.onload = () => {
console.assert(articles != null);
loadArticle(currentId);
}
</script>
<script type="module">
import dictionary from 'https://sharks-interactive.github.io/Silveny-Speech/dictionary.js';
const outputField = document.getElementById('js-output-trans');
const getPrefix = (i, words) =>
(i == 0 || words[i - 1] == ' ') ? '' : ' '; // No previous char
function translate() {
document.querySelectorAll('*').forEach(elm => {
if (!['P', 'H2', 'H1', 'H3', 'STRONG'].includes(elm.tagName)) return;
console.log(elm.tagName)
const words = elm.innerText.split(' ');
var output = '';
for (let z = 0; z < words.length; z++) {
let element = filterPunctuation(words[z]);
output += getPrefix(z, words) + findValueByKey(element[0]) + element[1];
}
elm.innerText = output;
});
}
window.trans = translate;
function findValueByKey(searchKey) {
let result = dictionary[searchKey.toLowerCase()];
if (result) return searchKey.charAt(0).toUpperCase() != searchKey.charAt(0) ? result.charAt(0).toLowerCase() + result.substr(1) : result;
return searchKey;
}
function filterPunctuation(string) {
let punc = "";
['.', ',', '?', '!', ';',].forEach(element => {
if (string.includes(element)) {
string = string.replaceAll(element, '');
punc = element;
}
});
return [string, punc];
}
</script>
</body>
</html>