File app/index.html changed (mode: 100755) (index 4908267..52a129a) |
14 |
14 |
<li id="Page0" class="oPage isActive uCenter"> |
<li id="Page0" class="oPage isActive uCenter"> |
15 |
15 |
<img class="oPage_logo" src="logo.png" /> |
<img class="oPage_logo" src="logo.png" /> |
16 |
16 |
|
|
17 |
|
<small>V 5.0.0</small> |
|
|
17 |
|
<small id="AppVersion">V 5.0.1</small> |
18 |
18 |
|
|
19 |
19 |
<h1>Texte Liturgice Ortodoxe</h1> |
<h1>Texte Liturgice Ortodoxe</h1> |
20 |
20 |
|
|
|
41 |
41 |
<ul id="ChapterBooks" class="oListBare"></ul> |
<ul id="ChapterBooks" class="oListBare"></ul> |
42 |
42 |
</li> |
</li> |
43 |
43 |
|
|
44 |
|
<li id="Page3" class="oPage oContent"></li> |
|
|
44 |
|
<li id="Page3" class="oPage"> |
|
45 |
|
<main id="Page3Content" class="oContent text-normal"></main> |
|
46 |
|
</li> |
45 |
47 |
|
|
46 |
48 |
</ul> |
</ul> |
47 |
49 |
|
|
48 |
50 |
<!-- -------------------------------------- --> |
<!-- -------------------------------------- --> |
49 |
51 |
|
|
50 |
52 |
<script type="text/javascript"> |
<script type="text/javascript"> |
51 |
|
console.log('Start JS'); |
|
52 |
53 |
var DONE = 4; // readyState 4 means the request is done. |
var DONE = 4; // readyState 4 means the request is done. |
53 |
54 |
var OK = 200; // status 200 is a successful return. |
var OK = 200; // status 200 is a successful return. |
54 |
55 |
|
|
|
56 |
57 |
var elPageIndex = document.getElementById('Page0'); |
var elPageIndex = document.getElementById('Page0'); |
57 |
58 |
var elPageHome = document.getElementById('Page1'); |
var elPageHome = document.getElementById('Page1'); |
58 |
59 |
var elPageChapter = document.getElementById('Page2'); |
var elPageChapter = document.getElementById('Page2'); |
59 |
|
var elPageContent = document.getElementById('Page3'); |
|
|
60 |
|
var elPageBook = document.getElementById('Page3'); |
|
61 |
|
var elPageContent = document.getElementById('Page3Content'); |
60 |
62 |
var elMainBooks = document.getElementById('MainBooks'); |
var elMainBooks = document.getElementById('MainBooks'); |
61 |
63 |
|
|
62 |
64 |
var urls = { |
var urls = { |
|
66 |
68 |
var pagesList = []; |
var pagesList = []; |
67 |
69 |
var mainBooks = []; |
var mainBooks = []; |
68 |
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
/// Core section |
|
74 |
|
|
|
75 |
|
function promise (url, fnSuccess, fnError) { |
|
76 |
|
var oReq = new XMLHttpRequest(); |
|
77 |
|
|
|
78 |
|
oReq.onload = function (e) { |
|
79 |
|
if (typeof(fnSuccess) == "function") { |
|
80 |
|
var responseText = e.target.response.toString(); |
|
81 |
|
|
|
82 |
|
fnSuccess.call(this,[responseText]); |
|
83 |
|
} |
|
84 |
|
}; |
|
85 |
|
|
|
86 |
|
oReq.onerror = function (e) { |
|
87 |
|
if (typeof(fnSuccess) == "function") { |
|
88 |
|
var responseText = e.target.response.toString(); |
|
89 |
|
|
|
90 |
|
fnError.call(this, [responseText]); |
|
91 |
|
} |
|
92 |
|
}; |
|
93 |
|
|
|
94 |
|
oReq.onreadystatechange = function () { |
|
95 |
|
console.log(oReq.readyState); |
|
96 |
|
}; |
|
97 |
|
|
|
98 |
|
oReq.open('GET', url, true); |
|
99 |
|
|
|
100 |
|
oReq.send(); |
|
101 |
|
} |
|
102 |
|
|
|
103 |
|
function errorHandler () { |
|
104 |
|
console.log("ERROR: "); |
|
105 |
|
console.error(errorMessage); |
|
106 |
|
} |
|
107 |
|
|
69 |
108 |
function changePage (elPageCurrent, elPageNew, fnCallback) { |
function changePage (elPageCurrent, elPageNew, fnCallback) { |
70 |
109 |
elPageCurrent.classList.add('animated'); |
elPageCurrent.classList.add('animated'); |
71 |
110 |
elPageCurrent.classList.add('slideOutLeft'); |
elPageCurrent.classList.add('slideOutLeft'); |
|
121 |
160 |
pagesList.pop(); |
pagesList.pop(); |
122 |
161 |
} |
} |
123 |
162 |
|
|
|
163 |
|
function pageContent (strContent) { |
|
164 |
|
elPageContent.innerHTML = strContent + mSize(); |
|
165 |
|
|
|
166 |
|
mSizeEvents(); |
|
167 |
|
} |
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
/// Size module |
|
172 |
|
|
|
173 |
|
function mSize () { |
|
174 |
|
var htmlFooter = |
|
175 |
|
'<footer id="ContentFooter">' + |
|
176 |
|
'<div id="SizeButtons" class="mSize">' + |
|
177 |
|
'<span class="mSize-small">A</span>' + |
|
178 |
|
'<span class="mSize-normal mSize-active">A</span>' + |
|
179 |
|
'<span class="mSize-large">A</span>' + |
|
180 |
|
'</div>' + |
|
181 |
|
'</footer>'; |
|
182 |
|
|
|
183 |
|
return htmlFooter; |
|
184 |
|
} |
|
185 |
|
|
|
186 |
|
function mSizeFind (_inClass) { |
|
187 |
|
var elSizeButtons = document.getElementById('SizeButtons'); |
|
188 |
|
var sizes = elSizeButtons.getElementsByTagName('span'); |
|
189 |
|
|
|
190 |
|
_inClass = 'mSize-' + _inClass; |
|
191 |
|
|
|
192 |
|
for (var i in sizes) { |
|
193 |
|
if ((' ' + sizes[i].className + ' ').indexOf(' ' + _inClass + ' ') > -1) { |
|
194 |
|
return sizes[i]; |
|
195 |
|
} |
|
196 |
|
} |
|
197 |
|
return false; |
|
198 |
|
} |
|
199 |
|
|
|
200 |
|
function mSizeEvents () { |
|
201 |
|
var elSizeButtons = document.getElementById('SizeButtons'); |
|
202 |
|
|
|
203 |
|
elSizeButtons.addEventListener('click', function () { |
|
204 |
|
var btnSize = document.getElementById('btn-size'); |
|
205 |
|
var elActive = mSizeFind('active'); |
|
206 |
|
var classContent = elPageContent.classList[1]; |
|
207 |
|
var classActive = 'mSize-active'; |
|
208 |
|
|
|
209 |
|
elActive.classList.remove(classActive); |
|
210 |
|
|
|
211 |
|
var sizeModifier; |
|
212 |
|
|
|
213 |
|
switch (classContent) { |
|
214 |
|
case 'text-normal': |
|
215 |
|
sizeModifier = 'large'; |
|
216 |
|
break; |
|
217 |
|
case 'text-large': |
|
218 |
|
sizeModifier = 'small'; |
|
219 |
|
break; |
|
220 |
|
case 'text-small': |
|
221 |
|
sizeModifier = 'normal'; |
|
222 |
|
break; |
|
223 |
|
default: |
|
224 |
|
} |
|
225 |
|
|
|
226 |
|
mSizeFind(sizeModifier).classList.add(classActive); |
|
227 |
|
elPageContent.classList.remove(classContent); |
|
228 |
|
elPageContent.classList.add("text-" + sizeModifier); |
|
229 |
|
}); |
|
230 |
|
} |
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
|
/// Book section |
|
235 |
|
|
124 |
236 |
function addBook (currentBook, index, elParent) { |
function addBook (currentBook, index, elParent) { |
125 |
237 |
var elItem = document.createElement("li"); |
var elItem = document.createElement("li"); |
126 |
238 |
var elCheckbox = document.createElement("input"); |
var elCheckbox = document.createElement("input"); |
|
236 |
348 |
var bookId = this.getAttribute('data-book'); |
var bookId = this.getAttribute('data-book'); |
237 |
349 |
var bookUrl = 'book_' + bookId + '.html'; |
var bookUrl = 'book_' + bookId + '.html'; |
238 |
350 |
|
|
239 |
|
console.log("Request " + bookUrl); |
|
240 |
|
|
|
241 |
351 |
elPageContent.innerHTML = ""; |
elPageContent.innerHTML = ""; |
242 |
|
|
|
243 |
|
changePage(elPageChapter, elPageContent); |
|
244 |
|
|
|
|
352 |
|
changePage(elPageChapter, elPageBook); |
245 |
353 |
|
|
246 |
354 |
promise(bookUrl, function (responseText) { |
promise(bookUrl, function (responseText) { |
247 |
355 |
console.log("Received data"); |
console.log("Received data"); |
248 |
356 |
console.log(responseText); // 'This is the returned text.' |
console.log(responseText); // 'This is the returned text.' |
249 |
357 |
|
|
250 |
|
elPageContent.innerHTML = responseText; |
|
|
358 |
|
pageContent(responseText); |
251 |
359 |
}, errorHandler); |
}, errorHandler); |
252 |
360 |
} |
} |
253 |
|
|
|
254 |
|
// var xhr = new XMLHttpRequest(); |
|
255 |
|
// xhr.open('GET', bookUrl); |
|
256 |
|
// xhr.send(null); |
|
257 |
|
// console.log("Request " + bookUrl); |
|
258 |
|
|
|
259 |
|
// xhr.onreadystatechange = function () { |
|
260 |
|
// if (xhr.readyState === DONE) { |
|
261 |
|
// var chapterBooks = []; |
|
262 |
|
|
|
263 |
|
// if (xhr.status === OK) { |
|
264 |
|
// console.log("Received data"); |
|
265 |
|
// console.log(xhr.responseText); // 'This is the returned text.' |
|
266 |
|
// chapterBooks = JSON.parse(xhr.responseText); |
|
267 |
|
// } else { |
|
268 |
|
// console.log('Error: ' + xhr.status); // An error occurred during the request. |
|
269 |
|
// } |
|
270 |
|
|
|
271 |
|
// setTimeout( function () { |
|
272 |
|
// changePage(elPageHome, elPageChapter, function () { listChaper(chapterBooks, bookId); }); |
|
273 |
|
// }, 2000); |
|
274 |
|
// } |
|
275 |
|
// }; |
|
276 |
|
} |
|
277 |
|
|
|
278 |
|
function promise (url, fnSuccess, fnError) { |
|
279 |
|
var oReq = new XMLHttpRequest(); |
|
280 |
|
|
|
281 |
|
oReq.onload = function (e) { |
|
282 |
|
if (typeof(fnSuccess) == "function") { |
|
283 |
|
var responseText = e.target.response.toString(); |
|
284 |
|
|
|
285 |
|
fnSuccess.call(this,[responseText]); |
|
286 |
|
} |
|
287 |
|
}; |
|
288 |
|
|
|
289 |
|
oReq.onerror = function (e) { |
|
290 |
|
if (typeof(fnSuccess) == "function") { |
|
291 |
|
var responseText = e.target.response.toString(); |
|
292 |
|
|
|
293 |
|
fnError.call(this, [responseText]); |
|
294 |
|
} |
|
295 |
|
}; |
|
296 |
|
|
|
297 |
|
oReq.onreadystatechange = function () { |
|
298 |
|
console.log(oReq.readyState); |
|
299 |
|
}; |
|
300 |
|
|
|
301 |
|
oReq.open('GET', url, true); |
|
302 |
|
|
|
303 |
|
oReq.send(); |
|
304 |
|
} |
|
305 |
|
|
|
306 |
|
function errorHandler () { |
|
307 |
|
console.log("ERROR: "); |
|
308 |
|
console.error(errorMessage); |
|
309 |
361 |
} |
} |
310 |
362 |
|
|
311 |
363 |
|
|
312 |
364 |
|
|
313 |
|
////////// |
|
314 |
|
|
|
315 |
|
|
|
|
365 |
|
/// Bootstrap actions when page is loaded |
316 |
366 |
|
|
317 |
367 |
document.addEventListener('DOMContentLoaded', function() { |
document.addEventListener('DOMContentLoaded', function() { |
318 |
368 |
|
|
|
320 |
370 |
mainBooks = JSON.parse(responseText); |
mainBooks = JSON.parse(responseText); |
321 |
371 |
setTimeout( function () { |
setTimeout( function () { |
322 |
372 |
changePage(elPageIndex, elPageHome, listBooks); |
changePage(elPageIndex, elPageHome, listBooks); |
323 |
|
}, 2000); |
|
|
373 |
|
}, 1000); |
324 |
374 |
}, errorHandler); |
}, errorHandler); |
325 |
375 |
|
|
326 |
376 |
}); |
}); |
|
328 |
378 |
</script> |
</script> |
329 |
379 |
|
|
330 |
380 |
</body> |
</body> |
331 |
|
</html> |
|
|
381 |
|
</html> |