Commit e9db04ee authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

correction bug enregistrements new id dans repCases après duplication carte

parent 9911f9d9
...@@ -97,7 +97,7 @@ function loadPage() { ...@@ -97,7 +97,7 @@ function loadPage() {
var phon = bouches[bouchePath].replace('bouche_','phon_').replace('.jpg',''); var phon = bouches[bouchePath].replace('bouche_','phon_').replace('.jpg','');
// Formatage de la carte // Formatage de la carte
newDiv.id = phon + '-' + Math.random().toString(36).substring(7); newDiv.id = phon + '-' + Math.random().toString(36).substring(2,9);
newDiv.className = "carte"; newDiv.className = "carte";
newDiv.draggable = true; newDiv.draggable = true;
newDiv.style.backgroundImage = 'url("bouches/'+bouches[bouchePath]+'"'; newDiv.style.backgroundImage = 'url("bouches/'+bouches[bouchePath]+'"';
...@@ -113,7 +113,7 @@ function loadPage() { ...@@ -113,7 +113,7 @@ function loadPage() {
var punct = puncts[i].replace('.jpg',''); var punct = puncts[i].replace('.jpg','');
// Formatage de la carte // Formatage de la carte
newDiv.id = punct + '-' + Math.random().toString(36).substring(7); newDiv.id = punct + '-' + Math.random().toString(36).substring(2,9);
newDiv.className = "carte"; newDiv.className = "carte";
newDiv.draggable = true; newDiv.draggable = true;
newDiv.style.backgroundImage = 'url("punct/'+puncts[i]+'"'; newDiv.style.backgroundImage = 'url("punct/'+puncts[i]+'"';
...@@ -129,7 +129,7 @@ function loadPage() { ...@@ -129,7 +129,7 @@ function loadPage() {
var tp = tps[i].replace('.jpg',''); var tp = tps[i].replace('.jpg','');
// Formatage de la carte // Formatage de la carte
newDiv.id = tp + '-' + Math.random().toString(36).substring(7); newDiv.id = tp + '-' + Math.random().toString(36).substring(2,9);
newDiv.className = "carte"; newDiv.className = "carte";
newDiv.draggable = true; newDiv.draggable = true;
newDiv.style.backgroundImage = 'url("trait-point/'+tps[i]+'"'; newDiv.style.backgroundImage = 'url("trait-point/'+tps[i]+'"';
...@@ -202,6 +202,7 @@ function loadPage() { ...@@ -202,6 +202,7 @@ function loadPage() {
////////////////////////////////////////// //////////////////////////////////////////
// https://www.youtube.com/watch?v=C22hQKE_32c // https://www.youtube.com/watch?v=C22hQKE_32c
// multiple elements : https://www.sitepoint.com/accessible-drag-drop/ // multiple elements : https://www.sitepoint.com/accessible-drag-drop/
// simple draggable http://jsfiddle.net/maniator/zVZFq/
// Drag Functions // Drag Functions
...@@ -273,16 +274,17 @@ function loadPage() { ...@@ -273,16 +274,17 @@ function loadPage() {
} else if (this.classList.contains('case')) { } else if (this.classList.contains('case')) {
repCases[item.parentNode.id] = null; repCases[item.parentNode.id] = null;
repCases[this.id] = item.id;
logg("DROP! in "+this.id); logg("DROP! in "+this.id);
var nodeCopy = item.cloneNode(true); var nodeCopy = item.cloneNode(true);
nodeCopy.classList.remove('hold'); nodeCopy.classList.remove('hold');
nodeCopy.addEventListener('dragstart', dragStart); nodeCopy.addEventListener('dragstart', dragStart);
nodeCopy.addEventListener('dragend', dragEnd); nodeCopy.addEventListener('dragend', dragEnd);
var thisPhon = nodeCopy.id.match(/phon_\w+/); var thisPhon = nodeCopy.id.match(/(\w+)-\w+/);
thisPhon = thisPhon[1];
logg("Match id: "+thisPhon); logg("Match id: "+thisPhon);
thisPhon = thisPhon + '-' + Math.random().toString(36).substring(7); thisPhon = thisPhon + '-' + Math.random().toString(36).substring(2,9);
nodeCopy.id = thisPhon; nodeCopy.id = thisPhon;
repCases[this.id] = nodeCopy.id;
logg("Created new item id: "+nodeCopy.id); logg("Created new item id: "+nodeCopy.id);
e.currentTarget.innerHTML = ''; // on vide la case si elle déjà pleine. e.currentTarget.innerHTML = ''; // on vide la case si elle déjà pleine.
e.currentTarget.appendChild(nodeCopy); e.currentTarget.appendChild(nodeCopy);
...@@ -400,7 +402,7 @@ async function save2url(){ ...@@ -400,7 +402,7 @@ async function save2url(){
var dateTime = date+' '+time; var dateTime = date+' '+time;
// Id // Id
if (pageId == '0') pageId = 'id-' + Math.random().toString(36).substring(7); if (pageId == '0') pageId = 'id-' + Math.random().toString(36).substring(2,9);
// ON EMBALLE TOUT ÇA // ON EMBALLE TOUT ÇA
var colis = { var colis = {
......
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