Commit 9e48facb authored by arnaudbey's avatar arnaudbey
Browse files

dirty fix. use select instead of datalist

parent 3ccfb501
......@@ -41,6 +41,8 @@ Contributors
* Arnaud Bey
* Benjamin Abrial
* Mathieu Loiseau
* Typos
* Yoann Goudin
Credits
--------
......
<script>
function dispalyMoreLanguages(){
//var dl=document.getElementById("list_lang");
var t=document.getElementById("userlang_spoken");
var count = t.getElementsByTagName("tr").length;
if (count === 10) { return;}
var tr = t.insertRow(count);
//var tr = document.createElement("tr");
var td = tr.insertCell(0);
td.align = "center";
//var td = document.createElement("td");
var i = document.createElement('input');
i.type = "text";
i.required="required";
i.setAttribute('list','iso');
i.setAttribute('name','choix_langs_'.concat(count));
i.setAttribute('onchange', 'updateRadio(this);');
//i.list="iso";
i.size="10";
td.appendChild(i);
// tr.appendChild(td);
var td = tr.insertCell(1);
//td = document.createElement('td');
td.align="center";
i = document.createElement('input');
i.type="text";
i.required="required";
i.setAttribute('list','lang_level');
i.setAttribute('name','choix_niveau_'.concat(count));
i.size="10";
td.appendChild(i);
//tr.appendChild(td);
var td = tr.insertCell(2);
//td = document.createElement('td');
td.align="center";
i = document.createElement('input');
i.type="radio";
i.setAttribute('name','lang_game');
td.appendChild(i);
//tr.appendChild(td);
//t.appendChild(tr);
}
function dispalyLessLanguages(){
var t=document.getElementById("userlang_spoken");
function addLanguage(){
var t = document.getElementById("userlang_spoken");
var count = t.getElementsByTagName("tr").length;
if (count > 2) { t.deleteRow(count-1); }
if (count === 10) { return;}
// spoken language
var options = document.getElementById('languages').innerHTML;
var tr = t.insertRow(count);
var td = tr.insertCell(0);
td.align = "center";
var s = document.createElement('select');
s.required="required";
s.setAttribute('name','choix_langs_'.concat(count));
s.setAttribute('onchange', 'updateRadio(this);');
s.innerHTML = options;
s.selectedIndex = 0;
td.appendChild(s);
// level
var td = tr.insertCell(1);
options = document.getElementById('levels').innerHTML;
td.align="center";
s = document.createElement('select');
s.required="required";
s.setAttribute('name','choix_niveau_'.concat(count));
s.innerHTML = options;
s.selectedIndex = 0;
td.appendChild(s);
// Game language
var td = tr.insertCell(2);
td.align="center";
i = document.createElement('input');
i.type="radio";
i.setAttribute('name','lang_game');
td.appendChild(i);
}
function removeLastLanguage(){
var t = document.getElementById("userlang_spoken");
var count = t.getElementsByTagName("tr").length;
if (count > 2) {
t.deleteRow(count-1);
}
}
function updateRadio(l) {
var tr = l.parentNode.parentNode;
var game = tr.cells[2].children[0];
game.setAttribute('value', l.value);
}
</script>
\ No newline at end of file
}
</script>
......@@ -51,20 +51,6 @@ include('./controllersJS/display_lang.js');
<dl>
<dt><label for="userlang_spoken" ><?php echo "Langues parlées";?></label></dt>
<dd>
<datalist id="lang_level">
<option value="Débutant">
<option value="Intermédiaire">
<option value="Avancé">
<option value="Natif">
</datalist>
<datalist id="iso">
<?php
$tableLang=$lang_iso->get_all_codes();
foreach($tableLang as $value){
echo "<option value='".$value."'>";
}
?>
</datalist>
<table id="userlang_spoken">
<tr>
<td width="25%" align="center">Langue</td>
......@@ -73,26 +59,42 @@ include('./controllersJS/display_lang.js');
</tr>
<?php
$i=1;
$languages = $lang_iso->get_all_codes();
$levels = ["Débutant", "Intermédiaire", "Avancé", "Natif"];
$spoken_lang = explode(';',$this->spoken_lang);
$niveaux = explode(';',$this->niveau);
$userlang_game = strlen($this->userlang_game) > 0 ? $lang_iso->french_for($this->userlang_game) : '';
if (sizeof($spoken_lang) >= 1 && !empty($spoken_lang[0])) {
for ($i=0; $i<sizeof($spoken_lang); $i++) {
$languageid = ($i === 0) ? "id='languages'" : "";
$levelid = ($i === 0) ? "id='levels'" : "";
$l = $spoken_lang[$i];
$n = $niveaux[$i];
$i++;
//foreach ($spoken_lang as $l) {
if (strlen($l) > 0) {
echo "<tr><td align='center'>" .
"<input list='iso' type='text' name='choix_langs_" . $i . "' required='required' size='10' onchange=\"updateRadio(this);\" value='" . $l . "'/>" .
"<select ".$languageid ." name='choix_langs_" . $i . "' required='required' onchange=\"updateRadio(this);\">";
foreach($languages as $language){
$selected = ($l === $language) ? "selected" : "";
echo "<option value='".$language."' ".$selected.">".$language."</option>";
}
echo "</select>" .
"</td>" .
"<td align='center'><input list='lang_level' name='choix_niveau_" . $i . "' required='required' size='10'/ value='" . $n . "'></td>";
"<td align='center'>".
"<select ".$levelid." name='choix_niveau_" . $i . "' required='required'>";
foreach($levels as $level){
$selected = ($n === $level) ? "selected" : "";
echo "<option value='".$level."' ".$selected.">".$level."</option>";
}
echo "</select></td>";
if (strcmp($l,$userlang_game) == 0) {
echo "<td align='center'><input type='radio' name='lang_game' required='required' checked value='" . $l . "'/></td></tr>";
} else {
echo "<td align='center'><input type='radio' name='lang_game' required='required' value='" . $l . "'/> </td></tr>";
}
// $i++;
}
$i--;
}
......@@ -109,10 +111,10 @@ include('./controllersJS/display_lang.js');
</table>
<table>
<tr><!-- ici, on include display_lang.js pour ajouter des langues ou les retirer-->
<td><button type="button" id="langueAppriseBtn" onClick="dispalyMoreLanguages();" align="center"><?php echo $lang['ajout_langue'];?></button></td>
<td><button type="button" id="langueAppriseBtn" onClick="addLanguage();" align="center"><?php echo $lang['ajout_langue'];?></button></td>
</tr>
<tr>
<td><button type="button" id="langueAppriseCancel" onClick="dispalyLessLanguages();" align="center"><?php echo "Retirer langue";?></button></td>
<td><button type="button" id="langueAppriseCancel" onClick="removeLastLanguage();" align="center"><?php echo "Retirer langue";?></button></td>
</tr>
</table>
......
<?php
$title = 'S\'enregister';
$title = 'S\'enregistrer ';
include('./views/page.header.html');
require_once('./sys/load_iso.php');
$lang_iso = new IsoLang();
......@@ -48,20 +48,6 @@ include('./controllersJS/display_lang.js');
<dl>
<dt><label for="userlang_spoken" >Choisissez les langues que vous parlez</label></dt>
<dd>
<datalist id="lang_level">
<option value="Débutant">
<option value="Intermédiaire">
<option value="Avancé">
<option value="Natif">
</datalist>
<datalist id="iso">
<?php
$tableLang=$lang_iso->get_all_codes();
foreach($tableLang as $value){
echo "<option value='".$value."'>";
}
?>
</datalist>
<table id="userlang_spoken">
<tr>
<td width="25%" align="center">Langue</td>
......@@ -69,22 +55,40 @@ include('./controllersJS/display_lang.js');
<td width="50%" align="center">Langue de jeu</td>
</tr>
<tr>
<td align="center"><input list="iso" type="text" name="choix_langs_1" required="required" size="10" onchange="updateRadio(this);"/></td>
<td align="center"><input list="lang_level" name="choix_niveau_1" required="required" size="10"/></td>
<td>
<select id="languages" name="choix_langs_1" required="required" onchange="updateRadio(this);">
<option value="">--</option>
<?php
$languages = $lang_iso->get_all_codes();
foreach($languages as $language){
echo "<option value='".$value."'>".$language."</option>";
}
?>
</select>
</td>
<td align="center">
<select id="levels" name="choix_niveau_1" required="required">
<option value="">--</option>
<?php
$levels = ["Débutant", "Intermédiaire", "Avancé", "Natif"];
foreach($levels as $level){
echo "<option value='".$level."'>".$level."</option>";
}
?>
</select>
</td>
<td align="center"><input type="radio" name="lang_game" required="required" /></td>
</tr>
</table>
<table>
<tr>
<td><button type="button" id="langueAppriseBtn" onClick="dispalyMoreLanguages();" align="center">Ajouter une langue </button></td>
<td><button type="button" id="langueAppriseBtn" onClick="addLanguage();" align="center">Ajouter une langue </button></td>
</tr>
<tr>
<td><button type="button" id="langueAppriseCancel" onClick="dispalyLessLanguages();" align="center">Retirer une langue</button></td>
<td><button type="button" id="langueAppriseCancel" onClick="removeLastLanguage();" align="center">Retirer une langue</button></td>
</tr>
</table>
</dd>
</dl>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment