mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-19 20:09:14 +03:00
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:
commit
5fd8495a88
1 changed files with 12 additions and 3 deletions
15
index.php
15
index.php
|
@ -19,6 +19,7 @@ if (!is_logged_in() and isset($_POST['formname']) and $_POST['formname'] === "lo
|
|||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>NSEdit!</title>
|
||||
|
@ -178,10 +179,18 @@ function displayExportIcon(zone) {
|
|||
var $img = $('<img class="list clickme" src="img/export.png" title="Export zone" />');
|
||||
$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;
|
||||
|
|
Loading…
Add table
Reference in a new issue