diff --git a/content/src/controller.js b/content/src/controller.js index 73f5d5dc..347b6854 100644 --- a/content/src/controller.js +++ b/content/src/controller.js @@ -170,7 +170,9 @@ function updateTopControls(addHistory) { label: 'Save', menu: [ { id: 'save2', label: 'Save' }, - { id: 'saveas', label: 'Copy and Save As...' } + { id: 'saveas', label: 'Copy and Save As...' }, + { id: 'download',label: 'Save code on local machine'}, + { id: 'download1', label: 'Download Html and Css'} ], disabled: !cansave(), }, { @@ -523,6 +525,16 @@ $(window).on('beforeunload', function() { return "There are unsaved changes." } }); +//Saves the Main code on our local machine +view.on('download', function() { +uriContent = "data:application/octet-stream," + encodeURIComponent("Main Code"+"\n\n"+newdata.data); +window.open(uriContent, 'neuesDokument'); +}); +//Saves HTML and CSS on your local machine +view.on('download1', function() { + urlContent = "data:application/octet-stream," + encodeURIComponent("HTML"+"\n\n"+window.downloadhtml+"\n\n"+"CSS"+"\n\n"+window.downloadcss); +window.open(urlContent, 'neuesDokument'); +}); view.on('logout', function() { model.username = null; diff --git a/content/src/view.js b/content/src/view.js index 1b9c6cca..3425f114 100644 --- a/content/src/view.js +++ b/content/src/view.js @@ -18,7 +18,8 @@ function htmlEscape(s) { return s.replace(/[<>&"]/g, function(c) { return c=='<'?'<':c=='>'?'>':c=='&'?'&':'"';}); } - +var downloadhtml; +var downloadcss; // The view has three panes, #left, #right, and #back (the offscreen pane). // // Any of the three panes can show: @@ -2924,9 +2925,11 @@ function updateMeta(paneState) { // Grab the html and the CSS from the editors. if (paneState.htmlEditor) { paneState.meta.html = paneState.htmlEditor.getValue(); + window.downloadhtml=paneState.meta.html; } if (paneState.cssEditor) { paneState.meta.css = paneState.cssEditor.getValue(); + window.downloadcss=paneState.meta.css; } } function getPaneEditorData(pane) {