plugins saver method updated (#87)

* changed parsing method. Now data parses data like sample.json

* saver module

* upgraded plugins
This commit is contained in:
khaydarov 2016-07-16 01:37:01 +03:00 committed by Peter Savchenko
parent b0d3907793
commit f3d70c8724
6 changed files with 59 additions and 53 deletions

View file

@ -39,14 +39,15 @@ var codeTool = {
/**
* Method to extract JSON data from HTML block
*/
save : function (block){
save : function (blockContent){
var json = {
type : 'code',
data : {
text : null,
}
};
var block = blockContent[0];
json = {
type : 'code',
data : {
text : null,
}
};
json.data.text = block.innerHTML;

View file

@ -52,15 +52,16 @@ var headerTool = {
/**
* Method to extract JSON data from HTML block
*/
save : function (block){
save : function (blockContent) {
var json = {
type : 'header',
data : {
type : null,
text : null,
}
};
var block = blockContent[0],
json = {
type : 'header',
data : {
type : null,
text : null,
}
};
json.data.type = block.dataset.headerData;
json.data.text = block.textContent;

View file

@ -64,20 +64,21 @@ var linkTool = {
/**
* Method to extract JSON data from HTML block
*/
save : function (block){
save : function (blockContent){
var linkElement = linkTool.elementClasses.link;
var json = {
type : 'link',
data : {
fullLink : block.querySelector("." + linkElement).href,
shortLink : block.querySelector("." + linkElement).textContent,
image : block.querySelector("." + linkTool.elementClasses.image).src,
title : block.querySelector("." + linkTool.elementClasses.title).textContent,
description : block.querySelector("." + linkTool.elementClasses.description).textContent
}
};
var block = blockContent[0],
json = {
type : 'link',
data : {
fullLink : block.querySelector("." + linkElement).href,
shortLink : block.querySelector("." + linkElement).textContent,
image : block.querySelector("." + linkTool.elementClasses.image).src,
title : block.querySelector("." + linkTool.elementClasses.title).textContent,
description : block.querySelector("." + linkTool.elementClasses.description).textContent
}
};
return json;

View file

@ -54,15 +54,16 @@ var listTool = {
/**
* Method to extract JSON data from HTML block
*/
save : function (block){
save : function (blockContent){
var json = {
type : 'list',
data : {
type : null,
items : [],
}
};
var block = blockContent[0],
json = {
type : 'list',
data : {
type : null,
items : [],
}
};
for(var index = 0; index < block.childNodes.length; index++)
json.data.items[index] = block.childNodes[index].textContent;

View file

@ -35,14 +35,15 @@ var paragraphTool = {
/**
* Method to extract JSON data from HTML block
*/
save : function (block){
save : function (blockContent){
var json = {
type : 'paragraph',
data : {
text : null,
}
};
var block = blockContent[0],
json = {
type : 'paragraph',
data : {
text : null,
}
};
json.data.text = block.innerHTML;
return json;

View file

@ -45,24 +45,25 @@ var quoteTools = {
return quoteTools.makeBlockToAppend(data);
},
save : function(block) {
save : function(blockContent) {
/**
* Extracts JSON quote data from HTML block
* @param {Text} text, {Text} author, {Object} photo
*/
parsedblock = quoteTools.parseBlockQuote(block);
parsedblock = quoteTools.parseBlockQuote(blockContent);
var json = {
type : 'quote',
data : {
style : parsedblock.style,
text : parsedblock.text,
author : parsedblock.author,
job : parsedblock.job,
photo : parsedblock.photo,
}
};
var block = blockContent[0],
json = {
type : 'quote',
data : {
style : parsedblock.style,
text : parsedblock.text,
author : parsedblock.author,
job : parsedblock.job,
photo : parsedblock.photo,
}
};
return json;
},