Add logic to enable and disable

This commit is contained in:
Julien Lengrand-Lambert
2018-02-22 21:19:11 +01:00
parent 38cdb10425
commit abfbac7bbd
3 changed files with 96 additions and 11 deletions

43
original-schema.json Normal file
View File

@@ -0,0 +1,43 @@
[
{
"family": "doe",
"emails": [
{
"email": "jane@doe.com"
},
{
"email": "john@doe.com"
}],
"responded": false,
"members": [
{
"name": "john doe"
},
{
"name": "jane doe"
},
{
"name": "baby doe"
}
],
"american": false,
"songs":
[
]
},
{
"family": "trump",
"emails": [
{
"email": "donald@duck.gov"
}
],
"responded": false,
"members": [
{
"name": "donald trump"
}
],
"american": true
}
]

View File

@@ -3,12 +3,10 @@
"family": "doe",
"emails": [
{
"email": "jane@doe.com",
"code": "C3PO"
"email": "jane@doe.com"
},
{
"email": "john@doe.com",
"code": "R2D2"
"email": "john@doe.com"
}],
"responded": true,
"members": [

View File

@@ -53,6 +53,7 @@
}
closeModal("myNav");
disableAll();
openModal("myList");
}
@@ -76,11 +77,49 @@
disableAccomodations();
}
function disableAccomodations() {
document.getElementById("iWantHotel").disabled = true;
document.getElementById("iWantCamping").disabled = true;
function disableAccomodations(){
changeAccomodations(true);
}
function enableAccomodations(){
changeAccomodations(false);
}
function changeAccomodations(trueOrFalse) {
document.getElementById("iWantHotel").disabled = trueOrFalse;
document.getElementById("iWantCamping").disabled = trueOrFalse;
}
function disableSongs(){
changeSongs(true);
}
function enableSongs(){
changeSongs(false);
}
function changeSongs(trueOrFalse){
var songInputs = document.getElementsByClassName("song");
for(var i = 0; i < songInputs.length; i++){
songInputs[i].disabled = trueOrFalse;
}
}
function disableAll(){
disableAccomodations();
disableSongs();
}
function enableAll(){
enableAccomodations();
enableSongs();
}
function finish(){
closeModal("myList");
}
function checkAttendees() {
var listModal = document.getElementById("attendeesList");
var checkBoxes = listModal.getElementsByTagName("input");
@@ -103,6 +142,9 @@
if (!hasYeses) {
openModal("sorryMessage");
}
else{
enableAll();
}
}
else {
console.log("More to go!");
@@ -208,14 +250,16 @@
<input type="button" id="iWantHotel" onClick="iWantHotel()" value="Submit">
<h3>Oh, hey what about the songs?</h3>
<!-- This should be generated-->
<input class="input-box" id="song1" type="text" value="" placeholder="song">
<input class="input-box" id="artist1" type="text" value="" placeholder="artist">
<input class="input-box song" id="song1" type="text" value="" placeholder="song">
<input class="input-box song" id="artist1" type="text" value="" placeholder="artist">
<br>
<input class="input-box" id="song2" type="text" value="" placeholder="song">
<input class="input-box" id="artist2" type="text" value="" placeholder="artist">
<input class="input-box song" id="song2" type="text" value="" placeholder="song">
<input class="input-box song" id="artist2" type="text" value="" placeholder="artist">
</div>
<input type="button" id="finished" onClick="finish()" value="Close">
</div>
</div>