Fix for defect #158

This commit is contained in:
knsv
2015-04-20 21:21:17 +02:00
parent f310eb0574
commit 2204d46ce1
13 changed files with 181 additions and 266 deletions

View File

@@ -28,18 +28,24 @@ var system = require('system')
, fs = require('fs')
, webpage = require('webpage')
var page = webpage.create()
, files = phantom.args.slice(6, phantom.args.length)
, files = phantom.args.slice(7, phantom.args.length)
, options = {
outputDir: phantom.args[0]
, png: phantom.args[1] === 'true' ? true : false
, svg: phantom.args[2] === 'true' ? true : false
, css: phantom.args[3] !== '' ? phantom.args[3] : '* { margin: 0; padding: 0; }'
, sequenceConfig: phantom.args[4]
, verbose: phantom.args[5] === 'true' ? true : false
, ganttConfig: phantom.args[5]
, verbose: phantom.args[6] === 'true' ? true : false
}
, log = logger(options.verbose)
console.log('options');
console.log(options.ganttConfig);
page.content = [
'<html>'
, '<head>'
@@ -68,8 +74,9 @@ files.forEach(function(file) {
// look like it. we need to serialize then unserialize the svgContent that's
// taken from the DOM
svgContent = page.evaluate(executeInPage, {
contents: contents,
sequenceConfig: options.sequenceConfig
contents : contents,
ganttConfig : options.ganttConfig,
sequenceConfig : options.sequenceConfig
})
oDOM = oParser.parseFromString(svgContent, "text/xml")
@@ -193,6 +200,7 @@ function executeInPage(data) {
var xmlSerializer = new XMLSerializer()
, contents = data.contents
, sequenceConfig = data.sequenceConfig
, ganttConfig = data.ganttConfig
, toRemove
, el
, elContent
@@ -221,6 +229,17 @@ function executeInPage(data) {
document.body.appendChild(sc)
}
if(typeof ganttConfig !== undefined && ganttConfig !== 'undefined'){
console.log('Got ganttConfig');
sc = document.createElement("script")
scContent = document.createTextNode('mermaid.ganttConfig = JSON.parse(' + JSON.stringify(ganttConfig) + ');')
sc.appendChild(scContent)
document.body.appendChild(sc)
}else{
console.log('No gantt config');
}
mermaid.init();
svg = document.querySelector('svg')