From 54c348b160a53e2245cd903711cc71c7a438541f Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Tue, 24 Feb 2015 13:57:25 +0100 Subject: [PATCH] This fixes downloading of zones. It is tested in Linux Chromium, Iceweasel, Windows Firefox. Fixes and closes #20 --- index.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 60cdf8b..530e2f9 100644 --- a/index.php +++ b/index.php @@ -19,6 +19,7 @@ if (!is_logged_in() and isset($_POST['formname']) and $_POST['formname'] === "lo } ?> + NSEdit! @@ -178,10 +179,18 @@ function displayExportIcon(zone) { var $img = $(''); $img.click(function () { var $zexport = $.getJSON("zones.php?zone="+zone.record.name+"&action=export", function(data) { + blob = new Blob([data.Record.zone], { type: 'text/plain' }); var dl = document.createElement('a'); - dl.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(data.Record.zone)); - dl.setAttribute('download', zone.record.name+'.txt'); - dl.click(); + dl.addEventListener('click', function(ev) { + dl.href = URL.createObjectURL(blob); + dl.download = zone.record.name+'.txt'; + }, false); + + if (document.createEvent) { + var event = document.createEvent("MouseEvents"); + event.initEvent("click", true, true); + dl.dispatchEvent(event); + } }); }); return $img;