mermaid
Version:
Markdownish syntax for generating flowcharts
331 lines • 11.3 kB
JSON
[
{
"tags": [],
"description": {
"full": "Created by knut on 14-11-03.",
"summary": "Created by knut on 14-11-03.",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "var vertices = {};\nvar edges = [];\nvar classes = [];\nvar direction;\n// Functions to be run after graph rendering\nvar funs = [];",
"ctx": {
"type": "declaration",
"name": "vertices",
"value": "{}",
"string": "vertices"
}
},
{
"tags": [
{
"type": "param",
"types": [
"id"
],
"name": "",
"description": ""
},
{
"type": "param",
"types": [
"text"
],
"name": "",
"description": ""
},
{
"type": "param",
"types": [
"type"
],
"name": "",
"description": ""
},
{
"type": "param",
"types": [
"style"
],
"name": "",
"description": ""
}
],
"description": {
"full": "Function called by parser when a node definition has been found",
"summary": "Function called by parser when a node definition has been found",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.addVertex = function (id, text, type, style) {\n\n if(typeof id === 'undefined'){\n return;\n }\n if(id.trim().length === 0){\n return;\n }\n\n if (typeof vertices[id] === 'undefined') {\n vertices[id] = {id: id, styles: [], classes:[]};\n }\n if (typeof text !== 'undefined') {\n vertices[id].text = text;\n }\n if (typeof type !== 'undefined') {\n vertices[id].type = type;\n }\n if (typeof type !== 'undefined') {\n vertices[id].type = type;\n }\n if (typeof style !== 'undefined') {\n if (style !== null) {\n style.forEach(function (s) {\n vertices[id].styles.push(s);\n });\n }\n }\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "addVertex",
"string": "exports.addVertex()"
}
},
{
"tags": [
{
"type": "param",
"types": [
"start"
],
"name": "",
"description": ""
},
{
"type": "param",
"types": [
"end"
],
"name": "",
"description": ""
},
{
"type": "param",
"types": [
"type"
],
"name": "",
"description": ""
},
{
"type": "param",
"types": [
"linktext"
],
"name": "",
"description": ""
}
],
"description": {
"full": "Function called by parser when a link/edge definition has been found",
"summary": "Function called by parser when a link/edge definition has been found",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.addLink = function (start, end, type, linktext) {\n //console.log('Got edge', start, end);\n var edge = {start: start, end: end, type: undefined, text: ''};\n var linktext = type.text;\n if (typeof linktext !== 'undefined') {\n edge.text = linktext;\n }\n\n if (typeof type !== 'undefined') {\n edge.type = type.type;\n }\n edges.push(edge);\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "addLink",
"string": "exports.addLink()"
}
},
{
"tags": [
{
"type": "param",
"types": [
"pos"
],
"name": "",
"description": ""
},
{
"type": "param",
"types": [
"style"
],
"name": "",
"description": ""
}
],
"description": {
"full": "Updates a link with a style",
"summary": "Updates a link with a style",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.updateLink = function (pos, style) {\n var position = pos.substr(1);\n edges[pos].style = style;\n};\n\nexports.addClass = function (id, style) {\n if (typeof classes[id] === 'undefined') {\n classes[id] = {id: id, styles: []};\n }\n\n if (typeof style !== 'undefined') {\n if (style !== null) {\n style.forEach(function (s) {\n classes[id].styles.push(s);\n });\n }\n }\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "updateLink",
"string": "exports.updateLink()"
}
},
{
"tags": [
{
"type": "param",
"types": [
"dir"
],
"name": "",
"description": ""
}
],
"description": {
"full": "Called by parser when a graph definition is found, stores the direction of the chart.",
"summary": "Called by parser when a graph definition is found, stores the direction of the chart.",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.setDirection = function (dir) {\n direction = dir;\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "setDirection",
"string": "exports.setDirection()"
}
},
{
"tags": [
{
"type": "param",
"types": [
"dir"
],
"name": "",
"description": ""
}
],
"description": {
"full": "Called by parser when a graph definition is found, stores the direction of the chart.",
"summary": "Called by parser when a graph definition is found, stores the direction of the chart.",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.setClass = function (id,className) {\n if(id.indexOf(',')>0){\n id.split(',').forEach(function(id2){\n if(typeof vertices[id2] !== 'undefined'){\n vertices[id2].classes.push(className);\n }\n });\n }else{\n if(typeof vertices[id] !== 'undefined'){\n vertices[id].classes.push(className);\n }\n }\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "setClass",
"string": "exports.setClass()"
}
},
{
"tags": [
{
"type": "param",
"types": [
"dir"
],
"name": "",
"description": ""
}
],
"description": {
"full": "Called by parser when a graph definition is found, stores the direction of the chart.",
"summary": "Called by parser when a graph definition is found, stores the direction of the chart.",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.setClickEvent = function (id,functionName) {\n\n\n if(id.indexOf(',')>0){\n id.split(',').forEach(function(id2) {\n if (typeof vertices[id2] !== 'undefined') {\n funs.push(function () {\n var elem = document.getElementById(id2);\n if (elem !== null) {\n elem.onclick = function () {\n eval(functionName + '(\\'' + id2 + '\\')');\n };\n }\n });\n }\n });\n }else{\n //console.log('Checking now for ::'+id);\n if(typeof vertices[id] !== 'undefined'){\n funs.push(function(){\n var elem = document.getElementById(id);\n if(elem !== null){\n //console.log('id was NOT null: '+id);\n elem.onclick = function(){eval(functionName+'(\\'' + id + '\\')');};\n }\n else{\n //console.log('id was null: '+id);\n }\n });\n }\n }\n\n\n};\n\nexports.bindFunctions = function(){\n //setTimeout(function(){\n funs.forEach(function(fun){\n fun();\n });\n //},1000);\n\n};\nexports.getDirection = function () {\n return direction;\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "setClickEvent",
"string": "exports.setClickEvent()"
}
},
{
"tags": [
{
"type": "returns",
"string": "{{}|*|vertices}"
}
],
"description": {
"full": "Retrieval function for fetching the found nodes after parsing has completed.",
"summary": "Retrieval function for fetching the found nodes after parsing has completed.",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.getVertices = function () {\n return vertices;\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "getVertices",
"string": "exports.getVertices()"
}
},
{
"tags": [
{
"type": "returns",
"string": "{{}|*|edges}"
}
],
"description": {
"full": "Retrieval function for fetching the found links after parsing has completed.",
"summary": "Retrieval function for fetching the found links after parsing has completed.",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.getEdges = function () {\n return edges;\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "getEdges",
"string": "exports.getEdges()"
}
},
{
"tags": [
{
"type": "returns",
"string": "{{}|*|classes}"
}
],
"description": {
"full": "Retrieval function for fetching the found class definitions after parsing has completed.",
"summary": "Retrieval function for fetching the found class definitions after parsing has completed.",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.getClasses = function () {\n return classes;\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "getClasses",
"string": "exports.getClasses()"
}
},
{
"tags": [],
"description": {
"full": "Clears the internal graph db so that a new graph can be parsed.",
"summary": "Clears the internal graph db so that a new graph can be parsed.",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.clear = function () {\n vertices = {};\n classes = {};\n edges = [];\n funs = [];\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "clear",
"string": "exports.clear()"
}
},
{
"tags": [],
"description": {
"full": "@returns {string}",
"summary": "@returns {string}",
"body": ""
},
"isPrivate": false,
"ignore": false,
"code": "exports.defaultStyle = function () {\n return \"fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;\";\n};",
"ctx": {
"type": "method",
"receiver": "exports",
"name": "defaultStyle",
"string": "exports.defaultStyle()"
}
}
]