/* * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ function onReady() { construct_reglages(); } function generate() { var reg = get_regs(); reg.leftbar=get_cats(); reg.main=get_conts(); return reg; } function test() { console.log(JSON.stringify(generate())); //send_post(generate()); var blob = new Blob([JSON.stringify(generate())], {type: "application/*"}); saveAs(blob, "cv.json"); } function fill_ui(data) { if(typeof data == "string") data=JSON.parse(data); info_open(data.leftbar); regs_open(data); cont_open(data.main); load_json(); } function submitForm() { console.log("submit event"); var fd = new FormData(document.getElementById("fileinfo")); //fd.append("label", "WEBUPLOAD"); $.ajax({ url: "server/ping.php", type: "POST", data: fd, processData: false, // tell jQuery not to process the data contentType: false // tell jQuery not to set contentType }).done(function( data ) { fill_ui(data); }); return false; } function submitFormImage() { console.log("submit event image"); var obj = generate(); var fd = new FormData(document.getElementById("fileinfoimage")); fd.append("json", JSON.stringify(obj)); fd.append("img", "cv/"+obj.photo); $.ajax({ url: "server/archive.php", type: "POST", data: fd, processData: false, contentType: false, async: false }).done(function( data ) { var a = document.getElementById('a1'); a.href = "data:application/x-tgz;base64,"+data; a.click(); }); return false; } function load_json() { if($('#button_open').html()=="Importer") { $('#button_open').html("Annuler"); $('#input_open').removeClass('hidden'); } else { $('#button_open').html("Importer"); $('#input_open').addClass('hidden'); } } function toggle_distribe() { if($('#button_distrib').html()=="Distribuer") { $('#button_distrib').html("Annuler"); $('#input_open_image').removeClass('hidden'); } else { $('#button_distrib').html("Distribuer"); $('#input_open_image').addClass('hidden'); } } $( document ).ready(onReady);