#931 Aligning code standard

This commit is contained in:
knsv 2019-09-12 12:55:31 -07:00
parent e14922f15c
commit e67b8c86d6
3 changed files with 49 additions and 50 deletions

View File

@ -1,15 +1,15 @@
/* eslint-env jasmine */ /* eslint-env jasmine */
describe('when parsing an info graph it', function () { describe('when parsing an info graph it', function() {
var ex var ex;
beforeEach(function () { beforeEach(function() {
ex = require('./parser/info').parser ex = require('./parser/info').parser;
ex.yy = require('./infoDb') ex.yy = require('./infoDb');
}) });
it('should handle an info definition', function () { it('should handle an info definition', function() {
var str = `info var str = `info
showInfo` showInfo`;
ex.parse(str) ex.parse(str);
}) });
}) });

View File

@ -1,27 +1,27 @@
/** /**
* Created by knut on 15-01-14. * Created by knut on 15-01-14.
*/ */
import { logger } from '../../logger' import { logger } from '../../logger';
var message = '' var message = '';
var info = false var info = false;
export const setMessage = txt => { export const setMessage = txt => {
logger.debug('Setting message to: ' + txt) logger.debug('Setting message to: ' + txt);
message = txt message = txt;
} };
export const getMessage = () => { export const getMessage = () => {
return message return message;
} };
export const setInfo = inf => { export const setInfo = inf => {
info = inf info = inf;
} };
export const getInfo = () => { export const getInfo = () => {
return info return info;
} };
// export const parseError = (err, hash) => { // export const parseError = (err, hash) => {
// global.mermaidAPI.parseError(err, hash) // global.mermaidAPI.parseError(err, hash)
@ -33,4 +33,4 @@ export default {
setInfo, setInfo,
getInfo getInfo
// parseError // parseError
} };

View File

@ -1,20 +1,19 @@
/** /**
* Created by knut on 14-12-11. * Created by knut on 14-12-11.
*/ */
import * as d3 from 'd3' import * as d3 from 'd3';
import db from './infoDb' import db from './infoDb';
import infoParser from './parser/info' import infoParser from './parser/info';
import { logger } from '../../logger' import { logger } from '../../logger';
const conf = { const conf = {};
} export const setConf = function(cnf) {
export const setConf = function (cnf) { const keys = Object.keys(cnf);
const keys = Object.keys(cnf)
keys.forEach(function (key) { keys.forEach(function(key) {
conf[key] = cnf[key] conf[key] = cnf[key];
}) });
} };
/** /**
* Draws a an info picture in the tag with id: id based on the graph definition in text. * Draws a an info picture in the tag with id: id based on the graph definition in text.
@ -23,16 +22,16 @@ export const setConf = function (cnf) {
*/ */
export const draw = (txt, id, ver) => { export const draw = (txt, id, ver) => {
try { try {
const parser = infoParser.parser const parser = infoParser.parser;
parser.yy = db parser.yy = db;
logger.debug('Renering info diagram\n' + txt) logger.debug('Renering info diagram\n' + txt);
// Parse the graph definition // Parse the graph definition
parser.parse(txt) parser.parse(txt);
logger.debug('Parsed info diagram') logger.debug('Parsed info diagram');
// Fetch the default direction, use TD if none was found // Fetch the default direction, use TD if none was found
const svg = d3.select('#' + id) const svg = d3.select('#' + id);
const g = svg.append('g') const g = svg.append('g');
g.append('text') // text label for the x axis g.append('text') // text label for the x axis
.attr('x', 100) .attr('x', 100)
@ -40,18 +39,18 @@ export const draw = (txt, id, ver) => {
.attr('class', 'version') .attr('class', 'version')
.attr('font-size', '32px') .attr('font-size', '32px')
.style('text-anchor', 'middle') .style('text-anchor', 'middle')
.text('v ' + ver) .text('v ' + ver);
svg.attr('height', 100) svg.attr('height', 100);
svg.attr('width', 400) svg.attr('width', 400);
// svg.attr('viewBox', '0 0 300 150'); // svg.attr('viewBox', '0 0 300 150');
} catch (e) { } catch (e) {
logger.error('Error while rendering info diagram') logger.error('Error while rendering info diagram');
logger.error(e.message) logger.error(e.message);
} }
} };
export default { export default {
setConf, setConf,
draw draw
} };