Modernization, better linting, adjustment after stricter static rules

This commit is contained in:
knsv
2015-10-17 10:38:05 +02:00
parent 2417741283
commit 8365fcc2f9
14 changed files with 48 additions and 364 deletions

View File

@@ -3,6 +3,7 @@
*/
describe('when parsing an info graph it',function() {
var parseError;
var ex;
beforeEach(function () {
ex = require('./parser/example').parser;
ex.yy = require('./exampleDb');

View File

@@ -139,14 +139,14 @@ parse: function parse(input) {
lstack.length = lstack.length - n;
}
_token_stack:
function lex() {
var lex = function () {
var token;
token = lexer.lex() || EOF;
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token;
}
};
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
while (true) {
state = stack[stack.length - 1];

View File

@@ -43,8 +43,6 @@ exports.addVertices = function (vert, g) {
var vertice = vert[id];
var verticeText;
var i;
/**
* Variable for storing the classes for the vertice
* @type {string}
@@ -78,7 +76,7 @@ exports.addVertices = function (vert, g) {
var labelTypeStr = '';
if(conf.htmlLabels) {
labelTypeStr = 'html';
verticeText = verticeText.replace(/fa:fa[\w\-]+/g,function(s,t,u){
verticeText = verticeText.replace(/fa:fa[\w\-]+/g,function(s){
return '<i class="fa '+ s.substring(3)+'">';
});
@@ -119,7 +117,7 @@ exports.addVertices = function (vert, g) {
_shape = 'rect';
}
// Add the node
g.setNode(vertice.id, {labelType: labelTypeStr, shape:_shape, label: verticeText, rx: radious, ry: radious, class: classStr, style: style, id:vertice.id});
g.setNode(vertice.id, {labelType: labelTypeStr, shape:_shape, label: verticeText, rx: radious, ry: radious, 'class': classStr, style: style, id:vertice.id});
});
};
@@ -257,7 +255,7 @@ exports.draw = function (text, id,isDot) {
parser.parse(text);
}
catch(err){
log.debug('Parsing failed');
}
// Fetch the default direction, use TD if none was found
@@ -347,7 +345,7 @@ exports.draw = function (text, id,isDot) {
{x: w, y: 0},
{x: w, y: -h},
{x: -h/2, y: -h},
{x: 0, y: -h/2},
{x: 0, y: -h/2}
];
var shapeSvg = parent.insert('polygon', ':first-child')
.attr('points', points.map(function (d) {
@@ -369,7 +367,7 @@ exports.draw = function (text, id,isDot) {
{x: w+h/2, y: 0},
{x: w, y: -h/2},
{x: w+h/2, y: -h},
{x: 0, y: -h},
{x: 0, y: -h}
];
var shapeSvg = parent.insert('polygon', ':first-child')
.attr('points', points.map(function (d) {
@@ -401,7 +399,7 @@ exports.draw = function (text, id,isDot) {
// Set up an SVG group so that we can translate the final graph.
var svg = d3.select('#' + id);
svgGroup = d3.select('#' + id + ' g');
//svgGroup = d3.select('#' + id + ' g');
// Run the renderer. This is what draws the final graph.
var element = d3.select('#' + id + ' g');
@@ -413,12 +411,6 @@ exports.draw = function (text, id,isDot) {
return graph.getTooltip(this.id);
});
//
//element.selectAll('g.node')
// .attr('title', function(v) { return styleTooltip(v, g.node(v).description) })
// .each(function(v) { $(this).tipsy({ gravity: 'w', opacity: 1, html: true }); });
var svgb = document.querySelector('#' + id);
/*
var xPos = document.querySelectorAll('.clusters rect')[0].x.baseVal.value;
var width = document.querySelectorAll('.clusters rect')[0].width.baseVal.value;
@@ -455,7 +447,6 @@ exports.draw = function (text, id,isDot) {
graph.indexNodes('subGraph'+i);
for(i=0;i<subGraphs.length;i++){
var pos = graph.getDepthFirstPos(i);
subG = subGraphs[i];
if (subG.title !== 'undefined') {

View File

@@ -179,14 +179,14 @@ parse: function parse(input) {
lstack.length = lstack.length - n;
}
_token_stack:
function lex() {
var lex = function () {
var token;
token = lexer.lex() || EOF;
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token;
}
};
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
while (true) {
state = stack[stack.length - 1];

View File

@@ -332,14 +332,14 @@ parse: function parse(input) {
lstack.length = lstack.length - n;
}
_token_stack:
function lex() {
var lex = function () {
var token;
token = lexer.lex() || EOF;
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token;
}
};
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
while (true) {
state = stack[stack.length - 1];

View File

@@ -3,7 +3,7 @@
*/
var log = require('../../logger').create();
describe('when using the ganttDb',function() {
var parseError, gantt;
var parseError, gantt, gDb;
var moment = require('moment');
beforeEach(function () {

View File

@@ -151,14 +151,14 @@ parse: function parse(input) {
lstack.length = lstack.length - n;
}
_token_stack:
function lex() {
var lex = function () {
var token;
token = lexer.lex() || EOF;
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token;
}
};
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
while (true) {
state = stack[stack.length - 1];

View File

@@ -210,14 +210,14 @@ parse: function parse(input) {
lstack.length = lstack.length - n;
}
_token_stack:
function lex() {
var lex = function () {
var token;
token = lexer.lex() || EOF;
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token;
}
};
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
while (true) {
state = stack[stack.length - 1];

View File

@@ -226,15 +226,19 @@ var drawMessage = function(elem, startx, stopx, verticalPos, msg){
line.attr('class', 'messageLine0');
}
var url = window.location.protocol+'//'+window.location.host+window.location.pathname +window.location.search;
url = url.replace(/\(/g,'\\(');
url = url.replace(/\)/g,'\\)');
line.attr('stroke-width', 2);
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(' + window.location.protocol+'//'+window.location.host+window.location.pathname + '#arrowhead)');
line.attr('marker-end', 'url(' + url + '#crosshead)');
}
if (msg.type === sq.yy.LINETYPE.SOLID_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_CROSS){
line.attr('marker-end', 'url(' + window.location.protocol+'//'+window.location.host+window.location.pathname + '#crosshead)');
line.attr('marker-end', 'url(' + url + '#crosshead)');
}
};