factorise JS WIP
This commit is contained in:
parent
78d565f11b
commit
aabde97ec5
|
@ -25,7 +25,9 @@ section{margin: 0 auto; width: 90%;}
|
||||||
article{float: right; width:70%;}
|
article{float: right; width:70%;}
|
||||||
aside{float:left;width:29%;}
|
aside{float:left;width:29%;}
|
||||||
.playerBox{}
|
.playerBox{}
|
||||||
.playerBox input, .playerBox select {width:100%;}
|
.playerBox em {width: 100%;}
|
||||||
|
.playerBox em label { width: 40%; text-align: right;}
|
||||||
|
.playerBox em input,.playerBox em input, .playerBox em select {width:59%; float:right;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,6 +93,7 @@ function createElemWithLabel(type,attributes,labelTxt, id =''){
|
||||||
var forId = makeid();
|
var forId = makeid();
|
||||||
}
|
}
|
||||||
var label = createElem('label',{'for' : forId});
|
var label = createElem('label',{'for' : forId});
|
||||||
|
label.innerHTML = labelTxt;
|
||||||
em.appendChild(label);
|
em.appendChild(label);
|
||||||
var elem = createElem(type,attributes);
|
var elem = createElem(type,attributes);
|
||||||
if (typeof attributes['id'] !== 'undefined') {
|
if (typeof attributes['id'] !== 'undefined') {
|
||||||
|
@ -119,54 +122,64 @@ function createLineSelect(labelTxt,arrayOptions,attributes){
|
||||||
|
|
||||||
for(var i=0; i < arrayOptions.length; i++){
|
for(var i=0; i < arrayOptions.length; i++){
|
||||||
var option = createElem('option',{'value':arrayOptions[i]['value']});
|
var option = createElem('option',{'value':arrayOptions[i]['value']});
|
||||||
|
option.innerHTML = arrayOptions[i]['text'];
|
||||||
|
select.appendChild(option);
|
||||||
}
|
}
|
||||||
|
em.appendChild(select);
|
||||||
return em;
|
return em;
|
||||||
}
|
}
|
||||||
function createPlayerForm(index){
|
function createPlayerForm(index){
|
||||||
var container = document.getElementById("playersSettings");
|
var container = document.getElementById("playersSettings");
|
||||||
var divForm = createElem("div", {"id": "containerPlayer" + index,"class":"playerBox" } );
|
var divForm = createElem("div", {"id": "containerPlayer" + index,"class":"playerBox" } );
|
||||||
|
|
||||||
//Type of player
|
divForm.appendChild(
|
||||||
var select = createElem("select",{"id":"playerType" + index,"onchange":"changeTypePlayer('" + index + "', this.value);"});
|
createLineSelect('Type:',
|
||||||
var optionHuman = createElem("option",{"value":"Human"});
|
[ {'value':'bot','text' : 'bot'},
|
||||||
optionHuman.innerHTML = "Human";
|
{'value':'human','text' : 'human'}
|
||||||
var optionBot = createElem("option",{"value":"Bot"});
|
],
|
||||||
optionBot.innerHTML = "Bot";
|
|
||||||
|
|
||||||
select.appendChild(optionBot);
|
{"id":"playerType" + index,
|
||||||
select.appendChild(optionHuman);
|
"onchange":"changeTypePlayer('" + index + "', this.value);"
|
||||||
divForm.appendChild(select);
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
divForm.appendChild(
|
||||||
|
createElemWithLabel(
|
||||||
|
'input',
|
||||||
|
{
|
||||||
|
"id":"botUrl" + index, "type": "text", "value":"",
|
||||||
|
"placeholder":"http://Bot.url"
|
||||||
|
},
|
||||||
|
'URL du Bot'
|
||||||
|
)
|
||||||
|
|
||||||
//url
|
);
|
||||||
var inputUrl = createElem("input", {"id":"botUrl" + index, "type": "text", "value":"", "placeholder":"http://Bot.url" });
|
divForm.appendChild(
|
||||||
divForm.appendChild(inputUrl);
|
createLineSelect('Starting cell:',
|
||||||
|
[ {'value':'random','text' : 'random'},
|
||||||
|
{'value':'defined','text' : 'Let me define it'}
|
||||||
|
],
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
//Starting cell
|
|
||||||
var selectRandomStartCell = createElem("select",{
|
|
||||||
"id": "randomOrNot" + index,
|
"id": "randomOrNot" + index,
|
||||||
"onchange":"changeRandom('" + index + "', this.value);"
|
"onchange":"changeRandom('" + index + "', this.value);"
|
||||||
});
|
}
|
||||||
|
)
|
||||||
var optionRandom = createElem("option",{"value":"random","selected":"selected"});
|
);
|
||||||
optionRandom.innerHTML = "random";
|
divForm.appendChild(
|
||||||
|
createElemWithLabel(
|
||||||
var optionDefined = createElem("option",{"value":"defined"});
|
'input',
|
||||||
optionDefined.innerHTML = "Let me define it";
|
{"type":"text","value": "0","id":"posX" + index},
|
||||||
selectRandomStartCell.appendChild(optionRandom);
|
'X coord:'
|
||||||
selectRandomStartCell.appendChild(optionDefined);
|
)
|
||||||
|
);
|
||||||
divForm.appendChild(selectRandomStartCell);
|
divForm.appendChild(
|
||||||
|
createElemWithLabel(
|
||||||
var inputX = createElem("input",{"type":"text","value": "0","id":"posX" + index,"class":"hidden"});
|
'input',
|
||||||
var inputY = createElem("input",{"type":"text","value": "0","id":"posY" + index,"class":"hidden"});
|
{"type":"text","value": "0","id":"posY" + index},
|
||||||
|
'Y coord:'
|
||||||
divForm.appendChild(inputX);
|
)
|
||||||
divForm.appendChild(inputY);
|
);
|
||||||
|
|
||||||
container.appendChild(divForm);
|
container.appendChild(divForm);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user