-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·119 lines (100 loc) · 4.92 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
<!DOCTYPE html>
<html dir="ltr" lang="fr">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Accueil</title>
<script type="text/javascript">
// Charge un fichier JSON de manière asynchrone et appelle la fonction de callback quand le chargement est terminé
function loadJsonAsynchronously(callback, file) {
var xobj = new XMLHttpRequest();
xobj.open('GET', file);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
callback(xobj.responseText);
}
};
xobj.send(null);
}
// Ajoute dans le DOM la demande de chargement d'un fichier JS ou CSS
function loadFileInDom(filename, filetype, mountingPoint) {
if (filetype == "js") {
var fileref = document.createElement('script');
fileref.setAttribute("type", "text/javascript");
fileref.setAttribute("src", filename);
}
else if (filetype == "css") {
var fileref = document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", filename);
} else if (filetype == "icon") {
var fileref = document.createElement("link");
fileref.setAttribute("rel", "icon");
fileref.setAttribute("type", "image/png");
fileref.setAttribute("href", filename);
}
if (typeof fileref != "undefined") {
mountingPoint = mountingPoint || "head";
document.getElementsByTagName(mountingPoint)[0].appendChild(fileref);
}
}
</script>
<script type="text/javascript">
(function (root) {
var messages = undefined;
var menuItems = undefined;
var config = undefined;
loadJsonAsynchronously(function (response) {
messages = JSON.parse(response);
buildConfigurationAndLoadScript();
}, '/applitutoriel-online/static/resources/messages-fr-FR.json');
loadJsonAsynchronously(function (response) {
menuItems = JSON.parse(response);
buildConfigurationAndLoadScript();
}, '/applitutoriel-online/static/resources/navigation.json');
loadJsonAsynchronously(function (response) {
config = JSON.parse(response);
buildConfigurationAndLoadScript();
}, '/applitutoriel-online/static/config-spa.json');
function buildConfigurationAndLoadScript() {
if (!messages || !menuItems || !config) {
console.log('Chargement non terminé, attente de la prochaine exécution de cette fonction');
return;
}
// Tout est correctement chargé, on peut y aller
console.log('Chargement de la configuration terminée, chargement de la page');
// On insère le contenu du tableau
// config.dispatcher.stores.NavigationBaseStore.menuItems = menuItems.menu;
// On insère la conf de l'application
root.App = {
"plugins": {
"InternationalisationPlugin": {
"i18nMessages": messages,
"locale": config.locale
}
}
};
root.Config = config;
root.HornetCLS = {
"hornet.internationalization": {
"locale": config.locale,
"lang": "fr",
"messages": messages
},
"hornet.menuConfig": menuItems.menu
};
root.AppSharedProps = {"appName":"applitutoriel-online","appVersion":"5.1.0","appDescription":"Application tutoriel utilisant le Framework hornet","appAuthor":"MEAE - Ministère de l'Europe et des Affaires étrangères", "welcomePageUrl":"\u002Faccueil"};
var themeUrl = config.themeUrl;
loadFileInDom("/applitutoriel-online/static/img/logoHornet.png", "icon");
loadFileInDom("/applitutoriel-online/static/css/theme.css", "css");
loadFileInDom("/applitutoriel-online/static/hornet-themes/css/theme.css", "css");
loadFileInDom("/applitutoriel-online/static/js/client.js", "js", "body");
}
}(this));
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>