diff options
author | Jose Antonio Marquez | 2012-02-09 21:38:02 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-02-09 21:39:03 -0800 |
commit | e8f7453c2b70960c63f81b5ec81d8e642a609900 (patch) | |
tree | 3e1159e9051a3e9fde404e2637a5e9dd24752307 | |
parent | ad9b4d6c90c3a85a3687018f5ee135eea292bc2f (diff) | |
download | ninja-e8f7453c2b70960c63f81b5ec81d8e642a609900.tar.gz |
New/Open HTML document parsing
-rw-r--r-- | js/mediators/io-mediator.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index f2f2f642..630b0aa2 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -87,7 +87,13 @@ exports.IoMediator = Montage.create(Component, { | |||
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 | //TODO: Add handling for converting HTML to Ninja format |
90 | result.content = read.file.content; | 90 | if (result.extension !== 'html' && result.extension !== 'htm') { |
91 | result.content = read.file.content; | ||
92 | } else { | ||
93 | // | ||
94 | result.content = this.parseHtmlToNinjaTemplate(read.file.content); | ||
95 | } | ||
96 | |||
91 | result.status = read.status; | 97 | result.status = read.status; |
92 | // | 98 | // |
93 | if (callback) callback(result); | 99 | if (callback) callback(result); |
@@ -140,6 +146,20 @@ exports.IoMediator = Montage.create(Component, { | |||
140 | value: function (file, copy, callback) { | 146 | value: function (file, copy, callback) { |
141 | // | 147 | // |
142 | } | 148 | } |
149 | }, | ||
150 | //////////////////////////////////////////////////////////////////// | ||
151 | // | ||
152 | parseHtmlToNinjaTemplate: { | ||
153 | enumerable: false, | ||
154 | value: function (html) { | ||
155 | var doc = window.document.implementation.createHTMLDocument(), template; | ||
156 | // | ||
157 | doc.getElementsByTagName('html')[0].innerHTML = html; | ||
158 | template = {head: doc.head, body: doc.body, document: doc}; | ||
159 | doc = null; | ||
160 | // | ||
161 | return template; | ||
162 | } | ||
143 | } | 163 | } |
144 | //////////////////////////////////////////////////////////////////// | 164 | //////////////////////////////////////////////////////////////////// |
145 | }); | 165 | }); |