/* Contains all the logic of the user dashboard, such as create canvas, remove one or logout */ $(function() { /*================================ REGISTER USER HAS LOGGED IN: Load their canvases ================================*/ // "loggedin_user_email" is the email of the user who's logged in. It is retrieved from the php script on top of the in the dashbord.php file and stored as a js variable in the js script the in the header of the dashboard.php file /* --------------------------------------------------------- An AJAX request to post the user's email to the server to load their saved canvases -----------------------------------------------------------*/ /*If the user has no canvases it returns []. This is an example of what two canvases returned: [{"canvas_id":"6RnpIt9d9W","user_id":"hello@arturocalvo.com","canvas_name":"Test ARTURO 2","canvas_date":"2016-07-16"},{"canvas_id":"E4YoiRJgSB","user_id":"hello@arturocalvo.com","canvas_name":"Test ARTURO 1","canvas_date":"2016-07-16"}]*/ var url = "load_user_canvases.php"; $.post(url, { loggedin_user_email: loggedin_user_email }, function(data, status) { //the data is a string holding array of json //concert the string to array of json to be able to loop it var canvasArray = jQuery.parseJSON(data); var canvas_color_index; //the color of the canvas in the gallery ( is designed in dashbord.css, and assiged here with jQuery) $.each(canvasArray, function(index, canvasItem) { /* canvas gallery elements would be dynamically created by jQuery
created: 2016/09/14
created:
' + canvasItem.canvas_date + '