Advertisement
Guest User

love

a guest
Jun 6th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 60.39 KB | None | 0 0
  1. $(document).ready(function() {
  2. // $("#testimonial").css("background","gray";);
  3. $("#testimonial").css("background", "#EFEFEF");
  4. // console.log($("#testimonial"));
  5. // console.log($("#testimonial").css());
  6. bindings();
  7. });
  8.  
  9. function bindings(){
  10. $("#login_form").bind("submit", post_login);
  11. $("#register_form").bind("submit", post_register);
  12. $("#login").bind("click", display_login);
  13. $("#register").bind("click",display_register);
  14. $("#my_profil").bind("click",my_profil);
  15. $(".plus_like").bind("click", add_user_liked);
  16. $(".minus_like").bind("click", remove_user_liked);
  17. $(".plus_cook").bind("click", add_user_cooked);
  18. $(".minus_cook").bind("click", remove_user_cooked);
  19. $(".fa-times").bind("click", delete_plate);
  20. }
  21.  
  22. function add_love(id){
  23. console.log("begin");
  24. var dict = {username : id };
  25. console.log(dict);
  26. var data = JSON.stringify(dict);
  27. console.log(data);
  28. $.ajax({
  29. url: "/user/loved",
  30. type: "PUT",
  31. contentType:"application/json",
  32. data: data,
  33. success: function(json){
  34. window.location.reload();
  35. }
  36. })
  37. }
  38.  
  39. function post_login(){
  40. $("#login_form").submit(function(e){
  41. e.preventDefault();
  42. var dict={
  43. username: $('input[id="username"]').val(),
  44. password: $('input[id="password"]').val()
  45. };
  46. var datas=JSON.stringify(dict);
  47. console.log("test");
  48. // test form
  49. $.ajax({
  50. url: "/user",
  51. type: "POST",
  52. contentType:"application/json",
  53. data: datas,
  54. success: function(json){
  55. window.location.reload();
  56. // display_home() ;
  57. }
  58. });
  59. bindings();
  60. return false;
  61. });
  62. }
  63.  
  64. function display_login(){
  65. $("#main_container").empty();
  66. var html = "";
  67. html +="<section id=\"contact\">";
  68. html +=" <div class=\"container\">";
  69. html +=" <div class=\"row\">";
  70. html +=" <div class=\"col-md-12 col-sm-12 col-xs-12\">";
  71. html +=" <div class=\"feature_header text-center\">";
  72. html +=" <h3 class=\"feature_title\">Sign <b>in</b></h3>";
  73. html +=" <h4 class=\"feature_sub\">Take your seats! There's enough cake for everybody! </h4>";
  74. html +=" <div class=\"divider\"></div>";
  75. html +=" </div>";
  76. html +=" </div>";
  77. html +=" </div>";
  78. html +=" <div class=\"row\">";
  79. html +=" <div class=\"row\">";
  80. html +=" <div class=\"contact_full\">";
  81. html +=" <div class=\"col-md-12 text-center\">";
  82. html +=" <div class=\"center_contact\">";
  83. html +=" <form id=\"login_form\" methods='POST'>";
  84. html +=" <div class=\"form-level\">";
  85. html +=" <input name=\"username\" placeholder=\"Username\" id=\"username\" class=\"input-block\" value=\"\" type=\"username\">";
  86. html +=" <span class=\"form-icon fa fa-user \"></span>";
  87. html +=" </div>";
  88. html +=" <div class=\"form-level\">";
  89. html +=" <input name=\"password\" placeholder=\"Password\" id=\"password\" class=\"input-block\" value=\"\" type=\"password\">";
  90. html +=" <span class=\"form-icon fa fa-key \"></span>";
  91. html +=" </div>";
  92. html +=" <input id=\"login_submit\"type=\"submit\" value=\"Do Eat\" class=\"btn btn-main featured\">";
  93. html +=" </form>";
  94. html +=" </div>";
  95. html +=" </div>";
  96. html +=" </div>";
  97. html +=" </div>";
  98. html +="</section>";
  99. $("#main_container").append(html);
  100. post_login();
  101. }
  102.  
  103.  
  104.  
  105. function post_register(){
  106. $("#register_form").submit(function(e){
  107. e.preventDefault();
  108. var dict={
  109. username: $('input[id="username"]').val(),
  110. password: $('input[id="password"]').val(),
  111. firstName: $('input[id="firstName"]').val(),
  112. lastName: $('input[id="lastName"]').val(),
  113. email: $('input[id="email"]').val(),
  114. picture: $('input[id="picture"]').val(),
  115. desc: $('textarea[id="desc"]').val(),
  116. town: $('input[id="town"]').val()
  117. };
  118. var datas=JSON.stringify(dict);
  119. console.log("test");
  120. $.ajax({
  121. url: "/user",
  122. type: "PUT",
  123. contentType:"application/json",
  124. data: datas,
  125. success: function(json){
  126. window.location.reload();
  127. display_home();
  128. }
  129. });
  130. bindings();
  131. return false;
  132. });
  133. }
  134.  
  135. function display_register(){
  136. $("#main_container").empty();
  137. var html = "";
  138. html +="<section id=\"contact\">";
  139. html +=" <div class=\"container\">";
  140. html +=" <div class=\"row\">";
  141. html +=" <div class=\"col-md-12 col-sm-12 col-xs-12\">";
  142. html +=" <div class=\"feature_header text-center\">";
  143. html +=" <h3 class=\"feature_title\">Sign <b>up</b></h3>";
  144. html +=" <h4 class=\"feature_sub\">Fresh meat is near...</h4>";
  145. html +=" <div class=\"divider\"></div>";
  146. html +=" </div>";
  147. html +=" </div>";
  148. html +=" </div>";
  149. html +=" <div class=\"row\">";
  150. html +=" <div class=\"contact_full\">";
  151. html +=" <div class=\"col-md-6 left\">";
  152. html +=" <div class=\"\">";
  153. html +=" <form id=\"register_form\">";
  154. html +=" <div class=\"form-level\">";
  155. html +=" <input name=\"username\" placeholder=\"Username\" id=\"username\" value=\"\" type=\"text\" class=\"input-block\">";
  156. html +=" <span class=\"form-icon fa fa-user\"></span>";
  157. html +=" </div>";
  158. html +=" <div class=\"form-level\">";
  159. html +=" <input name=\"password\" placeholder=\"Password\" id=\"password\" class=\"input-block\" value=\"\" type=\"password\">";
  160. html +=" <span class=\"form-icon fa fa-key\"></span>";
  161. html +=" </div>";
  162. html +=" <div class=\"form-level\">";
  163. html +=" <input name=\"firstName\" placeholder=\"First Name\" id=\"firstName\" class=\"input-block\" value=\"\" type=\"firstName\">";
  164. html +=" <span class=\"form-icon fa fa-hand-o-left\"></span>";
  165. html +=" </div>";
  166. html +=" <div class=\"form-level\">";
  167. html +=" <input name=\"lastName\" placeholder=\"Last Name\" id=\"lastName\" class=\"input-block\" value=\"\" type=\"lastName\">";
  168. html +=" <span class=\"form-icon fa fa-hand-o-right\"></span>";
  169. html +=" </div>";
  170. html +=" <div class=\"form-level\">";
  171. html +=" <input name=\"email\" placeholder=\"Email\" id=\"email\" class=\"input-block\" value=\"\" type=\"email\">";
  172. html +=" <span class=\"form-icon fa fa-envelope\"></span>";
  173. html +=" </div>";
  174. html +=" <div class=\"form-level\">";
  175. html +=" <input name=\"picture\" placeholder=\"Picture\" id=\"picture\" class=\"input-block\" value=\"\" type=\"picture\">";
  176. html +=" <span class=\"form-icon fa fa-picture-o \"></span>";
  177. html +=" </div>";
  178. html +=" <div class=\"form-level\">";
  179. html +=" <input name=\"town\" placeholder=\"Town\" id=\"town\" class=\"input-block\" value=\"\" type=\"town\">";
  180. html +=" <span class=\"form-icon fa fa-building-o \"></span>";
  181. html +=" </div>";
  182. html +=" <input id=\"register_submit\"type=\"submit\" value=\"Time to Eat\" class=\"btn btn-main featured\">";
  183. html +=" </form>";
  184. html +=" </div>";
  185. html +=" </div>";
  186. html +="";
  187. html +=" <div class=\"col-md-6 right\">";
  188. html +=" <div class=\"form-level\">";
  189. html +=" <textarea name=\"desc\" id=\"desc\" rows=\"10\" class=\"textarea-block\" placeholder=\"Description\"></textarea>";
  190. html +=" <span class=\"form-icon fa fa-pencil\"></span>";
  191. html +=" </div>";
  192. html +=" </div>";
  193. html +=" </div>";
  194. html +=" </div>";
  195. html +="</section>";
  196. $("#main_container").prepend(html);
  197. post_register();
  198. }
  199.  
  200.  
  201.  
  202. function display_all_plates(category){
  203. $("#main_container").empty();
  204. if ( category == 'all') {
  205. var source="/allplates";
  206. var choice = "";
  207. }
  208. else {
  209. var source="/plates_by_class/"+category;
  210. var choice = {"choice" : category};
  211. }
  212. $.ajax({
  213. url : source,
  214. type : "GET",
  215. datatype: "json",
  216. data :choice,
  217. success: function(data){
  218. var category=data.plates;
  219. var html = "";
  220. html+='<section id="portfolio">';
  221. html+=' <div class="container">';
  222. html+=' <div class="row">';
  223. html+=' <div class="col-md-12 col-sm-12 col-xs-12">';
  224. html+=' <div class="feature_header text-center">';
  225. html+=' <h3 class="feature_title">Your <b>plates</b></h3>';
  226. html+=' <h4 class="feature_sub">Here you can add, or delete plates you like. </h4>';
  227. html+=' <div class="divider"></div>';
  228. html+=' </div>';
  229. html+=' </div> <!-- Col-md-12 End -->';
  230. html+=' </div>';
  231. html+=' </div>';
  232. html+=' <div id="Search">';
  233. html+=' <input name=\"Search\" placeholder=\"Search\" id=\"inputSearch\" value=\"\" type=\"text\" class=\"input-block\">';
  234. html+=' <a id="Search" href="#" onClick="search_plate(\'all\');" class="">Search</a>';
  235. html+=' </div>';
  236. html+=' <div id="isotope-filter" class="skew3 text-center">';
  237. html+=' <a id="all" href="#" onClick="display_all_plates(\'all\');" class="active ">All</a>';
  238. html+=' <a id="Entrée" href="#" onClick="display_all_plates(\'Entree\');" class="">Entrée</a>';
  239. html+=' <a id="Plat" href="#" onClick="display_all_plates(\'Plat\');" class="">Plat</a>';
  240. html+=' <a id="Dessert" href="#" onClick="display_all_plates(\'Dessert\');" class="">Dessert</a>';
  241. html+=' <a id="Apéro" href="#" onClick="display_all_plates(\'Apero\');" class="">Apéro</a>';
  242. html+=' </div>';
  243. html+=' <div class="clearfix"></div>';
  244. html+=' <div class="text-center ">';
  245. html+=' <ul class="portfolio-wrap" id="portfolio_items">';
  246. // debut li
  247. for(var i=0; i<category.length; i++){
  248. html+=' <li class="col-xs-12 col-sm-6 col-md-3 single-portfolio identity web-design">';
  249. html+=' <figure>';
  250. html+=' <img src="../static/images/food/'+category[i]["img"]+'" alt="" />';
  251. html+=' <figcaption>';
  252. html+=' <h5>'+category[i]["name"]+'</h5>';
  253. html+=' <div class="links">';
  254. if(category[i]["name"] in data.liked){
  255. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive"> ';
  256. html+=' <i class="fa fa-minus minus_like" onClick="remove_user_liked('+category[i]["id"]+');"></i>';
  257. html+=' </a>';
  258. }
  259. else{
  260. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive">';
  261. html+=' <i class="fa fa-plus plus_like" onClick="add_user_liked('+category[i]["id"]+');"></i>';
  262. html+=' </a>';
  263. }
  264. if (data.admin==1){
  265. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive"> ';
  266. html+=' <i class="fa fa-times" onClick="delete_plate('+category[i]["id"]+');"></i>';
  267. html+=' </a>';
  268. };
  269. html+=' </div>';
  270. html+=' </figcaption>';
  271. html+=' </figure>';
  272. html+=' </li>';
  273. }
  274. //fin li
  275. html+=' </ul>';
  276. html+=' </div> <!-- Container Full End -->';
  277. html+='</section> <!-- Portfolio Section End -->';
  278. html+= "<script type='text/javascript' src='/static/js/jquery.easing.1.3.js'></script>";
  279. $("#main_container").append(html);
  280. }
  281. });
  282. }
  283.  
  284. function search_plate(){
  285. var search=document.getElementById("inputSearch").value;
  286. console.log(search);
  287. $("#main_container").empty();
  288. $.ajax({
  289. url : "/addplates/search/"+search,
  290. type : "GET",
  291. contentType: "application/json",
  292. success: function(data){
  293. var category = data.results;
  294. html = "";
  295. html+='<section id="portfolio">';
  296. html+=' <div class="container">';
  297. html+=' <div class="row">';
  298. html+=' <div class="col-md-12 col-sm-12 col-xs-12">';
  299. html+=' <div class="feature_header text-center">';
  300. html+=' <h3 class="feature_title">Your <b>plates</b></h3>';
  301. html+=' <h4 class="feature_sub">Here you can add, or delete plates you like. </h4>';
  302. html+=' <div class="divider"></div>';
  303. html+=' </div>';
  304. html+=' </div> <!-- Col-md-12 End -->';
  305. html+=' </div>';
  306. html+=' </div>';
  307. html+=' <div id="Search">';
  308. html+=' <input name=\"Search\" placeholder=\"Search\" id=\"inputSearch\" value=\"\" type=\"text\" class=\"input-block\">';
  309. html+=' <a id="Search" href="#" onClick="search_plate();" class="">Search</a>';
  310. html+=' </div>';
  311. html+=' <div id="isotope-filter" class="skew3 text-center">';
  312. html+=' <a id="all" href="#" onClick="display_all_plates(\'all\');" class="active ">All</a>';
  313. html+=' <a id="Entrée" href="#" onClick="display_all_plates(\'Entree\');" class="">Entrée</a>';
  314. html+=' <a id="Plat" href="#" onClick="display_all_plates(\'Plat\');" class="">Plat</a>';
  315. html+=' <a id="Dessert" href="#" onClick="display_all_plates(\'Dessert\');" class="">Dessert</a>';
  316. html+=' <a id="Apéro" href="#" onClick="display_all_plates(\'Apero\');" class="">Apéro</a>';
  317. html+=' </div>';
  318. html+=' <div class="clearfix"></div>';
  319. html+=' <div class="text-center ">';
  320. html+=' <ul class="portfolio-wrap" id="portfolio_items">';
  321. // debut li
  322. $.each(category, function(i, obj) {
  323. html+=' <li class="col-xs-12 col-sm-6 col-md-3 single-portfolio identity web-design">';
  324. html+=' <figure>';
  325. html+=' <img src="../static/images/food/'+category[i]["img"]+'" alt="" />';
  326. html+=' <figcaption>';
  327. html+=' <h5>'+category[i]["name"]+'</h5>';
  328. html+=' <div class="links">';
  329. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive">';
  330. html+=' <i class="fa fa-plus plus_cook" onClick="add_user_cooked('+category[i]["id"]+');"></i>';
  331. html+=' </a>';
  332. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive"> ';
  333. html+=' <i class="fa fa-minus minus_cook" onClick="remove_user_cooked('+category[i]["id"]+');"></i>';
  334. html+=' </a>';
  335. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive"> ';
  336. html+=' <i class="fa fa-times" onClick="delete_plate('+category[i]["id"]+');"></i>';
  337. html+=' </a>';
  338. html+=' </div>';
  339. html+=' </figcaption>';
  340. html+=' </figure>';
  341. html+=' </li>';
  342. });
  343. //fin li
  344. html+=' </ul>';
  345. html+=' </div> <!-- Container Full End -->';
  346. html+='</section> <!-- Portfolio Section End -->';
  347. html+= "<script type='text/javascript' src='/static/js/jquery.easing.1.3.js'></script>";
  348. $("#main_container").append(html);
  349. bindings();
  350. //include('jquery.easing.1.3.js');
  351. }
  352. });
  353. }
  354.  
  355. function display_all_cook(category){
  356. if ( category == 'all') {
  357. var source="/allplates";
  358. var choice = "";
  359. }
  360. else {
  361. var source="/plates_by_class/"+category;
  362. var choice = {"choice" : category};
  363. }
  364. $.ajax({
  365. url : source,
  366. type : "GET",
  367. contentType: "application/json",
  368. data : choice,
  369. success: function(data){
  370. $("#main_container").empty();
  371. var category = data.plates;
  372. console.log(data);
  373. console.log(category.length);
  374. var html = "";
  375. html+='<section id="portfolio">';
  376. html+=' <div class="container">';
  377. html+=' <div class="row">';
  378. html+=' <div class="col-md-12 col-sm-12 col-xs-12">';
  379. html+=' <div class="feature_header text-center">';
  380. html+=' <h3 class="feature_title">Your <b>cook</b></h3>';
  381. html+=' <h4 class="feature_sub">Here you can add, or delete plates you like. </h4>';
  382. html+=' <div class="divider"></div>';
  383. html+=' </div>';
  384. html+=' </div> <!-- Col-md-12 End -->';
  385. html+=' </div>';
  386. html+=' </div>';
  387. html+=' <div id="Search">';
  388. html+=' <input name=\"Search\" placeholder=\"Search\" id=\"inputSearch\" value=\"\" type=\"text\" class=\"input-block\">';
  389. html+=' <a id="Search" href="#" onClick="search_cook();" class="">Search</a>';
  390. html+=' </div>';
  391. html+=' <div id="isotope-filter" class="skew3 text-center">';
  392. html+=' <a id="all" href="#" onClick="display_all_cook(\'all\');" class="active ">All</a>';
  393. html+=' <a id="Entrée" href="#" onClick="display_all_cook(\'Entree\');" class="">Entrée</a>';
  394. html+=' <a id="Plat" href="#" onClick="display_all_cook(\'Plat\');" class="">Plat</a>';
  395. html+=' <a id="Dessert" href="#" onClick="display_all_cook(\'Dessert\');" class="">Dessert</a>';
  396. html+=' <a id="Apéro" href="#" onClick="display_all_cook(\'Apero\');" class="">Apéro</a>';
  397. html+=' </div>';
  398. html+=' <div class="clearfix"></div>';
  399. html+=' <div class="text-center ">';
  400. html+=' <ul class="portfolio-wrap" id="portfolio_items">';
  401. // debut li
  402. for(var i=0; i<category.length; i++){
  403. html+=' <li class="col-xs-12 col-sm-6 col-md-3 single-portfolio identity web-design">';
  404. html+=' <figure>';
  405. html+=' <img src="../static/images/food/'+category[i]["img"]+'" alt="" />';
  406. html+=' <figcaption>';
  407. html+=' <h5>'+category[i]["name"]+'</h5>';
  408. html+=' <div class="links">';
  409. if(category[i]["name"] in data.cooked){
  410. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive">';
  411. html+=' <i class="fa fa-plus plus_cook" onClick="add_user_cooked('+category[i]["id"]+');"></i>';
  412. html+=' </a>';
  413. }
  414. else{
  415. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive"> ';
  416. html+=' <i class="fa fa-minus minus_cook" onClick="remove_user_cooked('+category[i]["id"]+');"></i>';
  417. html+=' </a>';
  418. }
  419. if (data.admin==1){
  420. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive"> ';
  421. html+=' <i class="fa fa-times" onClick="delete_plate('+category[i]["id"]+');"></i>';
  422. html+=' </a>';
  423. };
  424. html+=' </div>';
  425. html+=' </figcaption>';
  426. html+=' </figure>';
  427. html+=' </li>';
  428. }
  429. //fin li
  430. html+=' </ul>';
  431. html+=' </div> <!-- Container Full End -->';
  432. html+='</section> <!-- Portfolio Section End -->';
  433. html+= "<script type='text/javascript' src='/static/js/jquery.easing.1.3.js'></script>";
  434. $("#main_container").append(html);
  435. bindings();
  436. //include('jquery.easing.1.3.js');
  437. }
  438. });
  439. }
  440.  
  441.  
  442.  
  443. function search_cook(){
  444. var search=document.getElementById("inputSearch").value;
  445. console.log(search);
  446. $("#main_container").empty();
  447. $.ajax({
  448. url : "/addcook/search/"+search,
  449. type : "GET",
  450. contentType: "application/json",
  451. success: function(data){
  452. var category = data.results;
  453. html = "";
  454. html+='<section id="portfolio">';
  455. html+=' <div class="container">';
  456. html+=' <div class="row">';
  457. html+=' <div class="col-md-12 col-sm-12 col-xs-12">';
  458. html+=' <div class="feature_header text-center">';
  459. html+=' <h3 class="feature_title">Your <b>cooks</b></h3>';
  460. html+=' <h4 class="feature_sub">Here you can add, or delete plates you like. </h4>';
  461. html+=' <div class="divider"></div>';
  462. html+=' </div>';
  463. html+=' </div> <!-- Col-md-12 End -->';
  464. html+=' </div>';
  465. html+=' </div>';
  466. html+=' <div id="Search">';
  467. html+=' <input name=\"Search\" placeholder=\"Search\" id=\"inputSearch\" value=\"\" type=\"text\" class=\"input-block\">';
  468. html+=' <a id="Search" href="#" onClick="search_cook();" class="">Search</a>';
  469. html+=' </div>';
  470. html+=' <div id="isotope-filter" class="skew3 text-center">';
  471. html+=' <a id="all" href="#" onClick="display_all_cook(\'all\');" class="active ">All</a>';
  472. html+=' <a id="Entrée" href="#" onClick="display_all_cook(\'Entree\');" class="">Entrée</a>';
  473. html+=' <a id="Plat" href="#" onClick="display_all_cook(\'Plat\');" class="">Plat</a>';
  474. html+=' <a id="Dessert" href="#" onClick="display_all_cook(\'Dessert\');" class="">Dessert</a>';
  475. html+=' <a id="Apéro" href="#" onClick="display_all_cook(\'Apero\');" class="">Apéro</a>';
  476. html+=' </div>';
  477. html+=' <div class="clearfix"></div>';
  478. html+=' <div class="text-center ">';
  479. html+=' <ul class="portfolio-wrap" id="portfolio_items">';
  480. // debut li
  481. $.each(category, function(i, obj) {
  482. console.log(i);
  483. console.log(obj);
  484. html+=' <li class="col-xs-12 col-sm-6 col-md-3 single-portfolio identity web-design">';
  485. html+=' <figure>';
  486. html+=' <img src="../static/images/food/'+category[i]["img"]+'" alt="" />';
  487. html+=' <figcaption>';
  488. html+=' <h5>'+category[i]["name"]+'</h5>';
  489. html+=' <div class="links">';
  490. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive">';
  491. html+=' <i class="fa fa-plus plus_cook" onClick="add_user_cooked('+category[i]["id"]+');"></i>';
  492. html+=' </a>';
  493. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive"> ';
  494. html+=' <i class="fa fa-minus minus_cook" onClick="remove_user_cooked('+category[i]["id"]+');"></i>';
  495. html+=' </a>';
  496. html+=' <a href="#" data-rel="prettyPhoto" class="img-responsive"> ';
  497. html+=' <i class="fa fa-times" onClick="delete_plate('+category[i]["id"]+');"></i>';
  498. html+=' </a>';
  499. html+=' </div>';
  500. html+=' </figcaption>';
  501. html+=' </figure>';
  502. html+=' </li>';
  503. });
  504. //fin li
  505. html+=' </ul>';
  506. html+=' </div> <!-- Container Full End -->';
  507. html+='</section> <!-- Portfolio Section End -->';
  508. html+= "<script type='text/javascript' src='/static/js/jquery.easing.1.3.js'></script>";
  509. $("#main_container").append(html);
  510. bindings();
  511. //include('jquery.easing.1.3.js');
  512. }
  513. });
  514. }
  515.  
  516. function add_user_liked(id){
  517. var dict={
  518. "id":id
  519. };
  520. var datas = JSON.stringify(dict);
  521. bindings();
  522. $.ajax({
  523. url:"http://localhost:5000/user/liked/add",
  524. type : "PUT",
  525. contentType : "application/json",
  526. data: datas,
  527. success : function(json){
  528. alert("food added");
  529. }
  530. });
  531. }
  532.  
  533. function remove_user_liked(id){
  534. var dict={
  535. "id":id
  536. };
  537. var datas = JSON.stringify(dict);
  538. bindings();
  539. $.ajax({
  540. url:"http://localhost:5000/user/liked/remove",
  541. type : "PUT",
  542. contentType : "application/json",
  543. data: datas,
  544. success : function(json){
  545. alert("food removed");
  546. }
  547. });
  548. }
  549.  
  550. function add_user_cooked(id){
  551. var dict={
  552. "id":id
  553. };
  554. var datas = JSON.stringify(dict);
  555. bindings();
  556. $.ajax({
  557. url:"http://localhost:5000/user/cooked/add",
  558. type : "PUT",
  559. contentType : "application/json",
  560. data: datas,
  561. success : function(json){
  562. alert("food added");
  563. }
  564. });
  565. }
  566.  
  567. function remove_user_cooked(id){
  568. var dict={
  569. "id":id
  570. };
  571. var datas = JSON.stringify(dict);
  572. bindings();
  573. $.ajax({
  574. url:"http://localhost:5000/user/cooked/remove",
  575. type : "PUT",
  576. contentType : "application/json",
  577. data: datas,
  578. success : function(json){
  579. alert("food removed");
  580. }
  581. });
  582. }
  583.  
  584.  
  585. function my_profil(){
  586. $("#main_container").empty();
  587. $.ajax({
  588. url : "http://localhost:5000/user/profil",
  589. type : "GET",
  590. datatype: "json",
  591. success: function(data){
  592. var html = "";
  593. html +="<section id=\"contact\">";
  594. html +=" <div class=\"container\">";
  595. html +=" <div class=\"row\">";
  596. html +=" <div class=\"col-md-12 col-sm-12 col-xs-12\">";
  597. html +=" <div class=\"feature_header text-center\">";
  598. html +=" <h3 class=\"feature_title\">My <b>profil</b></h3>";
  599. html +=" <div class=\"divider\"></div>";
  600. html +=" </div>";
  601. html +=" </div>";
  602. html +=" </div>";
  603. html +=" <div class=\"row\">";
  604. html +=" <div class=\"contact_full\">";
  605. html +=" <div class=\"col-md-6 left\">";
  606. html +=" <div class=\"\">";
  607. html +=" <form action=\"role\">";
  608. html +=" <div class=\"form-level\">";
  609. html +=" <input name=\"username\" placeholder=\"Username\" id=\"username\" value=\""+data.user.username+"\" type=\"text\" class=\"input-block\">";
  610. html +=" <span class=\"form-icon fa fa-user\"></span>";
  611. html +=" </div>";
  612. html +=" <div class=\"form-level\">";
  613. html +=" <input name=\"password\" placeholder=\"Password\" id=\"password\" class=\"input-block\" value=\"\" type=\"password\">";
  614. html +=" <span class=\"form-icon fa fa-key\"></span>";
  615. html +=" </div>";
  616. html +=" <div class=\"form-level\">";
  617. html +=" <input name=\"firstName\" placeholder=\"First Name\" id=\"firstName\" class=\"input-block\" value=\""+data.user.firstName+"\" type=\"firstName\">";
  618. html +=" <span class=\"form-icon fa fa-hand-o-left\"></span>";
  619. html +=" </div>";
  620. html +=" <div class=\"form-level\">";
  621. html +=" <input name=\"lastName\" placeholder=\"Last Name\" id=\"lastName\" class=\"input-block\" value=\""+data.user.lastName+"\" type=\"lastName\">";
  622. html +=" <span class=\"form-icon fa fa-hand-o-right\"></span>";
  623. html +=" </div>";
  624. html +=" <div class=\"form-level\">";
  625. html +=" <input name=\"email\" placeholder=\"Email\" id=\"mail\" class=\"input-block\" value=\""+data.user.email+"\" type=\"email\">";
  626. html +=" <span class=\"form-icon fa fa-envelope\"></span>";
  627. html +=" </div>";
  628. html +=" <div class=\"form-level\">";
  629. html +=" <input name=\"img\" placeholder=\"Image\" id=\"img\" class=\"input-block\" value=\""+data.user.img+"\" type=\"url\">";
  630. html +=" <span class=\"form-icon fa fa-picture-o\"></span>";
  631. html +=" </div>";
  632. html +=" </form>";
  633. html +=" </div>";
  634. html +=" </div>";
  635. html +="";
  636. html +=" <div class=\"col-md-6 right\">";
  637. html +=" <div class=\"form-level\">";
  638. html +=" <textarea name=\"desc\" id=\"desc\" rows=\"10\" class=\"textarea-block\" placeholder=\"Description\">"+data.user.desc+"</textarea>";
  639. html +=" <span class=\"form-icon fa fa-pencil\"></span>";
  640. html +=" </div>";
  641. html+=" <iframe src='"+data.user.img+"' width='350' height='281' allowfullscreen></iframe>";
  642. html +=" </div>";
  643. html +=" <div class=\"col-md-12 text-center\">";
  644. html +=" <button class=\"btn btn-main featured\">Change profil</button>";
  645. html +=" </div>";
  646. html +=" </div>";
  647. html +=" </div>";
  648. html +="</section>";
  649. $("#main_container").append(html);
  650. }
  651. });
  652. }
  653.  
  654. function display_home(){
  655. $.ajax({
  656. url : "http://localhost:5000/home_user",
  657. type : "GET",
  658. datatype: "json",
  659. success: function(data){
  660. $("#main_container").empty();
  661. var html="";
  662. html+="{% if not current_user.is_authenticated %}";
  663. html+=" <!-- Slider start -->";
  664. html+=" <section id='slider_part'>";
  665. html+=" <div class='carousel slide' id='carousel-example-generic' data-ride='carousel'>";
  666. html+=" <!-- Indicators -->";
  667. html+=" <ol class='carousel-indicators text-center'>";
  668. html+=" <li data-target='#carousel-example-generic' data-slide-to='0' class='active'></li>";
  669. html+=" <li data-target='#carousel-example-generic' data-slide-to='1'></li>";
  670. html+=" <li data-target='#carousel-example-generic' data-slide-to='2'></li>";
  671. html+=" </ol>";
  672. html+=" <div class='carousel-inner'>";
  673. html+=" <div class='item active'>";
  674. html+=" <div class='overlay-slide'>";
  675. html+=" <img src='../static/images/news1.jpeg' alt='' class='img-responsive'>";
  676. html+=" </div>";
  677. html+=" <div class='carousel-caption'>";
  678. html+=" <div class='col-md-12 col-xs-12 text-center'>";
  679. html+=" <h3> <b>EatMe</b>";
  680. html+=" <div class='line'></div>";
  681. html+=" <p> I love meat</p>";
  682. html+=" </div>";
  683. html+=" </div>";
  684. html+=" </div>";
  685. html+=" <div class='item'>";
  686. html+=" <div class='overlay-slide'>";
  687. html+=" <img src='../static/images/news2.jpeg' alt='' class='img-responsive'>";
  688. html+=" </div>";
  689. html+=" <div class='carousel-caption'>";
  690. html+=" <div class='col-md-12 col-xs-12 text-center'>";
  691. html+=" <h4 > We know you are Greats Chiefs </h4>";
  692. html+=" <div class='line'></div>";
  693. html+=" <p> Our range of flat has been extended!</p>";
  694. html+=" </div>";
  695. html+=" </div>";
  696. html+=" </div>";
  697. html+=" <div class='item'>";
  698. html+=" <div class='overlay-slide'>";
  699. html+=" <img src='../static/images/news3.jpeg' alt='' class='img-responsive'>";
  700. html+=" </div>";
  701. html+=" <div class='carousel-caption'>";
  702. html+=" <div class='col-md-12 col-xs-12 text-center'>";
  703. html+=" <h3 > See your Days' Matches</h3>";
  704. html+=" <div class='line'></div>";
  705. html+=" <h5> We never know? Tonight, it might be you that makes you cook </h5>";
  706. html+=" </div>";
  707. html+=" </div>";
  708. html+=" </div>";
  709. html+=" </div> <!-- End Carousel Inner -->";
  710. html+=" <!-- Controls -->";
  711. html+=" <div class='slides-control '>";
  712. html+=" <a class='left carousel-control' href='#carousel-example-generic' data-slide='prev'>";
  713. html+=" <span><i class='fa fa-angle-left'></i></span>";
  714. html+=" </a>";
  715. html+=" <a class='right carousel-control' href='#carousel-example-generic' data-slide='next'>";
  716. html+=" <span><i class='fa fa-angle-right'></i></span>";
  717. html+=" </a>";
  718. html+=" </div>";
  719. html+=" </div>";
  720. html+=" </section>";
  721. html+=" <!--/ Slider end -->";
  722. html+=" <!-- Service Area start -->";
  723. html+=" <section id='service'>";
  724. html+=" <div class='container'>";
  725. html+=" <div class='row'>";
  726. html+=" <div class='col-md-12 col-sm-12 col-xs-12'>";
  727. html+=" <div class='feature_header text-center'>";
  728. html+=" <h3 class='feature_title'> <b>WebSite utilisation</b></h3>";
  729. html+=" <h4 class='feature_sub'>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 !</h4>";
  730. html+=" <div class='divider'></div>";
  731. html+=" </div>";
  732. html+=" </div> <!-- Col-md-12 End -->";
  733. html+=" </div>";
  734. html+=" <div class='row'>";
  735. html+=" <div class='main_feature text-center'>";
  736. html+=" <div class='col-md-3 col-xs-12 col-sm-6'>";
  737. html+=" <div class='feature_content'>";
  738. html+=" <i class='fa fa-thumbs-o-up'></i>";
  739. html+=" <h5>Like</h5>";
  740. html+=" <p>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!</p>";
  741. html+=" </div>";
  742. html+=" </div>";
  743. html+=" <div class='col-md-3 col-xs-12 col-sm-6'>";
  744. html+=" <div class='feature_content'>";
  745. html+=" <i class='fa fa-cutlery'></i>";
  746. html+=" <h5>Cook</h5>";
  747. html+=" <p>Si vous êtes du genre cordon bleu hipster, sur notre site vous pourrez y inscrire ce que vous savez, un peu, beaucoup, pationnement cuisinner. </p>";
  748. html+=" </div>";
  749. html+=" </div> <!-- Col-md-4 Single_feature End -->";
  750. html+=" <div class='col-md-3 col-xs-12 col-sm-6'>";
  751. html+=" <div class='feature_content'>";
  752. html+=" <i class='fa fa-check'></i>";
  753. html+=" <h5>Match</h5>";
  754. html+=" <p>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.</p>";
  755. html+=" </div>";
  756. html+=" </div> <!-- Col-md-4 Single_feature End -->";
  757. html+=" <div class='col-md-3 col-xs-12 col-sm-6'>";
  758. html+=" <div class='feature_content'>";
  759. html+=" <i class='fa fa-heart'></i>";
  760. html+=" <h5>Love</h5>";
  761. html+=" <p>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!</p>";
  762. html+=" </div>";
  763. html+=" </div> <!-- Col-md-4 Single_feature End -->";
  764. html+=" <!-- <button class='btn btn-main'> Read More</button> -->";
  765. html+=" </div>";
  766. html+=" </div> <!-- Row End -->";
  767. html+=" </div> <!-- Container End -->";
  768. html+=" </section>";
  769. html+="{% else %}";
  770. html+=" <section id='testimonial' class='wow fadeInUp '>";
  771. html+=" <div class='container'>";
  772. html+=" <div class='row'>";
  773. html+=" <div class='col-md-12 col-sm-12 col-xs-12'>";
  774. html+=" <div class='feature_header text-center'>";
  775. html+=" {% if propositions=={} %}";
  776. html+=" <h3 class='feature_title'>No match found :(</h3>";
  777. html+=" <h4 class='feature_sub'>We're sorry for you</h4>";
  778. html+=" <div class='divider'></div>";
  779. html+=" </div>";
  780. html+=" </div> <!-- Col-md-12 End -->";
  781. html+=" </div>";
  782. html+=" <div class='row'>";
  783. html+=" <div id='testimonial-carousel' class='owl-carousel owl-theme text-center testimonial-slide '>";
  784. html+=" <h4> Our algorithme hadn't found any matches concerning your plates liked or cooked. <a href='#' onclick='display_all_plates()'> Please add one !</h4> </p>";
  785. html+=" {% else %}";
  786. html+=" <h3 class='feature_title'>You should like them</h3>";
  787. html+=" <h4 class='feature_sub'>Mom, what do we eat tonight ?</h4>";
  788. html+=" <div class='divider'></div>";
  789. html+=" </div>";
  790. html+=" </div> <!-- Col-md-12 End -->";
  791. html+=" </div>";
  792. html+=" <div class='row'>";
  793. html+=" <div id='testimonial-carousel' class='owl-carousel owl-theme text-center testimonial-slide '>";
  794. html+=" {% for user in propositions %}";
  795. html+=" <div id ='{{ propositions[user]['User'][0]['username'] }}' class='item'>";
  796. html+=" <div class='testimonial-thumb'>";
  797. html+=" {% if propositions[user]['User'][0]['img'] != '' %}";
  798. html+=" <img id='{{ propositions[user]['User'][0]['username'] }}' onclick='add_love(this.id)' class='img-circle' src='{{ propositions[user]['User'][0]['img'] }}' onerror=this.src='{{ url_for('static', filename='images/default.png')}}' >";
  799. html+=" {% else %}";
  800. html+=" <img id='{{ propositions[user]['User'][0]['username'] }}' class='img-circle' src='{{ url_for('static', filename='images/default.png')}}' onerror=this.src='{{ url_for('static', filename='images/default.png')}}' >";
  801. html+=" {% endif %}";
  802. html+=" </div>";
  803. html+=" <div class='testimonial-content'>";
  804. html+=" <h3 id='{{ propositions[user]['User'][0]['username'] }}' class='name'><a class='get_profil' onclick='get_profil(this.id)' id='{{ propositions[user]['User'][0]['username'] }}' href='#'>{{ propositions[user]['User'][0]['username'] }}</a><span> Eating Rate : {{ propositions[user]['User'][0]['foodLevel'] }}/5</span></h3>";
  805. html+=" <p class='testimonial-text'>";
  806. html+=" {{ propositions[user]['User'][0]['desc'] }}";
  807. html+=" </p>";
  808. html+=" <div>";
  809. html+=" <div class='proposition_commun'>She likes those of your meals : {% for plate in propositions[user]['ICook'] %}{{ plate['name'] }},{% endfor %}</div>";
  810. html+=" <div class='proposition_commun'>You like those of her meals : {% for plate in propositions[user]['HeCooks'] %}{{ plate['name'] }},{% endfor %}</div>";
  811. html+=" <div class='proposition_commun'>You both like eating : {% for plate in propositions[user]['WeLike'] %}{{ plate['name'] }},{% endfor %}</div>";
  812. html+=" <div class='proposition_commun'>You both know cooking : {% for plate in propositions[user]['WeCook'] %}{{ plate['name'] }},{% endfor %}</div>";
  813. html+=" </div>";
  814. html+=" </div>";
  815. html+=" </div>";
  816. html+=" {% endfor %}";
  817. html+=" </div>";
  818. html+=" <!-- Navigation start -->";
  819. html+=" <div class='customNavigation cyprass-carousel-controller'>";
  820. html+=" <a class='prev left'>";
  821. html+=" <i class='fa fa-chevron-left'></i>";
  822. html+=" </a>";
  823. html+=" <!-- <a class='prev center'>";
  824. html+=" <button class='btn btn-danger btn-lg' ><i class='fa fa-heart' aria-hidden='true'></i></button>";
  825. html+=" </a> -->";
  826. html+=" <a class='next right'>";
  827. html+=" <i class='fa fa-chevron-right'></i>";
  828. html+=" </a>";
  829. html+=" </div>";
  830. html+=" {% endif %}";
  831. html+=" <!-- Navigation ENd -->";
  832. html+=" </div>";
  833. html+=" </div> <!-- Row End -->";
  834. html+=" </section> <!-- Section Testimonial End -->";
  835. html+=" </section> <!-- Section TEam End -->";
  836. html+=" <section id='about'>";
  837. html+=" <div class='container'>";
  838. html+=" <div class='row'>";
  839. html+=" <div class='col-md-12 col-sm-12 col-xs-12'>";
  840. html+=" <div class='feature_header text-center'>";
  841. html+=" <h3 class='feature_title'>Eating Program</h3>";
  842. html+=" <div class='divider'></div>";
  843. html+=" </div>";
  844. html+=" </div>";
  845. html+=" </div>";
  846. html+=" <div class='row'>";
  847. html+=" <div class='feature-tab'>";
  848. html+=" <div class='col-md-2 col-sm-3 col-xs-12'>";
  849. html+=" <ul class='nav nav-tabs main-tab-list text-center' role='tablist'>";
  850. html+=" <li role='presentation' class='active'>";
  851. html+=" <a href='#matches' role='tab' data-toggle='tab'>";
  852. html+=" <div class='single-tab'>";
  853. html+=" <div class='f-icon'>";
  854. html+=" <i class='fa fa-heart'></i>";
  855. html+=" </div>";
  856. html+=" </div>";
  857. html+=" <h4>Your matches</h4>";
  858. html+=" </a>";
  859. html+=" </li>";
  860. html+=" <li role='presentation'>";
  861. html+=" <a href='#liked' role='tab' data-toggle='tab' >";
  862. html+=" <div class='single-tab'>";
  863. html+=" <div class='f-icon'>";
  864. html+=" <i class='fa fa-thumbs-up'></i>";
  865. html+=" </div>";
  866. html+=" </div>";
  867. html+=" <h4>What I Like</h4>";
  868. html+=" </a>";
  869. html+=" </li>";
  870. html+=" <li role='presentation' >";
  871. html+=" <a href='#cooked' role='tab' data-toggle='tab'>";
  872. html+=" <div class='single-tab'>";
  873. html+=" <div class='f-icon'>";
  874. html+=" <i class='fa fa-cutlery'></i>";
  875. html+=" </div>";
  876. html+=" </div>";
  877. html+=" <h4>What I Cook</h4>";
  878. html+=" </a>";
  879. html+=" </li>";
  880. html+=" </ul>";
  881. html+=" </div> <!-- col-md-12 end -->";
  882. html+=" <div class='col-md-10 col-sm-9 col-xs-12'>";
  883. html+=" <div class='tab-content main-tab-content'>";
  884. html+=" <div role='tabpanel' class='tab-pane active ' id='matches'>";
  885. html+=" <div class='col-md-12 col-sm-9'>";
  886. html+=" <img src='images/about/web1.png' alt='' class='img-responsive'>";
  887. html+=" </div>";
  888. html+=" <div class='col-md-12 col-sm-9'>";
  889. html+=" <div class='c-tab'>";
  890. html+=" <h4>Here you cand find the eaters that you loved, and loved you back : contact them !</h4>";
  891. html+=" <div>";
  892. html+=" <ul>";
  893. html+=" {% for user in current_user.matched %}";
  894. html+=" <li>";
  895. html+=" <a href='#' onclick='get_profil(this.id)' id='{{user.username}}'>{{user.username}}</a> : {{user.email}}";
  896. html+=" </li>";
  897. html+=" {% endfor %}";
  898. html+=" </ul>";
  899. html+=" </div>";
  900. html+=" </div>";
  901. html+=" </div>";
  902. html+=" </div>";
  903. html+=" <div role='tabpanel' class='tab-pane' id='liked'>";
  904. html+=" <div class='col-md-12 col-sm-9'>";
  905. html+=" <img src='images/about/browse.png' alt='' class='img-responsive'>";
  906. html+=" </div>";
  907. html+=" <div class='col-md-12 col-sm-9'>";
  908. html+=" <div class='c-tab'>";
  909. html+=" <h4>Plates that you like</h4>";
  910. html+=" {% if current_user.liked==None %}";
  911. html+=" <p>Don't you like any of our plates ?</p>";
  912. html+=" <a href='#' onclick='display_all_plates()'> See our selection</a>";
  913. html+=" {% else %}";
  914. html+=" <p>{% for plate in current_user.liked %}{{plate.name}}<br>{% endfor %}</p>";
  915. html+=" <a href='#' onclick='display_all_plates()'> Add other plates</a>";
  916. html+=" {% endif %}";
  917. html+=" </div>";
  918. html+=" </div>";
  919. html+=" </div>";
  920. html+=" <div role='tabpanel' class='tab-pane' id='cooked'>";
  921. html+=" <div class='col-md-12 col-sm-9'>";
  922. html+=" <img src='images/about/web1.png' alt='' class='img-responsive'>";
  923. html+=" </div>";
  924. html+=" <div class='col-md-12 col-sm-9'>";
  925. html+=" <div class='c-tab'>";
  926. html+=" {% if current_user.cooked==[] %}";
  927. html+=" <h4>Apparently nothing?</h4>";
  928. html+=" <p>We are sure you know how to cook something...</p>";
  929. html+=" {% else %}";
  930. html+=" <h4>List of all the plate you can propose to your matches !</h4>";
  931. html+=" <p>{% for plate in current_user.cooked %}{{plate.name}}<br>{% endfor %}</p>";
  932. html+=" {% endif %}";
  933. html+=" <a href='#' onclick='display_all_plates()'> Increase your cooked list </a>";
  934. html+=" </div>";
  935. html+=" </div>";
  936. html+=" </div>";
  937. html+=" </div>";
  938. html+=" </div>";
  939. html+=" </div>";
  940. html+=" </div>";
  941. html+=" </div>";
  942. html+=" </section>";
  943. html+="{% endif %}";
  944. $("#main_container").append(html);
  945. bindings();
  946. }
  947. });
  948. }
  949.  
  950. function get_profil(id){
  951. console.log(id);
  952. var dict={
  953. "username": id
  954. };
  955. var datas=JSON.stringify(dict);
  956. $.ajax({
  957. url : "http://localhost:5000/user/profil",
  958. type : "POST",
  959. contentType:"application/json",
  960. data: datas,
  961. success: function(data){
  962. display_profil(data);
  963. }
  964. });
  965. }
  966.  
  967. function display_profil(json){
  968. var html ="";
  969. $("#main_container").empty();
  970. html+="<div class='clearfix'></div>";
  971. html+="</br>";
  972. html+="</br>";
  973. html+="<section id='video-fact'>";
  974. html+=" <div class='container'>";
  975. html+=" <div class='row'>";
  976. html+=" <div class='col-md-6 '>";
  977. html+=" <div class='landing-video'>";
  978. html+=" <div class='video-embed wow fadeIn' data-wow-duration='1s'>";
  979. html+=" <!-- Change the url -->";
  980. html+=" <iframe src='"+json.user.img+"' width='350' height='281' allowfullscreen></iframe>";
  981. html+=" </div>";
  982. html+=" </div>";
  983. html+=" </div>";
  984. html+=" <div class='col-md-6 '>";
  985. html+=" <div class='video-text'>";
  986. html+=" <div class='panel-group' id='accordion' role='tablist' aria-multiselectable='true'>";
  987. html+=" <div class='panel panel-default'>";
  988. html+=" <div class='panel-heading active' role='tab' id='headingOne'>";
  989. html+=" <h4 class='panel-title'>";
  990. html+=" <a class='accordion-toggle' data-toggle='collapse' data-parent='#accordion' href='#collapseOne' aria-expanded='true' aria-controls='collapseOne'>";
  991. html+=" What like to eat:";
  992. html+=" </a>";
  993. html+=" </h4>";
  994. html+=" </div>";
  995. html+=" <div id='collapseOne' class='panel-collapse collapse in' role='tabpanel' aria-labelledby='headingOne'>";
  996. html+=" <div class='panel-body p1'>";
  997. html+=" <ul>";
  998. $.each(json.user.liked, function(i, obj) {
  999. html+="<li>"+obj+"</li>";
  1000. });
  1001. html+=" </ul>";
  1002. html+=" </div>";
  1003. html+=" </div>";
  1004. html+=" </div>";
  1005. html+=" <div class='panel panel-default'>";
  1006. html+=" <div class='panel-heading ' role='tab' id='headingTwo'>";
  1007. html+=" <h4 class='panel-title'>";
  1008. html+=" <a class='accordion-toggle collapsed' data-toggle='collapse' data-parent='#accordion' href='#collapseTwo' aria-expanded='false' aria-controls='collapseTwo'>";
  1009. html+=" What like to cook:";
  1010. html+=" </a>";
  1011. html+=" </h4>";
  1012. html+=" </div>";
  1013. html+=" <div id='collapseTwo' class='panel-collapse collapse' role='tabpanel' aria-labelledby='headingTwo'>";
  1014. html+=" <div class='panel-body p1'>";
  1015. html+=" <ul>";
  1016. $.each(json.user.cooked, function(i, obj) {
  1017. html+="<li>"+obj+"</li>";
  1018. });
  1019. html+=" </ul>";
  1020. html+=" </div>";
  1021. html+=" </div>";
  1022. html+=" </div>";
  1023. html+=" <div class='panel panel-default'>";
  1024. html+=" <div class='panel-heading ' role='tab' id='headingThree'>";
  1025. html+=" <h4 class='panel-title'>";
  1026. html+=" <a class='accordion-toggle collapsed' data-toggle='collapse' data-parent='#accordion' href='#collapseThree' aria-expanded='false' aria-controls='collapseThree'>";
  1027. html+=" Description:";
  1028. html+=" </a>";
  1029. html+=" </h4>";
  1030. html+=" </div>";
  1031. html+=" <div id='collapseThree' class='panel-collapse collapse' role='tabpanel' aria-labelledby='headingThree'>";
  1032. html+=" <div class='panel-body p1'>";
  1033. html+=" "+json.user.desc+"";
  1034. html+=" </div>";
  1035. html+=" </div>";
  1036. html+=" </div>";
  1037. html+=" </div>";
  1038. html+=" <div class='row'>";
  1039. html+=" <div class='col-md-1 col-md-push-5'>";
  1040. html+=" <button id='"+json.user.username+"' onclick='add_love(this.id)' class='btn btn-danger btn-lg'><i class='fa fa-heart' aria-hidden='true'></i></button>";
  1041. html+=" </div>";
  1042. html+=" </div>";
  1043. html+=" </div>";
  1044. html+=" </div>";
  1045. html+=" </div><!-- row End -->";
  1046. html+=" </div>";
  1047. html+="</section>";
  1048. $("#main_container").append(html);
  1049. }
  1050.  
  1051. function delete_plate(id){
  1052. var dict={
  1053. "id":id
  1054. };
  1055. var datas = JSON.stringify(dict);
  1056. $.ajax({
  1057. url:"http://localhost:5000/allplates",
  1058. type : 'DELETE',
  1059. contentType : "application/json",
  1060. data: datas,
  1061. success : function(json){
  1062. alert("Food has been removed form Database");
  1063. }
  1064. });
  1065. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement