-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
202 lines (184 loc) · 10.9 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
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html lang="fr">
<head>
<title>InfoGare</title>
<meta charset="UTF-8">
<meta name="description" content="Exemple de générateur d'Infogare">
<meta name="author" content="SSStuart">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="favicon.png">
<link rel="stylesheet" type="text/css" href="./styles.css">
<script src="https://ssstuart.net/APIs/WWWidget.js"></script>
</head>
<body>
<header>Infogare - <abbr title="Démonstration de faisabilité">POC</abbr></header>
<main>
<button type="button" onclick="toggleAreas()">Afficher/Cacher les zones</button><button type="button" onclick="toggleAreas(true);save();">Enregistrer (.png)</button>
<div id="containerParcoursDepart">
<p><span class="value" contenteditable id="heure">00h00</span></p>
<div id="typeNum">
<p class="inline"><span class="value" contenteditable id="destination">Entzheim Aéroport</span></p>
<p class="inline"><span class="value" contenteditable id="typeTrain">TER</span></p>
<p class="inline"><span class="value" contenteditable id="numTrain">86770</span></p>
</div>
<p><span class="value stops" contenteditable id="stop0">Molsheim</span></p>
<p><span class="value stops" contenteditable id="stop1">Mutzig</span></p>
<p><span class="value stops" contenteditable id="stop2">Gresswiller</span></p>
<p><span class="value stops" contenteditable id="stop3">Urmatt</span></p>
<p><span class="value stops" contenteditable id="stop4">Lutzelhouse</span></p>
<p><span class="value stops" contenteditable id="stop5">Wisches</span></p>
<p><span class="value stops" contenteditable id="stop6">Russ Hersbach</span></p>
<p><span class="value stops" contenteditable id="stop7">Schirmeck la Broque</span></p>
<p><span class="value stops" contenteditable id="stop8">Rothau</span></p>
<p><span class="value stops" contenteditable id="stop9">Fouday</span></p>
<div id="dest">
<p class="inline"><span class="value" contenteditable id="stopDest">Entzheim Aéroport</span></p>
</div>
<p><span class="value" contenteditable id="informations">Assurez-vous de n'avoir rien oublié dans le train</span></p>
<p><span class="value heure" contenteditable id="currentHeure">00:00</span></p>
<p><span class="value heure" contenteditable id="currentSec">00</span></p>
</div>
<!--<div id="containerParcoursArrive">
<p><span class="value" contenteditable id="heure">00h00</span></p>
<div id="typeNum">
<p class="inline"><span class="value" contenteditable id="destination">Lyon</span></p>
<p class="inline"><span class="value" contenteditable id="typeTrain">TER</span></p>
<p class="inline"><span class="value" contenteditable id="numTrain">86770</span></p>
</div>
<p><span class="value stops" contenteditable id="stop0">Molsheim</span></p>
<p><span class="value stops" contenteditable id="stop1">Mutzig</span></p>
<p><span class="value stops" contenteditable id="stop2">Gresswiller</span></p>
<p><span class="value stops" contenteditable id="stop3">Urmatt</span></p>
<p><span class="value stops" contenteditable id="stop4">Lutzelhouse</span></p>
<p><span class="value stops" contenteditable id="stop5">Wisches</span></p>
<p><span class="value stops" contenteditable id="stop6">Russ Hersbach</span></p>
<p><span class="value stops" contenteditable id="stop7">Schirmeck la Broque</span></p>
<p><span class="value stops" contenteditable id="stop8">Rothau</span></p>
<p><span class="value stops" contenteditable id="stop9">Fouday</span></p>
<p><span class="value stops" contenteditable id="stopDest">Lyon</span></p>
<p><span class="value heure" contenteditable id="currentHeure"></span></p>
<p><span class="value heure" contenteditable id="currentSec"></span></p>
<p><span class="value" contenteditable id="informations">Assurez-vous de n'avoir rien oublié dans le train</span></p>
</div>-->
<details>
<summary><b>Comparaison avec affichage réel</b></summary>
<p>
Vous pouvez recopier le texte (par exemple l'heure : 08h50) pour comparer l'affichage original et la reproduction.
</p>
<div id="containerExemple">
<p><span contenteditable id="heure"></span></p>
<div id="typeNum">
<p class="inline"><span contenteditable id="destination"></span></p>
<p class="inline"><span contenteditable id="typeTrain"></span></p>
<p class="inline"><span contenteditable id="numTrain"></span></p>
</div>
<p><span class="stops" contenteditable id="stop0"></span></p>
<p><span class="stops" contenteditable id="stop1"></span></p>
<p><span class="stops" contenteditable id="stop2"></span></p>
<p><span class="stops" contenteditable id="stop3"></span></p>
<p><span class="stops" contenteditable id="stop4"></span></p>
<p><span class="stops" contenteditable id="stop5"></span></p>
<p><span class="stops" contenteditable id="stop6"></span></p>
<p><span class="stops" contenteditable id="stop7"></span></p>
<p><span class="stops" contenteditable id="stop8"></span></p>
<p><span class="stops" contenteditable id="stop9"></span></p>
<div id="dest">
<p class="inline"><span contenteditable id="stopDest"></span></p>
</div>
<p><span class="heure" contenteditable id="currentHeure"></span></p>
<p><span class="heure" contenteditable id="currentSec"></span></p>
</div>
</details>
</main>
<script src="html2canvas.min.js"></script>
<script>
// Enregistrement de l'image créée
function save() {
window.scrollTo(0, 0);
html2canvas(document.querySelector("#containerParcoursDepart")).then(canvas => {
saveAs(canvas.toDataURL(), 'infogare.png');
});
}
function saveAs(uri, filename) {
var link = document.createElement('a');
if (typeof link.download === 'string') {
// Pour Firefox (nécessite de créer un lien)
link.href = uri;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} else {
window.open(uri);
}
}
var displayArea = false;
function toggleAreas(state = null) {
if (state != null) {
displayArea = state;
}
var valdisp = document.getElementsByClassName('value');
if (displayArea) {
for (disp = 0; disp < valdisp.length; disp++) {
valdisp[disp].style.outline = "";
displayArea = false;
}
} else {
for (disp = 0; disp < valdisp.length; disp++) {
valdisp[disp].style.outline = "1px red solid";
displayArea = true;
}
}
}
var today = new Date();
var hourMin = "";
if (today.getHours().toString().length<2)
hourMin = "0" + today.getHours() + ":";
else
hourMin = today.getHours() + ":";
if (today.getMinutes().toString().length<2)
hourMin += "0" + today.getMinutes();
else
hourMin += today.getMinutes();
var seconde;
if (today.getSeconds().toString().length<2) {
seconde = "0" + today.getSeconds();
} else {
seconde = today.getSeconds();
}
document.getElementById('currentHeure').innerHTML = hourMin;
document.getElementById('currentSec').innerHTML = seconde;
document.getElementById('currentHeure').addEventListener('keydown', function(event)
{
if (event.keyCode == 8 || event.keyCode == 46) {
contentHeure = document.getElementById('currentHeure').innerText = "";
} else {
contentHeure = document.getElementById('currentHeure').innerText;
contentHeureClean = contentHeure.replace("<br>", "");
console.log(contentHeureClean);
if (contentHeure.length>5) {
// PERMET D'ECRIRE L'HEURE (heure+minute+seconde) SANS CHANGER DE SPAN
overflow = contentHeure.slice(-1);
contentHeure = contentHeure.substring(0, 5);
document.getElementById('currentHeure').innerHTML = contentHeure;
document.getElementById('currentSec').innerHTML = overflow;
document.getElementById('currentSec').focus();
range = document.createRange();
range.selectNodeContents(document.getElementById('currentSec'));
range.collapse(false);
selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
}
}
});
document.getElementById('stopDest').addEventListener('keydown', function(event)
{
contentDest = document.getElementById('stopDest').innerHTML;
if (contentDest == "") {
document.getElementById('stopDest').innerHTML = " ";
}
});
</script>
</body>
</html>