2018-10-29 22:14:56 +01:00
|
|
|
function downloadObjectAsJson(exportObj, exportName){
|
|
|
|
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(exportObj));
|
|
|
|
var downloadAnchorNode = document.createElement('a');
|
|
|
|
downloadAnchorNode.setAttribute("href", dataStr);
|
|
|
|
downloadAnchorNode.setAttribute("download", exportName + ".json");
|
|
|
|
document.body.appendChild(downloadAnchorNode); // required for firefox
|
|
|
|
downloadAnchorNode.click();
|
|
|
|
downloadAnchorNode.remove();
|
|
|
|
}
|
2018-10-29 19:57:40 +01:00
|
|
|
$(document).ready(function(){
|
|
|
|
$("#username-input").focus(function(){$(this).css("color", "black");});
|
|
|
|
$("#mail-input").focus(function(){$(this).css("color", "black");});
|
2018-10-29 22:14:56 +01:00
|
|
|
$("#export-recipe-button").click(function(){
|
|
|
|
$.post("/php/edit-recipes.php", {function:"export"}, function(data){
|
2018-10-29 22:23:51 +01:00
|
|
|
downloadObjectAsJson(JSON.parse(data), "recipes");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$("#export-list-button").click(function(){
|
|
|
|
$.post("/php/edit-list.php", {function:"export"}, function(data){
|
|
|
|
downloadObjectAsJson(JSON.parse(data), "list");
|
2018-10-29 22:14:56 +01:00
|
|
|
});
|
2018-10-29 19:57:40 +01:00
|
|
|
});
|
|
|
|
});
|