Skip to content

Commit

Permalink
changed order of modal
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethgoodman committed May 8, 2016
1 parent 92717cb commit 45c636a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 62 deletions.
2 changes: 1 addition & 1 deletion public/javascript/dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ rowsLookedAt = {}
var blank = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
'<tr>'+
'<td> Status: </td>'+
'<td>'+'waiting'+'</td>'+
'<td>'+'waiting...this may take a minute'+'</td>'+
'</tr>'+
'<tr>'+
'<tr>'+
Expand Down
57 changes: 25 additions & 32 deletions public/javascript/jqueryBinding.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
function replaceAll(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
}
function ValidateEmail(inputText)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
Expand All @@ -15,14 +18,14 @@ function makeTableHTML(myArray,queryArray) {
delete queryArray[parseInt(e.id)]
//removeFromArray(queryArray,parseInt(e.id)) //remove it from array and from UI
$(e).closest('tr').remove()

var count = 0
for(var i in queryArray){
if(queryArray[i] != null || queryArray != undefined)
count++
}
if(count == 1){
$("#next").prop("disabled",true)
if(count <= 5){
$("#confirm").prop("disabled",true)
$("#confirmInfo").append("<br>You must select a class before continuing")
}
}
removeFromArray = function(array,from, to) {
Expand All @@ -49,19 +52,10 @@ $(document).ready(function(){
$(this).closest('tr').remove()
})
$("#submitData").unbind('click').click( function (e) {
$("#confirm").prop("disabled",false);//just in case the button is disabled
clicked(function(queryArray,infoArray){
$("#confirmDialog").modal("show")
var whatWillHappen= "you have chosen to be alerted as soon as these classes open: <br><br>"
whatWillHappen += makeTableHTML(infoArray,queryArray)//.slice(0, -1))
$("#confirmInfo").html( whatWillHappen )
if(queryArray.length == 1){
$("#next").prop("disabled",true)
}
$("#next").unbind('click').click(function (){
$("#confirmDialog").modal("toggle")
$("#infoDialog").modal("show")
})
$("#confirm").unbind('click').click(function(){
$("#infoDialog").modal("show")
$("#next").unbind('click').click(function(){
for(var e in queryArray){
if(queryArray[e] == null || queryArray[e] == undefined)
removeFromArray(queryArray,parseInt(e))
Expand All @@ -70,34 +64,34 @@ $(document).ready(function(){
var carrier = $('#carrier').val();
var phoneNbr = $('#you_phone_nbr').val();
phoneNbr = parsePhoneNumber(phoneNbr);
/*var email = $('#emailInput').val();
if(phoneNbr.length > 0){
if(email.length > 0){
contactHow = "both"
}
else{
contactHow = "text"
}
}
else{
contactHow = "email"
}*/
queryArray.push(phoneNbr)
queryArray.push(carrier)
queryArray.push("NA")
queryArray.push(contactHow)
//console.log(queryArray)
var whatWillHappen= "you have chosen to be alerted as soon as these classes open: <br><br>"
whatWillHappen += makeTableHTML(infoArray,queryArray)//.slice(0, -1))
$("#confirmInfo").html( whatWillHappen )
if(queryArray.length <= 5){
$("#confirm").prop("disabled",true)
$("#confirmInfo").append("<br>You must select a class before continuing")
}
$("#infoDialog").modal("toggle")
if(queryArray.length > 4) ws.send(JSON.stringify(queryArray)) //there are four default information parameters
$("#confirmDialog").modal("show")

})
$("#confirm").unbind('click').click(function (){
$("#confirmDialog").modal("toggle")
queryArray = replaceAll(JSON.stringify(queryArray), "null,", "") //remove all the deleted items
if(queryArray.length > 5) ws.send(queryArray) //there are five default information parameters
})
});
});
$("#next")
$('#inst').unbind('change').change(function(){
$("#ajax-loader").show();
var e = document.getElementById("inst");
values = JSON.parse(e.options[e.selectedIndex].value)
console.log(values)
//console.log(values)
ws.send(JSON.stringify(["get_classes",values["schoolCode"], values["sessionCode"]]));
//send message for get session
})
Expand Down Expand Up @@ -184,7 +178,6 @@ validEmailAndPhoneNbr = function(phoneNbr,email){
return [phoneNbr,email]
}
clicked = function(callback){
$("#next").prop("disabled",false)
var inst, session;
try{
var e = document.getElementById("inst");
Expand Down Expand Up @@ -234,6 +227,6 @@ clicked = function(callback){
//infoArray.push([phoneNbr, email])
//if(count > 0) ws.send(JSON.stringify(queryArray)); //now implemented later
//if( count < 1 ){alert("Please select a class"); return;}
console.log(queryArray)
//console.log(queryArray)
callback(queryArray,infoArray)
}
2 changes: 1 addition & 1 deletion public/javascript/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ ws.onmessage = function (event) {
var table = $('#dataTables').dataTable().api();
var row = table.row( data[2] )
hiddenRowData[data[2]] = ["Loading...",data[1]]
row.child( format(["Loading...",data[1]]) );
row.child( format(["Loading...this may take a minute",data[1]]) );
$("#ajax-loader").hide();
}
else if(commandFromServer == "statusInfo"){
Expand Down
19 changes: 2 additions & 17 deletions views/pages/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-default" id="next">Next</button>
<button type="button" class="btn btn-success" id="confirm">Confirm</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -119,26 +119,11 @@
</option>
</select>
<img src="/images/ajax-loader.gif" id="ajax-loader" style="display:none">
<!--
<p> and/or </p>
<->
<p><br>info = {{infoValid()}} <br> num valid = {{numberIsValid()}} <br> carAndNum = {{carrierAndNumAreValid()}} <br>
email = {{emailIsValid()}} <br> emailNotEmpty = {{emailNotEmpty()}}<p>
<- --->
<!--
<br>
<input type="email" id="emailInput" name="email" ng-model="email" placeholder="youremail@domain.com">
<div ng-messages="exampleForm.userEmail.$error">
<div ng-message="email">Your email address is invalid</div>
</div>
<span ng-show="!emailIsValid()">Please enter a valid email</span>
<br>-->
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" id="confirm" ng-disabled="!carrierAndNumAreValid()">Confirm</button>
<button type="button" class="btn btn-default" id="next" ng-disabled="!carrierAndNumAreValid()">Next!</button>
</div>
</div>
</div>
Expand Down
21 changes: 10 additions & 11 deletions websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,16 @@ module.exports = function(wss){
temp.push(result[row])
}
sendData(ws,["classesBeingTaken",temp]);
if(data.length == 6){
sendData(ws,["sendNotification", "Your have succesfully added " + data[1][1] +" - "+ data[1][2] +": "+ data[1][3]])
}
else{
var temp = ""
for(var i = 1; i < data.length-2; i++){
temp += data[1][1] +" - "+ data[1][2] +": "+ data[1][3]+ ",\n";
}
temp[temp.length-1] = "";
sendData(ws,["sendNotification", "Your have succesfully added "+temp])
}
if(data.length == 6){
sendData(ws,["sendNotification", "Your have succesfully added " + data[1][1] +" - "+ data[1][2] +": "+ data[1][3]])
}
else{
var temp = ""
for(var i = 1; i < data.length-4; i++){
temp += data[i][1] + " - "+ data[i][2] + ": "+ data[i][3]+ ",\n";
}
sendData(ws,["sendNotification", "Your have succesfully added " + temp])
}

});
//sendData(ws, ["Success", "Your classes have succesfully been entered"])
Expand Down

0 comments on commit 45c636a

Please sign in to comment.