I have a string returned from a function and number works well, because it is possible to cast a number with Number();
But for a boolean, this seems not to work?
Is it really necessary to parse the string “true” and “false” like this?
[FONT=Monaco][COLOR=#931a68]function[/COLOR] setSettings(result)[/FONT]
[FONT=Monaco]{[/FONT]
[FONT=Monaco] [COLOR=#931a68]var[/COLOR] res = result.split([COLOR=#3933ff]','[/COLOR]);[/FONT]
[COLOR=#4E9072][FONT=Monaco]//alert(res);[/FONT][/COLOR]
[FONT=Monaco] document.querySelector([COLOR=#3933ff]"#tilewidth"[/COLOR]).value = Number(res[0]);[/FONT]
[FONT=Monaco] document.querySelector([COLOR=#3933ff]"#tileheight"[/COLOR]).value= Number(res[1]);[/FONT]
[FONT=Monaco] document.querySelector([COLOR=#3933ff]"#fileprefix"[/COLOR]).value= res[2];[/FONT]
[FONT=Monaco] document.querySelector([COLOR=#3933ff]"#addlayer"[/COLOR]).checked= fBoolean(res[3]);[COLOR=#4e9072]//[/COLOR][/FONT]
[FONT=Monaco] document.querySelector([COLOR=#3933ff]"#foldername"[/COLOR]).value= res[4];[/FONT]
[FONT=Monaco] document.querySelector([COLOR=#3933ff]"#isretina"[/COLOR]).checked= fBoolean(res[5]);[COLOR=#4e9072]//[/COLOR][/FONT]
[FONT=Monaco] document.querySelector([COLOR=#3933ff]"#notlocalfolder"[/COLOR]).checked= fBoolean(res[6]);[COLOR=#4e9072]//[/COLOR][/FONT]
[FONT=Monaco]}[/FONT]
[FONT=Monaco]
[/FONT]
[FONT=Monaco][COLOR=#931a68]function[/COLOR] fBoolean(str)[/FONT]
[FONT=Monaco]{[/FONT]
[FONT=Monaco] [COLOR=#931a68]if[/COLOR](str==[COLOR=#3933ff]"true"[/COLOR])[/FONT]
[FONT=Monaco] {
[/FONT][COLOR=#931A68][FONT=Monaco] return true[COLOR=#000000];[/COLOR][/FONT][/COLOR]
[FONT=Monaco] }[/FONT]
[FONT=Monaco] [COLOR=#931a68]else[/COLOR] [COLOR=#931a68]if[/COLOR](str == [COLOR=#3933ff]"false"[/COLOR])[/FONT]
[FONT=Monaco] {
[/FONT][COLOR=#931A68][FONT=Monaco] return false[COLOR=#000000];[/COLOR][/FONT][/COLOR]
[FONT=Monaco] }[/FONT]
[FONT=Monaco]}[/FONT]