From 84729d5912688b18e02bcec243fe5ddba1bef3a1 Mon Sep 17 00:00:00 2001 From: Tim Krehan Date: Mon, 29 Oct 2018 22:23:51 +0100 Subject: [PATCH] added export for list entries --- bin/settings.js | 7 ++++++- php/edit-list.php | 5 +++++ php/edit-recipes.php | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/settings.js b/bin/settings.js index 4dbf2bc..0b4768c 100644 --- a/bin/settings.js +++ b/bin/settings.js @@ -12,7 +12,12 @@ $(document).ready(function(){ $("#mail-input").focus(function(){$(this).css("color", "black");}); $("#export-recipe-button").click(function(){ $.post("/php/edit-recipes.php", {function:"export"}, function(data){ - downloadObjectAsJson(data, "recipes"); + downloadObjectAsJson(JSON.parse(data), "recipes"); + }); + }); + $("#export-list-button").click(function(){ + $.post("/php/edit-list.php", {function:"export"}, function(data){ + downloadObjectAsJson(JSON.parse(data), "list"); }); }); }); diff --git a/php/edit-list.php b/php/edit-list.php index e9237df..ede9866 100644 --- a/php/edit-list.php +++ b/php/edit-list.php @@ -19,6 +19,11 @@ case 'check': $shopping->check($_POST["id"], $_POST["status"]); + break; + + case 'export': + echo json_encode($shopping); + break; default: // code... diff --git a/php/edit-recipes.php b/php/edit-recipes.php index 5d7040e..857bda4 100644 --- a/php/edit-recipes.php +++ b/php/edit-recipes.php @@ -29,7 +29,6 @@ case 'export': $book->fillCookbook(); - header("Content-type: text/json"); echo json_encode($book); break;