$(document).ready(function() { // $("#testimonial").css("background","gray";); $("#testimonial").css("background", "#EFEFEF"); // console.log($("#testimonial")); // console.log($("#testimonial").css()); bindings(); }); function bindings(){ $("#login_form").bind("submit", post_login); $("#register_form").bind("submit", post_register); $("#login").bind("click", display_login); $("#register").bind("click",display_register); $("#my_profil").bind("click",my_profil); $(".plus_like").bind("click", add_user_liked); $(".minus_like").bind("click", remove_user_liked); $(".plus_cook").bind("click", add_user_cooked); $(".minus_cook").bind("click", remove_user_cooked); $(".fa-times").bind("click", delete_plate); } function add_love(id){ console.log("begin"); var dict = {username : id }; console.log(dict); var data = JSON.stringify(dict); console.log(data); $.ajax({ url: "/user/loved", type: "PUT", contentType:"application/json", data: data, success: function(json){ window.location.reload(); } }) } function post_login(){ $("#login_form").submit(function(e){ e.preventDefault(); var dict={ username: $('input[id="username"]').val(), password: $('input[id="password"]').val() }; var datas=JSON.stringify(dict); console.log("test"); // test form $.ajax({ url: "/user", type: "POST", contentType:"application/json", data: datas, success: function(json){ window.location.reload(); // display_home() ; } }); bindings(); return false; }); } function display_login(){ $("#main_container").empty(); var html = ""; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="

Sign in

"; html +="

Take your seats! There's enough cake for everybody!

"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +=" "; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; $("#main_container").append(html); post_login(); } function post_register(){ $("#register_form").submit(function(e){ e.preventDefault(); var dict={ username: $('input[id="username"]').val(), password: $('input[id="password"]').val(), firstName: $('input[id="firstName"]').val(), lastName: $('input[id="lastName"]').val(), email: $('input[id="email"]').val(), picture: $('input[id="picture"]').val(), desc: $('textarea[id="desc"]').val(), town: $('input[id="town"]').val() }; var datas=JSON.stringify(dict); console.log("test"); $.ajax({ url: "/user", type: "PUT", contentType:"application/json", data: datas, success: function(json){ window.location.reload(); display_home(); } }); bindings(); return false; }); } function display_register(){ $("#main_container").empty(); var html = ""; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="

Sign up

"; html +="

Fresh meat is near...

"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +=" "; html +="
"; html +="
"; html +="
"; html +=""; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; $("#main_container").prepend(html); post_register(); } function display_all_plates(category){ $("#main_container").empty(); if ( category == 'all') { var source="/allplates"; var choice = ""; } else { var source="/plates_by_class/"+category; var choice = {"choice" : category}; } $.ajax({ url : source, type : "GET", datatype: "json", data :choice, success: function(data){ var category=data.plates; var html = ""; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+='

Your plates

'; html+='

Here you can add, or delete plates you like.

'; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+=' '; html+='
'; html+=' All'; html+=' Entrée'; html+=' Plat'; html+=' Dessert'; html+=' Apéro'; html+='
'; html+='
'; html+='
'; html+=' '; html+='
'; html+='
'; html+= ""; $("#main_container").append(html); } }); } function search_plate(){ var search=document.getElementById("inputSearch").value; console.log(search); $("#main_container").empty(); $.ajax({ url : "/addplates/search/"+search, type : "GET", contentType: "application/json", success: function(data){ var category = data.results; html = ""; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+='

Your plates

'; html+='

Here you can add, or delete plates you like.

'; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+=' '; html+='
'; html+=' All'; html+=' Entrée'; html+=' Plat'; html+=' Dessert'; html+=' Apéro'; html+='
'; html+='
'; html+='
'; html+=' '; html+='
'; html+='
'; html+= ""; $("#main_container").append(html); bindings(); //include('jquery.easing.1.3.js'); } }); } function display_all_cook(category){ if ( category == 'all') { var source="/allplates"; var choice = ""; } else { var source="/plates_by_class/"+category; var choice = {"choice" : category}; } $.ajax({ url : source, type : "GET", contentType: "application/json", data : choice, success: function(data){ $("#main_container").empty(); var category = data.plates; console.log(data); console.log(category.length); var html = ""; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+='

Your cook

'; html+='

Here you can add, or delete plates you like.

'; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+=' '; html+='
'; html+=' All'; html+=' Entrée'; html+=' Plat'; html+=' Dessert'; html+=' Apéro'; html+='
'; html+='
'; html+='
'; html+=' '; html+='
'; html+='
'; html+= ""; $("#main_container").append(html); bindings(); //include('jquery.easing.1.3.js'); } }); } function search_cook(){ var search=document.getElementById("inputSearch").value; console.log(search); $("#main_container").empty(); $.ajax({ url : "/addcook/search/"+search, type : "GET", contentType: "application/json", success: function(data){ var category = data.results; html = ""; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+='

Your cooks

'; html+='

Here you can add, or delete plates you like.

'; html+='
'; html+='
'; html+='
'; html+='
'; html+='
'; html+=' '; html+='
'; html+=' All'; html+=' Entrée'; html+=' Plat'; html+=' Dessert'; html+=' Apéro'; html+='
'; html+='
'; html+='
'; html+=' '; html+='
'; html+='
'; html+= ""; $("#main_container").append(html); bindings(); //include('jquery.easing.1.3.js'); } }); } function add_user_liked(id){ var dict={ "id":id }; var datas = JSON.stringify(dict); bindings(); $.ajax({ url:"http://localhost:5000/user/liked/add", type : "PUT", contentType : "application/json", data: datas, success : function(json){ alert("food added"); } }); } function remove_user_liked(id){ var dict={ "id":id }; var datas = JSON.stringify(dict); bindings(); $.ajax({ url:"http://localhost:5000/user/liked/remove", type : "PUT", contentType : "application/json", data: datas, success : function(json){ alert("food removed"); } }); } function add_user_cooked(id){ var dict={ "id":id }; var datas = JSON.stringify(dict); bindings(); $.ajax({ url:"http://localhost:5000/user/cooked/add", type : "PUT", contentType : "application/json", data: datas, success : function(json){ alert("food added"); } }); } function remove_user_cooked(id){ var dict={ "id":id }; var datas = JSON.stringify(dict); bindings(); $.ajax({ url:"http://localhost:5000/user/cooked/remove", type : "PUT", contentType : "application/json", data: datas, success : function(json){ alert("food removed"); } }); } function my_profil(){ $("#main_container").empty(); $.ajax({ url : "http://localhost:5000/user/profil", type : "GET", datatype: "json", success: function(data){ var html = ""; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="

My profil

"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html +="
"; html +="
"; html +="
"; html +=""; html +="
"; html +="
"; html +=" "; html +=" "; html +="
"; html+=" "; html +="
"; html +="
"; html +=" "; html +="
"; html +="
"; html +="
"; html +="
"; $("#main_container").append(html); } }); } function display_home(){ $.ajax({ url : "http://localhost:5000/home_user", type : "GET", datatype: "json", success: function(data){ $("#main_container").empty(); var html=""; html+="{% if not current_user.is_authenticated %}"; html+=" "; html+="
"; html+=" "; html+="
"; html+=" "; html+=" "; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="

WebSite utilisation

"; html+="

EatMe is dating site between persons who love cuisine, they practice it like nationnal sport, or not at all. Here you could invite members to cook what they like to eat. Or at the contrary it's will be they who invite you !

"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
Like
"; html+="

You must grade in your like, all the plates you like to eat. It's could be the not ordinary pepperony pizza, or more sophisticated tiramisu!

"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
Cook
"; html+="

Si vous êtes du genre cordon bleu hipster, sur notre site vous pourrez y inscrire ce que vous savez, un peu, beaucoup, pationnement cuisinner.

"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
Match
"; html+="

Grâce à notre technologie de pointe, EatMe vous permet de mettre en relation les plats que vous savez cuisnier avec les gouts cullinaires de nos membres.

"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
Love
"; html+="

Enfin grâce à un système de choix perfectionné vous pourrez choisir les profils de nos membres qui vous interesse et entrez facilement en contact avec eux!

"; html+="
"; html+="
"; html+=" "; html+="
"; html+="
"; html+="
"; html+="
"; html+="{% else %}"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" {% if propositions=={} %}"; html+="

No match found :(

"; html+="

We're sorry for you

"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
"; html+="
"; html+="
"; html+=" "; html+=" "; html+=" "; html+=" {% endif %}"; html+=" "; html+="
"; html+=" "; html+="
"; html+=" "; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="

Eating Program

"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
"; html+="
"; html+="
"; html+="

Here you cand find the eaters that you loved, and loved you back : contact them !

"; html+="
"; html+="
    "; html+=" {% for user in current_user.matched %}"; html+="
  • "; html+=" {{user.username}} : {{user.email}}"; html+="
  • "; html+=" {% endfor %}"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
"; html+="
"; html+="
"; html+="

Plates that you like

"; html+=" {% if current_user.liked==None %}"; html+="

Don't you like any of our plates ?

"; html+=" See our selection"; html+=" {% else %}"; html+="

{% for plate in current_user.liked %}{{plate.name}}
{% endfor %}

"; html+=" Add other plates"; html+=" {% endif %}"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
"; html+="
"; html+="
"; html+=" {% if current_user.cooked==[] %}"; html+="

Apparently nothing?

"; html+="

We are sure you know how to cook something...

"; html+=" {% else %}"; html+="

List of all the plate you can propose to your matches !

"; html+="

{% for plate in current_user.cooked %}{{plate.name}}
{% endfor %}

"; html+=" {% endif %}"; html+=" Increase your cooked list "; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="{% endif %}"; $("#main_container").append(html); bindings(); } }); } function get_profil(id){ console.log(id); var dict={ "username": id }; var datas=JSON.stringify(dict); $.ajax({ url : "http://localhost:5000/user/profil", type : "POST", contentType:"application/json", data: datas, success: function(data){ display_profil(data); } }); } function display_profil(json){ var html =""; $("#main_container").empty(); html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+=" "; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
"; html+="
"; html+="
    "; $.each(json.user.liked, function(i, obj) { html+="
  • "+obj+"
  • "; }); html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
"; html+="
"; html+="
    "; $.each(json.user.cooked, function(i, obj) { html+="
  • "+obj+"
  • "; }); html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
"; html+="
"; html+=" "+json.user.desc+""; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+=" "; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; html+="
"; $("#main_container").append(html); } function delete_plate(id){ var dict={ "id":id }; var datas = JSON.stringify(dict); $.ajax({ url:"http://localhost:5000/allplates", type : 'DELETE', contentType : "application/json", data: datas, success : function(json){ alert("Food has been removed form Database"); } }); }