Merge pull request #31 from tuxis-ie/fix-issue20

This fixes downloading of zones. It is tested in Linux Chromium, Iceweas...
This commit is contained in:
Tuxis Internet Engineering V.O.F. 2015-02-24 13:58:35 +01:00
commit 5fd8495a88

View file

@ -19,6 +19,7 @@ if (!is_logged_in() and isset($_POST['formname']) and $_POST['formname'] === "lo
} }
?> ?>
<!DOCTYPE html>
<html> <html>
<head> <head>
<title>NSEdit!</title> <title>NSEdit!</title>
@ -178,10 +179,18 @@ function displayExportIcon(zone) {
var $img = $('<img class="list clickme" src="img/export.png" title="Export zone" />'); var $img = $('<img class="list clickme" src="img/export.png" title="Export zone" />');
$img.click(function () { $img.click(function () {
var $zexport = $.getJSON("zones.php?zone="+zone.record.name+"&action=export", function(data) { 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'); var dl = document.createElement('a');
dl.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(data.Record.zone)); dl.addEventListener('click', function(ev) {
dl.setAttribute('download', zone.record.name+'.txt'); dl.href = URL.createObjectURL(blob);
dl.click(); 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; return $img;