Skip to content

Commit

Permalink
Merge pull request #20 from joelthorner/dev
Browse files Browse the repository at this point in the history
Add mail id into download file name
  • Loading branch information
joelthorner authored May 19, 2018
2 parents b54a9e7 + cfc9ecd commit 479fb3d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 40 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">Emilio generator&nbsp;&nbsp;<small class="badge badge-pill badge-warning">v1.1.0</small></a>
<a class="navbar-brand" href="#">Emilio generator&nbsp;&nbsp;<small class="badge badge-pill badge-warning">v1.1.1</small></a>
<form class="form-inline" onsubmit="return false;">
<input class="form-control form-control-sm mr-sm-2" type="search" placeholder="Search" aria-label="Search" id="search">
<button class="btn btn-sm btn-secondary my-2 my-sm-0" type="submit" id="search-submit">Search</button>
Expand Down
63 changes: 24 additions & 39 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,28 +282,8 @@ APP.frontEnd = {
event.preventDefault();
event.stopPropagation();


var $editor = $(this).parents('.block-mail').find('.editor');

var editor = ace.edit($editor[0]);
var code = editor.getValue();
var name = DATA.mails[$editor.data('id')];
var actualLangId = $('#output-tabs .nav-link.active').data('lang-id');
var actualLangKey = $('#output-tabs .nav-link.active').data('lang-key');
var header = ace.edit( $('#editor-'+actualLangId+'_H')[0] ).getValue();
var footer = ace.edit( $('#editor-'+actualLangId+'_F')[0] ).getValue();


var a = window.document.createElement('a');
a.href = window.URL.createObjectURL(new Blob([header, code, footer], {type: 'text/html'}));
a.download = name + '_' + actualLangKey + '.html';

// Append anchor to body.
document.body.appendChild(a);
a.click();

// Remove anchor from body
document.body.removeChild(a);
APP.frontEnd.generateLinkDownload($editor);
});

$('.download-all').click(function(event) {
Expand All @@ -312,29 +292,34 @@ APP.frontEnd = {

var actualLangId = $('#output-tabs .nav-link.active').data('lang-id');

$('#output-tabs-cont #tab-lang-c-'+actualLangId+' .block-mail').not('.block-header, .block-footer').each(function(index, el) {
var $editor = $(this).find('.editor');
$('#output-tabs-cont #tab-lang-c-' + actualLangId + ' .block-mail').not('.block-header, .block-footer')
.each(function(index, el) {
var $editor = $(this).find('.editor');
APP.frontEnd.generateLinkDownload($editor);
});
});
},

var editor = ace.edit($editor[0]);
var code = editor.getValue();
var name = DATA.mails[$editor.data('id')];
var actualLangKey = $('#output-tabs .nav-link.active').data('lang-key');
var header = ace.edit( $('#editor-'+actualLangId+'_H')[0] ).getValue();
var footer = ace.edit( $('#editor-'+actualLangId+'_F')[0] ).getValue();
generateLinkDownload : function ($editor) {
var editor = ace.edit($editor[0]);
var code = editor.getValue();
var name = DATA.mails[$editor.data('id')];
var actualLangId = $('#output-tabs .nav-link.active').data('lang-id');
var actualLangKey = $('#output-tabs .nav-link.active').data('lang-key');
var header = ace.edit( $('#editor-'+actualLangId+'_H')[0] ).getValue();
var footer = ace.edit( $('#editor-'+actualLangId+'_F')[0] ).getValue();


var a = window.document.createElement('a');
a.href = window.URL.createObjectURL(new Blob([header, code, footer], {type: 'text/html'}));
a.download = name + '_' + actualLangKey + '.html';
var a = window.document.createElement('a');
a.href = window.URL.createObjectURL(new Blob([header, code, footer], {type: 'text/html'}));
a.download = name + '_' + actualLangKey + '_id-' + $editor.data('id') + '.html';

// Append anchor to body.
document.body.appendChild(a);
a.click();
// Append anchor to body.
document.body.appendChild(a);
a.click();

// Remove anchor from body
document.body.removeChild(a);
});
});
// Remove anchor from body
document.body.removeChild(a);
},

preview : function () {
Expand Down

0 comments on commit 479fb3d

Please sign in to comment.