From e8f7453c2b70960c63f81b5ec81d8e642a609900 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 9 Feb 2012 21:38:02 -0800 Subject: New/Open HTML document parsing --- js/mediators/io-mediator.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'js/mediators/io-mediator.js') 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, { //Creating and formatting result object for callbak result = read.file.details; //TODO: Add handling for converting HTML to Ninja format - result.content = read.file.content; + if (result.extension !== 'html' && result.extension !== 'htm') { + result.content = read.file.content; + } else { + // + result.content = this.parseHtmlToNinjaTemplate(read.file.content); + } + result.status = read.status; // if (callback) callback(result); @@ -140,6 +146,20 @@ exports.IoMediator = Montage.create(Component, { value: function (file, copy, callback) { // } + }, + //////////////////////////////////////////////////////////////////// + // + parseHtmlToNinjaTemplate: { + enumerable: false, + value: function (html) { + var doc = window.document.implementation.createHTMLDocument(), template; + // + doc.getElementsByTagName('html')[0].innerHTML = html; + template = {head: doc.head, body: doc.body, document: doc}; + doc = null; + // + return template; + } } //////////////////////////////////////////////////////////////////// }); -- cgit v1.2.3 From fbe830fabe497d01f4f2eaddb867161a8187c101 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 9 Feb 2012 23:42:04 -0800 Subject: Adding download cloud app UI --- js/mediators/io-mediator.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 630b0aa2..2f286e5e 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -86,16 +86,17 @@ exports.IoMediator = Montage.create(Component, { case 204: //Creating and formatting result object for callbak result = read.file.details; - //TODO: Add handling for converting HTML to Ninja format + //Checking for type of content to returns if (result.extension !== 'html' && result.extension !== 'htm') { + //Simple string result.content = read.file.content; } else { - // + //Object to be used by Ninja Template result.content = this.parseHtmlToNinjaTemplate(read.file.content); } - + //Status of call result.status = read.status; - // + //Calling back with result if (callback) callback(result); break; case 404: @@ -143,7 +144,7 @@ exports.IoMediator = Montage.create(Component, { // fileSaveAs: { enumerable: false, - value: function (file, copy, callback) { + value: function (copyTo, copyFrom, callback) { // } }, @@ -152,13 +153,12 @@ exports.IoMediator = Montage.create(Component, { parseHtmlToNinjaTemplate: { enumerable: false, value: function (html) { + //Creating temp object to mimic HTML var doc = window.document.implementation.createHTMLDocument(), template; - // + //Setting content to temp doc.getElementsByTagName('html')[0].innerHTML = html; - template = {head: doc.head, body: doc.body, document: doc}; - doc = null; - // - return template; + //Creating return object + return {head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc}; } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3