Actualiser js/admin.js
This commit is contained in:
+11
-5
@@ -20,6 +20,11 @@ function getStarsHTML(rating) {
|
|||||||
|
|
||||||
function parseCSV(text) {
|
function parseCSV(text) {
|
||||||
if (text.charCodeAt(0) === 0xFEFF) text = text.slice(1);
|
if (text.charCodeAt(0) === 0xFEFF) text = text.slice(1);
|
||||||
|
|
||||||
|
// ✅ NOUVEAU : Détection automatique du séparateur le plus utilisé sur la première ligne
|
||||||
|
const firstLine = text.split(/[\r\n]+/)[0] || '';
|
||||||
|
const sep = (firstLine.match(/;/g) || []).length > (firstLine.match(/,/g) || []).length ? ';' : ',';
|
||||||
|
|
||||||
const rows = [];
|
const rows = [];
|
||||||
let col = '', row = [], inQuotes = false;
|
let col = '', row = [], inQuotes = false;
|
||||||
for (let i = 0; i < text.length; i++) {
|
for (let i = 0; i < text.length; i++) {
|
||||||
@@ -31,7 +36,7 @@ function parseCSV(text) {
|
|||||||
} else col += c;
|
} else col += c;
|
||||||
} else {
|
} else {
|
||||||
if (c === '"') inQuotes = true;
|
if (c === '"') inQuotes = true;
|
||||||
else if (c === ',') { row.push(col); col = ''; }
|
else if (c === sep) { row.push(col); col = ''; } // ✅ On utilise le séparateur détecté
|
||||||
else if (c === '\n' || c === '\r') {
|
else if (c === '\n' || c === '\r') {
|
||||||
if (c === '\r' && text[i+1] === '\n') i++;
|
if (c === '\r' && text[i+1] === '\n') i++;
|
||||||
row.push(col); col = '';
|
row.push(col); col = '';
|
||||||
@@ -416,14 +421,15 @@ function normalizeVideothequeRow(row) {
|
|||||||
let ean = row['ean_isbn13'] || row['EAN'] || row['ean'] || row['Barcode'] || row['UPC'] || row['upc_isbn10'] || '';
|
let ean = row['ean_isbn13'] || row['EAN'] || row['ean'] || row['Barcode'] || row['UPC'] || row['upc_isbn10'] || '';
|
||||||
if (ean) ean = String(ean).replace(/[^0-9]/g, '');
|
if (ean) ean = String(ean).replace(/[^0-9]/g, '');
|
||||||
|
|
||||||
// ✅ NOUVEAU : Récupérer aussi le titre du CSV
|
// ✅ Tolérance sur le nom de la colonne
|
||||||
let title = row['title'] ? String(row['title']).trim() : '';
|
let title = row['Title'] || row['title'] || row['Titre'] || row['titre'] || row['Name'] || row['name'] || '';
|
||||||
|
title = String(title).trim();
|
||||||
|
|
||||||
if (!ean && !title) return null;
|
if (!ean && !title) return null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ean: ean,
|
ean: ean,
|
||||||
title: title // ✅ Titre envoyé au backend
|
title: title
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,7 +467,7 @@ function handleVideothequeUpload(input) {
|
|||||||
totalSkp += data.skipped || 0;
|
totalSkp += data.skipped || 0;
|
||||||
processed += batch.length;
|
processed += batch.length;
|
||||||
updateImportModal(processed, items.length);
|
updateImportModal(processed, items.length);
|
||||||
await new Promise(r => setTimeout(r, 2000)); // ✅ Délai de 2s pour Blu-ray.com
|
await new Promise(r => setTimeout(r, 5500)); // ✅ Délai de 5.5s pour éviter le blocage
|
||||||
}
|
}
|
||||||
|
|
||||||
input.value = '';
|
input.value = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user