|
|
@ -5,7 +5,7 @@ $( function() {
|
|
|
|
$(".user-result-container").position({
|
|
|
|
$(".user-result-container").position({
|
|
|
|
my: "left top",
|
|
|
|
my: "left top",
|
|
|
|
at: "left bottom",
|
|
|
|
at: "left bottom",
|
|
|
|
of: $('#search-user'), // or $("#otherdiv")
|
|
|
|
of: $('#search-user'),
|
|
|
|
collision: "fit"
|
|
|
|
collision: "fit"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('.user-result-container').hide();
|
|
|
|
$('.user-result-container').hide();
|
|
|
@ -34,20 +34,23 @@ function plan_meal() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function add_user() {
|
|
|
|
function add_user() {
|
|
|
|
|
|
|
|
if (eaters.includes($('#search-user').val()))
|
|
|
|
|
|
|
|
return;
|
|
|
|
$.ajax({
|
|
|
|
$.ajax({
|
|
|
|
url: "/searchusers?q=" + $('#search-user').val()
|
|
|
|
url: "/searchusers?q=" + $('#search-user').val() + "&s=0"
|
|
|
|
}).done(function(results) {
|
|
|
|
}).done(function(results) {
|
|
|
|
if (results == '[]') {
|
|
|
|
if (results == '[]') {
|
|
|
|
alert('Invalid username');
|
|
|
|
alert('Invalid username');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
names = results.substring(1, results.length-1).split(', ');
|
|
|
|
var meal_date = $('#datepicker').datepicker('getDate');
|
|
|
|
if (names.length > 1) {
|
|
|
|
if (meal_date == null || $('#spinner-hour').val() == '' || $('#spinner-minute').val() == '') {
|
|
|
|
alert('Please choose one.');
|
|
|
|
alert('Please select a date and a time.');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eaters.push(names[0].substring(1, names[0].length));
|
|
|
|
names = results.substring(1, results.length - 1).split(', ');
|
|
|
|
var meal_date = $('#datepicker').datepicker('getDate');
|
|
|
|
new_eater = names[0].substring(1, names[0].length - 1);
|
|
|
|
|
|
|
|
eaters.push(new_eater);
|
|
|
|
var month = (meal_date.getMonth() + 1).toString();
|
|
|
|
var month = (meal_date.getMonth() + 1).toString();
|
|
|
|
if (month.length == 1)
|
|
|
|
if (month.length == 1)
|
|
|
|
month = '0' + month;
|
|
|
|
month = '0' + month;
|
|
|
@ -69,7 +72,26 @@ function add_user() {
|
|
|
|
$('#est-cook').attr('src', 'static/' + estkuk + '.png')
|
|
|
|
$('#est-cook').attr('src', 'static/' + estkuk + '.png')
|
|
|
|
$('#est-cook').attr('title', estkuk)
|
|
|
|
$('#est-cook').attr('title', estkuk)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
e = '<div class="add-people-container" id="for-user-' + new_eater + '">\
|
|
|
|
|
|
|
|
<div class="flex-card" style="margin: 0">\
|
|
|
|
|
|
|
|
<img src="static/' + new_eater + '.png">\
|
|
|
|
|
|
|
|
<span class="username">' + new_eater + '</span>\
|
|
|
|
|
|
|
|
</div>\
|
|
|
|
|
|
|
|
<div class="small-round-button" onclick="remove_user(\'' + new_eater + '\')"><i class="fa fa-minus" aria-hidden="true"></i></div>\
|
|
|
|
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
$('#add-user').before(e);
|
|
|
|
|
|
|
|
$('.small-round-button').show();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function remove_user(name) {
|
|
|
|
|
|
|
|
eaters = eaters.filter(function(value, index, arr){
|
|
|
|
|
|
|
|
return value != name;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#for-user-' + name).remove();
|
|
|
|
|
|
|
|
if ($('#eaters-list > div').length == 2) {
|
|
|
|
|
|
|
|
$('.small-round-button').hide();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fill_box(name) {
|
|
|
|
function fill_box(name) {
|
|
|
@ -82,7 +104,7 @@ function user_search() {
|
|
|
|
if ($('#search-user').val() == '')
|
|
|
|
if ($('#search-user').val() == '')
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
$.ajax({
|
|
|
|
$.ajax({
|
|
|
|
url: "/searchusers?q=" + $('#search-user').val()
|
|
|
|
url: "/searchusers?q=" + $('#search-user').val() + "&s=1"
|
|
|
|
}).done(function(results) {
|
|
|
|
}).done(function(results) {
|
|
|
|
// Load results
|
|
|
|
// Load results
|
|
|
|
if (results == '[]')
|
|
|
|
if (results == '[]')
|
|
|
@ -97,6 +119,12 @@ function user_search() {
|
|
|
|
</div>'
|
|
|
|
</div>'
|
|
|
|
$('.user-result-container').append($(e));
|
|
|
|
$('.user-result-container').append($(e));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// $(".user-result-container").position({
|
|
|
|
|
|
|
|
// my: "left top",
|
|
|
|
|
|
|
|
// at: "left bottom",
|
|
|
|
|
|
|
|
// of: $('#search-user'),
|
|
|
|
|
|
|
|
// collision: "fit"
|
|
|
|
|
|
|
|
// });
|
|
|
|
$('.user-result-container').show();
|
|
|
|
$('.user-result-container').show();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|