From 6416824523266257598e63343ff7b0daadffd2e9 Mon Sep 17 00:00:00 2001 From: Amay Agrawal Date: Fri, 25 Dec 2015 04:57:07 +0530 Subject: [PATCH 1/2] Update view.js Here i have declared two varables downloadhtml and downloadcss and get their respective content of html and css in them --- content/src/view.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) { From 3ab53aeb1a7f8629a398104a9adbcc344e49ca34 Mon Sep 17 00:00:00 2001 From: Amay Agrawal Date: Fri, 25 Dec 2015 05:11:03 +0530 Subject: [PATCH 2/2] Update controller.js Here I have defined two functions one for downloading main code and other for downloading html and css on our local machine. --- content/src/controller.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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;