New release

This commit is contained in:
knsv 2015-10-21 21:14:41 +02:00
parent 185233c971
commit c9d29c16e2
9 changed files with 677 additions and 16 deletions

131
dist/mermaid.js vendored
View File

@ -30976,7 +30976,7 @@ module.exports = '1.0.7';
},{}],86:[function(require,module,exports){
module.exports={
"name": "mermaid",
"version": "0.5.4",
"version": "0.5.5",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
"main": "src/mermaid.js",
"keywords": [
@ -35112,6 +35112,7 @@ exports.findTaskById = function (id) {
};
exports.getTasks = function () {
//compileTasks();
var i;
for (i = 10000; i < tasks.length; i++) {
tasks[i].startTime = moment(tasks[i].startTime).format(dateFormat);
@ -35122,6 +35123,7 @@ exports.getTasks = function () {
};
var getStartDate = function getStartDate(prevTime, dateFormat, str) {
//console.log('Deciding start date:'+JSON.stringify(str));
//log.debug('Deciding start date:'+str);
//log.debug('with dateformat:'+dateFormat);
@ -35130,12 +35132,15 @@ var getStartDate = function getStartDate(prevTime, dateFormat, str) {
// Test for after
var re = /^after\s+([\d\w\-]+)/;
var afterStatement = re.exec(str.trim());
if (afterStatement !== null) {
var task = exports.findTaskById(afterStatement[1]);
//console.log('xxx'+JSON.stringify(task));
if (typeof task === 'undefined') {
var dt = new Date();
dt.setHours(0, 0, 0, 0);
return dt;
//return undefined;
}
return task.endTime;
}
@ -35272,7 +35277,95 @@ var compileData = function compileData(prevTask, dataStr) {
return task;
};
var parseData = function parseData(dataStr) {
var ds;
if (dataStr.substr(0, 1) === ':') {
ds = dataStr.substr(1, dataStr.length);
} else {
ds = dataStr;
}
var data = ds.split(',');
var task = {};
var df = exports.getDateFormat();
// Get tags like active, done cand crit
var matchFound = true;
while (matchFound) {
matchFound = false;
if (data[0].match(/^\s*active\s*$/)) {
task.active = true;
data.shift(1);
matchFound = true;
}
if (data[0].match(/^\s*done\s*$/)) {
task.done = true;
data.shift(1);
matchFound = true;
}
if (data[0].match(/^\s*crit\s*$/)) {
task.crit = true;
data.shift(1);
matchFound = true;
}
}
var i;
for (i = 0; i < data.length; i++) {
data[i] = data[i].trim();
}
switch (data.length) {
case 1:
task.id = parseId();
task.startTime = { type: 'prevTaskEnd' };
task.endTime = { data: data[0] };
break;
case 2:
task.id = parseId();
task.startTime = { type: 'getStartDate', startData: data[0] };
task.endTime = { data: data[1] };
break;
case 3:
task.id = parseId(data[0]);
task.startTime = { type: 'getStartDate', startData: data[1] };
task.endTime = { data: data[2] };
break;
default:
}
return task;
};
var lastTask;
var lastTaskID;
var rawTasks = [];
var taskDb = {};
exports.addTaskNew = function (descr, data) {
var rawTask = {
section: currentSection,
type: currentSection,
description: descr,
processed: false,
raw: { data: data }
};
var taskInfo = parseData(data);
rawTask.raw.startTime = taskInfo.startTime;
rawTask.raw.endTime = taskInfo.endTime;
rawTask.id = taskInfo.id;
rawTask.prevTaskId = lastTaskID;
rawTask.active = taskInfo.active;
rawTask.done = taskInfo.done;
rawTask.crit = taskInfo.crit;
var pos = rawTasks.push(rawTask);
lastTaskID = rawTask.id;
// Store cross ref
taskDb[rawTask.id] = pos;
};
exports.addTask = function (descr, data) {
var newTask = {
@ -35292,6 +35385,40 @@ exports.addTask = function (descr, data) {
tasks.push(newTask);
};
var compileTasks = function compileTasks() {
console.log('Compiling tasks' + rawTasks.length);
var df = exports.getDateFormat();
var compileTask = function compileTask(pos) {
var task = rawTasks[pos];
var startTime = '';
switch (rawTasks[pos].raw.startTime.type) {
case 'prevTaskEnd':
rawTasks[pos].startTime = rawTasks[taskDb[pos].prevTaskId].endTime;
break;
case 'getStartDate':
var startTime = getStartDate(undefined, df, rawTasks[pos].raw.startTime.startData);
if (startTime) {
rawTasks[pos].startTime = startTime;
}
break;
}
if (rawTasks[pos].startTime) {
rawTasks[pos].endTime = getEndDate(rawTasks[pos].startTime, df, rawTasks[pos].raw.endTime.data);
}
};
var i;
for (i = 0; i < rawTasks.length; i++) {
console.log('Pre ompiling: ' + JSON.stringify(rawTasks[i]));
compileTask(i);
//console.log('Compiling: '+rawTasks[taskDb[i]].id);
console.log('Compiling: ' + JSON.stringify(rawTasks[i], null, 2));
}
};
exports.parseError = function (err, hash) {
global.mermaidAPI.parseError(err, hash);
};
@ -37502,7 +37629,7 @@ var drawMessage = function drawMessage(elem, startx, stopx, verticalPos, msg) {
line.attr('stroke', 'black');
line.style('fill', 'none'); // remove any fill colour
if (msg.type === sq.yy.LINETYPE.SOLID || msg.type === sq.yy.LINETYPE.DOTTED) {
line.attr('marker-end', 'url(' + url + '#crosshead)');
line.attr('marker-end', 'url(' + url + '#arrowhead)');
}
if (msg.type === sq.yy.LINETYPE.SOLID_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_CROSS) {

8
dist/mermaid.min.js vendored

File diff suppressed because one or more lines are too long

131
dist/mermaid.slim.js vendored
View File

@ -21471,7 +21471,7 @@ module.exports = '1.0.7';
},{}],85:[function(require,module,exports){
module.exports={
"name": "mermaid",
"version": "0.5.4",
"version": "0.5.5",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
"main": "src/mermaid.js",
"keywords": [
@ -25607,6 +25607,7 @@ exports.findTaskById = function (id) {
};
exports.getTasks = function () {
//compileTasks();
var i;
for (i = 10000; i < tasks.length; i++) {
tasks[i].startTime = moment(tasks[i].startTime).format(dateFormat);
@ -25617,6 +25618,7 @@ exports.getTasks = function () {
};
var getStartDate = function getStartDate(prevTime, dateFormat, str) {
//console.log('Deciding start date:'+JSON.stringify(str));
//log.debug('Deciding start date:'+str);
//log.debug('with dateformat:'+dateFormat);
@ -25625,12 +25627,15 @@ var getStartDate = function getStartDate(prevTime, dateFormat, str) {
// Test for after
var re = /^after\s+([\d\w\-]+)/;
var afterStatement = re.exec(str.trim());
if (afterStatement !== null) {
var task = exports.findTaskById(afterStatement[1]);
//console.log('xxx'+JSON.stringify(task));
if (typeof task === 'undefined') {
var dt = new Date();
dt.setHours(0, 0, 0, 0);
return dt;
//return undefined;
}
return task.endTime;
}
@ -25767,7 +25772,95 @@ var compileData = function compileData(prevTask, dataStr) {
return task;
};
var parseData = function parseData(dataStr) {
var ds;
if (dataStr.substr(0, 1) === ':') {
ds = dataStr.substr(1, dataStr.length);
} else {
ds = dataStr;
}
var data = ds.split(',');
var task = {};
var df = exports.getDateFormat();
// Get tags like active, done cand crit
var matchFound = true;
while (matchFound) {
matchFound = false;
if (data[0].match(/^\s*active\s*$/)) {
task.active = true;
data.shift(1);
matchFound = true;
}
if (data[0].match(/^\s*done\s*$/)) {
task.done = true;
data.shift(1);
matchFound = true;
}
if (data[0].match(/^\s*crit\s*$/)) {
task.crit = true;
data.shift(1);
matchFound = true;
}
}
var i;
for (i = 0; i < data.length; i++) {
data[i] = data[i].trim();
}
switch (data.length) {
case 1:
task.id = parseId();
task.startTime = { type: 'prevTaskEnd' };
task.endTime = { data: data[0] };
break;
case 2:
task.id = parseId();
task.startTime = { type: 'getStartDate', startData: data[0] };
task.endTime = { data: data[1] };
break;
case 3:
task.id = parseId(data[0]);
task.startTime = { type: 'getStartDate', startData: data[1] };
task.endTime = { data: data[2] };
break;
default:
}
return task;
};
var lastTask;
var lastTaskID;
var rawTasks = [];
var taskDb = {};
exports.addTaskNew = function (descr, data) {
var rawTask = {
section: currentSection,
type: currentSection,
description: descr,
processed: false,
raw: { data: data }
};
var taskInfo = parseData(data);
rawTask.raw.startTime = taskInfo.startTime;
rawTask.raw.endTime = taskInfo.endTime;
rawTask.id = taskInfo.id;
rawTask.prevTaskId = lastTaskID;
rawTask.active = taskInfo.active;
rawTask.done = taskInfo.done;
rawTask.crit = taskInfo.crit;
var pos = rawTasks.push(rawTask);
lastTaskID = rawTask.id;
// Store cross ref
taskDb[rawTask.id] = pos;
};
exports.addTask = function (descr, data) {
var newTask = {
@ -25787,6 +25880,40 @@ exports.addTask = function (descr, data) {
tasks.push(newTask);
};
var compileTasks = function compileTasks() {
console.log('Compiling tasks' + rawTasks.length);
var df = exports.getDateFormat();
var compileTask = function compileTask(pos) {
var task = rawTasks[pos];
var startTime = '';
switch (rawTasks[pos].raw.startTime.type) {
case 'prevTaskEnd':
rawTasks[pos].startTime = rawTasks[taskDb[pos].prevTaskId].endTime;
break;
case 'getStartDate':
var startTime = getStartDate(undefined, df, rawTasks[pos].raw.startTime.startData);
if (startTime) {
rawTasks[pos].startTime = startTime;
}
break;
}
if (rawTasks[pos].startTime) {
rawTasks[pos].endTime = getEndDate(rawTasks[pos].startTime, df, rawTasks[pos].raw.endTime.data);
}
};
var i;
for (i = 0; i < rawTasks.length; i++) {
console.log('Pre ompiling: ' + JSON.stringify(rawTasks[i]));
compileTask(i);
//console.log('Compiling: '+rawTasks[taskDb[i]].id);
console.log('Compiling: ' + JSON.stringify(rawTasks[i], null, 2));
}
};
exports.parseError = function (err, hash) {
global.mermaidAPI.parseError(err, hash);
};
@ -27997,7 +28124,7 @@ var drawMessage = function drawMessage(elem, startx, stopx, verticalPos, msg) {
line.attr('stroke', 'black');
line.style('fill', 'none'); // remove any fill colour
if (msg.type === sq.yy.LINETYPE.SOLID || msg.type === sq.yy.LINETYPE.DOTTED) {
line.attr('marker-end', 'url(' + url + '#crosshead)');
line.attr('marker-end', 'url(' + url + '#arrowhead)');
}
if (msg.type === sq.yy.LINETYPE.SOLID_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_CROSS) {

131
dist/mermaidAPI.js vendored
View File

@ -30643,7 +30643,7 @@ module.exports = '1.0.7';
},{}],85:[function(require,module,exports){
module.exports={
"name": "mermaid",
"version": "0.5.4",
"version": "0.5.5",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
"main": "src/mermaid.js",
"keywords": [
@ -34779,6 +34779,7 @@ exports.findTaskById = function (id) {
};
exports.getTasks = function () {
//compileTasks();
var i;
for (i = 10000; i < tasks.length; i++) {
tasks[i].startTime = moment(tasks[i].startTime).format(dateFormat);
@ -34789,6 +34790,7 @@ exports.getTasks = function () {
};
var getStartDate = function getStartDate(prevTime, dateFormat, str) {
//console.log('Deciding start date:'+JSON.stringify(str));
//log.debug('Deciding start date:'+str);
//log.debug('with dateformat:'+dateFormat);
@ -34797,12 +34799,15 @@ var getStartDate = function getStartDate(prevTime, dateFormat, str) {
// Test for after
var re = /^after\s+([\d\w\-]+)/;
var afterStatement = re.exec(str.trim());
if (afterStatement !== null) {
var task = exports.findTaskById(afterStatement[1]);
//console.log('xxx'+JSON.stringify(task));
if (typeof task === 'undefined') {
var dt = new Date();
dt.setHours(0, 0, 0, 0);
return dt;
//return undefined;
}
return task.endTime;
}
@ -34939,7 +34944,95 @@ var compileData = function compileData(prevTask, dataStr) {
return task;
};
var parseData = function parseData(dataStr) {
var ds;
if (dataStr.substr(0, 1) === ':') {
ds = dataStr.substr(1, dataStr.length);
} else {
ds = dataStr;
}
var data = ds.split(',');
var task = {};
var df = exports.getDateFormat();
// Get tags like active, done cand crit
var matchFound = true;
while (matchFound) {
matchFound = false;
if (data[0].match(/^\s*active\s*$/)) {
task.active = true;
data.shift(1);
matchFound = true;
}
if (data[0].match(/^\s*done\s*$/)) {
task.done = true;
data.shift(1);
matchFound = true;
}
if (data[0].match(/^\s*crit\s*$/)) {
task.crit = true;
data.shift(1);
matchFound = true;
}
}
var i;
for (i = 0; i < data.length; i++) {
data[i] = data[i].trim();
}
switch (data.length) {
case 1:
task.id = parseId();
task.startTime = { type: 'prevTaskEnd' };
task.endTime = { data: data[0] };
break;
case 2:
task.id = parseId();
task.startTime = { type: 'getStartDate', startData: data[0] };
task.endTime = { data: data[1] };
break;
case 3:
task.id = parseId(data[0]);
task.startTime = { type: 'getStartDate', startData: data[1] };
task.endTime = { data: data[2] };
break;
default:
}
return task;
};
var lastTask;
var lastTaskID;
var rawTasks = [];
var taskDb = {};
exports.addTaskNew = function (descr, data) {
var rawTask = {
section: currentSection,
type: currentSection,
description: descr,
processed: false,
raw: { data: data }
};
var taskInfo = parseData(data);
rawTask.raw.startTime = taskInfo.startTime;
rawTask.raw.endTime = taskInfo.endTime;
rawTask.id = taskInfo.id;
rawTask.prevTaskId = lastTaskID;
rawTask.active = taskInfo.active;
rawTask.done = taskInfo.done;
rawTask.crit = taskInfo.crit;
var pos = rawTasks.push(rawTask);
lastTaskID = rawTask.id;
// Store cross ref
taskDb[rawTask.id] = pos;
};
exports.addTask = function (descr, data) {
var newTask = {
@ -34959,6 +35052,40 @@ exports.addTask = function (descr, data) {
tasks.push(newTask);
};
var compileTasks = function compileTasks() {
console.log('Compiling tasks' + rawTasks.length);
var df = exports.getDateFormat();
var compileTask = function compileTask(pos) {
var task = rawTasks[pos];
var startTime = '';
switch (rawTasks[pos].raw.startTime.type) {
case 'prevTaskEnd':
rawTasks[pos].startTime = rawTasks[taskDb[pos].prevTaskId].endTime;
break;
case 'getStartDate':
var startTime = getStartDate(undefined, df, rawTasks[pos].raw.startTime.startData);
if (startTime) {
rawTasks[pos].startTime = startTime;
}
break;
}
if (rawTasks[pos].startTime) {
rawTasks[pos].endTime = getEndDate(rawTasks[pos].startTime, df, rawTasks[pos].raw.endTime.data);
}
};
var i;
for (i = 0; i < rawTasks.length; i++) {
console.log('Pre ompiling: ' + JSON.stringify(rawTasks[i]));
compileTask(i);
//console.log('Compiling: '+rawTasks[taskDb[i]].id);
console.log('Compiling: ' + JSON.stringify(rawTasks[i], null, 2));
}
};
exports.parseError = function (err, hash) {
global.mermaidAPI.parseError(err, hash);
};
@ -37169,7 +37296,7 @@ var drawMessage = function drawMessage(elem, startx, stopx, verticalPos, msg) {
line.attr('stroke', 'black');
line.style('fill', 'none'); // remove any fill colour
if (msg.type === sq.yy.LINETYPE.SOLID || msg.type === sq.yy.LINETYPE.DOTTED) {
line.attr('marker-end', 'url(' + url + '#crosshead)');
line.attr('marker-end', 'url(' + url + '#arrowhead)');
}
if (msg.type === sq.yy.LINETYPE.SOLID_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_CROSS) {

View File

@ -21138,7 +21138,7 @@ module.exports = '1.0.7';
},{}],84:[function(require,module,exports){
module.exports={
"name": "mermaid",
"version": "0.5.4",
"version": "0.5.5",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
"main": "src/mermaid.js",
"keywords": [
@ -25274,6 +25274,7 @@ exports.findTaskById = function (id) {
};
exports.getTasks = function () {
//compileTasks();
var i;
for (i = 10000; i < tasks.length; i++) {
tasks[i].startTime = moment(tasks[i].startTime).format(dateFormat);
@ -25284,6 +25285,7 @@ exports.getTasks = function () {
};
var getStartDate = function getStartDate(prevTime, dateFormat, str) {
//console.log('Deciding start date:'+JSON.stringify(str));
//log.debug('Deciding start date:'+str);
//log.debug('with dateformat:'+dateFormat);
@ -25292,12 +25294,15 @@ var getStartDate = function getStartDate(prevTime, dateFormat, str) {
// Test for after
var re = /^after\s+([\d\w\-]+)/;
var afterStatement = re.exec(str.trim());
if (afterStatement !== null) {
var task = exports.findTaskById(afterStatement[1]);
//console.log('xxx'+JSON.stringify(task));
if (typeof task === 'undefined') {
var dt = new Date();
dt.setHours(0, 0, 0, 0);
return dt;
//return undefined;
}
return task.endTime;
}
@ -25434,7 +25439,95 @@ var compileData = function compileData(prevTask, dataStr) {
return task;
};
var parseData = function parseData(dataStr) {
var ds;
if (dataStr.substr(0, 1) === ':') {
ds = dataStr.substr(1, dataStr.length);
} else {
ds = dataStr;
}
var data = ds.split(',');
var task = {};
var df = exports.getDateFormat();
// Get tags like active, done cand crit
var matchFound = true;
while (matchFound) {
matchFound = false;
if (data[0].match(/^\s*active\s*$/)) {
task.active = true;
data.shift(1);
matchFound = true;
}
if (data[0].match(/^\s*done\s*$/)) {
task.done = true;
data.shift(1);
matchFound = true;
}
if (data[0].match(/^\s*crit\s*$/)) {
task.crit = true;
data.shift(1);
matchFound = true;
}
}
var i;
for (i = 0; i < data.length; i++) {
data[i] = data[i].trim();
}
switch (data.length) {
case 1:
task.id = parseId();
task.startTime = { type: 'prevTaskEnd' };
task.endTime = { data: data[0] };
break;
case 2:
task.id = parseId();
task.startTime = { type: 'getStartDate', startData: data[0] };
task.endTime = { data: data[1] };
break;
case 3:
task.id = parseId(data[0]);
task.startTime = { type: 'getStartDate', startData: data[1] };
task.endTime = { data: data[2] };
break;
default:
}
return task;
};
var lastTask;
var lastTaskID;
var rawTasks = [];
var taskDb = {};
exports.addTaskNew = function (descr, data) {
var rawTask = {
section: currentSection,
type: currentSection,
description: descr,
processed: false,
raw: { data: data }
};
var taskInfo = parseData(data);
rawTask.raw.startTime = taskInfo.startTime;
rawTask.raw.endTime = taskInfo.endTime;
rawTask.id = taskInfo.id;
rawTask.prevTaskId = lastTaskID;
rawTask.active = taskInfo.active;
rawTask.done = taskInfo.done;
rawTask.crit = taskInfo.crit;
var pos = rawTasks.push(rawTask);
lastTaskID = rawTask.id;
// Store cross ref
taskDb[rawTask.id] = pos;
};
exports.addTask = function (descr, data) {
var newTask = {
@ -25454,6 +25547,40 @@ exports.addTask = function (descr, data) {
tasks.push(newTask);
};
var compileTasks = function compileTasks() {
console.log('Compiling tasks' + rawTasks.length);
var df = exports.getDateFormat();
var compileTask = function compileTask(pos) {
var task = rawTasks[pos];
var startTime = '';
switch (rawTasks[pos].raw.startTime.type) {
case 'prevTaskEnd':
rawTasks[pos].startTime = rawTasks[taskDb[pos].prevTaskId].endTime;
break;
case 'getStartDate':
var startTime = getStartDate(undefined, df, rawTasks[pos].raw.startTime.startData);
if (startTime) {
rawTasks[pos].startTime = startTime;
}
break;
}
if (rawTasks[pos].startTime) {
rawTasks[pos].endTime = getEndDate(rawTasks[pos].startTime, df, rawTasks[pos].raw.endTime.data);
}
};
var i;
for (i = 0; i < rawTasks.length; i++) {
console.log('Pre ompiling: ' + JSON.stringify(rawTasks[i]));
compileTask(i);
//console.log('Compiling: '+rawTasks[taskDb[i]].id);
console.log('Compiling: ' + JSON.stringify(rawTasks[i], null, 2));
}
};
exports.parseError = function (err, hash) {
global.mermaidAPI.parseError(err, hash);
};
@ -27664,7 +27791,7 @@ var drawMessage = function drawMessage(elem, startx, stopx, verticalPos, msg) {
line.attr('stroke', 'black');
line.style('fill', 'none'); // remove any fill colour
if (msg.type === sq.yy.LINETYPE.SOLID || msg.type === sq.yy.LINETYPE.DOTTED) {
line.attr('marker-end', 'url(' + url + '#crosshead)');
line.attr('marker-end', 'url(' + url + '#arrowhead)');
}
if (msg.type === sq.yy.LINETYPE.SOLID_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_CROSS) {

View File

@ -1,6 +1,6 @@
{
"name": "mermaid",
"version": "0.5.4",
"version": "0.5.5",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
"main": "src/mermaid.js",
"keywords": [

View File

@ -51,6 +51,7 @@ exports.findTaskById = function(id) {
};
exports.getTasks=function(){
//compileTasks();
var i;
for(i=10000;i<tasks.length;i++){
tasks[i].startTime = moment(tasks[i].startTime).format(dateFormat);
@ -62,6 +63,7 @@ exports.getTasks=function(){
var getStartDate = function(prevTime, dateFormat, str){
//console.log('Deciding start date:'+JSON.stringify(str));
//log.debug('Deciding start date:'+str);
//log.debug('with dateformat:'+dateFormat);
@ -70,12 +72,15 @@ var getStartDate = function(prevTime, dateFormat, str){
// Test for after
var re = /^after\s+([\d\w\-]+)/;
var afterStatement = re.exec(str.trim());
if(afterStatement!==null){
var task = exports.findTaskById(afterStatement[1]);
//console.log('xxx'+JSON.stringify(task));
if(typeof task === 'undefined'){
var dt = new Date();
dt.setHours(0,0,0,0);
return dt;
//return undefined;
}
return task.endTime;
}
@ -217,8 +222,103 @@ var compileData = function(prevTask, dataStr){
return task;
};
var parseData = function(dataStr){
var ds;
if(dataStr.substr(0,1) === ':'){
ds = dataStr.substr(1,dataStr.length);
}
else{
ds=dataStr;
}
var data = ds.split(',');
var task = {};
var df = exports.getDateFormat();
// Get tags like active, done cand crit
var matchFound = true;
while(matchFound){
matchFound = false;
if(data[0].match(/^\s*active\s*$/)){
task.active = true;
data.shift(1);
matchFound = true;
}
if(data[0].match(/^\s*done\s*$/)){
task.done = true;
data.shift(1);
matchFound = true;
}
if(data[0].match(/^\s*crit\s*$/)){
task.crit = true;
data.shift(1);
matchFound = true;
}
}
var i;
for(i=0;i<data.length;i++){
data[i] = data[i].trim();
}
switch(data.length){
case 1:
task.id = parseId();
task.startTime = {type: 'prevTaskEnd'};
task.endTime = {data: data[0]};
break;
case 2:
task.id = parseId();
task.startTime = {type:'getStartDate',startData:data[0]};
task.endTime = {data: data[1]};
break;
case 3:
task.id = parseId(data[0]);
task.startTime = {type:'getStartDate',startData: data[1]};
task.endTime = {data: data[2]};
break;
default:
}
return task;
};
var lastTask;
var lastTaskID;
var rawTasks = [];
var taskDb = {};
exports.addTaskNew = function(descr,data){
var rawTask = {
section:currentSection,
type:currentSection,
description:descr,
processed:false,
raw:{data:data}
};
var taskInfo = parseData(data);
rawTask.raw.startTime = taskInfo.startTime;
rawTask.raw.endTime = taskInfo.endTime;
rawTask.id = taskInfo.id;
rawTask.prevTaskId = lastTaskID;
rawTask.active = taskInfo.active;
rawTask.done = taskInfo.done;
rawTask.crit = taskInfo.crit;
var pos = rawTasks.push(rawTask);
lastTaskID = rawTask.id;
// Store cross ref
taskDb[rawTask.id]= pos;
};
exports.addTask = function(descr,data){
var newTask = {
@ -238,6 +338,41 @@ exports.addTask = function(descr,data){
tasks.push(newTask);
};
var compileTasks=function(){
console.log('Compiling tasks'+rawTasks.length);
var df = exports.getDateFormat();
var compileTask = function(pos){
var task = rawTasks[pos];
var startTime = '';
switch(rawTasks[pos].raw.startTime.type){
case 'prevTaskEnd':
rawTasks[pos].startTime = rawTasks[taskDb[pos].prevTaskId].endTime;
break;
case 'getStartDate':
var startTime = getStartDate(undefined, df, rawTasks[pos].raw.startTime.startData);
if(startTime){
rawTasks[pos].startTime = startTime;
}
break;
}
if(rawTasks[pos].startTime){
rawTasks[pos].endTime = getEndDate(rawTasks[pos].startTime, df, rawTasks[pos].raw.endTime.data);
}
};
var i;
for(i=0;i<rawTasks.length;i++){
console.log('Pre ompiling: '+JSON.stringify(rawTasks[i]));
compileTask(i);
//console.log('Compiling: '+rawTasks[taskDb[i]].id);
console.log('Compiling: '+JSON.stringify(rawTasks[i],null,2));
}
};
exports.parseError = function(err,hash){
global.mermaidAPI.parseError(err,hash);
};

View File

@ -1,14 +1,13 @@
/**
* Created by knut on 14-11-18.
*/
//var log = require('../../logger').create();
describe('when using the ganttDb',function() {
var gDb;
var moment = require('moment');
beforeEach(function () {
//gantt = require('./parser/gantt').parser;
gDb = require('./ganttDb');
gDb.clear();
//ex.yy.parseError = parseError;
@ -159,6 +158,24 @@ describe('when using the ganttDb',function() {
expect(tasks[1].id ).toEqual('task1');
expect(tasks[1].description).toEqual('test2');
});
xit('should handle relative start date based on id regardless of sections', function () {
gDb.setDateFormat('YYYY-MM-DD');
gDb.addSection('testa1');
gDb.addTask('test1','id1,2013-01-01,2w');
gDb.addTask('test2','id2,after id3,1d');
gDb.addSection('testa2');
gDb.addTask('test3','id3,after id1,2d');
var tasks = gDb.getTasks();
expect(tasks[1].startTime ).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate());
expect(tasks[1].id ).toEqual('id2');
expect(tasks[1].description).toEqual('test2');
expect(tasks[2].id ).toEqual('id3');
expect(tasks[2].description).toEqual('test3');
expect(tasks[2].startTime ).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate());
});
});

View File

@ -13,7 +13,8 @@
flowchart:{
useMaxWidth:false,
htmlLabels:true
}
},
logLevel:5
};
mermaid.initialize(config);
</script>