fix README.md

This commit is contained in:
Gnieark 2017-02-08 18:41:26 +01:00
parent 21c7253b76
commit 78d565f11b
2 changed files with 71 additions and 3 deletions

View File

@ -42,6 +42,17 @@ function createElem(type,attributes){
{elem.setAttribute(i,attributes[i]);} {elem.setAttribute(i,attributes[i]);}
return elem; return elem;
} }
function makeid(){
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < 5; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
function changeRandom(index,newValue){ function changeRandom(index,newValue){
if (newValue == "random" ){ if (newValue == "random" ){
document.getElementById("posX" + index).className = "hidden"; document.getElementById("posX" + index).className = "hidden";
@ -52,11 +63,68 @@ function changeRandom(index,newValue){
} }
} }
function changeTypePlayer(index,newValue){ function changeTypePlayer(index,newValue){
if (newValue == "Human") document.getElementById("botUrl" + index).className = "hidden"; if (newValue == "Human") document.getElementById("botUrl" + index).className = "hidden";
else document.getElementById("botUrl" + index).className = ""; else document.getElementById("botUrl" + index).className = "";
} }
function createElemWithLabel(type,attributes,labelTxt, id =''){
/*
* return an em element containing label and data like this:
* <em id='kjhjk'>
* <label for="plop"> the text of blah blah </label>
* <input type='someType' value='kjhjlkh' id='plop'/>
* </em>
*/
if( id == ''){
var em = createElem ('em',{});
}else{
var em = createElem ('em',{'id':id});
}
if (typeof attributes['id'] !== 'undefined') {
var forId = attributes['id'];
}else{
var forId = makeid();
}
var label = createElem('label',{'for' : forId});
em.appendChild(label);
var elem = createElem(type,attributes);
if (typeof attributes['id'] !== 'undefined') {
em.setAttribute('id',forId);
}
em.appendChild(elem);
return em;
}
function createLineSelect(labelTxt,arrayOptions,attributes){
//attributes are the select 's attributes, not his container
var em = createElem('em',{});
if (typeof attributes['id'] !== 'undefined') {
var forId = attributes['id'];
}else{
var forId = makeid();
}
var label = createElem('label',{'for':forId});
label.innerHTML = labelTxt;
em.appendChild(label);
var select = createElem('select',attributes);
if (typeof attributes['id'] !== 'undefined') {
select.setAttribute('id',forId);
}
for(var i=0; i < arrayOptions.length; i++){
var option = createElem('option',{'value':arrayOptions[i]['value']});
}
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" } );