diff options
Diffstat (limited to 'js/mediators')
-rw-r--r-- | js/mediators/io-mediator.js | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index f2f2f642..2f286e5e 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -86,10 +86,17 @@ exports.IoMediator = Montage.create(Component, { | |||
86 | case 204: | 86 | case 204: |
87 | //Creating and formatting result object for callbak | 87 | //Creating and formatting result object for callbak |
88 | result = read.file.details; | 88 | result = read.file.details; |
89 | //TODO: Add handling for converting HTML to Ninja format | 89 | //Checking for type of content to returns |
90 | result.content = read.file.content; | 90 | if (result.extension !== 'html' && result.extension !== 'htm') { |
91 | //Simple string | ||
92 | result.content = read.file.content; | ||
93 | } else { | ||
94 | //Object to be used by Ninja Template | ||
95 | result.content = this.parseHtmlToNinjaTemplate(read.file.content); | ||
96 | } | ||
97 | //Status of call | ||
91 | result.status = read.status; | 98 | result.status = read.status; |
92 | // | 99 | //Calling back with result |
93 | if (callback) callback(result); | 100 | if (callback) callback(result); |
94 | break; | 101 | break; |
95 | case 404: | 102 | case 404: |
@@ -137,9 +144,22 @@ exports.IoMediator = Montage.create(Component, { | |||
137 | // | 144 | // |
138 | fileSaveAs: { | 145 | fileSaveAs: { |
139 | enumerable: false, | 146 | enumerable: false, |
140 | value: function (file, copy, callback) { | 147 | value: function (copyTo, copyFrom, callback) { |
141 | // | 148 | // |
142 | } | 149 | } |
150 | }, | ||
151 | //////////////////////////////////////////////////////////////////// | ||
152 | // | ||
153 | parseHtmlToNinjaTemplate: { | ||
154 | enumerable: false, | ||
155 | value: function (html) { | ||
156 | //Creating temp object to mimic HTML | ||
157 | var doc = window.document.implementation.createHTMLDocument(), template; | ||
158 | //Setting content to temp | ||
159 | doc.getElementsByTagName('html')[0].innerHTML = html; | ||
160 | //Creating return object | ||
161 | return {head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc}; | ||
162 | } | ||
143 | } | 163 | } |
144 | //////////////////////////////////////////////////////////////////// | 164 | //////////////////////////////////////////////////////////////////// |
145 | }); | 165 | }); |