Update templates/traduction.html
Browse files- templates/traduction.html +75 -6
templates/traduction.html
CHANGED
@@ -12,25 +12,71 @@
|
|
12 |
secondary: '#333333',
|
13 |
hover: '#ffbfcf',
|
14 |
'light-gray': '#e0e0e0',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
}
|
17 |
}
|
18 |
}
|
19 |
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
</head>
|
21 |
<body class="bg-white font-sans">
|
22 |
|
23 |
-
<header class="bg-primary py-4 shadow-md">
|
24 |
<h1 class="text-center text-2xl font-semibold text-secondary">BOMA LANGUE</h1>
|
25 |
</header>
|
26 |
|
27 |
-
<main class="container mx-auto p-4">
|
28 |
<form id="translation-form">
|
29 |
|
30 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
|
31 |
<div>
|
32 |
<label for="source_language" class="block text-sm font-medium text-secondary mb-2">Langue source:</label>
|
33 |
-
<select id="source_language" name="source_language" class="w-full p-3 border border-light-gray rounded-md focus:ring-2 focus:ring-primary focus:border-transparent">
|
34 |
{% for lang in source_languages %}
|
35 |
<option value="{{ lang }}">{{ lang }}</option>
|
36 |
{% endfor %}
|
@@ -38,7 +84,7 @@
|
|
38 |
</div>
|
39 |
<div>
|
40 |
<label for="target_language" class="block text-sm font-medium text-secondary mb-2">Langue cible:</label>
|
41 |
-
<select id="target_language" name="target_language" class="w-full p-3 border border-light-gray rounded-md focus:ring-2 focus:ring-primary focus:border-transparent">
|
42 |
{% for lang in target_languages %}
|
43 |
<option value="{{ lang }}">{{ lang }}</option>
|
44 |
{% endfor %}
|
@@ -48,7 +94,7 @@
|
|
48 |
|
49 |
<div class="mb-6">
|
50 |
<label for="input_text" class="block text-sm font-medium text-secondary mb-2">Texte source:</label>
|
51 |
-
<textarea id="input_text" name="input_text" class="w-full p-3 border border-light-gray rounded-md focus:ring-2 focus:ring-primary focus:border-transparent resize-none" rows="5" placeholder="Entrez le texte à traduire"></textarea>
|
52 |
</div>
|
53 |
|
54 |
<div class="flex justify-center mb-6">
|
@@ -57,25 +103,48 @@
|
|
57 |
|
58 |
<div class="mb-6">
|
59 |
<label for="translated_text" class="block text-sm font-medium text-secondary mb-2">Texte traduit:</label>
|
60 |
-
<textarea id="translated_text" name="translated_text" class="w-full p-3 border border-light-gray rounded-md focus:ring-2 focus:ring-primary focus:border-transparent resize-none" rows="5" placeholder="Traduction" readonly></textarea>
|
61 |
</div>
|
62 |
|
63 |
</form>
|
64 |
</main>
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
<script>
|
67 |
document.getElementById('translation-form').addEventListener('submit', function (event) {
|
68 |
event.preventDefault();
|
69 |
const form = event.target;
|
|
|
|
|
|
|
|
|
|
|
70 |
fetch('/', {
|
71 |
method: 'POST',
|
72 |
body: new FormData(form)
|
73 |
})
|
74 |
.then(response => response.json())
|
75 |
.then(data => {
|
|
|
|
|
76 |
document.getElementById('translated_text').value = data.translated_text;
|
77 |
})
|
78 |
.catch(error => {
|
|
|
|
|
79 |
console.error('Error:', error);
|
80 |
document.getElementById('translated_text').value = 'Une erreur est survenue.';
|
81 |
});
|
|
|
12 |
secondary: '#333333',
|
13 |
hover: '#ffbfcf',
|
14 |
'light-gray': '#e0e0e0',
|
15 |
+
},
|
16 |
+
keyframes: {
|
17 |
+
'fade-in-down': {
|
18 |
+
'0%': {
|
19 |
+
opacity: '0',
|
20 |
+
transform: 'translateY(-10px)'
|
21 |
+
},
|
22 |
+
'100%': {
|
23 |
+
opacity: '1',
|
24 |
+
transform: 'translateY(0)'
|
25 |
+
},
|
26 |
+
},
|
27 |
+
'bounce': {
|
28 |
+
'0%, 100%': {
|
29 |
+
transform: 'translateY(-10%)',
|
30 |
+
'animation-timing-function': 'cubic-bezier(0.8,0,1,1)'
|
31 |
+
},
|
32 |
+
'50%': {
|
33 |
+
transform: 'translateY(0)',
|
34 |
+
'animation-timing-function': 'cubic-bezier(0,0,0.2,1)'
|
35 |
+
}
|
36 |
+
},
|
37 |
+
'spin-slow': {
|
38 |
+
'0%': { transform: 'rotate(0deg)' },
|
39 |
+
'100%': { transform: 'rotate(360deg)' },
|
40 |
+
},
|
41 |
+
},
|
42 |
+
animation: {
|
43 |
+
'fade-in-down': 'fade-in-down 0.5s ease-out',
|
44 |
+
'bounce': 'bounce 1s infinite',
|
45 |
+
'spin-slow': 'spin-slow 2s linear infinite',
|
46 |
}
|
47 |
}
|
48 |
}
|
49 |
}
|
50 |
</script>
|
51 |
+
<style>
|
52 |
+
/* Style pour l'overlay de chargement */
|
53 |
+
.loading-overlay {
|
54 |
+
position: fixed;
|
55 |
+
top: 0;
|
56 |
+
left: 0;
|
57 |
+
width: 100%;
|
58 |
+
height: 100%;
|
59 |
+
background-color: rgba(255, 255, 255, 0.8); /* Fond blanc semi-transparent */
|
60 |
+
display: flex;
|
61 |
+
justify-content: center;
|
62 |
+
align-items: center;
|
63 |
+
z-index: 50; /* Assurez-vous que l'overlay est au-dessus du contenu */
|
64 |
+
}
|
65 |
+
</style>
|
66 |
</head>
|
67 |
<body class="bg-white font-sans">
|
68 |
|
69 |
+
<header class="bg-primary py-4 shadow-md animate-fade-in-down">
|
70 |
<h1 class="text-center text-2xl font-semibold text-secondary">BOMA LANGUE</h1>
|
71 |
</header>
|
72 |
|
73 |
+
<main class="container mx-auto p-4 animate-fade-in-down">
|
74 |
<form id="translation-form">
|
75 |
|
76 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
|
77 |
<div>
|
78 |
<label for="source_language" class="block text-sm font-medium text-secondary mb-2">Langue source:</label>
|
79 |
+
<select id="source_language" name="source_language" class="w-full p-3 border border-light-gray rounded-md focus:ring-2 focus:ring-primary focus:border-transparent transition duration-200 ease-in-out">
|
80 |
{% for lang in source_languages %}
|
81 |
<option value="{{ lang }}">{{ lang }}</option>
|
82 |
{% endfor %}
|
|
|
84 |
</div>
|
85 |
<div>
|
86 |
<label for="target_language" class="block text-sm font-medium text-secondary mb-2">Langue cible:</label>
|
87 |
+
<select id="target_language" name="target_language" class="w-full p-3 border border-light-gray rounded-md focus:ring-2 focus:ring-primary focus:border-transparent transition duration-200 ease-in-out">
|
88 |
{% for lang in target_languages %}
|
89 |
<option value="{{ lang }}">{{ lang }}</option>
|
90 |
{% endfor %}
|
|
|
94 |
|
95 |
<div class="mb-6">
|
96 |
<label for="input_text" class="block text-sm font-medium text-secondary mb-2">Texte source:</label>
|
97 |
+
<textarea id="input_text" name="input_text" class="w-full p-3 border border-light-gray rounded-md focus:ring-2 focus:ring-primary focus:border-transparent resize-none transition duration-200 ease-in-out" rows="5" placeholder="Entrez le texte à traduire"></textarea>
|
98 |
</div>
|
99 |
|
100 |
<div class="flex justify-center mb-6">
|
|
|
103 |
|
104 |
<div class="mb-6">
|
105 |
<label for="translated_text" class="block text-sm font-medium text-secondary mb-2">Texte traduit:</label>
|
106 |
+
<textarea id="translated_text" name="translated_text" class="w-full p-3 border border-light-gray rounded-md focus:ring-2 focus:ring-primary focus:border-transparent resize-none transition duration-200 ease-in-out" rows="5" placeholder="Traduction" readonly></textarea>
|
107 |
</div>
|
108 |
|
109 |
</form>
|
110 |
</main>
|
111 |
|
112 |
+
<!-- Overlay de chargement -->
|
113 |
+
<div id="loading-overlay" class="loading-overlay hidden">
|
114 |
+
<div class="flex space-x-2 animate-bounce">
|
115 |
+
<div class="w-4 h-4 bg-primary rounded-full"></div>
|
116 |
+
<div class="w-4 h-4 bg-primary rounded-full"></div>
|
117 |
+
<div class="w-4 h-4 bg-primary rounded-full"></div>
|
118 |
+
</div>
|
119 |
+
<div class="animate-spin-slow ml-4 text-secondary">
|
120 |
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
121 |
+
<path stroke-linecap="round" stroke-linejoin="round" d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5" />
|
122 |
+
</svg>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
|
126 |
<script>
|
127 |
document.getElementById('translation-form').addEventListener('submit', function (event) {
|
128 |
event.preventDefault();
|
129 |
const form = event.target;
|
130 |
+
const loadingOverlay = document.getElementById('loading-overlay');
|
131 |
+
|
132 |
+
// Afficher l'overlay de chargement
|
133 |
+
loadingOverlay.classList.remove('hidden');
|
134 |
+
|
135 |
fetch('/', {
|
136 |
method: 'POST',
|
137 |
body: new FormData(form)
|
138 |
})
|
139 |
.then(response => response.json())
|
140 |
.then(data => {
|
141 |
+
// Masquer l'overlay de chargement après la réponse
|
142 |
+
loadingOverlay.classList.add('hidden');
|
143 |
document.getElementById('translated_text').value = data.translated_text;
|
144 |
})
|
145 |
.catch(error => {
|
146 |
+
// Masquer l'overlay de chargement en cas d'erreur
|
147 |
+
loadingOverlay.classList.add('hidden');
|
148 |
console.error('Error:', error);
|
149 |
document.getElementById('translated_text').value = 'Une erreur est survenue.';
|
150 |
});
|