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
|
function Options(values, textes) {
this.options = [];
textes = typeof textes === 'undefined' ? values: textes;
for (let i=0, max=values.length; i<max; i++) {
this.options[i] = document.createElement('option');
this.options[i].value = values[i];
this.options[i].appendChild(document.createTextNode(textes[i]));
}
return this.options;
}
function DataSet(elemId, badgeLineRange, contentRange) {
let dataType = elemId.substr(0, elemId.indexOf('[')),
fields = [],
params = [],
separators = ['\u00A0', '-', '\u00A0-\u00A0', '.', '\u00A0.\u00A0', '+', '\u00A0+\u00A0', ', '], // Séparateurs de champs
//separators = ['a', 'b', 'c'],
listOptions = new Options(separators);
contentCell = document.getElementById('main['+badgeLineRange+']');
if (dataType != 'db' && dataType != 'txt') return false;
switch (dataType) {
case 'db':
params = ['select',{id:createId('item',badgeLineRange,contentRange)}, ''];
fields[0] = new CellContent(params);
// Ajouter les options
break;
case 'txt':
params = ['input',{id:createId('item', badgeLineRange, contentRange)}, ''];
fields[0] = new CellContent(params);
break;
}
contentCell.appendChild(fields[0]);
// Ajout du séparateur --> Gérer la largeur
params = ['select', {id:createId('sep',badgeLineRange,contentRange)}, ''];
fields[1] = new CellContent(params);
fields[1].style.minWidth = 'initial';
fields[1].style.maxWidth = '3em';
contentCell.appendChild(fields[1]);
// Ajout des options du séparateur
for (let i=0, max=separators.length; i<max; i++) {
fields[1].appendChild(listOptions[i]);
}
// Ajout de l'image del2
params = ['img', {id:createId('del2',badgeLineRange), src:'_images/del.png', alt:'del.png', title:fromPHPtoJS.delItem}, ''];
fields[2] = new CellContent(params);
contentCell.appendChild(fields[2]);
} |
Partager