Comparing version 7.0.0 to 7.0.1
#!/usr/bin/env node | ||
var fs = require('fs') | ||
, chalk = require('chalk') | ||
, error = chalk.bold.red | ||
, cli = require('../lib/cli.js') | ||
, lib = require('../lib'); | ||
var chalk = require('chalk') | ||
var cli = require('../lib/cli.js') | ||
var lib = require('../lib') | ||
cli.parse(process.argv.slice(2), function(err, message, options) { | ||
cli.parse(process.argv.slice(2), function (err, message, options) { | ||
if (err) { | ||
console.error( | ||
error('\nYou had errors in your syntax. Use --help for further information.') | ||
chalk.bold.red('\nYou had errors in your syntax. Use --help for further information.') | ||
) | ||
@@ -19,4 +17,3 @@ err.forEach(function (e) { | ||
return | ||
} | ||
else if (message) { | ||
} else if (message) { | ||
console.log(message) | ||
@@ -28,2 +25,2 @@ | ||
lib.process(options.files, options, process.exit) | ||
}); | ||
}) |
@@ -6,3 +6,3 @@ { | ||
], | ||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.", | ||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.", | ||
"main": "dist/mermaid.slim.js", | ||
@@ -14,3 +14,5 @@ "keywords": [ | ||
"sequence diagram", | ||
"gantt" | ||
"gantt", | ||
"class diagram", | ||
"git graph" | ||
], | ||
@@ -17,0 +19,0 @@ "license": "MIT", |
@@ -16,2 +16,3 @@ # How to contribute | ||
## Guidelines for avoiding duplicate work | ||
@@ -30,2 +31,3 @@ | ||
## Submitting changes | ||
Please send a GitHub Pull Request with a clear list of what you've done (read more about pull requests). When you send | ||
@@ -37,3 +39,3 @@ a pull request, we will love you forever if you include jasmine tests. We can always use more test coverage. | ||
$ git commit -m "A brief summary of the commit | ||
> | ||
> | ||
> A paragraph describing what changed and its impact." | ||
@@ -53,9 +55,10 @@ Coding conventions | ||
# Build instructions | ||
Fork, then: | ||
``` | ||
npm install | ||
yarn install | ||
``` | ||
Then the dependencies will have been installed. You use gulp and npm calls as build tools. | ||
Then the dependencies will have been installed. You use gulp and yarn calls as build tools. | ||
@@ -70,12 +73,21 @@ The following targets are probably interesting: | ||
``` | ||
To build: | ||
``` | ||
yarn build | ||
``` | ||
To run the tests: | ||
``` | ||
npm run karma | ||
yarn test | ||
``` | ||
To build the /dist directory | ||
Make sure you have Chrome browser installed. We use Chrome headless for testing. | ||
Manual test: | ||
``` | ||
npm run dist | ||
open dist/demo/index.html | ||
``` | ||
Thanks, Knut Sveidqvist |
@@ -1,2 +0,2 @@ | ||
!function(){if("ontouchstart"in window){var t,e,n,r,i,a,o={};t=function(t,e){return Math.abs(t[0]-e[0])>5||Math.abs(t[1]-e[1])>5},e=function(t){this.startXY=[t.touches[0].clientX,t.touches[0].clientY],this.threshold=!1},n=function(e){return this.threshold?!1:void(this.threshold=t(this.startXY,[e.touches[0].clientX,e.touches[0].clientY]))},r=function(e){if(!this.threshold&&!t(this.startXY,[e.changedTouches[0].clientX,e.changedTouches[0].clientY])){var n=e.changedTouches[0],r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,0,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),r.simulated=!0,e.target.dispatchEvent(r)}},i=function(t){var e=Date.now(),n=e-o.time,r=t.clientX,i=t.clientY,u=[Math.abs(o.x-r),Math.abs(o.y-i)],s=a(t.target,"A")||t.target,c=s.nodeName,l="A"===c,h=window.navigator.standalone&&l&&t.target.getAttribute("href");return o.time=e,o.x=r,o.y=i,(!t.simulated&&(500>n||1500>n&&u[0]<50&&u[1]<50)||h)&&(t.preventDefault(),t.stopPropagation(),!h)?!1:(h&&(window.location=s.getAttribute("href")),void(s&&s.classList&&(s.classList.add("energize-focus"),window.setTimeout(function(){s.classList.remove("energize-focus")},150))))},a=function(t,e){for(var n=t;n!==document.body;){if(!n||n.nodeName===e)return n;n=n.parentNode}return null},document.addEventListener("touchstart",e,!1),document.addEventListener("touchmove",n,!1),document.addEventListener("touchend",r,!1),document.addEventListener("click",i,!0)}}(),/* | ||
!(function () { if ('ontouchstart' in window) { var t, e, n, r, i, a, o = {}; t = function (t, e) { return Math.abs(t[0] - e[0]) > 5 || Math.abs(t[1] - e[1]) > 5 }, e = function (t) { this.startXY = [t.touches[0].clientX, t.touches[0].clientY], this.threshold = !1 }, n = function (e) { return this.threshold ? !1 : void (this.threshold = t(this.startXY, [e.touches[0].clientX, e.touches[0].clientY])) }, r = function (e) { if (!this.threshold && !t(this.startXY, [e.changedTouches[0].clientX, e.changedTouches[0].clientY])) { var n = e.changedTouches[0], r = document.createEvent('MouseEvents'); r.initMouseEvent('click', !0, !0, window, 0, n.screenX, n.screenY, n.clientX, n.clientY, !1, !1, !1, !1, 0, null), r.simulated = !0, e.target.dispatchEvent(r) } }, i = function (t) { var e = Date.now(), n = e - o.time, r = t.clientX, i = t.clientY, u = [Math.abs(o.x - r), Math.abs(o.y - i)], s = a(t.target, 'A') || t.target, c = s.nodeName, l = c === 'A', h = window.navigator.standalone && l && t.target.getAttribute('href'); return o.time = e, o.x = r, o.y = i, (!t.simulated && (n < 500 || n < 1500 && u[0] < 50 && u[1] < 50) || h) && (t.preventDefault(), t.stopPropagation(), !h) ? !1 : (h && (window.location = s.getAttribute('href')), void (s && s.classList && (s.classList.add('energize-focus'), window.setTimeout(function () { s.classList.remove('energize-focus') }, 150)))) }, a = function (t, e) { for (var n = t; n !== document.body;) { if (!n || n.nodeName === e) return n; n = n.parentNode } return null }, document.addEventListener('touchstart', e, !1), document.addEventListener('touchmove', n, !1), document.addEventListener('touchend', r, !1), document.addEventListener('click', i, !0) } }()), /* | ||
Copyright 2008-2013 Concur Technologies, Inc. | ||
@@ -16,7 +16,7 @@ | ||
*/ | ||
function(t){"use strict";function e(e){if(e&&""!==e){$(".lang-selector a").removeClass("active"),$(".lang-selector a[data-language-name='"+e+"']").addClass("active");for(var n=0;n<s.length;n++)$(".highlight."+s[n]).hide();$(".highlight."+e).show(),t.toc.calculateHeights(),$(window.location.hash).get(0)&&$(window.location.hash).get(0).scrollIntoView(!0)}}function n(t){return"string"!=typeof t?{}:(t=t.trim().replace(/^(\?|#|&)/,""),t?t.split("&").reduce(function(t,e){var n=e.replace(/\+/g," ").split("="),r=n[0],i=n[1];return r=decodeURIComponent(r),i=void 0===i?null:decodeURIComponent(i),t.hasOwnProperty(r)?Array.isArray(t[r])?t[r].push(i):t[r]=[t[r],i]:t[r]=i,t},{}):{})}function r(t){return t?Object.keys(t).sort().map(function(e){var n=t[e];return Array.isArray(n)?n.sort().map(function(t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}).join("&"):encodeURIComponent(e)+"="+encodeURIComponent(n)}).join("&"):""}function i(){if(location.search.length>=1){var t=n(location.search).language;if(t)return t;if(-1!=jQuery.inArray(location.search.substr(1),s))return location.search.substr(1)}return!1}function a(t){var e=n(location.search);return e.language?(e.language=t,r(e)):t}function o(t){if(history){var e=window.location.hash;e&&(e=e.replace(/^#+/,"")),history.pushState({},"","?"+a(t)+"#"+e),localStorage.setItem("language",t)}}function u(t){var n=localStorage.getItem("language");s=t;var r=i();r?(e(r),localStorage.setItem("language",r)):e(null!==n&&-1!=jQuery.inArray(n,s)?n:s[0])}var s=[];t.setupLanguages=u,t.activateLanguage=e,$(function(){$(".lang-selector a").on("click",function(){var t=$(this).data("language-name");return o(t),e(t),!1}),window.onpopstate=function(){e(i())}})}(window),/*! jQuery UI - v1.11.3 - 2015-02-12 | ||
(function (t) { 'use strict'; function e (e) { if (e && e !== '') { $('.lang-selector a').removeClass('active'), $(".lang-selector a[data-language-name='" + e + "']").addClass('active'); for (var n = 0; n < s.length; n++)$('.highlight.' + s[n]).hide(); $('.highlight.' + e).show(), t.toc.calculateHeights(), $(window.location.hash).get(0) && $(window.location.hash).get(0).scrollIntoView(!0) } } function n (t) { return typeof t !== 'string' ? {} : (t = t.trim().replace(/^(\?|#|&)/, ''), t ? t.split('&').reduce(function (t, e) { var n = e.replace(/\+/g, ' ').split('='), r = n[0], i = n[1]; return r = decodeURIComponent(r), i = void 0 === i ? null : decodeURIComponent(i), t.hasOwnProperty(r) ? Array.isArray(t[r]) ? t[r].push(i) : t[r] = [t[r], i] : t[r] = i, t }, {}) : {}) } function r (t) { return t ? Object.keys(t).sort().map(function (e) { var n = t[e]; return Array.isArray(n) ? n.sort().map(function (t) { return encodeURIComponent(e) + '=' + encodeURIComponent(t) }).join('&') : encodeURIComponent(e) + '=' + encodeURIComponent(n) }).join('&') : '' } function i () { if (location.search.length >= 1) { var t = n(location.search).language; if (t) return t; if (jQuery.inArray(location.search.substr(1), s) != -1) return location.search.substr(1) } return !1 } function a (t) { var e = n(location.search); return e.language ? (e.language = t, r(e)) : t } function o (t) { if (history) { var e = window.location.hash; e && (e = e.replace(/^#+/, '')), history.pushState({}, '', '?' + a(t) + '#' + e), localStorage.setItem('language', t) } } function u (t) { var n = localStorage.getItem('language'); s = t; var r = i(); r ? (e(r), localStorage.setItem('language', r)) : e(n !== null && jQuery.inArray(n, s) != -1 ? n : s[0]) } var s = []; t.setupLanguages = u, t.activateLanguage = e, $(function () { $('.lang-selector a').on('click', function () { var t = $(this).data('language-name'); return o(t), e(t), !1 }), window.onpopstate = function () { e(i()) } }) }(window)), /*! jQuery UI - v1.11.3 - 2015-02-12 | ||
* http://jqueryui.com | ||
* Includes: widget.js | ||
* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ | ||
function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(t){/*! | ||
(function (t) { typeof define === 'function' && define.amd ? define(['jquery'], t) : t(jQuery) }(function (t) { /*! | ||
* jQuery UI Widget 1.11.3 | ||
@@ -31,3 +31,4 @@ * http://jqueryui.com | ||
*/ | ||
var e=0,n=Array.prototype.slice;t.cleanData=function(e){return function(n){var r,i,a;for(a=0;null!=(i=n[a]);a++)try{r=t._data(i,"events"),r&&r.remove&&t(i).triggerHandler("remove")}catch(o){}e(n)}}(t.cleanData),t.widget=function(e,n,r){var i,a,o,u,s={},c=e.split(".")[0];return e=e.split(".")[1],i=c+"-"+e,r||(r=n,n=t.Widget),t.expr[":"][i.toLowerCase()]=function(e){return!!t.data(e,i)},t[c]=t[c]||{},a=t[c][e],o=t[c][e]=function(t,e){return this._createWidget?void(arguments.length&&this._createWidget(t,e)):new o(t,e)},t.extend(o,a,{version:r.version,_proto:t.extend({},r),_childConstructors:[]}),u=new n,u.options=t.widget.extend({},u.options),t.each(r,function(e,r){return t.isFunction(r)?void(s[e]=function(){var t=function(){return n.prototype[e].apply(this,arguments)},i=function(t){return n.prototype[e].apply(this,t)};return function(){var e,n=this._super,a=this._superApply;return this._super=t,this._superApply=i,e=r.apply(this,arguments),this._super=n,this._superApply=a,e}}()):void(s[e]=r)}),o.prototype=t.widget.extend(u,{widgetEventPrefix:a?u.widgetEventPrefix||e:e},s,{constructor:o,namespace:c,widgetName:e,widgetFullName:i}),a?(t.each(a._childConstructors,function(e,n){var r=n.prototype;t.widget(r.namespace+"."+r.widgetName,o,n._proto)}),delete a._childConstructors):n._childConstructors.push(o),t.widget.bridge(e,o),o},t.widget.extend=function(e){for(var r,i,a=n.call(arguments,1),o=0,u=a.length;u>o;o++)for(r in a[o])i=a[o][r],a[o].hasOwnProperty(r)&&void 0!==i&&(e[r]=t.isPlainObject(i)?t.isPlainObject(e[r])?t.widget.extend({},e[r],i):t.widget.extend({},i):i);return e},t.widget.bridge=function(e,r){var i=r.prototype.widgetFullName||e;t.fn[e]=function(a){var o="string"==typeof a,u=n.call(arguments,1),s=this;return o?this.each(function(){var n,r=t.data(this,i);return"instance"===a?(s=r,!1):r?t.isFunction(r[a])&&"_"!==a.charAt(0)?(n=r[a].apply(r,u),n!==r&&void 0!==n?(s=n&&n.jquery?s.pushStack(n.get()):n,!1):void 0):t.error("no such method '"+a+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; attempted to call method '"+a+"'")}):(u.length&&(a=t.widget.extend.apply(null,[a].concat(u))),this.each(function(){var e=t.data(this,i);e?(e.option(a||{}),e._init&&e._init()):t.data(this,i,new r(a,this))})),s}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(n,r){r=t(r||this.defaultElement||this)[0],this.element=t(r),this.uuid=e++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),r!==this&&(t.data(r,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===r&&this.destroy()}}),this.document=t(r.style?r.ownerDocument:r.document||r),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),n),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(e,n){var r,i,a,o=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(o={},r=e.split("."),e=r.shift(),r.length){for(i=o[e]=t.widget.extend({},this.options[e]),a=0;a<r.length-1;a++)i[r[a]]=i[r[a]]||{},i=i[r[a]];if(e=r.pop(),1===arguments.length)return void 0===i[e]?null:i[e];i[e]=n}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];o[e]=n}return this._setOptions(o),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return this.options[t]=e,"disabled"===t&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!e),e&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(e,n,r){var i,a=this;"boolean"!=typeof e&&(r=n,n=e,e=!1),r?(n=i=t(n),this.bindings=this.bindings.add(n)):(r=n,n=this.element,i=this.widget()),t.each(r,function(r,o){function u(){return e||a.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof o?a[o]:o).apply(a,arguments):void 0}"string"!=typeof o&&(u.guid=o.guid=o.guid||u.guid||t.guid++);var s=r.match(/^([\w:-]*)\s*(.*)$/),c=s[1]+a.eventNamespace,l=s[2];l?i.delegate(l,c,u):n.bind(c,u)})},_off:function(e,n){n=(n||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(n).undelegate(n),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function n(){return("string"==typeof t?r[t]:t).apply(r,arguments)}var r=this;return setTimeout(n,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){t(e.currentTarget).addClass("ui-state-hover")},mouseleave:function(e){t(e.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){t(e.currentTarget).addClass("ui-state-focus")},focusout:function(e){t(e.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(e,n,r){var i,a,o=this.options[e];if(r=r||{},n=t.Event(n),n.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),n.target=this.element[0],a=n.originalEvent)for(i in a)i in n||(n[i]=a[i]);return this.element.trigger(n,r),!(t.isFunction(o)&&o.apply(this.element[0],[n].concat(r))===!1||n.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,n){t.Widget.prototype["_"+e]=function(r,i,a){"string"==typeof i&&(i={effect:i});var o,u=i?i===!0||"number"==typeof i?n:i.effect||n:e;i=i||{},"number"==typeof i&&(i={duration:i}),o=!t.isEmptyObject(i),i.complete=a,i.delay&&r.delay(i.delay),o&&t.effects&&t.effects.effect[u]?r[e](i):u!==e&&r[u]?r[u](i.duration,i.easing,a):r.queue(function(n){t(this)[e](),a&&a.call(r[0]),n()})}});t.widget}),/* jquery Tocify - v1.8.0 - 2013-09-16 | ||
var e = 0, n = Array.prototype.slice; t.cleanData = (function (e) { return function (n) { var r, i, a; for (a = 0; (i = n[a]) != null; a++) try { r = t._data(i, 'events'), r && r.remove && t(i).triggerHandler('remove') } catch (o) {}e(n) } }(t.cleanData)), t.widget = function (e, n, r) { var i, a, o, u, s = {}, c = e.split('.')[0]; return e = e.split('.')[1], i = c + '-' + e, r || (r = n, n = t.Widget), t.expr[':'][i.toLowerCase()] = function (e) { return !!t.data(e, i) }, t[c] = t[c] || {}, a = t[c][e], o = t[c][e] = function (t, e) { return this._createWidget ? void (arguments.length && this._createWidget(t, e)) : new o(t, e) }, t.extend(o, a, {version: r.version, _proto: t.extend({}, r), _childConstructors: []}), u = new n(), u.options = t.widget.extend({}, u.options), t.each(r, function (e, r) { return t.isFunction(r) ? void (s[e] = (function () { var t = function () { return n.prototype[e].apply(this, arguments) }, i = function (t) { return n.prototype[e].apply(this, t) }; return function () { var e, n = this._super, a = this._superApply; return this._super = t, this._superApply = i, e = r.apply(this, arguments), this._super = n, this._superApply = a, e } }())) : void (s[e] = r) }), o.prototype = t.widget.extend(u, {widgetEventPrefix: a ? u.widgetEventPrefix || e : e}, s, {constructor: o, namespace: c, widgetName: e, widgetFullName: i}), a ? (t.each(a._childConstructors, function (e, n) { var r = n.prototype; t.widget(r.namespace + '.' + r.widgetName, o, n._proto) }), delete a._childConstructors) : n._childConstructors.push(o), t.widget.bridge(e, o), o }, t.widget.extend = function (e) { for (var r, i, a = n.call(arguments, 1), o = 0, u = a.length; u > o; o++) for (r in a[o])i = a[o][r], a[o].hasOwnProperty(r) && void 0 !== i && (e[r] = t.isPlainObject(i) ? t.isPlainObject(e[r]) ? t.widget.extend({}, e[r], i) : t.widget.extend({}, i) : i); return e }, t.widget.bridge = function (e, r) { var i = r.prototype.widgetFullName || e; t.fn[e] = function (a) { var o = typeof a === 'string', u = n.call(arguments, 1), s = this; return o ? this.each(function () { var n, r = t.data(this, i); return a === 'instance' ? (s = r, !1) : r ? t.isFunction(r[a]) && a.charAt(0) !== '_' ? (n = r[a].apply(r, u), n !== r && void 0 !== n ? (s = n && n.jquery ? s.pushStack(n.get()) : n, !1) : void 0) : t.error("no such method '" + a + "' for " + e + ' widget instance') : t.error('cannot call methods on ' + e + " prior to initialization; attempted to call method '" + a + "'") }) : (u.length && (a = t.widget.extend.apply(null, [a].concat(u))), this.each(function () { var e = t.data(this, i); e ? (e.option(a || {}), e._init && e._init()) : t.data(this, i, new r(a, this)) })), s } }, t.Widget = function () {}, t.Widget._childConstructors = [], t.Widget.prototype = {widgetName: 'widget', widgetEventPrefix: '', defaultElement: '<div>', options: {disabled: !1, create: null}, _createWidget: function (n, r) { r = t(r || this.defaultElement || this)[0], this.element = t(r), this.uuid = e++, this.eventNamespace = '.' + this.widgetName + this.uuid, this.bindings = t(), this.hoverable = t(), this.focusable = t(), r !== this && (t.data(r, this.widgetFullName, this), this._on(!0, this.element, {remove: function (t) { t.target === r && this.destroy() }}), this.document = t(r.style ? r.ownerDocument : r.document || r), this.window = t(this.document[0].defaultView || this.document[0].parentWindow)), this.options = t.widget.extend({}, this.options, this._getCreateOptions(), n), this._create(), this._trigger('create', null, this._getCreateEventData()), this._init() }, _getCreateOptions: t.noop, _getCreateEventData: t.noop, _create: t.noop, _init: t.noop, destroy: function () { this._destroy(), this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)), this.widget().unbind(this.eventNamespace).removeAttr('aria-disabled').removeClass(this.widgetFullName + '-disabled ui-state-disabled'), this.bindings.unbind(this.eventNamespace), this.hoverable.removeClass('ui-state-hover'), this.focusable.removeClass('ui-state-focus') }, _destroy: t.noop, widget: function () { return this.element }, option: function (e, n) { var r, i, a, o = e; if (arguments.length === 0) return t.widget.extend({}, this.options); if (typeof e === 'string') if (o = {}, r = e.split('.'), e = r.shift(), r.length) { for (i = o[e] = t.widget.extend({}, this.options[e]), a = 0; a < r.length - 1; a++)i[r[a]] = i[r[a]] || {}, i = i[r[a]]; if (e = r.pop(), arguments.length === 1) return void 0 === i[e] ? null : i[e]; i[e] = n } else { if (arguments.length === 1) return void 0 === this.options[e] ? null : this.options[e]; o[e] = n } return this._setOptions(o), this }, _setOptions: function (t) { var e; for (e in t) this._setOption(e, t[e]); return this }, _setOption: function (t, e) { return this.options[t] = e, t === 'disabled' && (this.widget().toggleClass(this.widgetFullName + '-disabled', !!e), e && (this.hoverable.removeClass('ui-state-hover'), this.focusable.removeClass('ui-state-focus'))), this }, enable: function () { return this._setOptions({disabled: !1}) }, disable: function () { return this._setOptions({disabled: !0}) }, _on: function (e, n, r) { var i, a = this; typeof e !== 'boolean' && (r = n, n = e, e = !1), r ? (n = i = t(n), this.bindings = this.bindings.add(n)) : (r = n, n = this.element, i = this.widget()), t.each(r, function (r, o) { function u () { return e || a.options.disabled !== !0 && !t(this).hasClass('ui-state-disabled') ? (typeof o === 'string' ? a[o] : o).apply(a, arguments) : void 0 } typeof o !== 'string' && (u.guid = o.guid = o.guid || u.guid || t.guid++); var s = r.match(/^([\w:-]*)\s*(.*)$/), c = s[1] + a.eventNamespace, l = s[2]; l ? i.delegate(l, c, u) : n.bind(c, u) }) }, _off: function (e, n) { n = (n || '').split(' ').join(this.eventNamespace + ' ') + this.eventNamespace, e.unbind(n).undelegate(n), this.bindings = t(this.bindings.not(e).get()), this.focusable = t(this.focusable.not(e).get()), this.hoverable = t(this.hoverable.not(e).get()) }, _delay: function (t, e) { function n () { return (typeof t === 'string' ? r[t] : t).apply(r, arguments) } var r = this; return setTimeout(n, e || 0) }, _hoverable: function (e) { this.hoverable = this.hoverable.add(e), this._on(e, {mouseenter: function (e) { t(e.currentTarget).addClass('ui-state-hover') }, mouseleave: function (e) { t(e.currentTarget).removeClass('ui-state-hover') }}) }, _focusable: function (e) { this.focusable = this.focusable.add(e), this._on(e, {focusin: function (e) { t(e.currentTarget).addClass('ui-state-focus') }, focusout: function (e) { t(e.currentTarget).removeClass('ui-state-focus') }}) }, _trigger: function (e, n, r) { var i, a, o = this.options[e]; if (r = r || {}, n = t.Event(n), n.type = (e === this.widgetEventPrefix ? e : this.widgetEventPrefix + e).toLowerCase(), n.target = this.element[0], a = n.originalEvent) for (i in a)i in n || (n[i] = a[i]); return this.element.trigger(n, r), !(t.isFunction(o) && o.apply(this.element[0], [n].concat(r)) === !1 || n.isDefaultPrevented()) }}, t.each({show: 'fadeIn', hide: 'fadeOut'}, function (e, n) { t.Widget.prototype['_' + e] = function (r, i, a) { typeof i === 'string' && (i = {effect: i}); var o, u = i ? i === !0 || typeof i === 'number' ? n : i.effect || n : e; i = i || {}, typeof i === 'number' && (i = {duration: i}), o = !t.isEmptyObject(i), i.complete = a, i.delay && r.delay(i.delay), o && t.effects && t.effects.effect[u] ? r[e](i) : u !== e && r[u] ? r[u](i.duration, i.easing, a) : r.queue(function (n) { t(this)[e](), a && a.call(r[0]), n() }) } }); t.widget | ||
})), /* jquery Tocify - v1.8.0 - 2013-09-16 | ||
* http://www.gregfranko.com/jquery.tocify.js/ | ||
@@ -40,3 +41,3 @@ * Copyright (c) 2013 Greg Franko; Licensed MIT | ||
* lag spikes below 30 fps */ | ||
function(t){"use strict";t(window.jQuery,window,document)}(function(t,e,n,r){"use strict";var i="tocify",a="tocify-focus",o="tocify-hover",u="tocify-hide",s="tocify-header",c="."+s,l="tocify-subheader",h="."+l,f="tocify-item",d="."+f,p="tocify-extend-page",g="."+p;t.widget("toc.tocify",{version:"1.8.0",options:{context:"body",ignoreSelector:null,selectors:"h1, h2, h3",showAndHide:!0,showEffect:"slideDown",showEffectSpeed:"medium",hideEffect:"slideUp",hideEffectSpeed:"medium",smoothScroll:!0,smoothScrollSpeed:"medium",scrollTo:0,showAndHideOnScroll:!0,highlightOnScroll:!0,highlightOffset:40,theme:"bootstrap",extendPage:!0,extendPageOffset:100,history:!0,scrollHistory:!1,hashGenerator:"compact",highlightDefault:!0},_create:function(){var n=this;n.tocifyWrapper=t(".tocify-wrapper"),n.extendPageScroll=!0,n.items=[],n._generateToc(),n.cachedHeights=[],n.cachedAnchors=[],n._addCSSClasses(),n.webkit=function(){for(var t in e)if(t&&-1!==t.toLowerCase().indexOf("webkit"))return!0;return!1}(),n._setEventHandlers(),t(e).load(function(){n._setActiveElement(!0),t("html, body").promise().done(function(){setTimeout(function(){n.extendPageScroll=!1},0)})})},_generateToc:function(){var e,n,r=this,a=r.options.ignoreSelector;return e=t(this.options.context).find(-1!==this.options.selectors.indexOf(",")?this.options.selectors.replace(/ /g,"").substr(0,this.options.selectors.indexOf(",")):this.options.selectors.replace(/ /g,"")),e.length?(r.element.addClass(i),void e.each(function(e){t(this).is(a)||(n=t("<ul/>",{id:s+e,"class":s}).append(r._nestElements(t(this),e)),r.element.append(n),t(this).nextUntil(this.nodeName.toLowerCase()).each(function(){0===t(this).find(r.options.selectors).length?t(this).filter(r.options.selectors).each(function(){t(this).is(a)||r._appendSubheaders.call(this,r,n)}):t(this).find(r.options.selectors).each(function(){t(this).is(a)||r._appendSubheaders.call(this,r,n)})}))})):void r.element.addClass(u)},_setActiveElement:function(t){var n=this,r=e.location.hash.substring(1),i=n.element.find("li[data-unique='"+r+"']");return r.length?(n.element.find("."+n.focusClass).removeClass(n.focusClass),i.addClass(n.focusClass),n.options.showAndHide&&i.click()):(n.element.find("."+n.focusClass).removeClass(n.focusClass),!r.length&&t&&n.options.highlightDefault&&n.element.find(d).first().addClass(n.focusClass)),n},_nestElements:function(e,n){var r,i,a;return r=t.grep(this.items,function(t){return t===e.text()}),this.items.push(r.length?e.text()+n:e.text()),a=this._generateHashValue(r,e,n),i=t("<li/>",{"class":f,"data-unique":a}).append(t("<a/>",{text:e.text()})),e.before(t("<div/>",{name:a,"data-unique":a})),i},_generateHashValue:function(t,e,n){var r="",i=this.options.hashGenerator;if("pretty"===i){for(r=e.text().toLowerCase().replace(/\s/g,"-"),r=r.replace(/[^\x00-\x7F]/g,"");r.indexOf("--")>-1;)r=r.replace(/--/g,"-");for(;r.indexOf(":-")>-1;)r=r.replace(/:-/g,"-")}else r="function"==typeof i?i(e.text(),e):e.text().replace(/\s/g,"");return t.length&&(r+=""+n),r},_appendSubheaders:function(e,n){var r=t(this).index(e.options.selectors),i=t(e.options.selectors).eq(r-1),a=+t(this).prop("tagName").charAt(1),o=+i.prop("tagName").charAt(1);o>a?e.element.find(h+"[data-tag="+a+"]").last().append(e._nestElements(t(this),r)):a===o?n.find(d).last().after(e._nestElements(t(this),r)):n.find(d).last().after(t("<ul/>",{"class":l,"data-tag":a})).next(h).append(e._nestElements(t(this),r))},_setEventHandlers:function(){var i=this;this.element.on("click.tocify","li",function(){if(i.options.history&&(e.location.hash=t(this).attr("data-unique")),i.element.find("."+i.focusClass).removeClass(i.focusClass),t(this).addClass(i.focusClass),i.options.showAndHide){var n=t('li[data-unique="'+t(this).attr("data-unique")+'"]');i._triggerShow(n)}i._scrollTo(t(this))}),this.element.find("li").on({"mouseenter.tocify":function(){t(this).addClass(i.hoverClass),t(this).css("cursor","pointer")},"mouseleave.tocify":function(){"bootstrap"!==i.options.theme&&t(this).removeClass(i.hoverClass)}}),t(e).on("resize",function(){i.calculateHeights()}),t(e).on("scroll.tocify",function(){t("html, body").promise().done(function(){var a,o,u,s,c=t(e).scrollTop(),l=t(e).height(),h=t(n).height(),f=t("body")[0].scrollHeight;if(i.options.extendPage&&(i.webkit&&c>=f-l-i.options.extendPageOffset||!i.webkit&&l+c>h-i.options.extendPageOffset)&&!t(g).length){if(o=t('div[data-unique="'+t(d).last().attr("data-unique")+'"]'),!o.length)return;u=o.offset().top,t(i.options.context).append(t("<div />",{"class":p,height:Math.abs(u-c)+"px","data-unique":p})),i.extendPageScroll&&(s=i.element.find("li.active"),i._scrollTo(t("div[data-unique="+s.attr("data-unique")+"]")))}setTimeout(function(){var o,u=null;0==i.cachedHeights.length&&i.calculateHeights();var s=t(e).scrollTop();if(i.cachedAnchors.each(function(t){return i.cachedHeights[t]-s<0?void(u=t):!1}),o=t(i.cachedAnchors[u]).attr("data-unique"),a=t('li[data-unique="'+o+'"]'),i.options.highlightOnScroll&&a.length&&!a.hasClass(i.focusClass)){i.element.find("."+i.focusClass).removeClass(i.focusClass),a.addClass(i.focusClass);var c=i.tocifyWrapper,l=t(a).closest(".tocify-header"),h=l.offset().top,f=c.offset().top,d=h-f;if(d>=t(e).height()){var p=d+c.scrollTop();c.scrollTop(p)}else 0>d&&c.scrollTop(0)}i.options.scrollHistory&&e.location.hash!=="#"+o&&o!==r&&(history.replaceState?history.replaceState({},"","#"+o):(scrollV=n.body.scrollTop,scrollH=n.body.scrollLeft,location.hash="#"+o,n.body.scrollTop=scrollV,n.body.scrollLeft=scrollH)),i.options.showAndHideOnScroll&&i.options.showAndHide&&i._triggerShow(a,!0)},0)})})},calculateHeights:function(){var e=this;e.cachedHeights=[],e.cachedAnchors=[];var n=t(e.options.context).find("div[data-unique]");n.each(function(n){var r=(t(this).next().length?t(this).next():t(this)).offset().top-e.options.highlightOffset;e.cachedHeights[n]=r}),e.cachedAnchors=n},show:function(e){var n=this;if(!e.is(":visible"))switch(e.find(h).length||e.parent().is(c)||e.parent().is(":visible")?e.children(h).length||e.parent().is(c)||(e=e.closest(h)):e=e.parents(h).add(e),n.options.showEffect){case"none":e.show();break;case"show":e.show(n.options.showEffectSpeed);break;case"slideDown":e.slideDown(n.options.showEffectSpeed);break;case"fadeIn":e.fadeIn(n.options.showEffectSpeed);break;default:e.show()}return n.hide(t(h).not(e.parent().is(c)?e:e.closest(c).find(h).not(e.siblings()))),n},hide:function(t){var e=this;switch(e.options.hideEffect){case"none":t.hide();break;case"hide":t.hide(e.options.hideEffectSpeed);break;case"slideUp":t.slideUp(e.options.hideEffectSpeed);break;case"fadeOut":t.fadeOut(e.options.hideEffectSpeed);break;default:t.hide()}return e},_triggerShow:function(t,e){var n=this;return t.parent().is(c)||t.next().is(h)?n.show(t.next(h),e):t.parent().is(h)&&n.show(t.parent(),e),n},_addCSSClasses:function(){return"jqueryui"===this.options.theme?(this.focusClass="ui-state-default",this.hoverClass="ui-state-hover",this.element.addClass("ui-widget").find(".toc-title").addClass("ui-widget-header").end().find("li").addClass("ui-widget-content")):"bootstrap"===this.options.theme?(this.element.find(c+","+h).addClass("nav nav-list"),this.focusClass="active"):(this.focusClass=a,this.hoverClass=o),this},setOption:function(){t.Widget.prototype._setOption.apply(this,arguments)},setOptions:function(){t.Widget.prototype._setOptions.apply(this,arguments)},_scrollTo:function(e){var n=this,r=n.options.smoothScroll||0,i=n.options.scrollTo;return t("html, body").promise().done(function(){t("html, body").animate({scrollTop:t('div[data-unique="'+e.attr("data-unique")+'"]').next().offset().top-(t.isFunction(i)?i.call():i)+"px"},{duration:r})}),n}})}),/*! | ||
(function (t) { 'use strict'; t(window.jQuery, window, document) }(function (t, e, n, r) { 'use strict'; var i = 'tocify', a = 'tocify-focus', o = 'tocify-hover', u = 'tocify-hide', s = 'tocify-header', c = '.' + s, l = 'tocify-subheader', h = '.' + l, f = 'tocify-item', d = '.' + f, p = 'tocify-extend-page', g = '.' + p; t.widget('toc.tocify', {version: '1.8.0', options: {context: 'body', ignoreSelector: null, selectors: 'h1, h2, h3', showAndHide: !0, showEffect: 'slideDown', showEffectSpeed: 'medium', hideEffect: 'slideUp', hideEffectSpeed: 'medium', smoothScroll: !0, smoothScrollSpeed: 'medium', scrollTo: 0, showAndHideOnScroll: !0, highlightOnScroll: !0, highlightOffset: 40, theme: 'bootstrap', extendPage: !0, extendPageOffset: 100, history: !0, scrollHistory: !1, hashGenerator: 'compact', highlightDefault: !0}, _create: function () { var n = this; n.tocifyWrapper = t('.tocify-wrapper'), n.extendPageScroll = !0, n.items = [], n._generateToc(), n.cachedHeights = [], n.cachedAnchors = [], n._addCSSClasses(), n.webkit = (function () { for (var t in e) if (t && t.toLowerCase().indexOf('webkit') !== -1) return !0; return !1 }()), n._setEventHandlers(), t(e).load(function () { n._setActiveElement(!0), t('html, body').promise().done(function () { setTimeout(function () { n.extendPageScroll = !1 }, 0) }) }) }, _generateToc: function () { var e, n, r = this, a = r.options.ignoreSelector; return e = t(this.options.context).find(this.options.selectors.indexOf(',') !== -1 ? this.options.selectors.replace(/ /g, '').substr(0, this.options.selectors.indexOf(',')) : this.options.selectors.replace(/ /g, '')), e.length ? (r.element.addClass(i), void e.each(function (e) { t(this).is(a) || (n = t('<ul/>', {id: s + e, 'class': s}).append(r._nestElements(t(this), e)), r.element.append(n), t(this).nextUntil(this.nodeName.toLowerCase()).each(function () { t(this).find(r.options.selectors).length === 0 ? t(this).filter(r.options.selectors).each(function () { t(this).is(a) || r._appendSubheaders.call(this, r, n) }) : t(this).find(r.options.selectors).each(function () { t(this).is(a) || r._appendSubheaders.call(this, r, n) }) })) })) : void r.element.addClass(u) }, _setActiveElement: function (t) { var n = this, r = e.location.hash.substring(1), i = n.element.find("li[data-unique='" + r + "']"); return r.length ? (n.element.find('.' + n.focusClass).removeClass(n.focusClass), i.addClass(n.focusClass), n.options.showAndHide && i.click()) : (n.element.find('.' + n.focusClass).removeClass(n.focusClass), !r.length && t && n.options.highlightDefault && n.element.find(d).first().addClass(n.focusClass)), n }, _nestElements: function (e, n) { var r, i, a; return r = t.grep(this.items, function (t) { return t === e.text() }), this.items.push(r.length ? e.text() + n : e.text()), a = this._generateHashValue(r, e, n), i = t('<li/>', {'class': f, 'data-unique': a}).append(t('<a/>', {text: e.text()})), e.before(t('<div/>', {name: a, 'data-unique': a})), i }, _generateHashValue: function (t, e, n) { var r = '', i = this.options.hashGenerator; if (i === 'pretty') { for (r = e.text().toLowerCase().replace(/\s/g, '-'), r = r.replace(/[^\x00-\x7F]/g, ''); r.indexOf('--') > -1;)r = r.replace(/--/g, '-'); for (;r.indexOf(':-') > -1;)r = r.replace(/:-/g, '-') } else r = typeof i === 'function' ? i(e.text(), e) : e.text().replace(/\s/g, ''); return t.length && (r += '' + n), r }, _appendSubheaders: function (e, n) { var r = t(this).index(e.options.selectors), i = t(e.options.selectors).eq(r - 1), a = +t(this).prop('tagName').charAt(1), o = +i.prop('tagName').charAt(1); o > a ? e.element.find(h + '[data-tag=' + a + ']').last().append(e._nestElements(t(this), r)) : a === o ? n.find(d).last().after(e._nestElements(t(this), r)) : n.find(d).last().after(t('<ul/>', {'class': l, 'data-tag': a})).next(h).append(e._nestElements(t(this), r)) }, _setEventHandlers: function () { var i = this; this.element.on('click.tocify', 'li', function () { if (i.options.history && (e.location.hash = t(this).attr('data-unique')), i.element.find('.' + i.focusClass).removeClass(i.focusClass), t(this).addClass(i.focusClass), i.options.showAndHide) { var n = t('li[data-unique="' + t(this).attr('data-unique') + '"]'); i._triggerShow(n) }i._scrollTo(t(this)) }), this.element.find('li').on({'mouseenter.tocify': function () { t(this).addClass(i.hoverClass), t(this).css('cursor', 'pointer') }, 'mouseleave.tocify': function () { i.options.theme !== 'bootstrap' && t(this).removeClass(i.hoverClass) }}), t(e).on('resize', function () { i.calculateHeights() }), t(e).on('scroll.tocify', function () { t('html, body').promise().done(function () { var a, o, u, s, c = t(e).scrollTop(), l = t(e).height(), h = t(n).height(), f = t('body')[0].scrollHeight; if (i.options.extendPage && (i.webkit && c >= f - l - i.options.extendPageOffset || !i.webkit && l + c > h - i.options.extendPageOffset) && !t(g).length) { if (o = t('div[data-unique="' + t(d).last().attr('data-unique') + '"]'), !o.length) return; u = o.offset().top, t(i.options.context).append(t('<div />', {'class': p, height: Math.abs(u - c) + 'px', 'data-unique': p})), i.extendPageScroll && (s = i.element.find('li.active'), i._scrollTo(t('div[data-unique=' + s.attr('data-unique') + ']'))) }setTimeout(function () { var o, u = null; i.cachedHeights.length == 0 && i.calculateHeights(); var s = t(e).scrollTop(); if (i.cachedAnchors.each(function (t) { return i.cachedHeights[t] - s < 0 ? void (u = t) : !1 }), o = t(i.cachedAnchors[u]).attr('data-unique'), a = t('li[data-unique="' + o + '"]'), i.options.highlightOnScroll && a.length && !a.hasClass(i.focusClass)) { i.element.find('.' + i.focusClass).removeClass(i.focusClass), a.addClass(i.focusClass); var c = i.tocifyWrapper, l = t(a).closest('.tocify-header'), h = l.offset().top, f = c.offset().top, d = h - f; if (d >= t(e).height()) { var p = d + c.scrollTop(); c.scrollTop(p) } else d < 0 && c.scrollTop(0) }i.options.scrollHistory && e.location.hash !== '#' + o && o !== r && (history.replaceState ? history.replaceState({}, '', '#' + o) : (scrollV = n.body.scrollTop, scrollH = n.body.scrollLeft, location.hash = '#' + o, n.body.scrollTop = scrollV, n.body.scrollLeft = scrollH)), i.options.showAndHideOnScroll && i.options.showAndHide && i._triggerShow(a, !0) }, 0) }) }) }, calculateHeights: function () { var e = this; e.cachedHeights = [], e.cachedAnchors = []; var n = t(e.options.context).find('div[data-unique]'); n.each(function (n) { var r = (t(this).next().length ? t(this).next() : t(this)).offset().top - e.options.highlightOffset; e.cachedHeights[n] = r }), e.cachedAnchors = n }, show: function (e) { var n = this; if (!e.is(':visible')) switch (e.find(h).length || e.parent().is(c) || e.parent().is(':visible') ? e.children(h).length || e.parent().is(c) || (e = e.closest(h)) : e = e.parents(h).add(e), n.options.showEffect) { case 'none':e.show(); break; case 'show':e.show(n.options.showEffectSpeed); break; case 'slideDown':e.slideDown(n.options.showEffectSpeed); break; case 'fadeIn':e.fadeIn(n.options.showEffectSpeed); break; default:e.show() } return n.hide(t(h).not(e.parent().is(c) ? e : e.closest(c).find(h).not(e.siblings()))), n }, hide: function (t) { var e = this; switch (e.options.hideEffect) { case 'none':t.hide(); break; case 'hide':t.hide(e.options.hideEffectSpeed); break; case 'slideUp':t.slideUp(e.options.hideEffectSpeed); break; case 'fadeOut':t.fadeOut(e.options.hideEffectSpeed); break; default:t.hide() } return e }, _triggerShow: function (t, e) { var n = this; return t.parent().is(c) || t.next().is(h) ? n.show(t.next(h), e) : t.parent().is(h) && n.show(t.parent(), e), n }, _addCSSClasses: function () { return this.options.theme === 'jqueryui' ? (this.focusClass = 'ui-state-default', this.hoverClass = 'ui-state-hover', this.element.addClass('ui-widget').find('.toc-title').addClass('ui-widget-header').end().find('li').addClass('ui-widget-content')) : this.options.theme === 'bootstrap' ? (this.element.find(c + ',' + h).addClass('nav nav-list'), this.focusClass = 'active') : (this.focusClass = a, this.hoverClass = o), this }, setOption: function () { t.Widget.prototype._setOption.apply(this, arguments) }, setOptions: function () { t.Widget.prototype._setOptions.apply(this, arguments) }, _scrollTo: function (e) { var n = this, r = n.options.smoothScroll || 0, i = n.options.scrollTo; return t('html, body').promise().done(function () { t('html, body').animate({scrollTop: t('div[data-unique="' + e.attr('data-unique') + '"]').next().offset().top - (t.isFunction(i) ? i.call() : i) + 'px'}, {duration: r}) }), n }}) })), /*! | ||
* imagesLoaded PACKAGED v3.1.8 | ||
@@ -46,2 +47,2 @@ * JavaScript is all like "You images are done yet or what?" | ||
*/ | ||
function(){function t(){}function e(t,e){for(var n=t.length;n--;)if(t[n].listener===e)return n;return-1}function n(t){return function(){return this[t].apply(this,arguments)}}var r=t.prototype,i=this,a=i.EventEmitter;r.getListeners=function(t){var e,n,r=this._getEvents();if("object"==typeof t){e={};for(n in r)r.hasOwnProperty(n)&&t.test(n)&&(e[n]=r[n])}else e=r[t]||(r[t]=[]);return e},r.flattenListeners=function(t){var e,n=[];for(e=0;t.length>e;e+=1)n.push(t[e].listener);return n},r.getListenersAsObject=function(t){var e,n=this.getListeners(t);return n instanceof Array&&(e={},e[t]=n),e||n},r.addListener=function(t,n){var r,i=this.getListenersAsObject(t),a="object"==typeof n;for(r in i)i.hasOwnProperty(r)&&-1===e(i[r],n)&&i[r].push(a?n:{listener:n,once:!1});return this},r.on=n("addListener"),r.addOnceListener=function(t,e){return this.addListener(t,{listener:e,once:!0})},r.once=n("addOnceListener"),r.defineEvent=function(t){return this.getListeners(t),this},r.defineEvents=function(t){for(var e=0;t.length>e;e+=1)this.defineEvent(t[e]);return this},r.removeListener=function(t,n){var r,i,a=this.getListenersAsObject(t);for(i in a)a.hasOwnProperty(i)&&(r=e(a[i],n),-1!==r&&a[i].splice(r,1));return this},r.off=n("removeListener"),r.addListeners=function(t,e){return this.manipulateListeners(!1,t,e)},r.removeListeners=function(t,e){return this.manipulateListeners(!0,t,e)},r.manipulateListeners=function(t,e,n){var r,i,a=t?this.removeListener:this.addListener,o=t?this.removeListeners:this.addListeners;if("object"!=typeof e||e instanceof RegExp)for(r=n.length;r--;)a.call(this,e,n[r]);else for(r in e)e.hasOwnProperty(r)&&(i=e[r])&&("function"==typeof i?a.call(this,r,i):o.call(this,r,i));return this},r.removeEvent=function(t){var e,n=typeof t,r=this._getEvents();if("string"===n)delete r[t];else if("object"===n)for(e in r)r.hasOwnProperty(e)&&t.test(e)&&delete r[e];else delete this._events;return this},r.removeAllListeners=n("removeEvent"),r.emitEvent=function(t,e){var n,r,i,a,o=this.getListenersAsObject(t);for(i in o)if(o.hasOwnProperty(i))for(r=o[i].length;r--;)n=o[i][r],n.once===!0&&this.removeListener(t,n.listener),a=n.listener.apply(this,e||[]),a===this._getOnceReturnValue()&&this.removeListener(t,n.listener);return this},r.trigger=n("emitEvent"),r.emit=function(t){var e=Array.prototype.slice.call(arguments,1);return this.emitEvent(t,e)},r.setOnceReturnValue=function(t){return this._onceReturnValue=t,this},r._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},r._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return i.EventEmitter=a,t},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return t}):"object"==typeof module&&module.exports?module.exports=t:this.EventEmitter=t}.call(this),function(t){function e(e){var n=t.event;return n.target=n.target||n.srcElement||e,n}var n=document.documentElement,r=function(){};n.addEventListener?r=function(t,e,n){t.addEventListener(e,n,!1)}:n.attachEvent&&(r=function(t,n,r){t[n+r]=r.handleEvent?function(){var n=e(t);r.handleEvent.call(r,n)}:function(){var n=e(t);r.call(t,n)},t.attachEvent("on"+n,t[n+r])});var i=function(){};n.removeEventListener?i=function(t,e,n){t.removeEventListener(e,n,!1)}:n.detachEvent&&(i=function(t,e,n){t.detachEvent("on"+e,t[e+n]);try{delete t[e+n]}catch(r){t[e+n]=void 0}});var a={bind:r,unbind:i};"function"==typeof define&&define.amd?define("eventie/eventie",a):t.eventie=a}(this),function(t,e){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,r){return e(t,n,r)}):"object"==typeof exports?module.exports=e(t,require("wolfy87-eventemitter"),require("eventie")):t.imagesLoaded=e(t,t.EventEmitter,t.eventie)}(window,function(t,e,n){function r(t,e){for(var n in e)t[n]=e[n];return t}function i(t){return"[object Array]"===f.call(t)}function a(t){var e=[];if(i(t))e=t;else if("number"==typeof t.length)for(var n=0,r=t.length;r>n;n++)e.push(t[n]);else e.push(t);return e}function o(t,e,n){if(!(this instanceof o))return new o(t,e);"string"==typeof t&&(t=document.querySelectorAll(t)),this.elements=a(t),this.options=r({},this.options),"function"==typeof e?n=e:r(this.options,e),n&&this.on("always",n),this.getImages(),c&&(this.jqDeferred=new c.Deferred);var i=this;setTimeout(function(){i.check()})}function u(t){this.img=t}function s(t){this.src=t,d[t]=this}var c=t.jQuery,l=t.console,h=void 0!==l,f=Object.prototype.toString;o.prototype=new e,o.prototype.options={},o.prototype.getImages=function(){this.images=[];for(var t=0,e=this.elements.length;e>t;t++){var n=this.elements[t];"IMG"===n.nodeName&&this.addImage(n);var r=n.nodeType;if(r&&(1===r||9===r||11===r))for(var i=n.querySelectorAll("img"),a=0,o=i.length;o>a;a++){var u=i[a];this.addImage(u)}}},o.prototype.addImage=function(t){var e=new u(t);this.images.push(e)},o.prototype.check=function(){function t(t,i){return e.options.debug&&h&&l.log("confirm",t,i),e.progress(t),n++,n===r&&e.complete(),!0}var e=this,n=0,r=this.images.length;if(this.hasAnyBroken=!1,!r)return void this.complete();for(var i=0;r>i;i++){var a=this.images[i];a.on("confirm",t),a.check()}},o.prototype.progress=function(t){this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded;var e=this;setTimeout(function(){e.emit("progress",e,t),e.jqDeferred&&e.jqDeferred.notify&&e.jqDeferred.notify(e,t)})},o.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var e=this;setTimeout(function(){if(e.emit(t,e),e.emit("always",e),e.jqDeferred){var n=e.hasAnyBroken?"reject":"resolve";e.jqDeferred[n](e)}})},c&&(c.fn.imagesLoaded=function(t,e){var n=new o(this,t,e);return n.jqDeferred.promise(c(this))}),u.prototype=new e,u.prototype.check=function(){var t=d[this.img.src]||new s(this.img.src);if(t.isConfirmed)return void this.confirm(t.isLoaded,"cached was confirmed");if(this.img.complete&&void 0!==this.img.naturalWidth)return void this.confirm(0!==this.img.naturalWidth,"naturalWidth");var e=this;t.on("confirm",function(t,n){return e.confirm(t.isLoaded,n),!0}),t.check()},u.prototype.confirm=function(t,e){this.isLoaded=t,this.emit("confirm",this,e)};var d={};return s.prototype=new e,s.prototype.check=function(){if(!this.isChecked){var t=new Image;n.bind(t,"load",this),n.bind(t,"error",this),t.src=this.src,this.isChecked=!0}},s.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},s.prototype.onload=function(t){this.confirm(!0,"onload"),this.unbindProxyEvents(t)},s.prototype.onerror=function(t){this.confirm(!1,"onerror"),this.unbindProxyEvents(t)},s.prototype.confirm=function(t,e){this.isConfirmed=!0,this.isLoaded=t,this.emit("confirm",this,e)},s.prototype.unbindProxyEvents=function(t){n.unbind(t.target,"load",this),n.unbind(t.target,"error",this)},o}),function(t){"use strict";function e(){setTimeout(function(){toc.setOption("showEffectSpeed",180)},50)}var n=function(){$(".tocify-wrapper").removeClass("open"),$("#nav-button").removeClass("open")},r=function(){t.toc=$("#toc").tocify({selectors:"h1, h2",extendPage:!1,theme:"none",smoothScroll:!1,showEffectSpeed:0,hideEffectSpeed:180,ignoreSelector:".toc-ignore",highlightOffset:60,scrollTo:-1,scrollHistory:!0,hashGenerator:function(t,e){return e.prop("id")}}).data("toc-tocify"),$("#nav-button").click(function(){return $(".tocify-wrapper").toggleClass("open"),$("#nav-button").toggleClass("open"),!1}),$(".page-wrapper").click(n),$(".tocify-item").click(n)};$(function(){r(),e(),$(".content").imagesLoaded(function(){t.toc.calculateHeights()})})}(window); | ||
(function () { function t () {} function e (t, e) { for (var n = t.length; n--;) if (t[n].listener === e) return n; return -1 } function n (t) { return function () { return this[t].apply(this, arguments) } } var r = t.prototype, i = this, a = i.EventEmitter; r.getListeners = function (t) { var e, n, r = this._getEvents(); if (typeof t === 'object') { e = {}; for (n in r)r.hasOwnProperty(n) && t.test(n) && (e[n] = r[n]) } else e = r[t] || (r[t] = []); return e }, r.flattenListeners = function (t) { var e, n = []; for (e = 0; t.length > e; e += 1)n.push(t[e].listener); return n }, r.getListenersAsObject = function (t) { var e, n = this.getListeners(t); return n instanceof Array && (e = {}, e[t] = n), e || n }, r.addListener = function (t, n) { var r, i = this.getListenersAsObject(t), a = typeof n === 'object'; for (r in i)i.hasOwnProperty(r) && e(i[r], n) === -1 && i[r].push(a ? n : {listener: n, once: !1}); return this }, r.on = n('addListener'), r.addOnceListener = function (t, e) { return this.addListener(t, {listener: e, once: !0}) }, r.once = n('addOnceListener'), r.defineEvent = function (t) { return this.getListeners(t), this }, r.defineEvents = function (t) { for (var e = 0; t.length > e; e += 1) this.defineEvent(t[e]); return this }, r.removeListener = function (t, n) { var r, i, a = this.getListenersAsObject(t); for (i in a)a.hasOwnProperty(i) && (r = e(a[i], n), r !== -1 && a[i].splice(r, 1)); return this }, r.off = n('removeListener'), r.addListeners = function (t, e) { return this.manipulateListeners(!1, t, e) }, r.removeListeners = function (t, e) { return this.manipulateListeners(!0, t, e) }, r.manipulateListeners = function (t, e, n) { var r, i, a = t ? this.removeListener : this.addListener, o = t ? this.removeListeners : this.addListeners; if (typeof e !== 'object' || e instanceof RegExp) for (r = n.length; r--;)a.call(this, e, n[r]); else for (r in e)e.hasOwnProperty(r) && (i = e[r]) && (typeof i === 'function' ? a.call(this, r, i) : o.call(this, r, i)); return this }, r.removeEvent = function (t) { var e, n = typeof t, r = this._getEvents(); if (n === 'string') delete r[t]; else if (n === 'object') for (e in r)r.hasOwnProperty(e) && t.test(e) && delete r[e]; else delete this._events; return this }, r.removeAllListeners = n('removeEvent'), r.emitEvent = function (t, e) { var n, r, i, a, o = this.getListenersAsObject(t); for (i in o) if (o.hasOwnProperty(i)) for (r = o[i].length; r--;)n = o[i][r], n.once === !0 && this.removeListener(t, n.listener), a = n.listener.apply(this, e || []), a === this._getOnceReturnValue() && this.removeListener(t, n.listener); return this }, r.trigger = n('emitEvent'), r.emit = function (t) { var e = Array.prototype.slice.call(arguments, 1); return this.emitEvent(t, e) }, r.setOnceReturnValue = function (t) { return this._onceReturnValue = t, this }, r._getOnceReturnValue = function () { return this.hasOwnProperty('_onceReturnValue') ? this._onceReturnValue : !0 }, r._getEvents = function () { return this._events || (this._events = {}) }, t.noConflict = function () { return i.EventEmitter = a, t }, typeof define === 'function' && define.amd ? define('eventEmitter/EventEmitter', [], function () { return t }) : typeof module === 'object' && module.exports ? module.exports = t : this.EventEmitter = t }.call(this)), (function (t) { function e (e) { var n = t.event; return n.target = n.target || n.srcElement || e, n } var n = document.documentElement, r = function () {}; n.addEventListener ? r = function (t, e, n) { t.addEventListener(e, n, !1) } : n.attachEvent && (r = function (t, n, r) { t[n + r] = r.handleEvent ? function () { var n = e(t); r.handleEvent.call(r, n) } : function () { var n = e(t); r.call(t, n) }, t.attachEvent('on' + n, t[n + r]) }); var i = function () {}; n.removeEventListener ? i = function (t, e, n) { t.removeEventListener(e, n, !1) } : n.detachEvent && (i = function (t, e, n) { t.detachEvent('on' + e, t[e + n]); try { delete t[e + n] } catch (r) { t[e + n] = void 0 } }); var a = {bind: r, unbind: i}; typeof define === 'function' && define.amd ? define('eventie/eventie', a) : t.eventie = a }(this)), (function (t, e) { typeof define === 'function' && define.amd ? define(['eventEmitter/EventEmitter', 'eventie/eventie'], function (n, r) { return e(t, n, r) }) : typeof exports === 'object' ? module.exports = e(t, require('wolfy87-eventemitter'), require('eventie')) : t.imagesLoaded = e(t, t.EventEmitter, t.eventie) }(window, function (t, e, n) { function r (t, e) { for (var n in e)t[n] = e[n]; return t } function i (t) { return f.call(t) === '[object Array]' } function a (t) { var e = []; if (i(t))e = t; else if (typeof t.length === 'number') for (var n = 0, r = t.length; r > n; n++)e.push(t[n]); else e.push(t); return e } function o (t, e, n) { if (!(this instanceof o)) return new o(t, e); typeof t === 'string' && (t = document.querySelectorAll(t)), this.elements = a(t), this.options = r({}, this.options), typeof e === 'function' ? n = e : r(this.options, e), n && this.on('always', n), this.getImages(), c && (this.jqDeferred = new c.Deferred()); var i = this; setTimeout(function () { i.check() }) } function u (t) { this.img = t } function s (t) { this.src = t, d[t] = this } var c = t.jQuery, l = t.console, h = void 0 !== l, f = Object.prototype.toString; o.prototype = new e(), o.prototype.options = {}, o.prototype.getImages = function () { this.images = []; for (var t = 0, e = this.elements.length; e > t; t++) { var n = this.elements[t]; n.nodeName === 'IMG' && this.addImage(n); var r = n.nodeType; if (r && (r === 1 || r === 9 || r === 11)) for (var i = n.querySelectorAll('img'), a = 0, o = i.length; o > a; a++) { var u = i[a]; this.addImage(u) } } }, o.prototype.addImage = function (t) { var e = new u(t); this.images.push(e) }, o.prototype.check = function () { function t (t, i) { return e.options.debug && h && l.log('confirm', t, i), e.progress(t), n++, n === r && e.complete(), !0 } var e = this, n = 0, r = this.images.length; if (this.hasAnyBroken = !1, !r) return void this.complete(); for (var i = 0; r > i; i++) { var a = this.images[i]; a.on('confirm', t), a.check() } }, o.prototype.progress = function (t) { this.hasAnyBroken = this.hasAnyBroken || !t.isLoaded; var e = this; setTimeout(function () { e.emit('progress', e, t), e.jqDeferred && e.jqDeferred.notify && e.jqDeferred.notify(e, t) }) }, o.prototype.complete = function () { var t = this.hasAnyBroken ? 'fail' : 'done'; this.isComplete = !0; var e = this; setTimeout(function () { if (e.emit(t, e), e.emit('always', e), e.jqDeferred) { var n = e.hasAnyBroken ? 'reject' : 'resolve'; e.jqDeferred[n](e) } }) }, c && (c.fn.imagesLoaded = function (t, e) { var n = new o(this, t, e); return n.jqDeferred.promise(c(this)) }), u.prototype = new e(), u.prototype.check = function () { var t = d[this.img.src] || new s(this.img.src); if (t.isConfirmed) return void this.confirm(t.isLoaded, 'cached was confirmed'); if (this.img.complete && void 0 !== this.img.naturalWidth) return void this.confirm(this.img.naturalWidth !== 0, 'naturalWidth'); var e = this; t.on('confirm', function (t, n) { return e.confirm(t.isLoaded, n), !0 }), t.check() }, u.prototype.confirm = function (t, e) { this.isLoaded = t, this.emit('confirm', this, e) }; var d = {}; return s.prototype = new e(), s.prototype.check = function () { if (!this.isChecked) { var t = new Image(); n.bind(t, 'load', this), n.bind(t, 'error', this), t.src = this.src, this.isChecked = !0 } }, s.prototype.handleEvent = function (t) { var e = 'on' + t.type; this[e] && this[e](t) }, s.prototype.onload = function (t) { this.confirm(!0, 'onload'), this.unbindProxyEvents(t) }, s.prototype.onerror = function (t) { this.confirm(!1, 'onerror'), this.unbindProxyEvents(t) }, s.prototype.confirm = function (t, e) { this.isConfirmed = !0, this.isLoaded = t, this.emit('confirm', this, e) }, s.prototype.unbindProxyEvents = function (t) { n.unbind(t.target, 'load', this), n.unbind(t.target, 'error', this) }, o })), (function (t) { 'use strict'; function e () { setTimeout(function () { toc.setOption('showEffectSpeed', 180) }, 50) } var n = function () { $('.tocify-wrapper').removeClass('open'), $('#nav-button').removeClass('open') }, r = function () { t.toc = $('#toc').tocify({selectors: 'h1, h2', extendPage: !1, theme: 'none', smoothScroll: !1, showEffectSpeed: 0, hideEffectSpeed: 180, ignoreSelector: '.toc-ignore', highlightOffset: 60, scrollTo: -1, scrollHistory: !0, hashGenerator: function (t, e) { return e.prop('id') }}).data('toc-tocify'), $('#nav-button').click(function () { return $('.tocify-wrapper').toggleClass('open'), $('#nav-button').toggleClass('open'), !1 }), $('.page-wrapper').click(n), $('.tocify-item').click(n) }; $(function () { r(), e(), $('.content').imagesLoaded(function () { t.toc.calculateHeights() }) }) }(window)) |
@@ -1,2 +0,2 @@ | ||
!function(){if("ontouchstart"in window){var t,e,n,r,i,o,a={};t=function(t,e){return Math.abs(t[0]-e[0])>5||Math.abs(t[1]-e[1])>5},e=function(t){this.startXY=[t.touches[0].clientX,t.touches[0].clientY],this.threshold=!1},n=function(e){return this.threshold?!1:void(this.threshold=t(this.startXY,[e.touches[0].clientX,e.touches[0].clientY]))},r=function(e){if(!this.threshold&&!t(this.startXY,[e.changedTouches[0].clientX,e.changedTouches[0].clientY])){var n=e.changedTouches[0],r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,0,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),r.simulated=!0,e.target.dispatchEvent(r)}},i=function(t){var e=Date.now(),n=e-a.time,r=t.clientX,i=t.clientY,s=[Math.abs(a.x-r),Math.abs(a.y-i)],u=o(t.target,"A")||t.target,c=u.nodeName,l="A"===c,h=window.navigator.standalone&&l&&t.target.getAttribute("href");return a.time=e,a.x=r,a.y=i,(!t.simulated&&(500>n||1500>n&&s[0]<50&&s[1]<50)||h)&&(t.preventDefault(),t.stopPropagation(),!h)?!1:(h&&(window.location=u.getAttribute("href")),void(u&&u.classList&&(u.classList.add("energize-focus"),window.setTimeout(function(){u.classList.remove("energize-focus")},150))))},o=function(t,e){for(var n=t;n!==document.body;){if(!n||n.nodeName===e)return n;n=n.parentNode}return null},document.addEventListener("touchstart",e,!1),document.addEventListener("touchmove",n,!1),document.addEventListener("touchend",r,!1),document.addEventListener("click",i,!0)}}(),/* | ||
!(function () { if ('ontouchstart' in window) { var t, e, n, r, i, o, a = {}; t = function (t, e) { return Math.abs(t[0] - e[0]) > 5 || Math.abs(t[1] - e[1]) > 5 }, e = function (t) { this.startXY = [t.touches[0].clientX, t.touches[0].clientY], this.threshold = !1 }, n = function (e) { return this.threshold ? !1 : void (this.threshold = t(this.startXY, [e.touches[0].clientX, e.touches[0].clientY])) }, r = function (e) { if (!this.threshold && !t(this.startXY, [e.changedTouches[0].clientX, e.changedTouches[0].clientY])) { var n = e.changedTouches[0], r = document.createEvent('MouseEvents'); r.initMouseEvent('click', !0, !0, window, 0, n.screenX, n.screenY, n.clientX, n.clientY, !1, !1, !1, !1, 0, null), r.simulated = !0, e.target.dispatchEvent(r) } }, i = function (t) { var e = Date.now(), n = e - a.time, r = t.clientX, i = t.clientY, s = [Math.abs(a.x - r), Math.abs(a.y - i)], u = o(t.target, 'A') || t.target, c = u.nodeName, l = c === 'A', h = window.navigator.standalone && l && t.target.getAttribute('href'); return a.time = e, a.x = r, a.y = i, (!t.simulated && (n < 500 || n < 1500 && s[0] < 50 && s[1] < 50) || h) && (t.preventDefault(), t.stopPropagation(), !h) ? !1 : (h && (window.location = u.getAttribute('href')), void (u && u.classList && (u.classList.add('energize-focus'), window.setTimeout(function () { u.classList.remove('energize-focus') }, 150)))) }, o = function (t, e) { for (var n = t; n !== document.body;) { if (!n || n.nodeName === e) return n; n = n.parentNode } return null }, document.addEventListener('touchstart', e, !1), document.addEventListener('touchmove', n, !1), document.addEventListener('touchend', r, !1), document.addEventListener('click', i, !0) } }()), /* | ||
Copyright 2008-2013 Concur Technologies, Inc. | ||
@@ -16,3 +16,3 @@ | ||
*/ | ||
function(t){"use strict";function e(e){if(e&&""!==e){$(".lang-selector a").removeClass("active"),$(".lang-selector a[data-language-name='"+e+"']").addClass("active");for(var n=0;n<u.length;n++)$(".highlight."+u[n]).hide();$(".highlight."+e).show(),t.toc.calculateHeights(),$(window.location.hash).get(0)&&$(window.location.hash).get(0).scrollIntoView(!0)}}function n(t){return"string"!=typeof t?{}:(t=t.trim().replace(/^(\?|#|&)/,""),t?t.split("&").reduce(function(t,e){var n=e.replace(/\+/g," ").split("="),r=n[0],i=n[1];return r=decodeURIComponent(r),i=void 0===i?null:decodeURIComponent(i),t.hasOwnProperty(r)?Array.isArray(t[r])?t[r].push(i):t[r]=[t[r],i]:t[r]=i,t},{}):{})}function r(t){return t?Object.keys(t).sort().map(function(e){var n=t[e];return Array.isArray(n)?n.sort().map(function(t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}).join("&"):encodeURIComponent(e)+"="+encodeURIComponent(n)}).join("&"):""}function i(){if(location.search.length>=1){var t=n(location.search).language;if(t)return t;if(-1!=jQuery.inArray(location.search.substr(1),u))return location.search.substr(1)}return!1}function o(t){var e=n(location.search);return e.language?(e.language=t,r(e)):t}function a(t){if(history){var e=window.location.hash;e&&(e=e.replace(/^#+/,"")),history.pushState({},"","?"+o(t)+"#"+e),localStorage.setItem("language",t)}}function s(t){var n=localStorage.getItem("language");u=t;var r=i();r?(e(r),localStorage.setItem("language",r)):e(null!==n&&-1!=jQuery.inArray(n,u)?n:u[0])}var u=[];t.setupLanguages=s,t.activateLanguage=e,$(function(){$(".lang-selector a").on("click",function(){var t=$(this).data("language-name");return a(t),e(t),!1}),window.onpopstate=function(){e(i())}})}(window),/** | ||
(function (t) { 'use strict'; function e (e) { if (e && e !== '') { $('.lang-selector a').removeClass('active'), $(".lang-selector a[data-language-name='" + e + "']").addClass('active'); for (var n = 0; n < u.length; n++)$('.highlight.' + u[n]).hide(); $('.highlight.' + e).show(), t.toc.calculateHeights(), $(window.location.hash).get(0) && $(window.location.hash).get(0).scrollIntoView(!0) } } function n (t) { return typeof t !== 'string' ? {} : (t = t.trim().replace(/^(\?|#|&)/, ''), t ? t.split('&').reduce(function (t, e) { var n = e.replace(/\+/g, ' ').split('='), r = n[0], i = n[1]; return r = decodeURIComponent(r), i = void 0 === i ? null : decodeURIComponent(i), t.hasOwnProperty(r) ? Array.isArray(t[r]) ? t[r].push(i) : t[r] = [t[r], i] : t[r] = i, t }, {}) : {}) } function r (t) { return t ? Object.keys(t).sort().map(function (e) { var n = t[e]; return Array.isArray(n) ? n.sort().map(function (t) { return encodeURIComponent(e) + '=' + encodeURIComponent(t) }).join('&') : encodeURIComponent(e) + '=' + encodeURIComponent(n) }).join('&') : '' } function i () { if (location.search.length >= 1) { var t = n(location.search).language; if (t) return t; if (jQuery.inArray(location.search.substr(1), u) != -1) return location.search.substr(1) } return !1 } function o (t) { var e = n(location.search); return e.language ? (e.language = t, r(e)) : t } function a (t) { if (history) { var e = window.location.hash; e && (e = e.replace(/^#+/, '')), history.pushState({}, '', '?' + o(t) + '#' + e), localStorage.setItem('language', t) } } function s (t) { var n = localStorage.getItem('language'); u = t; var r = i(); r ? (e(r), localStorage.setItem('language', r)) : e(n !== null && jQuery.inArray(n, u) != -1 ? n : u[0]) } var u = []; t.setupLanguages = s, t.activateLanguage = e, $(function () { $('.lang-selector a').on('click', function () { var t = $(this).data('language-name'); return a(t), e(t), !1 }), window.onpopstate = function () { e(i()) } }) }(window)), /** | ||
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.5.7 | ||
@@ -23,35 +23,36 @@ * Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
function(){var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.5.7",/*! | ||
(function () { | ||
var t = function (e) { var n = new t.Index(); return n.pipeline.add(t.trimmer, t.stopWordFilter, t.stemmer), e && e.call(n, n), n }; t.version = '0.5.7', /*! | ||
* lunr.utils | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.utils={},t.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),/*! | ||
t.utils = {}, t.utils.warn = (function (t) { return function (e) { t.console && console.warn && console.warn(e) } }(this)), /*! | ||
* lunr.EventEmitter | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");n.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},t.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var n=this.events[t].indexOf(e);this.events[t].splice(n,1),this.events[t].length||delete this.events[t]}},t.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){var e=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void 0,e)})}},t.EventEmitter.prototype.hasHandler=function(t){return t in this.events},/*! | ||
t.EventEmitter = function () { this.events = {} }, t.EventEmitter.prototype.addListener = function () { var t = Array.prototype.slice.call(arguments), e = t.pop(), n = t; if (typeof e !== 'function') throw new TypeError('last argument must be a function'); n.forEach(function (t) { this.hasHandler(t) || (this.events[t] = []), this.events[t].push(e) }, this) }, t.EventEmitter.prototype.removeListener = function (t, e) { if (this.hasHandler(t)) { var n = this.events[t].indexOf(e); this.events[t].splice(n, 1), this.events[t].length || delete this.events[t] } }, t.EventEmitter.prototype.emit = function (t) { if (this.hasHandler(t)) { var e = Array.prototype.slice.call(arguments, 1); this.events[t].forEach(function (t) { t.apply(void 0, e) }) } }, t.EventEmitter.prototype.hasHandler = function (t) { return t in this.events }, /*! | ||
* lunr.tokenizer | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.tokenizer=function(t){if(!arguments.length||null==t||void 0==t)return[];if(Array.isArray(t))return t.map(function(t){return t.toLowerCase()});for(var e=t.toString().replace(/^\s+/,""),n=e.length-1;n>=0;n--)if(/\S/.test(e.charAt(n))){e=e.substring(0,n+1);break}return e.split(/(?:\s+|\-)/).filter(function(t){return!!t}).map(function(t){return t.toLowerCase()})},/*! | ||
t.tokenizer = function (t) { if (!arguments.length || t == null || void 0 == t) return []; if (Array.isArray(t)) return t.map(function (t) { return t.toLowerCase() }); for (var e = t.toString().replace(/^\s+/, ''), n = e.length - 1; n >= 0; n--) if (/\S/.test(e.charAt(n))) { e = e.substring(0, n + 1); break } return e.split(/(?:\s+|\-)/).filter(function (t) { return !!t }).map(function (t) { return t.toLowerCase() }) }, /*! | ||
* lunr.Pipeline | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var r=t.Pipeline.registeredFunctions[e];if(!r)throw new Error("Cannot load un-registered function: "+e);n.add(r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e)+1;this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(t){var e=this._stack.indexOf(t);this._stack.splice(e,1)},t.Pipeline.prototype.run=function(t){for(var e=[],n=t.length,r=this._stack.length,i=0;n>i;i++){for(var o=t[i],a=0;r>a&&(o=this._stack[a](o,i,t),void 0!==o);a++);void 0!==o&&e.push(o)}return e},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},/*! | ||
t.Pipeline = function () { this._stack = [] }, t.Pipeline.registeredFunctions = {}, t.Pipeline.registerFunction = function (e, n) { n in this.registeredFunctions && t.utils.warn('Overwriting existing registered function: ' + n), e.label = n, t.Pipeline.registeredFunctions[e.label] = e }, t.Pipeline.warnIfFunctionNotRegistered = function (e) { var n = e.label && e.label in this.registeredFunctions; n || t.utils.warn('Function is not registered with pipeline. This may cause problems when serialising the index.\n', e) }, t.Pipeline.load = function (e) { var n = new t.Pipeline(); return e.forEach(function (e) { var r = t.Pipeline.registeredFunctions[e]; if (!r) throw new Error('Cannot load un-registered function: ' + e); n.add(r) }), n }, t.Pipeline.prototype.add = function () { var e = Array.prototype.slice.call(arguments); e.forEach(function (e) { t.Pipeline.warnIfFunctionNotRegistered(e), this._stack.push(e) }, this) }, t.Pipeline.prototype.after = function (e, n) { t.Pipeline.warnIfFunctionNotRegistered(n); var r = this._stack.indexOf(e) + 1; this._stack.splice(r, 0, n) }, t.Pipeline.prototype.before = function (e, n) { t.Pipeline.warnIfFunctionNotRegistered(n); var r = this._stack.indexOf(e); this._stack.splice(r, 0, n) }, t.Pipeline.prototype.remove = function (t) { var e = this._stack.indexOf(t); this._stack.splice(e, 1) }, t.Pipeline.prototype.run = function (t) { for (var e = [], n = t.length, r = this._stack.length, i = 0; n > i; i++) { for (var o = t[i], a = 0; r > a && (o = this._stack[a](o, i, t), void 0 !== o); a++);void 0 !== o && e.push(o) } return e }, t.Pipeline.prototype.reset = function () { this._stack = [] }, t.Pipeline.prototype.toJSON = function () { return this._stack.map(function (e) { return t.Pipeline.warnIfFunctionNotRegistered(e), e.label }) }, /*! | ||
* lunr.Vector | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.Vector=function(){this._magnitude=null,this.list=void 0,this.length=0},t.Vector.Node=function(t,e,n){this.idx=t,this.val=e,this.next=n},t.Vector.prototype.insert=function(e,n){var r=this.list;if(!r)return this.list=new t.Vector.Node(e,n,r),this.length++;for(var i=r,o=r.next;void 0!=o;){if(e<o.idx)return i.next=new t.Vector.Node(e,n,o),this.length++;i=o,o=o.next}return i.next=new t.Vector.Node(e,n,o),this.length++},t.Vector.prototype.magnitude=function(){if(this._magniture)return this._magnitude;for(var t,e=this.list,n=0;e;)t=e.val,n+=t*t,e=e.next;return this._magnitude=Math.sqrt(n)},t.Vector.prototype.dot=function(t){for(var e=this.list,n=t.list,r=0;e&&n;)e.idx<n.idx?e=e.next:e.idx>n.idx?n=n.next:(r+=e.val*n.val,e=e.next,n=n.next);return r},t.Vector.prototype.similarity=function(t){return this.dot(t)/(this.magnitude()*t.magnitude())},/*! | ||
t.Vector = function () { this._magnitude = null, this.list = void 0, this.length = 0 }, t.Vector.Node = function (t, e, n) { this.idx = t, this.val = e, this.next = n }, t.Vector.prototype.insert = function (e, n) { var r = this.list; if (!r) return this.list = new t.Vector.Node(e, n, r), this.length++; for (var i = r, o = r.next; void 0 != o;) { if (e < o.idx) return i.next = new t.Vector.Node(e, n, o), this.length++; i = o, o = o.next } return i.next = new t.Vector.Node(e, n, o), this.length++ }, t.Vector.prototype.magnitude = function () { if (this._magniture) return this._magnitude; for (var t, e = this.list, n = 0; e;)t = e.val, n += t * t, e = e.next; return this._magnitude = Math.sqrt(n) }, t.Vector.prototype.dot = function (t) { for (var e = this.list, n = t.list, r = 0; e && n;)e.idx < n.idx ? e = e.next : e.idx > n.idx ? n = n.next : (r += e.val * n.val, e = e.next, n = n.next); return r }, t.Vector.prototype.similarity = function (t) { return this.dot(t) / (this.magnitude() * t.magnitude()) }, /*! | ||
* lunr.SortedSet | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.SortedSet=function(){this.length=0,this.elements=[]},t.SortedSet.load=function(t){var e=new this;return e.elements=t,e.length=t.length,e},t.SortedSet.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(t){~this.indexOf(t)||this.elements.splice(this.locationFor(t),0,t)},this),this.length=this.elements.length},t.SortedSet.prototype.toArray=function(){return this.elements.slice()},t.SortedSet.prototype.map=function(t,e){return this.elements.map(t,e)},t.SortedSet.prototype.forEach=function(t,e){return this.elements.forEach(t,e)},t.SortedSet.prototype.indexOf=function(t,e,n){var e=e||0,n=n||this.elements.length,r=n-e,i=e+Math.floor(r/2),o=this.elements[i];return 1>=r?o===t?i:-1:t>o?this.indexOf(t,i,n):o>t?this.indexOf(t,e,i):o===t?i:void 0},t.SortedSet.prototype.locationFor=function(t,e,n){var e=e||0,n=n||this.elements.length,r=n-e,i=e+Math.floor(r/2),o=this.elements[i];if(1>=r){if(o>t)return i;if(t>o)return i+1}return t>o?this.locationFor(t,i,n):o>t?this.locationFor(t,e,i):void 0},t.SortedSet.prototype.intersect=function(e){for(var n=new t.SortedSet,r=0,i=0,o=this.length,a=e.length,s=this.elements,u=e.elements;;){if(r>o-1||i>a-1)break;s[r]!==u[i]?s[r]<u[i]?r++:s[r]>u[i]&&i++:(n.add(s[r]),r++,i++)}return n},t.SortedSet.prototype.clone=function(){var e=new t.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},t.SortedSet.prototype.union=function(t){var e,n,r;return this.length>=t.length?(e=this,n=t):(e=t,n=this),r=e.clone(),r.add.apply(r,n.toArray()),r},t.SortedSet.prototype.toJSON=function(){return this.toArray()},/*! | ||
t.SortedSet = function () { this.length = 0, this.elements = [] }, t.SortedSet.load = function (t) { var e = new this(); return e.elements = t, e.length = t.length, e }, t.SortedSet.prototype.add = function () { Array.prototype.slice.call(arguments).forEach(function (t) { ~this.indexOf(t) || this.elements.splice(this.locationFor(t), 0, t) }, this), this.length = this.elements.length }, t.SortedSet.prototype.toArray = function () { return this.elements.slice() }, t.SortedSet.prototype.map = function (t, e) { return this.elements.map(t, e) }, t.SortedSet.prototype.forEach = function (t, e) { return this.elements.forEach(t, e) }, t.SortedSet.prototype.indexOf = function (t, e, n) { var e = e || 0, n = n || this.elements.length, r = n - e, i = e + Math.floor(r / 2), o = this.elements[i]; return r <= 1 ? o === t ? i : -1 : t > o ? this.indexOf(t, i, n) : o > t ? this.indexOf(t, e, i) : o === t ? i : void 0 }, t.SortedSet.prototype.locationFor = function (t, e, n) { var e = e || 0, n = n || this.elements.length, r = n - e, i = e + Math.floor(r / 2), o = this.elements[i]; if (r <= 1) { if (o > t) return i; if (t > o) return i + 1 } return t > o ? this.locationFor(t, i, n) : o > t ? this.locationFor(t, e, i) : void 0 }, t.SortedSet.prototype.intersect = function (e) { for (var n = new t.SortedSet(), r = 0, i = 0, o = this.length, a = e.length, s = this.elements, u = e.elements; ;) { if (r > o - 1 || i > a - 1) break; s[r] !== u[i] ? s[r] < u[i] ? r++ : s[r] > u[i] && i++ : (n.add(s[r]), r++, i++) } return n }, t.SortedSet.prototype.clone = function () { var e = new t.SortedSet(); return e.elements = this.toArray(), e.length = e.elements.length, e }, t.SortedSet.prototype.union = function (t) { var e, n, r; return this.length >= t.length ? (e = this, n = t) : (e = t, n = this), r = e.clone(), r.add.apply(r, n.toArray()), r }, t.SortedSet.prototype.toJSON = function () { return this.toArray() }, /*! | ||
* lunr.Index | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.Store,this.tokenStore=new t.TokenStore,this.corpusTokens=new t.SortedSet,this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var t=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,t)},t.Index.prototype.off=function(t,e){return this.eventEmitter.removeListener(t,e)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;return n._fields=e.fields,n._ref=e.ref,n.documentStore=t.Store.load(e.documentStore),n.tokenStore=t.TokenStore.load(e.tokenStore),n.corpusTokens=t.SortedSet.load(e.corpusTokens),n.pipeline=t.Pipeline.load(e.pipeline),n},t.Index.prototype.field=function(t,e){var e=e||{},n={name:t,boost:e.boost||1};return this._fields.push(n),this},t.Index.prototype.ref=function(t){return this._ref=t,this},t.Index.prototype.add=function(e,n){var r={},i=new t.SortedSet,o=e[this._ref],n=void 0===n?!0:n;this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n.name]));r[n.name]=o,t.SortedSet.prototype.add.apply(i,o)},this),this.documentStore.set(o,i),t.SortedSet.prototype.add.apply(this.corpusTokens,i.toArray());for(var a=0;a<i.length;a++){var s=i.elements[a],u=this._fields.reduce(function(t,e){var n=r[e.name].length;if(!n)return t;var i=r[e.name].filter(function(t){return t===s}).length;return t+i/n*e.boost},0);this.tokenStore.add(s,{ref:o,tf:u})}n&&this.eventEmitter.emit("add",e,this)},t.Index.prototype.remove=function(t,e){var n=t[this._ref],e=void 0===e?!0:e;if(this.documentStore.has(n)){var r=this.documentStore.get(n);this.documentStore.remove(n),r.forEach(function(t){this.tokenStore.remove(t,n)},this),e&&this.eventEmitter.emit("remove",t,this)}},t.Index.prototype.update=function(t,e){var e=void 0===e?!0:e;this.remove(t,!1),this.add(t,!1),e&&this.eventEmitter.emit("update",t,this)},t.Index.prototype.idf=function(t){var e="@"+t;if(Object.prototype.hasOwnProperty.call(this._idfCache,e))return this._idfCache[e];var n=this.tokenStore.count(t),r=1;return n>0&&(r=1+Math.log(this.tokenStore.length/n)),this._idfCache[e]=r},t.Index.prototype.search=function(e){var n=this.pipeline.run(t.tokenizer(e)),r=new t.Vector,i=[],o=this._fields.reduce(function(t,e){return t+e.boost},0),a=n.some(function(t){return this.tokenStore.has(t)},this);if(!a)return[];n.forEach(function(e,n,a){var s=1/a.length*this._fields.length*o,u=this,c=this.tokenStore.expand(e).reduce(function(n,i){var o=u.corpusTokens.indexOf(i),a=u.idf(i),c=1,l=new t.SortedSet;if(i!==e){var h=Math.max(3,i.length-e.length);c=1/Math.log(h)}return o>-1&&r.insert(o,s*a*c),Object.keys(u.tokenStore.get(i)).forEach(function(t){l.add(t)}),n.union(l)},new t.SortedSet);i.push(c)},this);var s=i.reduce(function(t,e){return t.intersect(e)});return s.map(function(t){return{ref:t,score:r.similarity(this.documentVector(t))}},this).sort(function(t,e){return e.score-t.score})},t.Index.prototype.documentVector=function(e){for(var n=this.documentStore.get(e),r=n.length,i=new t.Vector,o=0;r>o;o++){var a=n.elements[o],s=this.tokenStore.get(a)[e].tf,u=this.idf(a);i.insert(this.corpusTokens.indexOf(a),s*u)}return i},t.Index.prototype.toJSON=function(){return{version:t.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(t){var e=Array.prototype.slice.call(arguments,1);e.unshift(this),t.apply(this,e)},/*! | ||
t.Index = function () { this._fields = [], this._ref = 'id', this.pipeline = new t.Pipeline(), this.documentStore = new t.Store(), this.tokenStore = new t.TokenStore(), this.corpusTokens = new t.SortedSet(), this.eventEmitter = new t.EventEmitter(), this._idfCache = {}, this.on('add', 'remove', 'update', function () { this._idfCache = {} }.bind(this)) }, t.Index.prototype.on = function () { var t = Array.prototype.slice.call(arguments); return this.eventEmitter.addListener.apply(this.eventEmitter, t) }, t.Index.prototype.off = function (t, e) { return this.eventEmitter.removeListener(t, e) }, t.Index.load = function (e) { e.version !== t.version && t.utils.warn('version mismatch: current ' + t.version + ' importing ' + e.version); var n = new this(); return n._fields = e.fields, n._ref = e.ref, n.documentStore = t.Store.load(e.documentStore), n.tokenStore = t.TokenStore.load(e.tokenStore), n.corpusTokens = t.SortedSet.load(e.corpusTokens), n.pipeline = t.Pipeline.load(e.pipeline), n }, t.Index.prototype.field = function (t, e) { var e = e || {}, n = {name: t, boost: e.boost || 1}; return this._fields.push(n), this }, t.Index.prototype.ref = function (t) { return this._ref = t, this }, t.Index.prototype.add = function (e, n) { var r = {}, i = new t.SortedSet(), o = e[this._ref], n = void 0 === n ? !0 : n; this._fields.forEach(function (n) { var o = this.pipeline.run(t.tokenizer(e[n.name])); r[n.name] = o, t.SortedSet.prototype.add.apply(i, o) }, this), this.documentStore.set(o, i), t.SortedSet.prototype.add.apply(this.corpusTokens, i.toArray()); for (var a = 0; a < i.length; a++) { var s = i.elements[a], u = this._fields.reduce(function (t, e) { var n = r[e.name].length; if (!n) return t; var i = r[e.name].filter(function (t) { return t === s }).length; return t + i / n * e.boost }, 0); this.tokenStore.add(s, {ref: o, tf: u}) }n && this.eventEmitter.emit('add', e, this) }, t.Index.prototype.remove = function (t, e) { var n = t[this._ref], e = void 0 === e ? !0 : e; if (this.documentStore.has(n)) { var r = this.documentStore.get(n); this.documentStore.remove(n), r.forEach(function (t) { this.tokenStore.remove(t, n) }, this), e && this.eventEmitter.emit('remove', t, this) } }, t.Index.prototype.update = function (t, e) { var e = void 0 === e ? !0 : e; this.remove(t, !1), this.add(t, !1), e && this.eventEmitter.emit('update', t, this) }, t.Index.prototype.idf = function (t) { var e = '@' + t; if (Object.prototype.hasOwnProperty.call(this._idfCache, e)) return this._idfCache[e]; var n = this.tokenStore.count(t), r = 1; return n > 0 && (r = 1 + Math.log(this.tokenStore.length / n)), this._idfCache[e] = r }, t.Index.prototype.search = function (e) { var n = this.pipeline.run(t.tokenizer(e)), r = new t.Vector(), i = [], o = this._fields.reduce(function (t, e) { return t + e.boost }, 0), a = n.some(function (t) { return this.tokenStore.has(t) }, this); if (!a) return []; n.forEach(function (e, n, a) { var s = 1 / a.length * this._fields.length * o, u = this, c = this.tokenStore.expand(e).reduce(function (n, i) { var o = u.corpusTokens.indexOf(i), a = u.idf(i), c = 1, l = new t.SortedSet(); if (i !== e) { var h = Math.max(3, i.length - e.length); c = 1 / Math.log(h) } return o > -1 && r.insert(o, s * a * c), Object.keys(u.tokenStore.get(i)).forEach(function (t) { l.add(t) }), n.union(l) }, new t.SortedSet()); i.push(c) }, this); var s = i.reduce(function (t, e) { return t.intersect(e) }); return s.map(function (t) { return {ref: t, score: r.similarity(this.documentVector(t))} }, this).sort(function (t, e) { return e.score - t.score }) }, t.Index.prototype.documentVector = function (e) { for (var n = this.documentStore.get(e), r = n.length, i = new t.Vector(), o = 0; r > o; o++) { var a = n.elements[o], s = this.tokenStore.get(a)[e].tf, u = this.idf(a); i.insert(this.corpusTokens.indexOf(a), s * u) } return i }, t.Index.prototype.toJSON = function () { return {version: t.version, fields: this._fields, ref: this._ref, documentStore: this.documentStore.toJSON(), tokenStore: this.tokenStore.toJSON(), corpusTokens: this.corpusTokens.toJSON(), pipeline: this.pipeline.toJSON()} }, t.Index.prototype.use = function (t) { var e = Array.prototype.slice.call(arguments, 1); e.unshift(this), t.apply(this, e) }, /*! | ||
* lunr.Store | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.Store=function(){this.store={},this.length=0},t.Store.load=function(e){var n=new this;return n.length=e.length,n.store=Object.keys(e.store).reduce(function(n,r){return n[r]=t.SortedSet.load(e.store[r]),n},{}),n},t.Store.prototype.set=function(t,e){this.has(t)||this.length++,this.store[t]=e},t.Store.prototype.get=function(t){return this.store[t]},t.Store.prototype.has=function(t){return t in this.store},t.Store.prototype.remove=function(t){this.has(t)&&(delete this.store[t],this.length--)},t.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},/*! | ||
t.Store = function () { this.store = {}, this.length = 0 }, t.Store.load = function (e) { var n = new this(); return n.length = e.length, n.store = Object.keys(e.store).reduce(function (n, r) { return n[r] = t.SortedSet.load(e.store[r]), n }, {}), n }, t.Store.prototype.set = function (t, e) { this.has(t) || this.length++, this.store[t] = e }, t.Store.prototype.get = function (t) { return this.store[t] }, t.Store.prototype.has = function (t) { return t in this.store }, t.Store.prototype.remove = function (t) { this.has(t) && (delete this.store[t], this.length--) }, t.Store.prototype.toJSON = function () { return {store: this.store, length: this.length} }, /*! | ||
* lunr.stemmer | ||
@@ -61,11 +62,11 @@ * Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.stemmer=function(){var t={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},e={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",r="[aeiouy]",i=n+"[^aeiouy]*",o=r+"[aeiou]*",a="^("+i+")?"+o+i,s="^("+i+")?"+o+i+"("+o+")?$",u="^("+i+")?"+o+i+o+i,c="^("+i+")?"+r,l=new RegExp(a),h=new RegExp(u),f=new RegExp(s),d=new RegExp(c),p=/^(.+?)(ss|i)es$/,g=/^(.+?)([^s])s$/,m=/^(.+?)eed$/,y=/^(.+?)(ed|ing)$/,v=/.$/,b=/(at|bl|iz)$/,_=new RegExp("([^aeiouylsz])\\1$"),x=new RegExp("^"+i+r+"[^aeiouwxy]$"),w=/^(.+?[^aeiou])y$/,E=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,A=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,k=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,D=/^(.+?)(s|t)(ion)$/,S=/^(.+?)e$/,C=/ll$/,M=new RegExp("^"+i+r+"[^aeiouwxy]$"),T=function(n){var r,i,o,a,s,u,c;if(n.length<3)return n;if(o=n.substr(0,1),"y"==o&&(n=o.toUpperCase()+n.substr(1)),a=p,s=g,a.test(n)?n=n.replace(a,"$1$2"):s.test(n)&&(n=n.replace(s,"$1$2")),a=m,s=y,a.test(n)){var T=a.exec(n);a=l,a.test(T[1])&&(a=v,n=n.replace(a,""))}else if(s.test(n)){var T=s.exec(n);r=T[1],s=d,s.test(r)&&(n=r,s=b,u=_,c=x,s.test(n)?n+="e":u.test(n)?(a=v,n=n.replace(a,"")):c.test(n)&&(n+="e"))}if(a=w,a.test(n)){var T=a.exec(n);r=T[1],n=r+"i"}if(a=E,a.test(n)){var T=a.exec(n);r=T[1],i=T[2],a=l,a.test(r)&&(n=r+t[i])}if(a=A,a.test(n)){var T=a.exec(n);r=T[1],i=T[2],a=l,a.test(r)&&(n=r+e[i])}if(a=k,s=D,a.test(n)){var T=a.exec(n);r=T[1],a=h,a.test(r)&&(n=r)}else if(s.test(n)){var T=s.exec(n);r=T[1]+T[2],s=h,s.test(r)&&(n=r)}if(a=S,a.test(n)){var T=a.exec(n);r=T[1],a=h,s=f,u=M,(a.test(r)||s.test(r)&&!u.test(r))&&(n=r)}return a=C,s=h,a.test(n)&&s.test(n)&&(a=v,n=n.replace(a,"")),"y"==o&&(n=o.toLowerCase()+n.substr(1)),n};return T}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),/*! | ||
t.stemmer = (function () { var t = {ational: 'ate', tional: 'tion', enci: 'ence', anci: 'ance', izer: 'ize', bli: 'ble', alli: 'al', entli: 'ent', eli: 'e', ousli: 'ous', ization: 'ize', ation: 'ate', ator: 'ate', alism: 'al', iveness: 'ive', fulness: 'ful', ousness: 'ous', aliti: 'al', iviti: 'ive', biliti: 'ble', logi: 'log'}, e = {icate: 'ic', ative: '', alize: 'al', iciti: 'ic', ical: 'ic', ful: '', ness: ''}, n = '[^aeiou]', r = '[aeiouy]', i = n + '[^aeiouy]*', o = r + '[aeiou]*', a = '^(' + i + ')?' + o + i, s = '^(' + i + ')?' + o + i + '(' + o + ')?$', u = '^(' + i + ')?' + o + i + o + i, c = '^(' + i + ')?' + r, l = new RegExp(a), h = new RegExp(u), f = new RegExp(s), d = new RegExp(c), p = /^(.+?)(ss|i)es$/, g = /^(.+?)([^s])s$/, m = /^(.+?)eed$/, y = /^(.+?)(ed|ing)$/, v = /.$/, b = /(at|bl|iz)$/, _ = new RegExp('([^aeiouylsz])\\1$'), x = new RegExp('^' + i + r + '[^aeiouwxy]$'), w = /^(.+?[^aeiou])y$/, E = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/, A = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/, k = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/, D = /^(.+?)(s|t)(ion)$/, S = /^(.+?)e$/, C = /ll$/, M = new RegExp('^' + i + r + '[^aeiouwxy]$'), T = function (n) { var r, i, o, a, s, u, c; if (n.length < 3) return n; if (o = n.substr(0, 1), o == 'y' && (n = o.toUpperCase() + n.substr(1)), a = p, s = g, a.test(n) ? n = n.replace(a, '$1$2') : s.test(n) && (n = n.replace(s, '$1$2')), a = m, s = y, a.test(n)) { var T = a.exec(n); a = l, a.test(T[1]) && (a = v, n = n.replace(a, '')) } else if (s.test(n)) { var T = s.exec(n); r = T[1], s = d, s.test(r) && (n = r, s = b, u = _, c = x, s.test(n) ? n += 'e' : u.test(n) ? (a = v, n = n.replace(a, '')) : c.test(n) && (n += 'e')) } if (a = w, a.test(n)) { var T = a.exec(n); r = T[1], n = r + 'i' } if (a = E, a.test(n)) { var T = a.exec(n); r = T[1], i = T[2], a = l, a.test(r) && (n = r + t[i]) } if (a = A, a.test(n)) { var T = a.exec(n); r = T[1], i = T[2], a = l, a.test(r) && (n = r + e[i]) } if (a = k, s = D, a.test(n)) { var T = a.exec(n); r = T[1], a = h, a.test(r) && (n = r) } else if (s.test(n)) { var T = s.exec(n); r = T[1] + T[2], s = h, s.test(r) && (n = r) } if (a = S, a.test(n)) { var T = a.exec(n); r = T[1], a = h, s = f, u = M, (a.test(r) || s.test(r) && !u.test(r)) && (n = r) } return a = C, s = h, a.test(n) && s.test(n) && (a = v, n = n.replace(a, '')), o == 'y' && (n = o.toLowerCase() + n.substr(1)), n }; return T }()), t.Pipeline.registerFunction(t.stemmer, 'stemmer'), /*! | ||
* lunr.stopWordFilter | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.stopWordFilter=function(e){return-1===t.stopWordFilter.stopWords.indexOf(e)?e:void 0},t.stopWordFilter.stopWords=new t.SortedSet,t.stopWordFilter.stopWords.length=119,t.stopWordFilter.stopWords.elements=["","a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"],t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),/*! | ||
t.stopWordFilter = function (e) { return t.stopWordFilter.stopWords.indexOf(e) === -1 ? e : void 0 }, t.stopWordFilter.stopWords = new t.SortedSet(), t.stopWordFilter.stopWords.length = 119, t.stopWordFilter.stopWords.elements = ['', 'a', 'able', 'about', 'across', 'after', 'all', 'almost', 'also', 'am', 'among', 'an', 'and', 'any', 'are', 'as', 'at', 'be', 'because', 'been', 'but', 'by', 'can', 'cannot', 'could', 'dear', 'did', 'do', 'does', 'either', 'else', 'ever', 'every', 'for', 'from', 'get', 'got', 'had', 'has', 'have', 'he', 'her', 'hers', 'him', 'his', 'how', 'however', 'i', 'if', 'in', 'into', 'is', 'it', 'its', 'just', 'least', 'let', 'like', 'likely', 'may', 'me', 'might', 'most', 'must', 'my', 'neither', 'no', 'nor', 'not', 'of', 'off', 'often', 'on', 'only', 'or', 'other', 'our', 'own', 'rather', 'said', 'say', 'says', 'she', 'should', 'since', 'so', 'some', 'than', 'that', 'the', 'their', 'them', 'then', 'there', 'these', 'they', 'this', 'tis', 'to', 'too', 'twas', 'us', 'wants', 'was', 'we', 'were', 'what', 'when', 'where', 'which', 'while', 'who', 'whom', 'why', 'will', 'with', 'would', 'yet', 'you', 'your'], t.Pipeline.registerFunction(t.stopWordFilter, 'stopWordFilter'), /*! | ||
* lunr.trimmer | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.trimmer=function(t){return t.replace(/^\W+/,"").replace(/\W+$/,"")},t.Pipeline.registerFunction(t.trimmer,"trimmer"),/*! | ||
t.trimmer = function (t) { return t.replace(/^\W+/, '').replace(/\W+$/, '') }, t.Pipeline.registerFunction(t.trimmer, 'trimmer'), /*! | ||
* lunr.stemmer | ||
@@ -75,3 +76,4 @@ * Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.TokenStore=function(){this.root={docs:{}},this.length=0},t.TokenStore.load=function(t){var e=new this;return e.root=t.root,e.length=t.length,e},t.TokenStore.prototype.add=function(t,e,n){var n=n||this.root,r=t[0],i=t.slice(1);return r in n||(n[r]={docs:{}}),0===i.length?(n[r].docs[e.ref]=e,void(this.length+=1)):this.add(i,e,n[r])},t.TokenStore.prototype.has=function(t){if(!t)return!1;for(var e=this.root,n=0;n<t.length;n++){if(!e[t[n]])return!1;e=e[t[n]]}return!0},t.TokenStore.prototype.getNode=function(t){if(!t)return{};for(var e=this.root,n=0;n<t.length;n++){if(!e[t[n]])return{};e=e[t[n]]}return e},t.TokenStore.prototype.get=function(t,e){return this.getNode(t,e).docs||{}},t.TokenStore.prototype.count=function(t,e){return Object.keys(this.get(t,e)).length},t.TokenStore.prototype.remove=function(t,e){if(t){for(var n=this.root,r=0;r<t.length;r++){if(!(t[r]in n))return;n=n[t[r]]}delete n.docs[e]}},t.TokenStore.prototype.expand=function(t,e){var n=this.getNode(t),r=n.docs||{},e=e||[];return Object.keys(r).length&&e.push(t),Object.keys(n).forEach(function(n){"docs"!==n&&e.concat(this.expand(t+n,e))},this),e},t.TokenStore.prototype.toJSON=function(){return{root:this.root,length:this.length}},function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.lunr=e()}(this,function(){return t})}(),/* | ||
t.TokenStore = function () { this.root = {docs: {}}, this.length = 0 }, t.TokenStore.load = function (t) { var e = new this(); return e.root = t.root, e.length = t.length, e }, t.TokenStore.prototype.add = function (t, e, n) { var n = n || this.root, r = t[0], i = t.slice(1); return r in n || (n[r] = {docs: {}}), i.length === 0 ? (n[r].docs[e.ref] = e, void (this.length += 1)) : this.add(i, e, n[r]) }, t.TokenStore.prototype.has = function (t) { if (!t) return !1; for (var e = this.root, n = 0; n < t.length; n++) { if (!e[t[n]]) return !1; e = e[t[n]] } return !0 }, t.TokenStore.prototype.getNode = function (t) { if (!t) return {}; for (var e = this.root, n = 0; n < t.length; n++) { if (!e[t[n]]) return {}; e = e[t[n]] } return e }, t.TokenStore.prototype.get = function (t, e) { return this.getNode(t, e).docs || {} }, t.TokenStore.prototype.count = function (t, e) { return Object.keys(this.get(t, e)).length }, t.TokenStore.prototype.remove = function (t, e) { if (t) { for (var n = this.root, r = 0; r < t.length; r++) { if (!(t[r] in n)) return; n = n[t[r]] } delete n.docs[e] } }, t.TokenStore.prototype.expand = function (t, e) { var n = this.getNode(t), r = n.docs || {}, e = e || []; return Object.keys(r).length && e.push(t), Object.keys(n).forEach(function (n) { n !== 'docs' && e.concat(this.expand(t + n, e)) }, this), e }, t.TokenStore.prototype.toJSON = function () { return {root: this.root, length: this.length} }, (function (t, e) { typeof define === 'function' && define.amd ? define(e) : typeof exports === 'object' ? module.exports = e() : t.lunr = e() }(this, function () { return t })) | ||
}()), /* | ||
* jQuery Highlight plugin | ||
@@ -120,7 +122,7 @@ * | ||
*/ | ||
jQuery.extend({highlight:function(t,e,n,r){if(3===t.nodeType){var i=t.data.match(e);if(i){var o=document.createElement(n||"span");o.className=r||"highlight";var a=t.splitText(i.index);a.splitText(i[0].length);var s=a.cloneNode(!0);return o.appendChild(s),a.parentNode.replaceChild(o,a),1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&(t.tagName!==n.toUpperCase()||t.className!==r))for(var u=0;u<t.childNodes.length;u++)u+=jQuery.highlight(t.childNodes[u],e,n,r);return 0}}),jQuery.fn.unhighlight=function(t){var e={className:"highlight",element:"span"};return jQuery.extend(e,t),this.find(e.element+"."+e.className).each(function(){var t=this.parentNode;t.replaceChild(this.firstChild,this),t.normalize()}).end()},jQuery.fn.highlight=function(t,e){var n={className:"highlight",element:"span",caseSensitive:!1,wordsOnly:!1};if(jQuery.extend(n,e),t.constructor===String&&(t=[t]),t=jQuery.grep(t,function(t){return""!=t}),t=jQuery.map(t,function(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}),0==t.length)return this;var r=n.caseSensitive?"":"i",i="("+t.join("|")+")";n.wordsOnly&&(i="\\b"+i+"\\b");var o=new RegExp(i,r);return this.each(function(){jQuery.highlight(this,o,n.element,n.className)})},function(){"use strict";function t(){$("h1, h2").each(function(){var t=$(this),e=t.nextUntil("h1, h2");u.add({id:t.prop("id"),title:t.text(),body:e.text()})})}function e(){o=$(".content"),a=$(".search-results"),$("#input-search").on("keyup",n)}function n(t){if(i(),a.addClass("visible"),27===t.keyCode&&(this.value=""),this.value){var e=u.search(this.value).filter(function(t){return t.score>1e-4});e.length?(a.empty(),$.each(e,function(t,e){var n=document.getElementById(e.ref);a.append("<li><a href='#"+e.ref+"'>"+$(n).text()+"</a></li>")}),r.call(this)):(a.html("<li></li>"),$(".search-results li").text('No Results Found for "'+this.value+'"'))}else i(),a.removeClass("visible")}function r(){this.value&&o.highlight(this.value,s)}function i(){o.unhighlight(s)}var o,a,s={element:"span",className:"search-highlight"},u=new lunr.Index;u.ref("id"),u.field("title",{boost:10}),u.field("body"),u.pipeline.add(lunr.trimmer,lunr.stopWordFilter),$(t),$(e)}(),/*! jQuery UI - v1.11.3 - 2015-02-12 | ||
jQuery.extend({highlight: function (t, e, n, r) { if (t.nodeType === 3) { var i = t.data.match(e); if (i) { var o = document.createElement(n || 'span'); o.className = r || 'highlight'; var a = t.splitText(i.index); a.splitText(i[0].length); var s = a.cloneNode(!0); return o.appendChild(s), a.parentNode.replaceChild(o, a), 1 } } else if (t.nodeType === 1 && t.childNodes && !/(script|style)/i.test(t.tagName) && (t.tagName !== n.toUpperCase() || t.className !== r)) for (var u = 0; u < t.childNodes.length; u++)u += jQuery.highlight(t.childNodes[u], e, n, r); return 0 }}), jQuery.fn.unhighlight = function (t) { var e = {className: 'highlight', element: 'span'}; return jQuery.extend(e, t), this.find(e.element + '.' + e.className).each(function () { var t = this.parentNode; t.replaceChild(this.firstChild, this), t.normalize() }).end() }, jQuery.fn.highlight = function (t, e) { var n = {className: 'highlight', element: 'span', caseSensitive: !1, wordsOnly: !1}; if (jQuery.extend(n, e), t.constructor === String && (t = [t]), t = jQuery.grep(t, function (t) { return t != '' }), t = jQuery.map(t, function (t) { return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') }), t.length == 0) return this; var r = n.caseSensitive ? '' : 'i', i = '(' + t.join('|') + ')'; n.wordsOnly && (i = '\\b' + i + '\\b'); var o = new RegExp(i, r); return this.each(function () { jQuery.highlight(this, o, n.element, n.className) }) }, (function () { 'use strict'; function t () { $('h1, h2').each(function () { var t = $(this), e = t.nextUntil('h1, h2'); u.add({id: t.prop('id'), title: t.text(), body: e.text()}) }) } function e () { o = $('.content'), a = $('.search-results'), $('#input-search').on('keyup', n) } function n (t) { if (i(), a.addClass('visible'), t.keyCode === 27 && (this.value = ''), this.value) { var e = u.search(this.value).filter(function (t) { return t.score > 1e-4 }); e.length ? (a.empty(), $.each(e, function (t, e) { var n = document.getElementById(e.ref); a.append("<li><a href='#" + e.ref + "'>" + $(n).text() + '</a></li>') }), r.call(this)) : (a.html('<li></li>'), $('.search-results li').text('No Results Found for "' + this.value + '"')) } else i(), a.removeClass('visible') } function r () { this.value && o.highlight(this.value, s) } function i () { o.unhighlight(s) } var o, a, s = {element: 'span', className: 'search-highlight'}, u = new lunr.Index(); u.ref('id'), u.field('title', {boost: 10}), u.field('body'), u.pipeline.add(lunr.trimmer, lunr.stopWordFilter), $(t), $(e) }()), /*! jQuery UI - v1.11.3 - 2015-02-12 | ||
* http://jqueryui.com | ||
* Includes: widget.js | ||
* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ | ||
function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(t){/*! | ||
(function (t) { typeof define === 'function' && define.amd ? define(['jquery'], t) : t(jQuery) }(function (t) { /*! | ||
* jQuery UI Widget 1.11.3 | ||
@@ -135,3 +137,4 @@ * http://jqueryui.com | ||
*/ | ||
var e=0,n=Array.prototype.slice;t.cleanData=function(e){return function(n){var r,i,o;for(o=0;null!=(i=n[o]);o++)try{r=t._data(i,"events"),r&&r.remove&&t(i).triggerHandler("remove")}catch(a){}e(n)}}(t.cleanData),t.widget=function(e,n,r){var i,o,a,s,u={},c=e.split(".")[0];return e=e.split(".")[1],i=c+"-"+e,r||(r=n,n=t.Widget),t.expr[":"][i.toLowerCase()]=function(e){return!!t.data(e,i)},t[c]=t[c]||{},o=t[c][e],a=t[c][e]=function(t,e){return this._createWidget?void(arguments.length&&this._createWidget(t,e)):new a(t,e)},t.extend(a,o,{version:r.version,_proto:t.extend({},r),_childConstructors:[]}),s=new n,s.options=t.widget.extend({},s.options),t.each(r,function(e,r){return t.isFunction(r)?void(u[e]=function(){var t=function(){return n.prototype[e].apply(this,arguments)},i=function(t){return n.prototype[e].apply(this,t)};return function(){var e,n=this._super,o=this._superApply;return this._super=t,this._superApply=i,e=r.apply(this,arguments),this._super=n,this._superApply=o,e}}()):void(u[e]=r)}),a.prototype=t.widget.extend(s,{widgetEventPrefix:o?s.widgetEventPrefix||e:e},u,{constructor:a,namespace:c,widgetName:e,widgetFullName:i}),o?(t.each(o._childConstructors,function(e,n){var r=n.prototype;t.widget(r.namespace+"."+r.widgetName,a,n._proto)}),delete o._childConstructors):n._childConstructors.push(a),t.widget.bridge(e,a),a},t.widget.extend=function(e){for(var r,i,o=n.call(arguments,1),a=0,s=o.length;s>a;a++)for(r in o[a])i=o[a][r],o[a].hasOwnProperty(r)&&void 0!==i&&(e[r]=t.isPlainObject(i)?t.isPlainObject(e[r])?t.widget.extend({},e[r],i):t.widget.extend({},i):i);return e},t.widget.bridge=function(e,r){var i=r.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,s=n.call(arguments,1),u=this;return a?this.each(function(){var n,r=t.data(this,i);return"instance"===o?(u=r,!1):r?t.isFunction(r[o])&&"_"!==o.charAt(0)?(n=r[o].apply(r,s),n!==r&&void 0!==n?(u=n&&n.jquery?u.pushStack(n.get()):n,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; attempted to call method '"+o+"'")}):(s.length&&(o=t.widget.extend.apply(null,[o].concat(s))),this.each(function(){var e=t.data(this,i);e?(e.option(o||{}),e._init&&e._init()):t.data(this,i,new r(o,this))})),u}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(n,r){r=t(r||this.defaultElement||this)[0],this.element=t(r),this.uuid=e++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),r!==this&&(t.data(r,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===r&&this.destroy()}}),this.document=t(r.style?r.ownerDocument:r.document||r),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),n),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(e,n){var r,i,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},r=e.split("."),e=r.shift(),r.length){for(i=a[e]=t.widget.extend({},this.options[e]),o=0;o<r.length-1;o++)i[r[o]]=i[r[o]]||{},i=i[r[o]];if(e=r.pop(),1===arguments.length)return void 0===i[e]?null:i[e];i[e]=n}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=n}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return this.options[t]=e,"disabled"===t&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!e),e&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(e,n,r){var i,o=this;"boolean"!=typeof e&&(r=n,n=e,e=!1),r?(n=i=t(n),this.bindings=this.bindings.add(n)):(r=n,n=this.element,i=this.widget()),t.each(r,function(r,a){function s(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(s.guid=a.guid=a.guid||s.guid||t.guid++);var u=r.match(/^([\w:-]*)\s*(.*)$/),c=u[1]+o.eventNamespace,l=u[2];l?i.delegate(l,c,s):n.bind(c,s)})},_off:function(e,n){n=(n||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(n).undelegate(n),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function n(){return("string"==typeof t?r[t]:t).apply(r,arguments)}var r=this;return setTimeout(n,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){t(e.currentTarget).addClass("ui-state-hover")},mouseleave:function(e){t(e.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){t(e.currentTarget).addClass("ui-state-focus")},focusout:function(e){t(e.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(e,n,r){var i,o,a=this.options[e];if(r=r||{},n=t.Event(n),n.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),n.target=this.element[0],o=n.originalEvent)for(i in o)i in n||(n[i]=o[i]);return this.element.trigger(n,r),!(t.isFunction(a)&&a.apply(this.element[0],[n].concat(r))===!1||n.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,n){t.Widget.prototype["_"+e]=function(r,i,o){"string"==typeof i&&(i={effect:i});var a,s=i?i===!0||"number"==typeof i?n:i.effect||n:e;i=i||{},"number"==typeof i&&(i={duration:i}),a=!t.isEmptyObject(i),i.complete=o,i.delay&&r.delay(i.delay),a&&t.effects&&t.effects.effect[s]?r[e](i):s!==e&&r[s]?r[s](i.duration,i.easing,o):r.queue(function(n){t(this)[e](),o&&o.call(r[0]),n()})}});t.widget}),/* jquery Tocify - v1.8.0 - 2013-09-16 | ||
var e = 0, n = Array.prototype.slice; t.cleanData = (function (e) { return function (n) { var r, i, o; for (o = 0; (i = n[o]) != null; o++) try { r = t._data(i, 'events'), r && r.remove && t(i).triggerHandler('remove') } catch (a) {}e(n) } }(t.cleanData)), t.widget = function (e, n, r) { var i, o, a, s, u = {}, c = e.split('.')[0]; return e = e.split('.')[1], i = c + '-' + e, r || (r = n, n = t.Widget), t.expr[':'][i.toLowerCase()] = function (e) { return !!t.data(e, i) }, t[c] = t[c] || {}, o = t[c][e], a = t[c][e] = function (t, e) { return this._createWidget ? void (arguments.length && this._createWidget(t, e)) : new a(t, e) }, t.extend(a, o, {version: r.version, _proto: t.extend({}, r), _childConstructors: []}), s = new n(), s.options = t.widget.extend({}, s.options), t.each(r, function (e, r) { return t.isFunction(r) ? void (u[e] = (function () { var t = function () { return n.prototype[e].apply(this, arguments) }, i = function (t) { return n.prototype[e].apply(this, t) }; return function () { var e, n = this._super, o = this._superApply; return this._super = t, this._superApply = i, e = r.apply(this, arguments), this._super = n, this._superApply = o, e } }())) : void (u[e] = r) }), a.prototype = t.widget.extend(s, {widgetEventPrefix: o ? s.widgetEventPrefix || e : e}, u, {constructor: a, namespace: c, widgetName: e, widgetFullName: i}), o ? (t.each(o._childConstructors, function (e, n) { var r = n.prototype; t.widget(r.namespace + '.' + r.widgetName, a, n._proto) }), delete o._childConstructors) : n._childConstructors.push(a), t.widget.bridge(e, a), a }, t.widget.extend = function (e) { for (var r, i, o = n.call(arguments, 1), a = 0, s = o.length; s > a; a++) for (r in o[a])i = o[a][r], o[a].hasOwnProperty(r) && void 0 !== i && (e[r] = t.isPlainObject(i) ? t.isPlainObject(e[r]) ? t.widget.extend({}, e[r], i) : t.widget.extend({}, i) : i); return e }, t.widget.bridge = function (e, r) { var i = r.prototype.widgetFullName || e; t.fn[e] = function (o) { var a = typeof o === 'string', s = n.call(arguments, 1), u = this; return a ? this.each(function () { var n, r = t.data(this, i); return o === 'instance' ? (u = r, !1) : r ? t.isFunction(r[o]) && o.charAt(0) !== '_' ? (n = r[o].apply(r, s), n !== r && void 0 !== n ? (u = n && n.jquery ? u.pushStack(n.get()) : n, !1) : void 0) : t.error("no such method '" + o + "' for " + e + ' widget instance') : t.error('cannot call methods on ' + e + " prior to initialization; attempted to call method '" + o + "'") }) : (s.length && (o = t.widget.extend.apply(null, [o].concat(s))), this.each(function () { var e = t.data(this, i); e ? (e.option(o || {}), e._init && e._init()) : t.data(this, i, new r(o, this)) })), u } }, t.Widget = function () {}, t.Widget._childConstructors = [], t.Widget.prototype = {widgetName: 'widget', widgetEventPrefix: '', defaultElement: '<div>', options: {disabled: !1, create: null}, _createWidget: function (n, r) { r = t(r || this.defaultElement || this)[0], this.element = t(r), this.uuid = e++, this.eventNamespace = '.' + this.widgetName + this.uuid, this.bindings = t(), this.hoverable = t(), this.focusable = t(), r !== this && (t.data(r, this.widgetFullName, this), this._on(!0, this.element, {remove: function (t) { t.target === r && this.destroy() }}), this.document = t(r.style ? r.ownerDocument : r.document || r), this.window = t(this.document[0].defaultView || this.document[0].parentWindow)), this.options = t.widget.extend({}, this.options, this._getCreateOptions(), n), this._create(), this._trigger('create', null, this._getCreateEventData()), this._init() }, _getCreateOptions: t.noop, _getCreateEventData: t.noop, _create: t.noop, _init: t.noop, destroy: function () { this._destroy(), this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)), this.widget().unbind(this.eventNamespace).removeAttr('aria-disabled').removeClass(this.widgetFullName + '-disabled ui-state-disabled'), this.bindings.unbind(this.eventNamespace), this.hoverable.removeClass('ui-state-hover'), this.focusable.removeClass('ui-state-focus') }, _destroy: t.noop, widget: function () { return this.element }, option: function (e, n) { var r, i, o, a = e; if (arguments.length === 0) return t.widget.extend({}, this.options); if (typeof e === 'string') if (a = {}, r = e.split('.'), e = r.shift(), r.length) { for (i = a[e] = t.widget.extend({}, this.options[e]), o = 0; o < r.length - 1; o++)i[r[o]] = i[r[o]] || {}, i = i[r[o]]; if (e = r.pop(), arguments.length === 1) return void 0 === i[e] ? null : i[e]; i[e] = n } else { if (arguments.length === 1) return void 0 === this.options[e] ? null : this.options[e]; a[e] = n } return this._setOptions(a), this }, _setOptions: function (t) { var e; for (e in t) this._setOption(e, t[e]); return this }, _setOption: function (t, e) { return this.options[t] = e, t === 'disabled' && (this.widget().toggleClass(this.widgetFullName + '-disabled', !!e), e && (this.hoverable.removeClass('ui-state-hover'), this.focusable.removeClass('ui-state-focus'))), this }, enable: function () { return this._setOptions({disabled: !1}) }, disable: function () { return this._setOptions({disabled: !0}) }, _on: function (e, n, r) { var i, o = this; typeof e !== 'boolean' && (r = n, n = e, e = !1), r ? (n = i = t(n), this.bindings = this.bindings.add(n)) : (r = n, n = this.element, i = this.widget()), t.each(r, function (r, a) { function s () { return e || o.options.disabled !== !0 && !t(this).hasClass('ui-state-disabled') ? (typeof a === 'string' ? o[a] : a).apply(o, arguments) : void 0 } typeof a !== 'string' && (s.guid = a.guid = a.guid || s.guid || t.guid++); var u = r.match(/^([\w:-]*)\s*(.*)$/), c = u[1] + o.eventNamespace, l = u[2]; l ? i.delegate(l, c, s) : n.bind(c, s) }) }, _off: function (e, n) { n = (n || '').split(' ').join(this.eventNamespace + ' ') + this.eventNamespace, e.unbind(n).undelegate(n), this.bindings = t(this.bindings.not(e).get()), this.focusable = t(this.focusable.not(e).get()), this.hoverable = t(this.hoverable.not(e).get()) }, _delay: function (t, e) { function n () { return (typeof t === 'string' ? r[t] : t).apply(r, arguments) } var r = this; return setTimeout(n, e || 0) }, _hoverable: function (e) { this.hoverable = this.hoverable.add(e), this._on(e, {mouseenter: function (e) { t(e.currentTarget).addClass('ui-state-hover') }, mouseleave: function (e) { t(e.currentTarget).removeClass('ui-state-hover') }}) }, _focusable: function (e) { this.focusable = this.focusable.add(e), this._on(e, {focusin: function (e) { t(e.currentTarget).addClass('ui-state-focus') }, focusout: function (e) { t(e.currentTarget).removeClass('ui-state-focus') }}) }, _trigger: function (e, n, r) { var i, o, a = this.options[e]; if (r = r || {}, n = t.Event(n), n.type = (e === this.widgetEventPrefix ? e : this.widgetEventPrefix + e).toLowerCase(), n.target = this.element[0], o = n.originalEvent) for (i in o)i in n || (n[i] = o[i]); return this.element.trigger(n, r), !(t.isFunction(a) && a.apply(this.element[0], [n].concat(r)) === !1 || n.isDefaultPrevented()) }}, t.each({show: 'fadeIn', hide: 'fadeOut'}, function (e, n) { t.Widget.prototype['_' + e] = function (r, i, o) { typeof i === 'string' && (i = {effect: i}); var a, s = i ? i === !0 || typeof i === 'number' ? n : i.effect || n : e; i = i || {}, typeof i === 'number' && (i = {duration: i}), a = !t.isEmptyObject(i), i.complete = o, i.delay && r.delay(i.delay), a && t.effects && t.effects.effect[s] ? r[e](i) : s !== e && r[s] ? r[s](i.duration, i.easing, o) : r.queue(function (n) { t(this)[e](), o && o.call(r[0]), n() }) } }); t.widget | ||
})), /* jquery Tocify - v1.8.0 - 2013-09-16 | ||
* http://www.gregfranko.com/jquery.tocify.js/ | ||
@@ -144,3 +147,3 @@ * Copyright (c) 2013 Greg Franko; Licensed MIT | ||
* lag spikes below 30 fps */ | ||
function(t){"use strict";t(window.jQuery,window,document)}(function(t,e,n,r){"use strict";var i="tocify",o="tocify-focus",a="tocify-hover",s="tocify-hide",u="tocify-header",c="."+u,l="tocify-subheader",h="."+l,f="tocify-item",d="."+f,p="tocify-extend-page",g="."+p;t.widget("toc.tocify",{version:"1.8.0",options:{context:"body",ignoreSelector:null,selectors:"h1, h2, h3",showAndHide:!0,showEffect:"slideDown",showEffectSpeed:"medium",hideEffect:"slideUp",hideEffectSpeed:"medium",smoothScroll:!0,smoothScrollSpeed:"medium",scrollTo:0,showAndHideOnScroll:!0,highlightOnScroll:!0,highlightOffset:40,theme:"bootstrap",extendPage:!0,extendPageOffset:100,history:!0,scrollHistory:!1,hashGenerator:"compact",highlightDefault:!0},_create:function(){var n=this;n.tocifyWrapper=t(".tocify-wrapper"),n.extendPageScroll=!0,n.items=[],n._generateToc(),n.cachedHeights=[],n.cachedAnchors=[],n._addCSSClasses(),n.webkit=function(){for(var t in e)if(t&&-1!==t.toLowerCase().indexOf("webkit"))return!0;return!1}(),n._setEventHandlers(),t(e).load(function(){n._setActiveElement(!0),t("html, body").promise().done(function(){setTimeout(function(){n.extendPageScroll=!1},0)})})},_generateToc:function(){var e,n,r=this,o=r.options.ignoreSelector;return e=t(this.options.context).find(-1!==this.options.selectors.indexOf(",")?this.options.selectors.replace(/ /g,"").substr(0,this.options.selectors.indexOf(",")):this.options.selectors.replace(/ /g,"")),e.length?(r.element.addClass(i),void e.each(function(e){t(this).is(o)||(n=t("<ul/>",{id:u+e,"class":u}).append(r._nestElements(t(this),e)),r.element.append(n),t(this).nextUntil(this.nodeName.toLowerCase()).each(function(){0===t(this).find(r.options.selectors).length?t(this).filter(r.options.selectors).each(function(){t(this).is(o)||r._appendSubheaders.call(this,r,n)}):t(this).find(r.options.selectors).each(function(){t(this).is(o)||r._appendSubheaders.call(this,r,n)})}))})):void r.element.addClass(s)},_setActiveElement:function(t){var n=this,r=e.location.hash.substring(1),i=n.element.find("li[data-unique='"+r+"']");return r.length?(n.element.find("."+n.focusClass).removeClass(n.focusClass),i.addClass(n.focusClass),n.options.showAndHide&&i.click()):(n.element.find("."+n.focusClass).removeClass(n.focusClass),!r.length&&t&&n.options.highlightDefault&&n.element.find(d).first().addClass(n.focusClass)),n},_nestElements:function(e,n){var r,i,o;return r=t.grep(this.items,function(t){return t===e.text()}),this.items.push(r.length?e.text()+n:e.text()),o=this._generateHashValue(r,e,n),i=t("<li/>",{"class":f,"data-unique":o}).append(t("<a/>",{text:e.text()})),e.before(t("<div/>",{name:o,"data-unique":o})),i},_generateHashValue:function(t,e,n){var r="",i=this.options.hashGenerator;if("pretty"===i){for(r=e.text().toLowerCase().replace(/\s/g,"-"),r=r.replace(/[^\x00-\x7F]/g,"");r.indexOf("--")>-1;)r=r.replace(/--/g,"-");for(;r.indexOf(":-")>-1;)r=r.replace(/:-/g,"-")}else r="function"==typeof i?i(e.text(),e):e.text().replace(/\s/g,"");return t.length&&(r+=""+n),r},_appendSubheaders:function(e,n){var r=t(this).index(e.options.selectors),i=t(e.options.selectors).eq(r-1),o=+t(this).prop("tagName").charAt(1),a=+i.prop("tagName").charAt(1);a>o?e.element.find(h+"[data-tag="+o+"]").last().append(e._nestElements(t(this),r)):o===a?n.find(d).last().after(e._nestElements(t(this),r)):n.find(d).last().after(t("<ul/>",{"class":l,"data-tag":o})).next(h).append(e._nestElements(t(this),r))},_setEventHandlers:function(){var i=this;this.element.on("click.tocify","li",function(){if(i.options.history&&(e.location.hash=t(this).attr("data-unique")),i.element.find("."+i.focusClass).removeClass(i.focusClass),t(this).addClass(i.focusClass),i.options.showAndHide){var n=t('li[data-unique="'+t(this).attr("data-unique")+'"]');i._triggerShow(n)}i._scrollTo(t(this))}),this.element.find("li").on({"mouseenter.tocify":function(){t(this).addClass(i.hoverClass),t(this).css("cursor","pointer")},"mouseleave.tocify":function(){"bootstrap"!==i.options.theme&&t(this).removeClass(i.hoverClass)}}),t(e).on("resize",function(){i.calculateHeights()}),t(e).on("scroll.tocify",function(){t("html, body").promise().done(function(){var o,a,s,u,c=t(e).scrollTop(),l=t(e).height(),h=t(n).height(),f=t("body")[0].scrollHeight;if(i.options.extendPage&&(i.webkit&&c>=f-l-i.options.extendPageOffset||!i.webkit&&l+c>h-i.options.extendPageOffset)&&!t(g).length){if(a=t('div[data-unique="'+t(d).last().attr("data-unique")+'"]'),!a.length)return;s=a.offset().top,t(i.options.context).append(t("<div />",{"class":p,height:Math.abs(s-c)+"px","data-unique":p})),i.extendPageScroll&&(u=i.element.find("li.active"),i._scrollTo(t("div[data-unique="+u.attr("data-unique")+"]")))}setTimeout(function(){var a,s=null;0==i.cachedHeights.length&&i.calculateHeights();var u=t(e).scrollTop();if(i.cachedAnchors.each(function(t){return i.cachedHeights[t]-u<0?void(s=t):!1}),a=t(i.cachedAnchors[s]).attr("data-unique"),o=t('li[data-unique="'+a+'"]'),i.options.highlightOnScroll&&o.length&&!o.hasClass(i.focusClass)){i.element.find("."+i.focusClass).removeClass(i.focusClass),o.addClass(i.focusClass);var c=i.tocifyWrapper,l=t(o).closest(".tocify-header"),h=l.offset().top,f=c.offset().top,d=h-f;if(d>=t(e).height()){var p=d+c.scrollTop();c.scrollTop(p)}else 0>d&&c.scrollTop(0)}i.options.scrollHistory&&e.location.hash!=="#"+a&&a!==r&&(history.replaceState?history.replaceState({},"","#"+a):(scrollV=n.body.scrollTop,scrollH=n.body.scrollLeft,location.hash="#"+a,n.body.scrollTop=scrollV,n.body.scrollLeft=scrollH)),i.options.showAndHideOnScroll&&i.options.showAndHide&&i._triggerShow(o,!0)},0)})})},calculateHeights:function(){var e=this;e.cachedHeights=[],e.cachedAnchors=[];var n=t(e.options.context).find("div[data-unique]");n.each(function(n){var r=(t(this).next().length?t(this).next():t(this)).offset().top-e.options.highlightOffset;e.cachedHeights[n]=r}),e.cachedAnchors=n},show:function(e){var n=this;if(!e.is(":visible"))switch(e.find(h).length||e.parent().is(c)||e.parent().is(":visible")?e.children(h).length||e.parent().is(c)||(e=e.closest(h)):e=e.parents(h).add(e),n.options.showEffect){case"none":e.show();break;case"show":e.show(n.options.showEffectSpeed);break;case"slideDown":e.slideDown(n.options.showEffectSpeed);break;case"fadeIn":e.fadeIn(n.options.showEffectSpeed);break;default:e.show()}return n.hide(t(h).not(e.parent().is(c)?e:e.closest(c).find(h).not(e.siblings()))),n},hide:function(t){var e=this;switch(e.options.hideEffect){case"none":t.hide();break;case"hide":t.hide(e.options.hideEffectSpeed);break;case"slideUp":t.slideUp(e.options.hideEffectSpeed);break;case"fadeOut":t.fadeOut(e.options.hideEffectSpeed);break;default:t.hide()}return e},_triggerShow:function(t,e){var n=this;return t.parent().is(c)||t.next().is(h)?n.show(t.next(h),e):t.parent().is(h)&&n.show(t.parent(),e),n},_addCSSClasses:function(){return"jqueryui"===this.options.theme?(this.focusClass="ui-state-default",this.hoverClass="ui-state-hover",this.element.addClass("ui-widget").find(".toc-title").addClass("ui-widget-header").end().find("li").addClass("ui-widget-content")):"bootstrap"===this.options.theme?(this.element.find(c+","+h).addClass("nav nav-list"),this.focusClass="active"):(this.focusClass=o,this.hoverClass=a),this},setOption:function(){t.Widget.prototype._setOption.apply(this,arguments)},setOptions:function(){t.Widget.prototype._setOptions.apply(this,arguments)},_scrollTo:function(e){var n=this,r=n.options.smoothScroll||0,i=n.options.scrollTo;return t("html, body").promise().done(function(){t("html, body").animate({scrollTop:t('div[data-unique="'+e.attr("data-unique")+'"]').next().offset().top-(t.isFunction(i)?i.call():i)+"px"},{duration:r})}),n}})}),/*! | ||
(function (t) { 'use strict'; t(window.jQuery, window, document) }(function (t, e, n, r) { 'use strict'; var i = 'tocify', o = 'tocify-focus', a = 'tocify-hover', s = 'tocify-hide', u = 'tocify-header', c = '.' + u, l = 'tocify-subheader', h = '.' + l, f = 'tocify-item', d = '.' + f, p = 'tocify-extend-page', g = '.' + p; t.widget('toc.tocify', {version: '1.8.0', options: {context: 'body', ignoreSelector: null, selectors: 'h1, h2, h3', showAndHide: !0, showEffect: 'slideDown', showEffectSpeed: 'medium', hideEffect: 'slideUp', hideEffectSpeed: 'medium', smoothScroll: !0, smoothScrollSpeed: 'medium', scrollTo: 0, showAndHideOnScroll: !0, highlightOnScroll: !0, highlightOffset: 40, theme: 'bootstrap', extendPage: !0, extendPageOffset: 100, history: !0, scrollHistory: !1, hashGenerator: 'compact', highlightDefault: !0}, _create: function () { var n = this; n.tocifyWrapper = t('.tocify-wrapper'), n.extendPageScroll = !0, n.items = [], n._generateToc(), n.cachedHeights = [], n.cachedAnchors = [], n._addCSSClasses(), n.webkit = (function () { for (var t in e) if (t && t.toLowerCase().indexOf('webkit') !== -1) return !0; return !1 }()), n._setEventHandlers(), t(e).load(function () { n._setActiveElement(!0), t('html, body').promise().done(function () { setTimeout(function () { n.extendPageScroll = !1 }, 0) }) }) }, _generateToc: function () { var e, n, r = this, o = r.options.ignoreSelector; return e = t(this.options.context).find(this.options.selectors.indexOf(',') !== -1 ? this.options.selectors.replace(/ /g, '').substr(0, this.options.selectors.indexOf(',')) : this.options.selectors.replace(/ /g, '')), e.length ? (r.element.addClass(i), void e.each(function (e) { t(this).is(o) || (n = t('<ul/>', {id: u + e, 'class': u}).append(r._nestElements(t(this), e)), r.element.append(n), t(this).nextUntil(this.nodeName.toLowerCase()).each(function () { t(this).find(r.options.selectors).length === 0 ? t(this).filter(r.options.selectors).each(function () { t(this).is(o) || r._appendSubheaders.call(this, r, n) }) : t(this).find(r.options.selectors).each(function () { t(this).is(o) || r._appendSubheaders.call(this, r, n) }) })) })) : void r.element.addClass(s) }, _setActiveElement: function (t) { var n = this, r = e.location.hash.substring(1), i = n.element.find("li[data-unique='" + r + "']"); return r.length ? (n.element.find('.' + n.focusClass).removeClass(n.focusClass), i.addClass(n.focusClass), n.options.showAndHide && i.click()) : (n.element.find('.' + n.focusClass).removeClass(n.focusClass), !r.length && t && n.options.highlightDefault && n.element.find(d).first().addClass(n.focusClass)), n }, _nestElements: function (e, n) { var r, i, o; return r = t.grep(this.items, function (t) { return t === e.text() }), this.items.push(r.length ? e.text() + n : e.text()), o = this._generateHashValue(r, e, n), i = t('<li/>', {'class': f, 'data-unique': o}).append(t('<a/>', {text: e.text()})), e.before(t('<div/>', {name: o, 'data-unique': o})), i }, _generateHashValue: function (t, e, n) { var r = '', i = this.options.hashGenerator; if (i === 'pretty') { for (r = e.text().toLowerCase().replace(/\s/g, '-'), r = r.replace(/[^\x00-\x7F]/g, ''); r.indexOf('--') > -1;)r = r.replace(/--/g, '-'); for (;r.indexOf(':-') > -1;)r = r.replace(/:-/g, '-') } else r = typeof i === 'function' ? i(e.text(), e) : e.text().replace(/\s/g, ''); return t.length && (r += '' + n), r }, _appendSubheaders: function (e, n) { var r = t(this).index(e.options.selectors), i = t(e.options.selectors).eq(r - 1), o = +t(this).prop('tagName').charAt(1), a = +i.prop('tagName').charAt(1); a > o ? e.element.find(h + '[data-tag=' + o + ']').last().append(e._nestElements(t(this), r)) : o === a ? n.find(d).last().after(e._nestElements(t(this), r)) : n.find(d).last().after(t('<ul/>', {'class': l, 'data-tag': o})).next(h).append(e._nestElements(t(this), r)) }, _setEventHandlers: function () { var i = this; this.element.on('click.tocify', 'li', function () { if (i.options.history && (e.location.hash = t(this).attr('data-unique')), i.element.find('.' + i.focusClass).removeClass(i.focusClass), t(this).addClass(i.focusClass), i.options.showAndHide) { var n = t('li[data-unique="' + t(this).attr('data-unique') + '"]'); i._triggerShow(n) }i._scrollTo(t(this)) }), this.element.find('li').on({'mouseenter.tocify': function () { t(this).addClass(i.hoverClass), t(this).css('cursor', 'pointer') }, 'mouseleave.tocify': function () { i.options.theme !== 'bootstrap' && t(this).removeClass(i.hoverClass) }}), t(e).on('resize', function () { i.calculateHeights() }), t(e).on('scroll.tocify', function () { t('html, body').promise().done(function () { var o, a, s, u, c = t(e).scrollTop(), l = t(e).height(), h = t(n).height(), f = t('body')[0].scrollHeight; if (i.options.extendPage && (i.webkit && c >= f - l - i.options.extendPageOffset || !i.webkit && l + c > h - i.options.extendPageOffset) && !t(g).length) { if (a = t('div[data-unique="' + t(d).last().attr('data-unique') + '"]'), !a.length) return; s = a.offset().top, t(i.options.context).append(t('<div />', {'class': p, height: Math.abs(s - c) + 'px', 'data-unique': p})), i.extendPageScroll && (u = i.element.find('li.active'), i._scrollTo(t('div[data-unique=' + u.attr('data-unique') + ']'))) }setTimeout(function () { var a, s = null; i.cachedHeights.length == 0 && i.calculateHeights(); var u = t(e).scrollTop(); if (i.cachedAnchors.each(function (t) { return i.cachedHeights[t] - u < 0 ? void (s = t) : !1 }), a = t(i.cachedAnchors[s]).attr('data-unique'), o = t('li[data-unique="' + a + '"]'), i.options.highlightOnScroll && o.length && !o.hasClass(i.focusClass)) { i.element.find('.' + i.focusClass).removeClass(i.focusClass), o.addClass(i.focusClass); var c = i.tocifyWrapper, l = t(o).closest('.tocify-header'), h = l.offset().top, f = c.offset().top, d = h - f; if (d >= t(e).height()) { var p = d + c.scrollTop(); c.scrollTop(p) } else d < 0 && c.scrollTop(0) }i.options.scrollHistory && e.location.hash !== '#' + a && a !== r && (history.replaceState ? history.replaceState({}, '', '#' + a) : (scrollV = n.body.scrollTop, scrollH = n.body.scrollLeft, location.hash = '#' + a, n.body.scrollTop = scrollV, n.body.scrollLeft = scrollH)), i.options.showAndHideOnScroll && i.options.showAndHide && i._triggerShow(o, !0) }, 0) }) }) }, calculateHeights: function () { var e = this; e.cachedHeights = [], e.cachedAnchors = []; var n = t(e.options.context).find('div[data-unique]'); n.each(function (n) { var r = (t(this).next().length ? t(this).next() : t(this)).offset().top - e.options.highlightOffset; e.cachedHeights[n] = r }), e.cachedAnchors = n }, show: function (e) { var n = this; if (!e.is(':visible')) switch (e.find(h).length || e.parent().is(c) || e.parent().is(':visible') ? e.children(h).length || e.parent().is(c) || (e = e.closest(h)) : e = e.parents(h).add(e), n.options.showEffect) { case 'none':e.show(); break; case 'show':e.show(n.options.showEffectSpeed); break; case 'slideDown':e.slideDown(n.options.showEffectSpeed); break; case 'fadeIn':e.fadeIn(n.options.showEffectSpeed); break; default:e.show() } return n.hide(t(h).not(e.parent().is(c) ? e : e.closest(c).find(h).not(e.siblings()))), n }, hide: function (t) { var e = this; switch (e.options.hideEffect) { case 'none':t.hide(); break; case 'hide':t.hide(e.options.hideEffectSpeed); break; case 'slideUp':t.slideUp(e.options.hideEffectSpeed); break; case 'fadeOut':t.fadeOut(e.options.hideEffectSpeed); break; default:t.hide() } return e }, _triggerShow: function (t, e) { var n = this; return t.parent().is(c) || t.next().is(h) ? n.show(t.next(h), e) : t.parent().is(h) && n.show(t.parent(), e), n }, _addCSSClasses: function () { return this.options.theme === 'jqueryui' ? (this.focusClass = 'ui-state-default', this.hoverClass = 'ui-state-hover', this.element.addClass('ui-widget').find('.toc-title').addClass('ui-widget-header').end().find('li').addClass('ui-widget-content')) : this.options.theme === 'bootstrap' ? (this.element.find(c + ',' + h).addClass('nav nav-list'), this.focusClass = 'active') : (this.focusClass = o, this.hoverClass = a), this }, setOption: function () { t.Widget.prototype._setOption.apply(this, arguments) }, setOptions: function () { t.Widget.prototype._setOptions.apply(this, arguments) }, _scrollTo: function (e) { var n = this, r = n.options.smoothScroll || 0, i = n.options.scrollTo; return t('html, body').promise().done(function () { t('html, body').animate({scrollTop: t('div[data-unique="' + e.attr('data-unique') + '"]').next().offset().top - (t.isFunction(i) ? i.call() : i) + 'px'}, {duration: r}) }), n }}) })), /*! | ||
* imagesLoaded PACKAGED v3.1.8 | ||
@@ -150,2 +153,2 @@ * JavaScript is all like "You images are done yet or what?" | ||
*/ | ||
function(){function t(){}function e(t,e){for(var n=t.length;n--;)if(t[n].listener===e)return n;return-1}function n(t){return function(){return this[t].apply(this,arguments)}}var r=t.prototype,i=this,o=i.EventEmitter;r.getListeners=function(t){var e,n,r=this._getEvents();if("object"==typeof t){e={};for(n in r)r.hasOwnProperty(n)&&t.test(n)&&(e[n]=r[n])}else e=r[t]||(r[t]=[]);return e},r.flattenListeners=function(t){var e,n=[];for(e=0;t.length>e;e+=1)n.push(t[e].listener);return n},r.getListenersAsObject=function(t){var e,n=this.getListeners(t);return n instanceof Array&&(e={},e[t]=n),e||n},r.addListener=function(t,n){var r,i=this.getListenersAsObject(t),o="object"==typeof n;for(r in i)i.hasOwnProperty(r)&&-1===e(i[r],n)&&i[r].push(o?n:{listener:n,once:!1});return this},r.on=n("addListener"),r.addOnceListener=function(t,e){return this.addListener(t,{listener:e,once:!0})},r.once=n("addOnceListener"),r.defineEvent=function(t){return this.getListeners(t),this},r.defineEvents=function(t){for(var e=0;t.length>e;e+=1)this.defineEvent(t[e]);return this},r.removeListener=function(t,n){var r,i,o=this.getListenersAsObject(t);for(i in o)o.hasOwnProperty(i)&&(r=e(o[i],n),-1!==r&&o[i].splice(r,1));return this},r.off=n("removeListener"),r.addListeners=function(t,e){return this.manipulateListeners(!1,t,e)},r.removeListeners=function(t,e){return this.manipulateListeners(!0,t,e)},r.manipulateListeners=function(t,e,n){var r,i,o=t?this.removeListener:this.addListener,a=t?this.removeListeners:this.addListeners;if("object"!=typeof e||e instanceof RegExp)for(r=n.length;r--;)o.call(this,e,n[r]);else for(r in e)e.hasOwnProperty(r)&&(i=e[r])&&("function"==typeof i?o.call(this,r,i):a.call(this,r,i));return this},r.removeEvent=function(t){var e,n=typeof t,r=this._getEvents();if("string"===n)delete r[t];else if("object"===n)for(e in r)r.hasOwnProperty(e)&&t.test(e)&&delete r[e];else delete this._events;return this},r.removeAllListeners=n("removeEvent"),r.emitEvent=function(t,e){var n,r,i,o,a=this.getListenersAsObject(t);for(i in a)if(a.hasOwnProperty(i))for(r=a[i].length;r--;)n=a[i][r],n.once===!0&&this.removeListener(t,n.listener),o=n.listener.apply(this,e||[]),o===this._getOnceReturnValue()&&this.removeListener(t,n.listener);return this},r.trigger=n("emitEvent"),r.emit=function(t){var e=Array.prototype.slice.call(arguments,1);return this.emitEvent(t,e)},r.setOnceReturnValue=function(t){return this._onceReturnValue=t,this},r._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},r._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return i.EventEmitter=o,t},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return t}):"object"==typeof module&&module.exports?module.exports=t:this.EventEmitter=t}.call(this),function(t){function e(e){var n=t.event;return n.target=n.target||n.srcElement||e,n}var n=document.documentElement,r=function(){};n.addEventListener?r=function(t,e,n){t.addEventListener(e,n,!1)}:n.attachEvent&&(r=function(t,n,r){t[n+r]=r.handleEvent?function(){var n=e(t);r.handleEvent.call(r,n)}:function(){var n=e(t);r.call(t,n)},t.attachEvent("on"+n,t[n+r])});var i=function(){};n.removeEventListener?i=function(t,e,n){t.removeEventListener(e,n,!1)}:n.detachEvent&&(i=function(t,e,n){t.detachEvent("on"+e,t[e+n]);try{delete t[e+n]}catch(r){t[e+n]=void 0}});var o={bind:r,unbind:i};"function"==typeof define&&define.amd?define("eventie/eventie",o):t.eventie=o}(this),function(t,e){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,r){return e(t,n,r)}):"object"==typeof exports?module.exports=e(t,require("wolfy87-eventemitter"),require("eventie")):t.imagesLoaded=e(t,t.EventEmitter,t.eventie)}(window,function(t,e,n){function r(t,e){for(var n in e)t[n]=e[n];return t}function i(t){return"[object Array]"===f.call(t)}function o(t){var e=[];if(i(t))e=t;else if("number"==typeof t.length)for(var n=0,r=t.length;r>n;n++)e.push(t[n]);else e.push(t);return e}function a(t,e,n){if(!(this instanceof a))return new a(t,e);"string"==typeof t&&(t=document.querySelectorAll(t)),this.elements=o(t),this.options=r({},this.options),"function"==typeof e?n=e:r(this.options,e),n&&this.on("always",n),this.getImages(),c&&(this.jqDeferred=new c.Deferred);var i=this;setTimeout(function(){i.check()})}function s(t){this.img=t}function u(t){this.src=t,d[t]=this}var c=t.jQuery,l=t.console,h=void 0!==l,f=Object.prototype.toString;a.prototype=new e,a.prototype.options={},a.prototype.getImages=function(){this.images=[];for(var t=0,e=this.elements.length;e>t;t++){var n=this.elements[t];"IMG"===n.nodeName&&this.addImage(n);var r=n.nodeType;if(r&&(1===r||9===r||11===r))for(var i=n.querySelectorAll("img"),o=0,a=i.length;a>o;o++){var s=i[o];this.addImage(s)}}},a.prototype.addImage=function(t){var e=new s(t);this.images.push(e)},a.prototype.check=function(){function t(t,i){return e.options.debug&&h&&l.log("confirm",t,i),e.progress(t),n++,n===r&&e.complete(),!0}var e=this,n=0,r=this.images.length;if(this.hasAnyBroken=!1,!r)return void this.complete();for(var i=0;r>i;i++){var o=this.images[i];o.on("confirm",t),o.check()}},a.prototype.progress=function(t){this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded;var e=this;setTimeout(function(){e.emit("progress",e,t),e.jqDeferred&&e.jqDeferred.notify&&e.jqDeferred.notify(e,t)})},a.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var e=this;setTimeout(function(){if(e.emit(t,e),e.emit("always",e),e.jqDeferred){var n=e.hasAnyBroken?"reject":"resolve";e.jqDeferred[n](e)}})},c&&(c.fn.imagesLoaded=function(t,e){var n=new a(this,t,e);return n.jqDeferred.promise(c(this))}),s.prototype=new e,s.prototype.check=function(){var t=d[this.img.src]||new u(this.img.src);if(t.isConfirmed)return void this.confirm(t.isLoaded,"cached was confirmed");if(this.img.complete&&void 0!==this.img.naturalWidth)return void this.confirm(0!==this.img.naturalWidth,"naturalWidth");var e=this;t.on("confirm",function(t,n){return e.confirm(t.isLoaded,n),!0}),t.check()},s.prototype.confirm=function(t,e){this.isLoaded=t,this.emit("confirm",this,e)};var d={};return u.prototype=new e,u.prototype.check=function(){if(!this.isChecked){var t=new Image;n.bind(t,"load",this),n.bind(t,"error",this),t.src=this.src,this.isChecked=!0}},u.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},u.prototype.onload=function(t){this.confirm(!0,"onload"),this.unbindProxyEvents(t)},u.prototype.onerror=function(t){this.confirm(!1,"onerror"),this.unbindProxyEvents(t)},u.prototype.confirm=function(t,e){this.isConfirmed=!0,this.isLoaded=t,this.emit("confirm",this,e)},u.prototype.unbindProxyEvents=function(t){n.unbind(t.target,"load",this),n.unbind(t.target,"error",this)},a}),function(t){"use strict";function e(){setTimeout(function(){toc.setOption("showEffectSpeed",180)},50)}var n=function(){$(".tocify-wrapper").removeClass("open"),$("#nav-button").removeClass("open")},r=function(){t.toc=$("#toc").tocify({selectors:"h1, h2",extendPage:!1,theme:"none",smoothScroll:!1,showEffectSpeed:0,hideEffectSpeed:180,ignoreSelector:".toc-ignore",highlightOffset:60,scrollTo:-1,scrollHistory:!0,hashGenerator:function(t,e){return e.prop("id")}}).data("toc-tocify"),$("#nav-button").click(function(){return $(".tocify-wrapper").toggleClass("open"),$("#nav-button").toggleClass("open"),!1}),$(".page-wrapper").click(n),$(".tocify-item").click(n)};$(function(){r(),e(),$(".content").imagesLoaded(function(){t.toc.calculateHeights()})})}(window); | ||
(function () { function t () {} function e (t, e) { for (var n = t.length; n--;) if (t[n].listener === e) return n; return -1 } function n (t) { return function () { return this[t].apply(this, arguments) } } var r = t.prototype, i = this, o = i.EventEmitter; r.getListeners = function (t) { var e, n, r = this._getEvents(); if (typeof t === 'object') { e = {}; for (n in r)r.hasOwnProperty(n) && t.test(n) && (e[n] = r[n]) } else e = r[t] || (r[t] = []); return e }, r.flattenListeners = function (t) { var e, n = []; for (e = 0; t.length > e; e += 1)n.push(t[e].listener); return n }, r.getListenersAsObject = function (t) { var e, n = this.getListeners(t); return n instanceof Array && (e = {}, e[t] = n), e || n }, r.addListener = function (t, n) { var r, i = this.getListenersAsObject(t), o = typeof n === 'object'; for (r in i)i.hasOwnProperty(r) && e(i[r], n) === -1 && i[r].push(o ? n : {listener: n, once: !1}); return this }, r.on = n('addListener'), r.addOnceListener = function (t, e) { return this.addListener(t, {listener: e, once: !0}) }, r.once = n('addOnceListener'), r.defineEvent = function (t) { return this.getListeners(t), this }, r.defineEvents = function (t) { for (var e = 0; t.length > e; e += 1) this.defineEvent(t[e]); return this }, r.removeListener = function (t, n) { var r, i, o = this.getListenersAsObject(t); for (i in o)o.hasOwnProperty(i) && (r = e(o[i], n), r !== -1 && o[i].splice(r, 1)); return this }, r.off = n('removeListener'), r.addListeners = function (t, e) { return this.manipulateListeners(!1, t, e) }, r.removeListeners = function (t, e) { return this.manipulateListeners(!0, t, e) }, r.manipulateListeners = function (t, e, n) { var r, i, o = t ? this.removeListener : this.addListener, a = t ? this.removeListeners : this.addListeners; if (typeof e !== 'object' || e instanceof RegExp) for (r = n.length; r--;)o.call(this, e, n[r]); else for (r in e)e.hasOwnProperty(r) && (i = e[r]) && (typeof i === 'function' ? o.call(this, r, i) : a.call(this, r, i)); return this }, r.removeEvent = function (t) { var e, n = typeof t, r = this._getEvents(); if (n === 'string') delete r[t]; else if (n === 'object') for (e in r)r.hasOwnProperty(e) && t.test(e) && delete r[e]; else delete this._events; return this }, r.removeAllListeners = n('removeEvent'), r.emitEvent = function (t, e) { var n, r, i, o, a = this.getListenersAsObject(t); for (i in a) if (a.hasOwnProperty(i)) for (r = a[i].length; r--;)n = a[i][r], n.once === !0 && this.removeListener(t, n.listener), o = n.listener.apply(this, e || []), o === this._getOnceReturnValue() && this.removeListener(t, n.listener); return this }, r.trigger = n('emitEvent'), r.emit = function (t) { var e = Array.prototype.slice.call(arguments, 1); return this.emitEvent(t, e) }, r.setOnceReturnValue = function (t) { return this._onceReturnValue = t, this }, r._getOnceReturnValue = function () { return this.hasOwnProperty('_onceReturnValue') ? this._onceReturnValue : !0 }, r._getEvents = function () { return this._events || (this._events = {}) }, t.noConflict = function () { return i.EventEmitter = o, t }, typeof define === 'function' && define.amd ? define('eventEmitter/EventEmitter', [], function () { return t }) : typeof module === 'object' && module.exports ? module.exports = t : this.EventEmitter = t }.call(this)), (function (t) { function e (e) { var n = t.event; return n.target = n.target || n.srcElement || e, n } var n = document.documentElement, r = function () {}; n.addEventListener ? r = function (t, e, n) { t.addEventListener(e, n, !1) } : n.attachEvent && (r = function (t, n, r) { t[n + r] = r.handleEvent ? function () { var n = e(t); r.handleEvent.call(r, n) } : function () { var n = e(t); r.call(t, n) }, t.attachEvent('on' + n, t[n + r]) }); var i = function () {}; n.removeEventListener ? i = function (t, e, n) { t.removeEventListener(e, n, !1) } : n.detachEvent && (i = function (t, e, n) { t.detachEvent('on' + e, t[e + n]); try { delete t[e + n] } catch (r) { t[e + n] = void 0 } }); var o = {bind: r, unbind: i}; typeof define === 'function' && define.amd ? define('eventie/eventie', o) : t.eventie = o }(this)), (function (t, e) { typeof define === 'function' && define.amd ? define(['eventEmitter/EventEmitter', 'eventie/eventie'], function (n, r) { return e(t, n, r) }) : typeof exports === 'object' ? module.exports = e(t, require('wolfy87-eventemitter'), require('eventie')) : t.imagesLoaded = e(t, t.EventEmitter, t.eventie) }(window, function (t, e, n) { function r (t, e) { for (var n in e)t[n] = e[n]; return t } function i (t) { return f.call(t) === '[object Array]' } function o (t) { var e = []; if (i(t))e = t; else if (typeof t.length === 'number') for (var n = 0, r = t.length; r > n; n++)e.push(t[n]); else e.push(t); return e } function a (t, e, n) { if (!(this instanceof a)) return new a(t, e); typeof t === 'string' && (t = document.querySelectorAll(t)), this.elements = o(t), this.options = r({}, this.options), typeof e === 'function' ? n = e : r(this.options, e), n && this.on('always', n), this.getImages(), c && (this.jqDeferred = new c.Deferred()); var i = this; setTimeout(function () { i.check() }) } function s (t) { this.img = t } function u (t) { this.src = t, d[t] = this } var c = t.jQuery, l = t.console, h = void 0 !== l, f = Object.prototype.toString; a.prototype = new e(), a.prototype.options = {}, a.prototype.getImages = function () { this.images = []; for (var t = 0, e = this.elements.length; e > t; t++) { var n = this.elements[t]; n.nodeName === 'IMG' && this.addImage(n); var r = n.nodeType; if (r && (r === 1 || r === 9 || r === 11)) for (var i = n.querySelectorAll('img'), o = 0, a = i.length; a > o; o++) { var s = i[o]; this.addImage(s) } } }, a.prototype.addImage = function (t) { var e = new s(t); this.images.push(e) }, a.prototype.check = function () { function t (t, i) { return e.options.debug && h && l.log('confirm', t, i), e.progress(t), n++, n === r && e.complete(), !0 } var e = this, n = 0, r = this.images.length; if (this.hasAnyBroken = !1, !r) return void this.complete(); for (var i = 0; r > i; i++) { var o = this.images[i]; o.on('confirm', t), o.check() } }, a.prototype.progress = function (t) { this.hasAnyBroken = this.hasAnyBroken || !t.isLoaded; var e = this; setTimeout(function () { e.emit('progress', e, t), e.jqDeferred && e.jqDeferred.notify && e.jqDeferred.notify(e, t) }) }, a.prototype.complete = function () { var t = this.hasAnyBroken ? 'fail' : 'done'; this.isComplete = !0; var e = this; setTimeout(function () { if (e.emit(t, e), e.emit('always', e), e.jqDeferred) { var n = e.hasAnyBroken ? 'reject' : 'resolve'; e.jqDeferred[n](e) } }) }, c && (c.fn.imagesLoaded = function (t, e) { var n = new a(this, t, e); return n.jqDeferred.promise(c(this)) }), s.prototype = new e(), s.prototype.check = function () { var t = d[this.img.src] || new u(this.img.src); if (t.isConfirmed) return void this.confirm(t.isLoaded, 'cached was confirmed'); if (this.img.complete && void 0 !== this.img.naturalWidth) return void this.confirm(this.img.naturalWidth !== 0, 'naturalWidth'); var e = this; t.on('confirm', function (t, n) { return e.confirm(t.isLoaded, n), !0 }), t.check() }, s.prototype.confirm = function (t, e) { this.isLoaded = t, this.emit('confirm', this, e) }; var d = {}; return u.prototype = new e(), u.prototype.check = function () { if (!this.isChecked) { var t = new Image(); n.bind(t, 'load', this), n.bind(t, 'error', this), t.src = this.src, this.isChecked = !0 } }, u.prototype.handleEvent = function (t) { var e = 'on' + t.type; this[e] && this[e](t) }, u.prototype.onload = function (t) { this.confirm(!0, 'onload'), this.unbindProxyEvents(t) }, u.prototype.onerror = function (t) { this.confirm(!1, 'onerror'), this.unbindProxyEvents(t) }, u.prototype.confirm = function (t, e) { this.isConfirmed = !0, this.isLoaded = t, this.emit('confirm', this, e) }, u.prototype.unbindProxyEvents = function (t) { n.unbind(t.target, 'load', this), n.unbind(t.target, 'error', this) }, a })), (function (t) { 'use strict'; function e () { setTimeout(function () { toc.setOption('showEffectSpeed', 180) }, 50) } var n = function () { $('.tocify-wrapper').removeClass('open'), $('#nav-button').removeClass('open') }, r = function () { t.toc = $('#toc').tocify({selectors: 'h1, h2', extendPage: !1, theme: 'none', smoothScroll: !1, showEffectSpeed: 0, hideEffectSpeed: 180, ignoreSelector: '.toc-ignore', highlightOffset: 60, scrollTo: -1, scrollHistory: !0, hashGenerator: function (t, e) { return e.prop('id') }}).data('toc-tocify'), $('#nav-button').click(function () { return $('.tocify-wrapper').toggleClass('open'), $('#nav-button').toggleClass('open'), !1 }), $('.page-wrapper').click(n), $('.tocify-item').click(n) }; $(function () { r(), e(), $('.content').imagesLoaded(function () { t.toc.calculateHeights() }) }) }(window)) |
/**/ | ||
!function(e){"undefined"!=typeof exports?e(exports):(window.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return window.hljs}))}(function(e){function n(e){return e.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0==t.index}function a(e){var n=(e.className+" "+(e.parentNode?e.parentNode.className:"")).split(/\s+/);return n=n.map(function(e){return e.replace(/^lang(uage)?-/,"")}),n.filter(function(e){return N(e)||/no(-?)highlight/.test(e)})[0]}function o(e,n){var t={};for(var r in e)t[r]=e[r];if(n)for(var r in n)t[r]=n[r];return t}function i(e){var n=[];return function r(e,a){for(var o=e.firstChild;o;o=o.nextSibling)3==o.nodeType?a+=o.nodeValue.length:1==o.nodeType&&(n.push({event:"start",offset:a,node:o}),a=r(o,a),t(o).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:o}));return a}(e,0),n}function c(e,r,a){function o(){return e.length&&r.length?e[0].offset!=r[0].offset?e[0].offset<r[0].offset?e:r:"start"==r[0].event?e:r:e.length?e:r}function i(e){function r(e){return" "+e.nodeName+'="'+n(e.value)+'"'}l+="<"+t(e)+Array.prototype.map.call(e.attributes,r).join("")+">"}function c(e){l+="</"+t(e)+">"}function u(e){("start"==e.event?i:c)(e.node)}for(var s=0,l="",f=[];e.length||r.length;){var g=o();if(l+=n(a.substr(s,g[0].offset-s)),s=g[0].offset,g==e){f.reverse().forEach(c);do u(g.splice(0,1)[0]),g=o();while(g==e&&g.length&&g[0].offset==s);f.reverse().forEach(i)}else"start"==g[0].event?f.push(g[0].node):f.pop(),u(g.splice(0,1)[0])}return l+n(a.substr(s))}function u(e){function n(e){return e&&e.source||e}function t(t,r){return RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var c={},u=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");c[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?u("keyword",a.k):Object.keys(a.k).forEach(function(e){u(e,a.k[e])}),a.k=c}a.lR=t(a.l||/\b[A-Za-z0-9_]+\b/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),void 0===a.r&&(a.r=1),a.c||(a.c=[]);var s=[];a.c.forEach(function(e){e.v?e.v.forEach(function(n){s.push(o(e,n))}):s.push("self"==e?a:e)}),a.c=s,a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var l=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=l.length?t(l.join("|"),!0):{exec:function(){return null}}}}r(e)}function s(e,t,a,o){function i(e,n){for(var t=0;t<n.c.length;t++)if(r(n.c[t].bR,e))return n.c[t]}function c(e,n){return r(e.eR,n)?e:e.eW?c(e.parent,n):void 0}function f(e,n){return!a&&r(n.iR,e)}function g(e,n){var t=x.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function p(e,n,t,r){var a=r?"":E.classPrefix,o='<span class="'+a,i=t?"":"</span>";return o+=e+'">',o+n+i}function d(){if(!w.k)return n(y);var e="",t=0;w.lR.lastIndex=0;for(var r=w.lR.exec(y);r;){e+=n(y.substr(t,r.index-t));var a=g(w,r);a?(B+=a[1],e+=p(a[0],n(r[0]))):e+=n(r[0]),t=w.lR.lastIndex,r=w.lR.exec(y)}return e+n(y.substr(t))}function h(){if(w.sL&&!R[w.sL])return n(y);var e=w.sL?s(w.sL,y,!0,L[w.sL]):l(y);return w.r>0&&(B+=e.r),"continuous"==w.subLanguageMode&&(L[w.sL]=e.top),p(e.language,e.value,!1,!0)}function v(){return void 0!==w.sL?h():d()}function b(e,t){var r=e.cN?p(e.cN,"",!0):"";e.rB?(M+=r,y=""):e.eB?(M+=n(t)+r,y=""):(M+=r,y=t),w=Object.create(e,{parent:{value:w}})}function m(e,t){if(y+=e,void 0===t)return M+=v(),0;var r=i(t,w);if(r)return M+=v(),b(r,t),r.rB?0:t.length;var a=c(w,t);if(a){var o=w;o.rE||o.eE||(y+=t),M+=v();do w.cN&&(M+="</span>"),B+=w.r,w=w.parent;while(w!=a.parent);return o.eE&&(M+=n(t)),y="",a.starts&&b(a.starts,""),o.rE?0:t.length}if(f(t,w))throw new Error('Illegal lexeme "'+t+'" for mode "'+(w.cN||"<unnamed>")+'"');return y+=t,t.length||1}var x=N(e);if(!x)throw new Error('Unknown language: "'+e+'"');u(x);for(var w=o||x,L={},M="",k=w;k!=x;k=k.parent)k.cN&&(M=p(k.cN,"",!0)+M);var y="",B=0;try{for(var C,j,I=0;;){if(w.t.lastIndex=I,C=w.t.exec(t),!C)break;j=m(t.substr(I,C.index-I),C[0]),I=C.index+j}m(t.substr(I));for(var k=w;k.parent;k=k.parent)k.cN&&(M+="</span>");return{r:B,value:M,language:e,top:w}}catch(A){if(-1!=A.message.indexOf("Illegal"))return{r:0,value:n(t)};throw A}}function l(e,t){t=t||E.languages||Object.keys(R);var r={r:0,value:n(e)},a=r;return t.forEach(function(n){if(N(n)){var t=s(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}}),a.language&&(r.second_best=a),r}function f(e){return E.tabReplace&&(e=e.replace(/^((<[^>]+>|\t)+)/gm,function(e,n){return n.replace(/\t/g,E.tabReplace)})),E.useBR&&(e=e.replace(/\n/g,"<br>")),e}function g(e,n,t){var r=n?x[n]:t,a=[e.trim()];return e.match(/(\s|^)hljs(\s|$)/)||a.push("hljs"),r&&a.push(r),a.join(" ").trim()}function p(e){var n=a(e);if(!/no(-?)highlight/.test(n)){var t;E.useBR?(t=document.createElementNS("http://www.w3.org/1999/xhtml","div"),t.innerHTML=e.innerHTML.replace(/\n/g,"").replace(/<br[ \/]*>/g,"\n")):t=e;var r=t.textContent,o=n?s(n,r,!0):l(r),u=i(t);if(u.length){var p=document.createElementNS("http://www.w3.org/1999/xhtml","div");p.innerHTML=o.value,o.value=c(u,i(p),r)}o.value=f(o.value),e.innerHTML=o.value,e.className=g(e.className,n,o.language),e.result={language:o.language,re:o.r},o.second_best&&(e.second_best={language:o.second_best.language,re:o.second_best.r})}}function d(e){E=o(E,e)}function h(){if(!h.called){h.called=!0;var e=document.querySelectorAll("pre code");Array.prototype.forEach.call(e,p)}}function v(){addEventListener("DOMContentLoaded",h,!1),addEventListener("load",h,!1)}function b(n,t){var r=R[n]=t(e);r.aliases&&r.aliases.forEach(function(e){x[e]=n})}function m(){return Object.keys(R)}function N(e){return R[e]||R[x[e]]}var E={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},R={},x={};return e.highlight=s,e.highlightAuto=l,e.fixMarkup=f,e.highlightBlock=p,e.configure=d,e.initHighlighting=h,e.initHighlightingOnLoad=v,e.registerLanguage=b,e.listLanguages=m,e.getLanguage=N,e.inherit=o,e.IR="[a-zA-Z][a-zA-Z0-9_]*",e.UIR="[a-zA-Z_][a-zA-Z0-9_]*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such)\b/},e.CLCM={cN:"comment",b:"//",e:"$",c:[e.PWM]},e.CBCM={cN:"comment",b:"/\\*",e:"\\*/",c:[e.PWM]},e.HCM={cN:"comment",b:"#",e:"$",c:[e.PWM]},e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e});hljs.registerLanguage("coffeescript",function(e){var c={keyword:"in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super then unless until loop of by when and or is isnt not",literal:"true false null undefined yes no on off",reserved:"case default function var void with const let enum export import native __hasProp __extends __slice __bind __indexOf",built_in:"npm require console print module global window document"},n="[A-Za-z$_][0-9A-Za-z$_]*",t={cN:"subst",b:/#\{/,e:/}/,k:c},r=[e.BNM,e.inherit(e.CNM,{starts:{e:"(\\s*/)?",r:0}}),{cN:"string",v:[{b:/'''/,e:/'''/,c:[e.BE]},{b:/'/,e:/'/,c:[e.BE]},{b:/"""/,e:/"""/,c:[e.BE,t]},{b:/"/,e:/"/,c:[e.BE,t]}]},{cN:"regexp",v:[{b:"///",e:"///",c:[t,e.HCM]},{b:"//[gim]*",r:0},{b:/\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/}]},{cN:"property",b:"@"+n},{b:"`",e:"`",eB:!0,eE:!0,sL:"javascript"}];t.c=r;var i=e.inherit(e.TM,{b:n}),s="(\\(.*\\))?\\s*\\B[-=]>",o={cN:"params",b:"\\([^\\(]",rB:!0,c:[{b:/\(/,e:/\)/,k:c,c:["self"].concat(r)}]};return{aliases:["coffee","cson","iced"],k:c,i:/\/\*/,c:r.concat([{cN:"comment",b:"###",e:"###",c:[e.PWM]},e.HCM,{cN:"function",b:"^\\s*"+n+"\\s*=\\s*"+s,e:"[-=]>",rB:!0,c:[i,o]},{b:/[:\(,=]\s*/,r:0,c:[{cN:"function",b:s,e:"[-=]>",rB:!0,c:[o]}]},{cN:"class",bK:"class",e:"$",i:/[:="\[\]]/,c:[{bK:"extends",eW:!0,i:/[:="\[\]]/,c:[i]},i]},{cN:"attribute",b:n+":",e:":",rB:!0,rE:!0,r:0}])}});hljs.registerLanguage("xml",function(){var t="[A-Za-z0-9\\._:-]+",e={b:/<\?(php)?(?!\w)/,e:/\?>/,sL:"php",subLanguageMode:"continuous"},c={eW:!0,i:/</,r:0,c:[e,{cN:"attribute",b:t,r:0},{b:"=",r:0,c:[{cN:"value",c:[e],v:[{b:/"/,e:/"/},{b:/'/,e:/'/},{b:/[^\s\/>]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xsl","plist"],cI:!0,c:[{cN:"doctype",b:"<!DOCTYPE",e:">",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"<!--",e:"-->",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"<style(?=\\s|>|$)",e:">",k:{title:"style"},c:[c],starts:{e:"</style>",rE:!0,sL:"css"}},{cN:"tag",b:"<script(?=\\s|>|$)",e:">",k:{title:"script"},c:[c],starts:{e:"</script>",rE:!0,sL:"javascript"}},e,{cN:"pi",b:/<\?\w+/,e:/\?>/,r:10},{cN:"tag",b:"</?",e:"/?>",c:[{cN:"title",b:/[^ \/><\n\t]+/,r:0},c]}]}});hljs.registerLanguage("markdown",function(){return{aliases:["md","mkdown","mkd"],c:[{cN:"header",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"blockquote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{cN:"horizontal_rule",b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"link_label",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link_url",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"link_reference",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:"^\\[.+\\]:",rB:!0,c:[{cN:"link_reference",b:"\\[",e:"\\]:",eB:!0,eE:!0,starts:{cN:"link_url",e:"$"}}]}]}});hljs.registerLanguage("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)\}/}]},s={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},a={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/-?[a-z\.]+/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",operator:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"shebang",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,e.NM,s,a,t]}});hljs.registerLanguage("ruby",function(e){var b="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",r="and false then defined module in return redo if BEGIN retry end for true self when next until do begin unless END rescue nil else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",c={cN:"yardoctag",b:"@[A-Za-z]+"},a={cN:"value",b:"#<",e:">"},s={cN:"comment",v:[{b:"#",e:"$",c:[c]},{b:"^\\=begin",e:"^\\=end",c:[c],r:10},{b:"^__END__",e:"\\n$"}]},n={cN:"subst",b:"#\\{",e:"}",k:r},t={cN:"string",c:[e.BE,n],v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/`/,e:/`/},{b:"%[qQwWx]?\\(",e:"\\)"},{b:"%[qQwWx]?\\[",e:"\\]"},{b:"%[qQwWx]?{",e:"}"},{b:"%[qQwWx]?<",e:">"},{b:"%[qQwWx]?/",e:"/"},{b:"%[qQwWx]?%",e:"%"},{b:"%[qQwWx]?-",e:"-"},{b:"%[qQwWx]?\\|",e:"\\|"},{b:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/}]},i={cN:"params",b:"\\(",e:"\\)",k:r},d=[t,a,s,{cN:"class",bK:"class module",e:"$|;",i:/=/,c:[e.inherit(e.TM,{b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{cN:"inheritance",b:"<\\s*",c:[{cN:"parent",b:"("+e.IR+"::)?"+e.IR}]},s]},{cN:"function",bK:"def",e:" |$|;",r:0,c:[e.inherit(e.TM,{b:b}),i,s]},{cN:"constant",b:"(::)?(\\b[A-Z]\\w*(::)?)+",r:0},{cN:"symbol",b:e.UIR+"(\\!|\\?)?:",r:0},{cN:"symbol",b:":",c:[t,{b:b}],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"variable",b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{b:"("+e.RSR+")\\s*",c:[a,s,{cN:"regexp",c:[e.BE,n],i:/\n/,v:[{b:"/",e:"/[a-z]*"},{b:"%r{",e:"}[a-z]*"},{b:"%r\\(",e:"\\)[a-z]*"},{b:"%r!",e:"![a-z]*"},{b:"%r\\[",e:"\\][a-z]*"}]}],r:0}];n.c=d,i.c=d;var l="[>?]>",u="[\\w#]+\\(\\w+\\):\\d+:\\d+>",N="(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>",o=[{b:/^\s*=>/,cN:"status",starts:{e:"$",c:d}},{cN:"prompt",b:"^("+l+"|"+u+"|"+N+")",starts:{e:"$",c:d}}];return{aliases:["rb","gemspec","podspec","thor","irb"],k:r,c:[s].concat(o).concat(d)}});hljs.registerLanguage("javascript",function(r){return{aliases:["js"],k:{keyword:"in if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const class",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document"},c:[{cN:"pi",r:10,v:[{b:/^\s*('|")use strict('|")/},{b:/^\s*('|")use asm('|")/}]},r.ASM,r.QSM,r.CLCM,r.CBCM,r.CNM,{b:"("+r.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[r.CLCM,r.CBCM,r.RM,{b:/</,e:/>;/,r:0,sL:"xml"}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[r.inherit(r.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{cN:"params",b:/\(/,e:/\)/,c:[r.CLCM,r.CBCM],i:/["'\(]/}],i:/\[|%/},{b:/\$[(.]/},{b:"\\."+r.IR,r:0}]}});hljs.registerLanguage("json",function(e){var t={literal:"true false null"},i=[e.QSM,e.CNM],l={cN:"value",e:",",eW:!0,eE:!0,c:i,k:t},c={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:!0,eE:!0,c:[e.BE],i:"\\n",starts:l}],i:"\\S"},n={b:"\\[",e:"\\]",c:[e.inherit(l,{cN:null})],i:"\\S"};return i.splice(i.length,0,c,n),{c:i,k:t,i:"\\S"}});hljs.registerLanguage("http",function(){return{i:"\\S",c:[{cN:"status",b:"^HTTP/[0-9\\.]+",e:"$",c:[{cN:"number",b:"\\b\\d{3}\\b"}]},{cN:"request",b:"^[A-Z]+ (.*?) HTTP/[0-9\\.]+$",rB:!0,e:"$",c:[{cN:"string",b:" ",e:" ",eB:!0,eE:!0}]},{cN:"attribute",b:"^\\w",e:": ",eE:!0,i:"\\n|\\s|=",starts:{cN:"string",e:"$"}},{b:"\\n\\n",starts:{sL:"",eW:!0}}]}});hljs.registerLanguage("css",function(e){var c="[a-zA-Z-][a-zA-Z0-9_-]*",a={cN:"function",b:c+"\\(",rB:!0,eE:!0,e:"\\("};return{cI:!0,i:"[=/|']",c:[e.CBCM,{cN:"id",b:"\\#[A-Za-z0-9_-]+"},{cN:"class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"attr_selector",b:"\\[",e:"\\]",i:"$"},{cN:"pseudo",b:":(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\\"\\']+"},{cN:"at_rule",b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{cN:"at_rule",b:"@",e:"[{;]",c:[{cN:"keyword",b:/\S+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[a,e.ASM,e.QSM,e.CSSNM]}]},{cN:"tag",b:c,r:0},{cN:"rules",b:"{",e:"}",i:"[^\\s]",r:0,c:[e.CBCM,{cN:"rule",b:"[^\\s]",rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:!0,i:"[^\\s]",starts:{cN:"value",eW:!0,eE:!0,c:[a,e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"hexcolor",b:"#[0-9A-Fa-f]+"},{cN:"important",b:"!important"}]}}]}]}]}}); | ||
!(function (e) { typeof exports !== 'undefined' ? e(exports) : (window.hljs = e({}), typeof define === 'function' && define.amd && define([], function () { return window.hljs })) }(function (e) { function n (e) { return e.replace(/&/gm, '&').replace(/</gm, '<').replace(/>/gm, '>') } function t (e) { return e.nodeName.toLowerCase() } function r (e, n) { var t = e && e.exec(n); return t && t.index == 0 } function a (e) { var n = (e.className + ' ' + (e.parentNode ? e.parentNode.className : '')).split(/\s+/); return n = n.map(function (e) { return e.replace(/^lang(uage)?-/, '') }), n.filter(function (e) { return N(e) || /no(-?)highlight/.test(e) })[0] } function o (e, n) { var t = {}; for (var r in e)t[r] = e[r]; if (n) for (var r in n)t[r] = n[r]; return t } function i (e) { var n = []; return (function r (e, a) { for (var o = e.firstChild; o; o = o.nextSibling)o.nodeType == 3 ? a += o.nodeValue.length : o.nodeType == 1 && (n.push({event: 'start', offset: a, node: o}), a = r(o, a), t(o).match(/br|hr|img|input/) || n.push({event: 'stop', offset: a, node: o})); return a }(e, 0)), n } function c (e, r, a) { function o () { return e.length && r.length ? e[0].offset != r[0].offset ? e[0].offset < r[0].offset ? e : r : r[0].event == 'start' ? e : r : e.length ? e : r } function i (e) { function r (e) { return ' ' + e.nodeName + '="' + n(e.value) + '"' }l += '<' + t(e) + Array.prototype.map.call(e.attributes, r).join('') + '>' } function c (e) { l += '</' + t(e) + '>' } function u (e) { (e.event == 'start' ? i : c)(e.node) } for (var s = 0, l = '', f = []; e.length || r.length;) { var g = o(); if (l += n(a.substr(s, g[0].offset - s)), s = g[0].offset, g == e) { f.reverse().forEach(c); do u(g.splice(0, 1)[0]), g = o(); while (g == e && g.length && g[0].offset == s);f.reverse().forEach(i) } else g[0].event == 'start' ? f.push(g[0].node) : f.pop(), u(g.splice(0, 1)[0]) } return l + n(a.substr(s)) } function u (e) { function n (e) { return e && e.source || e } function t (t, r) { return RegExp(n(t), 'm' + (e.cI ? 'i' : '') + (r ? 'g' : '')) } function r (a, i) { if (!a.compiled) { if (a.compiled = !0, a.k = a.k || a.bK, a.k) { var c = {}, u = function (n, t) { e.cI && (t = t.toLowerCase()), t.split(' ').forEach(function (e) { var t = e.split('|'); c[t[0]] = [n, t[1] ? Number(t[1]) : 1] }) }; typeof a.k === 'string' ? u('keyword', a.k) : Object.keys(a.k).forEach(function (e) { u(e, a.k[e]) }), a.k = c }a.lR = t(a.l || /\b[A-Za-z0-9_]+\b/, !0), i && (a.bK && (a.b = '\\b(' + a.bK.split(' ').join('|') + ')\\b'), a.b || (a.b = /\B|\b/), a.bR = t(a.b), a.e || a.eW || (a.e = /\B|\b/), a.e && (a.eR = t(a.e)), a.tE = n(a.e) || '', a.eW && i.tE && (a.tE += (a.e ? '|' : '') + i.tE)), a.i && (a.iR = t(a.i)), void 0 === a.r && (a.r = 1), a.c || (a.c = []); var s = []; a.c.forEach(function (e) { e.v ? e.v.forEach(function (n) { s.push(o(e, n)) }) : s.push(e == 'self' ? a : e) }), a.c = s, a.c.forEach(function (e) { r(e, a) }), a.starts && r(a.starts, i); var l = a.c.map(function (e) { return e.bK ? '\\.?(' + e.b + ')\\.?' : e.b }).concat([a.tE, a.i]).map(n).filter(Boolean); a.t = l.length ? t(l.join('|'), !0) : {exec: function () { return null }} } }r(e) } function s (e, t, a, o) { function i (e, n) { for (var t = 0; t < n.c.length; t++) if (r(n.c[t].bR, e)) return n.c[t] } function c (e, n) { return r(e.eR, n) ? e : e.eW ? c(e.parent, n) : void 0 } function f (e, n) { return !a && r(n.iR, e) } function g (e, n) { var t = x.cI ? n[0].toLowerCase() : n[0]; return e.k.hasOwnProperty(t) && e.k[t] } function p (e, n, t, r) { var a = r ? '' : E.classPrefix, o = '<span class="' + a, i = t ? '' : '</span>'; return o += e + '">', o + n + i } function d () { if (!w.k) return n(y); var e = '', t = 0; w.lR.lastIndex = 0; for (var r = w.lR.exec(y); r;) { e += n(y.substr(t, r.index - t)); var a = g(w, r); a ? (B += a[1], e += p(a[0], n(r[0]))) : e += n(r[0]), t = w.lR.lastIndex, r = w.lR.exec(y) } return e + n(y.substr(t)) } function h () { if (w.sL && !R[w.sL]) return n(y); var e = w.sL ? s(w.sL, y, !0, L[w.sL]) : l(y); return w.r > 0 && (B += e.r), w.subLanguageMode == 'continuous' && (L[w.sL] = e.top), p(e.language, e.value, !1, !0) } function v () { return void 0 !== w.sL ? h() : d() } function b (e, t) { var r = e.cN ? p(e.cN, '', !0) : ''; e.rB ? (M += r, y = '') : e.eB ? (M += n(t) + r, y = '') : (M += r, y = t), w = Object.create(e, {parent: {value: w}}) } function m (e, t) { if (y += e, void 0 === t) return M += v(), 0; var r = i(t, w); if (r) return M += v(), b(r, t), r.rB ? 0 : t.length; var a = c(w, t); if (a) { var o = w; o.rE || o.eE || (y += t), M += v(); do w.cN && (M += '</span>'), B += w.r, w = w.parent; while (w != a.parent);return o.eE && (M += n(t)), y = '', a.starts && b(a.starts, ''), o.rE ? 0 : t.length } if (f(t, w)) throw new Error('Illegal lexeme "' + t + '" for mode "' + (w.cN || '<unnamed>') + '"'); return y += t, t.length || 1 } var x = N(e); if (!x) throw new Error('Unknown language: "' + e + '"'); u(x); for (var w = o || x, L = {}, M = '', k = w; k != x; k = k.parent)k.cN && (M = p(k.cN, '', !0) + M); var y = '', B = 0; try { for (var C, j, I = 0; ;) { if (w.t.lastIndex = I, C = w.t.exec(t), !C) break; j = m(t.substr(I, C.index - I), C[0]), I = C.index + j }m(t.substr(I)); for (var k = w; k.parent; k = k.parent)k.cN && (M += '</span>'); return {r: B, value: M, language: e, top: w} } catch (A) { if (A.message.indexOf('Illegal') != -1) return {r: 0, value: n(t)}; throw A } } function l (e, t) { t = t || E.languages || Object.keys(R); var r = {r: 0, value: n(e)}, a = r; return t.forEach(function (n) { if (N(n)) { var t = s(n, e, !1); t.language = n, t.r > a.r && (a = t), t.r > r.r && (a = r, r = t) } }), a.language && (r.second_best = a), r } function f (e) { return E.tabReplace && (e = e.replace(/^((<[^>]+>|\t)+)/gm, function (e, n) { return n.replace(/\t/g, E.tabReplace) })), E.useBR && (e = e.replace(/\n/g, '<br>')), e } function g (e, n, t) { var r = n ? x[n] : t, a = [e.trim()]; return e.match(/(\s|^)hljs(\s|$)/) || a.push('hljs'), r && a.push(r), a.join(' ').trim() } function p (e) { var n = a(e); if (!/no(-?)highlight/.test(n)) { var t; E.useBR ? (t = document.createElementNS('http://www.w3.org/1999/xhtml', 'div'), t.innerHTML = e.innerHTML.replace(/\n/g, '').replace(/<br[ \/]*>/g, '\n')) : t = e; var r = t.textContent, o = n ? s(n, r, !0) : l(r), u = i(t); if (u.length) { var p = document.createElementNS('http://www.w3.org/1999/xhtml', 'div'); p.innerHTML = o.value, o.value = c(u, i(p), r) }o.value = f(o.value), e.innerHTML = o.value, e.className = g(e.className, n, o.language), e.result = {language: o.language, re: o.r}, o.second_best && (e.second_best = {language: o.second_best.language, re: o.second_best.r}) } } function d (e) { E = o(E, e) } function h () { if (!h.called) { h.called = !0; var e = document.querySelectorAll('pre code'); Array.prototype.forEach.call(e, p) } } function v () { addEventListener('DOMContentLoaded', h, !1), addEventListener('load', h, !1) } function b (n, t) { var r = R[n] = t(e); r.aliases && r.aliases.forEach(function (e) { x[e] = n }) } function m () { return Object.keys(R) } function N (e) { return R[e] || R[x[e]] } var E = {classPrefix: 'hljs-', tabReplace: null, useBR: !1, languages: void 0}, R = {}, x = {}; return e.highlight = s, e.highlightAuto = l, e.fixMarkup = f, e.highlightBlock = p, e.configure = d, e.initHighlighting = h, e.initHighlightingOnLoad = v, e.registerLanguage = b, e.listLanguages = m, e.getLanguage = N, e.inherit = o, e.IR = '[a-zA-Z][a-zA-Z0-9_]*', e.UIR = '[a-zA-Z_][a-zA-Z0-9_]*', e.NR = '\\b\\d+(\\.\\d+)?', e.CNR = '(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)', e.BNR = '\\b(0b[01]+)', e.RSR = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~', e.BE = {b: '\\\\[\\s\\S]', r: 0}, e.ASM = {cN: 'string', b: "'", e: "'", i: '\\n', c: [e.BE]}, e.QSM = {cN: 'string', b: '"', e: '"', i: '\\n', c: [e.BE]}, e.PWM = {b: /\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such)\b/}, e.CLCM = {cN: 'comment', b: '//', e: '$', c: [e.PWM]}, e.CBCM = {cN: 'comment', b: '/\\*', e: '\\*/', c: [e.PWM]}, e.HCM = {cN: 'comment', b: '#', e: '$', c: [e.PWM]}, e.NM = {cN: 'number', b: e.NR, r: 0}, e.CNM = {cN: 'number', b: e.CNR, r: 0}, e.BNM = {cN: 'number', b: e.BNR, r: 0}, e.CSSNM = {cN: 'number', b: e.NR + '(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?', r: 0}, e.RM = {cN: 'regexp', b: /\//, e: /\/[gimuy]*/, i: /\n/, c: [e.BE, {b: /\[/, e: /\]/, r: 0, c: [e.BE]}]}, e.TM = {cN: 'title', b: e.IR, r: 0}, e.UTM = {cN: 'title', b: e.UIR, r: 0}, e })); hljs.registerLanguage('coffeescript', function (e) { var c = {keyword: 'in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super then unless until loop of by when and or is isnt not', literal: 'true false null undefined yes no on off', reserved: 'case default function var void with const let enum export import native __hasProp __extends __slice __bind __indexOf', built_in: 'npm require console print module global window document'}, n = '[A-Za-z$_][0-9A-Za-z$_]*', t = {cN: 'subst', b: /#\{/, e: /}/, k: c}, r = [e.BNM, e.inherit(e.CNM, {starts: {e: '(\\s*/)?', r: 0}}), {cN: 'string', v: [{b: /'''/, e: /'''/, c: [e.BE]}, {b: /'/, e: /'/, c: [e.BE]}, {b: /"""/, e: /"""/, c: [e.BE, t]}, {b: /"/, e: /"/, c: [e.BE, t]}]}, {cN: 'regexp', v: [{b: '///', e: '///', c: [t, e.HCM]}, {b: '//[gim]*', r: 0}, {b: /\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/}]}, {cN: 'property', b: '@' + n}, {b: '`', e: '`', eB: !0, eE: !0, sL: 'javascript'}]; t.c = r; var i = e.inherit(e.TM, {b: n}), s = '(\\(.*\\))?\\s*\\B[-=]>', o = {cN: 'params', b: '\\([^\\(]', rB: !0, c: [{b: /\(/, e: /\)/, k: c, c: ['self'].concat(r)}]}; return {aliases: ['coffee', 'cson', 'iced'], k: c, i: /\/\*/, c: r.concat([{cN: 'comment', b: '###', e: '###', c: [e.PWM]}, e.HCM, {cN: 'function', b: '^\\s*' + n + '\\s*=\\s*' + s, e: '[-=]>', rB: !0, c: [i, o]}, {b: /[:\(,=]\s*/, r: 0, c: [{cN: 'function', b: s, e: '[-=]>', rB: !0, c: [o]}]}, {cN: 'class', bK: 'class', e: '$', i: /[:="\[\]]/, c: [{bK: 'extends', eW: !0, i: /[:="\[\]]/, c: [i]}, i]}, {cN: 'attribute', b: n + ':', e: ':', rB: !0, rE: !0, r: 0}])} }); hljs.registerLanguage('xml', function () { var t = '[A-Za-z0-9\\._:-]+', e = {b: /<\?(php)?(?!\w)/, e: /\?>/, sL: 'php', subLanguageMode: 'continuous'}, c = {eW: !0, i: /</, r: 0, c: [e, {cN: 'attribute', b: t, r: 0}, {b: '=', r: 0, c: [{cN: 'value', c: [e], v: [{b: /"/, e: /"/}, {b: /'/, e: /'/}, {b: /[^\s\/>]+/}]}]}]}; return {aliases: ['html', 'xhtml', 'rss', 'atom', 'xsl', 'plist'], cI: !0, c: [{cN: 'doctype', b: '<!DOCTYPE', e: '>', r: 10, c: [{b: '\\[', e: '\\]'}]}, {cN: 'comment', b: '<!--', e: '-->', r: 10}, {cN: 'cdata', b: '<\\!\\[CDATA\\[', e: '\\]\\]>', r: 10}, {cN: 'tag', b: '<style(?=\\s|>|$)', e: '>', k: {title: 'style'}, c: [c], starts: {e: '</style>', rE: !0, sL: 'css'}}, {cN: 'tag', b: '<script(?=\\s|>|$)', e: '>', k: {title: 'script'}, c: [c], starts: {e: '</script>', rE: !0, sL: 'javascript'}}, e, {cN: 'pi', b: /<\?\w+/, e: /\?>/, r: 10}, {cN: 'tag', b: '</?', e: '/?>', c: [{cN: 'title', b: /[^ \/><\n\t]+/, r: 0}, c]}]} }); hljs.registerLanguage('markdown', function () { return {aliases: ['md', 'mkdown', 'mkd'], c: [{cN: 'header', v: [{b: '^#{1,6}', e: '$'}, {b: '^.+?\\n[=-]{2,}$'}]}, {b: '<', e: '>', sL: 'xml', r: 0}, {cN: 'bullet', b: '^([*+-]|(\\d+\\.))\\s+'}, {cN: 'strong', b: '[*_]{2}.+?[*_]{2}'}, {cN: 'emphasis', v: [{b: '\\*.+?\\*'}, {b: '_.+?_', r: 0}]}, {cN: 'blockquote', b: '^>\\s+', e: '$'}, {cN: 'code', v: [{b: '`.+?`'}, {b: '^( {4}| )', e: '$', r: 0}]}, {cN: 'horizontal_rule', b: '^[-\\*]{3,}', e: '$'}, {b: '\\[.+?\\][\\(\\[].*?[\\)\\]]', rB: !0, c: [{cN: 'link_label', b: '\\[', e: '\\]', eB: !0, rE: !0, r: 0}, {cN: 'link_url', b: '\\]\\(', e: '\\)', eB: !0, eE: !0}, {cN: 'link_reference', b: '\\]\\[', e: '\\]', eB: !0, eE: !0}], r: 10}, {b: '^\\[.+\\]:', rB: !0, c: [{cN: 'link_reference', b: '\\[', e: '\\]:', eB: !0, eE: !0, starts: {cN: 'link_url', e: '$'}}]}]} }); hljs.registerLanguage('bash', function (e) { var t = {cN: 'variable', v: [{b: /\$[\w\d#@][\w\d_]*/}, {b: /\$\{(.*?)\}/}]}, s = {cN: 'string', b: /"/, e: /"/, c: [e.BE, t, {cN: 'variable', b: /\$\(/, e: /\)/, c: [e.BE]}]}, a = {cN: 'string', b: /'/, e: /'/}; return {aliases: ['sh', 'zsh'], l: /-?[a-z\.]+/, k: {keyword: 'if then else elif fi for while in do done case esac function', literal: 'true false', built_in: 'break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp', operator: '-ne -eq -lt -gt -f -d -e -s -l -a'}, c: [{cN: 'shebang', b: /^#![^\n]+sh\s*$/, r: 10}, {cN: 'function', b: /\w[\w\d_]*\s*\(\s*\)\s*\{/, rB: !0, c: [e.inherit(e.TM, {b: /\w[\w\d_]*/})], r: 0}, e.HCM, e.NM, s, a, t]} }); hljs.registerLanguage('ruby', function (e) { var b = '[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?', r = 'and false then defined module in return redo if BEGIN retry end for true self when next until do begin unless END rescue nil else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor', c = {cN: 'yardoctag', b: '@[A-Za-z]+'}, a = {cN: 'value', b: '#<', e: '>'}, s = {cN: 'comment', v: [{b: '#', e: '$', c: [c]}, {b: '^\\=begin', e: '^\\=end', c: [c], r: 10}, {b: '^__END__', e: '\\n$'}]}, n = {cN: 'subst', b: '#\\{', e: '}', k: r}, t = {cN: 'string', c: [e.BE, n], v: [{b: /'/, e: /'/}, {b: /"/, e: /"/}, {b: /`/, e: /`/}, {b: '%[qQwWx]?\\(', e: '\\)'}, {b: '%[qQwWx]?\\[', e: '\\]'}, {b: '%[qQwWx]?{', e: '}'}, {b: '%[qQwWx]?<', e: '>'}, {b: '%[qQwWx]?/', e: '/'}, {b: '%[qQwWx]?%', e: '%'}, {b: '%[qQwWx]?-', e: '-'}, {b: '%[qQwWx]?\\|', e: '\\|'}, {b: /\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/}]}, i = {cN: 'params', b: '\\(', e: '\\)', k: r}, d = [t, a, s, {cN: 'class', bK: 'class module', e: '$|;', i: /=/, c: [e.inherit(e.TM, {b: '[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?'}), {cN: 'inheritance', b: '<\\s*', c: [{cN: 'parent', b: '(' + e.IR + '::)?' + e.IR}]}, s]}, {cN: 'function', bK: 'def', e: ' |$|;', r: 0, c: [e.inherit(e.TM, {b: b}), i, s]}, {cN: 'constant', b: '(::)?(\\b[A-Z]\\w*(::)?)+', r: 0}, {cN: 'symbol', b: e.UIR + '(\\!|\\?)?:', r: 0}, {cN: 'symbol', b: ':', c: [t, {b: b}], r: 0}, {cN: 'number', b: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b', r: 0}, {cN: 'variable', b: '(\\$\\W)|((\\$|\\@\\@?)(\\w+))'}, {b: '(' + e.RSR + ')\\s*', c: [a, s, {cN: 'regexp', c: [e.BE, n], i: /\n/, v: [{b: '/', e: '/[a-z]*'}, {b: '%r{', e: '}[a-z]*'}, {b: '%r\\(', e: '\\)[a-z]*'}, {b: '%r!', e: '![a-z]*'}, {b: '%r\\[', e: '\\][a-z]*'}]}], r: 0}]; n.c = d, i.c = d; var l = '[>?]>', u = '[\\w#]+\\(\\w+\\):\\d+:\\d+>', N = '(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>', o = [{b: /^\s*=>/, cN: 'status', starts: {e: '$', c: d}}, {cN: 'prompt', b: '^(' + l + '|' + u + '|' + N + ')', starts: {e: '$', c: d}}]; return {aliases: ['rb', 'gemspec', 'podspec', 'thor', 'irb'], k: r, c: [s].concat(o).concat(d)} }); hljs.registerLanguage('javascript', function (r) { return {aliases: ['js'], k: {keyword: 'in if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const class', literal: 'true false null undefined NaN Infinity', built_in: 'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document'}, c: [{cN: 'pi', r: 10, v: [{b: /^\s*('|")use strict('|")/}, {b: /^\s*('|")use asm('|")/}]}, r.ASM, r.QSM, r.CLCM, r.CBCM, r.CNM, {b: '(' + r.RSR + '|\\b(case|return|throw)\\b)\\s*', k: 'return throw case', c: [r.CLCM, r.CBCM, r.RM, {b: /</, e: />;/, r: 0, sL: 'xml'}], r: 0}, {cN: 'function', bK: 'function', e: /\{/, eE: !0, c: [r.inherit(r.TM, {b: /[A-Za-z$_][0-9A-Za-z$_]*/}), {cN: 'params', b: /\(/, e: /\)/, c: [r.CLCM, r.CBCM], i: /["'\(]/}], i: /\[|%/}, {b: /\$[(.]/}, {b: '\\.' + r.IR, r: 0}]} }); hljs.registerLanguage('json', function (e) { var t = {literal: 'true false null'}, i = [e.QSM, e.CNM], l = {cN: 'value', e: ',', eW: !0, eE: !0, c: i, k: t}, c = {b: '{', e: '}', c: [{cN: 'attribute', b: '\\s*"', e: '"\\s*:\\s*', eB: !0, eE: !0, c: [e.BE], i: '\\n', starts: l}], i: '\\S'}, n = {b: '\\[', e: '\\]', c: [e.inherit(l, {cN: null})], i: '\\S'}; return i.splice(i.length, 0, c, n), {c: i, k: t, i: '\\S'} }); hljs.registerLanguage('http', function () { return {i: '\\S', c: [{cN: 'status', b: '^HTTP/[0-9\\.]+', e: '$', c: [{cN: 'number', b: '\\b\\d{3}\\b'}]}, {cN: 'request', b: '^[A-Z]+ (.*?) HTTP/[0-9\\.]+$', rB: !0, e: '$', c: [{cN: 'string', b: ' ', e: ' ', eB: !0, eE: !0}]}, {cN: 'attribute', b: '^\\w', e: ': ', eE: !0, i: '\\n|\\s|=', starts: {cN: 'string', e: '$'}}, {b: '\\n\\n', starts: {sL: '', eW: !0}}]} }); hljs.registerLanguage('css', function (e) { var c = '[a-zA-Z-][a-zA-Z0-9_-]*', a = {cN: 'function', b: c + '\\(', rB: !0, eE: !0, e: '\\('}; return {cI: !0, i: "[=/|']", c: [e.CBCM, {cN: 'id', b: '\\#[A-Za-z0-9_-]+'}, {cN: 'class', b: '\\.[A-Za-z0-9_-]+', r: 0}, {cN: 'attr_selector', b: '\\[', e: '\\]', i: '$'}, {cN: 'pseudo', b: ":(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\\"\\']+"}, {cN: 'at_rule', b: '@(font-face|page)', l: '[a-z-]+', k: 'font-face page'}, {cN: 'at_rule', b: '@', e: '[{;]', c: [{cN: 'keyword', b: /\S+/}, {b: /\s/, eW: !0, eE: !0, r: 0, c: [a, e.ASM, e.QSM, e.CSSNM]}]}, {cN: 'tag', b: c, r: 0}, {cN: 'rules', b: '{', e: '}', i: '[^\\s]', r: 0, c: [e.CBCM, {cN: 'rule', b: '[^\\s]', rB: !0, e: ';', eW: !0, c: [{cN: 'attribute', b: '[A-Z\\_\\.\\-]+', e: ':', eE: !0, i: '[^\\s]', starts: {cN: 'value', eW: !0, eE: !0, c: [a, e.CSSNM, e.QSM, e.ASM, e.CBCM, {cN: 'hexcolor', b: '#[0-9A-Fa-f]+'}, {cN: 'important', b: '!important'}]}}]}]}]} }) |
@@ -20,3 +20,3 @@ --- | ||
Task in sec :2014-01-12 , 12d | ||
anther task : 24d | ||
another task : 24d | ||
``` | ||
@@ -35,3 +35,3 @@ | ||
Task in sec :2014-01-12 , 12d | ||
anther task : 24d | ||
another task : 24d | ||
``` | ||
@@ -50,3 +50,3 @@ | ||
Future task : des3, after des2, 5d | ||
Future task2 : des4, after des3, 5d | ||
Future task2 : des4, after des3, 5d | ||
@@ -68,4 +68,4 @@ section Critical tasks | ||
Describe gantt syntax :after doc1, 3d | ||
Add gantt diagram to demo page : 20h | ||
Add another diagram to demo page : 48h | ||
Add gantt diagram to demo page :20h | ||
Add another diagram to demo page :48h | ||
``` | ||
@@ -84,3 +84,3 @@ | ||
Future task : des3, after des2, 5d | ||
Future task2 : des4, after des3, 5d | ||
Future task2 : des4, after des3, 5d | ||
@@ -102,6 +102,6 @@ section Critical tasks | ||
Describe gantt syntax :after doc1, 3d | ||
Add gantt diagram to demo page : 20h | ||
Add another diagram to demo page : 48h | ||
``` | ||
### title | ||
Add gantt diagram to demo page :20h | ||
Add another diagram to demo page :48h | ||
``` | ||
### Title | ||
@@ -118,3 +118,2 @@ Tbd | ||
### Date format | ||
@@ -261,3 +260,3 @@ | ||
This is done by defining the **sequenceConfig** part of the configuration object. Read more about it [here](http://knsv.github.io/mermaid/index.html#configuration28). How to use | ||
the CLI is described in the [mermaidCLI]((http://knsv.github.io/mermaid/index.html#mermaidCLI) page. | ||
This is done by defining the **sequenceConfig** part of the configuration object. Read more about it [here](#configuration35). | ||
How to use the CLI is described in the [mermaidCLI](#mermaid-cli8) page. |
@@ -7,3 +7,3 @@ --- | ||
======= | ||
![Alt text](images/header.png) | ||
![Header Image](images/header.png) | ||
@@ -14,6 +14,4 @@ >Generation of diagrams and flowcharts from text in a similar manner as markdown. | ||
This is why mermaid was born, a simple markdown-like script language for generating charts from text via javascript. [Try it using our editor][live_editor]. | ||
This is why mermaid was born, a simple markdown-like script language for generating charts from text via javascript. [Try it using our editor](http://knsv.github.io/mermaid/live_editor). | ||
Code examples below: | ||
@@ -64,9 +62,7 @@ | ||
Play with mermaid using this [editor](http://danielmschmidt.github.io/mermaid-demo/) or this [live editor](live_editor). | ||
Play with mermaid using this [editor](https://danielmschmidt.github.io/mermaid-demo/) or this [live editor][live_editor]. | ||
## Credits | ||
Many thanks to the [d3](http://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects for providing | ||
the graphical layout and drawing libraries! Thanks also to the | ||
[js-sequence-diagram](http://bramp.github.io/js-sequence-diagrams) project for usage of the grammar for the | ||
sequence diagrams. | ||
Many thanks to the [d3](https://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects for providing the graphical layout and drawing libraries! | ||
Thanks also to the [js-sequence-diagram](https://bramp.github.io/js-sequence-diagrams) project for usage of the grammar for the sequence diagrams. | ||
@@ -90,3 +86,3 @@ *Mermaid was created by Knut Sveidqvist for easier documentation.* | ||
* [Plugin for atom](https://atom.io/packages/atom-mermaid) | ||
* [Markdown Plus](http://mdp.tylingsoft.com/) | ||
* [Markdown Plus](https://mdp.tylingsoft.com/) | ||
* [Vim Plugin](https://github.com/kannokanno/previm) | ||
@@ -105,2 +101,4 @@ * [Sphinx extension](https://github.com/mgaitan/sphinxcontrib-mermaid) | ||
* [Editor](http://knsv.github.io/mermaid/live_editor) | ||
* [Editor][live_editor] | ||
[live_editor]: https://knsv.github.io/mermaid/live_editor/ |
@@ -24,4 +24,7 @@ --- | ||
-o --outputDir Directory to save files, will be created automatically, defaults to `cwd` | ||
-O --outputSuffix Suffix to output filenames in front of '.svg' or '.png', defaults to '' | ||
-e --phantomPath Specify the path to the phantomjs executable | ||
-t --css Specify the path to a CSS file to be included when processing output | ||
-c --sequenceConfig Specify the path to the file with the configuration to be applied in the sequence diagram | ||
-g --ganttConfig Specify the path to the file with the configuration to be applied in the gantt diagram | ||
-h --help Show this message | ||
@@ -28,0 +31,0 @@ -v --verbose Show logging |
@@ -62,15 +62,12 @@ --- | ||
-> which will render a solid line without arrow | ||
Type | Description | ||
--- | --- | ||
-> | Solid line without arrow | ||
--> | Dotted line without arrow | ||
->> | Solid line with arrowhead | ||
-->> | Dotted line with arrowhead | ||
-x | Solid line with a cross at the end (async) | ||
--x | Dotted line with a cross at the end (async) | ||
--> which will render a dotted line without arrow | ||
->> which will render a solid line with arrowhead | ||
-->> which will render a dotted line with arrowhead | ||
-x which will render a solid line with a cross at the end (async) | ||
--x which will render a dotted line with a cross at the end (async) | ||
## Activations | ||
@@ -110,3 +107,3 @@ It is possible to activate and deactivate an actor. (de)activation can be dedicated declarations: | ||
Alice->>+John: Hello John, how are you? | ||
Alice->>+John: John, can yoy hear me? | ||
Alice->>+John: John, can you hear me? | ||
John-->>-Alice: Hi Alice, I can hear you! | ||
@@ -121,3 +118,3 @@ John-->>-Alice: I feel great! | ||
Alice->>+John: Hello John, how are you? | ||
Alice->>+John: John, can yoy hear me? | ||
Alice->>+John: John, can you hear me? | ||
John-->>-Alice: Hi Alice, I can hear you! | ||
@@ -343,5 +340,5 @@ John-->>-Alice: I feel great! | ||
This is done by defining **mermaid.sequenceConfig** or by the CLI to use a json file with the configuration. How to use | ||
the CLI is described in the mermaidCLI page. | ||
mermaid.sequenceConfig can be set to a JSON string with config parameters or the corresponding object. | ||
This is done by defining **mermaid.sequenceConfig** or by the CLI to use a json file with the configuration. | ||
How to use the CLI is described in the [mermaidCLI](#mermaid-cli8) page. | ||
**mermaid.sequenceConfig** can be set to a JSON string with config parameters or the corresponding object. | ||
@@ -363,3 +360,3 @@ ``` | ||
--- | --- | --- | ||
mirrorActor|Turns on/off the rendering of actors below the diagram as well as above it|false | ||
bottomMarginAdj|Adjusts how far down the graph ended. Wide borders styles with css could generate unwantewd clipping which is why this config param exists.|1 | ||
mirrorActor | Turns on/off the rendering of actors below the diagram as well as above it | false | ||
bottomMarginAdj | Adjusts how far down the graph ended. Wide borders styles with css could generate unwantewd clipping which is why this config param exists. | 1 |
@@ -1,2 +0,2 @@ | ||
!function(){if("ontouchstart"in window){var t,e,n,r,i,a,o={};t=function(t,e){return Math.abs(t[0]-e[0])>5||Math.abs(t[1]-e[1])>5},e=function(t){this.startXY=[t.touches[0].clientX,t.touches[0].clientY],this.threshold=!1},n=function(e){return this.threshold?!1:void(this.threshold=t(this.startXY,[e.touches[0].clientX,e.touches[0].clientY]))},r=function(e){if(!this.threshold&&!t(this.startXY,[e.changedTouches[0].clientX,e.changedTouches[0].clientY])){var n=e.changedTouches[0],r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,0,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),r.simulated=!0,e.target.dispatchEvent(r)}},i=function(t){var e=Date.now(),n=e-o.time,r=t.clientX,i=t.clientY,u=[Math.abs(o.x-r),Math.abs(o.y-i)],s=a(t.target,"A")||t.target,c=s.nodeName,l="A"===c,h=window.navigator.standalone&&l&&t.target.getAttribute("href");return o.time=e,o.x=r,o.y=i,(!t.simulated&&(500>n||1500>n&&u[0]<50&&u[1]<50)||h)&&(t.preventDefault(),t.stopPropagation(),!h)?!1:(h&&(window.location=s.getAttribute("href")),void(s&&s.classList&&(s.classList.add("energize-focus"),window.setTimeout(function(){s.classList.remove("energize-focus")},150))))},a=function(t,e){for(var n=t;n!==document.body;){if(!n||n.nodeName===e)return n;n=n.parentNode}return null},document.addEventListener("touchstart",e,!1),document.addEventListener("touchmove",n,!1),document.addEventListener("touchend",r,!1),document.addEventListener("click",i,!0)}}(),/* | ||
!(function () { if ('ontouchstart' in window) { var t, e, n, r, i, a, o = {}; t = function (t, e) { return Math.abs(t[0] - e[0]) > 5 || Math.abs(t[1] - e[1]) > 5 }, e = function (t) { this.startXY = [t.touches[0].clientX, t.touches[0].clientY], this.threshold = !1 }, n = function (e) { return this.threshold ? !1 : void (this.threshold = t(this.startXY, [e.touches[0].clientX, e.touches[0].clientY])) }, r = function (e) { if (!this.threshold && !t(this.startXY, [e.changedTouches[0].clientX, e.changedTouches[0].clientY])) { var n = e.changedTouches[0], r = document.createEvent('MouseEvents'); r.initMouseEvent('click', !0, !0, window, 0, n.screenX, n.screenY, n.clientX, n.clientY, !1, !1, !1, !1, 0, null), r.simulated = !0, e.target.dispatchEvent(r) } }, i = function (t) { var e = Date.now(), n = e - o.time, r = t.clientX, i = t.clientY, u = [Math.abs(o.x - r), Math.abs(o.y - i)], s = a(t.target, 'A') || t.target, c = s.nodeName, l = c === 'A', h = window.navigator.standalone && l && t.target.getAttribute('href'); return o.time = e, o.x = r, o.y = i, (!t.simulated && (n < 500 || n < 1500 && u[0] < 50 && u[1] < 50) || h) && (t.preventDefault(), t.stopPropagation(), !h) ? !1 : (h && (window.location = s.getAttribute('href')), void (s && s.classList && (s.classList.add('energize-focus'), window.setTimeout(function () { s.classList.remove('energize-focus') }, 150)))) }, a = function (t, e) { for (var n = t; n !== document.body;) { if (!n || n.nodeName === e) return n; n = n.parentNode } return null }, document.addEventListener('touchstart', e, !1), document.addEventListener('touchmove', n, !1), document.addEventListener('touchend', r, !1), document.addEventListener('click', i, !0) } }()), /* | ||
Copyright 2008-2013 Concur Technologies, Inc. | ||
@@ -16,7 +16,7 @@ | ||
*/ | ||
function(t){"use strict";function e(e){if(e&&""!==e){$(".lang-selector a").removeClass("active"),$(".lang-selector a[data-language-name='"+e+"']").addClass("active");for(var n=0;n<s.length;n++)$(".highlight."+s[n]).hide();$(".highlight."+e).show(),t.toc.calculateHeights(),$(window.location.hash).get(0)&&$(window.location.hash).get(0).scrollIntoView(!0)}}function n(t){return"string"!=typeof t?{}:(t=t.trim().replace(/^(\?|#|&)/,""),t?t.split("&").reduce(function(t,e){var n=e.replace(/\+/g," ").split("="),r=n[0],i=n[1];return r=decodeURIComponent(r),i=void 0===i?null:decodeURIComponent(i),t.hasOwnProperty(r)?Array.isArray(t[r])?t[r].push(i):t[r]=[t[r],i]:t[r]=i,t},{}):{})}function r(t){return t?Object.keys(t).sort().map(function(e){var n=t[e];return Array.isArray(n)?n.sort().map(function(t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}).join("&"):encodeURIComponent(e)+"="+encodeURIComponent(n)}).join("&"):""}function i(){if(location.search.length>=1){var t=n(location.search).language;if(t)return t;if(-1!=jQuery.inArray(location.search.substr(1),s))return location.search.substr(1)}return!1}function a(t){var e=n(location.search);return e.language?(e.language=t,r(e)):t}function o(t){if(history){var e=window.location.hash;e&&(e=e.replace(/^#+/,"")),history.pushState({},"","?"+a(t)+"#"+e),localStorage.setItem("language",t)}}function u(t){var n=localStorage.getItem("language");s=t;var r=i();r?(e(r),localStorage.setItem("language",r)):e(null!==n&&-1!=jQuery.inArray(n,s)?n:s[0])}var s=[];t.setupLanguages=u,t.activateLanguage=e,$(function(){$(".lang-selector a").on("click",function(){var t=$(this).data("language-name");return o(t),e(t),!1}),window.onpopstate=function(){e(i())}})}(window),/*! jQuery UI - v1.11.3 - 2015-02-12 | ||
(function (t) { 'use strict'; function e (e) { if (e && e !== '') { $('.lang-selector a').removeClass('active'), $(".lang-selector a[data-language-name='" + e + "']").addClass('active'); for (var n = 0; n < s.length; n++)$('.highlight.' + s[n]).hide(); $('.highlight.' + e).show(), t.toc.calculateHeights(), $(window.location.hash).get(0) && $(window.location.hash).get(0).scrollIntoView(!0) } } function n (t) { return typeof t !== 'string' ? {} : (t = t.trim().replace(/^(\?|#|&)/, ''), t ? t.split('&').reduce(function (t, e) { var n = e.replace(/\+/g, ' ').split('='), r = n[0], i = n[1]; return r = decodeURIComponent(r), i = void 0 === i ? null : decodeURIComponent(i), t.hasOwnProperty(r) ? Array.isArray(t[r]) ? t[r].push(i) : t[r] = [t[r], i] : t[r] = i, t }, {}) : {}) } function r (t) { return t ? Object.keys(t).sort().map(function (e) { var n = t[e]; return Array.isArray(n) ? n.sort().map(function (t) { return encodeURIComponent(e) + '=' + encodeURIComponent(t) }).join('&') : encodeURIComponent(e) + '=' + encodeURIComponent(n) }).join('&') : '' } function i () { if (location.search.length >= 1) { var t = n(location.search).language; if (t) return t; if (jQuery.inArray(location.search.substr(1), s) != -1) return location.search.substr(1) } return !1 } function a (t) { var e = n(location.search); return e.language ? (e.language = t, r(e)) : t } function o (t) { if (history) { var e = window.location.hash; e && (e = e.replace(/^#+/, '')), history.pushState({}, '', '?' + a(t) + '#' + e), localStorage.setItem('language', t) } } function u (t) { var n = localStorage.getItem('language'); s = t; var r = i(); r ? (e(r), localStorage.setItem('language', r)) : e(n !== null && jQuery.inArray(n, s) != -1 ? n : s[0]) } var s = []; t.setupLanguages = u, t.activateLanguage = e, $(function () { $('.lang-selector a').on('click', function () { var t = $(this).data('language-name'); return o(t), e(t), !1 }), window.onpopstate = function () { e(i()) } }) }(window)), /*! jQuery UI - v1.11.3 - 2015-02-12 | ||
* http://jqueryui.com | ||
* Includes: widget.js | ||
* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ | ||
function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(t){/*! | ||
(function (t) { typeof define === 'function' && define.amd ? define(['jquery'], t) : t(jQuery) }(function (t) { /*! | ||
* jQuery UI Widget 1.11.3 | ||
@@ -31,3 +31,4 @@ * http://jqueryui.com | ||
*/ | ||
var e=0,n=Array.prototype.slice;t.cleanData=function(e){return function(n){var r,i,a;for(a=0;null!=(i=n[a]);a++)try{r=t._data(i,"events"),r&&r.remove&&t(i).triggerHandler("remove")}catch(o){}e(n)}}(t.cleanData),t.widget=function(e,n,r){var i,a,o,u,s={},c=e.split(".")[0];return e=e.split(".")[1],i=c+"-"+e,r||(r=n,n=t.Widget),t.expr[":"][i.toLowerCase()]=function(e){return!!t.data(e,i)},t[c]=t[c]||{},a=t[c][e],o=t[c][e]=function(t,e){return this._createWidget?void(arguments.length&&this._createWidget(t,e)):new o(t,e)},t.extend(o,a,{version:r.version,_proto:t.extend({},r),_childConstructors:[]}),u=new n,u.options=t.widget.extend({},u.options),t.each(r,function(e,r){return t.isFunction(r)?void(s[e]=function(){var t=function(){return n.prototype[e].apply(this,arguments)},i=function(t){return n.prototype[e].apply(this,t)};return function(){var e,n=this._super,a=this._superApply;return this._super=t,this._superApply=i,e=r.apply(this,arguments),this._super=n,this._superApply=a,e}}()):void(s[e]=r)}),o.prototype=t.widget.extend(u,{widgetEventPrefix:a?u.widgetEventPrefix||e:e},s,{constructor:o,namespace:c,widgetName:e,widgetFullName:i}),a?(t.each(a._childConstructors,function(e,n){var r=n.prototype;t.widget(r.namespace+"."+r.widgetName,o,n._proto)}),delete a._childConstructors):n._childConstructors.push(o),t.widget.bridge(e,o),o},t.widget.extend=function(e){for(var r,i,a=n.call(arguments,1),o=0,u=a.length;u>o;o++)for(r in a[o])i=a[o][r],a[o].hasOwnProperty(r)&&void 0!==i&&(e[r]=t.isPlainObject(i)?t.isPlainObject(e[r])?t.widget.extend({},e[r],i):t.widget.extend({},i):i);return e},t.widget.bridge=function(e,r){var i=r.prototype.widgetFullName||e;t.fn[e]=function(a){var o="string"==typeof a,u=n.call(arguments,1),s=this;return o?this.each(function(){var n,r=t.data(this,i);return"instance"===a?(s=r,!1):r?t.isFunction(r[a])&&"_"!==a.charAt(0)?(n=r[a].apply(r,u),n!==r&&void 0!==n?(s=n&&n.jquery?s.pushStack(n.get()):n,!1):void 0):t.error("no such method '"+a+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; attempted to call method '"+a+"'")}):(u.length&&(a=t.widget.extend.apply(null,[a].concat(u))),this.each(function(){var e=t.data(this,i);e?(e.option(a||{}),e._init&&e._init()):t.data(this,i,new r(a,this))})),s}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(n,r){r=t(r||this.defaultElement||this)[0],this.element=t(r),this.uuid=e++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),r!==this&&(t.data(r,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===r&&this.destroy()}}),this.document=t(r.style?r.ownerDocument:r.document||r),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),n),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(e,n){var r,i,a,o=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(o={},r=e.split("."),e=r.shift(),r.length){for(i=o[e]=t.widget.extend({},this.options[e]),a=0;a<r.length-1;a++)i[r[a]]=i[r[a]]||{},i=i[r[a]];if(e=r.pop(),1===arguments.length)return void 0===i[e]?null:i[e];i[e]=n}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];o[e]=n}return this._setOptions(o),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return this.options[t]=e,"disabled"===t&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!e),e&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(e,n,r){var i,a=this;"boolean"!=typeof e&&(r=n,n=e,e=!1),r?(n=i=t(n),this.bindings=this.bindings.add(n)):(r=n,n=this.element,i=this.widget()),t.each(r,function(r,o){function u(){return e||a.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof o?a[o]:o).apply(a,arguments):void 0}"string"!=typeof o&&(u.guid=o.guid=o.guid||u.guid||t.guid++);var s=r.match(/^([\w:-]*)\s*(.*)$/),c=s[1]+a.eventNamespace,l=s[2];l?i.delegate(l,c,u):n.bind(c,u)})},_off:function(e,n){n=(n||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(n).undelegate(n),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function n(){return("string"==typeof t?r[t]:t).apply(r,arguments)}var r=this;return setTimeout(n,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){t(e.currentTarget).addClass("ui-state-hover")},mouseleave:function(e){t(e.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){t(e.currentTarget).addClass("ui-state-focus")},focusout:function(e){t(e.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(e,n,r){var i,a,o=this.options[e];if(r=r||{},n=t.Event(n),n.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),n.target=this.element[0],a=n.originalEvent)for(i in a)i in n||(n[i]=a[i]);return this.element.trigger(n,r),!(t.isFunction(o)&&o.apply(this.element[0],[n].concat(r))===!1||n.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,n){t.Widget.prototype["_"+e]=function(r,i,a){"string"==typeof i&&(i={effect:i});var o,u=i?i===!0||"number"==typeof i?n:i.effect||n:e;i=i||{},"number"==typeof i&&(i={duration:i}),o=!t.isEmptyObject(i),i.complete=a,i.delay&&r.delay(i.delay),o&&t.effects&&t.effects.effect[u]?r[e](i):u!==e&&r[u]?r[u](i.duration,i.easing,a):r.queue(function(n){t(this)[e](),a&&a.call(r[0]),n()})}});t.widget}),/* jquery Tocify - v1.8.0 - 2013-09-16 | ||
var e = 0, n = Array.prototype.slice; t.cleanData = (function (e) { return function (n) { var r, i, a; for (a = 0; (i = n[a]) != null; a++) try { r = t._data(i, 'events'), r && r.remove && t(i).triggerHandler('remove') } catch (o) {}e(n) } }(t.cleanData)), t.widget = function (e, n, r) { var i, a, o, u, s = {}, c = e.split('.')[0]; return e = e.split('.')[1], i = c + '-' + e, r || (r = n, n = t.Widget), t.expr[':'][i.toLowerCase()] = function (e) { return !!t.data(e, i) }, t[c] = t[c] || {}, a = t[c][e], o = t[c][e] = function (t, e) { return this._createWidget ? void (arguments.length && this._createWidget(t, e)) : new o(t, e) }, t.extend(o, a, {version: r.version, _proto: t.extend({}, r), _childConstructors: []}), u = new n(), u.options = t.widget.extend({}, u.options), t.each(r, function (e, r) { return t.isFunction(r) ? void (s[e] = (function () { var t = function () { return n.prototype[e].apply(this, arguments) }, i = function (t) { return n.prototype[e].apply(this, t) }; return function () { var e, n = this._super, a = this._superApply; return this._super = t, this._superApply = i, e = r.apply(this, arguments), this._super = n, this._superApply = a, e } }())) : void (s[e] = r) }), o.prototype = t.widget.extend(u, {widgetEventPrefix: a ? u.widgetEventPrefix || e : e}, s, {constructor: o, namespace: c, widgetName: e, widgetFullName: i}), a ? (t.each(a._childConstructors, function (e, n) { var r = n.prototype; t.widget(r.namespace + '.' + r.widgetName, o, n._proto) }), delete a._childConstructors) : n._childConstructors.push(o), t.widget.bridge(e, o), o }, t.widget.extend = function (e) { for (var r, i, a = n.call(arguments, 1), o = 0, u = a.length; u > o; o++) for (r in a[o])i = a[o][r], a[o].hasOwnProperty(r) && void 0 !== i && (e[r] = t.isPlainObject(i) ? t.isPlainObject(e[r]) ? t.widget.extend({}, e[r], i) : t.widget.extend({}, i) : i); return e }, t.widget.bridge = function (e, r) { var i = r.prototype.widgetFullName || e; t.fn[e] = function (a) { var o = typeof a === 'string', u = n.call(arguments, 1), s = this; return o ? this.each(function () { var n, r = t.data(this, i); return a === 'instance' ? (s = r, !1) : r ? t.isFunction(r[a]) && a.charAt(0) !== '_' ? (n = r[a].apply(r, u), n !== r && void 0 !== n ? (s = n && n.jquery ? s.pushStack(n.get()) : n, !1) : void 0) : t.error("no such method '" + a + "' for " + e + ' widget instance') : t.error('cannot call methods on ' + e + " prior to initialization; attempted to call method '" + a + "'") }) : (u.length && (a = t.widget.extend.apply(null, [a].concat(u))), this.each(function () { var e = t.data(this, i); e ? (e.option(a || {}), e._init && e._init()) : t.data(this, i, new r(a, this)) })), s } }, t.Widget = function () {}, t.Widget._childConstructors = [], t.Widget.prototype = {widgetName: 'widget', widgetEventPrefix: '', defaultElement: '<div>', options: {disabled: !1, create: null}, _createWidget: function (n, r) { r = t(r || this.defaultElement || this)[0], this.element = t(r), this.uuid = e++, this.eventNamespace = '.' + this.widgetName + this.uuid, this.bindings = t(), this.hoverable = t(), this.focusable = t(), r !== this && (t.data(r, this.widgetFullName, this), this._on(!0, this.element, {remove: function (t) { t.target === r && this.destroy() }}), this.document = t(r.style ? r.ownerDocument : r.document || r), this.window = t(this.document[0].defaultView || this.document[0].parentWindow)), this.options = t.widget.extend({}, this.options, this._getCreateOptions(), n), this._create(), this._trigger('create', null, this._getCreateEventData()), this._init() }, _getCreateOptions: t.noop, _getCreateEventData: t.noop, _create: t.noop, _init: t.noop, destroy: function () { this._destroy(), this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)), this.widget().unbind(this.eventNamespace).removeAttr('aria-disabled').removeClass(this.widgetFullName + '-disabled ui-state-disabled'), this.bindings.unbind(this.eventNamespace), this.hoverable.removeClass('ui-state-hover'), this.focusable.removeClass('ui-state-focus') }, _destroy: t.noop, widget: function () { return this.element }, option: function (e, n) { var r, i, a, o = e; if (arguments.length === 0) return t.widget.extend({}, this.options); if (typeof e === 'string') if (o = {}, r = e.split('.'), e = r.shift(), r.length) { for (i = o[e] = t.widget.extend({}, this.options[e]), a = 0; a < r.length - 1; a++)i[r[a]] = i[r[a]] || {}, i = i[r[a]]; if (e = r.pop(), arguments.length === 1) return void 0 === i[e] ? null : i[e]; i[e] = n } else { if (arguments.length === 1) return void 0 === this.options[e] ? null : this.options[e]; o[e] = n } return this._setOptions(o), this }, _setOptions: function (t) { var e; for (e in t) this._setOption(e, t[e]); return this }, _setOption: function (t, e) { return this.options[t] = e, t === 'disabled' && (this.widget().toggleClass(this.widgetFullName + '-disabled', !!e), e && (this.hoverable.removeClass('ui-state-hover'), this.focusable.removeClass('ui-state-focus'))), this }, enable: function () { return this._setOptions({disabled: !1}) }, disable: function () { return this._setOptions({disabled: !0}) }, _on: function (e, n, r) { var i, a = this; typeof e !== 'boolean' && (r = n, n = e, e = !1), r ? (n = i = t(n), this.bindings = this.bindings.add(n)) : (r = n, n = this.element, i = this.widget()), t.each(r, function (r, o) { function u () { return e || a.options.disabled !== !0 && !t(this).hasClass('ui-state-disabled') ? (typeof o === 'string' ? a[o] : o).apply(a, arguments) : void 0 } typeof o !== 'string' && (u.guid = o.guid = o.guid || u.guid || t.guid++); var s = r.match(/^([\w:-]*)\s*(.*)$/), c = s[1] + a.eventNamespace, l = s[2]; l ? i.delegate(l, c, u) : n.bind(c, u) }) }, _off: function (e, n) { n = (n || '').split(' ').join(this.eventNamespace + ' ') + this.eventNamespace, e.unbind(n).undelegate(n), this.bindings = t(this.bindings.not(e).get()), this.focusable = t(this.focusable.not(e).get()), this.hoverable = t(this.hoverable.not(e).get()) }, _delay: function (t, e) { function n () { return (typeof t === 'string' ? r[t] : t).apply(r, arguments) } var r = this; return setTimeout(n, e || 0) }, _hoverable: function (e) { this.hoverable = this.hoverable.add(e), this._on(e, {mouseenter: function (e) { t(e.currentTarget).addClass('ui-state-hover') }, mouseleave: function (e) { t(e.currentTarget).removeClass('ui-state-hover') }}) }, _focusable: function (e) { this.focusable = this.focusable.add(e), this._on(e, {focusin: function (e) { t(e.currentTarget).addClass('ui-state-focus') }, focusout: function (e) { t(e.currentTarget).removeClass('ui-state-focus') }}) }, _trigger: function (e, n, r) { var i, a, o = this.options[e]; if (r = r || {}, n = t.Event(n), n.type = (e === this.widgetEventPrefix ? e : this.widgetEventPrefix + e).toLowerCase(), n.target = this.element[0], a = n.originalEvent) for (i in a)i in n || (n[i] = a[i]); return this.element.trigger(n, r), !(t.isFunction(o) && o.apply(this.element[0], [n].concat(r)) === !1 || n.isDefaultPrevented()) }}, t.each({show: 'fadeIn', hide: 'fadeOut'}, function (e, n) { t.Widget.prototype['_' + e] = function (r, i, a) { typeof i === 'string' && (i = {effect: i}); var o, u = i ? i === !0 || typeof i === 'number' ? n : i.effect || n : e; i = i || {}, typeof i === 'number' && (i = {duration: i}), o = !t.isEmptyObject(i), i.complete = a, i.delay && r.delay(i.delay), o && t.effects && t.effects.effect[u] ? r[e](i) : u !== e && r[u] ? r[u](i.duration, i.easing, a) : r.queue(function (n) { t(this)[e](), a && a.call(r[0]), n() }) } }); t.widget | ||
})), /* jquery Tocify - v1.8.0 - 2013-09-16 | ||
* http://www.gregfranko.com/jquery.tocify.js/ | ||
@@ -40,3 +41,3 @@ * Copyright (c) 2013 Greg Franko; Licensed MIT | ||
* lag spikes below 30 fps */ | ||
function(t){"use strict";t(window.jQuery,window,document)}(function(t,e,n,r){"use strict";var i="tocify",a="tocify-focus",o="tocify-hover",u="tocify-hide",s="tocify-header",c="."+s,l="tocify-subheader",h="."+l,f="tocify-item",d="."+f,p="tocify-extend-page",g="."+p;t.widget("toc.tocify",{version:"1.8.0",options:{context:"body",ignoreSelector:null,selectors:"h1, h2, h3",showAndHide:!0,showEffect:"slideDown",showEffectSpeed:"medium",hideEffect:"slideUp",hideEffectSpeed:"medium",smoothScroll:!0,smoothScrollSpeed:"medium",scrollTo:0,showAndHideOnScroll:!0,highlightOnScroll:!0,highlightOffset:40,theme:"bootstrap",extendPage:!0,extendPageOffset:100,history:!0,scrollHistory:!1,hashGenerator:"compact",highlightDefault:!0},_create:function(){var n=this;n.tocifyWrapper=t(".tocify-wrapper"),n.extendPageScroll=!0,n.items=[],n._generateToc(),n.cachedHeights=[],n.cachedAnchors=[],n._addCSSClasses(),n.webkit=function(){for(var t in e)if(t&&-1!==t.toLowerCase().indexOf("webkit"))return!0;return!1}(),n._setEventHandlers(),t(e).load(function(){n._setActiveElement(!0),t("html, body").promise().done(function(){setTimeout(function(){n.extendPageScroll=!1},0)})})},_generateToc:function(){var e,n,r=this,a=r.options.ignoreSelector;return e=t(this.options.context).find(-1!==this.options.selectors.indexOf(",")?this.options.selectors.replace(/ /g,"").substr(0,this.options.selectors.indexOf(",")):this.options.selectors.replace(/ /g,"")),e.length?(r.element.addClass(i),void e.each(function(e){t(this).is(a)||(n=t("<ul/>",{id:s+e,"class":s}).append(r._nestElements(t(this),e)),r.element.append(n),t(this).nextUntil(this.nodeName.toLowerCase()).each(function(){0===t(this).find(r.options.selectors).length?t(this).filter(r.options.selectors).each(function(){t(this).is(a)||r._appendSubheaders.call(this,r,n)}):t(this).find(r.options.selectors).each(function(){t(this).is(a)||r._appendSubheaders.call(this,r,n)})}))})):void r.element.addClass(u)},_setActiveElement:function(t){var n=this,r=e.location.hash.substring(1),i=n.element.find("li[data-unique='"+r+"']");return r.length?(n.element.find("."+n.focusClass).removeClass(n.focusClass),i.addClass(n.focusClass),n.options.showAndHide&&i.click()):(n.element.find("."+n.focusClass).removeClass(n.focusClass),!r.length&&t&&n.options.highlightDefault&&n.element.find(d).first().addClass(n.focusClass)),n},_nestElements:function(e,n){var r,i,a;return r=t.grep(this.items,function(t){return t===e.text()}),this.items.push(r.length?e.text()+n:e.text()),a=this._generateHashValue(r,e,n),i=t("<li/>",{"class":f,"data-unique":a}).append(t("<a/>",{text:e.text()})),e.before(t("<div/>",{name:a,"data-unique":a})),i},_generateHashValue:function(t,e,n){var r="",i=this.options.hashGenerator;if("pretty"===i){for(r=e.text().toLowerCase().replace(/\s/g,"-"),r=r.replace(/[^\x00-\x7F]/g,"");r.indexOf("--")>-1;)r=r.replace(/--/g,"-");for(;r.indexOf(":-")>-1;)r=r.replace(/:-/g,"-")}else r="function"==typeof i?i(e.text(),e):e.text().replace(/\s/g,"");return t.length&&(r+=""+n),r},_appendSubheaders:function(e,n){var r=t(this).index(e.options.selectors),i=t(e.options.selectors).eq(r-1),a=+t(this).prop("tagName").charAt(1),o=+i.prop("tagName").charAt(1);o>a?e.element.find(h+"[data-tag="+a+"]").last().append(e._nestElements(t(this),r)):a===o?n.find(d).last().after(e._nestElements(t(this),r)):n.find(d).last().after(t("<ul/>",{"class":l,"data-tag":a})).next(h).append(e._nestElements(t(this),r))},_setEventHandlers:function(){var i=this;this.element.on("click.tocify","li",function(){if(i.options.history&&(e.location.hash=t(this).attr("data-unique")),i.element.find("."+i.focusClass).removeClass(i.focusClass),t(this).addClass(i.focusClass),i.options.showAndHide){var n=t('li[data-unique="'+t(this).attr("data-unique")+'"]');i._triggerShow(n)}i._scrollTo(t(this))}),this.element.find("li").on({"mouseenter.tocify":function(){t(this).addClass(i.hoverClass),t(this).css("cursor","pointer")},"mouseleave.tocify":function(){"bootstrap"!==i.options.theme&&t(this).removeClass(i.hoverClass)}}),t(e).on("resize",function(){i.calculateHeights()}),t(e).on("scroll.tocify",function(){t("html, body").promise().done(function(){var a,o,u,s,c=t(e).scrollTop(),l=t(e).height(),h=t(n).height(),f=t("body")[0].scrollHeight;if(i.options.extendPage&&(i.webkit&&c>=f-l-i.options.extendPageOffset||!i.webkit&&l+c>h-i.options.extendPageOffset)&&!t(g).length){if(o=t('div[data-unique="'+t(d).last().attr("data-unique")+'"]'),!o.length)return;u=o.offset().top,t(i.options.context).append(t("<div />",{"class":p,height:Math.abs(u-c)+"px","data-unique":p})),i.extendPageScroll&&(s=i.element.find("li.active"),i._scrollTo(t("div[data-unique="+s.attr("data-unique")+"]")))}setTimeout(function(){var o,u=null;0==i.cachedHeights.length&&i.calculateHeights();var s=t(e).scrollTop();if(i.cachedAnchors.each(function(t){return i.cachedHeights[t]-s<0?void(u=t):!1}),o=t(i.cachedAnchors[u]).attr("data-unique"),a=t('li[data-unique="'+o+'"]'),i.options.highlightOnScroll&&a.length&&!a.hasClass(i.focusClass)){i.element.find("."+i.focusClass).removeClass(i.focusClass),a.addClass(i.focusClass);var c=i.tocifyWrapper,l=t(a).closest(".tocify-header"),h=l.offset().top,f=c.offset().top,d=h-f;if(d>=t(e).height()){var p=d+c.scrollTop();c.scrollTop(p)}else 0>d&&c.scrollTop(0)}i.options.scrollHistory&&e.location.hash!=="#"+o&&o!==r&&(history.replaceState?history.replaceState({},"","#"+o):(scrollV=n.body.scrollTop,scrollH=n.body.scrollLeft,location.hash="#"+o,n.body.scrollTop=scrollV,n.body.scrollLeft=scrollH)),i.options.showAndHideOnScroll&&i.options.showAndHide&&i._triggerShow(a,!0)},0)})})},calculateHeights:function(){var e=this;e.cachedHeights=[],e.cachedAnchors=[];var n=t(e.options.context).find("div[data-unique]");n.each(function(n){var r=(t(this).next().length?t(this).next():t(this)).offset().top-e.options.highlightOffset;e.cachedHeights[n]=r}),e.cachedAnchors=n},show:function(e){var n=this;if(!e.is(":visible"))switch(e.find(h).length||e.parent().is(c)||e.parent().is(":visible")?e.children(h).length||e.parent().is(c)||(e=e.closest(h)):e=e.parents(h).add(e),n.options.showEffect){case"none":e.show();break;case"show":e.show(n.options.showEffectSpeed);break;case"slideDown":e.slideDown(n.options.showEffectSpeed);break;case"fadeIn":e.fadeIn(n.options.showEffectSpeed);break;default:e.show()}return n.hide(t(h).not(e.parent().is(c)?e:e.closest(c).find(h).not(e.siblings()))),n},hide:function(t){var e=this;switch(e.options.hideEffect){case"none":t.hide();break;case"hide":t.hide(e.options.hideEffectSpeed);break;case"slideUp":t.slideUp(e.options.hideEffectSpeed);break;case"fadeOut":t.fadeOut(e.options.hideEffectSpeed);break;default:t.hide()}return e},_triggerShow:function(t,e){var n=this;return t.parent().is(c)||t.next().is(h)?n.show(t.next(h),e):t.parent().is(h)&&n.show(t.parent(),e),n},_addCSSClasses:function(){return"jqueryui"===this.options.theme?(this.focusClass="ui-state-default",this.hoverClass="ui-state-hover",this.element.addClass("ui-widget").find(".toc-title").addClass("ui-widget-header").end().find("li").addClass("ui-widget-content")):"bootstrap"===this.options.theme?(this.element.find(c+","+h).addClass("nav nav-list"),this.focusClass="active"):(this.focusClass=a,this.hoverClass=o),this},setOption:function(){t.Widget.prototype._setOption.apply(this,arguments)},setOptions:function(){t.Widget.prototype._setOptions.apply(this,arguments)},_scrollTo:function(e){var n=this,r=n.options.smoothScroll||0,i=n.options.scrollTo;return t("html, body").promise().done(function(){t("html, body").animate({scrollTop:t('div[data-unique="'+e.attr("data-unique")+'"]').next().offset().top-(t.isFunction(i)?i.call():i)+"px"},{duration:r})}),n}})}),/*! | ||
(function (t) { 'use strict'; t(window.jQuery, window, document) }(function (t, e, n, r) { 'use strict'; var i = 'tocify', a = 'tocify-focus', o = 'tocify-hover', u = 'tocify-hide', s = 'tocify-header', c = '.' + s, l = 'tocify-subheader', h = '.' + l, f = 'tocify-item', d = '.' + f, p = 'tocify-extend-page', g = '.' + p; t.widget('toc.tocify', {version: '1.8.0', options: {context: 'body', ignoreSelector: null, selectors: 'h1, h2, h3', showAndHide: !0, showEffect: 'slideDown', showEffectSpeed: 'medium', hideEffect: 'slideUp', hideEffectSpeed: 'medium', smoothScroll: !0, smoothScrollSpeed: 'medium', scrollTo: 0, showAndHideOnScroll: !0, highlightOnScroll: !0, highlightOffset: 40, theme: 'bootstrap', extendPage: !0, extendPageOffset: 100, history: !0, scrollHistory: !1, hashGenerator: 'compact', highlightDefault: !0}, _create: function () { var n = this; n.tocifyWrapper = t('.tocify-wrapper'), n.extendPageScroll = !0, n.items = [], n._generateToc(), n.cachedHeights = [], n.cachedAnchors = [], n._addCSSClasses(), n.webkit = (function () { for (var t in e) if (t && t.toLowerCase().indexOf('webkit') !== -1) return !0; return !1 }()), n._setEventHandlers(), t(e).load(function () { n._setActiveElement(!0), t('html, body').promise().done(function () { setTimeout(function () { n.extendPageScroll = !1 }, 0) }) }) }, _generateToc: function () { var e, n, r = this, a = r.options.ignoreSelector; return e = t(this.options.context).find(this.options.selectors.indexOf(',') !== -1 ? this.options.selectors.replace(/ /g, '').substr(0, this.options.selectors.indexOf(',')) : this.options.selectors.replace(/ /g, '')), e.length ? (r.element.addClass(i), void e.each(function (e) { t(this).is(a) || (n = t('<ul/>', {id: s + e, 'class': s}).append(r._nestElements(t(this), e)), r.element.append(n), t(this).nextUntil(this.nodeName.toLowerCase()).each(function () { t(this).find(r.options.selectors).length === 0 ? t(this).filter(r.options.selectors).each(function () { t(this).is(a) || r._appendSubheaders.call(this, r, n) }) : t(this).find(r.options.selectors).each(function () { t(this).is(a) || r._appendSubheaders.call(this, r, n) }) })) })) : void r.element.addClass(u) }, _setActiveElement: function (t) { var n = this, r = e.location.hash.substring(1), i = n.element.find("li[data-unique='" + r + "']"); return r.length ? (n.element.find('.' + n.focusClass).removeClass(n.focusClass), i.addClass(n.focusClass), n.options.showAndHide && i.click()) : (n.element.find('.' + n.focusClass).removeClass(n.focusClass), !r.length && t && n.options.highlightDefault && n.element.find(d).first().addClass(n.focusClass)), n }, _nestElements: function (e, n) { var r, i, a; return r = t.grep(this.items, function (t) { return t === e.text() }), this.items.push(r.length ? e.text() + n : e.text()), a = this._generateHashValue(r, e, n), i = t('<li/>', {'class': f, 'data-unique': a}).append(t('<a/>', {text: e.text()})), e.before(t('<div/>', {name: a, 'data-unique': a})), i }, _generateHashValue: function (t, e, n) { var r = '', i = this.options.hashGenerator; if (i === 'pretty') { for (r = e.text().toLowerCase().replace(/\s/g, '-'), r = r.replace(/[^\x00-\x7F]/g, ''); r.indexOf('--') > -1;)r = r.replace(/--/g, '-'); for (;r.indexOf(':-') > -1;)r = r.replace(/:-/g, '-') } else r = typeof i === 'function' ? i(e.text(), e) : e.text().replace(/\s/g, ''); return t.length && (r += '' + n), r }, _appendSubheaders: function (e, n) { var r = t(this).index(e.options.selectors), i = t(e.options.selectors).eq(r - 1), a = +t(this).prop('tagName').charAt(1), o = +i.prop('tagName').charAt(1); o > a ? e.element.find(h + '[data-tag=' + a + ']').last().append(e._nestElements(t(this), r)) : a === o ? n.find(d).last().after(e._nestElements(t(this), r)) : n.find(d).last().after(t('<ul/>', {'class': l, 'data-tag': a})).next(h).append(e._nestElements(t(this), r)) }, _setEventHandlers: function () { var i = this; this.element.on('click.tocify', 'li', function () { if (i.options.history && (e.location.hash = t(this).attr('data-unique')), i.element.find('.' + i.focusClass).removeClass(i.focusClass), t(this).addClass(i.focusClass), i.options.showAndHide) { var n = t('li[data-unique="' + t(this).attr('data-unique') + '"]'); i._triggerShow(n) }i._scrollTo(t(this)) }), this.element.find('li').on({'mouseenter.tocify': function () { t(this).addClass(i.hoverClass), t(this).css('cursor', 'pointer') }, 'mouseleave.tocify': function () { i.options.theme !== 'bootstrap' && t(this).removeClass(i.hoverClass) }}), t(e).on('resize', function () { i.calculateHeights() }), t(e).on('scroll.tocify', function () { t('html, body').promise().done(function () { var a, o, u, s, c = t(e).scrollTop(), l = t(e).height(), h = t(n).height(), f = t('body')[0].scrollHeight; if (i.options.extendPage && (i.webkit && c >= f - l - i.options.extendPageOffset || !i.webkit && l + c > h - i.options.extendPageOffset) && !t(g).length) { if (o = t('div[data-unique="' + t(d).last().attr('data-unique') + '"]'), !o.length) return; u = o.offset().top, t(i.options.context).append(t('<div />', {'class': p, height: Math.abs(u - c) + 'px', 'data-unique': p})), i.extendPageScroll && (s = i.element.find('li.active'), i._scrollTo(t('div[data-unique=' + s.attr('data-unique') + ']'))) }setTimeout(function () { var o, u = null; i.cachedHeights.length == 0 && i.calculateHeights(); var s = t(e).scrollTop(); if (i.cachedAnchors.each(function (t) { return i.cachedHeights[t] - s < 0 ? void (u = t) : !1 }), o = t(i.cachedAnchors[u]).attr('data-unique'), a = t('li[data-unique="' + o + '"]'), i.options.highlightOnScroll && a.length && !a.hasClass(i.focusClass)) { i.element.find('.' + i.focusClass).removeClass(i.focusClass), a.addClass(i.focusClass); var c = i.tocifyWrapper, l = t(a).closest('.tocify-header'), h = l.offset().top, f = c.offset().top, d = h - f; if (d >= t(e).height()) { var p = d + c.scrollTop(); c.scrollTop(p) } else d < 0 && c.scrollTop(0) }i.options.scrollHistory && e.location.hash !== '#' + o && o !== r && (history.replaceState ? history.replaceState({}, '', '#' + o) : (scrollV = n.body.scrollTop, scrollH = n.body.scrollLeft, location.hash = '#' + o, n.body.scrollTop = scrollV, n.body.scrollLeft = scrollH)), i.options.showAndHideOnScroll && i.options.showAndHide && i._triggerShow(a, !0) }, 0) }) }) }, calculateHeights: function () { var e = this; e.cachedHeights = [], e.cachedAnchors = []; var n = t(e.options.context).find('div[data-unique]'); n.each(function (n) { var r = (t(this).next().length ? t(this).next() : t(this)).offset().top - e.options.highlightOffset; e.cachedHeights[n] = r }), e.cachedAnchors = n }, show: function (e) { var n = this; if (!e.is(':visible')) switch (e.find(h).length || e.parent().is(c) || e.parent().is(':visible') ? e.children(h).length || e.parent().is(c) || (e = e.closest(h)) : e = e.parents(h).add(e), n.options.showEffect) { case 'none':e.show(); break; case 'show':e.show(n.options.showEffectSpeed); break; case 'slideDown':e.slideDown(n.options.showEffectSpeed); break; case 'fadeIn':e.fadeIn(n.options.showEffectSpeed); break; default:e.show() } return n.hide(t(h).not(e.parent().is(c) ? e : e.closest(c).find(h).not(e.siblings()))), n }, hide: function (t) { var e = this; switch (e.options.hideEffect) { case 'none':t.hide(); break; case 'hide':t.hide(e.options.hideEffectSpeed); break; case 'slideUp':t.slideUp(e.options.hideEffectSpeed); break; case 'fadeOut':t.fadeOut(e.options.hideEffectSpeed); break; default:t.hide() } return e }, _triggerShow: function (t, e) { var n = this; return t.parent().is(c) || t.next().is(h) ? n.show(t.next(h), e) : t.parent().is(h) && n.show(t.parent(), e), n }, _addCSSClasses: function () { return this.options.theme === 'jqueryui' ? (this.focusClass = 'ui-state-default', this.hoverClass = 'ui-state-hover', this.element.addClass('ui-widget').find('.toc-title').addClass('ui-widget-header').end().find('li').addClass('ui-widget-content')) : this.options.theme === 'bootstrap' ? (this.element.find(c + ',' + h).addClass('nav nav-list'), this.focusClass = 'active') : (this.focusClass = a, this.hoverClass = o), this }, setOption: function () { t.Widget.prototype._setOption.apply(this, arguments) }, setOptions: function () { t.Widget.prototype._setOptions.apply(this, arguments) }, _scrollTo: function (e) { var n = this, r = n.options.smoothScroll || 0, i = n.options.scrollTo; return t('html, body').promise().done(function () { t('html, body').animate({scrollTop: t('div[data-unique="' + e.attr('data-unique') + '"]').next().offset().top - (t.isFunction(i) ? i.call() : i) + 'px'}, {duration: r}) }), n }}) })), /*! | ||
* imagesLoaded PACKAGED v3.1.8 | ||
@@ -46,2 +47,2 @@ * JavaScript is all like "You images are done yet or what?" | ||
*/ | ||
function(){function t(){}function e(t,e){for(var n=t.length;n--;)if(t[n].listener===e)return n;return-1}function n(t){return function(){return this[t].apply(this,arguments)}}var r=t.prototype,i=this,a=i.EventEmitter;r.getListeners=function(t){var e,n,r=this._getEvents();if("object"==typeof t){e={};for(n in r)r.hasOwnProperty(n)&&t.test(n)&&(e[n]=r[n])}else e=r[t]||(r[t]=[]);return e},r.flattenListeners=function(t){var e,n=[];for(e=0;t.length>e;e+=1)n.push(t[e].listener);return n},r.getListenersAsObject=function(t){var e,n=this.getListeners(t);return n instanceof Array&&(e={},e[t]=n),e||n},r.addListener=function(t,n){var r,i=this.getListenersAsObject(t),a="object"==typeof n;for(r in i)i.hasOwnProperty(r)&&-1===e(i[r],n)&&i[r].push(a?n:{listener:n,once:!1});return this},r.on=n("addListener"),r.addOnceListener=function(t,e){return this.addListener(t,{listener:e,once:!0})},r.once=n("addOnceListener"),r.defineEvent=function(t){return this.getListeners(t),this},r.defineEvents=function(t){for(var e=0;t.length>e;e+=1)this.defineEvent(t[e]);return this},r.removeListener=function(t,n){var r,i,a=this.getListenersAsObject(t);for(i in a)a.hasOwnProperty(i)&&(r=e(a[i],n),-1!==r&&a[i].splice(r,1));return this},r.off=n("removeListener"),r.addListeners=function(t,e){return this.manipulateListeners(!1,t,e)},r.removeListeners=function(t,e){return this.manipulateListeners(!0,t,e)},r.manipulateListeners=function(t,e,n){var r,i,a=t?this.removeListener:this.addListener,o=t?this.removeListeners:this.addListeners;if("object"!=typeof e||e instanceof RegExp)for(r=n.length;r--;)a.call(this,e,n[r]);else for(r in e)e.hasOwnProperty(r)&&(i=e[r])&&("function"==typeof i?a.call(this,r,i):o.call(this,r,i));return this},r.removeEvent=function(t){var e,n=typeof t,r=this._getEvents();if("string"===n)delete r[t];else if("object"===n)for(e in r)r.hasOwnProperty(e)&&t.test(e)&&delete r[e];else delete this._events;return this},r.removeAllListeners=n("removeEvent"),r.emitEvent=function(t,e){var n,r,i,a,o=this.getListenersAsObject(t);for(i in o)if(o.hasOwnProperty(i))for(r=o[i].length;r--;)n=o[i][r],n.once===!0&&this.removeListener(t,n.listener),a=n.listener.apply(this,e||[]),a===this._getOnceReturnValue()&&this.removeListener(t,n.listener);return this},r.trigger=n("emitEvent"),r.emit=function(t){var e=Array.prototype.slice.call(arguments,1);return this.emitEvent(t,e)},r.setOnceReturnValue=function(t){return this._onceReturnValue=t,this},r._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},r._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return i.EventEmitter=a,t},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return t}):"object"==typeof module&&module.exports?module.exports=t:this.EventEmitter=t}.call(this),function(t){function e(e){var n=t.event;return n.target=n.target||n.srcElement||e,n}var n=document.documentElement,r=function(){};n.addEventListener?r=function(t,e,n){t.addEventListener(e,n,!1)}:n.attachEvent&&(r=function(t,n,r){t[n+r]=r.handleEvent?function(){var n=e(t);r.handleEvent.call(r,n)}:function(){var n=e(t);r.call(t,n)},t.attachEvent("on"+n,t[n+r])});var i=function(){};n.removeEventListener?i=function(t,e,n){t.removeEventListener(e,n,!1)}:n.detachEvent&&(i=function(t,e,n){t.detachEvent("on"+e,t[e+n]);try{delete t[e+n]}catch(r){t[e+n]=void 0}});var a={bind:r,unbind:i};"function"==typeof define&&define.amd?define("eventie/eventie",a):t.eventie=a}(this),function(t,e){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,r){return e(t,n,r)}):"object"==typeof exports?module.exports=e(t,require("wolfy87-eventemitter"),require("eventie")):t.imagesLoaded=e(t,t.EventEmitter,t.eventie)}(window,function(t,e,n){function r(t,e){for(var n in e)t[n]=e[n];return t}function i(t){return"[object Array]"===f.call(t)}function a(t){var e=[];if(i(t))e=t;else if("number"==typeof t.length)for(var n=0,r=t.length;r>n;n++)e.push(t[n]);else e.push(t);return e}function o(t,e,n){if(!(this instanceof o))return new o(t,e);"string"==typeof t&&(t=document.querySelectorAll(t)),this.elements=a(t),this.options=r({},this.options),"function"==typeof e?n=e:r(this.options,e),n&&this.on("always",n),this.getImages(),c&&(this.jqDeferred=new c.Deferred);var i=this;setTimeout(function(){i.check()})}function u(t){this.img=t}function s(t){this.src=t,d[t]=this}var c=t.jQuery,l=t.console,h=void 0!==l,f=Object.prototype.toString;o.prototype=new e,o.prototype.options={},o.prototype.getImages=function(){this.images=[];for(var t=0,e=this.elements.length;e>t;t++){var n=this.elements[t];"IMG"===n.nodeName&&this.addImage(n);var r=n.nodeType;if(r&&(1===r||9===r||11===r))for(var i=n.querySelectorAll("img"),a=0,o=i.length;o>a;a++){var u=i[a];this.addImage(u)}}},o.prototype.addImage=function(t){var e=new u(t);this.images.push(e)},o.prototype.check=function(){function t(t,i){return e.options.debug&&h&&l.log("confirm",t,i),e.progress(t),n++,n===r&&e.complete(),!0}var e=this,n=0,r=this.images.length;if(this.hasAnyBroken=!1,!r)return void this.complete();for(var i=0;r>i;i++){var a=this.images[i];a.on("confirm",t),a.check()}},o.prototype.progress=function(t){this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded;var e=this;setTimeout(function(){e.emit("progress",e,t),e.jqDeferred&&e.jqDeferred.notify&&e.jqDeferred.notify(e,t)})},o.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var e=this;setTimeout(function(){if(e.emit(t,e),e.emit("always",e),e.jqDeferred){var n=e.hasAnyBroken?"reject":"resolve";e.jqDeferred[n](e)}})},c&&(c.fn.imagesLoaded=function(t,e){var n=new o(this,t,e);return n.jqDeferred.promise(c(this))}),u.prototype=new e,u.prototype.check=function(){var t=d[this.img.src]||new s(this.img.src);if(t.isConfirmed)return void this.confirm(t.isLoaded,"cached was confirmed");if(this.img.complete&&void 0!==this.img.naturalWidth)return void this.confirm(0!==this.img.naturalWidth,"naturalWidth");var e=this;t.on("confirm",function(t,n){return e.confirm(t.isLoaded,n),!0}),t.check()},u.prototype.confirm=function(t,e){this.isLoaded=t,this.emit("confirm",this,e)};var d={};return s.prototype=new e,s.prototype.check=function(){if(!this.isChecked){var t=new Image;n.bind(t,"load",this),n.bind(t,"error",this),t.src=this.src,this.isChecked=!0}},s.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},s.prototype.onload=function(t){this.confirm(!0,"onload"),this.unbindProxyEvents(t)},s.prototype.onerror=function(t){this.confirm(!1,"onerror"),this.unbindProxyEvents(t)},s.prototype.confirm=function(t,e){this.isConfirmed=!0,this.isLoaded=t,this.emit("confirm",this,e)},s.prototype.unbindProxyEvents=function(t){n.unbind(t.target,"load",this),n.unbind(t.target,"error",this)},o}),function(t){"use strict";function e(){setTimeout(function(){toc.setOption("showEffectSpeed",180)},50)}var n=function(){$(".tocify-wrapper").removeClass("open"),$("#nav-button").removeClass("open")},r=function(){t.toc=$("#toc").tocify({selectors:"h1, h2",extendPage:!1,theme:"none",smoothScroll:!1,showEffectSpeed:0,hideEffectSpeed:180,ignoreSelector:".toc-ignore",highlightOffset:60,scrollTo:-1,scrollHistory:!0,hashGenerator:function(t,e){return e.prop("id")}}).data("toc-tocify"),$("#nav-button").click(function(){return $(".tocify-wrapper").toggleClass("open"),$("#nav-button").toggleClass("open"),!1}),$(".page-wrapper").click(n),$(".tocify-item").click(n)};$(function(){r(),e(),$(".content").imagesLoaded(function(){t.toc.calculateHeights()})})}(window); | ||
(function () { function t () {} function e (t, e) { for (var n = t.length; n--;) if (t[n].listener === e) return n; return -1 } function n (t) { return function () { return this[t].apply(this, arguments) } } var r = t.prototype, i = this, a = i.EventEmitter; r.getListeners = function (t) { var e, n, r = this._getEvents(); if (typeof t === 'object') { e = {}; for (n in r)r.hasOwnProperty(n) && t.test(n) && (e[n] = r[n]) } else e = r[t] || (r[t] = []); return e }, r.flattenListeners = function (t) { var e, n = []; for (e = 0; t.length > e; e += 1)n.push(t[e].listener); return n }, r.getListenersAsObject = function (t) { var e, n = this.getListeners(t); return n instanceof Array && (e = {}, e[t] = n), e || n }, r.addListener = function (t, n) { var r, i = this.getListenersAsObject(t), a = typeof n === 'object'; for (r in i)i.hasOwnProperty(r) && e(i[r], n) === -1 && i[r].push(a ? n : {listener: n, once: !1}); return this }, r.on = n('addListener'), r.addOnceListener = function (t, e) { return this.addListener(t, {listener: e, once: !0}) }, r.once = n('addOnceListener'), r.defineEvent = function (t) { return this.getListeners(t), this }, r.defineEvents = function (t) { for (var e = 0; t.length > e; e += 1) this.defineEvent(t[e]); return this }, r.removeListener = function (t, n) { var r, i, a = this.getListenersAsObject(t); for (i in a)a.hasOwnProperty(i) && (r = e(a[i], n), r !== -1 && a[i].splice(r, 1)); return this }, r.off = n('removeListener'), r.addListeners = function (t, e) { return this.manipulateListeners(!1, t, e) }, r.removeListeners = function (t, e) { return this.manipulateListeners(!0, t, e) }, r.manipulateListeners = function (t, e, n) { var r, i, a = t ? this.removeListener : this.addListener, o = t ? this.removeListeners : this.addListeners; if (typeof e !== 'object' || e instanceof RegExp) for (r = n.length; r--;)a.call(this, e, n[r]); else for (r in e)e.hasOwnProperty(r) && (i = e[r]) && (typeof i === 'function' ? a.call(this, r, i) : o.call(this, r, i)); return this }, r.removeEvent = function (t) { var e, n = typeof t, r = this._getEvents(); if (n === 'string') delete r[t]; else if (n === 'object') for (e in r)r.hasOwnProperty(e) && t.test(e) && delete r[e]; else delete this._events; return this }, r.removeAllListeners = n('removeEvent'), r.emitEvent = function (t, e) { var n, r, i, a, o = this.getListenersAsObject(t); for (i in o) if (o.hasOwnProperty(i)) for (r = o[i].length; r--;)n = o[i][r], n.once === !0 && this.removeListener(t, n.listener), a = n.listener.apply(this, e || []), a === this._getOnceReturnValue() && this.removeListener(t, n.listener); return this }, r.trigger = n('emitEvent'), r.emit = function (t) { var e = Array.prototype.slice.call(arguments, 1); return this.emitEvent(t, e) }, r.setOnceReturnValue = function (t) { return this._onceReturnValue = t, this }, r._getOnceReturnValue = function () { return this.hasOwnProperty('_onceReturnValue') ? this._onceReturnValue : !0 }, r._getEvents = function () { return this._events || (this._events = {}) }, t.noConflict = function () { return i.EventEmitter = a, t }, typeof define === 'function' && define.amd ? define('eventEmitter/EventEmitter', [], function () { return t }) : typeof module === 'object' && module.exports ? module.exports = t : this.EventEmitter = t }.call(this)), (function (t) { function e (e) { var n = t.event; return n.target = n.target || n.srcElement || e, n } var n = document.documentElement, r = function () {}; n.addEventListener ? r = function (t, e, n) { t.addEventListener(e, n, !1) } : n.attachEvent && (r = function (t, n, r) { t[n + r] = r.handleEvent ? function () { var n = e(t); r.handleEvent.call(r, n) } : function () { var n = e(t); r.call(t, n) }, t.attachEvent('on' + n, t[n + r]) }); var i = function () {}; n.removeEventListener ? i = function (t, e, n) { t.removeEventListener(e, n, !1) } : n.detachEvent && (i = function (t, e, n) { t.detachEvent('on' + e, t[e + n]); try { delete t[e + n] } catch (r) { t[e + n] = void 0 } }); var a = {bind: r, unbind: i}; typeof define === 'function' && define.amd ? define('eventie/eventie', a) : t.eventie = a }(this)), (function (t, e) { typeof define === 'function' && define.amd ? define(['eventEmitter/EventEmitter', 'eventie/eventie'], function (n, r) { return e(t, n, r) }) : typeof exports === 'object' ? module.exports = e(t, require('wolfy87-eventemitter'), require('eventie')) : t.imagesLoaded = e(t, t.EventEmitter, t.eventie) }(window, function (t, e, n) { function r (t, e) { for (var n in e)t[n] = e[n]; return t } function i (t) { return f.call(t) === '[object Array]' } function a (t) { var e = []; if (i(t))e = t; else if (typeof t.length === 'number') for (var n = 0, r = t.length; r > n; n++)e.push(t[n]); else e.push(t); return e } function o (t, e, n) { if (!(this instanceof o)) return new o(t, e); typeof t === 'string' && (t = document.querySelectorAll(t)), this.elements = a(t), this.options = r({}, this.options), typeof e === 'function' ? n = e : r(this.options, e), n && this.on('always', n), this.getImages(), c && (this.jqDeferred = new c.Deferred()); var i = this; setTimeout(function () { i.check() }) } function u (t) { this.img = t } function s (t) { this.src = t, d[t] = this } var c = t.jQuery, l = t.console, h = void 0 !== l, f = Object.prototype.toString; o.prototype = new e(), o.prototype.options = {}, o.prototype.getImages = function () { this.images = []; for (var t = 0, e = this.elements.length; e > t; t++) { var n = this.elements[t]; n.nodeName === 'IMG' && this.addImage(n); var r = n.nodeType; if (r && (r === 1 || r === 9 || r === 11)) for (var i = n.querySelectorAll('img'), a = 0, o = i.length; o > a; a++) { var u = i[a]; this.addImage(u) } } }, o.prototype.addImage = function (t) { var e = new u(t); this.images.push(e) }, o.prototype.check = function () { function t (t, i) { return e.options.debug && h && l.log('confirm', t, i), e.progress(t), n++, n === r && e.complete(), !0 } var e = this, n = 0, r = this.images.length; if (this.hasAnyBroken = !1, !r) return void this.complete(); for (var i = 0; r > i; i++) { var a = this.images[i]; a.on('confirm', t), a.check() } }, o.prototype.progress = function (t) { this.hasAnyBroken = this.hasAnyBroken || !t.isLoaded; var e = this; setTimeout(function () { e.emit('progress', e, t), e.jqDeferred && e.jqDeferred.notify && e.jqDeferred.notify(e, t) }) }, o.prototype.complete = function () { var t = this.hasAnyBroken ? 'fail' : 'done'; this.isComplete = !0; var e = this; setTimeout(function () { if (e.emit(t, e), e.emit('always', e), e.jqDeferred) { var n = e.hasAnyBroken ? 'reject' : 'resolve'; e.jqDeferred[n](e) } }) }, c && (c.fn.imagesLoaded = function (t, e) { var n = new o(this, t, e); return n.jqDeferred.promise(c(this)) }), u.prototype = new e(), u.prototype.check = function () { var t = d[this.img.src] || new s(this.img.src); if (t.isConfirmed) return void this.confirm(t.isLoaded, 'cached was confirmed'); if (this.img.complete && void 0 !== this.img.naturalWidth) return void this.confirm(this.img.naturalWidth !== 0, 'naturalWidth'); var e = this; t.on('confirm', function (t, n) { return e.confirm(t.isLoaded, n), !0 }), t.check() }, u.prototype.confirm = function (t, e) { this.isLoaded = t, this.emit('confirm', this, e) }; var d = {}; return s.prototype = new e(), s.prototype.check = function () { if (!this.isChecked) { var t = new Image(); n.bind(t, 'load', this), n.bind(t, 'error', this), t.src = this.src, this.isChecked = !0 } }, s.prototype.handleEvent = function (t) { var e = 'on' + t.type; this[e] && this[e](t) }, s.prototype.onload = function (t) { this.confirm(!0, 'onload'), this.unbindProxyEvents(t) }, s.prototype.onerror = function (t) { this.confirm(!1, 'onerror'), this.unbindProxyEvents(t) }, s.prototype.confirm = function (t, e) { this.isConfirmed = !0, this.isLoaded = t, this.emit('confirm', this, e) }, s.prototype.unbindProxyEvents = function (t) { n.unbind(t.target, 'load', this), n.unbind(t.target, 'error', this) }, o })), (function (t) { 'use strict'; function e () { setTimeout(function () { toc.setOption('showEffectSpeed', 180) }, 50) } var n = function () { $('.tocify-wrapper').removeClass('open'), $('#nav-button').removeClass('open') }, r = function () { t.toc = $('#toc').tocify({selectors: 'h1, h2', extendPage: !1, theme: 'none', smoothScroll: !1, showEffectSpeed: 0, hideEffectSpeed: 180, ignoreSelector: '.toc-ignore', highlightOffset: 60, scrollTo: -1, scrollHistory: !0, hashGenerator: function (t, e) { return e.prop('id') }}).data('toc-tocify'), $('#nav-button').click(function () { return $('.tocify-wrapper').toggleClass('open'), $('#nav-button').toggleClass('open'), !1 }), $('.page-wrapper').click(n), $('.tocify-item').click(n) }; $(function () { r(), e(), $('.content').imagesLoaded(function () { t.toc.calculateHeights() }) }) }(window)) |
@@ -1,2 +0,2 @@ | ||
!function(){if("ontouchstart"in window){var t,e,n,r,i,o,a={};t=function(t,e){return Math.abs(t[0]-e[0])>5||Math.abs(t[1]-e[1])>5},e=function(t){this.startXY=[t.touches[0].clientX,t.touches[0].clientY],this.threshold=!1},n=function(e){return this.threshold?!1:void(this.threshold=t(this.startXY,[e.touches[0].clientX,e.touches[0].clientY]))},r=function(e){if(!this.threshold&&!t(this.startXY,[e.changedTouches[0].clientX,e.changedTouches[0].clientY])){var n=e.changedTouches[0],r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,0,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),r.simulated=!0,e.target.dispatchEvent(r)}},i=function(t){var e=Date.now(),n=e-a.time,r=t.clientX,i=t.clientY,s=[Math.abs(a.x-r),Math.abs(a.y-i)],u=o(t.target,"A")||t.target,c=u.nodeName,l="A"===c,h=window.navigator.standalone&&l&&t.target.getAttribute("href");return a.time=e,a.x=r,a.y=i,(!t.simulated&&(500>n||1500>n&&s[0]<50&&s[1]<50)||h)&&(t.preventDefault(),t.stopPropagation(),!h)?!1:(h&&(window.location=u.getAttribute("href")),void(u&&u.classList&&(u.classList.add("energize-focus"),window.setTimeout(function(){u.classList.remove("energize-focus")},150))))},o=function(t,e){for(var n=t;n!==document.body;){if(!n||n.nodeName===e)return n;n=n.parentNode}return null},document.addEventListener("touchstart",e,!1),document.addEventListener("touchmove",n,!1),document.addEventListener("touchend",r,!1),document.addEventListener("click",i,!0)}}(),/* | ||
!(function () { if ('ontouchstart' in window) { var t, e, n, r, i, o, a = {}; t = function (t, e) { return Math.abs(t[0] - e[0]) > 5 || Math.abs(t[1] - e[1]) > 5 }, e = function (t) { this.startXY = [t.touches[0].clientX, t.touches[0].clientY], this.threshold = !1 }, n = function (e) { return this.threshold ? !1 : void (this.threshold = t(this.startXY, [e.touches[0].clientX, e.touches[0].clientY])) }, r = function (e) { if (!this.threshold && !t(this.startXY, [e.changedTouches[0].clientX, e.changedTouches[0].clientY])) { var n = e.changedTouches[0], r = document.createEvent('MouseEvents'); r.initMouseEvent('click', !0, !0, window, 0, n.screenX, n.screenY, n.clientX, n.clientY, !1, !1, !1, !1, 0, null), r.simulated = !0, e.target.dispatchEvent(r) } }, i = function (t) { var e = Date.now(), n = e - a.time, r = t.clientX, i = t.clientY, s = [Math.abs(a.x - r), Math.abs(a.y - i)], u = o(t.target, 'A') || t.target, c = u.nodeName, l = c === 'A', h = window.navigator.standalone && l && t.target.getAttribute('href'); return a.time = e, a.x = r, a.y = i, (!t.simulated && (n < 500 || n < 1500 && s[0] < 50 && s[1] < 50) || h) && (t.preventDefault(), t.stopPropagation(), !h) ? !1 : (h && (window.location = u.getAttribute('href')), void (u && u.classList && (u.classList.add('energize-focus'), window.setTimeout(function () { u.classList.remove('energize-focus') }, 150)))) }, o = function (t, e) { for (var n = t; n !== document.body;) { if (!n || n.nodeName === e) return n; n = n.parentNode } return null }, document.addEventListener('touchstart', e, !1), document.addEventListener('touchmove', n, !1), document.addEventListener('touchend', r, !1), document.addEventListener('click', i, !0) } }()), /* | ||
Copyright 2008-2013 Concur Technologies, Inc. | ||
@@ -16,3 +16,3 @@ | ||
*/ | ||
function(t){"use strict";function e(e){if(e&&""!==e){$(".lang-selector a").removeClass("active"),$(".lang-selector a[data-language-name='"+e+"']").addClass("active");for(var n=0;n<u.length;n++)$(".highlight."+u[n]).hide();$(".highlight."+e).show(),t.toc.calculateHeights(),$(window.location.hash).get(0)&&$(window.location.hash).get(0).scrollIntoView(!0)}}function n(t){return"string"!=typeof t?{}:(t=t.trim().replace(/^(\?|#|&)/,""),t?t.split("&").reduce(function(t,e){var n=e.replace(/\+/g," ").split("="),r=n[0],i=n[1];return r=decodeURIComponent(r),i=void 0===i?null:decodeURIComponent(i),t.hasOwnProperty(r)?Array.isArray(t[r])?t[r].push(i):t[r]=[t[r],i]:t[r]=i,t},{}):{})}function r(t){return t?Object.keys(t).sort().map(function(e){var n=t[e];return Array.isArray(n)?n.sort().map(function(t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}).join("&"):encodeURIComponent(e)+"="+encodeURIComponent(n)}).join("&"):""}function i(){if(location.search.length>=1){var t=n(location.search).language;if(t)return t;if(-1!=jQuery.inArray(location.search.substr(1),u))return location.search.substr(1)}return!1}function o(t){var e=n(location.search);return e.language?(e.language=t,r(e)):t}function a(t){if(history){var e=window.location.hash;e&&(e=e.replace(/^#+/,"")),history.pushState({},"","?"+o(t)+"#"+e),localStorage.setItem("language",t)}}function s(t){var n=localStorage.getItem("language");u=t;var r=i();r?(e(r),localStorage.setItem("language",r)):e(null!==n&&-1!=jQuery.inArray(n,u)?n:u[0])}var u=[];t.setupLanguages=s,t.activateLanguage=e,$(function(){$(".lang-selector a").on("click",function(){var t=$(this).data("language-name");return a(t),e(t),!1}),window.onpopstate=function(){e(i())}})}(window),/** | ||
(function (t) { 'use strict'; function e (e) { if (e && e !== '') { $('.lang-selector a').removeClass('active'), $(".lang-selector a[data-language-name='" + e + "']").addClass('active'); for (var n = 0; n < u.length; n++)$('.highlight.' + u[n]).hide(); $('.highlight.' + e).show(), t.toc.calculateHeights(), $(window.location.hash).get(0) && $(window.location.hash).get(0).scrollIntoView(!0) } } function n (t) { return typeof t !== 'string' ? {} : (t = t.trim().replace(/^(\?|#|&)/, ''), t ? t.split('&').reduce(function (t, e) { var n = e.replace(/\+/g, ' ').split('='), r = n[0], i = n[1]; return r = decodeURIComponent(r), i = void 0 === i ? null : decodeURIComponent(i), t.hasOwnProperty(r) ? Array.isArray(t[r]) ? t[r].push(i) : t[r] = [t[r], i] : t[r] = i, t }, {}) : {}) } function r (t) { return t ? Object.keys(t).sort().map(function (e) { var n = t[e]; return Array.isArray(n) ? n.sort().map(function (t) { return encodeURIComponent(e) + '=' + encodeURIComponent(t) }).join('&') : encodeURIComponent(e) + '=' + encodeURIComponent(n) }).join('&') : '' } function i () { if (location.search.length >= 1) { var t = n(location.search).language; if (t) return t; if (jQuery.inArray(location.search.substr(1), u) != -1) return location.search.substr(1) } return !1 } function o (t) { var e = n(location.search); return e.language ? (e.language = t, r(e)) : t } function a (t) { if (history) { var e = window.location.hash; e && (e = e.replace(/^#+/, '')), history.pushState({}, '', '?' + o(t) + '#' + e), localStorage.setItem('language', t) } } function s (t) { var n = localStorage.getItem('language'); u = t; var r = i(); r ? (e(r), localStorage.setItem('language', r)) : e(n !== null && jQuery.inArray(n, u) != -1 ? n : u[0]) } var u = []; t.setupLanguages = s, t.activateLanguage = e, $(function () { $('.lang-selector a').on('click', function () { var t = $(this).data('language-name'); return a(t), e(t), !1 }), window.onpopstate = function () { e(i()) } }) }(window)), /** | ||
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.5.7 | ||
@@ -23,35 +23,36 @@ * Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
function(){var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.5.7",/*! | ||
(function () { | ||
var t = function (e) { var n = new t.Index(); return n.pipeline.add(t.trimmer, t.stopWordFilter, t.stemmer), e && e.call(n, n), n }; t.version = '0.5.7', /*! | ||
* lunr.utils | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.utils={},t.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),/*! | ||
t.utils = {}, t.utils.warn = (function (t) { return function (e) { t.console && console.warn && console.warn(e) } }(this)), /*! | ||
* lunr.EventEmitter | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");n.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},t.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var n=this.events[t].indexOf(e);this.events[t].splice(n,1),this.events[t].length||delete this.events[t]}},t.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){var e=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void 0,e)})}},t.EventEmitter.prototype.hasHandler=function(t){return t in this.events},/*! | ||
t.EventEmitter = function () { this.events = {} }, t.EventEmitter.prototype.addListener = function () { var t = Array.prototype.slice.call(arguments), e = t.pop(), n = t; if (typeof e !== 'function') throw new TypeError('last argument must be a function'); n.forEach(function (t) { this.hasHandler(t) || (this.events[t] = []), this.events[t].push(e) }, this) }, t.EventEmitter.prototype.removeListener = function (t, e) { if (this.hasHandler(t)) { var n = this.events[t].indexOf(e); this.events[t].splice(n, 1), this.events[t].length || delete this.events[t] } }, t.EventEmitter.prototype.emit = function (t) { if (this.hasHandler(t)) { var e = Array.prototype.slice.call(arguments, 1); this.events[t].forEach(function (t) { t.apply(void 0, e) }) } }, t.EventEmitter.prototype.hasHandler = function (t) { return t in this.events }, /*! | ||
* lunr.tokenizer | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.tokenizer=function(t){if(!arguments.length||null==t||void 0==t)return[];if(Array.isArray(t))return t.map(function(t){return t.toLowerCase()});for(var e=t.toString().replace(/^\s+/,""),n=e.length-1;n>=0;n--)if(/\S/.test(e.charAt(n))){e=e.substring(0,n+1);break}return e.split(/(?:\s+|\-)/).filter(function(t){return!!t}).map(function(t){return t.toLowerCase()})},/*! | ||
t.tokenizer = function (t) { if (!arguments.length || t == null || void 0 == t) return []; if (Array.isArray(t)) return t.map(function (t) { return t.toLowerCase() }); for (var e = t.toString().replace(/^\s+/, ''), n = e.length - 1; n >= 0; n--) if (/\S/.test(e.charAt(n))) { e = e.substring(0, n + 1); break } return e.split(/(?:\s+|\-)/).filter(function (t) { return !!t }).map(function (t) { return t.toLowerCase() }) }, /*! | ||
* lunr.Pipeline | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var r=t.Pipeline.registeredFunctions[e];if(!r)throw new Error("Cannot load un-registered function: "+e);n.add(r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e)+1;this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(t){var e=this._stack.indexOf(t);this._stack.splice(e,1)},t.Pipeline.prototype.run=function(t){for(var e=[],n=t.length,r=this._stack.length,i=0;n>i;i++){for(var o=t[i],a=0;r>a&&(o=this._stack[a](o,i,t),void 0!==o);a++);void 0!==o&&e.push(o)}return e},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},/*! | ||
t.Pipeline = function () { this._stack = [] }, t.Pipeline.registeredFunctions = {}, t.Pipeline.registerFunction = function (e, n) { n in this.registeredFunctions && t.utils.warn('Overwriting existing registered function: ' + n), e.label = n, t.Pipeline.registeredFunctions[e.label] = e }, t.Pipeline.warnIfFunctionNotRegistered = function (e) { var n = e.label && e.label in this.registeredFunctions; n || t.utils.warn('Function is not registered with pipeline. This may cause problems when serialising the index.\n', e) }, t.Pipeline.load = function (e) { var n = new t.Pipeline(); return e.forEach(function (e) { var r = t.Pipeline.registeredFunctions[e]; if (!r) throw new Error('Cannot load un-registered function: ' + e); n.add(r) }), n }, t.Pipeline.prototype.add = function () { var e = Array.prototype.slice.call(arguments); e.forEach(function (e) { t.Pipeline.warnIfFunctionNotRegistered(e), this._stack.push(e) }, this) }, t.Pipeline.prototype.after = function (e, n) { t.Pipeline.warnIfFunctionNotRegistered(n); var r = this._stack.indexOf(e) + 1; this._stack.splice(r, 0, n) }, t.Pipeline.prototype.before = function (e, n) { t.Pipeline.warnIfFunctionNotRegistered(n); var r = this._stack.indexOf(e); this._stack.splice(r, 0, n) }, t.Pipeline.prototype.remove = function (t) { var e = this._stack.indexOf(t); this._stack.splice(e, 1) }, t.Pipeline.prototype.run = function (t) { for (var e = [], n = t.length, r = this._stack.length, i = 0; n > i; i++) { for (var o = t[i], a = 0; r > a && (o = this._stack[a](o, i, t), void 0 !== o); a++);void 0 !== o && e.push(o) } return e }, t.Pipeline.prototype.reset = function () { this._stack = [] }, t.Pipeline.prototype.toJSON = function () { return this._stack.map(function (e) { return t.Pipeline.warnIfFunctionNotRegistered(e), e.label }) }, /*! | ||
* lunr.Vector | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.Vector=function(){this._magnitude=null,this.list=void 0,this.length=0},t.Vector.Node=function(t,e,n){this.idx=t,this.val=e,this.next=n},t.Vector.prototype.insert=function(e,n){var r=this.list;if(!r)return this.list=new t.Vector.Node(e,n,r),this.length++;for(var i=r,o=r.next;void 0!=o;){if(e<o.idx)return i.next=new t.Vector.Node(e,n,o),this.length++;i=o,o=o.next}return i.next=new t.Vector.Node(e,n,o),this.length++},t.Vector.prototype.magnitude=function(){if(this._magniture)return this._magnitude;for(var t,e=this.list,n=0;e;)t=e.val,n+=t*t,e=e.next;return this._magnitude=Math.sqrt(n)},t.Vector.prototype.dot=function(t){for(var e=this.list,n=t.list,r=0;e&&n;)e.idx<n.idx?e=e.next:e.idx>n.idx?n=n.next:(r+=e.val*n.val,e=e.next,n=n.next);return r},t.Vector.prototype.similarity=function(t){return this.dot(t)/(this.magnitude()*t.magnitude())},/*! | ||
t.Vector = function () { this._magnitude = null, this.list = void 0, this.length = 0 }, t.Vector.Node = function (t, e, n) { this.idx = t, this.val = e, this.next = n }, t.Vector.prototype.insert = function (e, n) { var r = this.list; if (!r) return this.list = new t.Vector.Node(e, n, r), this.length++; for (var i = r, o = r.next; void 0 != o;) { if (e < o.idx) return i.next = new t.Vector.Node(e, n, o), this.length++; i = o, o = o.next } return i.next = new t.Vector.Node(e, n, o), this.length++ }, t.Vector.prototype.magnitude = function () { if (this._magniture) return this._magnitude; for (var t, e = this.list, n = 0; e;)t = e.val, n += t * t, e = e.next; return this._magnitude = Math.sqrt(n) }, t.Vector.prototype.dot = function (t) { for (var e = this.list, n = t.list, r = 0; e && n;)e.idx < n.idx ? e = e.next : e.idx > n.idx ? n = n.next : (r += e.val * n.val, e = e.next, n = n.next); return r }, t.Vector.prototype.similarity = function (t) { return this.dot(t) / (this.magnitude() * t.magnitude()) }, /*! | ||
* lunr.SortedSet | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.SortedSet=function(){this.length=0,this.elements=[]},t.SortedSet.load=function(t){var e=new this;return e.elements=t,e.length=t.length,e},t.SortedSet.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(t){~this.indexOf(t)||this.elements.splice(this.locationFor(t),0,t)},this),this.length=this.elements.length},t.SortedSet.prototype.toArray=function(){return this.elements.slice()},t.SortedSet.prototype.map=function(t,e){return this.elements.map(t,e)},t.SortedSet.prototype.forEach=function(t,e){return this.elements.forEach(t,e)},t.SortedSet.prototype.indexOf=function(t,e,n){var e=e||0,n=n||this.elements.length,r=n-e,i=e+Math.floor(r/2),o=this.elements[i];return 1>=r?o===t?i:-1:t>o?this.indexOf(t,i,n):o>t?this.indexOf(t,e,i):o===t?i:void 0},t.SortedSet.prototype.locationFor=function(t,e,n){var e=e||0,n=n||this.elements.length,r=n-e,i=e+Math.floor(r/2),o=this.elements[i];if(1>=r){if(o>t)return i;if(t>o)return i+1}return t>o?this.locationFor(t,i,n):o>t?this.locationFor(t,e,i):void 0},t.SortedSet.prototype.intersect=function(e){for(var n=new t.SortedSet,r=0,i=0,o=this.length,a=e.length,s=this.elements,u=e.elements;;){if(r>o-1||i>a-1)break;s[r]!==u[i]?s[r]<u[i]?r++:s[r]>u[i]&&i++:(n.add(s[r]),r++,i++)}return n},t.SortedSet.prototype.clone=function(){var e=new t.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},t.SortedSet.prototype.union=function(t){var e,n,r;return this.length>=t.length?(e=this,n=t):(e=t,n=this),r=e.clone(),r.add.apply(r,n.toArray()),r},t.SortedSet.prototype.toJSON=function(){return this.toArray()},/*! | ||
t.SortedSet = function () { this.length = 0, this.elements = [] }, t.SortedSet.load = function (t) { var e = new this(); return e.elements = t, e.length = t.length, e }, t.SortedSet.prototype.add = function () { Array.prototype.slice.call(arguments).forEach(function (t) { ~this.indexOf(t) || this.elements.splice(this.locationFor(t), 0, t) }, this), this.length = this.elements.length }, t.SortedSet.prototype.toArray = function () { return this.elements.slice() }, t.SortedSet.prototype.map = function (t, e) { return this.elements.map(t, e) }, t.SortedSet.prototype.forEach = function (t, e) { return this.elements.forEach(t, e) }, t.SortedSet.prototype.indexOf = function (t, e, n) { var e = e || 0, n = n || this.elements.length, r = n - e, i = e + Math.floor(r / 2), o = this.elements[i]; return r <= 1 ? o === t ? i : -1 : t > o ? this.indexOf(t, i, n) : o > t ? this.indexOf(t, e, i) : o === t ? i : void 0 }, t.SortedSet.prototype.locationFor = function (t, e, n) { var e = e || 0, n = n || this.elements.length, r = n - e, i = e + Math.floor(r / 2), o = this.elements[i]; if (r <= 1) { if (o > t) return i; if (t > o) return i + 1 } return t > o ? this.locationFor(t, i, n) : o > t ? this.locationFor(t, e, i) : void 0 }, t.SortedSet.prototype.intersect = function (e) { for (var n = new t.SortedSet(), r = 0, i = 0, o = this.length, a = e.length, s = this.elements, u = e.elements; ;) { if (r > o - 1 || i > a - 1) break; s[r] !== u[i] ? s[r] < u[i] ? r++ : s[r] > u[i] && i++ : (n.add(s[r]), r++, i++) } return n }, t.SortedSet.prototype.clone = function () { var e = new t.SortedSet(); return e.elements = this.toArray(), e.length = e.elements.length, e }, t.SortedSet.prototype.union = function (t) { var e, n, r; return this.length >= t.length ? (e = this, n = t) : (e = t, n = this), r = e.clone(), r.add.apply(r, n.toArray()), r }, t.SortedSet.prototype.toJSON = function () { return this.toArray() }, /*! | ||
* lunr.Index | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.Store,this.tokenStore=new t.TokenStore,this.corpusTokens=new t.SortedSet,this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var t=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,t)},t.Index.prototype.off=function(t,e){return this.eventEmitter.removeListener(t,e)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;return n._fields=e.fields,n._ref=e.ref,n.documentStore=t.Store.load(e.documentStore),n.tokenStore=t.TokenStore.load(e.tokenStore),n.corpusTokens=t.SortedSet.load(e.corpusTokens),n.pipeline=t.Pipeline.load(e.pipeline),n},t.Index.prototype.field=function(t,e){var e=e||{},n={name:t,boost:e.boost||1};return this._fields.push(n),this},t.Index.prototype.ref=function(t){return this._ref=t,this},t.Index.prototype.add=function(e,n){var r={},i=new t.SortedSet,o=e[this._ref],n=void 0===n?!0:n;this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n.name]));r[n.name]=o,t.SortedSet.prototype.add.apply(i,o)},this),this.documentStore.set(o,i),t.SortedSet.prototype.add.apply(this.corpusTokens,i.toArray());for(var a=0;a<i.length;a++){var s=i.elements[a],u=this._fields.reduce(function(t,e){var n=r[e.name].length;if(!n)return t;var i=r[e.name].filter(function(t){return t===s}).length;return t+i/n*e.boost},0);this.tokenStore.add(s,{ref:o,tf:u})}n&&this.eventEmitter.emit("add",e,this)},t.Index.prototype.remove=function(t,e){var n=t[this._ref],e=void 0===e?!0:e;if(this.documentStore.has(n)){var r=this.documentStore.get(n);this.documentStore.remove(n),r.forEach(function(t){this.tokenStore.remove(t,n)},this),e&&this.eventEmitter.emit("remove",t,this)}},t.Index.prototype.update=function(t,e){var e=void 0===e?!0:e;this.remove(t,!1),this.add(t,!1),e&&this.eventEmitter.emit("update",t,this)},t.Index.prototype.idf=function(t){var e="@"+t;if(Object.prototype.hasOwnProperty.call(this._idfCache,e))return this._idfCache[e];var n=this.tokenStore.count(t),r=1;return n>0&&(r=1+Math.log(this.tokenStore.length/n)),this._idfCache[e]=r},t.Index.prototype.search=function(e){var n=this.pipeline.run(t.tokenizer(e)),r=new t.Vector,i=[],o=this._fields.reduce(function(t,e){return t+e.boost},0),a=n.some(function(t){return this.tokenStore.has(t)},this);if(!a)return[];n.forEach(function(e,n,a){var s=1/a.length*this._fields.length*o,u=this,c=this.tokenStore.expand(e).reduce(function(n,i){var o=u.corpusTokens.indexOf(i),a=u.idf(i),c=1,l=new t.SortedSet;if(i!==e){var h=Math.max(3,i.length-e.length);c=1/Math.log(h)}return o>-1&&r.insert(o,s*a*c),Object.keys(u.tokenStore.get(i)).forEach(function(t){l.add(t)}),n.union(l)},new t.SortedSet);i.push(c)},this);var s=i.reduce(function(t,e){return t.intersect(e)});return s.map(function(t){return{ref:t,score:r.similarity(this.documentVector(t))}},this).sort(function(t,e){return e.score-t.score})},t.Index.prototype.documentVector=function(e){for(var n=this.documentStore.get(e),r=n.length,i=new t.Vector,o=0;r>o;o++){var a=n.elements[o],s=this.tokenStore.get(a)[e].tf,u=this.idf(a);i.insert(this.corpusTokens.indexOf(a),s*u)}return i},t.Index.prototype.toJSON=function(){return{version:t.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(t){var e=Array.prototype.slice.call(arguments,1);e.unshift(this),t.apply(this,e)},/*! | ||
t.Index = function () { this._fields = [], this._ref = 'id', this.pipeline = new t.Pipeline(), this.documentStore = new t.Store(), this.tokenStore = new t.TokenStore(), this.corpusTokens = new t.SortedSet(), this.eventEmitter = new t.EventEmitter(), this._idfCache = {}, this.on('add', 'remove', 'update', function () { this._idfCache = {} }.bind(this)) }, t.Index.prototype.on = function () { var t = Array.prototype.slice.call(arguments); return this.eventEmitter.addListener.apply(this.eventEmitter, t) }, t.Index.prototype.off = function (t, e) { return this.eventEmitter.removeListener(t, e) }, t.Index.load = function (e) { e.version !== t.version && t.utils.warn('version mismatch: current ' + t.version + ' importing ' + e.version); var n = new this(); return n._fields = e.fields, n._ref = e.ref, n.documentStore = t.Store.load(e.documentStore), n.tokenStore = t.TokenStore.load(e.tokenStore), n.corpusTokens = t.SortedSet.load(e.corpusTokens), n.pipeline = t.Pipeline.load(e.pipeline), n }, t.Index.prototype.field = function (t, e) { var e = e || {}, n = {name: t, boost: e.boost || 1}; return this._fields.push(n), this }, t.Index.prototype.ref = function (t) { return this._ref = t, this }, t.Index.prototype.add = function (e, n) { var r = {}, i = new t.SortedSet(), o = e[this._ref], n = void 0 === n ? !0 : n; this._fields.forEach(function (n) { var o = this.pipeline.run(t.tokenizer(e[n.name])); r[n.name] = o, t.SortedSet.prototype.add.apply(i, o) }, this), this.documentStore.set(o, i), t.SortedSet.prototype.add.apply(this.corpusTokens, i.toArray()); for (var a = 0; a < i.length; a++) { var s = i.elements[a], u = this._fields.reduce(function (t, e) { var n = r[e.name].length; if (!n) return t; var i = r[e.name].filter(function (t) { return t === s }).length; return t + i / n * e.boost }, 0); this.tokenStore.add(s, {ref: o, tf: u}) }n && this.eventEmitter.emit('add', e, this) }, t.Index.prototype.remove = function (t, e) { var n = t[this._ref], e = void 0 === e ? !0 : e; if (this.documentStore.has(n)) { var r = this.documentStore.get(n); this.documentStore.remove(n), r.forEach(function (t) { this.tokenStore.remove(t, n) }, this), e && this.eventEmitter.emit('remove', t, this) } }, t.Index.prototype.update = function (t, e) { var e = void 0 === e ? !0 : e; this.remove(t, !1), this.add(t, !1), e && this.eventEmitter.emit('update', t, this) }, t.Index.prototype.idf = function (t) { var e = '@' + t; if (Object.prototype.hasOwnProperty.call(this._idfCache, e)) return this._idfCache[e]; var n = this.tokenStore.count(t), r = 1; return n > 0 && (r = 1 + Math.log(this.tokenStore.length / n)), this._idfCache[e] = r }, t.Index.prototype.search = function (e) { var n = this.pipeline.run(t.tokenizer(e)), r = new t.Vector(), i = [], o = this._fields.reduce(function (t, e) { return t + e.boost }, 0), a = n.some(function (t) { return this.tokenStore.has(t) }, this); if (!a) return []; n.forEach(function (e, n, a) { var s = 1 / a.length * this._fields.length * o, u = this, c = this.tokenStore.expand(e).reduce(function (n, i) { var o = u.corpusTokens.indexOf(i), a = u.idf(i), c = 1, l = new t.SortedSet(); if (i !== e) { var h = Math.max(3, i.length - e.length); c = 1 / Math.log(h) } return o > -1 && r.insert(o, s * a * c), Object.keys(u.tokenStore.get(i)).forEach(function (t) { l.add(t) }), n.union(l) }, new t.SortedSet()); i.push(c) }, this); var s = i.reduce(function (t, e) { return t.intersect(e) }); return s.map(function (t) { return {ref: t, score: r.similarity(this.documentVector(t))} }, this).sort(function (t, e) { return e.score - t.score }) }, t.Index.prototype.documentVector = function (e) { for (var n = this.documentStore.get(e), r = n.length, i = new t.Vector(), o = 0; r > o; o++) { var a = n.elements[o], s = this.tokenStore.get(a)[e].tf, u = this.idf(a); i.insert(this.corpusTokens.indexOf(a), s * u) } return i }, t.Index.prototype.toJSON = function () { return {version: t.version, fields: this._fields, ref: this._ref, documentStore: this.documentStore.toJSON(), tokenStore: this.tokenStore.toJSON(), corpusTokens: this.corpusTokens.toJSON(), pipeline: this.pipeline.toJSON()} }, t.Index.prototype.use = function (t) { var e = Array.prototype.slice.call(arguments, 1); e.unshift(this), t.apply(this, e) }, /*! | ||
* lunr.Store | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.Store=function(){this.store={},this.length=0},t.Store.load=function(e){var n=new this;return n.length=e.length,n.store=Object.keys(e.store).reduce(function(n,r){return n[r]=t.SortedSet.load(e.store[r]),n},{}),n},t.Store.prototype.set=function(t,e){this.has(t)||this.length++,this.store[t]=e},t.Store.prototype.get=function(t){return this.store[t]},t.Store.prototype.has=function(t){return t in this.store},t.Store.prototype.remove=function(t){this.has(t)&&(delete this.store[t],this.length--)},t.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},/*! | ||
t.Store = function () { this.store = {}, this.length = 0 }, t.Store.load = function (e) { var n = new this(); return n.length = e.length, n.store = Object.keys(e.store).reduce(function (n, r) { return n[r] = t.SortedSet.load(e.store[r]), n }, {}), n }, t.Store.prototype.set = function (t, e) { this.has(t) || this.length++, this.store[t] = e }, t.Store.prototype.get = function (t) { return this.store[t] }, t.Store.prototype.has = function (t) { return t in this.store }, t.Store.prototype.remove = function (t) { this.has(t) && (delete this.store[t], this.length--) }, t.Store.prototype.toJSON = function () { return {store: this.store, length: this.length} }, /*! | ||
* lunr.stemmer | ||
@@ -61,11 +62,11 @@ * Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.stemmer=function(){var t={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},e={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",r="[aeiouy]",i=n+"[^aeiouy]*",o=r+"[aeiou]*",a="^("+i+")?"+o+i,s="^("+i+")?"+o+i+"("+o+")?$",u="^("+i+")?"+o+i+o+i,c="^("+i+")?"+r,l=new RegExp(a),h=new RegExp(u),f=new RegExp(s),d=new RegExp(c),p=/^(.+?)(ss|i)es$/,g=/^(.+?)([^s])s$/,m=/^(.+?)eed$/,y=/^(.+?)(ed|ing)$/,v=/.$/,b=/(at|bl|iz)$/,_=new RegExp("([^aeiouylsz])\\1$"),x=new RegExp("^"+i+r+"[^aeiouwxy]$"),w=/^(.+?[^aeiou])y$/,E=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,A=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,k=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,D=/^(.+?)(s|t)(ion)$/,S=/^(.+?)e$/,C=/ll$/,M=new RegExp("^"+i+r+"[^aeiouwxy]$"),T=function(n){var r,i,o,a,s,u,c;if(n.length<3)return n;if(o=n.substr(0,1),"y"==o&&(n=o.toUpperCase()+n.substr(1)),a=p,s=g,a.test(n)?n=n.replace(a,"$1$2"):s.test(n)&&(n=n.replace(s,"$1$2")),a=m,s=y,a.test(n)){var T=a.exec(n);a=l,a.test(T[1])&&(a=v,n=n.replace(a,""))}else if(s.test(n)){var T=s.exec(n);r=T[1],s=d,s.test(r)&&(n=r,s=b,u=_,c=x,s.test(n)?n+="e":u.test(n)?(a=v,n=n.replace(a,"")):c.test(n)&&(n+="e"))}if(a=w,a.test(n)){var T=a.exec(n);r=T[1],n=r+"i"}if(a=E,a.test(n)){var T=a.exec(n);r=T[1],i=T[2],a=l,a.test(r)&&(n=r+t[i])}if(a=A,a.test(n)){var T=a.exec(n);r=T[1],i=T[2],a=l,a.test(r)&&(n=r+e[i])}if(a=k,s=D,a.test(n)){var T=a.exec(n);r=T[1],a=h,a.test(r)&&(n=r)}else if(s.test(n)){var T=s.exec(n);r=T[1]+T[2],s=h,s.test(r)&&(n=r)}if(a=S,a.test(n)){var T=a.exec(n);r=T[1],a=h,s=f,u=M,(a.test(r)||s.test(r)&&!u.test(r))&&(n=r)}return a=C,s=h,a.test(n)&&s.test(n)&&(a=v,n=n.replace(a,"")),"y"==o&&(n=o.toLowerCase()+n.substr(1)),n};return T}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),/*! | ||
t.stemmer = (function () { var t = {ational: 'ate', tional: 'tion', enci: 'ence', anci: 'ance', izer: 'ize', bli: 'ble', alli: 'al', entli: 'ent', eli: 'e', ousli: 'ous', ization: 'ize', ation: 'ate', ator: 'ate', alism: 'al', iveness: 'ive', fulness: 'ful', ousness: 'ous', aliti: 'al', iviti: 'ive', biliti: 'ble', logi: 'log'}, e = {icate: 'ic', ative: '', alize: 'al', iciti: 'ic', ical: 'ic', ful: '', ness: ''}, n = '[^aeiou]', r = '[aeiouy]', i = n + '[^aeiouy]*', o = r + '[aeiou]*', a = '^(' + i + ')?' + o + i, s = '^(' + i + ')?' + o + i + '(' + o + ')?$', u = '^(' + i + ')?' + o + i + o + i, c = '^(' + i + ')?' + r, l = new RegExp(a), h = new RegExp(u), f = new RegExp(s), d = new RegExp(c), p = /^(.+?)(ss|i)es$/, g = /^(.+?)([^s])s$/, m = /^(.+?)eed$/, y = /^(.+?)(ed|ing)$/, v = /.$/, b = /(at|bl|iz)$/, _ = new RegExp('([^aeiouylsz])\\1$'), x = new RegExp('^' + i + r + '[^aeiouwxy]$'), w = /^(.+?[^aeiou])y$/, E = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/, A = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/, k = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/, D = /^(.+?)(s|t)(ion)$/, S = /^(.+?)e$/, C = /ll$/, M = new RegExp('^' + i + r + '[^aeiouwxy]$'), T = function (n) { var r, i, o, a, s, u, c; if (n.length < 3) return n; if (o = n.substr(0, 1), o == 'y' && (n = o.toUpperCase() + n.substr(1)), a = p, s = g, a.test(n) ? n = n.replace(a, '$1$2') : s.test(n) && (n = n.replace(s, '$1$2')), a = m, s = y, a.test(n)) { var T = a.exec(n); a = l, a.test(T[1]) && (a = v, n = n.replace(a, '')) } else if (s.test(n)) { var T = s.exec(n); r = T[1], s = d, s.test(r) && (n = r, s = b, u = _, c = x, s.test(n) ? n += 'e' : u.test(n) ? (a = v, n = n.replace(a, '')) : c.test(n) && (n += 'e')) } if (a = w, a.test(n)) { var T = a.exec(n); r = T[1], n = r + 'i' } if (a = E, a.test(n)) { var T = a.exec(n); r = T[1], i = T[2], a = l, a.test(r) && (n = r + t[i]) } if (a = A, a.test(n)) { var T = a.exec(n); r = T[1], i = T[2], a = l, a.test(r) && (n = r + e[i]) } if (a = k, s = D, a.test(n)) { var T = a.exec(n); r = T[1], a = h, a.test(r) && (n = r) } else if (s.test(n)) { var T = s.exec(n); r = T[1] + T[2], s = h, s.test(r) && (n = r) } if (a = S, a.test(n)) { var T = a.exec(n); r = T[1], a = h, s = f, u = M, (a.test(r) || s.test(r) && !u.test(r)) && (n = r) } return a = C, s = h, a.test(n) && s.test(n) && (a = v, n = n.replace(a, '')), o == 'y' && (n = o.toLowerCase() + n.substr(1)), n }; return T }()), t.Pipeline.registerFunction(t.stemmer, 'stemmer'), /*! | ||
* lunr.stopWordFilter | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.stopWordFilter=function(e){return-1===t.stopWordFilter.stopWords.indexOf(e)?e:void 0},t.stopWordFilter.stopWords=new t.SortedSet,t.stopWordFilter.stopWords.length=119,t.stopWordFilter.stopWords.elements=["","a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"],t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),/*! | ||
t.stopWordFilter = function (e) { return t.stopWordFilter.stopWords.indexOf(e) === -1 ? e : void 0 }, t.stopWordFilter.stopWords = new t.SortedSet(), t.stopWordFilter.stopWords.length = 119, t.stopWordFilter.stopWords.elements = ['', 'a', 'able', 'about', 'across', 'after', 'all', 'almost', 'also', 'am', 'among', 'an', 'and', 'any', 'are', 'as', 'at', 'be', 'because', 'been', 'but', 'by', 'can', 'cannot', 'could', 'dear', 'did', 'do', 'does', 'either', 'else', 'ever', 'every', 'for', 'from', 'get', 'got', 'had', 'has', 'have', 'he', 'her', 'hers', 'him', 'his', 'how', 'however', 'i', 'if', 'in', 'into', 'is', 'it', 'its', 'just', 'least', 'let', 'like', 'likely', 'may', 'me', 'might', 'most', 'must', 'my', 'neither', 'no', 'nor', 'not', 'of', 'off', 'often', 'on', 'only', 'or', 'other', 'our', 'own', 'rather', 'said', 'say', 'says', 'she', 'should', 'since', 'so', 'some', 'than', 'that', 'the', 'their', 'them', 'then', 'there', 'these', 'they', 'this', 'tis', 'to', 'too', 'twas', 'us', 'wants', 'was', 'we', 'were', 'what', 'when', 'where', 'which', 'while', 'who', 'whom', 'why', 'will', 'with', 'would', 'yet', 'you', 'your'], t.Pipeline.registerFunction(t.stopWordFilter, 'stopWordFilter'), /*! | ||
* lunr.trimmer | ||
* Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.trimmer=function(t){return t.replace(/^\W+/,"").replace(/\W+$/,"")},t.Pipeline.registerFunction(t.trimmer,"trimmer"),/*! | ||
t.trimmer = function (t) { return t.replace(/^\W+/, '').replace(/\W+$/, '') }, t.Pipeline.registerFunction(t.trimmer, 'trimmer'), /*! | ||
* lunr.stemmer | ||
@@ -75,3 +76,4 @@ * Copyright (C) 2014 Oliver Nightingale | ||
*/ | ||
t.TokenStore=function(){this.root={docs:{}},this.length=0},t.TokenStore.load=function(t){var e=new this;return e.root=t.root,e.length=t.length,e},t.TokenStore.prototype.add=function(t,e,n){var n=n||this.root,r=t[0],i=t.slice(1);return r in n||(n[r]={docs:{}}),0===i.length?(n[r].docs[e.ref]=e,void(this.length+=1)):this.add(i,e,n[r])},t.TokenStore.prototype.has=function(t){if(!t)return!1;for(var e=this.root,n=0;n<t.length;n++){if(!e[t[n]])return!1;e=e[t[n]]}return!0},t.TokenStore.prototype.getNode=function(t){if(!t)return{};for(var e=this.root,n=0;n<t.length;n++){if(!e[t[n]])return{};e=e[t[n]]}return e},t.TokenStore.prototype.get=function(t,e){return this.getNode(t,e).docs||{}},t.TokenStore.prototype.count=function(t,e){return Object.keys(this.get(t,e)).length},t.TokenStore.prototype.remove=function(t,e){if(t){for(var n=this.root,r=0;r<t.length;r++){if(!(t[r]in n))return;n=n[t[r]]}delete n.docs[e]}},t.TokenStore.prototype.expand=function(t,e){var n=this.getNode(t),r=n.docs||{},e=e||[];return Object.keys(r).length&&e.push(t),Object.keys(n).forEach(function(n){"docs"!==n&&e.concat(this.expand(t+n,e))},this),e},t.TokenStore.prototype.toJSON=function(){return{root:this.root,length:this.length}},function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.lunr=e()}(this,function(){return t})}(),/* | ||
t.TokenStore = function () { this.root = {docs: {}}, this.length = 0 }, t.TokenStore.load = function (t) { var e = new this(); return e.root = t.root, e.length = t.length, e }, t.TokenStore.prototype.add = function (t, e, n) { var n = n || this.root, r = t[0], i = t.slice(1); return r in n || (n[r] = {docs: {}}), i.length === 0 ? (n[r].docs[e.ref] = e, void (this.length += 1)) : this.add(i, e, n[r]) }, t.TokenStore.prototype.has = function (t) { if (!t) return !1; for (var e = this.root, n = 0; n < t.length; n++) { if (!e[t[n]]) return !1; e = e[t[n]] } return !0 }, t.TokenStore.prototype.getNode = function (t) { if (!t) return {}; for (var e = this.root, n = 0; n < t.length; n++) { if (!e[t[n]]) return {}; e = e[t[n]] } return e }, t.TokenStore.prototype.get = function (t, e) { return this.getNode(t, e).docs || {} }, t.TokenStore.prototype.count = function (t, e) { return Object.keys(this.get(t, e)).length }, t.TokenStore.prototype.remove = function (t, e) { if (t) { for (var n = this.root, r = 0; r < t.length; r++) { if (!(t[r] in n)) return; n = n[t[r]] } delete n.docs[e] } }, t.TokenStore.prototype.expand = function (t, e) { var n = this.getNode(t), r = n.docs || {}, e = e || []; return Object.keys(r).length && e.push(t), Object.keys(n).forEach(function (n) { n !== 'docs' && e.concat(this.expand(t + n, e)) }, this), e }, t.TokenStore.prototype.toJSON = function () { return {root: this.root, length: this.length} }, (function (t, e) { typeof define === 'function' && define.amd ? define(e) : typeof exports === 'object' ? module.exports = e() : t.lunr = e() }(this, function () { return t })) | ||
}()), /* | ||
* jQuery Highlight plugin | ||
@@ -120,7 +122,7 @@ * | ||
*/ | ||
jQuery.extend({highlight:function(t,e,n,r){if(3===t.nodeType){var i=t.data.match(e);if(i){var o=document.createElement(n||"span");o.className=r||"highlight";var a=t.splitText(i.index);a.splitText(i[0].length);var s=a.cloneNode(!0);return o.appendChild(s),a.parentNode.replaceChild(o,a),1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&(t.tagName!==n.toUpperCase()||t.className!==r))for(var u=0;u<t.childNodes.length;u++)u+=jQuery.highlight(t.childNodes[u],e,n,r);return 0}}),jQuery.fn.unhighlight=function(t){var e={className:"highlight",element:"span"};return jQuery.extend(e,t),this.find(e.element+"."+e.className).each(function(){var t=this.parentNode;t.replaceChild(this.firstChild,this),t.normalize()}).end()},jQuery.fn.highlight=function(t,e){var n={className:"highlight",element:"span",caseSensitive:!1,wordsOnly:!1};if(jQuery.extend(n,e),t.constructor===String&&(t=[t]),t=jQuery.grep(t,function(t){return""!=t}),t=jQuery.map(t,function(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}),0==t.length)return this;var r=n.caseSensitive?"":"i",i="("+t.join("|")+")";n.wordsOnly&&(i="\\b"+i+"\\b");var o=new RegExp(i,r);return this.each(function(){jQuery.highlight(this,o,n.element,n.className)})},function(){"use strict";function t(){$("h1, h2").each(function(){var t=$(this),e=t.nextUntil("h1, h2");u.add({id:t.prop("id"),title:t.text(),body:e.text()})})}function e(){o=$(".content"),a=$(".search-results"),$("#input-search").on("keyup",n)}function n(t){if(i(),a.addClass("visible"),27===t.keyCode&&(this.value=""),this.value){var e=u.search(this.value).filter(function(t){return t.score>1e-4});e.length?(a.empty(),$.each(e,function(t,e){var n=document.getElementById(e.ref);a.append("<li><a href='#"+e.ref+"'>"+$(n).text()+"</a></li>")}),r.call(this)):(a.html("<li></li>"),$(".search-results li").text('No Results Found for "'+this.value+'"'))}else i(),a.removeClass("visible")}function r(){this.value&&o.highlight(this.value,s)}function i(){o.unhighlight(s)}var o,a,s={element:"span",className:"search-highlight"},u=new lunr.Index;u.ref("id"),u.field("title",{boost:10}),u.field("body"),u.pipeline.add(lunr.trimmer,lunr.stopWordFilter),$(t),$(e)}(),/*! jQuery UI - v1.11.3 - 2015-02-12 | ||
jQuery.extend({highlight: function (t, e, n, r) { if (t.nodeType === 3) { var i = t.data.match(e); if (i) { var o = document.createElement(n || 'span'); o.className = r || 'highlight'; var a = t.splitText(i.index); a.splitText(i[0].length); var s = a.cloneNode(!0); return o.appendChild(s), a.parentNode.replaceChild(o, a), 1 } } else if (t.nodeType === 1 && t.childNodes && !/(script|style)/i.test(t.tagName) && (t.tagName !== n.toUpperCase() || t.className !== r)) for (var u = 0; u < t.childNodes.length; u++)u += jQuery.highlight(t.childNodes[u], e, n, r); return 0 }}), jQuery.fn.unhighlight = function (t) { var e = {className: 'highlight', element: 'span'}; return jQuery.extend(e, t), this.find(e.element + '.' + e.className).each(function () { var t = this.parentNode; t.replaceChild(this.firstChild, this), t.normalize() }).end() }, jQuery.fn.highlight = function (t, e) { var n = {className: 'highlight', element: 'span', caseSensitive: !1, wordsOnly: !1}; if (jQuery.extend(n, e), t.constructor === String && (t = [t]), t = jQuery.grep(t, function (t) { return t != '' }), t = jQuery.map(t, function (t) { return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') }), t.length == 0) return this; var r = n.caseSensitive ? '' : 'i', i = '(' + t.join('|') + ')'; n.wordsOnly && (i = '\\b' + i + '\\b'); var o = new RegExp(i, r); return this.each(function () { jQuery.highlight(this, o, n.element, n.className) }) }, (function () { 'use strict'; function t () { $('h1, h2').each(function () { var t = $(this), e = t.nextUntil('h1, h2'); u.add({id: t.prop('id'), title: t.text(), body: e.text()}) }) } function e () { o = $('.content'), a = $('.search-results'), $('#input-search').on('keyup', n) } function n (t) { if (i(), a.addClass('visible'), t.keyCode === 27 && (this.value = ''), this.value) { var e = u.search(this.value).filter(function (t) { return t.score > 1e-4 }); e.length ? (a.empty(), $.each(e, function (t, e) { var n = document.getElementById(e.ref); a.append("<li><a href='#" + e.ref + "'>" + $(n).text() + '</a></li>') }), r.call(this)) : (a.html('<li></li>'), $('.search-results li').text('No Results Found for "' + this.value + '"')) } else i(), a.removeClass('visible') } function r () { this.value && o.highlight(this.value, s) } function i () { o.unhighlight(s) } var o, a, s = {element: 'span', className: 'search-highlight'}, u = new lunr.Index(); u.ref('id'), u.field('title', {boost: 10}), u.field('body'), u.pipeline.add(lunr.trimmer, lunr.stopWordFilter), $(t), $(e) }()), /*! jQuery UI - v1.11.3 - 2015-02-12 | ||
* http://jqueryui.com | ||
* Includes: widget.js | ||
* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ | ||
function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(t){/*! | ||
(function (t) { typeof define === 'function' && define.amd ? define(['jquery'], t) : t(jQuery) }(function (t) { /*! | ||
* jQuery UI Widget 1.11.3 | ||
@@ -135,3 +137,4 @@ * http://jqueryui.com | ||
*/ | ||
var e=0,n=Array.prototype.slice;t.cleanData=function(e){return function(n){var r,i,o;for(o=0;null!=(i=n[o]);o++)try{r=t._data(i,"events"),r&&r.remove&&t(i).triggerHandler("remove")}catch(a){}e(n)}}(t.cleanData),t.widget=function(e,n,r){var i,o,a,s,u={},c=e.split(".")[0];return e=e.split(".")[1],i=c+"-"+e,r||(r=n,n=t.Widget),t.expr[":"][i.toLowerCase()]=function(e){return!!t.data(e,i)},t[c]=t[c]||{},o=t[c][e],a=t[c][e]=function(t,e){return this._createWidget?void(arguments.length&&this._createWidget(t,e)):new a(t,e)},t.extend(a,o,{version:r.version,_proto:t.extend({},r),_childConstructors:[]}),s=new n,s.options=t.widget.extend({},s.options),t.each(r,function(e,r){return t.isFunction(r)?void(u[e]=function(){var t=function(){return n.prototype[e].apply(this,arguments)},i=function(t){return n.prototype[e].apply(this,t)};return function(){var e,n=this._super,o=this._superApply;return this._super=t,this._superApply=i,e=r.apply(this,arguments),this._super=n,this._superApply=o,e}}()):void(u[e]=r)}),a.prototype=t.widget.extend(s,{widgetEventPrefix:o?s.widgetEventPrefix||e:e},u,{constructor:a,namespace:c,widgetName:e,widgetFullName:i}),o?(t.each(o._childConstructors,function(e,n){var r=n.prototype;t.widget(r.namespace+"."+r.widgetName,a,n._proto)}),delete o._childConstructors):n._childConstructors.push(a),t.widget.bridge(e,a),a},t.widget.extend=function(e){for(var r,i,o=n.call(arguments,1),a=0,s=o.length;s>a;a++)for(r in o[a])i=o[a][r],o[a].hasOwnProperty(r)&&void 0!==i&&(e[r]=t.isPlainObject(i)?t.isPlainObject(e[r])?t.widget.extend({},e[r],i):t.widget.extend({},i):i);return e},t.widget.bridge=function(e,r){var i=r.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,s=n.call(arguments,1),u=this;return a?this.each(function(){var n,r=t.data(this,i);return"instance"===o?(u=r,!1):r?t.isFunction(r[o])&&"_"!==o.charAt(0)?(n=r[o].apply(r,s),n!==r&&void 0!==n?(u=n&&n.jquery?u.pushStack(n.get()):n,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; attempted to call method '"+o+"'")}):(s.length&&(o=t.widget.extend.apply(null,[o].concat(s))),this.each(function(){var e=t.data(this,i);e?(e.option(o||{}),e._init&&e._init()):t.data(this,i,new r(o,this))})),u}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(n,r){r=t(r||this.defaultElement||this)[0],this.element=t(r),this.uuid=e++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),r!==this&&(t.data(r,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===r&&this.destroy()}}),this.document=t(r.style?r.ownerDocument:r.document||r),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),n),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(e,n){var r,i,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},r=e.split("."),e=r.shift(),r.length){for(i=a[e]=t.widget.extend({},this.options[e]),o=0;o<r.length-1;o++)i[r[o]]=i[r[o]]||{},i=i[r[o]];if(e=r.pop(),1===arguments.length)return void 0===i[e]?null:i[e];i[e]=n}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=n}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return this.options[t]=e,"disabled"===t&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!e),e&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(e,n,r){var i,o=this;"boolean"!=typeof e&&(r=n,n=e,e=!1),r?(n=i=t(n),this.bindings=this.bindings.add(n)):(r=n,n=this.element,i=this.widget()),t.each(r,function(r,a){function s(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(s.guid=a.guid=a.guid||s.guid||t.guid++);var u=r.match(/^([\w:-]*)\s*(.*)$/),c=u[1]+o.eventNamespace,l=u[2];l?i.delegate(l,c,s):n.bind(c,s)})},_off:function(e,n){n=(n||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(n).undelegate(n),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function n(){return("string"==typeof t?r[t]:t).apply(r,arguments)}var r=this;return setTimeout(n,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){t(e.currentTarget).addClass("ui-state-hover")},mouseleave:function(e){t(e.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){t(e.currentTarget).addClass("ui-state-focus")},focusout:function(e){t(e.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(e,n,r){var i,o,a=this.options[e];if(r=r||{},n=t.Event(n),n.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),n.target=this.element[0],o=n.originalEvent)for(i in o)i in n||(n[i]=o[i]);return this.element.trigger(n,r),!(t.isFunction(a)&&a.apply(this.element[0],[n].concat(r))===!1||n.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,n){t.Widget.prototype["_"+e]=function(r,i,o){"string"==typeof i&&(i={effect:i});var a,s=i?i===!0||"number"==typeof i?n:i.effect||n:e;i=i||{},"number"==typeof i&&(i={duration:i}),a=!t.isEmptyObject(i),i.complete=o,i.delay&&r.delay(i.delay),a&&t.effects&&t.effects.effect[s]?r[e](i):s!==e&&r[s]?r[s](i.duration,i.easing,o):r.queue(function(n){t(this)[e](),o&&o.call(r[0]),n()})}});t.widget}),/* jquery Tocify - v1.8.0 - 2013-09-16 | ||
var e = 0, n = Array.prototype.slice; t.cleanData = (function (e) { return function (n) { var r, i, o; for (o = 0; (i = n[o]) != null; o++) try { r = t._data(i, 'events'), r && r.remove && t(i).triggerHandler('remove') } catch (a) {}e(n) } }(t.cleanData)), t.widget = function (e, n, r) { var i, o, a, s, u = {}, c = e.split('.')[0]; return e = e.split('.')[1], i = c + '-' + e, r || (r = n, n = t.Widget), t.expr[':'][i.toLowerCase()] = function (e) { return !!t.data(e, i) }, t[c] = t[c] || {}, o = t[c][e], a = t[c][e] = function (t, e) { return this._createWidget ? void (arguments.length && this._createWidget(t, e)) : new a(t, e) }, t.extend(a, o, {version: r.version, _proto: t.extend({}, r), _childConstructors: []}), s = new n(), s.options = t.widget.extend({}, s.options), t.each(r, function (e, r) { return t.isFunction(r) ? void (u[e] = (function () { var t = function () { return n.prototype[e].apply(this, arguments) }, i = function (t) { return n.prototype[e].apply(this, t) }; return function () { var e, n = this._super, o = this._superApply; return this._super = t, this._superApply = i, e = r.apply(this, arguments), this._super = n, this._superApply = o, e } }())) : void (u[e] = r) }), a.prototype = t.widget.extend(s, {widgetEventPrefix: o ? s.widgetEventPrefix || e : e}, u, {constructor: a, namespace: c, widgetName: e, widgetFullName: i}), o ? (t.each(o._childConstructors, function (e, n) { var r = n.prototype; t.widget(r.namespace + '.' + r.widgetName, a, n._proto) }), delete o._childConstructors) : n._childConstructors.push(a), t.widget.bridge(e, a), a }, t.widget.extend = function (e) { for (var r, i, o = n.call(arguments, 1), a = 0, s = o.length; s > a; a++) for (r in o[a])i = o[a][r], o[a].hasOwnProperty(r) && void 0 !== i && (e[r] = t.isPlainObject(i) ? t.isPlainObject(e[r]) ? t.widget.extend({}, e[r], i) : t.widget.extend({}, i) : i); return e }, t.widget.bridge = function (e, r) { var i = r.prototype.widgetFullName || e; t.fn[e] = function (o) { var a = typeof o === 'string', s = n.call(arguments, 1), u = this; return a ? this.each(function () { var n, r = t.data(this, i); return o === 'instance' ? (u = r, !1) : r ? t.isFunction(r[o]) && o.charAt(0) !== '_' ? (n = r[o].apply(r, s), n !== r && void 0 !== n ? (u = n && n.jquery ? u.pushStack(n.get()) : n, !1) : void 0) : t.error("no such method '" + o + "' for " + e + ' widget instance') : t.error('cannot call methods on ' + e + " prior to initialization; attempted to call method '" + o + "'") }) : (s.length && (o = t.widget.extend.apply(null, [o].concat(s))), this.each(function () { var e = t.data(this, i); e ? (e.option(o || {}), e._init && e._init()) : t.data(this, i, new r(o, this)) })), u } }, t.Widget = function () {}, t.Widget._childConstructors = [], t.Widget.prototype = {widgetName: 'widget', widgetEventPrefix: '', defaultElement: '<div>', options: {disabled: !1, create: null}, _createWidget: function (n, r) { r = t(r || this.defaultElement || this)[0], this.element = t(r), this.uuid = e++, this.eventNamespace = '.' + this.widgetName + this.uuid, this.bindings = t(), this.hoverable = t(), this.focusable = t(), r !== this && (t.data(r, this.widgetFullName, this), this._on(!0, this.element, {remove: function (t) { t.target === r && this.destroy() }}), this.document = t(r.style ? r.ownerDocument : r.document || r), this.window = t(this.document[0].defaultView || this.document[0].parentWindow)), this.options = t.widget.extend({}, this.options, this._getCreateOptions(), n), this._create(), this._trigger('create', null, this._getCreateEventData()), this._init() }, _getCreateOptions: t.noop, _getCreateEventData: t.noop, _create: t.noop, _init: t.noop, destroy: function () { this._destroy(), this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)), this.widget().unbind(this.eventNamespace).removeAttr('aria-disabled').removeClass(this.widgetFullName + '-disabled ui-state-disabled'), this.bindings.unbind(this.eventNamespace), this.hoverable.removeClass('ui-state-hover'), this.focusable.removeClass('ui-state-focus') }, _destroy: t.noop, widget: function () { return this.element }, option: function (e, n) { var r, i, o, a = e; if (arguments.length === 0) return t.widget.extend({}, this.options); if (typeof e === 'string') if (a = {}, r = e.split('.'), e = r.shift(), r.length) { for (i = a[e] = t.widget.extend({}, this.options[e]), o = 0; o < r.length - 1; o++)i[r[o]] = i[r[o]] || {}, i = i[r[o]]; if (e = r.pop(), arguments.length === 1) return void 0 === i[e] ? null : i[e]; i[e] = n } else { if (arguments.length === 1) return void 0 === this.options[e] ? null : this.options[e]; a[e] = n } return this._setOptions(a), this }, _setOptions: function (t) { var e; for (e in t) this._setOption(e, t[e]); return this }, _setOption: function (t, e) { return this.options[t] = e, t === 'disabled' && (this.widget().toggleClass(this.widgetFullName + '-disabled', !!e), e && (this.hoverable.removeClass('ui-state-hover'), this.focusable.removeClass('ui-state-focus'))), this }, enable: function () { return this._setOptions({disabled: !1}) }, disable: function () { return this._setOptions({disabled: !0}) }, _on: function (e, n, r) { var i, o = this; typeof e !== 'boolean' && (r = n, n = e, e = !1), r ? (n = i = t(n), this.bindings = this.bindings.add(n)) : (r = n, n = this.element, i = this.widget()), t.each(r, function (r, a) { function s () { return e || o.options.disabled !== !0 && !t(this).hasClass('ui-state-disabled') ? (typeof a === 'string' ? o[a] : a).apply(o, arguments) : void 0 } typeof a !== 'string' && (s.guid = a.guid = a.guid || s.guid || t.guid++); var u = r.match(/^([\w:-]*)\s*(.*)$/), c = u[1] + o.eventNamespace, l = u[2]; l ? i.delegate(l, c, s) : n.bind(c, s) }) }, _off: function (e, n) { n = (n || '').split(' ').join(this.eventNamespace + ' ') + this.eventNamespace, e.unbind(n).undelegate(n), this.bindings = t(this.bindings.not(e).get()), this.focusable = t(this.focusable.not(e).get()), this.hoverable = t(this.hoverable.not(e).get()) }, _delay: function (t, e) { function n () { return (typeof t === 'string' ? r[t] : t).apply(r, arguments) } var r = this; return setTimeout(n, e || 0) }, _hoverable: function (e) { this.hoverable = this.hoverable.add(e), this._on(e, {mouseenter: function (e) { t(e.currentTarget).addClass('ui-state-hover') }, mouseleave: function (e) { t(e.currentTarget).removeClass('ui-state-hover') }}) }, _focusable: function (e) { this.focusable = this.focusable.add(e), this._on(e, {focusin: function (e) { t(e.currentTarget).addClass('ui-state-focus') }, focusout: function (e) { t(e.currentTarget).removeClass('ui-state-focus') }}) }, _trigger: function (e, n, r) { var i, o, a = this.options[e]; if (r = r || {}, n = t.Event(n), n.type = (e === this.widgetEventPrefix ? e : this.widgetEventPrefix + e).toLowerCase(), n.target = this.element[0], o = n.originalEvent) for (i in o)i in n || (n[i] = o[i]); return this.element.trigger(n, r), !(t.isFunction(a) && a.apply(this.element[0], [n].concat(r)) === !1 || n.isDefaultPrevented()) }}, t.each({show: 'fadeIn', hide: 'fadeOut'}, function (e, n) { t.Widget.prototype['_' + e] = function (r, i, o) { typeof i === 'string' && (i = {effect: i}); var a, s = i ? i === !0 || typeof i === 'number' ? n : i.effect || n : e; i = i || {}, typeof i === 'number' && (i = {duration: i}), a = !t.isEmptyObject(i), i.complete = o, i.delay && r.delay(i.delay), a && t.effects && t.effects.effect[s] ? r[e](i) : s !== e && r[s] ? r[s](i.duration, i.easing, o) : r.queue(function (n) { t(this)[e](), o && o.call(r[0]), n() }) } }); t.widget | ||
})), /* jquery Tocify - v1.8.0 - 2013-09-16 | ||
* http://www.gregfranko.com/jquery.tocify.js/ | ||
@@ -144,3 +147,3 @@ * Copyright (c) 2013 Greg Franko; Licensed MIT | ||
* lag spikes below 30 fps */ | ||
function(t){"use strict";t(window.jQuery,window,document)}(function(t,e,n,r){"use strict";var i="tocify",o="tocify-focus",a="tocify-hover",s="tocify-hide",u="tocify-header",c="."+u,l="tocify-subheader",h="."+l,f="tocify-item",d="."+f,p="tocify-extend-page",g="."+p;t.widget("toc.tocify",{version:"1.8.0",options:{context:"body",ignoreSelector:null,selectors:"h1, h2, h3",showAndHide:!0,showEffect:"slideDown",showEffectSpeed:"medium",hideEffect:"slideUp",hideEffectSpeed:"medium",smoothScroll:!0,smoothScrollSpeed:"medium",scrollTo:0,showAndHideOnScroll:!0,highlightOnScroll:!0,highlightOffset:40,theme:"bootstrap",extendPage:!0,extendPageOffset:100,history:!0,scrollHistory:!1,hashGenerator:"compact",highlightDefault:!0},_create:function(){var n=this;n.tocifyWrapper=t(".tocify-wrapper"),n.extendPageScroll=!0,n.items=[],n._generateToc(),n.cachedHeights=[],n.cachedAnchors=[],n._addCSSClasses(),n.webkit=function(){for(var t in e)if(t&&-1!==t.toLowerCase().indexOf("webkit"))return!0;return!1}(),n._setEventHandlers(),t(e).load(function(){n._setActiveElement(!0),t("html, body").promise().done(function(){setTimeout(function(){n.extendPageScroll=!1},0)})})},_generateToc:function(){var e,n,r=this,o=r.options.ignoreSelector;return e=t(this.options.context).find(-1!==this.options.selectors.indexOf(",")?this.options.selectors.replace(/ /g,"").substr(0,this.options.selectors.indexOf(",")):this.options.selectors.replace(/ /g,"")),e.length?(r.element.addClass(i),void e.each(function(e){t(this).is(o)||(n=t("<ul/>",{id:u+e,"class":u}).append(r._nestElements(t(this),e)),r.element.append(n),t(this).nextUntil(this.nodeName.toLowerCase()).each(function(){0===t(this).find(r.options.selectors).length?t(this).filter(r.options.selectors).each(function(){t(this).is(o)||r._appendSubheaders.call(this,r,n)}):t(this).find(r.options.selectors).each(function(){t(this).is(o)||r._appendSubheaders.call(this,r,n)})}))})):void r.element.addClass(s)},_setActiveElement:function(t){var n=this,r=e.location.hash.substring(1),i=n.element.find("li[data-unique='"+r+"']");return r.length?(n.element.find("."+n.focusClass).removeClass(n.focusClass),i.addClass(n.focusClass),n.options.showAndHide&&i.click()):(n.element.find("."+n.focusClass).removeClass(n.focusClass),!r.length&&t&&n.options.highlightDefault&&n.element.find(d).first().addClass(n.focusClass)),n},_nestElements:function(e,n){var r,i,o;return r=t.grep(this.items,function(t){return t===e.text()}),this.items.push(r.length?e.text()+n:e.text()),o=this._generateHashValue(r,e,n),i=t("<li/>",{"class":f,"data-unique":o}).append(t("<a/>",{text:e.text()})),e.before(t("<div/>",{name:o,"data-unique":o})),i},_generateHashValue:function(t,e,n){var r="",i=this.options.hashGenerator;if("pretty"===i){for(r=e.text().toLowerCase().replace(/\s/g,"-"),r=r.replace(/[^\x00-\x7F]/g,"");r.indexOf("--")>-1;)r=r.replace(/--/g,"-");for(;r.indexOf(":-")>-1;)r=r.replace(/:-/g,"-")}else r="function"==typeof i?i(e.text(),e):e.text().replace(/\s/g,"");return t.length&&(r+=""+n),r},_appendSubheaders:function(e,n){var r=t(this).index(e.options.selectors),i=t(e.options.selectors).eq(r-1),o=+t(this).prop("tagName").charAt(1),a=+i.prop("tagName").charAt(1);a>o?e.element.find(h+"[data-tag="+o+"]").last().append(e._nestElements(t(this),r)):o===a?n.find(d).last().after(e._nestElements(t(this),r)):n.find(d).last().after(t("<ul/>",{"class":l,"data-tag":o})).next(h).append(e._nestElements(t(this),r))},_setEventHandlers:function(){var i=this;this.element.on("click.tocify","li",function(){if(i.options.history&&(e.location.hash=t(this).attr("data-unique")),i.element.find("."+i.focusClass).removeClass(i.focusClass),t(this).addClass(i.focusClass),i.options.showAndHide){var n=t('li[data-unique="'+t(this).attr("data-unique")+'"]');i._triggerShow(n)}i._scrollTo(t(this))}),this.element.find("li").on({"mouseenter.tocify":function(){t(this).addClass(i.hoverClass),t(this).css("cursor","pointer")},"mouseleave.tocify":function(){"bootstrap"!==i.options.theme&&t(this).removeClass(i.hoverClass)}}),t(e).on("resize",function(){i.calculateHeights()}),t(e).on("scroll.tocify",function(){t("html, body").promise().done(function(){var o,a,s,u,c=t(e).scrollTop(),l=t(e).height(),h=t(n).height(),f=t("body")[0].scrollHeight;if(i.options.extendPage&&(i.webkit&&c>=f-l-i.options.extendPageOffset||!i.webkit&&l+c>h-i.options.extendPageOffset)&&!t(g).length){if(a=t('div[data-unique="'+t(d).last().attr("data-unique")+'"]'),!a.length)return;s=a.offset().top,t(i.options.context).append(t("<div />",{"class":p,height:Math.abs(s-c)+"px","data-unique":p})),i.extendPageScroll&&(u=i.element.find("li.active"),i._scrollTo(t("div[data-unique="+u.attr("data-unique")+"]")))}setTimeout(function(){var a,s=null;0==i.cachedHeights.length&&i.calculateHeights();var u=t(e).scrollTop();if(i.cachedAnchors.each(function(t){return i.cachedHeights[t]-u<0?void(s=t):!1}),a=t(i.cachedAnchors[s]).attr("data-unique"),o=t('li[data-unique="'+a+'"]'),i.options.highlightOnScroll&&o.length&&!o.hasClass(i.focusClass)){i.element.find("."+i.focusClass).removeClass(i.focusClass),o.addClass(i.focusClass);var c=i.tocifyWrapper,l=t(o).closest(".tocify-header"),h=l.offset().top,f=c.offset().top,d=h-f;if(d>=t(e).height()){var p=d+c.scrollTop();c.scrollTop(p)}else 0>d&&c.scrollTop(0)}i.options.scrollHistory&&e.location.hash!=="#"+a&&a!==r&&(history.replaceState?history.replaceState({},"","#"+a):(scrollV=n.body.scrollTop,scrollH=n.body.scrollLeft,location.hash="#"+a,n.body.scrollTop=scrollV,n.body.scrollLeft=scrollH)),i.options.showAndHideOnScroll&&i.options.showAndHide&&i._triggerShow(o,!0)},0)})})},calculateHeights:function(){var e=this;e.cachedHeights=[],e.cachedAnchors=[];var n=t(e.options.context).find("div[data-unique]");n.each(function(n){var r=(t(this).next().length?t(this).next():t(this)).offset().top-e.options.highlightOffset;e.cachedHeights[n]=r}),e.cachedAnchors=n},show:function(e){var n=this;if(!e.is(":visible"))switch(e.find(h).length||e.parent().is(c)||e.parent().is(":visible")?e.children(h).length||e.parent().is(c)||(e=e.closest(h)):e=e.parents(h).add(e),n.options.showEffect){case"none":e.show();break;case"show":e.show(n.options.showEffectSpeed);break;case"slideDown":e.slideDown(n.options.showEffectSpeed);break;case"fadeIn":e.fadeIn(n.options.showEffectSpeed);break;default:e.show()}return n.hide(t(h).not(e.parent().is(c)?e:e.closest(c).find(h).not(e.siblings()))),n},hide:function(t){var e=this;switch(e.options.hideEffect){case"none":t.hide();break;case"hide":t.hide(e.options.hideEffectSpeed);break;case"slideUp":t.slideUp(e.options.hideEffectSpeed);break;case"fadeOut":t.fadeOut(e.options.hideEffectSpeed);break;default:t.hide()}return e},_triggerShow:function(t,e){var n=this;return t.parent().is(c)||t.next().is(h)?n.show(t.next(h),e):t.parent().is(h)&&n.show(t.parent(),e),n},_addCSSClasses:function(){return"jqueryui"===this.options.theme?(this.focusClass="ui-state-default",this.hoverClass="ui-state-hover",this.element.addClass("ui-widget").find(".toc-title").addClass("ui-widget-header").end().find("li").addClass("ui-widget-content")):"bootstrap"===this.options.theme?(this.element.find(c+","+h).addClass("nav nav-list"),this.focusClass="active"):(this.focusClass=o,this.hoverClass=a),this},setOption:function(){t.Widget.prototype._setOption.apply(this,arguments)},setOptions:function(){t.Widget.prototype._setOptions.apply(this,arguments)},_scrollTo:function(e){var n=this,r=n.options.smoothScroll||0,i=n.options.scrollTo;return t("html, body").promise().done(function(){t("html, body").animate({scrollTop:t('div[data-unique="'+e.attr("data-unique")+'"]').next().offset().top-(t.isFunction(i)?i.call():i)+"px"},{duration:r})}),n}})}),/*! | ||
(function (t) { 'use strict'; t(window.jQuery, window, document) }(function (t, e, n, r) { 'use strict'; var i = 'tocify', o = 'tocify-focus', a = 'tocify-hover', s = 'tocify-hide', u = 'tocify-header', c = '.' + u, l = 'tocify-subheader', h = '.' + l, f = 'tocify-item', d = '.' + f, p = 'tocify-extend-page', g = '.' + p; t.widget('toc.tocify', {version: '1.8.0', options: {context: 'body', ignoreSelector: null, selectors: 'h1, h2, h3', showAndHide: !0, showEffect: 'slideDown', showEffectSpeed: 'medium', hideEffect: 'slideUp', hideEffectSpeed: 'medium', smoothScroll: !0, smoothScrollSpeed: 'medium', scrollTo: 0, showAndHideOnScroll: !0, highlightOnScroll: !0, highlightOffset: 40, theme: 'bootstrap', extendPage: !0, extendPageOffset: 100, history: !0, scrollHistory: !1, hashGenerator: 'compact', highlightDefault: !0}, _create: function () { var n = this; n.tocifyWrapper = t('.tocify-wrapper'), n.extendPageScroll = !0, n.items = [], n._generateToc(), n.cachedHeights = [], n.cachedAnchors = [], n._addCSSClasses(), n.webkit = (function () { for (var t in e) if (t && t.toLowerCase().indexOf('webkit') !== -1) return !0; return !1 }()), n._setEventHandlers(), t(e).load(function () { n._setActiveElement(!0), t('html, body').promise().done(function () { setTimeout(function () { n.extendPageScroll = !1 }, 0) }) }) }, _generateToc: function () { var e, n, r = this, o = r.options.ignoreSelector; return e = t(this.options.context).find(this.options.selectors.indexOf(',') !== -1 ? this.options.selectors.replace(/ /g, '').substr(0, this.options.selectors.indexOf(',')) : this.options.selectors.replace(/ /g, '')), e.length ? (r.element.addClass(i), void e.each(function (e) { t(this).is(o) || (n = t('<ul/>', {id: u + e, 'class': u}).append(r._nestElements(t(this), e)), r.element.append(n), t(this).nextUntil(this.nodeName.toLowerCase()).each(function () { t(this).find(r.options.selectors).length === 0 ? t(this).filter(r.options.selectors).each(function () { t(this).is(o) || r._appendSubheaders.call(this, r, n) }) : t(this).find(r.options.selectors).each(function () { t(this).is(o) || r._appendSubheaders.call(this, r, n) }) })) })) : void r.element.addClass(s) }, _setActiveElement: function (t) { var n = this, r = e.location.hash.substring(1), i = n.element.find("li[data-unique='" + r + "']"); return r.length ? (n.element.find('.' + n.focusClass).removeClass(n.focusClass), i.addClass(n.focusClass), n.options.showAndHide && i.click()) : (n.element.find('.' + n.focusClass).removeClass(n.focusClass), !r.length && t && n.options.highlightDefault && n.element.find(d).first().addClass(n.focusClass)), n }, _nestElements: function (e, n) { var r, i, o; return r = t.grep(this.items, function (t) { return t === e.text() }), this.items.push(r.length ? e.text() + n : e.text()), o = this._generateHashValue(r, e, n), i = t('<li/>', {'class': f, 'data-unique': o}).append(t('<a/>', {text: e.text()})), e.before(t('<div/>', {name: o, 'data-unique': o})), i }, _generateHashValue: function (t, e, n) { var r = '', i = this.options.hashGenerator; if (i === 'pretty') { for (r = e.text().toLowerCase().replace(/\s/g, '-'), r = r.replace(/[^\x00-\x7F]/g, ''); r.indexOf('--') > -1;)r = r.replace(/--/g, '-'); for (;r.indexOf(':-') > -1;)r = r.replace(/:-/g, '-') } else r = typeof i === 'function' ? i(e.text(), e) : e.text().replace(/\s/g, ''); return t.length && (r += '' + n), r }, _appendSubheaders: function (e, n) { var r = t(this).index(e.options.selectors), i = t(e.options.selectors).eq(r - 1), o = +t(this).prop('tagName').charAt(1), a = +i.prop('tagName').charAt(1); a > o ? e.element.find(h + '[data-tag=' + o + ']').last().append(e._nestElements(t(this), r)) : o === a ? n.find(d).last().after(e._nestElements(t(this), r)) : n.find(d).last().after(t('<ul/>', {'class': l, 'data-tag': o})).next(h).append(e._nestElements(t(this), r)) }, _setEventHandlers: function () { var i = this; this.element.on('click.tocify', 'li', function () { if (i.options.history && (e.location.hash = t(this).attr('data-unique')), i.element.find('.' + i.focusClass).removeClass(i.focusClass), t(this).addClass(i.focusClass), i.options.showAndHide) { var n = t('li[data-unique="' + t(this).attr('data-unique') + '"]'); i._triggerShow(n) }i._scrollTo(t(this)) }), this.element.find('li').on({'mouseenter.tocify': function () { t(this).addClass(i.hoverClass), t(this).css('cursor', 'pointer') }, 'mouseleave.tocify': function () { i.options.theme !== 'bootstrap' && t(this).removeClass(i.hoverClass) }}), t(e).on('resize', function () { i.calculateHeights() }), t(e).on('scroll.tocify', function () { t('html, body').promise().done(function () { var o, a, s, u, c = t(e).scrollTop(), l = t(e).height(), h = t(n).height(), f = t('body')[0].scrollHeight; if (i.options.extendPage && (i.webkit && c >= f - l - i.options.extendPageOffset || !i.webkit && l + c > h - i.options.extendPageOffset) && !t(g).length) { if (a = t('div[data-unique="' + t(d).last().attr('data-unique') + '"]'), !a.length) return; s = a.offset().top, t(i.options.context).append(t('<div />', {'class': p, height: Math.abs(s - c) + 'px', 'data-unique': p})), i.extendPageScroll && (u = i.element.find('li.active'), i._scrollTo(t('div[data-unique=' + u.attr('data-unique') + ']'))) }setTimeout(function () { var a, s = null; i.cachedHeights.length == 0 && i.calculateHeights(); var u = t(e).scrollTop(); if (i.cachedAnchors.each(function (t) { return i.cachedHeights[t] - u < 0 ? void (s = t) : !1 }), a = t(i.cachedAnchors[s]).attr('data-unique'), o = t('li[data-unique="' + a + '"]'), i.options.highlightOnScroll && o.length && !o.hasClass(i.focusClass)) { i.element.find('.' + i.focusClass).removeClass(i.focusClass), o.addClass(i.focusClass); var c = i.tocifyWrapper, l = t(o).closest('.tocify-header'), h = l.offset().top, f = c.offset().top, d = h - f; if (d >= t(e).height()) { var p = d + c.scrollTop(); c.scrollTop(p) } else d < 0 && c.scrollTop(0) }i.options.scrollHistory && e.location.hash !== '#' + a && a !== r && (history.replaceState ? history.replaceState({}, '', '#' + a) : (scrollV = n.body.scrollTop, scrollH = n.body.scrollLeft, location.hash = '#' + a, n.body.scrollTop = scrollV, n.body.scrollLeft = scrollH)), i.options.showAndHideOnScroll && i.options.showAndHide && i._triggerShow(o, !0) }, 0) }) }) }, calculateHeights: function () { var e = this; e.cachedHeights = [], e.cachedAnchors = []; var n = t(e.options.context).find('div[data-unique]'); n.each(function (n) { var r = (t(this).next().length ? t(this).next() : t(this)).offset().top - e.options.highlightOffset; e.cachedHeights[n] = r }), e.cachedAnchors = n }, show: function (e) { var n = this; if (!e.is(':visible')) switch (e.find(h).length || e.parent().is(c) || e.parent().is(':visible') ? e.children(h).length || e.parent().is(c) || (e = e.closest(h)) : e = e.parents(h).add(e), n.options.showEffect) { case 'none':e.show(); break; case 'show':e.show(n.options.showEffectSpeed); break; case 'slideDown':e.slideDown(n.options.showEffectSpeed); break; case 'fadeIn':e.fadeIn(n.options.showEffectSpeed); break; default:e.show() } return n.hide(t(h).not(e.parent().is(c) ? e : e.closest(c).find(h).not(e.siblings()))), n }, hide: function (t) { var e = this; switch (e.options.hideEffect) { case 'none':t.hide(); break; case 'hide':t.hide(e.options.hideEffectSpeed); break; case 'slideUp':t.slideUp(e.options.hideEffectSpeed); break; case 'fadeOut':t.fadeOut(e.options.hideEffectSpeed); break; default:t.hide() } return e }, _triggerShow: function (t, e) { var n = this; return t.parent().is(c) || t.next().is(h) ? n.show(t.next(h), e) : t.parent().is(h) && n.show(t.parent(), e), n }, _addCSSClasses: function () { return this.options.theme === 'jqueryui' ? (this.focusClass = 'ui-state-default', this.hoverClass = 'ui-state-hover', this.element.addClass('ui-widget').find('.toc-title').addClass('ui-widget-header').end().find('li').addClass('ui-widget-content')) : this.options.theme === 'bootstrap' ? (this.element.find(c + ',' + h).addClass('nav nav-list'), this.focusClass = 'active') : (this.focusClass = o, this.hoverClass = a), this }, setOption: function () { t.Widget.prototype._setOption.apply(this, arguments) }, setOptions: function () { t.Widget.prototype._setOptions.apply(this, arguments) }, _scrollTo: function (e) { var n = this, r = n.options.smoothScroll || 0, i = n.options.scrollTo; return t('html, body').promise().done(function () { t('html, body').animate({scrollTop: t('div[data-unique="' + e.attr('data-unique') + '"]').next().offset().top - (t.isFunction(i) ? i.call() : i) + 'px'}, {duration: r}) }), n }}) })), /*! | ||
* imagesLoaded PACKAGED v3.1.8 | ||
@@ -150,2 +153,2 @@ * JavaScript is all like "You images are done yet or what?" | ||
*/ | ||
function(){function t(){}function e(t,e){for(var n=t.length;n--;)if(t[n].listener===e)return n;return-1}function n(t){return function(){return this[t].apply(this,arguments)}}var r=t.prototype,i=this,o=i.EventEmitter;r.getListeners=function(t){var e,n,r=this._getEvents();if("object"==typeof t){e={};for(n in r)r.hasOwnProperty(n)&&t.test(n)&&(e[n]=r[n])}else e=r[t]||(r[t]=[]);return e},r.flattenListeners=function(t){var e,n=[];for(e=0;t.length>e;e+=1)n.push(t[e].listener);return n},r.getListenersAsObject=function(t){var e,n=this.getListeners(t);return n instanceof Array&&(e={},e[t]=n),e||n},r.addListener=function(t,n){var r,i=this.getListenersAsObject(t),o="object"==typeof n;for(r in i)i.hasOwnProperty(r)&&-1===e(i[r],n)&&i[r].push(o?n:{listener:n,once:!1});return this},r.on=n("addListener"),r.addOnceListener=function(t,e){return this.addListener(t,{listener:e,once:!0})},r.once=n("addOnceListener"),r.defineEvent=function(t){return this.getListeners(t),this},r.defineEvents=function(t){for(var e=0;t.length>e;e+=1)this.defineEvent(t[e]);return this},r.removeListener=function(t,n){var r,i,o=this.getListenersAsObject(t);for(i in o)o.hasOwnProperty(i)&&(r=e(o[i],n),-1!==r&&o[i].splice(r,1));return this},r.off=n("removeListener"),r.addListeners=function(t,e){return this.manipulateListeners(!1,t,e)},r.removeListeners=function(t,e){return this.manipulateListeners(!0,t,e)},r.manipulateListeners=function(t,e,n){var r,i,o=t?this.removeListener:this.addListener,a=t?this.removeListeners:this.addListeners;if("object"!=typeof e||e instanceof RegExp)for(r=n.length;r--;)o.call(this,e,n[r]);else for(r in e)e.hasOwnProperty(r)&&(i=e[r])&&("function"==typeof i?o.call(this,r,i):a.call(this,r,i));return this},r.removeEvent=function(t){var e,n=typeof t,r=this._getEvents();if("string"===n)delete r[t];else if("object"===n)for(e in r)r.hasOwnProperty(e)&&t.test(e)&&delete r[e];else delete this._events;return this},r.removeAllListeners=n("removeEvent"),r.emitEvent=function(t,e){var n,r,i,o,a=this.getListenersAsObject(t);for(i in a)if(a.hasOwnProperty(i))for(r=a[i].length;r--;)n=a[i][r],n.once===!0&&this.removeListener(t,n.listener),o=n.listener.apply(this,e||[]),o===this._getOnceReturnValue()&&this.removeListener(t,n.listener);return this},r.trigger=n("emitEvent"),r.emit=function(t){var e=Array.prototype.slice.call(arguments,1);return this.emitEvent(t,e)},r.setOnceReturnValue=function(t){return this._onceReturnValue=t,this},r._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},r._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return i.EventEmitter=o,t},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return t}):"object"==typeof module&&module.exports?module.exports=t:this.EventEmitter=t}.call(this),function(t){function e(e){var n=t.event;return n.target=n.target||n.srcElement||e,n}var n=document.documentElement,r=function(){};n.addEventListener?r=function(t,e,n){t.addEventListener(e,n,!1)}:n.attachEvent&&(r=function(t,n,r){t[n+r]=r.handleEvent?function(){var n=e(t);r.handleEvent.call(r,n)}:function(){var n=e(t);r.call(t,n)},t.attachEvent("on"+n,t[n+r])});var i=function(){};n.removeEventListener?i=function(t,e,n){t.removeEventListener(e,n,!1)}:n.detachEvent&&(i=function(t,e,n){t.detachEvent("on"+e,t[e+n]);try{delete t[e+n]}catch(r){t[e+n]=void 0}});var o={bind:r,unbind:i};"function"==typeof define&&define.amd?define("eventie/eventie",o):t.eventie=o}(this),function(t,e){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,r){return e(t,n,r)}):"object"==typeof exports?module.exports=e(t,require("wolfy87-eventemitter"),require("eventie")):t.imagesLoaded=e(t,t.EventEmitter,t.eventie)}(window,function(t,e,n){function r(t,e){for(var n in e)t[n]=e[n];return t}function i(t){return"[object Array]"===f.call(t)}function o(t){var e=[];if(i(t))e=t;else if("number"==typeof t.length)for(var n=0,r=t.length;r>n;n++)e.push(t[n]);else e.push(t);return e}function a(t,e,n){if(!(this instanceof a))return new a(t,e);"string"==typeof t&&(t=document.querySelectorAll(t)),this.elements=o(t),this.options=r({},this.options),"function"==typeof e?n=e:r(this.options,e),n&&this.on("always",n),this.getImages(),c&&(this.jqDeferred=new c.Deferred);var i=this;setTimeout(function(){i.check()})}function s(t){this.img=t}function u(t){this.src=t,d[t]=this}var c=t.jQuery,l=t.console,h=void 0!==l,f=Object.prototype.toString;a.prototype=new e,a.prototype.options={},a.prototype.getImages=function(){this.images=[];for(var t=0,e=this.elements.length;e>t;t++){var n=this.elements[t];"IMG"===n.nodeName&&this.addImage(n);var r=n.nodeType;if(r&&(1===r||9===r||11===r))for(var i=n.querySelectorAll("img"),o=0,a=i.length;a>o;o++){var s=i[o];this.addImage(s)}}},a.prototype.addImage=function(t){var e=new s(t);this.images.push(e)},a.prototype.check=function(){function t(t,i){return e.options.debug&&h&&l.log("confirm",t,i),e.progress(t),n++,n===r&&e.complete(),!0}var e=this,n=0,r=this.images.length;if(this.hasAnyBroken=!1,!r)return void this.complete();for(var i=0;r>i;i++){var o=this.images[i];o.on("confirm",t),o.check()}},a.prototype.progress=function(t){this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded;var e=this;setTimeout(function(){e.emit("progress",e,t),e.jqDeferred&&e.jqDeferred.notify&&e.jqDeferred.notify(e,t)})},a.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var e=this;setTimeout(function(){if(e.emit(t,e),e.emit("always",e),e.jqDeferred){var n=e.hasAnyBroken?"reject":"resolve";e.jqDeferred[n](e)}})},c&&(c.fn.imagesLoaded=function(t,e){var n=new a(this,t,e);return n.jqDeferred.promise(c(this))}),s.prototype=new e,s.prototype.check=function(){var t=d[this.img.src]||new u(this.img.src);if(t.isConfirmed)return void this.confirm(t.isLoaded,"cached was confirmed");if(this.img.complete&&void 0!==this.img.naturalWidth)return void this.confirm(0!==this.img.naturalWidth,"naturalWidth");var e=this;t.on("confirm",function(t,n){return e.confirm(t.isLoaded,n),!0}),t.check()},s.prototype.confirm=function(t,e){this.isLoaded=t,this.emit("confirm",this,e)};var d={};return u.prototype=new e,u.prototype.check=function(){if(!this.isChecked){var t=new Image;n.bind(t,"load",this),n.bind(t,"error",this),t.src=this.src,this.isChecked=!0}},u.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},u.prototype.onload=function(t){this.confirm(!0,"onload"),this.unbindProxyEvents(t)},u.prototype.onerror=function(t){this.confirm(!1,"onerror"),this.unbindProxyEvents(t)},u.prototype.confirm=function(t,e){this.isConfirmed=!0,this.isLoaded=t,this.emit("confirm",this,e)},u.prototype.unbindProxyEvents=function(t){n.unbind(t.target,"load",this),n.unbind(t.target,"error",this)},a}),function(t){"use strict";function e(){setTimeout(function(){toc.setOption("showEffectSpeed",180)},50)}var n=function(){$(".tocify-wrapper").removeClass("open"),$("#nav-button").removeClass("open")},r=function(){t.toc=$("#toc").tocify({selectors:"h1, h2",extendPage:!1,theme:"none",smoothScroll:!1,showEffectSpeed:0,hideEffectSpeed:180,ignoreSelector:".toc-ignore",highlightOffset:60,scrollTo:-1,scrollHistory:!0,hashGenerator:function(t,e){return e.prop("id")}}).data("toc-tocify"),$("#nav-button").click(function(){return $(".tocify-wrapper").toggleClass("open"),$("#nav-button").toggleClass("open"),!1}),$(".page-wrapper").click(n),$(".tocify-item").click(n)};$(function(){r(),e(),$(".content").imagesLoaded(function(){t.toc.calculateHeights()})})}(window); | ||
(function () { function t () {} function e (t, e) { for (var n = t.length; n--;) if (t[n].listener === e) return n; return -1 } function n (t) { return function () { return this[t].apply(this, arguments) } } var r = t.prototype, i = this, o = i.EventEmitter; r.getListeners = function (t) { var e, n, r = this._getEvents(); if (typeof t === 'object') { e = {}; for (n in r)r.hasOwnProperty(n) && t.test(n) && (e[n] = r[n]) } else e = r[t] || (r[t] = []); return e }, r.flattenListeners = function (t) { var e, n = []; for (e = 0; t.length > e; e += 1)n.push(t[e].listener); return n }, r.getListenersAsObject = function (t) { var e, n = this.getListeners(t); return n instanceof Array && (e = {}, e[t] = n), e || n }, r.addListener = function (t, n) { var r, i = this.getListenersAsObject(t), o = typeof n === 'object'; for (r in i)i.hasOwnProperty(r) && e(i[r], n) === -1 && i[r].push(o ? n : {listener: n, once: !1}); return this }, r.on = n('addListener'), r.addOnceListener = function (t, e) { return this.addListener(t, {listener: e, once: !0}) }, r.once = n('addOnceListener'), r.defineEvent = function (t) { return this.getListeners(t), this }, r.defineEvents = function (t) { for (var e = 0; t.length > e; e += 1) this.defineEvent(t[e]); return this }, r.removeListener = function (t, n) { var r, i, o = this.getListenersAsObject(t); for (i in o)o.hasOwnProperty(i) && (r = e(o[i], n), r !== -1 && o[i].splice(r, 1)); return this }, r.off = n('removeListener'), r.addListeners = function (t, e) { return this.manipulateListeners(!1, t, e) }, r.removeListeners = function (t, e) { return this.manipulateListeners(!0, t, e) }, r.manipulateListeners = function (t, e, n) { var r, i, o = t ? this.removeListener : this.addListener, a = t ? this.removeListeners : this.addListeners; if (typeof e !== 'object' || e instanceof RegExp) for (r = n.length; r--;)o.call(this, e, n[r]); else for (r in e)e.hasOwnProperty(r) && (i = e[r]) && (typeof i === 'function' ? o.call(this, r, i) : a.call(this, r, i)); return this }, r.removeEvent = function (t) { var e, n = typeof t, r = this._getEvents(); if (n === 'string') delete r[t]; else if (n === 'object') for (e in r)r.hasOwnProperty(e) && t.test(e) && delete r[e]; else delete this._events; return this }, r.removeAllListeners = n('removeEvent'), r.emitEvent = function (t, e) { var n, r, i, o, a = this.getListenersAsObject(t); for (i in a) if (a.hasOwnProperty(i)) for (r = a[i].length; r--;)n = a[i][r], n.once === !0 && this.removeListener(t, n.listener), o = n.listener.apply(this, e || []), o === this._getOnceReturnValue() && this.removeListener(t, n.listener); return this }, r.trigger = n('emitEvent'), r.emit = function (t) { var e = Array.prototype.slice.call(arguments, 1); return this.emitEvent(t, e) }, r.setOnceReturnValue = function (t) { return this._onceReturnValue = t, this }, r._getOnceReturnValue = function () { return this.hasOwnProperty('_onceReturnValue') ? this._onceReturnValue : !0 }, r._getEvents = function () { return this._events || (this._events = {}) }, t.noConflict = function () { return i.EventEmitter = o, t }, typeof define === 'function' && define.amd ? define('eventEmitter/EventEmitter', [], function () { return t }) : typeof module === 'object' && module.exports ? module.exports = t : this.EventEmitter = t }.call(this)), (function (t) { function e (e) { var n = t.event; return n.target = n.target || n.srcElement || e, n } var n = document.documentElement, r = function () {}; n.addEventListener ? r = function (t, e, n) { t.addEventListener(e, n, !1) } : n.attachEvent && (r = function (t, n, r) { t[n + r] = r.handleEvent ? function () { var n = e(t); r.handleEvent.call(r, n) } : function () { var n = e(t); r.call(t, n) }, t.attachEvent('on' + n, t[n + r]) }); var i = function () {}; n.removeEventListener ? i = function (t, e, n) { t.removeEventListener(e, n, !1) } : n.detachEvent && (i = function (t, e, n) { t.detachEvent('on' + e, t[e + n]); try { delete t[e + n] } catch (r) { t[e + n] = void 0 } }); var o = {bind: r, unbind: i}; typeof define === 'function' && define.amd ? define('eventie/eventie', o) : t.eventie = o }(this)), (function (t, e) { typeof define === 'function' && define.amd ? define(['eventEmitter/EventEmitter', 'eventie/eventie'], function (n, r) { return e(t, n, r) }) : typeof exports === 'object' ? module.exports = e(t, require('wolfy87-eventemitter'), require('eventie')) : t.imagesLoaded = e(t, t.EventEmitter, t.eventie) }(window, function (t, e, n) { function r (t, e) { for (var n in e)t[n] = e[n]; return t } function i (t) { return f.call(t) === '[object Array]' } function o (t) { var e = []; if (i(t))e = t; else if (typeof t.length === 'number') for (var n = 0, r = t.length; r > n; n++)e.push(t[n]); else e.push(t); return e } function a (t, e, n) { if (!(this instanceof a)) return new a(t, e); typeof t === 'string' && (t = document.querySelectorAll(t)), this.elements = o(t), this.options = r({}, this.options), typeof e === 'function' ? n = e : r(this.options, e), n && this.on('always', n), this.getImages(), c && (this.jqDeferred = new c.Deferred()); var i = this; setTimeout(function () { i.check() }) } function s (t) { this.img = t } function u (t) { this.src = t, d[t] = this } var c = t.jQuery, l = t.console, h = void 0 !== l, f = Object.prototype.toString; a.prototype = new e(), a.prototype.options = {}, a.prototype.getImages = function () { this.images = []; for (var t = 0, e = this.elements.length; e > t; t++) { var n = this.elements[t]; n.nodeName === 'IMG' && this.addImage(n); var r = n.nodeType; if (r && (r === 1 || r === 9 || r === 11)) for (var i = n.querySelectorAll('img'), o = 0, a = i.length; a > o; o++) { var s = i[o]; this.addImage(s) } } }, a.prototype.addImage = function (t) { var e = new s(t); this.images.push(e) }, a.prototype.check = function () { function t (t, i) { return e.options.debug && h && l.log('confirm', t, i), e.progress(t), n++, n === r && e.complete(), !0 } var e = this, n = 0, r = this.images.length; if (this.hasAnyBroken = !1, !r) return void this.complete(); for (var i = 0; r > i; i++) { var o = this.images[i]; o.on('confirm', t), o.check() } }, a.prototype.progress = function (t) { this.hasAnyBroken = this.hasAnyBroken || !t.isLoaded; var e = this; setTimeout(function () { e.emit('progress', e, t), e.jqDeferred && e.jqDeferred.notify && e.jqDeferred.notify(e, t) }) }, a.prototype.complete = function () { var t = this.hasAnyBroken ? 'fail' : 'done'; this.isComplete = !0; var e = this; setTimeout(function () { if (e.emit(t, e), e.emit('always', e), e.jqDeferred) { var n = e.hasAnyBroken ? 'reject' : 'resolve'; e.jqDeferred[n](e) } }) }, c && (c.fn.imagesLoaded = function (t, e) { var n = new a(this, t, e); return n.jqDeferred.promise(c(this)) }), s.prototype = new e(), s.prototype.check = function () { var t = d[this.img.src] || new u(this.img.src); if (t.isConfirmed) return void this.confirm(t.isLoaded, 'cached was confirmed'); if (this.img.complete && void 0 !== this.img.naturalWidth) return void this.confirm(this.img.naturalWidth !== 0, 'naturalWidth'); var e = this; t.on('confirm', function (t, n) { return e.confirm(t.isLoaded, n), !0 }), t.check() }, s.prototype.confirm = function (t, e) { this.isLoaded = t, this.emit('confirm', this, e) }; var d = {}; return u.prototype = new e(), u.prototype.check = function () { if (!this.isChecked) { var t = new Image(); n.bind(t, 'load', this), n.bind(t, 'error', this), t.src = this.src, this.isChecked = !0 } }, u.prototype.handleEvent = function (t) { var e = 'on' + t.type; this[e] && this[e](t) }, u.prototype.onload = function (t) { this.confirm(!0, 'onload'), this.unbindProxyEvents(t) }, u.prototype.onerror = function (t) { this.confirm(!1, 'onerror'), this.unbindProxyEvents(t) }, u.prototype.confirm = function (t, e) { this.isConfirmed = !0, this.isLoaded = t, this.emit('confirm', this, e) }, u.prototype.unbindProxyEvents = function (t) { n.unbind(t.target, 'load', this), n.unbind(t.target, 'error', this) }, a })), (function (t) { 'use strict'; function e () { setTimeout(function () { toc.setOption('showEffectSpeed', 180) }, 50) } var n = function () { $('.tocify-wrapper').removeClass('open'), $('#nav-button').removeClass('open') }, r = function () { t.toc = $('#toc').tocify({selectors: 'h1, h2', extendPage: !1, theme: 'none', smoothScroll: !1, showEffectSpeed: 0, hideEffectSpeed: 180, ignoreSelector: '.toc-ignore', highlightOffset: 60, scrollTo: -1, scrollHistory: !0, hashGenerator: function (t, e) { return e.prop('id') }}).data('toc-tocify'), $('#nav-button').click(function () { return $('.tocify-wrapper').toggleClass('open'), $('#nav-button').toggleClass('open'), !1 }), $('.page-wrapper').click(n), $('.tocify-item').click(n) }; $(function () { r(), e(), $('.content').imagesLoaded(function () { t.toc.calculateHeights() }) }) }(window)) |
/**/ | ||
!function(e){"undefined"!=typeof exports?e(exports):(window.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return window.hljs}))}(function(e){function n(e){return e.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0==t.index}function a(e){var n=(e.className+" "+(e.parentNode?e.parentNode.className:"")).split(/\s+/);return n=n.map(function(e){return e.replace(/^lang(uage)?-/,"")}),n.filter(function(e){return N(e)||/no(-?)highlight/.test(e)})[0]}function o(e,n){var t={};for(var r in e)t[r]=e[r];if(n)for(var r in n)t[r]=n[r];return t}function i(e){var n=[];return function r(e,a){for(var o=e.firstChild;o;o=o.nextSibling)3==o.nodeType?a+=o.nodeValue.length:1==o.nodeType&&(n.push({event:"start",offset:a,node:o}),a=r(o,a),t(o).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:o}));return a}(e,0),n}function c(e,r,a){function o(){return e.length&&r.length?e[0].offset!=r[0].offset?e[0].offset<r[0].offset?e:r:"start"==r[0].event?e:r:e.length?e:r}function i(e){function r(e){return" "+e.nodeName+'="'+n(e.value)+'"'}l+="<"+t(e)+Array.prototype.map.call(e.attributes,r).join("")+">"}function c(e){l+="</"+t(e)+">"}function u(e){("start"==e.event?i:c)(e.node)}for(var s=0,l="",f=[];e.length||r.length;){var g=o();if(l+=n(a.substr(s,g[0].offset-s)),s=g[0].offset,g==e){f.reverse().forEach(c);do u(g.splice(0,1)[0]),g=o();while(g==e&&g.length&&g[0].offset==s);f.reverse().forEach(i)}else"start"==g[0].event?f.push(g[0].node):f.pop(),u(g.splice(0,1)[0])}return l+n(a.substr(s))}function u(e){function n(e){return e&&e.source||e}function t(t,r){return RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var c={},u=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");c[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?u("keyword",a.k):Object.keys(a.k).forEach(function(e){u(e,a.k[e])}),a.k=c}a.lR=t(a.l||/\b[A-Za-z0-9_]+\b/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),void 0===a.r&&(a.r=1),a.c||(a.c=[]);var s=[];a.c.forEach(function(e){e.v?e.v.forEach(function(n){s.push(o(e,n))}):s.push("self"==e?a:e)}),a.c=s,a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var l=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=l.length?t(l.join("|"),!0):{exec:function(){return null}}}}r(e)}function s(e,t,a,o){function i(e,n){for(var t=0;t<n.c.length;t++)if(r(n.c[t].bR,e))return n.c[t]}function c(e,n){return r(e.eR,n)?e:e.eW?c(e.parent,n):void 0}function f(e,n){return!a&&r(n.iR,e)}function g(e,n){var t=x.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function p(e,n,t,r){var a=r?"":E.classPrefix,o='<span class="'+a,i=t?"":"</span>";return o+=e+'">',o+n+i}function d(){if(!w.k)return n(y);var e="",t=0;w.lR.lastIndex=0;for(var r=w.lR.exec(y);r;){e+=n(y.substr(t,r.index-t));var a=g(w,r);a?(B+=a[1],e+=p(a[0],n(r[0]))):e+=n(r[0]),t=w.lR.lastIndex,r=w.lR.exec(y)}return e+n(y.substr(t))}function h(){if(w.sL&&!R[w.sL])return n(y);var e=w.sL?s(w.sL,y,!0,L[w.sL]):l(y);return w.r>0&&(B+=e.r),"continuous"==w.subLanguageMode&&(L[w.sL]=e.top),p(e.language,e.value,!1,!0)}function v(){return void 0!==w.sL?h():d()}function b(e,t){var r=e.cN?p(e.cN,"",!0):"";e.rB?(M+=r,y=""):e.eB?(M+=n(t)+r,y=""):(M+=r,y=t),w=Object.create(e,{parent:{value:w}})}function m(e,t){if(y+=e,void 0===t)return M+=v(),0;var r=i(t,w);if(r)return M+=v(),b(r,t),r.rB?0:t.length;var a=c(w,t);if(a){var o=w;o.rE||o.eE||(y+=t),M+=v();do w.cN&&(M+="</span>"),B+=w.r,w=w.parent;while(w!=a.parent);return o.eE&&(M+=n(t)),y="",a.starts&&b(a.starts,""),o.rE?0:t.length}if(f(t,w))throw new Error('Illegal lexeme "'+t+'" for mode "'+(w.cN||"<unnamed>")+'"');return y+=t,t.length||1}var x=N(e);if(!x)throw new Error('Unknown language: "'+e+'"');u(x);for(var w=o||x,L={},M="",k=w;k!=x;k=k.parent)k.cN&&(M=p(k.cN,"",!0)+M);var y="",B=0;try{for(var C,j,I=0;;){if(w.t.lastIndex=I,C=w.t.exec(t),!C)break;j=m(t.substr(I,C.index-I),C[0]),I=C.index+j}m(t.substr(I));for(var k=w;k.parent;k=k.parent)k.cN&&(M+="</span>");return{r:B,value:M,language:e,top:w}}catch(A){if(-1!=A.message.indexOf("Illegal"))return{r:0,value:n(t)};throw A}}function l(e,t){t=t||E.languages||Object.keys(R);var r={r:0,value:n(e)},a=r;return t.forEach(function(n){if(N(n)){var t=s(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}}),a.language&&(r.second_best=a),r}function f(e){return E.tabReplace&&(e=e.replace(/^((<[^>]+>|\t)+)/gm,function(e,n){return n.replace(/\t/g,E.tabReplace)})),E.useBR&&(e=e.replace(/\n/g,"<br>")),e}function g(e,n,t){var r=n?x[n]:t,a=[e.trim()];return e.match(/(\s|^)hljs(\s|$)/)||a.push("hljs"),r&&a.push(r),a.join(" ").trim()}function p(e){var n=a(e);if(!/no(-?)highlight/.test(n)){var t;E.useBR?(t=document.createElementNS("http://www.w3.org/1999/xhtml","div"),t.innerHTML=e.innerHTML.replace(/\n/g,"").replace(/<br[ \/]*>/g,"\n")):t=e;var r=t.textContent,o=n?s(n,r,!0):l(r),u=i(t);if(u.length){var p=document.createElementNS("http://www.w3.org/1999/xhtml","div");p.innerHTML=o.value,o.value=c(u,i(p),r)}o.value=f(o.value),e.innerHTML=o.value,e.className=g(e.className,n,o.language),e.result={language:o.language,re:o.r},o.second_best&&(e.second_best={language:o.second_best.language,re:o.second_best.r})}}function d(e){E=o(E,e)}function h(){if(!h.called){h.called=!0;var e=document.querySelectorAll("pre code");Array.prototype.forEach.call(e,p)}}function v(){addEventListener("DOMContentLoaded",h,!1),addEventListener("load",h,!1)}function b(n,t){var r=R[n]=t(e);r.aliases&&r.aliases.forEach(function(e){x[e]=n})}function m(){return Object.keys(R)}function N(e){return R[e]||R[x[e]]}var E={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},R={},x={};return e.highlight=s,e.highlightAuto=l,e.fixMarkup=f,e.highlightBlock=p,e.configure=d,e.initHighlighting=h,e.initHighlightingOnLoad=v,e.registerLanguage=b,e.listLanguages=m,e.getLanguage=N,e.inherit=o,e.IR="[a-zA-Z][a-zA-Z0-9_]*",e.UIR="[a-zA-Z_][a-zA-Z0-9_]*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such)\b/},e.CLCM={cN:"comment",b:"//",e:"$",c:[e.PWM]},e.CBCM={cN:"comment",b:"/\\*",e:"\\*/",c:[e.PWM]},e.HCM={cN:"comment",b:"#",e:"$",c:[e.PWM]},e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e});hljs.registerLanguage("coffeescript",function(e){var c={keyword:"in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super then unless until loop of by when and or is isnt not",literal:"true false null undefined yes no on off",reserved:"case default function var void with const let enum export import native __hasProp __extends __slice __bind __indexOf",built_in:"npm require console print module global window document"},n="[A-Za-z$_][0-9A-Za-z$_]*",t={cN:"subst",b:/#\{/,e:/}/,k:c},r=[e.BNM,e.inherit(e.CNM,{starts:{e:"(\\s*/)?",r:0}}),{cN:"string",v:[{b:/'''/,e:/'''/,c:[e.BE]},{b:/'/,e:/'/,c:[e.BE]},{b:/"""/,e:/"""/,c:[e.BE,t]},{b:/"/,e:/"/,c:[e.BE,t]}]},{cN:"regexp",v:[{b:"///",e:"///",c:[t,e.HCM]},{b:"//[gim]*",r:0},{b:/\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/}]},{cN:"property",b:"@"+n},{b:"`",e:"`",eB:!0,eE:!0,sL:"javascript"}];t.c=r;var i=e.inherit(e.TM,{b:n}),s="(\\(.*\\))?\\s*\\B[-=]>",o={cN:"params",b:"\\([^\\(]",rB:!0,c:[{b:/\(/,e:/\)/,k:c,c:["self"].concat(r)}]};return{aliases:["coffee","cson","iced"],k:c,i:/\/\*/,c:r.concat([{cN:"comment",b:"###",e:"###",c:[e.PWM]},e.HCM,{cN:"function",b:"^\\s*"+n+"\\s*=\\s*"+s,e:"[-=]>",rB:!0,c:[i,o]},{b:/[:\(,=]\s*/,r:0,c:[{cN:"function",b:s,e:"[-=]>",rB:!0,c:[o]}]},{cN:"class",bK:"class",e:"$",i:/[:="\[\]]/,c:[{bK:"extends",eW:!0,i:/[:="\[\]]/,c:[i]},i]},{cN:"attribute",b:n+":",e:":",rB:!0,rE:!0,r:0}])}});hljs.registerLanguage("xml",function(){var t="[A-Za-z0-9\\._:-]+",e={b:/<\?(php)?(?!\w)/,e:/\?>/,sL:"php",subLanguageMode:"continuous"},c={eW:!0,i:/</,r:0,c:[e,{cN:"attribute",b:t,r:0},{b:"=",r:0,c:[{cN:"value",c:[e],v:[{b:/"/,e:/"/},{b:/'/,e:/'/},{b:/[^\s\/>]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xsl","plist"],cI:!0,c:[{cN:"doctype",b:"<!DOCTYPE",e:">",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"<!--",e:"-->",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"<style(?=\\s|>|$)",e:">",k:{title:"style"},c:[c],starts:{e:"</style>",rE:!0,sL:"css"}},{cN:"tag",b:"<script(?=\\s|>|$)",e:">",k:{title:"script"},c:[c],starts:{e:"</script>",rE:!0,sL:"javascript"}},e,{cN:"pi",b:/<\?\w+/,e:/\?>/,r:10},{cN:"tag",b:"</?",e:"/?>",c:[{cN:"title",b:/[^ \/><\n\t]+/,r:0},c]}]}});hljs.registerLanguage("markdown",function(){return{aliases:["md","mkdown","mkd"],c:[{cN:"header",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"blockquote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{cN:"horizontal_rule",b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"link_label",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link_url",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"link_reference",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:"^\\[.+\\]:",rB:!0,c:[{cN:"link_reference",b:"\\[",e:"\\]:",eB:!0,eE:!0,starts:{cN:"link_url",e:"$"}}]}]}});hljs.registerLanguage("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)\}/}]},s={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},a={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/-?[a-z\.]+/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",operator:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"shebang",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,e.NM,s,a,t]}});hljs.registerLanguage("ruby",function(e){var b="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",r="and false then defined module in return redo if BEGIN retry end for true self when next until do begin unless END rescue nil else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",c={cN:"yardoctag",b:"@[A-Za-z]+"},a={cN:"value",b:"#<",e:">"},s={cN:"comment",v:[{b:"#",e:"$",c:[c]},{b:"^\\=begin",e:"^\\=end",c:[c],r:10},{b:"^__END__",e:"\\n$"}]},n={cN:"subst",b:"#\\{",e:"}",k:r},t={cN:"string",c:[e.BE,n],v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/`/,e:/`/},{b:"%[qQwWx]?\\(",e:"\\)"},{b:"%[qQwWx]?\\[",e:"\\]"},{b:"%[qQwWx]?{",e:"}"},{b:"%[qQwWx]?<",e:">"},{b:"%[qQwWx]?/",e:"/"},{b:"%[qQwWx]?%",e:"%"},{b:"%[qQwWx]?-",e:"-"},{b:"%[qQwWx]?\\|",e:"\\|"},{b:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/}]},i={cN:"params",b:"\\(",e:"\\)",k:r},d=[t,a,s,{cN:"class",bK:"class module",e:"$|;",i:/=/,c:[e.inherit(e.TM,{b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{cN:"inheritance",b:"<\\s*",c:[{cN:"parent",b:"("+e.IR+"::)?"+e.IR}]},s]},{cN:"function",bK:"def",e:" |$|;",r:0,c:[e.inherit(e.TM,{b:b}),i,s]},{cN:"constant",b:"(::)?(\\b[A-Z]\\w*(::)?)+",r:0},{cN:"symbol",b:e.UIR+"(\\!|\\?)?:",r:0},{cN:"symbol",b:":",c:[t,{b:b}],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"variable",b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{b:"("+e.RSR+")\\s*",c:[a,s,{cN:"regexp",c:[e.BE,n],i:/\n/,v:[{b:"/",e:"/[a-z]*"},{b:"%r{",e:"}[a-z]*"},{b:"%r\\(",e:"\\)[a-z]*"},{b:"%r!",e:"![a-z]*"},{b:"%r\\[",e:"\\][a-z]*"}]}],r:0}];n.c=d,i.c=d;var l="[>?]>",u="[\\w#]+\\(\\w+\\):\\d+:\\d+>",N="(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>",o=[{b:/^\s*=>/,cN:"status",starts:{e:"$",c:d}},{cN:"prompt",b:"^("+l+"|"+u+"|"+N+")",starts:{e:"$",c:d}}];return{aliases:["rb","gemspec","podspec","thor","irb"],k:r,c:[s].concat(o).concat(d)}});hljs.registerLanguage("javascript",function(r){return{aliases:["js"],k:{keyword:"in if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const class",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document"},c:[{cN:"pi",r:10,v:[{b:/^\s*('|")use strict('|")/},{b:/^\s*('|")use asm('|")/}]},r.ASM,r.QSM,r.CLCM,r.CBCM,r.CNM,{b:"("+r.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[r.CLCM,r.CBCM,r.RM,{b:/</,e:/>;/,r:0,sL:"xml"}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[r.inherit(r.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{cN:"params",b:/\(/,e:/\)/,c:[r.CLCM,r.CBCM],i:/["'\(]/}],i:/\[|%/},{b:/\$[(.]/},{b:"\\."+r.IR,r:0}]}});hljs.registerLanguage("json",function(e){var t={literal:"true false null"},i=[e.QSM,e.CNM],l={cN:"value",e:",",eW:!0,eE:!0,c:i,k:t},c={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:!0,eE:!0,c:[e.BE],i:"\\n",starts:l}],i:"\\S"},n={b:"\\[",e:"\\]",c:[e.inherit(l,{cN:null})],i:"\\S"};return i.splice(i.length,0,c,n),{c:i,k:t,i:"\\S"}});hljs.registerLanguage("http",function(){return{i:"\\S",c:[{cN:"status",b:"^HTTP/[0-9\\.]+",e:"$",c:[{cN:"number",b:"\\b\\d{3}\\b"}]},{cN:"request",b:"^[A-Z]+ (.*?) HTTP/[0-9\\.]+$",rB:!0,e:"$",c:[{cN:"string",b:" ",e:" ",eB:!0,eE:!0}]},{cN:"attribute",b:"^\\w",e:": ",eE:!0,i:"\\n|\\s|=",starts:{cN:"string",e:"$"}},{b:"\\n\\n",starts:{sL:"",eW:!0}}]}});hljs.registerLanguage("css",function(e){var c="[a-zA-Z-][a-zA-Z0-9_-]*",a={cN:"function",b:c+"\\(",rB:!0,eE:!0,e:"\\("};return{cI:!0,i:"[=/|']",c:[e.CBCM,{cN:"id",b:"\\#[A-Za-z0-9_-]+"},{cN:"class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"attr_selector",b:"\\[",e:"\\]",i:"$"},{cN:"pseudo",b:":(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\\"\\']+"},{cN:"at_rule",b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{cN:"at_rule",b:"@",e:"[{;]",c:[{cN:"keyword",b:/\S+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[a,e.ASM,e.QSM,e.CSSNM]}]},{cN:"tag",b:c,r:0},{cN:"rules",b:"{",e:"}",i:"[^\\s]",r:0,c:[e.CBCM,{cN:"rule",b:"[^\\s]",rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:!0,i:"[^\\s]",starts:{cN:"value",eW:!0,eE:!0,c:[a,e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"hexcolor",b:"#[0-9A-Fa-f]+"},{cN:"important",b:"!important"}]}}]}]}]}}); | ||
!(function (e) { typeof exports !== 'undefined' ? e(exports) : (window.hljs = e({}), typeof define === 'function' && define.amd && define([], function () { return window.hljs })) }(function (e) { function n (e) { return e.replace(/&/gm, '&').replace(/</gm, '<').replace(/>/gm, '>') } function t (e) { return e.nodeName.toLowerCase() } function r (e, n) { var t = e && e.exec(n); return t && t.index == 0 } function a (e) { var n = (e.className + ' ' + (e.parentNode ? e.parentNode.className : '')).split(/\s+/); return n = n.map(function (e) { return e.replace(/^lang(uage)?-/, '') }), n.filter(function (e) { return N(e) || /no(-?)highlight/.test(e) })[0] } function o (e, n) { var t = {}; for (var r in e)t[r] = e[r]; if (n) for (var r in n)t[r] = n[r]; return t } function i (e) { var n = []; return (function r (e, a) { for (var o = e.firstChild; o; o = o.nextSibling)o.nodeType == 3 ? a += o.nodeValue.length : o.nodeType == 1 && (n.push({event: 'start', offset: a, node: o}), a = r(o, a), t(o).match(/br|hr|img|input/) || n.push({event: 'stop', offset: a, node: o})); return a }(e, 0)), n } function c (e, r, a) { function o () { return e.length && r.length ? e[0].offset != r[0].offset ? e[0].offset < r[0].offset ? e : r : r[0].event == 'start' ? e : r : e.length ? e : r } function i (e) { function r (e) { return ' ' + e.nodeName + '="' + n(e.value) + '"' }l += '<' + t(e) + Array.prototype.map.call(e.attributes, r).join('') + '>' } function c (e) { l += '</' + t(e) + '>' } function u (e) { (e.event == 'start' ? i : c)(e.node) } for (var s = 0, l = '', f = []; e.length || r.length;) { var g = o(); if (l += n(a.substr(s, g[0].offset - s)), s = g[0].offset, g == e) { f.reverse().forEach(c); do u(g.splice(0, 1)[0]), g = o(); while (g == e && g.length && g[0].offset == s);f.reverse().forEach(i) } else g[0].event == 'start' ? f.push(g[0].node) : f.pop(), u(g.splice(0, 1)[0]) } return l + n(a.substr(s)) } function u (e) { function n (e) { return e && e.source || e } function t (t, r) { return RegExp(n(t), 'm' + (e.cI ? 'i' : '') + (r ? 'g' : '')) } function r (a, i) { if (!a.compiled) { if (a.compiled = !0, a.k = a.k || a.bK, a.k) { var c = {}, u = function (n, t) { e.cI && (t = t.toLowerCase()), t.split(' ').forEach(function (e) { var t = e.split('|'); c[t[0]] = [n, t[1] ? Number(t[1]) : 1] }) }; typeof a.k === 'string' ? u('keyword', a.k) : Object.keys(a.k).forEach(function (e) { u(e, a.k[e]) }), a.k = c }a.lR = t(a.l || /\b[A-Za-z0-9_]+\b/, !0), i && (a.bK && (a.b = '\\b(' + a.bK.split(' ').join('|') + ')\\b'), a.b || (a.b = /\B|\b/), a.bR = t(a.b), a.e || a.eW || (a.e = /\B|\b/), a.e && (a.eR = t(a.e)), a.tE = n(a.e) || '', a.eW && i.tE && (a.tE += (a.e ? '|' : '') + i.tE)), a.i && (a.iR = t(a.i)), void 0 === a.r && (a.r = 1), a.c || (a.c = []); var s = []; a.c.forEach(function (e) { e.v ? e.v.forEach(function (n) { s.push(o(e, n)) }) : s.push(e == 'self' ? a : e) }), a.c = s, a.c.forEach(function (e) { r(e, a) }), a.starts && r(a.starts, i); var l = a.c.map(function (e) { return e.bK ? '\\.?(' + e.b + ')\\.?' : e.b }).concat([a.tE, a.i]).map(n).filter(Boolean); a.t = l.length ? t(l.join('|'), !0) : {exec: function () { return null }} } }r(e) } function s (e, t, a, o) { function i (e, n) { for (var t = 0; t < n.c.length; t++) if (r(n.c[t].bR, e)) return n.c[t] } function c (e, n) { return r(e.eR, n) ? e : e.eW ? c(e.parent, n) : void 0 } function f (e, n) { return !a && r(n.iR, e) } function g (e, n) { var t = x.cI ? n[0].toLowerCase() : n[0]; return e.k.hasOwnProperty(t) && e.k[t] } function p (e, n, t, r) { var a = r ? '' : E.classPrefix, o = '<span class="' + a, i = t ? '' : '</span>'; return o += e + '">', o + n + i } function d () { if (!w.k) return n(y); var e = '', t = 0; w.lR.lastIndex = 0; for (var r = w.lR.exec(y); r;) { e += n(y.substr(t, r.index - t)); var a = g(w, r); a ? (B += a[1], e += p(a[0], n(r[0]))) : e += n(r[0]), t = w.lR.lastIndex, r = w.lR.exec(y) } return e + n(y.substr(t)) } function h () { if (w.sL && !R[w.sL]) return n(y); var e = w.sL ? s(w.sL, y, !0, L[w.sL]) : l(y); return w.r > 0 && (B += e.r), w.subLanguageMode == 'continuous' && (L[w.sL] = e.top), p(e.language, e.value, !1, !0) } function v () { return void 0 !== w.sL ? h() : d() } function b (e, t) { var r = e.cN ? p(e.cN, '', !0) : ''; e.rB ? (M += r, y = '') : e.eB ? (M += n(t) + r, y = '') : (M += r, y = t), w = Object.create(e, {parent: {value: w}}) } function m (e, t) { if (y += e, void 0 === t) return M += v(), 0; var r = i(t, w); if (r) return M += v(), b(r, t), r.rB ? 0 : t.length; var a = c(w, t); if (a) { var o = w; o.rE || o.eE || (y += t), M += v(); do w.cN && (M += '</span>'), B += w.r, w = w.parent; while (w != a.parent);return o.eE && (M += n(t)), y = '', a.starts && b(a.starts, ''), o.rE ? 0 : t.length } if (f(t, w)) throw new Error('Illegal lexeme "' + t + '" for mode "' + (w.cN || '<unnamed>') + '"'); return y += t, t.length || 1 } var x = N(e); if (!x) throw new Error('Unknown language: "' + e + '"'); u(x); for (var w = o || x, L = {}, M = '', k = w; k != x; k = k.parent)k.cN && (M = p(k.cN, '', !0) + M); var y = '', B = 0; try { for (var C, j, I = 0; ;) { if (w.t.lastIndex = I, C = w.t.exec(t), !C) break; j = m(t.substr(I, C.index - I), C[0]), I = C.index + j }m(t.substr(I)); for (var k = w; k.parent; k = k.parent)k.cN && (M += '</span>'); return {r: B, value: M, language: e, top: w} } catch (A) { if (A.message.indexOf('Illegal') != -1) return {r: 0, value: n(t)}; throw A } } function l (e, t) { t = t || E.languages || Object.keys(R); var r = {r: 0, value: n(e)}, a = r; return t.forEach(function (n) { if (N(n)) { var t = s(n, e, !1); t.language = n, t.r > a.r && (a = t), t.r > r.r && (a = r, r = t) } }), a.language && (r.second_best = a), r } function f (e) { return E.tabReplace && (e = e.replace(/^((<[^>]+>|\t)+)/gm, function (e, n) { return n.replace(/\t/g, E.tabReplace) })), E.useBR && (e = e.replace(/\n/g, '<br>')), e } function g (e, n, t) { var r = n ? x[n] : t, a = [e.trim()]; return e.match(/(\s|^)hljs(\s|$)/) || a.push('hljs'), r && a.push(r), a.join(' ').trim() } function p (e) { var n = a(e); if (!/no(-?)highlight/.test(n)) { var t; E.useBR ? (t = document.createElementNS('http://www.w3.org/1999/xhtml', 'div'), t.innerHTML = e.innerHTML.replace(/\n/g, '').replace(/<br[ \/]*>/g, '\n')) : t = e; var r = t.textContent, o = n ? s(n, r, !0) : l(r), u = i(t); if (u.length) { var p = document.createElementNS('http://www.w3.org/1999/xhtml', 'div'); p.innerHTML = o.value, o.value = c(u, i(p), r) }o.value = f(o.value), e.innerHTML = o.value, e.className = g(e.className, n, o.language), e.result = {language: o.language, re: o.r}, o.second_best && (e.second_best = {language: o.second_best.language, re: o.second_best.r}) } } function d (e) { E = o(E, e) } function h () { if (!h.called) { h.called = !0; var e = document.querySelectorAll('pre code'); Array.prototype.forEach.call(e, p) } } function v () { addEventListener('DOMContentLoaded', h, !1), addEventListener('load', h, !1) } function b (n, t) { var r = R[n] = t(e); r.aliases && r.aliases.forEach(function (e) { x[e] = n }) } function m () { return Object.keys(R) } function N (e) { return R[e] || R[x[e]] } var E = {classPrefix: 'hljs-', tabReplace: null, useBR: !1, languages: void 0}, R = {}, x = {}; return e.highlight = s, e.highlightAuto = l, e.fixMarkup = f, e.highlightBlock = p, e.configure = d, e.initHighlighting = h, e.initHighlightingOnLoad = v, e.registerLanguage = b, e.listLanguages = m, e.getLanguage = N, e.inherit = o, e.IR = '[a-zA-Z][a-zA-Z0-9_]*', e.UIR = '[a-zA-Z_][a-zA-Z0-9_]*', e.NR = '\\b\\d+(\\.\\d+)?', e.CNR = '(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)', e.BNR = '\\b(0b[01]+)', e.RSR = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~', e.BE = {b: '\\\\[\\s\\S]', r: 0}, e.ASM = {cN: 'string', b: "'", e: "'", i: '\\n', c: [e.BE]}, e.QSM = {cN: 'string', b: '"', e: '"', i: '\\n', c: [e.BE]}, e.PWM = {b: /\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such)\b/}, e.CLCM = {cN: 'comment', b: '//', e: '$', c: [e.PWM]}, e.CBCM = {cN: 'comment', b: '/\\*', e: '\\*/', c: [e.PWM]}, e.HCM = {cN: 'comment', b: '#', e: '$', c: [e.PWM]}, e.NM = {cN: 'number', b: e.NR, r: 0}, e.CNM = {cN: 'number', b: e.CNR, r: 0}, e.BNM = {cN: 'number', b: e.BNR, r: 0}, e.CSSNM = {cN: 'number', b: e.NR + '(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?', r: 0}, e.RM = {cN: 'regexp', b: /\//, e: /\/[gimuy]*/, i: /\n/, c: [e.BE, {b: /\[/, e: /\]/, r: 0, c: [e.BE]}]}, e.TM = {cN: 'title', b: e.IR, r: 0}, e.UTM = {cN: 'title', b: e.UIR, r: 0}, e })); hljs.registerLanguage('coffeescript', function (e) { var c = {keyword: 'in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super then unless until loop of by when and or is isnt not', literal: 'true false null undefined yes no on off', reserved: 'case default function var void with const let enum export import native __hasProp __extends __slice __bind __indexOf', built_in: 'npm require console print module global window document'}, n = '[A-Za-z$_][0-9A-Za-z$_]*', t = {cN: 'subst', b: /#\{/, e: /}/, k: c}, r = [e.BNM, e.inherit(e.CNM, {starts: {e: '(\\s*/)?', r: 0}}), {cN: 'string', v: [{b: /'''/, e: /'''/, c: [e.BE]}, {b: /'/, e: /'/, c: [e.BE]}, {b: /"""/, e: /"""/, c: [e.BE, t]}, {b: /"/, e: /"/, c: [e.BE, t]}]}, {cN: 'regexp', v: [{b: '///', e: '///', c: [t, e.HCM]}, {b: '//[gim]*', r: 0}, {b: /\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/}]}, {cN: 'property', b: '@' + n}, {b: '`', e: '`', eB: !0, eE: !0, sL: 'javascript'}]; t.c = r; var i = e.inherit(e.TM, {b: n}), s = '(\\(.*\\))?\\s*\\B[-=]>', o = {cN: 'params', b: '\\([^\\(]', rB: !0, c: [{b: /\(/, e: /\)/, k: c, c: ['self'].concat(r)}]}; return {aliases: ['coffee', 'cson', 'iced'], k: c, i: /\/\*/, c: r.concat([{cN: 'comment', b: '###', e: '###', c: [e.PWM]}, e.HCM, {cN: 'function', b: '^\\s*' + n + '\\s*=\\s*' + s, e: '[-=]>', rB: !0, c: [i, o]}, {b: /[:\(,=]\s*/, r: 0, c: [{cN: 'function', b: s, e: '[-=]>', rB: !0, c: [o]}]}, {cN: 'class', bK: 'class', e: '$', i: /[:="\[\]]/, c: [{bK: 'extends', eW: !0, i: /[:="\[\]]/, c: [i]}, i]}, {cN: 'attribute', b: n + ':', e: ':', rB: !0, rE: !0, r: 0}])} }); hljs.registerLanguage('xml', function () { var t = '[A-Za-z0-9\\._:-]+', e = {b: /<\?(php)?(?!\w)/, e: /\?>/, sL: 'php', subLanguageMode: 'continuous'}, c = {eW: !0, i: /</, r: 0, c: [e, {cN: 'attribute', b: t, r: 0}, {b: '=', r: 0, c: [{cN: 'value', c: [e], v: [{b: /"/, e: /"/}, {b: /'/, e: /'/}, {b: /[^\s\/>]+/}]}]}]}; return {aliases: ['html', 'xhtml', 'rss', 'atom', 'xsl', 'plist'], cI: !0, c: [{cN: 'doctype', b: '<!DOCTYPE', e: '>', r: 10, c: [{b: '\\[', e: '\\]'}]}, {cN: 'comment', b: '<!--', e: '-->', r: 10}, {cN: 'cdata', b: '<\\!\\[CDATA\\[', e: '\\]\\]>', r: 10}, {cN: 'tag', b: '<style(?=\\s|>|$)', e: '>', k: {title: 'style'}, c: [c], starts: {e: '</style>', rE: !0, sL: 'css'}}, {cN: 'tag', b: '<script(?=\\s|>|$)', e: '>', k: {title: 'script'}, c: [c], starts: {e: '</script>', rE: !0, sL: 'javascript'}}, e, {cN: 'pi', b: /<\?\w+/, e: /\?>/, r: 10}, {cN: 'tag', b: '</?', e: '/?>', c: [{cN: 'title', b: /[^ \/><\n\t]+/, r: 0}, c]}]} }); hljs.registerLanguage('markdown', function () { return {aliases: ['md', 'mkdown', 'mkd'], c: [{cN: 'header', v: [{b: '^#{1,6}', e: '$'}, {b: '^.+?\\n[=-]{2,}$'}]}, {b: '<', e: '>', sL: 'xml', r: 0}, {cN: 'bullet', b: '^([*+-]|(\\d+\\.))\\s+'}, {cN: 'strong', b: '[*_]{2}.+?[*_]{2}'}, {cN: 'emphasis', v: [{b: '\\*.+?\\*'}, {b: '_.+?_', r: 0}]}, {cN: 'blockquote', b: '^>\\s+', e: '$'}, {cN: 'code', v: [{b: '`.+?`'}, {b: '^( {4}| )', e: '$', r: 0}]}, {cN: 'horizontal_rule', b: '^[-\\*]{3,}', e: '$'}, {b: '\\[.+?\\][\\(\\[].*?[\\)\\]]', rB: !0, c: [{cN: 'link_label', b: '\\[', e: '\\]', eB: !0, rE: !0, r: 0}, {cN: 'link_url', b: '\\]\\(', e: '\\)', eB: !0, eE: !0}, {cN: 'link_reference', b: '\\]\\[', e: '\\]', eB: !0, eE: !0}], r: 10}, {b: '^\\[.+\\]:', rB: !0, c: [{cN: 'link_reference', b: '\\[', e: '\\]:', eB: !0, eE: !0, starts: {cN: 'link_url', e: '$'}}]}]} }); hljs.registerLanguage('bash', function (e) { var t = {cN: 'variable', v: [{b: /\$[\w\d#@][\w\d_]*/}, {b: /\$\{(.*?)\}/}]}, s = {cN: 'string', b: /"/, e: /"/, c: [e.BE, t, {cN: 'variable', b: /\$\(/, e: /\)/, c: [e.BE]}]}, a = {cN: 'string', b: /'/, e: /'/}; return {aliases: ['sh', 'zsh'], l: /-?[a-z\.]+/, k: {keyword: 'if then else elif fi for while in do done case esac function', literal: 'true false', built_in: 'break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp', operator: '-ne -eq -lt -gt -f -d -e -s -l -a'}, c: [{cN: 'shebang', b: /^#![^\n]+sh\s*$/, r: 10}, {cN: 'function', b: /\w[\w\d_]*\s*\(\s*\)\s*\{/, rB: !0, c: [e.inherit(e.TM, {b: /\w[\w\d_]*/})], r: 0}, e.HCM, e.NM, s, a, t]} }); hljs.registerLanguage('ruby', function (e) { var b = '[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?', r = 'and false then defined module in return redo if BEGIN retry end for true self when next until do begin unless END rescue nil else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor', c = {cN: 'yardoctag', b: '@[A-Za-z]+'}, a = {cN: 'value', b: '#<', e: '>'}, s = {cN: 'comment', v: [{b: '#', e: '$', c: [c]}, {b: '^\\=begin', e: '^\\=end', c: [c], r: 10}, {b: '^__END__', e: '\\n$'}]}, n = {cN: 'subst', b: '#\\{', e: '}', k: r}, t = {cN: 'string', c: [e.BE, n], v: [{b: /'/, e: /'/}, {b: /"/, e: /"/}, {b: /`/, e: /`/}, {b: '%[qQwWx]?\\(', e: '\\)'}, {b: '%[qQwWx]?\\[', e: '\\]'}, {b: '%[qQwWx]?{', e: '}'}, {b: '%[qQwWx]?<', e: '>'}, {b: '%[qQwWx]?/', e: '/'}, {b: '%[qQwWx]?%', e: '%'}, {b: '%[qQwWx]?-', e: '-'}, {b: '%[qQwWx]?\\|', e: '\\|'}, {b: /\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/}]}, i = {cN: 'params', b: '\\(', e: '\\)', k: r}, d = [t, a, s, {cN: 'class', bK: 'class module', e: '$|;', i: /=/, c: [e.inherit(e.TM, {b: '[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?'}), {cN: 'inheritance', b: '<\\s*', c: [{cN: 'parent', b: '(' + e.IR + '::)?' + e.IR}]}, s]}, {cN: 'function', bK: 'def', e: ' |$|;', r: 0, c: [e.inherit(e.TM, {b: b}), i, s]}, {cN: 'constant', b: '(::)?(\\b[A-Z]\\w*(::)?)+', r: 0}, {cN: 'symbol', b: e.UIR + '(\\!|\\?)?:', r: 0}, {cN: 'symbol', b: ':', c: [t, {b: b}], r: 0}, {cN: 'number', b: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b', r: 0}, {cN: 'variable', b: '(\\$\\W)|((\\$|\\@\\@?)(\\w+))'}, {b: '(' + e.RSR + ')\\s*', c: [a, s, {cN: 'regexp', c: [e.BE, n], i: /\n/, v: [{b: '/', e: '/[a-z]*'}, {b: '%r{', e: '}[a-z]*'}, {b: '%r\\(', e: '\\)[a-z]*'}, {b: '%r!', e: '![a-z]*'}, {b: '%r\\[', e: '\\][a-z]*'}]}], r: 0}]; n.c = d, i.c = d; var l = '[>?]>', u = '[\\w#]+\\(\\w+\\):\\d+:\\d+>', N = '(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>', o = [{b: /^\s*=>/, cN: 'status', starts: {e: '$', c: d}}, {cN: 'prompt', b: '^(' + l + '|' + u + '|' + N + ')', starts: {e: '$', c: d}}]; return {aliases: ['rb', 'gemspec', 'podspec', 'thor', 'irb'], k: r, c: [s].concat(o).concat(d)} }); hljs.registerLanguage('javascript', function (r) { return {aliases: ['js'], k: {keyword: 'in if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const class', literal: 'true false null undefined NaN Infinity', built_in: 'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document'}, c: [{cN: 'pi', r: 10, v: [{b: /^\s*('|")use strict('|")/}, {b: /^\s*('|")use asm('|")/}]}, r.ASM, r.QSM, r.CLCM, r.CBCM, r.CNM, {b: '(' + r.RSR + '|\\b(case|return|throw)\\b)\\s*', k: 'return throw case', c: [r.CLCM, r.CBCM, r.RM, {b: /</, e: />;/, r: 0, sL: 'xml'}], r: 0}, {cN: 'function', bK: 'function', e: /\{/, eE: !0, c: [r.inherit(r.TM, {b: /[A-Za-z$_][0-9A-Za-z$_]*/}), {cN: 'params', b: /\(/, e: /\)/, c: [r.CLCM, r.CBCM], i: /["'\(]/}], i: /\[|%/}, {b: /\$[(.]/}, {b: '\\.' + r.IR, r: 0}]} }); hljs.registerLanguage('json', function (e) { var t = {literal: 'true false null'}, i = [e.QSM, e.CNM], l = {cN: 'value', e: ',', eW: !0, eE: !0, c: i, k: t}, c = {b: '{', e: '}', c: [{cN: 'attribute', b: '\\s*"', e: '"\\s*:\\s*', eB: !0, eE: !0, c: [e.BE], i: '\\n', starts: l}], i: '\\S'}, n = {b: '\\[', e: '\\]', c: [e.inherit(l, {cN: null})], i: '\\S'}; return i.splice(i.length, 0, c, n), {c: i, k: t, i: '\\S'} }); hljs.registerLanguage('http', function () { return {i: '\\S', c: [{cN: 'status', b: '^HTTP/[0-9\\.]+', e: '$', c: [{cN: 'number', b: '\\b\\d{3}\\b'}]}, {cN: 'request', b: '^[A-Z]+ (.*?) HTTP/[0-9\\.]+$', rB: !0, e: '$', c: [{cN: 'string', b: ' ', e: ' ', eB: !0, eE: !0}]}, {cN: 'attribute', b: '^\\w', e: ': ', eE: !0, i: '\\n|\\s|=', starts: {cN: 'string', e: '$'}}, {b: '\\n\\n', starts: {sL: '', eW: !0}}]} }); hljs.registerLanguage('css', function (e) { var c = '[a-zA-Z-][a-zA-Z0-9_-]*', a = {cN: 'function', b: c + '\\(', rB: !0, eE: !0, e: '\\('}; return {cI: !0, i: "[=/|']", c: [e.CBCM, {cN: 'id', b: '\\#[A-Za-z0-9_-]+'}, {cN: 'class', b: '\\.[A-Za-z0-9_-]+', r: 0}, {cN: 'attr_selector', b: '\\[', e: '\\]', i: '$'}, {cN: 'pseudo', b: ":(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\\"\\']+"}, {cN: 'at_rule', b: '@(font-face|page)', l: '[a-z-]+', k: 'font-face page'}, {cN: 'at_rule', b: '@', e: '[{;]', c: [{cN: 'keyword', b: /\S+/}, {b: /\s/, eW: !0, eE: !0, r: 0, c: [a, e.ASM, e.QSM, e.CSSNM]}]}, {cN: 'tag', b: c, r: 0}, {cN: 'rules', b: '{', e: '}', i: '[^\\s]', r: 0, c: [e.CBCM, {cN: 'rule', b: '[^\\s]', rB: !0, e: ';', eW: !0, c: [{cN: 'attribute', b: '[A-Z\\_\\.\\-]+', e: ':', eE: !0, i: '[^\\s]', starts: {cN: 'value', eW: !0, eE: !0, c: [a, e.CSSNM, e.QSM, e.ASM, e.CBCM, {cN: 'hexcolor', b: '#[0-9A-Fa-f]+'}, {cN: 'important', b: '!important'}]}}]}]}]} }) |
/** | ||
* Created by knut on 2015-12-26. | ||
*/ | ||
var gulp = require('gulp'); | ||
var shell = require('gulp-shell'); | ||
var liveServer = require("live-server"); | ||
var gulp = require('gulp') | ||
var shell = require('gulp-shell') | ||
var liveServer = require('live-server') | ||
var params = { | ||
port: 8080, // Set the server port. Defaults to 8080. | ||
host: "0.0.0.0", // Set the address to bind to. Defaults to 0.0.0.0. | ||
root: "./test/examples", // Set root directory that's being server. Defaults to cwd. | ||
open: true, // When false, it won't load your browser by default. | ||
ignore: 'scss,my/templates', // comma-separated string for paths to ignore | ||
//file: "index.html", // When set, serve this file for every 404 (useful for single-page applications) | ||
wait: 1000, // Waits for all changes, before reloading. Defaults to 0 sec. | ||
mount: [['/dist', './dist']] // Mount a directory to a route. | ||
}; | ||
gulp.task('live-server',function(){ | ||
liveServer.start(params); | ||
}); | ||
port: 8080, // Set the server port. Defaults to 8080. | ||
host: '0.0.0.0', // Set the address to bind to. Defaults to 0.0.0.0. | ||
root: './test/examples', // Set root directory that's being server. Defaults to cwd. | ||
open: true, // When false, it won't load your browser by default. | ||
ignore: 'scss,my/templates', // comma-separated string for paths to ignore | ||
// file: "index.html", // When set, serve this file for every 404 (useful for single-page applications) | ||
wait: 1000, // Waits for all changes, before reloading. Defaults to 0 sec. | ||
mount: [['/dist', './dist']] // Mount a directory to a route. | ||
} | ||
gulp.task('live-server', function () { | ||
liveServer.start(params) | ||
}) | ||
gulp.task('watch2',['live-server'],function(){ | ||
return shell.task([ | ||
'watchify src/mermaid.js -s mermaid -o dist/mermaid.js', | ||
'node node_modules/eslint-watch/bin/esw src -w' | ||
]); | ||
}); | ||
// Basic usage | ||
gulp.task('watch-mermaid',function() { | ||
return gulp.src('src/mermaid.js') | ||
.pipe(browserify({ | ||
entry:'src/mermaid.js', | ||
standalone: 'mermaid' | ||
})) | ||
.pipe(rename('mermaid.js')) | ||
.pipe(gulp.dest('./dist/')) | ||
.pipe(uglify()) | ||
.pipe(extReplace('.min.js')) | ||
.pipe(gulp.dest('./dist/')); | ||
}); | ||
//var bg = require("gulp-bg"); | ||
// | ||
//let bgtask; | ||
//gulp.task("server", bgtask = bg("node", "--harmony", "server.js")); | ||
// | ||
//const exitCallback = (proc) => { if (proc.errorcode != 0) { process.exit(proc.errorcode); } }; | ||
// | ||
//gulp.task("stop", () => { | ||
// bgtask.setCallback(exitCallback); | ||
//bgtask.stop(); | ||
//} | ||
//}); | ||
// | ||
//gulp.task("default", ["server"], function() { | ||
// gulp.watch(["server.js"], ["server"]); | ||
//}); | ||
gulp.task('watch2', ['live-server'], function () { | ||
return shell.task([ | ||
'yarn build -- --watch' | ||
]) | ||
}) |
@@ -1,145 +0,9 @@ | ||
var gulp = require('gulp'); | ||
var browserify = require('gulp-browserify'); | ||
var shell = require('gulp-shell'); | ||
var gulp = require('gulp') | ||
var concat = require('gulp-concat') | ||
var concat = require('gulp-concat'); | ||
var uglify = require('gulp-uglify'); | ||
var extReplace = require('gulp-ext-replace'); | ||
var rename = require('gulp-rename'); | ||
var istanbul = require('gulp-istanbul'); | ||
var insert = require('gulp-insert'); | ||
/** | ||
* dist targets | ||
* * dist - creates everything | ||
* * mermaidAPI | ||
* * mermaidAPI.slim | ||
* * legacy - uses old build creates mermaid.full and mermaid.slim | ||
* * mermaid - new build creates mermaid.js and mermaid.min.js, mermaid.no-d3.js mermaid.no-d3.min.js | ||
*/ | ||
// Basic usage | ||
gulp.task('slimDist', function() { | ||
// Single entry point to browserify | ||
return gulp.src('src/main.js') | ||
.pipe(browserify()) | ||
/*.pipe(browserify({standalone: 'mermaid'})) | ||
.on('prebundle', function(bundle) { | ||
// Keep these external for the slim version. | ||
slim_ext_libs.forEach(function(lib) { | ||
bundle.external(lib); | ||
}); | ||
})*/ | ||
.pipe(rename('mermaid-legacy.slim.js')) | ||
.pipe(insert.prepend('(function () { var define = undefined; ')) | ||
.pipe(insert.append(' })();')) | ||
.pipe(gulp.dest('./dist/')) | ||
.pipe(uglify()) | ||
.pipe(extReplace('.min.js')) | ||
.pipe(gulp.dest('./dist/')); | ||
}); | ||
// Basic usage | ||
gulp.task('fullDist', ['slimDist'], function() { | ||
// Single entry point to browserify | ||
gulp.src(['node_modules/d3/d3.min.js','node_modules/dagre-d3/dist/dagre-d3.min.js','dist/mermaid.slim.js']) | ||
.pipe(concat('mermaid-legacy.full.js')) | ||
.pipe(gulp.dest('./dist/')); | ||
return gulp.src(['node_modules/d3/d3.min.js','node_modules/dagre-d3/dist/dagre-d3.min.js','dist/mermaid.slim.min.js']) | ||
.pipe(concat('mermaid.full.min.js')) | ||
.pipe(gulp.dest('./dist/')); | ||
}); | ||
// Basic usage | ||
//gulp.task('api', shell.task([ | ||
// 'browserify src/mermaid.js | uglify > dist/mermaid.min.js', | ||
// 'browserify src/mermaid.js | uglify > dist/mermaid.min.js', | ||
// 'browserify src/mermaidAPI.js -o dist/mermaidAPI.js' | ||
// //'jison src/diagrams/sequenceDiagram/parser/sequenceDiagram.jison -o src/diagrams/sequenceDiagram/parser/sequenceDiagram.js' | ||
//])); | ||
// Basic usage | ||
gulp.task('mermaid.slim',function() { | ||
// Single entry point to browserify | ||
var EXTERNALS = ['d3']; | ||
return gulp.src('src/mermaid.js') | ||
.pipe(browserify({ | ||
external: ['d3'], | ||
entry:'src/mermaid.js', | ||
standalone: 'mermaid' | ||
})) | ||
.pipe(rename('mermaid.slim.js')) | ||
// .on('prebundle', function(bundle){ | ||
// EXTERNALS.forEach(function(external){ | ||
// if(external.expose){ | ||
// bundle.require(external.require, {expose: external.expose} ) | ||
// } | ||
// else{ | ||
// bundle.require(external.require) | ||
// } | ||
// }) | ||
// }) | ||
.pipe(gulp.dest('./dist/')) | ||
.pipe(uglify()) | ||
.pipe(extReplace('.min.js')) | ||
.pipe(gulp.dest('./dist/')); | ||
}); | ||
// Basic usage | ||
gulp.task('mermaid',function() { | ||
return gulp.src('src/mermaid.js') | ||
.pipe(browserify({ | ||
entry:'src/mermaid.js', | ||
standalone: 'mermaid' | ||
})) | ||
.pipe(rename('mermaid.js')) | ||
.pipe(gulp.dest('./dist/')) | ||
.pipe(uglify()) | ||
.pipe(extReplace('.min.js')) | ||
.pipe(gulp.dest('./dist/')); | ||
}); | ||
// Basic usage | ||
gulp.task('mermaidAPI',function() { | ||
return gulp.src('src/mermaidAPI.js') | ||
.pipe(browserify({ | ||
})) | ||
.pipe(gulp.dest('./dist/')); | ||
//.pipe(uglify()) | ||
//.pipe(extReplace('.min.js')) | ||
//.pipe(gulp.dest('./dist/')); | ||
}); | ||
// Basic usage | ||
gulp.task('mermaidAPI.slim',function() { | ||
return gulp.src('src/mermaidAPI.js') | ||
.pipe(browserify({ | ||
debug:true, | ||
external: ['d3'] | ||
})) | ||
.pipe(rename('mermaidAPI.slim.js')) | ||
.pipe(gulp.dest('./dist/')) | ||
.pipe(uglify()) | ||
.pipe(extReplace('.min.js')) | ||
.pipe(gulp.dest('./dist/')); | ||
}); | ||
// Build editor | ||
gulp.task('editor', function() { | ||
/*gulp.src(['src/editor.js']) | ||
.pipe(browserify()) | ||
.pipe(concat('main.js')) | ||
.pipe(gulp.dest('./editor/'));*/ | ||
return gulp.src(['node_modules/d3/d3.min.js','node_modules/dagre-d3/dist/dagre-d3.min.js','dist/mermaid.slim.js','src/editor.js']) | ||
.pipe(concat('build.js')) | ||
.pipe(gulp.dest('./editor/')); | ||
}); | ||
//gulp.task('dist', ['slimDist', 'fullDist','jasmine']); | ||
gulp.task('legacy', ['slimDist', 'fullDist']); | ||
gulp.task('dist', ['mermaidAPI', 'mermaidAPI.slim','mermaid.slim','mermaid']); | ||
gulp.task('editor', function () { | ||
return gulp.src(['node_modules/d3/d3.min.js', 'node_modules/dagre-d3/dist/dagre-d3.min.js', 'dist/mermaid.slim.js', 'src/editor.js']) | ||
.pipe(concat('build.js')) | ||
.pipe(gulp.dest('./editor/')) | ||
}) |
@@ -1,54 +0,51 @@ | ||
var gulp = require('gulp'); | ||
var mdvars = require('gulp-mdvars'); | ||
var vartree = require('gulp-vartree'); | ||
var gmarked = require('gulp-marked'); | ||
var marked = require('marked'); | ||
var concat = require('gulp-concat'); | ||
var frontMatter = require('gulp-front-matter'); | ||
var hogan = require('hogan.js'); | ||
var es = require('event-stream'); | ||
var fs = require('fs'); | ||
var gulp = require('gulp') | ||
var vartree = require('gulp-vartree') | ||
var gmarked = require('gulp-marked') | ||
var concat = require('gulp-concat') | ||
var frontMatter = require('gulp-front-matter') | ||
var hogan = require('hogan.js') | ||
var es = require('event-stream') | ||
var fs = require('fs') | ||
// Compile a template for rendering each page | ||
var template = hogan.compile(String(fs.readFileSync('docs/tpl/slate.html'))); | ||
var template = hogan.compile(String(fs.readFileSync('docs/tpl/slate.html'))) | ||
var root = {}; | ||
var filelist = []; | ||
var iterator = function(obj) { | ||
var i; | ||
var root = {} | ||
var filelist = [] | ||
var iterator = function (obj) { | ||
var i | ||
for (i = 0; i < obj.childs.length; i++) { | ||
var item = obj.childs[i]; | ||
var item = obj.childs[i] | ||
if (item.folder) { | ||
iterator(item); | ||
iterator(item) | ||
} else { | ||
console.log(item.path + item.name); | ||
filelist.push('build/www' + '/' + item.path + item.name + '.html'); | ||
console.log(item.path + item.name) | ||
filelist.push('build/www' + '/' + item.path + item.name + '.html') | ||
} | ||
} | ||
}; | ||
} | ||
var renderer = { | ||
code: function(code, language) { | ||
code: function (code, language) { | ||
if (language === 'mermaid') { | ||
return '<div class="mermaid">' + code + '</div>'; | ||
return '<div class="mermaid">' + code + '</div>' | ||
} else { | ||
language='css'; | ||
return '<pre class="'+language+'"><code>' + code + '</code></pre>'; | ||
language = 'css' | ||
return '<pre class="' + language + '"><code>' + code + '</code></pre>' | ||
} | ||
} | ||
}; | ||
var filelog = require('gulp-filelog'); | ||
} | ||
var filelog = require('gulp-filelog') | ||
gulp.task('vartree',['dox','copyContent','copySite'], function() { | ||
gulp.task('vartree', ['dox', 'copyContent', 'copySite'], function () { | ||
gulp.src(['build/content/**/*.md']) | ||
.pipe(filelog()) | ||
.pipe(filelog()) | ||
.pipe(frontMatter({ | ||
property: 'order' // will put metadata in the file.meta property | ||
property: 'order' // will put metadata in the file.meta property | ||
})) | ||
.pipe(vartree({ | ||
root: root, // the root in which the vartree will be put | ||
prop: 'order', // metadata property to collect | ||
root: root, // the root in which the vartree will be put | ||
prop: 'order', // metadata property to collect | ||
sortProp: 'order', | ||
parent: 'parent' // keep a ref to the parent scope in the file.parent property | ||
parent: 'parent' // keep a ref to the parent scope in the file.parent property | ||
})) | ||
@@ -58,92 +55,82 @@ .pipe(gmarked({ | ||
sanitize: false | ||
})) // Do whatever you want with the files later | ||
.pipe(gulp.dest('build/www')).on('end', function() { | ||
iterator(root); | ||
//console.log('filelist'); | ||
//console.log(filelist); | ||
})) // Do whatever you want with the files later | ||
.pipe(gulp.dest('build/www')).on('end', function () { | ||
iterator(root) | ||
gulp.src(filelist) | ||
.pipe(concat('all.html')) | ||
.pipe(gulp.dest('./build/www')).on('end', function() { | ||
filelist.push('build/www' + '/all.html'); | ||
.pipe(gulp.dest('./build/www')).on('end', function () { | ||
filelist.push('build/www' + '/all.html') | ||
gulp.src(filelist) | ||
.pipe(filelog('html files')) | ||
// Run each file through a template | ||
.pipe(es.map(function(file, cb) { | ||
//console.log('file:',fileList); | ||
file.contents = new Buffer(template.render(file)); | ||
.pipe(filelog('html files')) | ||
// Run each file through a template | ||
.pipe(es.map(function (file, cb) { | ||
file.contents = Buffer.from(template.render(file)) | ||
cb(null, file); | ||
cb(null, file) | ||
})) | ||
// Output to build directory | ||
.pipe(gulp.dest('./dist/www')); | ||
.pipe(gulp.dest('./dist/www')) | ||
}) | ||
}) | ||
}) | ||
}); | ||
}); | ||
}); | ||
var dox = require('gulp-dox') | ||
var dox = require("gulp-dox"); | ||
var map = require('map-stream') | ||
var extReplace = require('gulp-ext-replace') | ||
var doxJson2Md = require('../plugins/doxJson2Md'); | ||
var map = require('map-stream'); | ||
var ext_replace = require('gulp-ext-replace'); | ||
gulp.task('dox', function () { | ||
return gulp.src(['./src/**/mermaidAPI.js']) | ||
.pipe(filelog()) | ||
.pipe(dox({ | ||
'raw': true | ||
})) | ||
.pipe(map(function (file, done) { | ||
var json = JSON.parse(file.contents.toString()) | ||
var i | ||
var str = '' | ||
for (i = 0; i < json.length; i++) { | ||
str = str + json[i].description.full + '\n' | ||
} | ||
file.contents = Buffer.from(str) | ||
done(null, file) | ||
})) | ||
.pipe(extReplace('.md')) | ||
.pipe(gulp.dest('./build/content')) | ||
}) | ||
gulp.task("dox",function(){ | ||
//return gulp.src(['src/**/*.js','!src/**/parser/*.js','!src/**/*.spec.js']) | ||
gulp.task('copyContent', function () { | ||
return gulp.src(['./docs/content/**/*.md']) | ||
.pipe(gulp.dest('./build/content')) | ||
}) | ||
return gulp.src(['./src/**/mermaidAPI.js']) | ||
.pipe(filelog()) | ||
.pipe(dox({ | ||
'raw':true | ||
})) | ||
.pipe(map(function(file, done){ | ||
var json = JSON.parse(file.contents.toString()); | ||
var i; | ||
var str = ''; | ||
for(i=0;i<json.length;i++){ | ||
//console.log(json[i].description.full); | ||
str = str + json[i].description.full + '\n'; | ||
} | ||
file.contents = new Buffer(str); | ||
done(null, file); | ||
})) | ||
.pipe(ext_replace('.md')) | ||
.pipe(gulp.dest("./build/content")) | ||
}); | ||
gulp.task('copyContent', function () { | ||
return gulp.src(['./docs/content/**/*.md']) | ||
.pipe(gulp.dest('./build/content')) | ||
}) | ||
gulp.task("copyContent",function() { | ||
return gulp.src(['./docs/content/**/*.md']) | ||
.pipe(gulp.dest("./build/content")); | ||
}); | ||
gulp.task("copyContent",function() { | ||
return gulp.src(['./docs/content/**/*.md']) | ||
.pipe(gulp.dest("./build/content")); | ||
}); | ||
gulp.task("copySite",function() { | ||
gulp.src(['./dist/mermaid.js']) | ||
.pipe(filelog()) | ||
.pipe(gulp.dest("./dist/www/javascripts/lib")); | ||
gulp.src(['./docs/site/**/*.css']) | ||
.pipe(filelog()) | ||
.pipe(gulp.dest("./dist/www")); | ||
gulp.src(['./docs/site/**/*.eot']) | ||
.pipe(gulp.dest("./dist/www")); | ||
gulp.src(['./docs/site/**/*.svg']) | ||
.pipe(gulp.dest("./dist/www")); | ||
gulp.src(['./docs/site/**/*.png']) | ||
.pipe(gulp.dest("./dist/www")); | ||
gulp.src(['./docs/site/**/*.jpg']) | ||
.pipe(gulp.dest("./dist/www")); | ||
gulp.src(['./docs/site/**/*.ttf']) | ||
.pipe(gulp.dest("./dist/www")); | ||
gulp.src(['./docs/site/**/*.woff']) | ||
.pipe(gulp.dest("./dist/www")); | ||
gulp.src(['./docs/site/**/*.woff2']) | ||
.pipe(gulp.dest("./dist/www")); | ||
return gulp.src(['./docs/site/**/*.js']) | ||
.pipe(gulp.dest("./dist/www")); | ||
}); | ||
gulp.task('copySite', function () { | ||
gulp.src(['./dist/mermaid.js']) | ||
.pipe(filelog()) | ||
.pipe(gulp.dest('./dist/www/javascripts/lib')) | ||
gulp.src(['./docs/site/**/*.css']) | ||
.pipe(filelog()) | ||
.pipe(gulp.dest('./dist/www')) | ||
gulp.src(['./docs/site/**/*.eot']) | ||
.pipe(gulp.dest('./dist/www')) | ||
gulp.src(['./docs/site/**/*.svg']) | ||
.pipe(gulp.dest('./dist/www')) | ||
gulp.src(['./docs/site/**/*.png']) | ||
.pipe(gulp.dest('./dist/www')) | ||
gulp.src(['./docs/site/**/*.jpg']) | ||
.pipe(gulp.dest('./dist/www')) | ||
gulp.src(['./docs/site/**/*.ttf']) | ||
.pipe(gulp.dest('./dist/www')) | ||
gulp.src(['./docs/site/**/*.woff']) | ||
.pipe(gulp.dest('./dist/www')) | ||
gulp.src(['./docs/site/**/*.woff2']) | ||
.pipe(gulp.dest('./dist/www')) | ||
return gulp.src(['./docs/site/**/*.js']) | ||
.pipe(gulp.dest('./dist/www')) | ||
}) |
@@ -1,24 +0,23 @@ | ||
var gulp = require('gulp'); | ||
var shell = require('gulp-shell'); | ||
var jison = require('gulp-jison'); | ||
var filelog = require('gulp-filelog'); | ||
var gulp = require('gulp') | ||
var shell = require('gulp-shell') | ||
var jison = require('gulp-jison') | ||
var filelog = require('gulp-filelog') | ||
gulp.task('jison', function() { | ||
return gulp.src('./src/**/*.jison') | ||
.pipe(filelog('Jison file:')) | ||
.pipe(jison({ moduleType: 'commonjs' })) | ||
.pipe(gulp.dest('./src/')); | ||
}); | ||
gulp.task('jison', function () { | ||
return gulp.src('./src/**/*.jison') | ||
.pipe(filelog('Jison file:')) | ||
.pipe(jison({ moduleType: 'commonjs' })) | ||
.pipe(gulp.dest('./src/')) | ||
}) | ||
gulp.task('jison_legacy', function(){ | ||
shell.task([ | ||
'node node_modules/jison/lib/cli.js src/diagrams/classDiagram/parser/classDiagram.jison -o src/diagrams/classDiagram/parser/classDiagram.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/sequenceDiagram/parser/sequenceDiagram.jison -o src/diagrams/sequenceDiagram/parser/sequenceDiagram.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/example/parser/example.jison -o src/diagrams/example/parser/example.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/flowchart/parser/flow.jison -o src/diagrams/flowchart/parser/flow.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/flowchart/parser/dot.jison -o src/diagrams/flowchart/parser/dot.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/gitGraph/parser/gitGraph.jison -o src/diagrams/gitGraph/parser/gitGraph.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/gantt/parser/gantt.jison -o src/diagrams/gantt/parser/gantt.js' | ||
]); | ||
}); | ||
gulp.task('jison_legacy', function () { | ||
shell.task([ | ||
'node node_modules/jison/lib/cli.js src/diagrams/classDiagram/parser/classDiagram.jison -o src/diagrams/classDiagram/parser/classDiagram.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/sequenceDiagram/parser/sequenceDiagram.jison -o src/diagrams/sequenceDiagram/parser/sequenceDiagram.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/example/parser/example.jison -o src/diagrams/example/parser/example.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/flowchart/parser/flow.jison -o src/diagrams/flowchart/parser/flow.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/flowchart/parser/dot.jison -o src/diagrams/flowchart/parser/dot.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/gitGraph/parser/gitGraph.jison -o src/diagrams/gitGraph/parser/gitGraph.js', | ||
'node node_modules/jison/lib/cli.js src/diagrams/gantt/parser/gantt.jison -o src/diagrams/gantt/parser/gantt.js' | ||
]) | ||
}) |
@@ -1,35 +0,16 @@ | ||
var gulp = require('gulp'); | ||
var path = require('path'); | ||
var less = require('gulp-less'); | ||
var rename = require('gulp-rename'); | ||
var concat = require('gulp-concat'); | ||
var gulp = require('gulp') | ||
var path = require('path') | ||
var less = require('gulp-less') | ||
var concat = require('gulp-concat') | ||
gulp.task('editor-less', function () { | ||
gulp.src(['./editor/css/editor.less']) | ||
.pipe(less({ | ||
generateSourceMap: false, // default true | ||
paths: [ path.join(__dirname, 'less', 'includes') ] | ||
})) | ||
.pipe(concat('editor.css')) | ||
.pipe(gulp.dest('./editor/css/')); | ||
}); | ||
gulp.src(['./editor/css/editor.less']) | ||
.pipe(less({ | ||
generateSourceMap: false, // default true | ||
paths: [path.join(__dirname, 'less', 'includes')] | ||
})) | ||
.pipe(concat('editor.css')) | ||
.pipe(gulp.dest('./editor/css/')) | ||
}) | ||
gulp.task('mermaid-less', function () { | ||
gulp.src(['./src/less/*/mermaid.less']) | ||
.pipe(less({ | ||
generateSourceMap: false, // default true | ||
paths: [ path.join(__dirname, 'less', 'includes') ] | ||
})) | ||
.pipe(rename(function (path) { | ||
if(path.dirname === 'default'){ | ||
path.basename = 'mermaid'; | ||
}else{ | ||
path.basename = 'mermaid.' + path.dirname; | ||
} | ||
path.dirname = ''; | ||
})) | ||
.pipe(gulp.dest('./dist/')); | ||
}); | ||
gulp.task('less',['mermaid-less', 'editor-less']); | ||
gulp.task('less', ['editor-less']) |
@@ -1,15 +0,16 @@ | ||
var gulp = require('gulp'); | ||
var bump = require('gulp-bump'); | ||
var gulp = require('gulp') | ||
var bump = require('gulp-bump') | ||
var tagVersion = require('gulp-tag-version') | ||
gulp.task('bump', function(){ | ||
gulp.src('./bw.json') | ||
.pipe(bump({key: "version"})) | ||
.pipe(gulp.dest('./')); | ||
}); | ||
gulp.task('bump', function () { | ||
gulp.src('./bw.json') | ||
.pipe(bump({ key: 'version' })) | ||
.pipe(gulp.dest('./')) | ||
}) | ||
// Assuming there's "version: 1.2.3" in package.json, | ||
// tag the last commit as "v1.2.3"// | ||
gulp.task('tag', function() { | ||
return gulp.src(['./package.json']).pipe(tag_version()); | ||
}); | ||
gulp.task('tag', function () { | ||
return gulp.src(['./package.json']).pipe(tagVersion()) | ||
}) | ||
@@ -30,20 +31,13 @@ /** | ||
function inc(importance) { | ||
// get all the files to bump version in | ||
return gulp.src(['./package.json']) | ||
// bump the version number in those files | ||
.pipe(bump({type: importance})) | ||
// save it back to filesystem | ||
.pipe(gulp.dest('./')); | ||
// commit the changed version number | ||
//.pipe(git.commit('bumps package version')) | ||
// read only one file to get the version number | ||
//.pipe(filter('package.json')) | ||
// **tag it in the repository** | ||
//.pipe(tag_version()); | ||
function inc (importance) { | ||
// get all the files to bump version in | ||
return gulp.src(['./package.json']) | ||
// bump the version number in those files | ||
.pipe(bump({ type: importance })) | ||
// save it back to filesystem | ||
.pipe(gulp.dest('./')) | ||
} | ||
gulp.task('patch', function() { return inc('patch'); }) | ||
gulp.task('feature', function() { return inc('minor'); }) | ||
gulp.task('release', function() { return inc('major'); }) | ||
gulp.task('patch', function () { return inc('patch') }) | ||
gulp.task('feature', function () { return inc('minor') }) | ||
gulp.task('release', function () { return inc('major') }) |
@@ -1,68 +0,46 @@ | ||
var gulp = require('gulp'); | ||
var jasmine = require('gulp-jasmine'); | ||
var gulp = require('gulp'); | ||
var browserify = require('gulp-browserify'); | ||
var shell = require('gulp-shell'); | ||
var jison = require('gulp-jison'); | ||
var gulp = require('gulp') | ||
var jasmine = require('gulp-jasmine') | ||
var istanbul = require('gulp-istanbul') | ||
var qunit = require('gulp-qunit') | ||
var bower = require('gulp-bower') | ||
var concat = require('gulp-concat'); | ||
var uglify = require('gulp-uglify'); | ||
var extReplace = require('gulp-ext-replace'); | ||
var rename = require('gulp-rename'); | ||
var istanbul = require('gulp-istanbul'); | ||
var insert = require('gulp-insert'); | ||
var jshint = require('gulp-jshint'); | ||
var stylish = require('jshint-stylish'); | ||
gulp.task('test', ['coverage', 'jasmine', 'qunit']) | ||
var qunit = require('gulp-qunit'); | ||
var bower = require('gulp-bower'); | ||
gulp.task('jasmine', ['jison', 'lint'], function () { | ||
return gulp.src(['src/**/*.spec.js']) | ||
.pipe(jasmine({ includeStackTrace: true })) | ||
}) | ||
// Using gulp-jshint and jshint-stylish | ||
gulp.task('lint', function() { | ||
return gulp.src(['./src/**/*.js', '!**/parser/*.js']) | ||
.pipe(jshint()) | ||
.pipe(jshint.reporter(stylish)); | ||
}); | ||
gulp.task('test',['coverage','tape','jasmine','qunit']); | ||
gulp.task('jasmine',['jison','lint'], function () { | ||
return gulp.src(['src/**/*.spec.js']) | ||
.pipe(jasmine({includeStackTrace:true})); | ||
}); | ||
gulp.task('jas', function () { | ||
return gulp.src(['src/**/*.spec.js']) | ||
.pipe(jasmine({includeStackTrace:true})); | ||
}); | ||
return gulp.src(['src/**/*.spec.js']) | ||
.pipe(jasmine({ includeStackTrace: true })) | ||
}) | ||
gulp.task('tape', shell.task(['node_modules/.bin/tape ./test/cli_test-*.js'])); | ||
gulp.task('coverage', function (cb) { | ||
gulp.src(['src/**/*.js', '!src/**/*.spec.js']) | ||
.pipe(istanbul()) // Covering files | ||
.on('finish', function () { | ||
gulp.src(['src/**/*.spec.js']) | ||
.pipe(jasmine()) | ||
.pipe(istanbul.writeReports()) // Creating the reports after tests runned | ||
.on('end', cb); | ||
}); | ||
}); | ||
gulp.src(['src/**/*.js', '!src/**/*.spec.js']) | ||
.pipe(istanbul()) // Covering files | ||
.on('finish', function () { | ||
gulp.src(['src/**/*.spec.js']) | ||
.pipe(jasmine()) | ||
.pipe(istanbul.writeReports()) // Creating the reports after tests runned | ||
.on('end', cb) | ||
}) | ||
}) | ||
gulp.task('qunit', ['usageTestsBower'], function() { | ||
return gulp.src('test/usageTests/requireTest.html') | ||
.pipe(qunit()); | ||
}); | ||
gulp.task('qunit', ['usageTestsBower'], function () { | ||
return gulp.src('test/usageTests/requireTest.html') | ||
.pipe(qunit()) | ||
}) | ||
gulp.task('usageTestsBower', function() { | ||
return bower({cwd: 'test/usageTests'}) | ||
.pipe(gulp.dest('test/usageTests/bower_components')); | ||
}); | ||
gulp.task('usageTestsBower', function () { | ||
return bower({ cwd: 'test/usageTests' }) | ||
.pipe(gulp.dest('test/usageTests/bower_components')) | ||
}) | ||
var jasmineBrowser = require('gulp-jasmine-browser'); | ||
var jasmineBrowser = require('gulp-jasmine-browser') | ||
gulp.task('jasmine2', function() { | ||
return gulp.src(['src/**/*.js']) | ||
.pipe(jasmineBrowser.specRunner({console: true})) | ||
.pipe(jasmineBrowser.headless()); | ||
}); | ||
gulp.task('jasmine2', function () { | ||
return gulp.src(['src/**/*.js']) | ||
.pipe(jasmineBrowser.specRunner({ console: true })) | ||
.pipe(jasmineBrowser.headless()) | ||
}) |
@@ -1,40 +0,3 @@ | ||
var gulp = require('gulp'); | ||
var requireDir = require('require-dir') | ||
var shell = require('gulp-shell'); | ||
var concat = require('gulp-concat'); | ||
var uglify = require('gulp-uglify'); | ||
var extReplace = require('gulp-ext-replace'); | ||
var rename = require('gulp-rename'); | ||
var istanbul = require('gulp-istanbul'); | ||
var bump = require('gulp-bump'); | ||
var tag_version = require('gulp-tag-version'); | ||
var insert = require('gulp-insert'); | ||
var requireDir = require('require-dir'); | ||
var tasks = requireDir('./gulp/tasks'); | ||
var paths = { | ||
scripts: ['./src/**/*.js', '!**/parser/*.js'] | ||
}; | ||
requireDir('./gulp/tasks') |
@@ -5,81 +5,96 @@ // Karma configuration | ||
module.exports = function (config) { | ||
config.set({ | ||
config.set({ | ||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: '.', | ||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: '.', | ||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['browserify', 'jasmine'], | ||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['jasmine'], | ||
// list of files / patterns to load in the browser | ||
files: [ | ||
'./src/*.spec.js', | ||
'./src/diagrams/flowchart/**/*.spec.js', | ||
'./src/diagrams/example/**/*.spec.js', | ||
'./src/diagrams/sequenceDiagram/**/*.spec.js', | ||
'./src/diagrams/classDiagram/**/*.spec.js', | ||
'./src/diagrams/gantt/**/*.spec.js', | ||
'./src/diagrams/gitGraph/**/*.spec.js' | ||
], | ||
// list of files / patterns to load in the browser | ||
files: [ | ||
'./src/*.spec.js', | ||
'./src/diagrams/flowchart/**/*.spec.js', | ||
'./src/diagrams/example/**/*.spec.js', | ||
'./src/diagrams/sequenceDiagram/**/*.spec.js', | ||
'./src/diagrams/classDiagram/**/*.spec.js', | ||
'./src/diagrams/gantt/**/*.spec.js', | ||
'./src/diagrams/gitGraph/**/*.spec.js' | ||
], | ||
preprocessors: { | ||
'src/**/*.spec.js': ['webpack'] | ||
}, | ||
preprocessors: { | ||
'src/**/*.spec.js': [ 'browserify' ] | ||
}, | ||
// list of files to exclude | ||
//exclude: ['src/diagrams/*.js'], | ||
browserify: { | ||
debug: true, | ||
//plugin: ['proxyquireify/plugin'] | ||
extensions : ['.js'], | ||
configure: function (bundle) { | ||
bundle.on('prebundle', function () { | ||
bundle | ||
.plugin('proxyquire-universal') | ||
}); | ||
webpack: { | ||
externals: ['fs'], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [ | ||
['env', { | ||
'targets': { | ||
'browsers': ['last 3 versions'] | ||
} | ||
}] | ||
], | ||
plugins: [ | ||
'transform-remove-strict-mode' | ||
] | ||
} | ||
} | ||
}, | ||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
} | ||
] | ||
} | ||
}, | ||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['dots'], | ||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['dots'], | ||
// web server port | ||
port: 9876, | ||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
// web server port | ||
port: 9876, | ||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: true, | ||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
customLaunchers: { | ||
ChromeHeadless: { | ||
base: 'Chrome', | ||
flags: [ | ||
'--incognito', | ||
// '--headless', | ||
'--disable-gpu', | ||
'--no-sandbox', | ||
// Without a remote debugging port, Google Chrome exits immediately. | ||
'--remote-debugging-port=9222' | ||
] | ||
} | ||
}, | ||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: true, | ||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['PhantomJS'], | ||
plugins: [ | ||
'karma-jasmine', | ||
'karma-phantomjs-launcher', | ||
'karma-browserify', | ||
'karma-babel-preprocessor' | ||
], | ||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: false | ||
}); | ||
}; | ||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['ChromeHeadless'], | ||
plugins: [ | ||
'karma-jasmine', | ||
'karma-chrome-launcher', | ||
'karma-webpack' | ||
], | ||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: false | ||
}) | ||
} |
164
lib/cli.js
var fs = require('fs') | ||
, exec = require('child_process').exec | ||
, chalk = require('chalk') | ||
, which = require('which') | ||
, parseArgs = require('minimist') | ||
, semver = require('semver') | ||
, path = require('path') | ||
var exec = require('child_process').exec | ||
var chalk = require('chalk') | ||
var which = require('which') | ||
var parseArgs = require('minimist') | ||
var semver = require('semver') | ||
var path = require('path') | ||
var PHANTOM_VERSION = "^2.1.0" | ||
var PHANTOM_VERSION = '^2.1.0' | ||
var info = chalk.blue.bold | ||
, note = chalk.green.bold | ||
module.exports = function() { | ||
return new cli() | ||
}() | ||
module.exports = (function () { | ||
return new Cli() | ||
}()) | ||
function cli(options) { | ||
function Cli (options) { | ||
this.options = { | ||
alias: { | ||
help: 'h' | ||
, png: 'p' | ||
, outputDir: 'o' | ||
, outputSuffix: 'O' | ||
, svg: 's' | ||
, verbose: 'v' | ||
, phantomPath: 'e' | ||
, sequenceConfig: 'c' | ||
, ganttConfig: 'g' | ||
, css: 't' | ||
, width: 'w' | ||
} | ||
, 'boolean': ['help', 'png', 'svg', 'verbose'] | ||
, 'string': ['outputDir', 'outputSuffix'] | ||
alias: { | ||
help: 'h', | ||
png: 'p', | ||
outputDir: 'o', | ||
outputSuffix: 'O', | ||
svg: 's', | ||
verbose: 'v', | ||
phantomPath: 'e', | ||
sequenceConfig: 'c', | ||
ganttConfig: 'g', | ||
css: 't', | ||
width: 'w' | ||
}, | ||
'boolean': ['help', 'png', 'svg', 'verbose'], | ||
'string': ['outputDir', 'outputSuffix'] | ||
} | ||
@@ -41,19 +40,19 @@ | ||
this.helpMessage = [ | ||
, info('Usage: mermaid [options] <file>...') | ||
, "" | ||
, "file The mermaid description file to be rendered" | ||
, "" | ||
, "Options:" | ||
, " -s --svg Output SVG instead of PNG (experimental)" | ||
, " -p --png If SVG was selected, and you also want PNG, set this flag" | ||
, " -o --outputDir Directory to save files, will be created automatically, defaults to `cwd`" | ||
, " -O --outputSuffix Suffix to output filenames in front of '.svg' or '.png', defaults to ''" | ||
, " -e --phantomPath Specify the path to the phantomjs executable" | ||
, " -t --css Specify the path to a CSS file to be included when processing output" | ||
, " -c --sequenceConfig Specify the path to the file with the configuration to be applied in the sequence diagram" | ||
, " -g --ganttConfig Specify the path to the file with the configuration to be applied in the gantt diagram" | ||
, " -h --help Show this message" | ||
, " -v --verbose Show logging" | ||
, " -w --width width of the generated png (number)" | ||
, " --version Print version and quit" | ||
info('Usage: mermaid [options] <file>...'), | ||
'', | ||
'file The mermaid description file to be rendered', | ||
'', | ||
'Options:', | ||
' -s --svg Output SVG instead of PNG (experimental)', | ||
' -p --png If SVG was selected, and you also want PNG, set this flag', | ||
' -o --outputDir Directory to save files, will be created automatically, defaults to `cwd`', | ||
" -O --outputSuffix Suffix to output filenames in front of '.svg' or '.png', defaults to ''", | ||
' -e --phantomPath Specify the path to the phantomjs executable', | ||
' -t --css Specify the path to a CSS file to be included when processing output', | ||
' -c --sequenceConfig Specify the path to the file with the configuration to be applied in the sequence diagram', | ||
' -g --ganttConfig Specify the path to the file with the configuration to be applied in the gantt diagram', | ||
' -h --help Show this message', | ||
' -v --verbose Show logging', | ||
' -w --width width of the generated png (number)', | ||
' --version Print version and quit' | ||
] | ||
@@ -64,27 +63,25 @@ | ||
cli.prototype.parse = function(argv, next) { | ||
Cli.prototype.parse = function (argv, next) { | ||
this.errors = [] // clear errors | ||
var options = parseArgs(argv, this.options) | ||
, phantom | ||
if (options.version) { | ||
var pkg = require('../package.json') | ||
this.message = "" + pkg.version | ||
this.message = '' + pkg.version | ||
next(null, this.message) | ||
} | ||
else if (options.help) { | ||
} else if (options.help) { | ||
this.message = this.helpMessage.join('\n') | ||
next(null, this.message) | ||
} | ||
else { | ||
} else { | ||
options.files = options._ | ||
if (!options.files.length) { | ||
this.errors.push(new Error("You must specify at least one source file.")) | ||
this.errors.push(new Error('You must specify at least one source file.')) | ||
} | ||
// ensure that parameter-expecting options have parameters | ||
;['outputDir', 'outputSuffix', 'phantomPath', 'sequenceConfig', 'ganttConfig', 'css'].forEach(function(i) { | ||
if(typeof options[i] !== 'undefined') { | ||
;['outputDir', 'outputSuffix', 'phantomPath', 'sequenceConfig', 'ganttConfig', 'css'].forEach(function (i) { | ||
if (typeof options[i] !== 'undefined') { | ||
if (typeof options[i] !== 'string' || options[i].length < 1) { | ||
this.errors.push(new Error(i + " expects a value.")) | ||
this.errors.push(new Error(i + ' expects a value.')) | ||
} | ||
@@ -97,11 +94,9 @@ } | ||
options.png = false | ||
} | ||
else { | ||
} else { | ||
options.png = true | ||
} | ||
if (options.sequenceConfig) { | ||
try { | ||
fs.accessSync(options.sequenceConfig, fs.R_OK) | ||
} catch (err) { | ||
@@ -113,7 +108,6 @@ this.errors.push(err) | ||
} | ||
if (options.ganttConfig) { | ||
try { | ||
fs.accessSync(options.ganttConfig, fs.R_OK) | ||
} catch (err) { | ||
@@ -129,3 +123,2 @@ this.errors.push(err) | ||
fs.accessSync(options.css, fs.R_OK) | ||
} catch (err) { | ||
@@ -135,8 +128,8 @@ this.errors.push(err) | ||
} else { | ||
options.css = path.join(__dirname, '..', 'dist', 'mermaid.css') | ||
options.css = path.join(__dirname, '..', 'dist', 'mermaid.css') | ||
} | ||
// set svg/png flags appropriately | ||
if(!options.width){ | ||
options.width = 1200; | ||
if (!options.width) { | ||
options.width = 1200 | ||
} | ||
@@ -146,4 +139,4 @@ | ||
this.checkPhantom(function(err, path) { | ||
if(err) { | ||
this.checkPhantom(function (err, path) { | ||
if (err) { | ||
this.errors.push(err) | ||
@@ -153,3 +146,3 @@ } | ||
next( | ||
this.errors.length > 0 ? this.errors : null | ||
this.errors.length > 0 ? this.errors : null | ||
, this.message | ||
@@ -162,9 +155,8 @@ , options | ||
function createCheckPhantom(_phantomPath) { | ||
function createCheckPhantom (_phantomPath) { | ||
var phantomPath = _phantomPath | ||
, phantomVersion | ||
return function checkPhantom(_next) { | ||
var next = _next || function() {} | ||
, err | ||
return function checkPhantom (_next) { | ||
var next = _next || function () { } | ||
var err | ||
@@ -183,6 +175,6 @@ if (typeof phantomPath === 'undefined') { | ||
[ | ||
"Cannot find phantomjs in your PATH. If phantomjs is installed" | ||
, "you may need to specify its path manually with the '-e' option." | ||
, "Run this executable with '--help' or view the README for more" | ||
, "details." | ||
'Cannot find phantomjs in your PATH. If phantomjs is installed', | ||
"you may need to specify its path manually with the '-e' option.", | ||
"Run this executable with '--help' or view the README for more", | ||
'details.' | ||
].join('\n') | ||
@@ -199,15 +191,13 @@ ) | ||
// If we have phantompath, see if its version satisfies our requirements | ||
exec('"' + phantomPath + '" --version', function(err, stdout, stderr) { | ||
exec('"' + phantomPath + '" --version', function (err, stdout, stderr) { | ||
if (err) { | ||
next(new Error("Could not find phantomjs at the specified path.")) | ||
} | ||
else if (!semver.satisfies(stdout, PHANTOM_VERSION)) { | ||
next(new Error('Could not find phantomjs at the specified path.')) | ||
} else if (!semver.satisfies(stdout, PHANTOM_VERSION)) { | ||
next(new Error( | ||
'mermaid requires phantomjs ' | ||
+ PHANTOM_VERSION | ||
+ ' to be installed, found version ' | ||
+ stdout | ||
'mermaid requires phantomjs ' + | ||
PHANTOM_VERSION + | ||
' to be installed, found version ' + | ||
stdout | ||
)) | ||
} | ||
else { | ||
} else { | ||
next(null, phantomPath) | ||
@@ -214,0 +204,0 @@ } |
@@ -1,5 +0,3 @@ | ||
var os = require('os') | ||
, fs = require('fs') | ||
, path = require('path') | ||
, spawn = require('child_process').spawn | ||
var path = require('path') | ||
var spawn = require('child_process').spawn | ||
@@ -12,30 +10,29 @@ var mkdirp = require('mkdirp') | ||
function processMermaid(files, _options, _next) { | ||
function processMermaid (files, _options, _next) { | ||
var options = _options || {} | ||
, outputDir = options.outputDir || process.cwd() | ||
, outputSuffix = options.outputSuffix || '' | ||
, next = _next || function() {} | ||
, phantomArgs = [ | ||
phantomscript | ||
, outputDir | ||
, options.png | ||
, options.svg | ||
, options.css | ||
, options.sequenceConfig | ||
, options.ganttConfig | ||
, options.verbose | ||
, options.width | ||
, outputSuffix | ||
]; | ||
var outputDir = options.outputDir || process.cwd() | ||
var outputSuffix = options.outputSuffix || '' | ||
var next = _next || function () { } | ||
var phantomArgs = [ | ||
phantomscript, | ||
outputDir, | ||
options.png, | ||
options.svg, | ||
options.css, | ||
options.sequenceConfig, | ||
options.ganttConfig, | ||
options.verbose, | ||
options.width, | ||
outputSuffix | ||
] | ||
files.forEach(function(file) { | ||
files.forEach(function (file) { | ||
phantomArgs.push(file) | ||
}) | ||
mkdirp(outputDir, function(err) { | ||
mkdirp(outputDir, function (err) { | ||
if (err) { | ||
throw err | ||
return | ||
} | ||
phantom = spawn(options.phantomPath, phantomArgs) | ||
var phantom = spawn(options.phantomPath, phantomArgs) | ||
@@ -42,0 +39,0 @@ phantom.on('exit', next) |
@@ -9,13 +9,13 @@ /** | ||
phantom.onError = function(msg, trace) { | ||
window.phantom.onError = function (msg, trace) { | ||
var msgStack = ['PHANTOM ERROR: ' + msg] | ||
if (trace && trace.length) { | ||
msgStack.push('TRACE:') | ||
trace.forEach(function(t) { | ||
trace.forEach(function (t) { | ||
msgStack.push( | ||
' -> ' | ||
+ (t.file || t.sourceURL) | ||
+ ': ' | ||
+ t.line | ||
+ (t.function ? ' (in function ' + t.function +')' : '') | ||
' -> ' + | ||
(t.file || t.sourceURL) + | ||
': ' + | ||
t.line + | ||
(t.function ? ' (in function ' + t.function + ')' : '') | ||
) | ||
@@ -25,59 +25,57 @@ }) | ||
system.stderr.write(msgStack.join('\n')) | ||
phantom.exit(1) | ||
window.phantom.exit(1) | ||
} | ||
var system = require('system') | ||
, fs = require('fs') | ||
, webpage = require('webpage') | ||
var fs = require('fs') | ||
var webpage = require('webpage') | ||
var page = webpage.create() | ||
, files = system.args.slice(10, system.args.length) | ||
, width = system.args[8] | ||
var files = system.args.slice(10, system.args.length) | ||
var width = system.args[8] | ||
if(typeof width === 'undefined' || width==='undefined'){ | ||
width = 1200; | ||
if (typeof width === 'undefined' || width === 'undefined') { | ||
width = 1200 | ||
} | ||
var options = { | ||
outputDir: system.args[1] | ||
, png: system.args[2] === 'true' ? true : false | ||
, svg: system.args[3] === 'true' ? true : false | ||
, css: fs.read(system.args[4]) | ||
, sequenceConfig: system.args[5] !== 'null' ? JSON.parse(fs.read(system.args[5])) : {} | ||
, ganttConfig: system.args[6] !== 'null' ? JSON.parse(fs.read(system.args[6])) : {} | ||
, verbose: system.args[7] === 'true' ? true : false | ||
, width: width | ||
, outputSuffix: system.args[9] | ||
} | ||
, log = logger(options.verbose) | ||
options.sequenceConfig.useMaxWidth = false; | ||
outputDir: system.args[1], | ||
png: system.args[2] === 'true', | ||
svg: system.args[3] === 'true', | ||
css: fs.read(system.args[4]), | ||
sequenceConfig: system.args[5] !== 'null' ? JSON.parse(fs.read(system.args[5])) : {}, | ||
ganttConfig: system.args[6] !== 'null' ? JSON.parse(fs.read(system.args[6])) : {}, | ||
verbose: system.args[7] === 'true', | ||
width: width, | ||
outputSuffix: system.args[9] | ||
} | ||
var log = logger(options.verbose) | ||
options.sequenceConfig.useMaxWidth = false | ||
page.content = [ | ||
'<html>' | ||
, '<head>' | ||
, '<style type="text/css">body {background:white;font-family: Arial;}' | ||
, options.css | ||
, '</style>' | ||
, '</head>' | ||
, '<body>' | ||
, '</body>' | ||
, '</html>' | ||
'<html>', | ||
'<head>', | ||
'<style type="text/css">body {background:white;font-family: Arial;}', | ||
options.css, | ||
'</style>', | ||
'</head>', | ||
'<body>', | ||
'</body>', | ||
'</html>' | ||
].join('\n') | ||
page.injectJs('../dist/mermaid.js') | ||
page.onConsoleMessage = function(msg, lineNum, sourceId) { | ||
console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")'); | ||
}; | ||
page.onConsoleMessage = function (msg, lineNum, sourceId) { | ||
log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")') | ||
} | ||
console.log('Num files to execute : ' + files.length) | ||
log('Num files to execute : ' + files.length) | ||
files.forEach(function(file) { | ||
files.forEach(function (file) { | ||
var contents = fs.read(file) | ||
, filename = file.split(fs.separator).slice(-1) | ||
, oParser = new DOMParser() | ||
, oDOM | ||
, svgContent | ||
, allElements; | ||
var filename = file.split(fs.separator).slice(-1) | ||
var oParser = new window.DOMParser() | ||
var oDOM | ||
var svgContent | ||
console.log('ready to execute png: ' + filename + '.png ') | ||
log('ready to execute: ' + file) | ||
@@ -88,50 +86,43 @@ // this JS is executed in this statement is sandboxed, even though it doesn't | ||
svgContent = page.evaluate(executeInPage, { | ||
contents : contents, | ||
ganttConfig : options.ganttConfig, | ||
sequenceConfig : options.sequenceConfig, | ||
confWidth : options.width | ||
contents: contents, | ||
ganttConfig: options.ganttConfig, | ||
sequenceConfig: options.sequenceConfig, | ||
confWidth: options.width | ||
}) | ||
oDOM = oParser.parseFromString(svgContent, "text/xml") | ||
oDOM = oParser.parseFromString(svgContent, 'text/xml') | ||
resolveSVGElement(oDOM.firstChild) | ||
setSVGStyle(oDOM.firstChild, options.css) | ||
// traverse the SVG, and replace all foreignObject elements | ||
// can be removed when https://github.com/knsv/mermaid/issues/58 is resolved | ||
allElements = traverse(oDOM) | ||
for (var i = 0, len = allElements.length; i < len; i++) { | ||
resolveForeignObjects(allElements[i]) | ||
} | ||
var outputPath=options.outputDir + fs.separator + filename + options.outputSuffix; | ||
var outputPath = options.outputDir + fs.separator + filename + options.outputSuffix | ||
if (options.png) { | ||
page.viewportSize = { | ||
width: ~~oDOM.documentElement.attributes.getNamedItem('width').value | ||
, height: ~~oDOM.documentElement.attributes.getNamedItem('height').value | ||
width: ~~oDOM.documentElement.attributes.getNamedItem('width').value, | ||
height: ~~oDOM.documentElement.attributes.getNamedItem('height').value | ||
} | ||
page.render(outputPath+'.png') | ||
console.log('saved png: ' + filename + '.png') | ||
page.render(outputPath + '.png') | ||
log('saved png: ' + outputPath + '.png') | ||
} | ||
if (options.svg) { | ||
var serialize = new XMLSerializer(); | ||
fs.write(outputPath+'.svg' | ||
, serialize.serializeToString(oDOM)+'\n' | ||
var serialize = new window.XMLSerializer() | ||
fs.write(outputPath + '.svg' | ||
, serialize.serializeToString(oDOM) + '\n' | ||
, 'w' | ||
) | ||
log('saved svg: ' + filename + '.svg') | ||
log('saved svg: ' + outputPath + '.svg') | ||
} | ||
}) | ||
phantom.exit() | ||
window.phantom.exit() | ||
function logger(_verbose) { | ||
function logger (_verbose) { | ||
var verbose = _verbose | ||
return function(_message, _level) { | ||
var level = level | ||
, message = _message | ||
, log | ||
return function (_message, _level) { | ||
var level = _level | ||
var message = _message | ||
var log | ||
@@ -146,93 +137,42 @@ log = level === 'error' ? system.stderr : system.stdout | ||
function traverse(obj){ | ||
var tree = [] | ||
tree.push(obj) | ||
visit(obj) | ||
function visit(node) { | ||
if (node && node.hasChildNodes()) { | ||
var child = node.firstChild | ||
while (child) { | ||
if (child.nodeType === 1 && child.nodeName != 'SCRIPT'){ | ||
tree.push(child) | ||
visit(child) | ||
} | ||
child = child.nextSibling | ||
} | ||
} | ||
function resolveSVGElement (element) { | ||
var prefix = { | ||
xmlns: 'http://www.w3.org/2000/xmlns/', | ||
xlink: 'http://www.w3.org/1999/xlink', | ||
svg: 'http://www.w3.org/2000/svg' | ||
} | ||
return tree | ||
} | ||
function resolveSVGElement(element) { | ||
var prefix = { | ||
xmlns: "http://www.w3.org/2000/xmlns/" | ||
, xlink: "http://www.w3.org/1999/xlink" | ||
, svg: "http://www.w3.org/2000/svg" | ||
} | ||
, doctype = '<!DOCTYPE svg:svg PUBLIC' | ||
+ ' "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"' | ||
+ ' "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">' | ||
element.setAttribute("version", "1.1") | ||
element.setAttribute('version', '1.1') | ||
// removing attributes so they aren't doubled up | ||
element.removeAttribute("xmlns") | ||
element.removeAttribute("xlink") | ||
element.removeAttribute('xmlns') | ||
element.removeAttribute('xlink') | ||
// These are needed for the svg | ||
if (!element.hasAttributeNS(prefix.xmlns, "xmlns")) { | ||
element.setAttributeNS(prefix.xmlns, "xmlns", prefix.svg) | ||
if (!element.hasAttributeNS(prefix.xmlns, 'xmlns')) { | ||
element.setAttributeNS(prefix.xmlns, 'xmlns', prefix.svg) | ||
} | ||
if (!element.hasAttributeNS(prefix.xmlns, "xmlns:xlink")) { | ||
element.setAttributeNS(prefix.xmlns, "xmlns:xlink", prefix.xlink) | ||
if (!element.hasAttributeNS(prefix.xmlns, 'xmlns:xlink')) { | ||
element.setAttributeNS(prefix.xmlns, 'xmlns:xlink', prefix.xlink) | ||
} | ||
} | ||
function setSVGStyle(svg, css) { | ||
if (!css || !svg) {return} | ||
var styles=svg.getElementsByTagName('style'); | ||
if (!styles || styles.length==0) { return } | ||
styles[0].textContent = css; | ||
function setSVGStyle (svg, css) { | ||
if (!css || !svg) { return } | ||
var styles = svg.getElementsByTagName('style') | ||
if (!styles || styles.length === 0) { return } | ||
styles[0].textContent = css | ||
} | ||
function resolveForeignObjects(element) { | ||
return; | ||
var children | ||
, textElement | ||
, textSpan | ||
// The sandboxed function that's executed in-page by phantom | ||
function executeInPage (data) { | ||
var xmlSerializer = new window.XMLSerializer() | ||
var contents = data.contents | ||
var sequenceConfig = JSON.stringify(data.sequenceConfig) | ||
var ganttConfig = JSON.stringify(data.ganttConfig).replace(/"(function.*})"/, '$1') | ||
var svg | ||
var svgValue | ||
var boundingBox | ||
var width | ||
var height | ||
var confWidth = data.confWidth | ||
if (element.tagName === 'foreignObject') { | ||
textElement = document.createElement('text') | ||
textSpan = document.createElement('tspan') | ||
textSpan.setAttribute( | ||
'style' | ||
, 'font-size: 11.5pt; font-family: "sans-serif";' | ||
) | ||
textSpan.setAttribute('x', 0) | ||
textSpan.setAttribute('y', 14.5) | ||
textSpan.textContent = element.textContent | ||
textElement.appendChild(textSpan) | ||
element.parentElement.appendChild(textElement) | ||
element.parentElement.removeChild(element) | ||
} | ||
} | ||
// The sandboxed function that's executed in-page by phantom | ||
function executeInPage(data) { | ||
var xmlSerializer = new XMLSerializer() | ||
, contents = data.contents | ||
, sequenceConfig = JSON.stringify(data.sequenceConfig) | ||
, ganttConfig = JSON.stringify(data.ganttConfig).replace(/"(function.*})"/, "$1") | ||
, toRemove | ||
, el | ||
, elContent | ||
, svg | ||
, svgValue | ||
, boundingBox | ||
, width | ||
, height | ||
, confWidth = data.confWidth | ||
var toRemove = document.getElementsByClassName('mermaid') | ||
@@ -245,34 +185,33 @@ if (toRemove && toRemove.length) { | ||
var el = document.createElement("div") | ||
var el = document.createElement('div') | ||
el.className = 'mermaid' | ||
el.appendChild(document.createTextNode(contents)) | ||
document.body.appendChild(el) | ||
var config = { | ||
sequenceDiagram: JSON.parse(sequenceConfig), | ||
flowchart: {useMaxWidth: false}, | ||
flowchart: { useMaxWidth: false }, | ||
logLevel: 1 | ||
}; | ||
mermaid.initialize(config); | ||
var sc = document.createElement("script") | ||
} | ||
window.mermaid.initialize(config) | ||
var sc = document.createElement('script') | ||
sc.appendChild(document.createTextNode('mermaid.ganttConfig = ' + ganttConfig + ';')) | ||
document.body.appendChild(sc) | ||
mermaid.init(); | ||
window.mermaid.init() | ||
svg = document.querySelector('svg') | ||
boundingBox = svg.getBoundingClientRect(); // the initial bonding box of the svg | ||
width = boundingBox.width * 1.5; // adding the scale factor for consistency with output in chrome browser | ||
height = boundingBox.height * 1.5; // adding the scale factor for consistency with output in chrome browser | ||
boundingBox = svg.getBoundingClientRect() // the initial bonding box of the svg | ||
width = boundingBox.width * 1.5 // adding the scale factor for consistency with output in chrome browser | ||
height = boundingBox.height * 1.5 // adding the scale factor for consistency with output in chrome browser | ||
var scalefactor = confWidth / (width - 8) | ||
var scalefactor = confWidth/(width-8); | ||
// resizing the body to fit the svg | ||
document.body.setAttribute( | ||
'style' | ||
, 'width: ' + (confWidth-8) + '; height: ' + (height*scalefactor) + ';' | ||
, 'width: ' + (confWidth - 8) + '; height: ' + (height * scalefactor) + ';' | ||
) | ||
@@ -282,3 +221,3 @@ // resizing the svg via css for consistent display | ||
'style' | ||
, 'width: ' + (confWidth-8) + '; height: ' + (height*scalefactor) + ';' | ||
, 'width: ' + (confWidth - 8) + '; height: ' + (height * scalefactor) + ';' | ||
) | ||
@@ -293,8 +232,7 @@ | ||
'height' | ||
, height*scalefactor | ||
, height * scalefactor | ||
) | ||
svgValue = xmlSerializer.serializeToString(svg)+"\n"; | ||
//console.log('confWidth: '+document.head.outerHTML); | ||
svgValue = xmlSerializer.serializeToString(svg) + '\n' | ||
return svgValue | ||
} |
181
package.json
@@ -1,5 +0,5 @@ | ||
{ | ||
{ | ||
"name": "mermaid", | ||
"version": "7.0.0", | ||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams and gantt charts.", | ||
"version": "7.0.1", | ||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.", | ||
"main": "src/mermaid.js", | ||
@@ -11,3 +11,5 @@ "keywords": [ | ||
"sequence diagram", | ||
"gantt" | ||
"gantt", | ||
"class diagram", | ||
"git graph" | ||
], | ||
@@ -18,18 +20,16 @@ "bin": { | ||
"scripts": { | ||
"watch": "yarn build -- --watch", | ||
"build": "node -r babel-register ./node_modules/.bin/webpack --progress --colors", | ||
"dist": "node -r babel-register ./node_modules/.bin/webpack --progress --colors -p --config webpack.config.prod.js", | ||
"upgrade": "rm -rf node_modules && rm yarn.lock && yarn install && ncu -ua && yarn upgrade && yarn remove d3 && yarn add d3@3.5.17", | ||
"lint": "node_modules/.bin/standard", | ||
"karma": "node node_modules/karma/bin/karma start karma.conf.js --single-run", | ||
"tape": "node node_modules/tape/bin/tape test/cli_test-*.js", | ||
"test": "yarn tape && yarn karma", | ||
"live": "live-server ./test/examples", | ||
"lint": "node node_modules/eslint/bin/eslint.js src", | ||
"jison": "gulp jison_legacy", | ||
"karma": "node node_modules/karma/bin/karma start karma.conf.js --single-run", | ||
"watch": "source ./scripts/watch.sh", | ||
"live_server": "gulp live-server", | ||
"doc": "rm -r build;rm -r dist/www;gulp vartree;cp dist/www/all.html ../mermaid-pages/index.html;cp dist/mermaid.js ../mermaid-pages/javascripts/lib;cp dist/mermaid.forest.css ../mermaid-pages/stylesheets", | ||
"tape": "node node_modules/tape/bin/tape test/cli_test-*.js", | ||
"jasmine": "npm run jison &&node node_modules/jasmine-es6/bin/jasmine.js", | ||
"pretest": "npm run jison", | ||
"test": "npm run dist && npm run karma && npm run tape", | ||
"dist-slim-mermaid": "node node_modules/browserify/bin/cmd.js src/mermaid.js -t babelify -s mermaid -o dist/mermaid.slim.js -x d3 && cat dist/mermaid.slim.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaid.slim.min.js", | ||
"dist-slim-mermaidAPI": "node node_modules/browserify/bin/cmd.js src/mermaidAPI.js -t babelify -s mermaidAPI -o dist/mermaidAPI.slim.js -x d3 && cat dist/mermaidAPI.slim.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaidAPI.slim.min.js", | ||
"dist-mermaid": "node node_modules/browserify/bin/cmd.js src/mermaid.js -t babelify -s mermaid -o dist/mermaid.js && cat dist/mermaid.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaid.min.js", | ||
"dist-mermaid-nomin": "node node_modules/browserify/bin/cmd.js src/mermaid.js -t babelify -s mermaid -o dist/mermaid.js", | ||
"dist-mermaidAPI": "node node_modules/browserify/bin/cmd.js src/mermaidAPI.js -t babelify -s mermaidAPI -o dist/mermaidAPI.js && cat dist/mermaidAPI.js | node node_modules/uglifyjs/bin/uglifyjs -mc > dist/mermaidAPI.min.js", | ||
"dist": "npm run dist-slim-mermaid && npm run dist-slim-mermaidAPI && npm run dist-mermaid && npm run dist-mermaidAPI" | ||
"pretest": "yarn lint", | ||
"prepublishOnly": "yarn build && yarn dist && yarn test" | ||
}, | ||
@@ -42,87 +42,88 @@ "repository": { | ||
"license": "MIT", | ||
"standard": { | ||
"ignore": [ | ||
"**/parser/*.js", | ||
"dist/**/*.js", | ||
"docs/**/*.js", | ||
"editor/**/*.js" | ||
] | ||
}, | ||
"dependencies": { | ||
"chalk": "^0.5.1", | ||
"d3": "3.5.6", | ||
"chalk": "^1.1.3", | ||
"d3": "3.5.17", | ||
"dagre": "^0.7.4", | ||
"dagre-d3": "0.4.10", | ||
"he": "^0.5.0", | ||
"lodash": "^4.6.1", | ||
"minimist": "^1.1.0", | ||
"mkdirp": "^0.5.0", | ||
"moment": "^2.9.0", | ||
"semver": "^4.1.1", | ||
"which": "^1.0.8" | ||
"dagre-d3-renderer": "0.1.6", | ||
"he": "^1.1.1", | ||
"lodash": "^4.17.4", | ||
"minimist": "^1.2.0", | ||
"mkdirp": "^0.5.1", | ||
"moment": "^2.18.1", | ||
"semver": "^5.3.0", | ||
"which": "^1.2.14" | ||
}, | ||
"devDependencies": { | ||
"async": "^0.9.0", | ||
"babel-eslint": "^4.1.3", | ||
"babelify": "^6.4.0", | ||
"browserify": "~6.2.0", | ||
"clone": "^0.2.0", | ||
"codeclimate-test-reporter": "0.0.4", | ||
"dateformat": "^1.0.11", | ||
"dox": "^0.8.0", | ||
"eslint": "^1.6.0", | ||
"eslint-watch": "^2.1.2", | ||
"event-stream": "^3.2.0", | ||
"foundation": "^4.2.1-1", | ||
"front-matter": "^0.2.0", | ||
"gulp": "~3.9.0", | ||
"gulp-bower": "0.0.10", | ||
"gulp-browserify": "^0.5.0", | ||
"gulp-bump": "^0.1.11", | ||
"gulp-concat": "~2.4.1", | ||
"gulp-data": "^1.1.1", | ||
"async": "^2.4.1", | ||
"babel-core": "^6.24.1", | ||
"babel-loader": "^7.0.0", | ||
"babel-plugin-transform-remove-strict-mode": "^0.0.2", | ||
"babel-preset-env": "^1.5.1", | ||
"clone": "^2.1.1", | ||
"codeclimate-test-reporter": "0.4.1", | ||
"css-loader": "^0.28.4", | ||
"dox": "^0.9.0", | ||
"event-stream": "^3.3.4", | ||
"extract-text-webpack-plugin": "^2.1.0", | ||
"front-matter": "^2.1.2", | ||
"gulp": "~3.9.1", | ||
"gulp-bower": "0.0.13", | ||
"gulp-bump": "^2.7.0", | ||
"gulp-concat": "~2.6.1", | ||
"gulp-data": "^1.2.1", | ||
"gulp-dox": "^0.1.6", | ||
"gulp-ext-replace": "^0.2.0", | ||
"gulp-ext-replace": "^0.3.0", | ||
"gulp-filelog": "^0.4.1", | ||
"gulp-front-matter": "^1.2.3", | ||
"gulp-hogan": "^1.1.0", | ||
"gulp-if": "^1.2.5", | ||
"gulp-insert": "^0.4.0", | ||
"gulp-istanbul": "^0.4.0", | ||
"gulp-jasmine": "~2.1.0", | ||
"gulp-jasmine-browser": "^0.2.3", | ||
"gulp-front-matter": "^1.3.0", | ||
"gulp-hogan": "^2.0.0", | ||
"gulp-if": "^2.0.2", | ||
"gulp-insert": "^0.5.0", | ||
"gulp-istanbul": "^1.1.1", | ||
"gulp-jasmine": "~2.4.2", | ||
"gulp-jasmine-browser": "^1.7.1", | ||
"gulp-jison": "~1.2.0", | ||
"gulp-jshint": "^1.9.0", | ||
"gulp-less": "^3.0.1", | ||
"gulp-livereload": "^3.8.0", | ||
"gulp-less": "^3.3.0", | ||
"gulp-livereload": "^3.8.1", | ||
"gulp-marked": "^1.0.0", | ||
"gulp-mdvars": "^2.0.0", | ||
"gulp-qunit": "~1.2.1", | ||
"gulp-rename": "~1.2.0", | ||
"gulp-shell": "^0.2.10", | ||
"gulp-tag-version": "^1.2.1", | ||
"gulp-uglify": "~1.0.1", | ||
"gulp-util": "^3.0.7", | ||
"gulp-qunit": "~1.5.0", | ||
"gulp-rename": "~1.2.2", | ||
"gulp-shell": "^0.6.3", | ||
"gulp-tag-version": "^1.3.0", | ||
"gulp-util": "^3.0.8", | ||
"gulp-vartree": "^2.0.1", | ||
"hogan.js": "^3.0.2", | ||
"jasmine": "2.3.2", | ||
"jasmine-es6": "0.0.18", | ||
"jison": "zaach/jison", | ||
"jsdom": "^7.0.2", | ||
"jshint-stylish": "^2.0.1", | ||
"karma": "^0.13.15", | ||
"karma-babel-preprocessor": "^6.0.1", | ||
"karma-browserify": "^4.4.0", | ||
"karma-jasmine": "^0.3.6", | ||
"karma-phantomjs-launcher": "^0.2.1", | ||
"live-server": "^0.9.0", | ||
"map-stream": "0.0.6", | ||
"marked": "^0.3.2", | ||
"mock-browser": "^0.91.34", | ||
"path": "^0.4.9", | ||
"phantomjs": "^2.1.3", | ||
"proxyquire": "^1.7.3", | ||
"proxyquire-universal": "^1.0.8", | ||
"proxyquireify": "^3.0.0", | ||
"require-dir": "^0.3.0", | ||
"rewire": "^2.1.3", | ||
"rimraf": "^2.2.8", | ||
"tape": "^3.0.3", | ||
"testdom": "^2.0.0", | ||
"uglifyjs": "^2.4.10", | ||
"vinyl-source-stream": "^1.1.0", | ||
"watchify": "^3.6.1" | ||
"inject-loader": "^3.0.0", | ||
"jasmine": "2.6.0", | ||
"jasmine-es6": "0.4.0", | ||
"jison": "^0.4.17", | ||
"jsdom": "^11.0.0", | ||
"karma": "^1.7.0", | ||
"karma-chrome-launcher": "^2.1.1", | ||
"karma-jasmine": "^1.1.0", | ||
"karma-webpack": "^2.0.3", | ||
"less": "^2.7.2", | ||
"less-loader": "^4.0.4", | ||
"live-server": "^1.2.0", | ||
"map-stream": "0.0.7", | ||
"marked": "^0.3.6", | ||
"mock-browser": "^0.92.14", | ||
"npm-check-updates": "^2.11.2", | ||
"phantomjs-prebuilt": "^2.1.14", | ||
"require-dir": "^0.3.1", | ||
"rimraf": "^2.6.1", | ||
"standard": "^10.0.2", | ||
"style-loader": "^0.18.1", | ||
"tape": "^4.6.3", | ||
"webpack": "^2.6.1", | ||
"webpack-node-externals": "^1.6.0" | ||
} | ||
} |
113
README.md
@@ -0,5 +1,4 @@ | ||
# mermaid [![Build Status](https://travis-ci.org/knsv/mermaid.svg?branch=master)](https://travis-ci.org/knsv/mermaid) | ||
mermaid [![Build Status](https://travis-ci.org/knsv/mermaid.svg?branch=master)](https://travis-ci.org/knsv/mermaid) [![Code Climate](https://codeclimate.com/github/knsv/mermaid/badges/gpa.svg)](https://codeclimate.com/github/knsv/mermaid) | ||
======= | ||
[![Code Climate](https://codeclimate.com/github/knsv/mermaid/badges/gpa.svg)](https://codeclimate.com/github/knsv/mermaid) | ||
[![Join the chat at https://gitter.im/knsv/mermaid](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/knsv/mermaid?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
@@ -61,3 +60,3 @@ | ||
classDiagram | ||
Class01 <|-- AveryLongClass : Cool | ||
Class01 <|-- AveryLongClass : Cool | ||
Class03 *-- Class04 | ||
@@ -74,3 +73,3 @@ Class05 o-- Class06 | ||
Class01 : int gorilla | ||
Class08 <--> C2: Cool label | ||
Class08 <--> C2: Cool label | ||
</code> | ||
@@ -83,4 +82,34 @@ </pre> | ||
</tr> | ||
<tr> | ||
<td> | ||
<pre> | ||
<code> | ||
gitGraph : | ||
options | ||
{ | ||
"key": "value", | ||
"nodeWidth": 150, | ||
"nodeSpacing" : 150 | ||
} | ||
end | ||
commit | ||
branch newbranch | ||
checkout newbranch | ||
commit | ||
commit | ||
checkout master | ||
commit | ||
commit | ||
merge newbranch | ||
</code> | ||
</pre> | ||
</td> | ||
<td> | ||
<img src='./docs/img/gitgraph.mm.png' alt='Example 4'> | ||
</td> | ||
</tr> | ||
</table> | ||
## Further reading | ||
@@ -94,10 +123,76 @@ | ||
# Request for assistance | ||
Things are piling up and I have hard time keeping up. To remedy this | ||
it would be great if we could form a core team of developers to cooperate | ||
with the future development mermaid. | ||
As part of this team you would get write access to the repository and would | ||
represent the project when answering questions and issues. | ||
Together we could continue the work with things like: | ||
* port the code to es6 | ||
* improved support for webpack | ||
* modernizing the build | ||
* adding more typers of diagrams like mindmaps, ert digrams etc | ||
* improving existing diagrams | ||
Don't hesitate to contact me if you want to get involved. | ||
# For contributors | ||
## Setup | ||
Make sure you have Chrome browser installed, this project uses Chrome headless to running tests. | ||
yarn install | ||
## Build | ||
yarn build | ||
If you want real time incremental build: | ||
yarn watch | ||
## Lint | ||
yarn lint | ||
We use [JavaScript Standard Style](https://github.com/feross/standard). | ||
We recommend you installing [editor plugins](https://github.com/feross/standard#are-there-text-editor-plugins) so you can get real time lint result. | ||
## Test | ||
yarn test | ||
Manual test in browser: | ||
open dist/demo/index.html | ||
Manual test in Node.js: | ||
node dist/demo/index.js | ||
## Distribtion | ||
yarn dist | ||
Command above generates files into the `dist` folder, then you can publish them to npmjs.org. | ||
# Credits | ||
Many thanks to the [d3](http://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects for providing | ||
the graphical layout and drawing libraries! Thanks also to the | ||
[js-sequence-diagram](http://bramp.github.io/js-sequence-diagrams) project for usage of the grammar for the | ||
sequence diagrams. Thanks to Jessica Peter for inspiration and starting point for gantt rendering. | ||
Many thanks to the [d3](http://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects for providing the graphical layout and drawing libraries! | ||
Thanks also to the [js-sequence-diagram](http://bramp.github.io/js-sequence-diagrams) project for usage of the grammar for the sequence diagrams. Thanks to Jessica Peter for inspiration and starting point for gantt rendering. | ||
*Mermaid was created by Knut Sveidqvist for easier documentation.* | ||
Knut has not done all work by him self, here is the full list of the projects [contributors](https://github.com/knsv/mermaid/graphs/contributors). |
853
src/d3.js
@@ -1,31 +0,6 @@ | ||
/* global window */ | ||
//log.debug('Setting up d3'); | ||
var d3; | ||
const d3 = require('d3') | ||
if (typeof require!=='undefined') { | ||
try { | ||
d3 = require('d3'); | ||
} catch (e) { | ||
//log.debug('Exception ... but ok'); | ||
//log.debug(e); | ||
} | ||
} | ||
module.exports = d3; | ||
//log.debug(d3); | ||
if (!d3) { | ||
//if(typeof window !== 'undefined') | ||
d3 = window.d3; | ||
} | ||
//if(typeof window === 'undefined'){ | ||
// window = {}; | ||
// window.d3 = d3; | ||
//} | ||
//log.debug('window'); | ||
//log.debug(window); | ||
module.exports = d3; | ||
/* jshint ignore:start */ | ||
/* | ||
D3 Text Wrap | ||
@@ -38,458 +13,436 @@ By Vijith Assar | ||
Detailed instructions at http://www.github.com/vijithassar/d3textwrap | ||
*/ | ||
(function() { | ||
(function () { | ||
// set this variable to a string value to always force a particular | ||
// wrap method for development purposes, for example to check tspan | ||
// rendering using a foreignobject-enabled browser. set to 'tspan' to | ||
// use tspans and 'foreignobject' to use foreignobject | ||
var forceWrapMethod = false // by default no wrap method is forced | ||
forceWrapMethod = 'tspans' // uncomment this statement to force tspans | ||
// force_wrap_method = 'foreignobjects'; // uncomment this statement to force foreignobjects | ||
// set this variable to a string value to always force a particular | ||
// wrap method for development purposes, for example to check tspan | ||
// rendering using a foreignobject-enabled browser. set to 'tspan' to | ||
// use tspans and 'foreignobject' to use foreignobject | ||
var force_wrap_method = false; // by default no wrap method is forced | ||
force_wrap_method = 'tspans'; // uncomment this statement to force tspans | ||
// force_wrap_method = 'foreignobjects'; // uncomment this statement to force foreignobjects | ||
// exit immediately if something in this location | ||
// has already been defined; the plugin will defer to whatever | ||
// else you're doing in your code | ||
if (d3.selection.prototype.textwrap) { | ||
return false | ||
} | ||
// exit immediately if something in this location | ||
// has already been defined; the plugin will defer to whatever | ||
// else you're doing in your code | ||
if(d3.selection.prototype.textwrap) { | ||
return false; | ||
} | ||
// double check the force_wrap_method flag | ||
// and reset if someone screwed up the above | ||
// settings | ||
if (typeof forceWrapMethod === 'undefined') { | ||
forceWrapMethod = false | ||
} | ||
// double check the force_wrap_method flag | ||
// and reset if someone screwed up the above | ||
// settings | ||
if(typeof force_wrap_method == 'undefined') { | ||
var force_wrap_method = false; | ||
} | ||
// create the plugin method twice, both for regular use | ||
// and again for use inside the enter() selection | ||
d3.selection.prototype.textwrap = d3.selection.enter.prototype.textwrap = function (bounds, padding) { | ||
// default value of padding is zero if it's undefined | ||
padding = parseInt(padding) || 0 | ||
// create the plugin method twice, both for regular use | ||
// and again for use inside the enter() selection | ||
d3.selection.prototype.textwrap = d3.selection.enter.prototype.textwrap = function(bounds, padding) { | ||
// save callee into a variable so we can continue to refer to it | ||
// as the function scope changes | ||
var selection = this | ||
// default value of padding is zero if it's undefined | ||
var padding = parseInt(padding) || 0; | ||
// create a variable to store desired return values in | ||
var returnValue | ||
// save callee into a variable so we can continue to refer to it | ||
// as the function scope changes | ||
var selection = this; | ||
// extract wrap boundaries from any d3-selected rect and return them | ||
// in a format that matches the simpler object argument option | ||
var extractBounds = function (bounds) { | ||
// discard the nested array wrappers added by d3 | ||
var boundingRect = bounds[0][0] | ||
// sanitize the svg element name so we can test against it | ||
var elementType = boundingRect.tagName.toString() | ||
// if it's not a rect, exit | ||
if (elementType !== 'rect') { | ||
return false | ||
// if it's a rect, proceed to extracting the position attributes | ||
} else { | ||
var boundsExtracted = {} | ||
boundsExtracted.x = d3.select(boundingRect).attr('x') || 0 | ||
boundsExtracted.y = d3.select(boundingRect).attr('y') || 0 | ||
boundsExtracted.width = d3.select(boundingRect).attr('width') || 0 | ||
boundsExtracted.height = d3.select(boundingRect).attr('height') || 0 | ||
// also pass along the getter function | ||
boundsExtracted.attr = bounds.attr | ||
} | ||
return boundsExtracted | ||
} | ||
// create a variable to store desired return values in | ||
var return_value; | ||
// extract wrap boundaries from any d3-selected rect and return them | ||
// in a format that matches the simpler object argument option | ||
var extract_bounds = function(bounds) { | ||
// discard the nested array wrappers added by d3 | ||
var bounding_rect = bounds[0][0]; | ||
// sanitize the svg element name so we can test against it | ||
var element_type = bounding_rect.tagName.toString(); | ||
// if it's not a rect, exit | ||
if(element_type !== 'rect') { | ||
return false; | ||
// if it's a rect, proceed to extracting the position attributes | ||
} else { | ||
var bounds_extracted = {}; | ||
bounds_extracted.x = d3.select(bounding_rect).attr('x') || 0; | ||
bounds_extracted.y = d3.select(bounding_rect).attr('y') || 0; | ||
bounds_extracted.width = d3.select(bounding_rect).attr('width') || 0; | ||
bounds_extracted.height = d3.select(bounding_rect).attr('height') || 0; | ||
// also pass along the getter function | ||
bounds_extracted.attr = bounds.attr; | ||
} | ||
return bounds_extracted; | ||
// double check the input argument for the wrapping | ||
// boundaries to make sure it actually contains all | ||
// the information we'll need in order to wrap successfully | ||
var verifyBounds = function (bounds) { | ||
// quickly add a simple getter method so you can use either | ||
// bounds.x or bounds.attr('x') as your notation, | ||
// the latter being a common convention among D3 | ||
// developers | ||
if (!bounds.attr) { | ||
bounds.attr = function (property) { | ||
if (this[property]) { | ||
return this[property] | ||
} | ||
} | ||
} | ||
// if it's an associative array, make sure it has all the | ||
// necessary properties represented directly | ||
if ( | ||
(typeof bounds === 'object') && | ||
(typeof bounds.x !== 'undefined') && | ||
(typeof bounds.y !== 'undefined') && | ||
(typeof bounds.width !== 'undefined') && | ||
(typeof bounds.height !== 'undefined') | ||
// if that's the case, then the bounds are fine | ||
) { | ||
// return the lightly modified bounds | ||
return bounds | ||
// if it's a numerically indexed array, assume it's a | ||
// d3-selected rect and try to extract the positions | ||
} else if ( | ||
// first try to make sure it's an array using Array.isArray | ||
( | ||
(typeof Array.isArray === 'function') && | ||
(Array.isArray(bounds)) | ||
) || | ||
// but since Array.isArray isn't always supported, fall | ||
// back to casting to the object to string when it's not | ||
(Object.prototype.toString.call(bounds) === '[object Array]') | ||
) { | ||
// once you're sure it's an array, extract the boundaries | ||
// from the rect | ||
var extractedBounds = extractBounds(bounds) | ||
return extractedBounds | ||
} else { | ||
// but if the bounds are neither an object nor a numerical | ||
// array, then the bounds argument is invalid and you'll | ||
// need to fix it | ||
return false | ||
} | ||
} | ||
// double check the input argument for the wrapping | ||
// boundaries to make sure it actually contains all | ||
// the information we'll need in order to wrap successfully | ||
var verify_bounds = function(bounds) { | ||
// quickly add a simple getter method so you can use either | ||
// bounds.x or bounds.attr('x') as your notation, | ||
// the latter being a common convention among D3 | ||
// developers | ||
if(!bounds.attr) { | ||
bounds.attr = function(property) { | ||
if(this[property]) { | ||
return this[property]; | ||
} | ||
} | ||
} | ||
// if it's an associative array, make sure it has all the | ||
// necessary properties represented directly | ||
if( | ||
(typeof bounds == 'object') && | ||
(typeof bounds.x !== 'undefined') && | ||
(typeof bounds.y !== 'undefined') && | ||
(typeof bounds.width !== 'undefined') && | ||
(typeof bounds.height !== 'undefined') | ||
// if that's the case, then the bounds are fine | ||
) { | ||
// return the lightly modified bounds | ||
return bounds; | ||
// if it's a numerically indexed array, assume it's a | ||
// d3-selected rect and try to extract the positions | ||
} else if ( | ||
// first try to make sure it's an array using Array.isArray | ||
( | ||
(typeof Array.isArray == 'function') && | ||
(Array.isArray(bounds)) | ||
) || | ||
// but since Array.isArray isn't always supported, fall | ||
// back to casting to the object to string when it's not | ||
(Object.prototype.toString.call(bounds) === '[object Array]') | ||
) { | ||
// once you're sure it's an array, extract the boundaries | ||
// from the rect | ||
var extracted_bounds = extract_bounds(bounds); | ||
return extracted_bounds; | ||
} else { | ||
// but if the bounds are neither an object nor a numerical | ||
// array, then the bounds argument is invalid and you'll | ||
// need to fix it | ||
return false; | ||
} | ||
} | ||
var applyPadding = function (bounds, padding) { | ||
var paddedBounds = bounds | ||
if (padding !== 0) { | ||
paddedBounds.x = parseInt(paddedBounds.x) + padding | ||
paddedBounds.y = parseInt(paddedBounds.y) + padding | ||
paddedBounds.width -= padding * 2 | ||
paddedBounds.height -= padding * 2 | ||
} | ||
return paddedBounds | ||
} | ||
var apply_padding = function(bounds, padding) { | ||
var padded_bounds = bounds; | ||
if(padding !== 0) { | ||
padded_bounds.x = parseInt(padded_bounds.x) + padding; | ||
padded_bounds.y = parseInt(padded_bounds.y) + padding; | ||
padded_bounds.width -= padding * 2; | ||
padded_bounds.height -= padding * 2; | ||
} | ||
return padded_bounds; | ||
} | ||
// verify bounds | ||
var verifiedBounds = verifyBounds(bounds) | ||
// verify bounds | ||
var verified_bounds = verify_bounds(bounds); | ||
// modify bounds if a padding value is provided | ||
if (padding) { | ||
verifiedBounds = applyPadding(verifiedBounds, padding) | ||
} | ||
// modify bounds if a padding value is provided | ||
if(padding) { | ||
verified_bounds = apply_padding(verified_bounds, padding); | ||
// check that we have the necessary conditions for this function to operate properly | ||
if ( | ||
// selection it's operating on cannot be not empty | ||
(selection.length === 0) || | ||
// d3 must be available | ||
(!d3) || | ||
// desired wrapping bounds must be provided as an input argument | ||
(!bounds) || | ||
// input bounds must validate | ||
(!verifiedBounds) | ||
) { | ||
// try to return the calling selection if possible | ||
// so as not to interfere with methods downstream in the | ||
// chain | ||
if (selection) { | ||
return selection | ||
// if all else fails, just return false. if you hit this point then you're | ||
// almost certainly trying to call the textwrap() method on something that | ||
// doesn't make sense! | ||
} else { | ||
return false | ||
} | ||
// if we've validated everything then we can finally proceed | ||
// to the meat of this operation | ||
} else { | ||
// reassign the verified bounds as the set we want | ||
// to work with from here on; this ensures that we're | ||
// using the same data structure for our bounds regardless | ||
// of whether the input argument was a simple object or | ||
// a d3 selection | ||
bounds = verifiedBounds | ||
// wrap using html and foreignObjects if they are supported | ||
var wrapWithForeignobjects = function (item) { | ||
// establish variables to quickly reference target nodes later | ||
var parent = d3.select(item[0].parentNode) | ||
var textNode = parent.select('text') | ||
var styledLineHeight = textNode.style('line-height') | ||
// extract our desired content from the single text element | ||
var textToWrap = textNode.text() | ||
// remove the text node and replace with a foreign object | ||
textNode.remove() | ||
var foreignObject = parent.append('foreignObject') | ||
// add foreign object and set dimensions, position, etc | ||
foreignObject | ||
.attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility') | ||
.attr('x', bounds.x) | ||
.attr('y', bounds.y) | ||
.attr('width', bounds.width) | ||
.attr('height', bounds.height) | ||
// insert an HTML div | ||
var wrapDiv = foreignObject | ||
.append('xhtml:div') | ||
// this class is currently hardcoded | ||
// probably not necessary but easy to | ||
// override using .classed() and for now | ||
// it's nice to avoid a litany of input | ||
// arguments | ||
.attr('class', 'wrapped') | ||
// set div to same dimensions as foreign object | ||
wrapDiv | ||
.style('height', bounds.height) | ||
.style('width', bounds.width) | ||
// insert text content | ||
.html(textToWrap) | ||
if (styledLineHeight) { | ||
wrapDiv.style('line-height', styledLineHeight) | ||
} | ||
returnValue = parent.select('foreignObject') | ||
} | ||
// check that we have the necessary conditions for this function to operate properly | ||
if( | ||
// selection it's operating on cannot be not empty | ||
(selection.length == 0) || | ||
// d3 must be available | ||
(!d3) || | ||
// desired wrapping bounds must be provided as an input argument | ||
(!bounds) || | ||
// input bounds must validate | ||
(!verified_bounds) | ||
// wrap with tspans if foreignObject is undefined | ||
var wrapWithTspans = function (item) { | ||
// operate on the first text item in the selection | ||
var textNode = item[0] | ||
var parent = textNode.parentNode | ||
var textNodeSelected = d3.select(textNode) | ||
// measure initial size of the text node as rendered | ||
var textNodeHeight = textNode.getBBox().height | ||
var textNodeWidth = textNode.getBBox().width | ||
// figure out the line height, either from rendered height | ||
// of the font or attached styling | ||
var lineHeight | ||
var renderedLineHeight = textNodeHeight | ||
var styledLineHeight = textNodeSelected.style('line-height') | ||
if ( | ||
(styledLineHeight) && | ||
(parseInt(styledLineHeight)) | ||
) { | ||
// try to return the calling selection if possible | ||
// so as not to interfere with methods downstream in the | ||
// chain | ||
if(selection) { | ||
return selection; | ||
// if all else fails, just return false. if you hit this point then you're | ||
// almost certainly trying to call the textwrap() method on something that | ||
// doesn't make sense! | ||
lineHeight = parseInt(styledLineHeight.replace('px', '')) | ||
} else { | ||
lineHeight = renderedLineHeight | ||
} | ||
// only fire the rest of this if the text content | ||
// overflows the desired dimensions | ||
if (textNodeWidth > bounds.width) { | ||
// store whatever is inside the text node | ||
// in a variable and then zero out the | ||
// initial content; we'll reinsert in a moment | ||
// using tspan elements. | ||
var textToWrap = textNodeSelected.text() | ||
textNodeSelected.text('') | ||
if (textToWrap) { | ||
// keep track of whether we are splitting by spaces | ||
// so we know whether to reinsert those spaces later | ||
var breakDelimiter | ||
// split at spaces to create an array of individual words | ||
var textToWrapArray | ||
if (textToWrap.indexOf(' ') !== -1) { | ||
breakDelimiter = ' ' | ||
textToWrapArray = textToWrap.split(' ') | ||
} else { | ||
return false; | ||
// if there are no spaces, figure out the split | ||
// points by comparing rendered text width against | ||
// bounds and translating that into character position | ||
// cuts | ||
breakDelimiter = '' | ||
var stringLength = textToWrap.length | ||
var numberOfSubstrings = Math.ceil(textNodeWidth / bounds.width) | ||
var spliceInterval = Math.floor(stringLength / numberOfSubstrings) | ||
if ( | ||
!(spliceInterval * numberOfSubstrings >= stringLength) | ||
) { | ||
numberOfSubstrings++ | ||
} | ||
textToWrapArray = [] | ||
var substring | ||
var startPosition | ||
for (var i = 0; i < numberOfSubstrings; i++) { | ||
startPosition = i * spliceInterval | ||
substring = textToWrap.substr(startPosition, spliceInterval) | ||
textToWrapArray.push(substring) | ||
} | ||
} | ||
// if we've validated everything then we can finally proceed | ||
// to the meat of this operation | ||
} else { | ||
// reassign the verified bounds as the set we want | ||
// to work with from here on; this ensures that we're | ||
// using the same data structure for our bounds regardless | ||
// of whether the input argument was a simple object or | ||
// a d3 selection | ||
bounds = verified_bounds; | ||
// new array where we'll store the words re-assembled into | ||
// substrings that have been tested against the desired | ||
// maximum wrapping width | ||
var substrings = [] | ||
// computed text length is arguably incorrectly reported for | ||
// all tspans after the first one, in that they will include | ||
// the width of previous separate tspans. to compensate we need | ||
// to manually track the computed text length of all those | ||
// previous tspans and substrings, and then use that to offset | ||
// the miscalculation. this then gives us the actual correct | ||
// position we want to use in rendering the text in the SVG. | ||
var totalOffset = 0 | ||
// object for storing the results of text length computations later | ||
var temp = {} | ||
// loop through the words and test the computed text length | ||
// of the string against the maximum desired wrapping width | ||
for (i = 0; i < textToWrapArray.length; i++) { | ||
var word = textToWrapArray[i] | ||
var previousString = textNodeSelected.text() | ||
var previousWidth = textNode.getComputedTextLength() | ||
// initialize the current word as the first word | ||
// or append to the previous string if one exists | ||
var newstring | ||
if (previousString) { | ||
newstring = previousString + breakDelimiter + word | ||
} else { | ||
newstring = word | ||
} | ||
// add the newest substring back to the text node and | ||
// measure the length | ||
textNodeSelected.text(newstring) | ||
var newWidth = textNode.getComputedTextLength() | ||
// adjust the length by the offset we've tracked | ||
// due to the misreported length discussed above | ||
// wrap using html and foreignObjects if they are supported | ||
var wrap_with_foreignobjects = function(item) { | ||
// establish variables to quickly reference target nodes later | ||
var parent = d3.select(item[0].parentNode); | ||
var text_node = parent.select('text'); | ||
var styled_line_height = text_node.style('line-height'); | ||
// extract our desired content from the single text element | ||
var text_to_wrap = text_node.text(); | ||
// remove the text node and replace with a foreign object | ||
text_node.remove(); | ||
var foreign_object = parent.append('foreignObject'); | ||
// add foreign object and set dimensions, position, etc | ||
foreign_object | ||
.attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility') | ||
.attr('x', bounds.x) | ||
.attr('y', bounds.y) | ||
.attr('width', bounds.width) | ||
.attr('height', bounds.height); | ||
// insert an HTML div | ||
var wrap_div = foreign_object | ||
.append('xhtml:div') | ||
// this class is currently hardcoded | ||
// probably not necessary but easy to | ||
// override using .classed() and for now | ||
// it's nice to avoid a litany of input | ||
// arguments | ||
.attr('class', 'wrapped'); | ||
// set div to same dimensions as foreign object | ||
wrap_div | ||
.style('height', bounds.height) | ||
.style('width', bounds.width) | ||
// insert text content | ||
.html(text_to_wrap); | ||
if(styled_line_height) { | ||
wrap_div.style('line-height', styled_line_height); | ||
// if our latest version of the string is too | ||
// big for the bounds, use the previous | ||
// version of the string (without the newest word | ||
// added) and use the latest word to restart the | ||
// process with a new tspan | ||
if (newWidth > bounds.width) { | ||
if ( | ||
(previousString) && | ||
(previousString !== '') | ||
) { | ||
totalOffset = totalOffset + previousWidth | ||
temp = { string: previousString, width: previousWidth, offset: totalOffset } | ||
substrings.push(temp) | ||
textNodeSelected.text('') | ||
textNodeSelected.text(word) | ||
// Handle case where there is just one more word to be wrapped | ||
if (i === textToWrapArray.length - 1) { | ||
newstring = word | ||
textNodeSelected.text(newstring) | ||
newWidth = textNode.getComputedTextLength() | ||
} | ||
} | ||
return_value = parent.select('foreignObject'); | ||
} | ||
// wrap with tspans if foreignObject is undefined | ||
var wrap_with_tspans = function(item) { | ||
// operate on the first text item in the selection | ||
var text_node = item[0]; | ||
var parent = text_node.parentNode; | ||
var text_node_selected = d3.select(text_node); | ||
// measure initial size of the text node as rendered | ||
var text_node_height = text_node.getBBox().height; | ||
var text_node_width = text_node.getBBox().width; | ||
// figure out the line height, either from rendered height | ||
// of the font or attached styling | ||
var line_height; | ||
var rendered_line_height = text_node_height; | ||
var styled_line_height = text_node_selected.style('line-height'); | ||
if( | ||
(styled_line_height) && | ||
(parseInt(styled_line_height)) | ||
} | ||
// if we're up to the last word in the array, | ||
// get the computed length as is without | ||
// appending anything further to it | ||
if (i === textToWrapArray.length - 1) { | ||
textNodeSelected.text('') | ||
var finalString = newstring | ||
if ( | ||
(finalString) && | ||
(finalString !== '') | ||
) { | ||
line_height = parseInt(styled_line_height.replace('px', '')); | ||
} else { | ||
line_height = rendered_line_height; | ||
if ((newWidth - totalOffset) > 0) { newWidth = newWidth - totalOffset } | ||
temp = { string: finalString, width: newWidth, offset: totalOffset } | ||
substrings.push(temp) | ||
} | ||
// only fire the rest of this if the text content | ||
// overflows the desired dimensions | ||
if(text_node_width > bounds.width) { | ||
// store whatever is inside the text node | ||
// in a variable and then zero out the | ||
// initial content; we'll reinsert in a moment | ||
// using tspan elements. | ||
var text_to_wrap = text_node_selected.text(); | ||
text_node_selected.text(''); | ||
if(text_to_wrap) { | ||
// keep track of whether we are splitting by spaces | ||
// so we know whether to reinsert those spaces later | ||
var break_delimiter; | ||
// split at spaces to create an array of individual words | ||
var text_to_wrap_array; | ||
if(text_to_wrap.indexOf(' ') !== -1) { | ||
var break_delimiter = ' '; | ||
text_to_wrap_array = text_to_wrap.split(' '); | ||
} else { | ||
// if there are no spaces, figure out the split | ||
// points by comparing rendered text width against | ||
// bounds and translating that into character position | ||
// cuts | ||
break_delimiter = ''; | ||
var string_length = text_to_wrap.length; | ||
var number_of_substrings = Math.ceil(text_node_width / bounds.width); | ||
var splice_interval = Math.floor(string_length / number_of_substrings); | ||
if( | ||
!(splice_interval * number_of_substrings >= string_length) | ||
) { | ||
number_of_substrings++; | ||
} | ||
var text_to_wrap_array = []; | ||
var substring; | ||
var start_position; | ||
for(var i = 0; i < number_of_substrings; i++) { | ||
start_position = i * splice_interval; | ||
substring = text_to_wrap.substr(start_position, splice_interval); | ||
text_to_wrap_array.push(substring); | ||
} | ||
} | ||
} | ||
} | ||
// new array where we'll store the words re-assembled into | ||
// substrings that have been tested against the desired | ||
// maximum wrapping width | ||
var substrings = []; | ||
// computed text length is arguably incorrectly reported for | ||
// all tspans after the first one, in that they will include | ||
// the width of previous separate tspans. to compensate we need | ||
// to manually track the computed text length of all those | ||
// previous tspans and substrings, and then use that to offset | ||
// the miscalculation. this then gives us the actual correct | ||
// position we want to use in rendering the text in the SVG. | ||
var total_offset = 0; | ||
// object for storing the results of text length computations later | ||
var temp = {}; | ||
// loop through the words and test the computed text length | ||
// of the string against the maximum desired wrapping width | ||
for(var i = 0; i < text_to_wrap_array.length; i++) { | ||
var word = text_to_wrap_array[i]; | ||
var previous_string = text_node_selected.text(); | ||
var previous_width = text_node.getComputedTextLength(); | ||
// initialize the current word as the first word | ||
// or append to the previous string if one exists | ||
var new_string; | ||
if(previous_string) { | ||
new_string = previous_string + break_delimiter + word; | ||
} else { | ||
new_string = word; | ||
} | ||
// add the newest substring back to the text node and | ||
// measure the length | ||
text_node_selected.text(new_string); | ||
var new_width = text_node.getComputedTextLength(); | ||
// adjust the length by the offset we've tracked | ||
// due to the misreported length discussed above | ||
var test_width = new_width - total_offset; | ||
// if our latest version of the string is too | ||
// big for the bounds, use the previous | ||
// version of the string (without the newest word | ||
// added) and use the latest word to restart the | ||
// process with a new tspan | ||
if(new_width > bounds.width) { | ||
if( | ||
(previous_string) && | ||
(previous_string !== '') | ||
) { | ||
total_offset = total_offset + previous_width; | ||
temp = {string: previous_string, width: previous_width, offset: total_offset}; | ||
substrings.push(temp); | ||
text_node_selected.text(''); | ||
text_node_selected.text(word); | ||
// Handle case where there is just one more word to be wrapped | ||
if(i == text_to_wrap_array.length - 1) { | ||
new_string = word; | ||
text_node_selected.text(new_string); | ||
new_width = text_node.getComputedTextLength(); | ||
} | ||
} | ||
} | ||
// if we're up to the last word in the array, | ||
// get the computed length as is without | ||
// appending anything further to it | ||
if(i == text_to_wrap_array.length - 1) { | ||
text_node_selected.text(''); | ||
var final_string = new_string; | ||
if( | ||
(final_string) && | ||
(final_string !== '') | ||
) { | ||
if((new_width - total_offset) > 0) {new_width = new_width - total_offset} | ||
temp = {string: final_string, width: new_width, offset: total_offset}; | ||
substrings.push(temp); | ||
} | ||
} | ||
} | ||
// append each substring as a tspan | ||
var current_tspan; | ||
var tspan_count; | ||
// double check that the text content has been removed | ||
// before we start appending tspans | ||
text_node_selected.text(''); | ||
for(var i = 0; i < substrings.length; i++) { | ||
var substring = substrings[i].string; | ||
if(i > 0) { | ||
var previous_substring = substrings[i - 1]; | ||
} | ||
// only append if we're sure it won't make the tspans | ||
// overflow the bounds. | ||
if((i) * line_height < bounds.height - (line_height * 1.5)) { | ||
current_tspan = text_node_selected.append('tspan') | ||
.text(substring); | ||
// vertical shift to all tspans after the first one | ||
current_tspan | ||
.attr('dy', function(d) { | ||
if(i > 0) { | ||
return line_height; | ||
} | ||
}); | ||
// shift left from default position, which | ||
// is probably based on the full length of the | ||
// text string until we make this adjustment | ||
current_tspan | ||
.attr('x', function() { | ||
var x_offset = bounds.x; | ||
if(padding) {x_offset += padding;} | ||
return x_offset; | ||
}); | ||
// .attr('dx', function() { | ||
// if(i == 0) { | ||
// var render_offset = 0; | ||
// } else if(i > 0) { | ||
// render_offset = substrings[i - 1].width; | ||
// render_offset = render_offset * -1; | ||
// } | ||
// return render_offset; | ||
// }); | ||
} | ||
} | ||
// append each substring as a tspan | ||
var currentTspan | ||
// var tspanCount | ||
// double check that the text content has been removed | ||
// before we start appending tspans | ||
textNodeSelected.text('') | ||
for (i = 0; i < substrings.length; i++) { | ||
substring = substrings[i].string | ||
// only append if we're sure it won't make the tspans | ||
// overflow the bounds. | ||
if ((i) * lineHeight < bounds.height - (lineHeight * 1.5)) { | ||
currentTspan = textNodeSelected.append('tspan') | ||
.text(substring) | ||
// vertical shift to all tspans after the first one | ||
currentTspan | ||
.attr('dy', function (d) { | ||
if (i > 0) { | ||
return lineHeight | ||
} | ||
} | ||
// position the overall text node, whether wrapped or not | ||
text_node_selected.attr('y', function() { | ||
var y_offset = bounds.y; | ||
// shift by line-height to move the baseline into | ||
// the bounds – otherwise the text baseline would be | ||
// at the top of the bounds | ||
if(line_height) {y_offset += line_height;} | ||
// shift by padding, if it's there | ||
if(padding) {y_offset += padding;} | ||
return y_offset; | ||
}); | ||
// shift to the right by the padding value | ||
text_node_selected.attr('x', function() { | ||
var x_offset = bounds.x; | ||
if(padding) {x_offset += padding;} | ||
return x_offset; | ||
}); | ||
// assign our modified text node with tspans | ||
// to the return value | ||
return_value = d3.select(parent).selectAll('text'); | ||
}) | ||
// shift left from default position, which | ||
// is probably based on the full length of the | ||
// text string until we make this adjustment | ||
currentTspan | ||
.attr('x', function () { | ||
var xOffset = bounds.x | ||
if (padding) { xOffset += padding } | ||
return xOffset | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
// position the overall text node, whether wrapped or not | ||
textNodeSelected.attr('y', function () { | ||
var yOffset = bounds.y | ||
// shift by line-height to move the baseline into | ||
// the bounds – otherwise the text baseline would be | ||
// at the top of the bounds | ||
if (lineHeight) { yOffset += lineHeight } | ||
// shift by padding, if it's there | ||
if (padding) { yOffset += padding } | ||
return yOffset | ||
}) | ||
// shift to the right by the padding value | ||
textNodeSelected.attr('x', function () { | ||
var xOffset = bounds.x | ||
if (padding) { xOffset += padding } | ||
return xOffset | ||
}) | ||
// variable used to hold the functions that let us | ||
// switch between the wrap methods | ||
var wrap_method; | ||
// assign our modified text node with tspans | ||
// to the return value | ||
returnValue = d3.select(parent).selectAll('text') | ||
} | ||
// if a wrap method if being forced, assign that | ||
// function | ||
if(force_wrap_method) { | ||
if(force_wrap_method == 'foreignobjects') { | ||
wrap_method = wrap_with_foreignobjects; | ||
} else if (force_wrap_method == 'tspans') { | ||
wrap_method = wrap_with_tspans; | ||
} | ||
} | ||
// variable used to hold the functions that let us | ||
// switch between the wrap methods | ||
var wrapMethod | ||
// if no wrap method is being forced, then instead | ||
// test for browser support of foreignobject and | ||
// use whichever wrap method makes sense accordingly | ||
if(!force_wrap_method) { | ||
if(typeof SVGForeignObjectElement !== 'undefined') { | ||
wrap_method = wrap_with_foreignobjects; | ||
} else { | ||
wrap_method = wrap_with_tspans; | ||
} | ||
} | ||
// if a wrap method if being forced, assign that | ||
// function | ||
if (forceWrapMethod) { | ||
if (forceWrapMethod === 'foreignobjects') { | ||
wrapMethod = wrapWithForeignobjects | ||
} else if (forceWrapMethod === 'tspans') { | ||
wrapMethod = wrapWithTspans | ||
} | ||
} | ||
// run the desired wrap function for each item | ||
// in the d3 selection that called .textwrap() | ||
for(var i = 0; i < selection.length; i++) { | ||
var item = selection[i]; | ||
wrap_method(item); | ||
} | ||
// if no wrap method is being forced, then instead | ||
// test for browser support of foreignobject and | ||
// use whichever wrap method makes sense accordingly | ||
if (!forceWrapMethod) { | ||
if (typeof SVGForeignObjectElement !== 'undefined') { | ||
wrapMethod = wrapWithForeignobjects | ||
} else { | ||
wrapMethod = wrapWithTspans | ||
} | ||
} | ||
// return the modified nodes so we can chain other | ||
// methods to them. | ||
return return_value; | ||
// run the desired wrap function for each item | ||
// in the d3 selection that called .textwrap() | ||
for (var i = 0; i < selection.length; i++) { | ||
var item = selection[i] | ||
wrapMethod(item) | ||
} | ||
} | ||
// return the modified nodes so we can chain other | ||
// methods to them. | ||
return returnValue | ||
} | ||
})(); | ||
/* jshint ignore:end */ | ||
} | ||
})() |
var Logger = require('../../logger'); | ||
var log = new Logger.Log(); | ||
var Logger = require('../../logger') | ||
var log = Logger.Log | ||
var relations = [] | ||
var relations = []; | ||
var classes; | ||
var idCache; | ||
var classes | ||
classes = { | ||
}; | ||
} | ||
// Functions to be run after graph rendering | ||
var funs = []; | ||
/** | ||
@@ -22,67 +18,64 @@ * Function called by parser when a node definition has been found. | ||
exports.addClass = function (id) { | ||
if(typeof classes[id] === 'undefined'){ | ||
classes[id] = { | ||
id:id, | ||
methods:[], | ||
members:[] | ||
}; | ||
if (typeof classes[id] === 'undefined') { | ||
classes[id] = { | ||
id: id, | ||
methods: [], | ||
members: [] | ||
} | ||
}; | ||
} | ||
} | ||
exports.clear = function () { | ||
relations = []; | ||
classes = {}; | ||
}; | ||
relations = [] | ||
classes = {} | ||
} | ||
module.exports.getClass = function (id) { | ||
return classes[id]; | ||
}; | ||
return classes[id] | ||
} | ||
module.exports.getClasses = function () { | ||
return classes; | ||
}; | ||
return classes | ||
} | ||
module.exports.getRelations = function () { | ||
return relations; | ||
}; | ||
return relations | ||
} | ||
exports.addRelation = function (relation) { | ||
log.warn('Adding relation: ' + JSON.stringify(relation)); | ||
exports.addClass(relation.id1); | ||
exports.addClass(relation.id2); | ||
log.warn('Adding relation: ' + JSON.stringify(relation)) | ||
exports.addClass(relation.id1) | ||
exports.addClass(relation.id2) | ||
relations.push(relation); | ||
}; | ||
relations.push(relation) | ||
} | ||
exports.addMembers = function (className, MembersArr) { | ||
var theClass = classes[className]; | ||
if(typeof MembersArr === 'string'){ | ||
if(MembersArr.substr(-1) === ')'){ | ||
theClass.methods.push(MembersArr); | ||
} | ||
else{ | ||
theClass.members.push(MembersArr); | ||
} | ||
var theClass = classes[className] | ||
if (typeof MembersArr === 'string') { | ||
if (MembersArr.substr(-1) === ')') { | ||
theClass.methods.push(MembersArr) | ||
} else { | ||
theClass.members.push(MembersArr) | ||
} | ||
}; | ||
} | ||
} | ||
exports.cleanupLabel = function (label) { | ||
if (label.substring(0, 1) === ':') { | ||
return label.substr(2).trim() | ||
} else { | ||
return label.trim() | ||
} | ||
} | ||
if(label.substring(0,1) === ':'){ | ||
return label.substr(2).trim(); | ||
} | ||
else{ | ||
return label.trim(); | ||
} | ||
}; | ||
exports.lineType = { | ||
LINE:0, | ||
DOTTED_LINE:1 | ||
}; | ||
LINE: 0, | ||
DOTTED_LINE: 1 | ||
} | ||
exports.relationType = { | ||
AGGREGATION:0, | ||
EXTENSION:1, | ||
COMPOSITION:2, | ||
DEPENDENCY:3 | ||
}; | ||
AGGREGATION: 0, | ||
EXTENSION: 1, | ||
COMPOSITION: 2, | ||
DEPENDENCY: 3 | ||
} |
@@ -0,1 +1,2 @@ | ||
/* eslint-env jasmine */ | ||
/** | ||
@@ -5,211 +6,210 @@ * Created by knut on 14-11-18. | ||
describe('class diagram, ', function () { | ||
describe('when parsing an info graph it', function () { | ||
var cd, cDDb; | ||
beforeEach(function () { | ||
cd = require('./parser/classDiagram').parser; | ||
cDDb = require('./classDb'); | ||
cd.yy = cDDb; | ||
}); | ||
describe('when parsing an info graph it', function () { | ||
var cd, cDDb | ||
beforeEach(function () { | ||
cd = require('./parser/classDiagram').parser | ||
cDDb = require('./classDb') | ||
cd.yy = cDDb | ||
}) | ||
it('should handle relation definitions', function () { | ||
var str = 'classDiagram\n'+ | ||
'Class01 <|-- Class02\n'+ | ||
'Class03 *-- Class04\n'+ | ||
'Class05 o-- Class06\n'+ | ||
'Class07 .. Class08\n'+ | ||
'Class09 -- Class1'; | ||
it('should handle relation definitions', function () { | ||
var str = 'classDiagram\n' + | ||
'Class01 <|-- Class02\n' + | ||
'Class03 *-- Class04\n' + | ||
'Class05 o-- Class06\n' + | ||
'Class07 .. Class08\n' + | ||
'Class09 -- Class1' | ||
cd.parse(str); | ||
}); | ||
it('should handle relation definition of different types and directions', function () { | ||
var str = 'classDiagram\n'+ | ||
'Class11 <|.. Class12\n'+ | ||
'Class13 --> Class14\n'+ | ||
'Class15 ..> Class16\n'+ | ||
'Class17 ..|> Class18\n'+ | ||
'Class19 <--* Class20'; | ||
cd.parse(str) | ||
}) | ||
it('should handle relation definition of different types and directions', function () { | ||
var str = 'classDiagram\n' + | ||
'Class11 <|.. Class12\n' + | ||
'Class13 --> Class14\n' + | ||
'Class15 ..> Class16\n' + | ||
'Class17 ..|> Class18\n' + | ||
'Class19 <--* Class20' | ||
cd.parse(str); | ||
}); | ||
cd.parse(str) | ||
}) | ||
it('should handle cardinality and labels', function () { | ||
var str = 'classDiagram\n'+ | ||
'Class01 "1" *-- "many" Class02 : contains\n'+ | ||
'Class03 o-- Class04 : aggregation\n'+ | ||
'Class05 --> "1" Class06'; | ||
it('should handle cardinality and labels', function () { | ||
var str = 'classDiagram\n' + | ||
'Class01 "1" *-- "many" Class02 : contains\n' + | ||
'Class03 o-- Class04 : aggregation\n' + | ||
'Class05 --> "1" Class06' | ||
cd.parse(str); | ||
}); | ||
it('should handle class definitions', function () { | ||
var str = 'classDiagram\n'+ | ||
'class Car\n'+ | ||
'Driver -- Car : drives >\n'+ | ||
'Car *-- Wheel : have 4 >\n'+ | ||
'Car -- Person : < owns'; | ||
cd.parse(str) | ||
}) | ||
it('should handle class definitions', function () { | ||
var str = 'classDiagram\n' + | ||
'class Car\n' + | ||
'Driver -- Car : drives >\n' + | ||
'Car *-- Wheel : have 4 >\n' + | ||
'Car -- Person : < owns' | ||
cd.parse(str); | ||
}); | ||
cd.parse(str) | ||
}) | ||
it('should handle method statements', function () { | ||
var str = 'classDiagram\n'+ | ||
'Object <|-- ArrayList\n'+ | ||
'Object : equals()\n'+ | ||
'ArrayList : Object[] elementData\n'+ | ||
'ArrayList : size()'; | ||
it('should handle method statements', function () { | ||
var str = 'classDiagram\n' + | ||
'Object <|-- ArrayList\n' + | ||
'Object : equals()\n' + | ||
'ArrayList : Object[] elementData\n' + | ||
'ArrayList : size()' | ||
cd.parse(str); | ||
}); | ||
it('should handle parsing of method statements grouped by brackets', function () { | ||
var str = 'classDiagram\n'+ | ||
'class Dummy {\n'+ | ||
'String data\n'+ | ||
' void methods()\n'+ | ||
'}\n'+ | ||
'\n'+ | ||
'class Flight {\n'+ | ||
' flightNumber : Integer\n'+ | ||
' departureTime : Date\n'+ | ||
'}'; | ||
cd.parse(str) | ||
}) | ||
it('should handle parsing of method statements grouped by brackets', function () { | ||
var str = 'classDiagram\n' + | ||
'class Dummy {\n' + | ||
'String data\n' + | ||
' void methods()\n' + | ||
'}\n' + | ||
'\n' + | ||
'class Flight {\n' + | ||
' flightNumber : Integer\n' + | ||
' departureTime : Date\n' + | ||
'}' | ||
cd.parse(str); | ||
}); | ||
cd.parse(str) | ||
}) | ||
it('should handle parsing of separators', function () { | ||
var str = 'classDiagram\n'+ | ||
'class Foo1 {\n'+ | ||
' You can use\n'+ | ||
' several lines\n'+ | ||
'..\n'+ | ||
'as you want\n'+ | ||
'and group\n'+ | ||
'==\n'+ | ||
'things together.\n'+ | ||
'__\n'+ | ||
'You can have as many groups\n'+ | ||
'as you want\n'+ | ||
'--\n'+ | ||
'End of class\n'+ | ||
'}\n'+ | ||
'\n'+ | ||
'class User {\n'+ | ||
'.. Simple Getter ..\n'+ | ||
'+ getName()\n'+ | ||
'+ getAddress()\n'+ | ||
'.. Some setter ..\n'+ | ||
'+ setName()\n'+ | ||
'__ private data __\n'+ | ||
'int age\n'+ | ||
'-- encrypted --\n'+ | ||
'String password\n'+ | ||
'}'; | ||
it('should handle parsing of separators', function () { | ||
var str = 'classDiagram\n' + | ||
'class Foo1 {\n' + | ||
' You can use\n' + | ||
' several lines\n' + | ||
'..\n' + | ||
'as you want\n' + | ||
'and group\n' + | ||
'==\n' + | ||
'things together.\n' + | ||
'__\n' + | ||
'You can have as many groups\n' + | ||
'as you want\n' + | ||
'--\n' + | ||
'End of class\n' + | ||
'}\n' + | ||
'\n' + | ||
'class User {\n' + | ||
'.. Simple Getter ..\n' + | ||
'+ getName()\n' + | ||
'+ getAddress()\n' + | ||
'.. Some setter ..\n' + | ||
'+ setName()\n' + | ||
'__ private data __\n' + | ||
'int age\n' + | ||
'-- encrypted --\n' + | ||
'String password\n' + | ||
'}' | ||
cd.parse(str); | ||
}); | ||
cd.parse(str) | ||
}) | ||
}) | ||
}); | ||
describe('when fetching data from an classDiagram graph it', function () { | ||
var cd, cDDb | ||
beforeEach(function () { | ||
cd = require('./parser/classDiagram').parser | ||
cDDb = require('./classDb') | ||
cd.yy = cDDb | ||
cd.yy.clear() | ||
}) | ||
it('should handle relation definitions EXTENSION', function () { | ||
var str = 'classDiagram\n' + | ||
'Class01 <|-- Class02' | ||
describe('when fetching data from an classDiagram graph it', function () { | ||
var cd, cDDb; | ||
beforeEach(function () { | ||
cd = require('./parser/classDiagram').parser; | ||
cDDb = require('./classDb'); | ||
cd.yy = cDDb; | ||
cd.yy.clear(); | ||
}); | ||
it('should handle relation definitions EXTENSION', function () { | ||
var str = 'classDiagram\n'+ | ||
'Class01 <|-- Class02'; | ||
cd.parse(str) | ||
cd.parse(str); | ||
var relations = cd.yy.getRelations() | ||
var relations = cd.yy.getRelations(); | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01') | ||
expect(cd.yy.getClass('Class02').id).toBe('Class02') | ||
expect(relations[0].relation.type1).toBe(cDDb.relationType.EXTENSION) | ||
expect(relations[0].relation.type2).toBe('none') | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.LINE) | ||
}) | ||
it('should handle relation definitions AGGREGATION and dotted line', function () { | ||
var str = 'classDiagram\n' + | ||
'Class01 o.. Class02' | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01'); | ||
expect(cd.yy.getClass('Class02').id).toBe('Class02'); | ||
expect(relations[0].relation.type1).toBe(cDDb.relationType.EXTENSION); | ||
expect(relations[0].relation.type2).toBe('none'); | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.LINE); | ||
}); | ||
it('should handle relation definitions AGGREGATION and dotted line', function () { | ||
var str = 'classDiagram\n'+ | ||
'Class01 o.. Class02'; | ||
cd.parse(str) | ||
cd.parse(str); | ||
var relations = cd.yy.getRelations() | ||
var relations = cd.yy.getRelations(); | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01') | ||
expect(cd.yy.getClass('Class02').id).toBe('Class02') | ||
expect(relations[0].relation.type1).toBe(cDDb.relationType.AGGREGATION) | ||
expect(relations[0].relation.type2).toBe('none') | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.DOTTED_LINE) | ||
}) | ||
it('should handle relation definitions COMPOSITION on both sides', function () { | ||
var str = 'classDiagram\n' + | ||
'Class01 *--* Class02' | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01'); | ||
expect(cd.yy.getClass('Class02').id).toBe('Class02'); | ||
expect(relations[0].relation.type1).toBe(cDDb.relationType.AGGREGATION); | ||
expect(relations[0].relation.type2).toBe('none'); | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.DOTTED_LINE); | ||
}); | ||
it('should handle relation definitions COMPOSITION on both sides', function () { | ||
var str = 'classDiagram\n'+ | ||
'Class01 *--* Class02'; | ||
cd.parse(str) | ||
cd.parse(str); | ||
var relations = cd.yy.getRelations() | ||
var relations = cd.yy.getRelations(); | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01') | ||
expect(cd.yy.getClass('Class02').id).toBe('Class02') | ||
expect(relations[0].relation.type1).toBe(cDDb.relationType.COMPOSITION) | ||
expect(relations[0].relation.type2).toBe(cDDb.relationType.COMPOSITION) | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.LINE) | ||
}) | ||
it('should handle relation definitions no types', function () { | ||
var str = 'classDiagram\n' + | ||
'Class01 -- Class02' | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01'); | ||
expect(cd.yy.getClass('Class02').id).toBe('Class02'); | ||
expect(relations[0].relation.type1).toBe(cDDb.relationType.COMPOSITION); | ||
expect(relations[0].relation.type2).toBe(cDDb.relationType.COMPOSITION); | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.LINE); | ||
}); | ||
it('should handle relation definitions no types', function () { | ||
var str = 'classDiagram\n'+ | ||
'Class01 -- Class02'; | ||
cd.parse(str) | ||
cd.parse(str); | ||
var relations = cd.yy.getRelations() | ||
var relations = cd.yy.getRelations(); | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01') | ||
expect(cd.yy.getClass('Class02').id).toBe('Class02') | ||
expect(relations[0].relation.type1).toBe('none') | ||
expect(relations[0].relation.type2).toBe('none') | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.LINE) | ||
}) | ||
it('should handle relation definitions with type only on right side', function () { | ||
var str = 'classDiagram\n' + | ||
'Class01 --|> Class02' | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01'); | ||
expect(cd.yy.getClass('Class02').id).toBe('Class02'); | ||
expect(relations[0].relation.type1).toBe('none'); | ||
expect(relations[0].relation.type2).toBe('none'); | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.LINE); | ||
}); | ||
it('should handle relation definitions with type only on right side', function () { | ||
var str = 'classDiagram\n'+ | ||
'Class01 --|> Class02'; | ||
cd.parse(str) | ||
cd.parse(str); | ||
var relations = cd.yy.getRelations() | ||
var relations = cd.yy.getRelations(); | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01') | ||
expect(cd.yy.getClass('Class02').id).toBe('Class02') | ||
expect(relations[0].relation.type1).toBe('none') | ||
expect(relations[0].relation.type2).toBe(cDDb.relationType.EXTENSION) | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.LINE) | ||
}) | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01'); | ||
expect(cd.yy.getClass('Class02').id).toBe('Class02'); | ||
expect(relations[0].relation.type1).toBe('none'); | ||
expect(relations[0].relation.type2).toBe(cDDb.relationType.EXTENSION); | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.LINE); | ||
}); | ||
it('should handle multiple classes and relation definitions', function () { | ||
var str = 'classDiagram\n' + | ||
'Class01 <|-- Class02\n' + | ||
'Class03 *-- Class04\n' + | ||
'Class05 o-- Class06\n' + | ||
'Class07 .. Class08\n' + | ||
'Class09 -- Class10' | ||
it('should handle multiple classes and relation definitions', function () { | ||
var str = 'classDiagram\n'+ | ||
'Class01 <|-- Class02\n'+ | ||
'Class03 *-- Class04\n'+ | ||
'Class05 o-- Class06\n'+ | ||
'Class07 .. Class08\n'+ | ||
'Class09 -- Class10'; | ||
cd.parse(str) | ||
cd.parse(str); | ||
var relations = cd.yy.getRelations() | ||
var relations = cd.yy.getRelations(); | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01') | ||
expect(cd.yy.getClass('Class10').id).toBe('Class10') | ||
expect(cd.yy.getClass('Class01').id).toBe('Class01'); | ||
expect(cd.yy.getClass('Class10').id).toBe('Class10'); | ||
expect(relations.length).toBe(5) | ||
expect(relations.length).toBe(5); | ||
expect(relations[0].relation.type1).toBe(cDDb.relationType.EXTENSION); | ||
expect(relations[0].relation.type2).toBe('none'); | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.LINE); | ||
expect(relations[3].relation.type1).toBe('none'); | ||
expect(relations[3].relation.type2).toBe('none'); | ||
expect(relations[3].relation.lineType).toBe(cDDb.lineType.DOTTED_LINE); | ||
}); | ||
}); | ||
}); | ||
expect(relations[0].relation.type1).toBe(cDDb.relationType.EXTENSION) | ||
expect(relations[0].relation.type2).toBe('none') | ||
expect(relations[0].relation.lineType).toBe(cDDb.lineType.LINE) | ||
expect(relations[3].relation.type1).toBe('none') | ||
expect(relations[3].relation.type2).toBe('none') | ||
expect(relations[3].relation.lineType).toBe(cDDb.lineType.DOTTED_LINE) | ||
}) | ||
}) | ||
}) |
@@ -5,32 +5,32 @@ /** | ||
var cd = require('./parser/classDiagram').parser; | ||
var cDDb = require('./classDb'); | ||
cd.yy = cDDb; | ||
var d3 = require('../../d3'); | ||
var Logger = require('../../logger'); | ||
var dagre = require('dagre'); | ||
var log = new Logger.Log(); | ||
var cd = require('./parser/classDiagram').parser | ||
var cDDb = require('./classDb') | ||
cd.yy = cDDb | ||
var d3 = require('../../d3') | ||
var Logger = require('../../logger') | ||
var log = Logger.Log | ||
var dagre = require('dagre') | ||
var idCache; | ||
idCache = {}; | ||
var idCache | ||
idCache = {} | ||
var classCnt = 0; | ||
var classCnt = 0 | ||
var conf = { | ||
dividerMargin: 10, | ||
padding: 5, | ||
textHeight: 14 | ||
}; | ||
dividerMargin: 10, | ||
padding: 5, | ||
textHeight: 10 | ||
} | ||
// Todo optimize | ||
var getGraphId = function (label) { | ||
var keys = Object.keys(idCache); | ||
var keys = Object.keys(idCache) | ||
var i; | ||
for(i=0;i<keys.length;i++){ | ||
if(idCache[keys[i]].label === label){ | ||
return keys[i]; | ||
} | ||
var i | ||
for (i = 0; i < keys.length; i++) { | ||
if (idCache[keys[i]].label === label) { | ||
return keys[i] | ||
} | ||
} | ||
return undefined; | ||
return undefined | ||
} | ||
@@ -42,289 +42,264 @@ | ||
var insertMarkers = function (elem) { | ||
elem.append('defs').append('marker') | ||
.attr('id', 'extensionStart') | ||
.attr('class', 'extension') | ||
.attr('refX', 0) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 190) | ||
.attr('markerHeight', 240) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 1,7 L18,13 V 1 Z'); | ||
elem.append('defs').append('marker') | ||
.attr('id', 'extensionStart') | ||
.attr('class', 'extension') | ||
.attr('refX', 0) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 190) | ||
.attr('markerHeight', 240) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 1,7 L18,13 V 1 Z') | ||
elem.append('defs').append('marker') | ||
.attr('id', 'extensionEnd') | ||
.attr('refX', 19) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 20) | ||
.attr('markerHeight', 28) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 1,1 V 13 L18,7 Z'); //this is actual shape for arrowhead | ||
elem.append('defs').append('marker') | ||
.attr('id', 'extensionEnd') | ||
.attr('refX', 19) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 20) | ||
.attr('markerHeight', 28) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 1,1 V 13 L18,7 Z') // this is actual shape for arrowhead | ||
elem.append('defs').append('marker') | ||
.attr('id', 'compositionStart') | ||
.attr('class', 'extension') | ||
.attr('refX', 0) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 190) | ||
.attr('markerHeight', 240) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z'); | ||
elem.append('defs').append('marker') | ||
.attr('id', 'compositionStart') | ||
.attr('class', 'extension') | ||
.attr('refX', 0) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 190) | ||
.attr('markerHeight', 240) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z') | ||
elem.append('defs').append('marker') | ||
.attr('id', 'compositionEnd') | ||
.attr('refX', 19) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 20) | ||
.attr('markerHeight', 28) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z'); | ||
elem.append('defs').append('marker') | ||
.attr('id', 'compositionEnd') | ||
.attr('refX', 19) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 20) | ||
.attr('markerHeight', 28) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z') | ||
elem.append('defs').append('marker') | ||
.attr('id', 'aggregationStart') | ||
.attr('class', 'extension') | ||
.attr('refX', 0) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 190) | ||
.attr('markerHeight', 240) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z') | ||
elem.append('defs').append('marker') | ||
.attr('id', 'aggregationStart') | ||
.attr('class', 'extension') | ||
.attr('refX', 0) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 190) | ||
.attr('markerHeight', 240) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z'); | ||
elem.append('defs').append('marker') | ||
.attr('id', 'aggregationEnd') | ||
.attr('refX', 19) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 20) | ||
.attr('markerHeight', 28) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z') | ||
elem.append('defs').append('marker') | ||
.attr('id', 'aggregationEnd') | ||
.attr('refX', 19) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 20) | ||
.attr('markerHeight', 28) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 18,7 L9,13 L1,7 L9,1 Z'); | ||
elem.append('defs').append('marker') | ||
.attr('id', 'dependencyStart') | ||
.attr('class', 'extension') | ||
.attr('refX', 0) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 190) | ||
.attr('markerHeight', 240) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 5,7 L9,13 L1,7 L9,1 Z') | ||
elem.append('defs').append('marker') | ||
.attr('id', 'dependencyStart') | ||
.attr('class', 'extension') | ||
.attr('refX', 0) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 190) | ||
.attr('markerHeight', 240) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 5,7 L9,13 L1,7 L9,1 Z'); | ||
elem.append('defs').append('marker') | ||
.attr('id', 'dependencyEnd') | ||
.attr('refX', 19) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 20) | ||
.attr('markerHeight', 28) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 18,7 L9,13 L14,7 L9,1 Z') | ||
} | ||
elem.append('defs').append('marker') | ||
.attr('id', 'dependencyEnd') | ||
.attr('refX', 19) | ||
.attr('refY', 7) | ||
.attr('markerWidth', 20) | ||
.attr('markerHeight', 28) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 18,7 L9,13 L14,7 L9,1 Z'); | ||
}; | ||
var edgeCount = 0; | ||
var edgeCount = 0 | ||
var drawEdge = function (elem, path, relation) { | ||
var getRelationType = function (type) { | ||
switch (type) { | ||
case cDDb.relationType.AGGREGATION: | ||
return 'aggregation'; | ||
case cDDb.relationType.EXTENSION: | ||
return 'extension'; | ||
case cDDb.relationType.COMPOSITION: | ||
return 'composition'; | ||
case cDDb.relationType.DEPENDENCY: | ||
return 'dependency'; | ||
} | ||
}; | ||
var getRelationType = function (type) { | ||
switch (type) { | ||
case cDDb.relationType.AGGREGATION: | ||
return 'aggregation' | ||
case cDDb.relationType.EXTENSION: | ||
return 'extension' | ||
case cDDb.relationType.COMPOSITION: | ||
return 'composition' | ||
case cDDb.relationType.DEPENDENCY: | ||
return 'dependency' | ||
} | ||
} | ||
// The data for our line | ||
var lineData = path.points | ||
//The data for our line | ||
var lineData = path.points; | ||
// This is the accessor function we talked about above | ||
var lineFunction = d3.svg.line() | ||
.x(function (d) { | ||
return d.x | ||
}) | ||
.y(function (d) { | ||
return d.y | ||
}) | ||
.interpolate('basis') | ||
//This is the accessor function we talked about above | ||
var lineFunction = d3.svg.line() | ||
.x(function (d) { | ||
return d.x; | ||
}) | ||
.y(function (d) { | ||
return d.y; | ||
}) | ||
//.interpolate('cardinal'); | ||
.interpolate('basis'); | ||
var svgPath = elem.append('path') | ||
.attr('d', lineFunction(lineData)) | ||
.attr('id', 'edge' + edgeCount) | ||
.attr('class', 'relation') | ||
var url = '' | ||
if (conf.arrowMarkerAbsolute) { | ||
url = window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search | ||
url = url.replace(/\(/g, '\\(') | ||
url = url.replace(/\)/g, '\\)') | ||
} | ||
var svgPath = elem.append('path') | ||
.attr('d', lineFunction(lineData)) | ||
.attr('id', 'edge' + edgeCount) | ||
.attr('class', 'relation'); | ||
var url = ''; | ||
if(conf.arrowMarkerAbsolute){ | ||
url = window.location.protocol+'//'+window.location.host+window.location.pathname +window.location.search; | ||
url = url.replace(/\(/g,'\\('); | ||
url = url.replace(/\)/g,'\\)'); | ||
} | ||
if (relation.relation.type1 !== 'none') { | ||
svgPath.attr('marker-start', 'url(' + url + '#' + getRelationType(relation.relation.type1) + 'Start' + ')') | ||
} | ||
if (relation.relation.type2 !== 'none') { | ||
svgPath.attr('marker-end', 'url(' + url + '#' + getRelationType(relation.relation.type2) + 'End' + ')') | ||
} | ||
//console.log(relation.relation.type1); | ||
if (relation.relation.type1 !== 'none') { | ||
svgPath.attr('marker-start', 'url(' + url + '#' + getRelationType(relation.relation.type1) + 'Start' + ')'); | ||
} | ||
if (relation.relation.type2 !== 'none') { | ||
svgPath.attr('marker-end', 'url(' + url + '#' + getRelationType(relation.relation.type2) + 'End' + ')'); | ||
} | ||
var x, y | ||
var l = path.points.length | ||
if ((l % 2) !== 0) { | ||
var p1 = path.points[Math.floor(l / 2)] | ||
var p2 = path.points[Math.ceil(l / 2)] | ||
x = (p1.x + p2.x) / 2 | ||
y = (p1.y + p2.y) / 2 | ||
} else { | ||
var p = path.points[Math.floor(l / 2)] | ||
x = p.x | ||
y = p.y | ||
} | ||
//var bbox = svgPath[0][0].getBBox(); | ||
//var x = Math.floor(bbox.x + bbox.width/2.0); | ||
//var y = Math.floor(bbox.y + bbox.height/2.0); | ||
var x, y; | ||
var l = path.points.length; | ||
if ((l % 2) !== 0) { | ||
var p1 = path.points[Math.floor(l / 2)]; | ||
var p2 = path.points[Math.ceil(l / 2)]; | ||
x = (p1.x + p2.x) / 2; | ||
y = (p1.y + p2.y) / 2; | ||
} | ||
else { | ||
var p = path.points[Math.floor(l / 2)]; | ||
x = p.x; | ||
y = p.y; | ||
} | ||
if (typeof relation.title !== 'undefined') { | ||
var g = elem.append('g') | ||
.attr('class', 'classLabel') | ||
var label = g.append('text') | ||
.attr('class', 'label') | ||
.attr('x', x) | ||
.attr('y', y) | ||
.attr('fill', 'red') | ||
.attr('text-anchor', 'middle') | ||
.text(relation.title) | ||
if (typeof relation.title !== 'undefined') { | ||
var g = elem.append('g'). | ||
attr('class','classLabel'); | ||
var label = g.append('text') | ||
.attr('class', 'label') | ||
.attr('x', x) | ||
.attr('y', y) | ||
.attr('fill', 'red') | ||
.attr('text-anchor', 'middle') | ||
.text(relation.title); | ||
window.label = label | ||
var bounds = label.node().getBBox() | ||
window.label = label; | ||
var bounds = label.node().getBBox(); | ||
g.insert('rect', ':first-child') | ||
.attr('class', 'box') | ||
.attr('x', bounds.x - conf.padding / 2) | ||
.attr('y', bounds.y - conf.padding / 2) | ||
.attr('width', bounds.width + conf.padding) | ||
.attr('height', bounds.height + conf.padding) | ||
} | ||
g.insert('rect', ':first-child') | ||
.attr('class', 'box') | ||
.attr('x', bounds.x-conf.padding/2) | ||
.attr('y', bounds.y-conf.padding/2) | ||
.attr('width', bounds.width + 2 * conf.padding/2) | ||
.attr('height', bounds.height + 2 * conf.padding/2); | ||
//.append('textpath') | ||
//.attr('xlink:href','#edge'+edgeCount) | ||
//.attr('text-anchor','middle') | ||
//.attr('startOffset','50%') | ||
} | ||
edgeCount++; | ||
edgeCount++ | ||
} | ||
var drawClass = function (elem, classDef) { | ||
log.info('Rendering class ' + classDef); | ||
log.info('Rendering class ' + classDef) | ||
var addTspan = function (textEl, txt, isFirst) { | ||
var tSpan = textEl.append('tspan') | ||
.attr('x', conf.padding) | ||
.text(txt); | ||
if (!isFirst) { | ||
tSpan.attr('dy', conf.textHeight); | ||
} | ||
}; | ||
var addTspan = function (textEl, txt, isFirst) { | ||
var tSpan = textEl.append('tspan') | ||
.attr('x', conf.padding) | ||
.text(txt) | ||
if (!isFirst) { | ||
tSpan.attr('dy', conf.textHeight) | ||
} | ||
} | ||
var id = 'classId' + classCnt; | ||
var classInfo = { | ||
id: id, | ||
label: classDef.id, | ||
width: 0, | ||
height: 0 | ||
}; | ||
var id = 'classId' + classCnt | ||
var classInfo = { | ||
id: id, | ||
label: classDef.id, | ||
width: 0, | ||
height: 0 | ||
} | ||
var g = elem.append('g') | ||
.attr('id', id) | ||
.attr('class', 'classGroup'); | ||
var title = g.append('text') | ||
.attr('x', conf.padding) | ||
.attr('y', conf.textHeight + conf.padding) | ||
.text(classDef.id); | ||
var g = elem.append('g') | ||
.attr('id', id) | ||
.attr('class', 'classGroup') | ||
var title = g.append('text') | ||
.attr('x', conf.padding) | ||
.attr('y', conf.textHeight + conf.padding) | ||
.text(classDef.id) | ||
var titleHeight = title.node().getBBox().height; | ||
var titleHeight = title.node().getBBox().height | ||
var membersLine = g.append('line') // text label for the x axis | ||
.attr('x1', 0) | ||
.attr('y1', conf.padding + titleHeight + conf.dividerMargin / 2) | ||
.attr('y2', conf.padding + titleHeight + conf.dividerMargin / 2); | ||
var membersLine = g.append('line') // text label for the x axis | ||
.attr('x1', 0) | ||
.attr('y1', conf.padding + titleHeight + conf.dividerMargin / 2) | ||
.attr('y2', conf.padding + titleHeight + conf.dividerMargin / 2) | ||
var members = g.append('text') // text label for the x axis | ||
.attr('x', conf.padding) | ||
.attr('y', titleHeight + (conf.dividerMargin) + conf.textHeight) | ||
.attr('fill', 'white') | ||
.attr('class', 'classText'); | ||
var members = g.append('text') // text label for the x axis | ||
.attr('x', conf.padding) | ||
.attr('y', titleHeight + (conf.dividerMargin) + conf.textHeight) | ||
.attr('fill', 'white') | ||
.attr('class', 'classText') | ||
var isFirst = true; | ||
var isFirst = true | ||
classDef.members.forEach(function(member){ | ||
addTspan(members, member, isFirst); | ||
isFirst = false; | ||
}); | ||
//for (var member of classDef.members) { | ||
// addTspan(members, member, isFirst); | ||
// isFirst = false; | ||
//} | ||
classDef.members.forEach(function (member) { | ||
addTspan(members, member, isFirst) | ||
isFirst = false | ||
}) | ||
var membersBox = members.node().getBBox(); | ||
var membersBox = members.node().getBBox() | ||
var methodsLine = g.append('line') // text label for the x axis | ||
.attr('x1', 0) | ||
.attr('y1', conf.padding + titleHeight + 3 * conf.dividerMargin / 2 + membersBox.height) | ||
.attr('y2', conf.padding + titleHeight + 3 * conf.dividerMargin / 2 + membersBox.height); | ||
var methodsLine = g.append('line') // text label for the x axis | ||
.attr('x1', 0) | ||
.attr('y1', conf.padding + titleHeight + conf.dividerMargin + membersBox.height) | ||
.attr('y2', conf.padding + titleHeight + conf.dividerMargin + membersBox.height) | ||
var methods = g.append('text') // text label for the x axis | ||
.attr('x', conf.padding) | ||
.attr('y', titleHeight + 2 * conf.dividerMargin + membersBox.height + conf.textHeight) | ||
.attr('fill', 'white') | ||
.attr('class', 'classText') | ||
var methods = g.append('text') // text label for the x axis | ||
.attr('x', conf.padding) | ||
.attr('y', titleHeight + 2 * conf.dividerMargin + membersBox.height + conf.textHeight) | ||
.attr('fill', 'white') | ||
.attr('class', 'classText'); | ||
isFirst = true | ||
isFirst = true; | ||
classDef.methods.forEach(function (method) { | ||
addTspan(methods, method, isFirst) | ||
isFirst = false | ||
}) | ||
classDef.methods.forEach(function(method){ | ||
addTspan(methods, method, isFirst); | ||
isFirst = false; | ||
}); | ||
//for (var method of classDef.methods) { | ||
// addTspan(methods, method, isFirst); | ||
// isFirst = false; | ||
//} | ||
var classBox = g.node().getBBox() | ||
g.insert('rect', ':first-child') | ||
.attr('x', 0) | ||
.attr('y', 0) | ||
.attr('width', classBox.width + 2 * conf.padding) | ||
.attr('height', classBox.height + conf.padding + 0.5 * conf.dividerMargin) | ||
var classBox = g.node().getBBox(); | ||
g.insert('rect', ':first-child') | ||
.attr('x', 0) | ||
.attr('y', 0) | ||
.attr('width', classBox.width + 2 * conf.padding) | ||
.attr('height', classBox.height + conf.padding + 0.5 * conf.dividerMargin); | ||
membersLine.attr('x2', classBox.width + 2 * conf.padding) | ||
methodsLine.attr('x2', classBox.width + 2 * conf.padding) | ||
classInfo.width = classBox.width + 2 * conf.padding | ||
classInfo.height = classBox.height + conf.padding + 0.5 * conf.dividerMargin | ||
membersLine.attr('x2', classBox.width + 2 * conf.padding); | ||
methodsLine.attr('x2', classBox.width + 2 * conf.padding); | ||
idCache[id] = classInfo | ||
classCnt++ | ||
return classInfo | ||
} | ||
classInfo.width = classBox.width + 2 * conf.padding; | ||
classInfo.height = classBox.height + conf.padding + 0.5 * conf.dividerMargin; | ||
idCache[id] = classInfo; | ||
classCnt++; | ||
return classInfo; | ||
}; | ||
module.exports.setConf = function (cnf) { | ||
var keys = Object.keys(cnf); | ||
var keys = Object.keys(cnf) | ||
keys.forEach(function (key) { | ||
conf[key] = cnf[key]; | ||
}); | ||
}; | ||
keys.forEach(function (key) { | ||
conf[key] = cnf[key] | ||
}) | ||
} | ||
/** | ||
@@ -336,89 +311,59 @@ * Draws a flowchart in the tag with id: id based on the graph definition in text. | ||
module.exports.draw = function (text, id) { | ||
cd.yy.clear(); | ||
cd.parse(text); | ||
cd.yy.clear() | ||
cd.parse(text) | ||
log.info('Rendering diagram ' + text); | ||
log.info('Rendering diagram ' + text) | ||
/// / Fetch the default direction, use TD if none was found | ||
var diagram = d3.select('#' + id) | ||
insertMarkers(diagram) | ||
//// Fetch the default direction, use TD if none was found | ||
var diagram = d3.select('#' + id); | ||
insertMarkers(diagram); | ||
//var svg = diagram.append('svg'); | ||
// Layout graph, Create a new directed graph | ||
var g = new dagre.graphlib.Graph({ | ||
multigraph: true | ||
}) | ||
// Layout graph, Create a new directed graph | ||
var g = new dagre.graphlib.Graph({ | ||
multigraph: true | ||
}); | ||
// Set an object for the graph label | ||
g.setGraph({ | ||
isMultiGraph: true | ||
}) | ||
// Set an object for the graph label | ||
g.setGraph({ | ||
isMultiGraph: true | ||
}); | ||
// Default to assigning a new object as a label for each new edge. | ||
g.setDefaultEdgeLabel(function () { | ||
return {} | ||
}) | ||
// Default to assigning a new object as a label for each new edge. | ||
g.setDefaultEdgeLabel(function () { | ||
return {}; | ||
}); | ||
var classes = cDDb.getClasses() | ||
var keys = Object.keys(classes) | ||
var i | ||
for (i = 0; i < keys.length; i++) { | ||
var classDef = classes[keys[i]] | ||
var node = drawClass(diagram, classDef) | ||
// Add nodes to the graph. The first argument is the node id. The second is | ||
// metadata about the node. In this case we're going to add labels to each of | ||
// our nodes. | ||
g.setNode(node.id, node) | ||
log.info('Org height: ' + node.height) | ||
} | ||
var classes = cDDb.getClasses(); | ||
var keys = Object.keys(classes); | ||
var i; | ||
for (i=0;i<keys.length;i++) { | ||
var classDef = classes[keys[i]]; | ||
var node = drawClass(diagram, classDef); | ||
// Add nodes to the graph. The first argument is the node id. The second is | ||
// metadata about the node. In this case we're going to add labels to each of | ||
// our nodes. | ||
g.setNode(node.id, node); | ||
log.info('Org height: ' + node.height); | ||
//g.setNode("swilliams", { label: "Saul Williams", width: 160, height: 100 }); | ||
//g.setNode("bpitt", { label: "Brad Pitt", width: 108, height: 100 }); | ||
//g.setNode("hford", { label: "Harrison Ford", width: 168, height: 100 }); | ||
//g.setNode("lwilson", { label: "Luke Wilson", width: 144, height: 100 }); | ||
//g.setNode("kbacon", { label: "Kevin Bacon", width: 121, height: 100 }); | ||
var relations = cDDb.getRelations() | ||
relations.forEach(function (relation) { | ||
log.info('tjoho' + getGraphId(relation.id1) + getGraphId(relation.id2) + JSON.stringify(relation)) | ||
g.setEdge(getGraphId(relation.id1), getGraphId(relation.id2), { relation: relation }) | ||
}) | ||
dagre.layout(g) | ||
g.nodes().forEach(function (v) { | ||
if (typeof v !== 'undefined') { | ||
log.debug('Node ' + v + ': ' + JSON.stringify(g.node(v))) | ||
d3.select('#' + v).attr('transform', 'translate(' + (g.node(v).x - (g.node(v).width / 2)) + ',' + (g.node(v).y - (g.node(v).height / 2)) + ' )') | ||
} | ||
}) | ||
g.edges().forEach(function (e) { | ||
log.debug('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(g.edge(e))) | ||
drawEdge(diagram, g.edge(e), g.edge(e).relation) | ||
}) | ||
var relations = cDDb.getRelations(); | ||
var i = 0; | ||
relations.forEach(function(relation){ | ||
i = i + 1; | ||
log.info('tjoho' + getGraphId(relation.id1) + getGraphId(relation.id2) + JSON.stringify(relation)); | ||
g.setEdge(getGraphId(relation.id1), getGraphId(relation.id2), {relation: relation}); | ||
}); | ||
//for (var relation of relations) { | ||
// i = i + 1; | ||
// log.info('tjoho' + getGraphId(relation.id1) + getGraphId(relation.id2) + JSON.stringify(relation)); | ||
// g.setEdge(getGraphId(relation.id1), getGraphId(relation.id2), {relation: relation}); | ||
//} | ||
dagre.layout(g); | ||
g.nodes().forEach(function (v) { | ||
if(typeof v !== 'undefined'){ | ||
log.debug('Node ' + v + ': ' + JSON.stringify(g.node(v))); | ||
d3.select('#' + v).attr('transform', 'translate(' + (g.node(v).x - (g.node(v).width / 2)) + ',' + (g.node(v).y - (g.node(v).height / 2)) + ' )'); | ||
//d3.select('#' +v +' rect').attr('x',(g.node(v).x-(g.node(v).width/2))) | ||
//.attr('y',(g.node(v).y-(g.node(v).height/2))); | ||
} | ||
}); | ||
g.edges().forEach(function (e) { | ||
log.debug('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(g.edge(e))); | ||
drawEdge(diagram, g.edge(e), g.edge(e).relation); | ||
}); | ||
// | ||
diagram.attr('height', '100%'); | ||
diagram.attr('width', '100%'); | ||
// | ||
// | ||
// | ||
// | ||
//if(conf.useMaxWidth) { | ||
// diagram.attr('height', '100%'); | ||
// diagram.attr('width', '100%'); | ||
// diagram.attr('style', 'max-width:' + (width) + 'px;'); | ||
//}else{ | ||
// diagram.attr('height',height); | ||
// diagram.attr('width', width ); | ||
//} | ||
//diagram.attr('viewBox', (box.startx-conf.diagramMarginX) + ' -' +conf.diagramMarginY + ' ' + width + ' ' + height); | ||
}; | ||
diagram.attr('height', '100%') | ||
diagram.attr('width', '100%') | ||
diagram.attr('viewBox', '0 0 ' + (g.graph().width + 20) + ' ' + (g.graph().height + 20)) | ||
} |
@@ -1,113 +0,28 @@ | ||
//var proxyquire = require('proxyquire'); | ||
//var newD3; | ||
///** | ||
// * Created by knut on 14-11-18. | ||
// */ | ||
// | ||
//var d3 = { | ||
// select:function(){ | ||
// return new newD3(); | ||
// }, | ||
// selectAll:function(){ | ||
// return new newD3(); | ||
// } | ||
//}; | ||
/* eslint-env jasmine */ | ||
/** | ||
* Created by knut on 14-11-18. | ||
*/ | ||
//var classRenderer = proxyquire('./classRenderer', { '../../d3': d3 }); | ||
//var testDom = require('testdom')('<html><body><div id="tst"></div></body></html>'); | ||
var classRenderer = require('./classRenderer'); | ||
var parser = require('./parser/classDiagram').parser; | ||
describe('class diagram, ', function () { | ||
describe('when rendering a classDiagram',function() { | ||
var conf; | ||
beforeEach(function () { | ||
////parser.yy = require('./classDb'); | ||
////parser.yy.clear(); | ||
////parseError = function(err, hash) { | ||
//// log.debug('Syntax error:' + err); | ||
//// log.debug(hash); | ||
////}; | ||
////sq.yy.parseError = parseError; | ||
// | ||
//newD3 = function() { | ||
// var o = { | ||
// append: function () { | ||
// return newD3(); | ||
// }, | ||
// attr: function () { | ||
// return this; | ||
// }, | ||
// style: function () { | ||
// return this; | ||
// }, | ||
// text: function () { | ||
// return this; | ||
// }, | ||
// 0:{ | ||
// 0: { | ||
// getBBox: function () { | ||
// return { | ||
// height: 10, | ||
// width: 20 | ||
// }; | ||
// } | ||
// } | ||
// | ||
// } | ||
// }; | ||
// | ||
// return o; | ||
//}; | ||
// | ||
//conf = { | ||
// diagramMarginX:50, | ||
// diagramMarginY:10, | ||
// actorMargin:50, | ||
// width:150, | ||
// // Height of actor boxes | ||
// height:65, | ||
// boxMargin:10, | ||
// messageMargin:40, | ||
// boxTextMargin:15, | ||
// noteMargin:25, | ||
// mirrorActors:true, | ||
// // Depending on css styling this might need adjustment | ||
// // Prolongs the edge of the diagram downwards | ||
// bottomMarginAdj:1 | ||
//}; | ||
//classRenderer.setConf(conf); | ||
// ... add whatever browser globals your tests might need ... | ||
//} | ||
Object.defineProperties(window.HTMLElement.prototype, { | ||
getBBox :{ | ||
get : function() {return {x:10,y:10,width:100,height:100}; } | ||
}, | ||
offsetLeft: { | ||
get: function() { return parseFloat(window.getComputedStyle(this).marginLeft) || 0; } | ||
}, | ||
offsetTop: { | ||
get: function() { return parseFloat(window.getComputedStyle(this).marginTop) || 0; } | ||
}, | ||
offsetHeight: { | ||
get: function() { return parseFloat(window.getComputedStyle(this).height) || 0; } | ||
}, | ||
offsetWidth: { | ||
get: function() { return parseFloat(window.getComputedStyle(this).width) || 0; } | ||
} | ||
}); | ||
}); | ||
it('it should handle one actor', function () { | ||
var str = 'classDiagram\n'+ | ||
'Class01 --|> Class02'; | ||
//classRenderer.draw(str,'tst'); | ||
//console.log(document.body.innerHTML); | ||
}); | ||
}); | ||
}); | ||
describe('when rendering a classDiagram', function () { | ||
beforeEach(function () { | ||
Object.defineProperties(window.HTMLElement.prototype, { | ||
getBBox: { | ||
get: function () { return { x: 10, y: 10, width: 100, height: 100 } } | ||
}, | ||
offsetLeft: { | ||
get: function () { return parseFloat(window.getComputedStyle(this).marginLeft) || 0 } | ||
}, | ||
offsetTop: { | ||
get: function () { return parseFloat(window.getComputedStyle(this).marginTop) || 0 } | ||
}, | ||
offsetHeight: { | ||
get: function () { return parseFloat(window.getComputedStyle(this).height) || 0 } | ||
}, | ||
offsetWidth: { | ||
get: function () { return parseFloat(window.getComputedStyle(this).width) || 0 } | ||
} | ||
}) | ||
}) | ||
}) | ||
}) |
@@ -53,3 +53,2 @@ /* parser generated by jison 0.4.17 */ | ||
token location info (@$, _$, etc.): { | ||
@@ -63,3 +62,2 @@ first_line: n, | ||
the parseError function receives a 'hash' object with these members for lexer and parser errors: { | ||
@@ -76,669 +74,666 @@ text: (matched text) | ||
*/ | ||
var parser = (function(){ | ||
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,11],$V1=[1,12],$V2=[1,13],$V3=[1,15],$V4=[1,16],$V5=[1,17],$V6=[6,8],$V7=[1,26],$V8=[1,27],$V9=[1,28],$Va=[1,29],$Vb=[1,30],$Vc=[1,31],$Vd=[6,8,13,17,23,26,27,28,29,30,31],$Ve=[6,8,13,17,23,26,27,28,29,30,31,45,46,47],$Vf=[23,45,46,47],$Vg=[23,30,31,45,46,47],$Vh=[23,26,27,28,29,45,46,47],$Vi=[6,8,13],$Vj=[1,46]; | ||
var parser = {trace: function trace() { }, | ||
yy: {}, | ||
symbols_: {"error":2,"mermaidDoc":3,"graphConfig":4,"CLASS_DIAGRAM":5,"NEWLINE":6,"statements":7,"EOF":8,"statement":9,"className":10,"alphaNumToken":11,"relationStatement":12,"LABEL":13,"classStatement":14,"methodStatement":15,"CLASS":16,"STRUCT_START":17,"members":18,"STRUCT_STOP":19,"MEMBER":20,"SEPARATOR":21,"relation":22,"STR":23,"relationType":24,"lineType":25,"AGGREGATION":26,"EXTENSION":27,"COMPOSITION":28,"DEPENDENCY":29,"LINE":30,"DOTTED_LINE":31,"commentToken":32,"textToken":33,"graphCodeTokens":34,"textNoTagsToken":35,"TAGSTART":36,"TAGEND":37,"==":38,"--":39,"PCT":40,"DEFAULT":41,"SPACE":42,"MINUS":43,"keywords":44,"UNICODE_TEXT":45,"NUM":46,"ALPHA":47,"$accept":0,"$end":1}, | ||
terminals_: {2:"error",5:"CLASS_DIAGRAM",6:"NEWLINE",8:"EOF",13:"LABEL",16:"CLASS",17:"STRUCT_START",19:"STRUCT_STOP",20:"MEMBER",21:"SEPARATOR",23:"STR",26:"AGGREGATION",27:"EXTENSION",28:"COMPOSITION",29:"DEPENDENCY",30:"LINE",31:"DOTTED_LINE",34:"graphCodeTokens",36:"TAGSTART",37:"TAGEND",38:"==",39:"--",40:"PCT",41:"DEFAULT",42:"SPACE",43:"MINUS",44:"keywords",45:"UNICODE_TEXT",46:"NUM",47:"ALPHA"}, | ||
productions_: [0,[3,1],[4,4],[7,1],[7,3],[10,2],[10,1],[9,1],[9,2],[9,1],[9,1],[14,2],[14,5],[18,1],[18,2],[15,1],[15,2],[15,1],[15,1],[12,3],[12,4],[12,4],[12,5],[22,3],[22,2],[22,2],[22,1],[24,1],[24,1],[24,1],[24,1],[25,1],[25,1],[32,1],[32,1],[33,1],[33,1],[33,1],[33,1],[33,1],[33,1],[33,1],[35,1],[35,1],[35,1],[35,1],[11,1],[11,1],[11,1]], | ||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
var parser = (function () { | ||
var o = function (k, v, o, l) { for (o = o || {}, l = k.length; l--; o[k[l]] = v);return o }, $V0 = [1, 11], $V1 = [1, 12], $V2 = [1, 13], $V3 = [1, 15], $V4 = [1, 16], $V5 = [1, 17], $V6 = [6, 8], $V7 = [1, 26], $V8 = [1, 27], $V9 = [1, 28], $Va = [1, 29], $Vb = [1, 30], $Vc = [1, 31], $Vd = [6, 8, 13, 17, 23, 26, 27, 28, 29, 30, 31], $Ve = [6, 8, 13, 17, 23, 26, 27, 28, 29, 30, 31, 45, 46, 47], $Vf = [23, 45, 46, 47], $Vg = [23, 30, 31, 45, 46, 47], $Vh = [23, 26, 27, 28, 29, 45, 46, 47], $Vi = [6, 8, 13], $Vj = [1, 46] | ||
var parser = {trace: function trace () { }, | ||
yy: {}, | ||
symbols_: {'error': 2, 'mermaidDoc': 3, 'graphConfig': 4, 'CLASS_DIAGRAM': 5, 'NEWLINE': 6, 'statements': 7, 'EOF': 8, 'statement': 9, 'className': 10, 'alphaNumToken': 11, 'relationStatement': 12, 'LABEL': 13, 'classStatement': 14, 'methodStatement': 15, 'CLASS': 16, 'STRUCT_START': 17, 'members': 18, 'STRUCT_STOP': 19, 'MEMBER': 20, 'SEPARATOR': 21, 'relation': 22, 'STR': 23, 'relationType': 24, 'lineType': 25, 'AGGREGATION': 26, 'EXTENSION': 27, 'COMPOSITION': 28, 'DEPENDENCY': 29, 'LINE': 30, 'DOTTED_LINE': 31, 'commentToken': 32, 'textToken': 33, 'graphCodeTokens': 34, 'textNoTagsToken': 35, 'TAGSTART': 36, 'TAGEND': 37, '==': 38, '--': 39, 'PCT': 40, 'DEFAULT': 41, 'SPACE': 42, 'MINUS': 43, 'keywords': 44, 'UNICODE_TEXT': 45, 'NUM': 46, 'ALPHA': 47, '$accept': 0, '$end': 1}, | ||
terminals_: {2: 'error', 5: 'CLASS_DIAGRAM', 6: 'NEWLINE', 8: 'EOF', 13: 'LABEL', 16: 'CLASS', 17: 'STRUCT_START', 19: 'STRUCT_STOP', 20: 'MEMBER', 21: 'SEPARATOR', 23: 'STR', 26: 'AGGREGATION', 27: 'EXTENSION', 28: 'COMPOSITION', 29: 'DEPENDENCY', 30: 'LINE', 31: 'DOTTED_LINE', 34: 'graphCodeTokens', 36: 'TAGSTART', 37: 'TAGEND', 38: '==', 39: '--', 40: 'PCT', 41: 'DEFAULT', 42: 'SPACE', 43: 'MINUS', 44: 'keywords', 45: 'UNICODE_TEXT', 46: 'NUM', 47: 'ALPHA'}, | ||
productions_: [0, [3, 1], [4, 4], [7, 1], [7, 3], [10, 2], [10, 1], [9, 1], [9, 2], [9, 1], [9, 1], [14, 2], [14, 5], [18, 1], [18, 2], [15, 1], [15, 2], [15, 1], [15, 1], [12, 3], [12, 4], [12, 4], [12, 5], [22, 3], [22, 2], [22, 2], [22, 1], [24, 1], [24, 1], [24, 1], [24, 1], [25, 1], [25, 1], [32, 1], [32, 1], [33, 1], [33, 1], [33, 1], [33, 1], [33, 1], [33, 1], [33, 1], [35, 1], [35, 1], [35, 1], [35, 1], [11, 1], [11, 1], [11, 1]], | ||
performAction: function anonymous (yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
/* this == yyval */ | ||
var $0 = $$.length - 1; | ||
switch (yystate) { | ||
case 5: | ||
this.$=$$[$0-1]+$$[$0]; | ||
break; | ||
case 6: | ||
this.$=$$[$0]; | ||
break; | ||
case 7: | ||
yy.addRelation($$[$0]); | ||
break; | ||
case 8: | ||
$$[$0-1].title = yy.cleanupLabel($$[$0]); yy.addRelation($$[$0-1]); | ||
break; | ||
case 12: | ||
/*console.log($$[$0-3],JSON.stringify($$[$0-1]));*/yy.addMembers($$[$0-3],$$[$0-1]); | ||
break; | ||
case 13: | ||
this.$ = [$$[$0]]; | ||
break; | ||
case 14: | ||
$$[$0].push($$[$0-1]);this.$=$$[$0]; | ||
break; | ||
case 15: | ||
/*console.log('Rel found',$$[$0]);*/ | ||
break; | ||
case 16: | ||
yy.addMembers($$[$0-1],yy.cleanupLabel($$[$0])); | ||
break; | ||
case 17: | ||
console.warn('Member',$$[$0]); | ||
break; | ||
case 18: | ||
/*console.log('sep found',$$[$0]);*/ | ||
break; | ||
case 19: | ||
this.$ = {'id1':$$[$0-2],'id2':$$[$0], relation:$$[$0-1], relationTitle1:'none', relationTitle2:'none'}; | ||
break; | ||
case 20: | ||
this.$ = {id1:$$[$0-3], id2:$$[$0], relation:$$[$0-1], relationTitle1:$$[$0-2], relationTitle2:'none'} | ||
break; | ||
case 21: | ||
this.$ = {id1:$$[$0-3], id2:$$[$0], relation:$$[$0-2], relationTitle1:'none', relationTitle2:$$[$0-1]}; | ||
break; | ||
case 22: | ||
this.$ = {id1:$$[$0-4], id2:$$[$0], relation:$$[$0-2], relationTitle1:$$[$0-3], relationTitle2:$$[$0-1]} | ||
break; | ||
case 23: | ||
this.$={type1:$$[$0-2],type2:$$[$0],lineType:$$[$0-1]}; | ||
break; | ||
case 24: | ||
this.$={type1:'none',type2:$$[$0],lineType:$$[$0-1]}; | ||
break; | ||
case 25: | ||
this.$={type1:$$[$0-1],type2:'none',lineType:$$[$0]}; | ||
break; | ||
case 26: | ||
this.$={type1:'none',type2:'none',lineType:$$[$0]}; | ||
break; | ||
case 27: | ||
this.$=yy.relationType.AGGREGATION; | ||
break; | ||
case 28: | ||
this.$=yy.relationType.EXTENSION; | ||
break; | ||
case 29: | ||
this.$=yy.relationType.COMPOSITION; | ||
break; | ||
case 30: | ||
this.$=yy.relationType.DEPENDENCY; | ||
break; | ||
case 31: | ||
this.$=yy.lineType.LINE; | ||
break; | ||
case 32: | ||
this.$=yy.lineType.DOTTED_LINE; | ||
break; | ||
} | ||
}, | ||
table: [{3:1,4:2,5:[1,3]},{1:[3]},{1:[2,1]},{6:[1,4]},{7:5,9:6,10:10,11:14,12:7,14:8,15:9,16:$V0,20:$V1,21:$V2,45:$V3,46:$V4,47:$V5},{8:[1,18]},{6:[1,19],8:[2,3]},o($V6,[2,7],{13:[1,20]}),o($V6,[2,9]),o($V6,[2,10]),o($V6,[2,15],{22:21,24:24,25:25,13:[1,23],23:[1,22],26:$V7,27:$V8,28:$V9,29:$Va,30:$Vb,31:$Vc}),{10:32,11:14,45:$V3,46:$V4,47:$V5},o($V6,[2,17]),o($V6,[2,18]),o($Vd,[2,6],{11:14,10:33,45:$V3,46:$V4,47:$V5}),o($Ve,[2,46]),o($Ve,[2,47]),o($Ve,[2,48]),{1:[2,2]},{7:34,9:6,10:10,11:14,12:7,14:8,15:9,16:$V0,20:$V1,21:$V2,45:$V3,46:$V4,47:$V5},o($V6,[2,8]),{10:35,11:14,23:[1,36],45:$V3,46:$V4,47:$V5},{22:37,24:24,25:25,26:$V7,27:$V8,28:$V9,29:$Va,30:$Vb,31:$Vc},o($V6,[2,16]),{25:38,30:$Vb,31:$Vc},o($Vf,[2,26],{24:39,26:$V7,27:$V8,28:$V9,29:$Va}),o($Vg,[2,27]),o($Vg,[2,28]),o($Vg,[2,29]),o($Vg,[2,30]),o($Vh,[2,31]),o($Vh,[2,32]),o($V6,[2,11],{17:[1,40]}),o($Vd,[2,5]),{8:[2,4]},o($Vi,[2,19]),{10:41,11:14,45:$V3,46:$V4,47:$V5},{10:42,11:14,23:[1,43],45:$V3,46:$V4,47:$V5},o($Vf,[2,25],{24:44,26:$V7,27:$V8,28:$V9,29:$Va}),o($Vf,[2,24]),{18:45,20:$Vj},o($Vi,[2,21]),o($Vi,[2,20]),{10:47,11:14,45:$V3,46:$V4,47:$V5},o($Vf,[2,23]),{19:[1,48]},{18:49,19:[2,13],20:$Vj},o($Vi,[2,22]),o($V6,[2,12]),{19:[2,14]}], | ||
defaultActions: {2:[2,1],18:[2,2],34:[2,4],49:[2,14]}, | ||
parseError: function parseError(str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str); | ||
} else { | ||
var $0 = $$.length - 1 | ||
switch (yystate) { | ||
case 5: | ||
this.$ = $$[$0 - 1] + $$[$0] | ||
break | ||
case 6: | ||
this.$ = $$[$0] | ||
break | ||
case 7: | ||
yy.addRelation($$[$0]) | ||
break | ||
case 8: | ||
$$[$0 - 1].title = yy.cleanupLabel($$[$0]); yy.addRelation($$[$0 - 1]) | ||
break | ||
case 12: | ||
/* console.log($$[$0-3],JSON.stringify($$[$0-1])); */yy.addMembers($$[$0 - 3], $$[$0 - 1]) | ||
break | ||
case 13: | ||
this.$ = [$$[$0]] | ||
break | ||
case 14: | ||
$$[$0].push($$[$0 - 1]); this.$ = $$[$0] | ||
break | ||
case 15: | ||
/* console.log('Rel found',$$[$0]); */ | ||
break | ||
case 16: | ||
yy.addMembers($$[$0 - 1], yy.cleanupLabel($$[$0])) | ||
break | ||
case 17: | ||
console.warn('Member', $$[$0]) | ||
break | ||
case 18: | ||
/* console.log('sep found',$$[$0]); */ | ||
break | ||
case 19: | ||
this.$ = {'id1': $$[$0 - 2], 'id2': $$[$0], relation: $$[$0 - 1], relationTitle1: 'none', relationTitle2: 'none'} | ||
break | ||
case 20: | ||
this.$ = {id1: $$[$0 - 3], id2: $$[$0], relation: $$[$0 - 1], relationTitle1: $$[$0 - 2], relationTitle2: 'none'} | ||
break | ||
case 21: | ||
this.$ = {id1: $$[$0 - 3], id2: $$[$0], relation: $$[$0 - 2], relationTitle1: 'none', relationTitle2: $$[$0 - 1]} | ||
break | ||
case 22: | ||
this.$ = {id1: $$[$0 - 4], id2: $$[$0], relation: $$[$0 - 2], relationTitle1: $$[$0 - 3], relationTitle2: $$[$0 - 1]} | ||
break | ||
case 23: | ||
this.$ = {type1: $$[$0 - 2], type2: $$[$0], lineType: $$[$0 - 1]} | ||
break | ||
case 24: | ||
this.$ = {type1: 'none', type2: $$[$0], lineType: $$[$0 - 1]} | ||
break | ||
case 25: | ||
this.$ = {type1: $$[$0 - 1], type2: 'none', lineType: $$[$0]} | ||
break | ||
case 26: | ||
this.$ = {type1: 'none', type2: 'none', lineType: $$[$0]} | ||
break | ||
case 27: | ||
this.$ = yy.relationType.AGGREGATION | ||
break | ||
case 28: | ||
this.$ = yy.relationType.EXTENSION | ||
break | ||
case 29: | ||
this.$ = yy.relationType.COMPOSITION | ||
break | ||
case 30: | ||
this.$ = yy.relationType.DEPENDENCY | ||
break | ||
case 31: | ||
this.$ = yy.lineType.LINE | ||
break | ||
case 32: | ||
this.$ = yy.lineType.DOTTED_LINE | ||
break | ||
} | ||
}, | ||
table: [{3: 1, 4: 2, 5: [1, 3]}, {1: [3]}, {1: [2, 1]}, {6: [1, 4]}, {7: 5, 9: 6, 10: 10, 11: 14, 12: 7, 14: 8, 15: 9, 16: $V0, 20: $V1, 21: $V2, 45: $V3, 46: $V4, 47: $V5}, {8: [1, 18]}, {6: [1, 19], 8: [2, 3]}, o($V6, [2, 7], {13: [1, 20]}), o($V6, [2, 9]), o($V6, [2, 10]), o($V6, [2, 15], {22: 21, 24: 24, 25: 25, 13: [1, 23], 23: [1, 22], 26: $V7, 27: $V8, 28: $V9, 29: $Va, 30: $Vb, 31: $Vc}), {10: 32, 11: 14, 45: $V3, 46: $V4, 47: $V5}, o($V6, [2, 17]), o($V6, [2, 18]), o($Vd, [2, 6], {11: 14, 10: 33, 45: $V3, 46: $V4, 47: $V5}), o($Ve, [2, 46]), o($Ve, [2, 47]), o($Ve, [2, 48]), {1: [2, 2]}, {7: 34, 9: 6, 10: 10, 11: 14, 12: 7, 14: 8, 15: 9, 16: $V0, 20: $V1, 21: $V2, 45: $V3, 46: $V4, 47: $V5}, o($V6, [2, 8]), {10: 35, 11: 14, 23: [1, 36], 45: $V3, 46: $V4, 47: $V5}, {22: 37, 24: 24, 25: 25, 26: $V7, 27: $V8, 28: $V9, 29: $Va, 30: $Vb, 31: $Vc}, o($V6, [2, 16]), {25: 38, 30: $Vb, 31: $Vc}, o($Vf, [2, 26], {24: 39, 26: $V7, 27: $V8, 28: $V9, 29: $Va}), o($Vg, [2, 27]), o($Vg, [2, 28]), o($Vg, [2, 29]), o($Vg, [2, 30]), o($Vh, [2, 31]), o($Vh, [2, 32]), o($V6, [2, 11], {17: [1, 40]}), o($Vd, [2, 5]), {8: [2, 4]}, o($Vi, [2, 19]), {10: 41, 11: 14, 45: $V3, 46: $V4, 47: $V5}, {10: 42, 11: 14, 23: [1, 43], 45: $V3, 46: $V4, 47: $V5}, o($Vf, [2, 25], {24: 44, 26: $V7, 27: $V8, 28: $V9, 29: $Va}), o($Vf, [2, 24]), {18: 45, 20: $Vj}, o($Vi, [2, 21]), o($Vi, [2, 20]), {10: 47, 11: 14, 45: $V3, 46: $V4, 47: $V5}, o($Vf, [2, 23]), {19: [1, 48]}, {18: 49, 19: [2, 13], 20: $Vj}, o($Vi, [2, 22]), o($V6, [2, 12]), {19: [2, 14]}], | ||
defaultActions: {2: [2, 1], 18: [2, 2], 34: [2, 4], 49: [2, 14]}, | ||
parseError: function parseError (str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str) | ||
} else { | ||
function _parseError (msg, hash) { | ||
this.message = msg; | ||
this.hash = hash; | ||
this.message = msg | ||
this.hash = hash | ||
} | ||
_parseError.prototype = Error; | ||
_parseError.prototype = Error | ||
throw new _parseError(str, hash); | ||
} | ||
}, | ||
parse: function parse(input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; | ||
var args = lstack.slice.call(arguments, 1); | ||
var lexer = Object.create(this.lexer); | ||
var sharedState = { yy: {} }; | ||
for (var k in this.yy) { | ||
throw new _parseError(str, hash) | ||
} | ||
}, | ||
parse: function parse (input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1 | ||
var args = lstack.slice.call(arguments, 1) | ||
var lexer = Object.create(this.lexer) | ||
var sharedState = { yy: {} } | ||
for (var k in this.yy) { | ||
if (Object.prototype.hasOwnProperty.call(this.yy, k)) { | ||
sharedState.yy[k] = this.yy[k]; | ||
sharedState.yy[k] = this.yy[k] | ||
} | ||
} | ||
lexer.setInput(input, sharedState.yy); | ||
sharedState.yy.lexer = lexer; | ||
sharedState.yy.parser = this; | ||
if (typeof lexer.yylloc == 'undefined') { | ||
lexer.yylloc = {}; | ||
} | ||
var yyloc = lexer.yylloc; | ||
lstack.push(yyloc); | ||
var ranges = lexer.options && lexer.options.ranges; | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError; | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError; | ||
} | ||
function popStack(n) { | ||
stack.length = stack.length - 2 * n; | ||
vstack.length = vstack.length - n; | ||
lstack.length = lstack.length - n; | ||
} | ||
_token_stack: | ||
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]; | ||
} | ||
lexer.setInput(input, sharedState.yy) | ||
sharedState.yy.lexer = lexer | ||
sharedState.yy.parser = this | ||
if (typeof lexer.yylloc === 'undefined') { | ||
lexer.yylloc = {} | ||
} | ||
var yyloc = lexer.yylloc | ||
lstack.push(yyloc) | ||
var ranges = lexer.options && lexer.options.ranges | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError | ||
} | ||
function popStack (n) { | ||
stack.length = stack.length - 2 * n | ||
vstack.length = vstack.length - n | ||
lstack.length = lstack.length - n | ||
} | ||
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] | ||
if (this.defaultActions[state]) { | ||
action = this.defaultActions[state]; | ||
action = this.defaultActions[state] | ||
} else { | ||
if (symbol === null || typeof symbol == 'undefined') { | ||
symbol = lex(); | ||
if (symbol === null || typeof symbol === 'undefined') { | ||
symbol = lex() | ||
} | ||
action = table[state] && table[state][symbol] | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = '' | ||
expected = [] | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\'') | ||
} | ||
action = table[state] && table[state][symbol]; | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'' | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'') | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}) | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = ''; | ||
expected = []; | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\''); | ||
} | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}); | ||
} | ||
if (action[0] instanceof Array && action.length > 1) { | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol) | ||
} | ||
switch (action[0]) { | ||
case 1: | ||
stack.push(symbol); | ||
vstack.push(lexer.yytext); | ||
lstack.push(lexer.yylloc); | ||
stack.push(action[1]); | ||
symbol = null; | ||
case 1: | ||
stack.push(symbol) | ||
vstack.push(lexer.yytext) | ||
lstack.push(lexer.yylloc) | ||
stack.push(action[1]) | ||
symbol = null | ||
if (!preErrorSymbol) { | ||
yyleng = lexer.yyleng; | ||
yytext = lexer.yytext; | ||
yylineno = lexer.yylineno; | ||
yyloc = lexer.yylloc; | ||
if (recovering > 0) { | ||
recovering--; | ||
} | ||
yyleng = lexer.yyleng | ||
yytext = lexer.yytext | ||
yylineno = lexer.yylineno | ||
yyloc = lexer.yylloc | ||
if (recovering > 0) { | ||
recovering-- | ||
} | ||
} else { | ||
symbol = preErrorSymbol; | ||
preErrorSymbol = null; | ||
symbol = preErrorSymbol | ||
preErrorSymbol = null | ||
} | ||
break; | ||
case 2: | ||
len = this.productions_[action[1]][1]; | ||
yyval.$ = vstack[vstack.length - len]; | ||
break | ||
case 2: | ||
len = this.productions_[action[1]][1] | ||
yyval.$ = vstack[vstack.length - len] | ||
yyval._$ = { | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
}; | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
} | ||
if (ranges) { | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
]; | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
] | ||
} | ||
r = this.performAction.apply(yyval, [ | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)); | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)) | ||
if (typeof r !== 'undefined') { | ||
return r; | ||
return r | ||
} | ||
if (len) { | ||
stack = stack.slice(0, -1 * len * 2); | ||
vstack = vstack.slice(0, -1 * len); | ||
lstack = lstack.slice(0, -1 * len); | ||
stack = stack.slice(0, -1 * len * 2) | ||
vstack = vstack.slice(0, -1 * len) | ||
lstack = lstack.slice(0, -1 * len) | ||
} | ||
stack.push(this.productions_[action[1]][0]); | ||
vstack.push(yyval.$); | ||
lstack.push(yyval._$); | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; | ||
stack.push(newState); | ||
break; | ||
case 3: | ||
return true; | ||
stack.push(this.productions_[action[1]][0]) | ||
vstack.push(yyval.$) | ||
lstack.push(yyval._$) | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]] | ||
stack.push(newState) | ||
break | ||
case 3: | ||
return true | ||
} | ||
} | ||
return true; | ||
}}; | ||
} | ||
return true | ||
}} | ||
/* generated by jison-lex 0.3.4 */ | ||
var lexer = (function(){ | ||
var lexer = ({ | ||
var lexer = (function () { | ||
var lexer = ({ | ||
EOF:1, | ||
EOF: 1, | ||
parseError:function parseError(str, hash) { | ||
parseError: function parseError (str, hash) { | ||
if (this.yy.parser) { | ||
this.yy.parser.parseError(str, hash); | ||
this.yy.parser.parseError(str, hash) | ||
} else { | ||
throw new Error(str); | ||
throw new Error(str) | ||
} | ||
}, | ||
}, | ||
// resets the lexer, sets new input | ||
setInput:function (input, yy) { | ||
this.yy = yy || this.yy || {}; | ||
this._input = input; | ||
this._more = this._backtrack = this.done = false; | ||
this.yylineno = this.yyleng = 0; | ||
this.yytext = this.matched = this.match = ''; | ||
this.conditionStack = ['INITIAL']; | ||
setInput: function (input, yy) { | ||
this.yy = yy || this.yy || {} | ||
this._input = input | ||
this._more = this._backtrack = this.done = false | ||
this.yylineno = this.yyleng = 0 | ||
this.yytext = this.matched = this.match = '' | ||
this.conditionStack = ['INITIAL'] | ||
this.yylloc = { | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
}; | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [0,0]; | ||
this.yylloc.range = [0, 0] | ||
} | ||
this.offset = 0; | ||
return this; | ||
}, | ||
this.offset = 0 | ||
return this | ||
}, | ||
// consumes and returns one char from the input | ||
input:function () { | ||
var ch = this._input[0]; | ||
this.yytext += ch; | ||
this.yyleng++; | ||
this.offset++; | ||
this.match += ch; | ||
this.matched += ch; | ||
var lines = ch.match(/(?:\r\n?|\n).*/g); | ||
input: function () { | ||
var ch = this._input[0] | ||
this.yytext += ch | ||
this.yyleng++ | ||
this.offset++ | ||
this.match += ch | ||
this.matched += ch | ||
var lines = ch.match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno++; | ||
this.yylloc.last_line++; | ||
this.yylineno++ | ||
this.yylloc.last_line++ | ||
} else { | ||
this.yylloc.last_column++; | ||
this.yylloc.last_column++ | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range[1]++; | ||
this.yylloc.range[1]++ | ||
} | ||
this._input = this._input.slice(1); | ||
return ch; | ||
}, | ||
this._input = this._input.slice(1) | ||
return ch | ||
}, | ||
// unshifts one char (or a string) into the input | ||
unput:function (ch) { | ||
var len = ch.length; | ||
var lines = ch.split(/(?:\r\n?|\n)/g); | ||
unput: function (ch) { | ||
var len = ch.length | ||
var lines = ch.split(/(?:\r\n?|\n)/g) | ||
this._input = ch + this._input; | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len); | ||
//this.yyleng -= len; | ||
this.offset -= len; | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g); | ||
this.match = this.match.substr(0, this.match.length - 1); | ||
this.matched = this.matched.substr(0, this.matched.length - 1); | ||
this._input = ch + this._input | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len) | ||
// this.yyleng -= len; | ||
this.offset -= len | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g) | ||
this.match = this.match.substr(0, this.match.length - 1) | ||
this.matched = this.matched.substr(0, this.matched.length - 1) | ||
if (lines.length - 1) { | ||
this.yylineno -= lines.length - 1; | ||
this.yylineno -= lines.length - 1 | ||
} | ||
var r = this.yylloc.range; | ||
var r = this.yylloc.range | ||
this.yylloc = { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines ? | ||
(lines.length === oldLines.length ? this.yylloc.first_column : 0) | ||
+ oldLines[oldLines.length - lines.length].length - lines[0].length : | ||
this.yylloc.first_column - len | ||
}; | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines | ||
? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + | ||
oldLines[oldLines.length - lines.length].length - lines[0].length | ||
: this.yylloc.first_column - len | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len]; | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len] | ||
} | ||
this.yyleng = this.yytext.length; | ||
return this; | ||
}, | ||
this.yyleng = this.yytext.length | ||
return this | ||
}, | ||
// When called from action, caches matched text and appends it on next action | ||
more:function () { | ||
this._more = true; | ||
return this; | ||
}, | ||
more: function () { | ||
this._more = true | ||
return this | ||
}, | ||
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. | ||
reject:function () { | ||
reject: function () { | ||
if (this.options.backtrack_lexer) { | ||
this._backtrack = true; | ||
this._backtrack = true | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
return this; | ||
}, | ||
return this | ||
}, | ||
// retain first n characters of the match | ||
less:function (n) { | ||
this.unput(this.match.slice(n)); | ||
}, | ||
less: function (n) { | ||
this.unput(this.match.slice(n)) | ||
}, | ||
// displays already matched input, i.e. for error messages | ||
pastInput:function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length); | ||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); | ||
}, | ||
pastInput: function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length) | ||
return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') | ||
}, | ||
// displays upcoming input, i.e. for error messages | ||
upcomingInput:function () { | ||
var next = this.match; | ||
upcomingInput: function () { | ||
var next = this.match | ||
if (next.length < 20) { | ||
next += this._input.substr(0, 20-next.length); | ||
next += this._input.substr(0, 20 - next.length) | ||
} | ||
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); | ||
}, | ||
return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, '') | ||
}, | ||
// displays the character position where the lexing error occurred, i.e. for error messages | ||
showPosition:function () { | ||
var pre = this.pastInput(); | ||
var c = new Array(pre.length + 1).join("-"); | ||
return pre + this.upcomingInput() + "\n" + c + "^"; | ||
}, | ||
showPosition: function () { | ||
var pre = this.pastInput() | ||
var c = new Array(pre.length + 1).join('-') | ||
return pre + this.upcomingInput() + '\n' + c + '^' | ||
}, | ||
// test the lexed token: return FALSE when not a match, otherwise return token | ||
test_match:function (match, indexed_rule) { | ||
test_match: function (match, indexed_rule) { | ||
var token, | ||
lines, | ||
backup; | ||
lines, | ||
backup | ||
if (this.options.backtrack_lexer) { | ||
// save context | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
}; | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0); | ||
} | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
} | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0) | ||
} | ||
} | ||
lines = match[0].match(/(?:\r\n?|\n).*/g); | ||
lines = match[0].match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno += lines.length; | ||
this.yylineno += lines.length | ||
} | ||
this.yylloc = { | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines ? | ||
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : | ||
this.yylloc.last_column + match[0].length | ||
}; | ||
this.yytext += match[0]; | ||
this.match += match[0]; | ||
this.matches = match; | ||
this.yyleng = this.yytext.length; | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines | ||
? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length | ||
: this.yylloc.last_column + match[0].length | ||
} | ||
this.yytext += match[0] | ||
this.match += match[0] | ||
this.matches = match | ||
this.yyleng = this.yytext.length | ||
if (this.options.ranges) { | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng]; | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng] | ||
} | ||
this._more = false; | ||
this._backtrack = false; | ||
this._input = this._input.slice(match[0].length); | ||
this.matched += match[0]; | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); | ||
this._more = false | ||
this._backtrack = false | ||
this._input = this._input.slice(match[0].length) | ||
this.matched += match[0] | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]) | ||
if (this.done && this._input) { | ||
this.done = false; | ||
this.done = false | ||
} | ||
if (token) { | ||
return token; | ||
return token | ||
} else if (this._backtrack) { | ||
// recover context | ||
for (var k in backup) { | ||
this[k] = backup[k]; | ||
} | ||
return false; // rule action called reject() implying the next rule should be tested instead. | ||
for (var k in backup) { | ||
this[k] = backup[k] | ||
} | ||
return false // rule action called reject() implying the next rule should be tested instead. | ||
} | ||
return false; | ||
}, | ||
return false | ||
}, | ||
// return next match in input | ||
next:function () { | ||
next: function () { | ||
if (this.done) { | ||
return this.EOF; | ||
return this.EOF | ||
} | ||
if (!this._input) { | ||
this.done = true; | ||
this.done = true | ||
} | ||
var token, | ||
match, | ||
tempMatch, | ||
index; | ||
match, | ||
tempMatch, | ||
index | ||
if (!this._more) { | ||
this.yytext = ''; | ||
this.match = ''; | ||
this.yytext = '' | ||
this.match = '' | ||
} | ||
var rules = this._currentRules(); | ||
var rules = this._currentRules() | ||
for (var i = 0; i < rules.length; i++) { | ||
tempMatch = this._input.match(this.rules[rules[i]]); | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch; | ||
index = i; | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]); | ||
if (token !== false) { | ||
return token; | ||
} else if (this._backtrack) { | ||
match = false; | ||
continue; // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
tempMatch = this._input.match(this.rules[rules[i]]) | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch | ||
index = i | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]) | ||
if (token !== false) { | ||
return token | ||
} else if (this._backtrack) { | ||
match = false | ||
continue // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
} | ||
} else if (!this.options.flex) { | ||
break; | ||
} | ||
return false | ||
} | ||
} else if (!this.options.flex) { | ||
break | ||
} | ||
} | ||
} | ||
if (match) { | ||
token = this.test_match(match, rules[index]); | ||
if (token !== false) { | ||
return token; | ||
} | ||
token = this.test_match(match, rules[index]) | ||
if (token !== false) { | ||
return token | ||
} | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
return false | ||
} | ||
if (this._input === "") { | ||
return this.EOF; | ||
if (this._input === '') { | ||
return this.EOF | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
}, | ||
}, | ||
// return next match that has a token | ||
lex:function lex() { | ||
var r = this.next(); | ||
lex: function lex () { | ||
var r = this.next() | ||
if (r) { | ||
return r; | ||
return r | ||
} else { | ||
return this.lex(); | ||
return this.lex() | ||
} | ||
}, | ||
}, | ||
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) | ||
begin:function begin(condition) { | ||
this.conditionStack.push(condition); | ||
}, | ||
begin: function begin (condition) { | ||
this.conditionStack.push(condition) | ||
}, | ||
// pop the previously active lexer condition state off the condition stack | ||
popState:function popState() { | ||
var n = this.conditionStack.length - 1; | ||
popState: function popState () { | ||
var n = this.conditionStack.length - 1 | ||
if (n > 0) { | ||
return this.conditionStack.pop(); | ||
return this.conditionStack.pop() | ||
} else { | ||
return this.conditionStack[0]; | ||
return this.conditionStack[0] | ||
} | ||
}, | ||
}, | ||
// produce the lexer rule set which is active for the currently active lexer condition state | ||
_currentRules:function _currentRules() { | ||
_currentRules: function _currentRules () { | ||
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules | ||
} else { | ||
return this.conditions["INITIAL"].rules; | ||
return this.conditions['INITIAL'].rules | ||
} | ||
}, | ||
}, | ||
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available | ||
topState:function topState(n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0); | ||
topState: function topState (n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0) | ||
if (n >= 0) { | ||
return this.conditionStack[n]; | ||
return this.conditionStack[n] | ||
} else { | ||
return "INITIAL"; | ||
return 'INITIAL' | ||
} | ||
}, | ||
}, | ||
// alias for begin(condition) | ||
pushState:function pushState(condition) { | ||
this.begin(condition); | ||
}, | ||
pushState: function pushState (condition) { | ||
this.begin(condition) | ||
}, | ||
// return the number of states currently on the stack | ||
stateStackSize:function stateStackSize() { | ||
return this.conditionStack.length; | ||
}, | ||
options: {}, | ||
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { | ||
var YYSTATE=YY_START; | ||
switch($avoiding_name_collisions) { | ||
case 0:/* do nothing */ | ||
break; | ||
case 1:return 6; | ||
break; | ||
case 2:/* skip whitespace */ | ||
break; | ||
case 3:return 5; | ||
break; | ||
case 4: this.begin("struct"); /*console.log('Starting struct');*/return 17; | ||
break; | ||
case 5: /*console.log('Ending struct');*/this.popState(); return 19; | ||
break; | ||
case 6:/* nothing */ | ||
break; | ||
case 7: /*console.log('lex-member: ' + yy_.yytext);*/ return "MEMBER"; | ||
break; | ||
case 8:return 16; | ||
break; | ||
case 9:this.begin("string"); | ||
break; | ||
case 10:this.popState(); | ||
break; | ||
case 11:return "STR"; | ||
break; | ||
case 12:return 27; | ||
break; | ||
case 13:return 27; | ||
break; | ||
case 14:return 29; | ||
break; | ||
case 15:return 29; | ||
break; | ||
case 16:return 28; | ||
break; | ||
case 17:return 26; | ||
break; | ||
case 18:return 30; | ||
break; | ||
case 19:return 31; | ||
break; | ||
case 20:return 13; | ||
break; | ||
case 21:return 43; | ||
break; | ||
case 22:return 'DOT'; | ||
break; | ||
case 23:return 'PLUS'; | ||
break; | ||
case 24:return 40; | ||
break; | ||
case 25:return 'EQUALS'; | ||
break; | ||
case 26:return 'EQUALS'; | ||
break; | ||
case 27:return 47; | ||
break; | ||
case 28:return 'PUNCTUATION'; | ||
break; | ||
case 29:return 46; | ||
break; | ||
case 30:return 45; | ||
break; | ||
case 31:return 42; | ||
break; | ||
case 32:return 8; | ||
break; | ||
} | ||
}, | ||
rules: [/^(?:%%[^\n]*)/,/^(?:\n+)/,/^(?:\s+)/,/^(?:classDiagram\b)/,/^(?:[\{])/,/^(?:\})/,/^(?:[\n])/,/^(?:[^\{\}\n]*)/,/^(?:class\b)/,/^(?:["])/,/^(?:["])/,/^(?:[^"]*)/,/^(?:\s*<\|)/,/^(?:\s*\|>)/,/^(?:\s*>)/,/^(?:\s*<)/,/^(?:\s*\*)/,/^(?:\s*o\b)/,/^(?:--)/,/^(?:\.\.)/,/^(?::[^#\n;]+)/,/^(?:-)/,/^(?:\.)/,/^(?:\+)/,/^(?:%)/,/^(?:=)/,/^(?:=)/,/^(?:[A-Za-z]+)/,/^(?:[!"#$%&'*+,-.`?\\_\/])/,/^(?:[0-9]+)/,/^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/,/^(?:\s)/,/^(?:$)/], | ||
conditions: {"string":{"rules":[10,11],"inclusive":false},"struct":{"rules":[5,6,7],"inclusive":false},"INITIAL":{"rules":[0,1,2,3,4,8,9,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32],"inclusive":true}} | ||
}); | ||
return lexer; | ||
})(); | ||
parser.lexer = lexer; | ||
function Parser () { | ||
this.yy = {}; | ||
} | ||
Parser.prototype = parser;parser.Parser = Parser; | ||
return new Parser; | ||
})(); | ||
stateStackSize: function stateStackSize () { | ||
return this.conditionStack.length | ||
}, | ||
options: {}, | ||
performAction: function anonymous (yy, yy_, $avoiding_name_collisions, YY_START) { | ||
var YYSTATE = YY_START | ||
switch ($avoiding_name_collisions) { | ||
case 0:/* do nothing */ | ||
break | ||
case 1:return 6 | ||
break | ||
case 2:/* skip whitespace */ | ||
break | ||
case 3:return 5 | ||
break | ||
case 4: this.begin('struct'); /* console.log('Starting struct'); */return 17 | ||
break | ||
case 5: /* console.log('Ending struct'); */this.popState(); return 19 | ||
break | ||
case 6:/* nothing */ | ||
break | ||
case 7: return 'MEMBER' | ||
break | ||
case 8:return 16 | ||
break | ||
case 9:this.begin('string') | ||
break | ||
case 10:this.popState() | ||
break | ||
case 11:return 'STR' | ||
break | ||
case 12:return 27 | ||
break | ||
case 13:return 27 | ||
break | ||
case 14:return 29 | ||
break | ||
case 15:return 29 | ||
break | ||
case 16:return 28 | ||
break | ||
case 17:return 26 | ||
break | ||
case 18:return 30 | ||
break | ||
case 19:return 31 | ||
break | ||
case 20:return 13 | ||
break | ||
case 21:return 43 | ||
break | ||
case 22:return 'DOT' | ||
break | ||
case 23:return 'PLUS' | ||
break | ||
case 24:return 40 | ||
break | ||
case 25:return 'EQUALS' | ||
break | ||
case 26:return 'EQUALS' | ||
break | ||
case 27:return 47 | ||
break | ||
case 28:return 'PUNCTUATION' | ||
break | ||
case 29:return 46 | ||
break | ||
case 30:return 45 | ||
break | ||
case 31:return 42 | ||
break | ||
case 32:return 8 | ||
break | ||
} | ||
}, | ||
rules: [/^(?:%%[^\n]*)/, /^(?:\n+)/, /^(?:\s+)/, /^(?:classDiagram\b)/, /^(?:[\{])/, /^(?:\})/, /^(?:[\n])/, /^(?:[^\{\}\n]*)/, /^(?:class\b)/, /^(?:["])/, /^(?:["])/, /^(?:[^"]*)/, /^(?:\s*<\|)/, /^(?:\s*\|>)/, /^(?:\s*>)/, /^(?:\s*<)/, /^(?:\s*\*)/, /^(?:\s*o\b)/, /^(?:--)/, /^(?:\.\.)/, /^(?::[^#\n;]+)/, /^(?:-)/, /^(?:\.)/, /^(?:\+)/, /^(?:%)/, /^(?:=)/, /^(?:=)/, /^(?:[A-Za-z]+)/, /^(?:[!"#$%&'*+,-.`?\\_\/])/, /^(?:[0-9]+)/, /^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/, /^(?:\s)/, /^(?:$)/], | ||
conditions: {'string': {'rules': [10, 11], 'inclusive': false}, 'struct': {'rules': [5, 6, 7], 'inclusive': false}, 'INITIAL': {'rules': [0, 1, 2, 3, 4, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32], 'inclusive': true}} | ||
}) | ||
return lexer | ||
})() | ||
parser.lexer = lexer | ||
function Parser () { | ||
this.yy = {} | ||
} | ||
Parser.prototype = parser; parser.Parser = Parser | ||
return new Parser() | ||
})() | ||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') { | ||
exports.parser = parser; | ||
exports.Parser = parser.Parser; | ||
exports.parse = function () { return parser.parse.apply(parser, arguments); }; | ||
exports.main = function commonjsMain(args) { | ||
exports.parser = parser | ||
exports.Parser = parser.Parser | ||
exports.parse = function () { return parser.parse.apply(parser, arguments) } | ||
exports.main = function commonjsMain (args) { | ||
if (!args[1]) { | ||
console.log('Usage: '+args[0]+' FILE'); | ||
process.exit(1); | ||
console.log('Usage: ' + args[0] + ' FILE') | ||
process.exit(1) | ||
} | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); | ||
return exports.parser.parse(source); | ||
}; | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)); | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), 'utf8') | ||
return exports.parser.parse(source) | ||
} | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)) | ||
} | ||
} | ||
} |
@@ -0,21 +1,22 @@ | ||
/* eslint-env jasmine */ | ||
/** | ||
* Created by knut on 14-11-18. | ||
*/ | ||
describe('when parsing an info graph it',function() { | ||
var ex; | ||
beforeEach(function () { | ||
ex = require('./parser/example').parser; | ||
ex.yy = require('./exampleDb'); | ||
}); | ||
describe('when parsing an info graph it', function () { | ||
var ex | ||
beforeEach(function () { | ||
ex = require('./parser/example').parser | ||
ex.yy = require('./exampleDb') | ||
}) | ||
it('should handle an info definition', function () { | ||
var str = 'info\nsay: hello'; | ||
it('should handle an info definition', function () { | ||
var str = 'info\nsay: hello' | ||
ex.parse(str); | ||
}); | ||
it('should handle an showMessage statement definition', function () { | ||
var str = 'info\nshowInfo'; | ||
ex.parse(str) | ||
}) | ||
it('should handle an showMessage statement definition', function () { | ||
var str = 'info\nshowInfo' | ||
ex.parse(str); | ||
}); | ||
}); | ||
ex.parse(str) | ||
}) | ||
}) |
/** | ||
* Created by knut on 15-01-14. | ||
*/ | ||
var Logger = require('../../logger'); | ||
var log = new Logger.Log(); | ||
var Logger = require('../../logger') | ||
var log = Logger.Log | ||
var message = ''; | ||
var info = false; | ||
var message = '' | ||
var info = false | ||
exports.setMessage = function(txt){ | ||
log.debug('Setting message to: '+txt); | ||
message = txt; | ||
}; | ||
exports.setMessage = function (txt) { | ||
log.debug('Setting message to: ' + txt) | ||
message = txt | ||
} | ||
exports.getMessage = function(){ | ||
return message; | ||
}; | ||
exports.getMessage = function () { | ||
return message | ||
} | ||
exports.setInfo = function(inf){ | ||
info = inf; | ||
}; | ||
exports.setInfo = function (inf) { | ||
info = inf | ||
} | ||
exports.getInfo = function(){ | ||
return info; | ||
}; | ||
exports.getInfo = function () { | ||
return info | ||
} | ||
exports.parseError = function(err,hash){ | ||
global.mermaidAPI.parseError(err,hash); | ||
}; | ||
exports.parseError = function (err, hash) { | ||
global.mermaidAPI.parseError(err, hash) | ||
} |
/** | ||
* Created by knut on 14-12-11. | ||
*/ | ||
var db = require('./exampleDb'); | ||
var exampleParser = require('./parser/example.js'); | ||
var d3 = require('../../d3'); | ||
var Logger = require('../../logger'); | ||
var log = new Logger.Log(); | ||
var db = require('./exampleDb') | ||
var exampleParser = require('./parser/example.js') | ||
var d3 = require('../../d3') | ||
var Logger = require('../../logger') | ||
var log = Logger.Log | ||
/** | ||
@@ -16,31 +17,24 @@ * Draws a an info picture in the tag with id: id based on the graph definition in text. | ||
exports.draw = function (txt, id, ver) { | ||
var parser; | ||
parser = exampleParser.parser; | ||
parser.yy = db; | ||
log.debug('Renering example diagram'); | ||
// Parse the graph definition | ||
parser.parse(txt); | ||
var parser | ||
parser = exampleParser.parser | ||
parser.yy = db | ||
log.debug('Renering example diagram') | ||
// Parse the graph definition | ||
parser.parse(txt) | ||
// Fetch the default direction, use TD if none was found | ||
var svg = d3.select('#'+id); | ||
// Fetch the default direction, use TD if none was found | ||
var svg = d3.select('#' + id) | ||
var g = svg.append('g'); | ||
var g = svg.append('g') | ||
g.append('text') // text label for the x axis | ||
.attr('x', 100) | ||
.attr('y', 40) | ||
.attr('class','version') | ||
.attr('font-size','32px') | ||
.style('text-anchor', 'middle') | ||
.text('mermaid '+ ver); | ||
g.append('text') // text label for the x axis | ||
.attr('x', 100) | ||
.attr('y', 40) | ||
.attr('class', 'version') | ||
.attr('font-size', '32px') | ||
.style('text-anchor', 'middle') | ||
.text('mermaid ' + ver) | ||
/* | ||
var box = exports.bounds.getBounds(); | ||
var height = box.stopy-box.starty+2*conf.diagramMarginY; | ||
var width = box.stopx-box.startx+2*conf.diagramMarginX;*/ | ||
svg.attr('height',100); | ||
svg.attr('width', 400 ); | ||
//svg.attr('viewBox', '0 0 300 150'); | ||
}; | ||
svg.attr('height', 100) | ||
svg.attr('width', 400) | ||
} |
@@ -53,3 +53,2 @@ /* parser generated by jison 0.4.17 */ | ||
token location info (@$, _$, etc.): { | ||
@@ -63,3 +62,2 @@ first_line: n, | ||
the parseError function receives a 'hash' object with these members for lexer and parser errors: { | ||
@@ -76,558 +74,555 @@ text: (matched text) | ||
*/ | ||
var parser = (function(){ | ||
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[6,9,10,12]; | ||
var parser = {trace: function trace() { }, | ||
yy: {}, | ||
symbols_: {"error":2,"start":3,"info":4,"document":5,"EOF":6,"line":7,"statement":8,"NL":9,"showInfo":10,"message":11,"say":12,"TXT":13,"$accept":0,"$end":1}, | ||
terminals_: {2:"error",4:"info",6:"EOF",9:"NL",10:"showInfo",12:"say",13:"TXT"}, | ||
productions_: [0,[3,3],[5,0],[5,2],[7,1],[7,1],[8,1],[8,1],[11,2]], | ||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
var parser = (function () { | ||
var o = function (k, v, o, l) { for (o = o || {}, l = k.length; l--; o[k[l]] = v);return o }, $V0 = [6, 9, 10, 12] | ||
var parser = {trace: function trace () { }, | ||
yy: {}, | ||
symbols_: {'error': 2, 'start': 3, 'info': 4, 'document': 5, 'EOF': 6, 'line': 7, 'statement': 8, 'NL': 9, 'showInfo': 10, 'message': 11, 'say': 12, 'TXT': 13, '$accept': 0, '$end': 1}, | ||
terminals_: {2: 'error', 4: 'info', 6: 'EOF', 9: 'NL', 10: 'showInfo', 12: 'say', 13: 'TXT'}, | ||
productions_: [0, [3, 3], [5, 0], [5, 2], [7, 1], [7, 1], [8, 1], [8, 1], [11, 2]], | ||
performAction: function anonymous (yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
/* this == yyval */ | ||
var $0 = $$.length - 1; | ||
switch (yystate) { | ||
case 1: | ||
return yy; | ||
break; | ||
case 4: | ||
break; | ||
case 6: | ||
yy.setInfo(true); | ||
break; | ||
case 7: | ||
yy.setMessage($$[$0]); | ||
break; | ||
case 8: | ||
this.$ = $$[$0-1].substring(1).trim().replace(/\\n/gm, "\n"); | ||
break; | ||
} | ||
}, | ||
table: [{3:1,4:[1,2]},{1:[3]},o($V0,[2,2],{5:3}),{6:[1,4],7:5,8:6,9:[1,7],10:[1,8],11:9,12:[1,10]},{1:[2,1]},o($V0,[2,3]),o($V0,[2,4]),o($V0,[2,5]),o($V0,[2,6]),o($V0,[2,7]),{13:[1,11]},o($V0,[2,8])], | ||
defaultActions: {4:[2,1]}, | ||
parseError: function parseError(str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str); | ||
} else { | ||
var $0 = $$.length - 1 | ||
switch (yystate) { | ||
case 1: | ||
return yy | ||
break | ||
case 4: | ||
break | ||
case 6: | ||
yy.setInfo(true) | ||
break | ||
case 7: | ||
yy.setMessage($$[$0]) | ||
break | ||
case 8: | ||
this.$ = $$[$0 - 1].substring(1).trim().replace(/\\n/gm, '\n') | ||
break | ||
} | ||
}, | ||
table: [{3: 1, 4: [1, 2]}, {1: [3]}, o($V0, [2, 2], {5: 3}), {6: [1, 4], 7: 5, 8: 6, 9: [1, 7], 10: [1, 8], 11: 9, 12: [1, 10]}, {1: [2, 1]}, o($V0, [2, 3]), o($V0, [2, 4]), o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 7]), {13: [1, 11]}, o($V0, [2, 8])], | ||
defaultActions: {4: [2, 1]}, | ||
parseError: function parseError (str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str) | ||
} else { | ||
function _parseError (msg, hash) { | ||
this.message = msg; | ||
this.hash = hash; | ||
this.message = msg | ||
this.hash = hash | ||
} | ||
_parseError.prototype = Error; | ||
_parseError.prototype = Error | ||
throw new _parseError(str, hash); | ||
} | ||
}, | ||
parse: function parse(input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; | ||
var args = lstack.slice.call(arguments, 1); | ||
var lexer = Object.create(this.lexer); | ||
var sharedState = { yy: {} }; | ||
for (var k in this.yy) { | ||
throw new _parseError(str, hash) | ||
} | ||
}, | ||
parse: function parse (input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1 | ||
var args = lstack.slice.call(arguments, 1) | ||
var lexer = Object.create(this.lexer) | ||
var sharedState = { yy: {} } | ||
for (var k in this.yy) { | ||
if (Object.prototype.hasOwnProperty.call(this.yy, k)) { | ||
sharedState.yy[k] = this.yy[k]; | ||
sharedState.yy[k] = this.yy[k] | ||
} | ||
} | ||
lexer.setInput(input, sharedState.yy); | ||
sharedState.yy.lexer = lexer; | ||
sharedState.yy.parser = this; | ||
if (typeof lexer.yylloc == 'undefined') { | ||
lexer.yylloc = {}; | ||
} | ||
var yyloc = lexer.yylloc; | ||
lstack.push(yyloc); | ||
var ranges = lexer.options && lexer.options.ranges; | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError; | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError; | ||
} | ||
function popStack(n) { | ||
stack.length = stack.length - 2 * n; | ||
vstack.length = vstack.length - n; | ||
lstack.length = lstack.length - n; | ||
} | ||
_token_stack: | ||
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]; | ||
} | ||
lexer.setInput(input, sharedState.yy) | ||
sharedState.yy.lexer = lexer | ||
sharedState.yy.parser = this | ||
if (typeof lexer.yylloc === 'undefined') { | ||
lexer.yylloc = {} | ||
} | ||
var yyloc = lexer.yylloc | ||
lstack.push(yyloc) | ||
var ranges = lexer.options && lexer.options.ranges | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError | ||
} | ||
function popStack (n) { | ||
stack.length = stack.length - 2 * n | ||
vstack.length = vstack.length - n | ||
lstack.length = lstack.length - n | ||
} | ||
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] | ||
if (this.defaultActions[state]) { | ||
action = this.defaultActions[state]; | ||
action = this.defaultActions[state] | ||
} else { | ||
if (symbol === null || typeof symbol == 'undefined') { | ||
symbol = lex(); | ||
if (symbol === null || typeof symbol === 'undefined') { | ||
symbol = lex() | ||
} | ||
action = table[state] && table[state][symbol] | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = '' | ||
expected = [] | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\'') | ||
} | ||
action = table[state] && table[state][symbol]; | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'' | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'') | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}) | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = ''; | ||
expected = []; | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\''); | ||
} | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}); | ||
} | ||
if (action[0] instanceof Array && action.length > 1) { | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol) | ||
} | ||
switch (action[0]) { | ||
case 1: | ||
stack.push(symbol); | ||
vstack.push(lexer.yytext); | ||
lstack.push(lexer.yylloc); | ||
stack.push(action[1]); | ||
symbol = null; | ||
case 1: | ||
stack.push(symbol) | ||
vstack.push(lexer.yytext) | ||
lstack.push(lexer.yylloc) | ||
stack.push(action[1]) | ||
symbol = null | ||
if (!preErrorSymbol) { | ||
yyleng = lexer.yyleng; | ||
yytext = lexer.yytext; | ||
yylineno = lexer.yylineno; | ||
yyloc = lexer.yylloc; | ||
if (recovering > 0) { | ||
recovering--; | ||
} | ||
yyleng = lexer.yyleng | ||
yytext = lexer.yytext | ||
yylineno = lexer.yylineno | ||
yyloc = lexer.yylloc | ||
if (recovering > 0) { | ||
recovering-- | ||
} | ||
} else { | ||
symbol = preErrorSymbol; | ||
preErrorSymbol = null; | ||
symbol = preErrorSymbol | ||
preErrorSymbol = null | ||
} | ||
break; | ||
case 2: | ||
len = this.productions_[action[1]][1]; | ||
yyval.$ = vstack[vstack.length - len]; | ||
break | ||
case 2: | ||
len = this.productions_[action[1]][1] | ||
yyval.$ = vstack[vstack.length - len] | ||
yyval._$ = { | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
}; | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
} | ||
if (ranges) { | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
]; | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
] | ||
} | ||
r = this.performAction.apply(yyval, [ | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)); | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)) | ||
if (typeof r !== 'undefined') { | ||
return r; | ||
return r | ||
} | ||
if (len) { | ||
stack = stack.slice(0, -1 * len * 2); | ||
vstack = vstack.slice(0, -1 * len); | ||
lstack = lstack.slice(0, -1 * len); | ||
stack = stack.slice(0, -1 * len * 2) | ||
vstack = vstack.slice(0, -1 * len) | ||
lstack = lstack.slice(0, -1 * len) | ||
} | ||
stack.push(this.productions_[action[1]][0]); | ||
vstack.push(yyval.$); | ||
lstack.push(yyval._$); | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; | ||
stack.push(newState); | ||
break; | ||
case 3: | ||
return true; | ||
stack.push(this.productions_[action[1]][0]) | ||
vstack.push(yyval.$) | ||
lstack.push(yyval._$) | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]] | ||
stack.push(newState) | ||
break | ||
case 3: | ||
return true | ||
} | ||
} | ||
return true; | ||
}}; | ||
} | ||
return true | ||
}} | ||
/* generated by jison-lex 0.3.4 */ | ||
var lexer = (function(){ | ||
var lexer = ({ | ||
var lexer = (function () { | ||
var lexer = ({ | ||
EOF:1, | ||
EOF: 1, | ||
parseError:function parseError(str, hash) { | ||
parseError: function parseError (str, hash) { | ||
if (this.yy.parser) { | ||
this.yy.parser.parseError(str, hash); | ||
this.yy.parser.parseError(str, hash) | ||
} else { | ||
throw new Error(str); | ||
throw new Error(str) | ||
} | ||
}, | ||
}, | ||
// resets the lexer, sets new input | ||
setInput:function (input, yy) { | ||
this.yy = yy || this.yy || {}; | ||
this._input = input; | ||
this._more = this._backtrack = this.done = false; | ||
this.yylineno = this.yyleng = 0; | ||
this.yytext = this.matched = this.match = ''; | ||
this.conditionStack = ['INITIAL']; | ||
setInput: function (input, yy) { | ||
this.yy = yy || this.yy || {} | ||
this._input = input | ||
this._more = this._backtrack = this.done = false | ||
this.yylineno = this.yyleng = 0 | ||
this.yytext = this.matched = this.match = '' | ||
this.conditionStack = ['INITIAL'] | ||
this.yylloc = { | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
}; | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [0,0]; | ||
this.yylloc.range = [0, 0] | ||
} | ||
this.offset = 0; | ||
return this; | ||
}, | ||
this.offset = 0 | ||
return this | ||
}, | ||
// consumes and returns one char from the input | ||
input:function () { | ||
var ch = this._input[0]; | ||
this.yytext += ch; | ||
this.yyleng++; | ||
this.offset++; | ||
this.match += ch; | ||
this.matched += ch; | ||
var lines = ch.match(/(?:\r\n?|\n).*/g); | ||
input: function () { | ||
var ch = this._input[0] | ||
this.yytext += ch | ||
this.yyleng++ | ||
this.offset++ | ||
this.match += ch | ||
this.matched += ch | ||
var lines = ch.match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno++; | ||
this.yylloc.last_line++; | ||
this.yylineno++ | ||
this.yylloc.last_line++ | ||
} else { | ||
this.yylloc.last_column++; | ||
this.yylloc.last_column++ | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range[1]++; | ||
this.yylloc.range[1]++ | ||
} | ||
this._input = this._input.slice(1); | ||
return ch; | ||
}, | ||
this._input = this._input.slice(1) | ||
return ch | ||
}, | ||
// unshifts one char (or a string) into the input | ||
unput:function (ch) { | ||
var len = ch.length; | ||
var lines = ch.split(/(?:\r\n?|\n)/g); | ||
unput: function (ch) { | ||
var len = ch.length | ||
var lines = ch.split(/(?:\r\n?|\n)/g) | ||
this._input = ch + this._input; | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len); | ||
//this.yyleng -= len; | ||
this.offset -= len; | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g); | ||
this.match = this.match.substr(0, this.match.length - 1); | ||
this.matched = this.matched.substr(0, this.matched.length - 1); | ||
this._input = ch + this._input | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len) | ||
// this.yyleng -= len; | ||
this.offset -= len | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g) | ||
this.match = this.match.substr(0, this.match.length - 1) | ||
this.matched = this.matched.substr(0, this.matched.length - 1) | ||
if (lines.length - 1) { | ||
this.yylineno -= lines.length - 1; | ||
this.yylineno -= lines.length - 1 | ||
} | ||
var r = this.yylloc.range; | ||
var r = this.yylloc.range | ||
this.yylloc = { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines ? | ||
(lines.length === oldLines.length ? this.yylloc.first_column : 0) | ||
+ oldLines[oldLines.length - lines.length].length - lines[0].length : | ||
this.yylloc.first_column - len | ||
}; | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines | ||
? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + | ||
oldLines[oldLines.length - lines.length].length - lines[0].length | ||
: this.yylloc.first_column - len | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len]; | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len] | ||
} | ||
this.yyleng = this.yytext.length; | ||
return this; | ||
}, | ||
this.yyleng = this.yytext.length | ||
return this | ||
}, | ||
// When called from action, caches matched text and appends it on next action | ||
more:function () { | ||
this._more = true; | ||
return this; | ||
}, | ||
more: function () { | ||
this._more = true | ||
return this | ||
}, | ||
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. | ||
reject:function () { | ||
reject: function () { | ||
if (this.options.backtrack_lexer) { | ||
this._backtrack = true; | ||
this._backtrack = true | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
return this; | ||
}, | ||
return this | ||
}, | ||
// retain first n characters of the match | ||
less:function (n) { | ||
this.unput(this.match.slice(n)); | ||
}, | ||
less: function (n) { | ||
this.unput(this.match.slice(n)) | ||
}, | ||
// displays already matched input, i.e. for error messages | ||
pastInput:function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length); | ||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); | ||
}, | ||
pastInput: function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length) | ||
return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') | ||
}, | ||
// displays upcoming input, i.e. for error messages | ||
upcomingInput:function () { | ||
var next = this.match; | ||
upcomingInput: function () { | ||
var next = this.match | ||
if (next.length < 20) { | ||
next += this._input.substr(0, 20-next.length); | ||
next += this._input.substr(0, 20 - next.length) | ||
} | ||
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); | ||
}, | ||
return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, '') | ||
}, | ||
// displays the character position where the lexing error occurred, i.e. for error messages | ||
showPosition:function () { | ||
var pre = this.pastInput(); | ||
var c = new Array(pre.length + 1).join("-"); | ||
return pre + this.upcomingInput() + "\n" + c + "^"; | ||
}, | ||
showPosition: function () { | ||
var pre = this.pastInput() | ||
var c = new Array(pre.length + 1).join('-') | ||
return pre + this.upcomingInput() + '\n' + c + '^' | ||
}, | ||
// test the lexed token: return FALSE when not a match, otherwise return token | ||
test_match:function (match, indexed_rule) { | ||
test_match: function (match, indexed_rule) { | ||
var token, | ||
lines, | ||
backup; | ||
lines, | ||
backup | ||
if (this.options.backtrack_lexer) { | ||
// save context | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
}; | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0); | ||
} | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
} | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0) | ||
} | ||
} | ||
lines = match[0].match(/(?:\r\n?|\n).*/g); | ||
lines = match[0].match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno += lines.length; | ||
this.yylineno += lines.length | ||
} | ||
this.yylloc = { | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines ? | ||
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : | ||
this.yylloc.last_column + match[0].length | ||
}; | ||
this.yytext += match[0]; | ||
this.match += match[0]; | ||
this.matches = match; | ||
this.yyleng = this.yytext.length; | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines | ||
? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length | ||
: this.yylloc.last_column + match[0].length | ||
} | ||
this.yytext += match[0] | ||
this.match += match[0] | ||
this.matches = match | ||
this.yyleng = this.yytext.length | ||
if (this.options.ranges) { | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng]; | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng] | ||
} | ||
this._more = false; | ||
this._backtrack = false; | ||
this._input = this._input.slice(match[0].length); | ||
this.matched += match[0]; | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); | ||
this._more = false | ||
this._backtrack = false | ||
this._input = this._input.slice(match[0].length) | ||
this.matched += match[0] | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]) | ||
if (this.done && this._input) { | ||
this.done = false; | ||
this.done = false | ||
} | ||
if (token) { | ||
return token; | ||
return token | ||
} else if (this._backtrack) { | ||
// recover context | ||
for (var k in backup) { | ||
this[k] = backup[k]; | ||
} | ||
return false; // rule action called reject() implying the next rule should be tested instead. | ||
for (var k in backup) { | ||
this[k] = backup[k] | ||
} | ||
return false // rule action called reject() implying the next rule should be tested instead. | ||
} | ||
return false; | ||
}, | ||
return false | ||
}, | ||
// return next match in input | ||
next:function () { | ||
next: function () { | ||
if (this.done) { | ||
return this.EOF; | ||
return this.EOF | ||
} | ||
if (!this._input) { | ||
this.done = true; | ||
this.done = true | ||
} | ||
var token, | ||
match, | ||
tempMatch, | ||
index; | ||
match, | ||
tempMatch, | ||
index | ||
if (!this._more) { | ||
this.yytext = ''; | ||
this.match = ''; | ||
this.yytext = '' | ||
this.match = '' | ||
} | ||
var rules = this._currentRules(); | ||
var rules = this._currentRules() | ||
for (var i = 0; i < rules.length; i++) { | ||
tempMatch = this._input.match(this.rules[rules[i]]); | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch; | ||
index = i; | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]); | ||
if (token !== false) { | ||
return token; | ||
} else if (this._backtrack) { | ||
match = false; | ||
continue; // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
tempMatch = this._input.match(this.rules[rules[i]]) | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch | ||
index = i | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]) | ||
if (token !== false) { | ||
return token | ||
} else if (this._backtrack) { | ||
match = false | ||
continue // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
} | ||
} else if (!this.options.flex) { | ||
break; | ||
} | ||
return false | ||
} | ||
} else if (!this.options.flex) { | ||
break | ||
} | ||
} | ||
} | ||
if (match) { | ||
token = this.test_match(match, rules[index]); | ||
if (token !== false) { | ||
return token; | ||
} | ||
token = this.test_match(match, rules[index]) | ||
if (token !== false) { | ||
return token | ||
} | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
return false | ||
} | ||
if (this._input === "") { | ||
return this.EOF; | ||
if (this._input === '') { | ||
return this.EOF | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
}, | ||
}, | ||
// return next match that has a token | ||
lex:function lex() { | ||
var r = this.next(); | ||
lex: function lex () { | ||
var r = this.next() | ||
if (r) { | ||
return r; | ||
return r | ||
} else { | ||
return this.lex(); | ||
return this.lex() | ||
} | ||
}, | ||
}, | ||
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) | ||
begin:function begin(condition) { | ||
this.conditionStack.push(condition); | ||
}, | ||
begin: function begin (condition) { | ||
this.conditionStack.push(condition) | ||
}, | ||
// pop the previously active lexer condition state off the condition stack | ||
popState:function popState() { | ||
var n = this.conditionStack.length - 1; | ||
popState: function popState () { | ||
var n = this.conditionStack.length - 1 | ||
if (n > 0) { | ||
return this.conditionStack.pop(); | ||
return this.conditionStack.pop() | ||
} else { | ||
return this.conditionStack[0]; | ||
return this.conditionStack[0] | ||
} | ||
}, | ||
}, | ||
// produce the lexer rule set which is active for the currently active lexer condition state | ||
_currentRules:function _currentRules() { | ||
_currentRules: function _currentRules () { | ||
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules | ||
} else { | ||
return this.conditions["INITIAL"].rules; | ||
return this.conditions['INITIAL'].rules | ||
} | ||
}, | ||
}, | ||
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available | ||
topState:function topState(n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0); | ||
topState: function topState (n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0) | ||
if (n >= 0) { | ||
return this.conditionStack[n]; | ||
return this.conditionStack[n] | ||
} else { | ||
return "INITIAL"; | ||
return 'INITIAL' | ||
} | ||
}, | ||
}, | ||
// alias for begin(condition) | ||
pushState:function pushState(condition) { | ||
this.begin(condition); | ||
}, | ||
pushState: function pushState (condition) { | ||
this.begin(condition) | ||
}, | ||
// return the number of states currently on the stack | ||
stateStackSize:function stateStackSize() { | ||
return this.conditionStack.length; | ||
}, | ||
options: {"case-insensitive":true}, | ||
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { | ||
stateStackSize: function stateStackSize () { | ||
return this.conditionStack.length | ||
}, | ||
options: {'case-insensitive': true}, | ||
performAction: function anonymous (yy, yy_, $avoiding_name_collisions, YY_START) { | ||
// Pre-lexer code can go here | ||
var YYSTATE=YY_START; | ||
switch($avoiding_name_collisions) { | ||
case 0:return 9; | ||
break; | ||
case 1:return 10; | ||
break; | ||
case 2:return 4; | ||
break; | ||
case 3:return 12; | ||
break; | ||
case 4:return 13; | ||
break; | ||
case 5:return 6; | ||
break; | ||
case 6:return 'INVALID'; | ||
break; | ||
} | ||
}, | ||
rules: [/^(?:[\n]+)/i,/^(?:showInfo\b)/i,/^(?:info\b)/i,/^(?:say\b)/i,/^(?::[^#\n;]+)/i,/^(?:$)/i,/^(?:.)/i], | ||
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6],"inclusive":true}} | ||
}); | ||
return lexer; | ||
})(); | ||
parser.lexer = lexer; | ||
function Parser () { | ||
this.yy = {}; | ||
} | ||
Parser.prototype = parser;parser.Parser = Parser; | ||
return new Parser; | ||
})(); | ||
var YYSTATE = YY_START | ||
switch ($avoiding_name_collisions) { | ||
case 0:return 9 | ||
break | ||
case 1:return 10 | ||
break | ||
case 2:return 4 | ||
break | ||
case 3:return 12 | ||
break | ||
case 4:return 13 | ||
break | ||
case 5:return 6 | ||
break | ||
case 6:return 'INVALID' | ||
break | ||
} | ||
}, | ||
rules: [/^(?:[\n]+)/i, /^(?:showInfo\b)/i, /^(?:info\b)/i, /^(?:say\b)/i, /^(?::[^#\n;]+)/i, /^(?:$)/i, /^(?:.)/i], | ||
conditions: {'INITIAL': {'rules': [0, 1, 2, 3, 4, 5, 6], 'inclusive': true}} | ||
}) | ||
return lexer | ||
})() | ||
parser.lexer = lexer | ||
function Parser () { | ||
this.yy = {} | ||
} | ||
Parser.prototype = parser; parser.Parser = Parser | ||
return new Parser() | ||
})() | ||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') { | ||
exports.parser = parser; | ||
exports.Parser = parser.Parser; | ||
exports.parse = function () { return parser.parse.apply(parser, arguments); }; | ||
exports.main = function commonjsMain(args) { | ||
exports.parser = parser | ||
exports.Parser = parser.Parser | ||
exports.parse = function () { return parser.parse.apply(parser, arguments) } | ||
exports.main = function commonjsMain (args) { | ||
if (!args[1]) { | ||
console.log('Usage: '+args[0]+' FILE'); | ||
process.exit(1); | ||
console.log('Usage: ' + args[0] + ' FILE') | ||
process.exit(1) | ||
} | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); | ||
return exports.parser.parse(source); | ||
}; | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)); | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), 'utf8') | ||
return exports.parser.parse(source) | ||
} | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)) | ||
} | ||
} | ||
} |
/** | ||
* Created by knut on 14-12-11. | ||
*/ | ||
var graph = require('./graphDb'); | ||
var flow = require('./parser/flow'); | ||
var dot = require('./parser/dot'); | ||
var d3 = require('../../d3'); | ||
var dagreD3 = require('./dagre-d3'); | ||
var Logger = require('../../logger'); | ||
var log = new Logger.Log(); | ||
var graph = require('./graphDb') | ||
var flow = require('./parser/flow') | ||
var dot = require('./parser/dot') | ||
var d3 = require('../../d3') | ||
var dagreD3 = require('dagre-d3-renderer') | ||
var Logger = require('../../logger') | ||
var log = Logger.Log | ||
var conf = { | ||
}; | ||
module.exports.setConf = function(cnf){ | ||
var keys = Object.keys(cnf); | ||
var i; | ||
for(i=0;i<keys.length;i++){ | ||
conf[keys[i]] = cnf[keys[i]]; | ||
} | ||
}; | ||
} | ||
module.exports.setConf = function (cnf) { | ||
var keys = Object.keys(cnf) | ||
var i | ||
for (i = 0; i < keys.length; i++) { | ||
conf[keys[i]] = cnf[keys[i]] | ||
} | ||
} | ||
@@ -29,121 +28,111 @@ /** | ||
exports.addVertices = function (vert, g) { | ||
var keys = Object.keys(vert); | ||
var keys = Object.keys(vert) | ||
var styleFromStyleArr = function(styleStr,arr){ | ||
var i; | ||
// Create a compound style definition from the style definitions found for the node in the graph definition | ||
for (i = 0; i < arr.length; i++) { | ||
if (typeof arr[i] !== 'undefined') { | ||
styleStr = styleStr + arr[i] + ';'; | ||
} | ||
} | ||
var styleFromStyleArr = function (styleStr, arr) { | ||
var i | ||
// Create a compound style definition from the style definitions found for the node in the graph definition | ||
for (i = 0; i < arr.length; i++) { | ||
if (typeof arr[i] !== 'undefined') { | ||
styleStr = styleStr + arr[i] + ';' | ||
} | ||
} | ||
return styleStr; | ||
}; | ||
return styleStr | ||
} | ||
// Iterate through each item in the vertice object (containing all the vertices found) in the graph definition | ||
keys.forEach(function (id) { | ||
var vertice = vert[id]; | ||
var verticeText; | ||
// Iterate through each item in the vertice object (containing all the vertices found) in the graph definition | ||
keys.forEach(function (id) { | ||
var vertice = vert[id] | ||
var verticeText | ||
/** | ||
* Variable for storing the classes for the vertice | ||
* @type {string} | ||
*/ | ||
var classStr = ''; | ||
/** | ||
* Variable for storing the classes for the vertice | ||
* @type {string} | ||
*/ | ||
var classStr = '' | ||
//log.debug(vertice.classes); | ||
if (vertice.classes.length > 0) { | ||
classStr = vertice.classes.join(' ') | ||
} | ||
if(vertice.classes.length >0){ | ||
classStr = vertice.classes.join(' '); | ||
} | ||
/** | ||
* Variable for storing the extracted style for the vertice | ||
* @type {string} | ||
*/ | ||
var style = '' | ||
// Create a compound style definition from the style definitions found for the node in the graph definition | ||
style = styleFromStyleArr(style, vertice.styles) | ||
/** | ||
* Variable for storing the extracted style for the vertice | ||
* @type {string} | ||
*/ | ||
var style = ''; | ||
// Create a compound style definition from the style definitions found for the node in the graph definition | ||
style = styleFromStyleArr(style, vertice.styles); | ||
// Use vertice id as text in the box if no text is provided by the graph definition | ||
if (typeof vertice.text === 'undefined') { | ||
verticeText = vertice.id | ||
} else { | ||
verticeText = vertice.text | ||
} | ||
// Use vertice id as text in the box if no text is provided by the graph definition | ||
if (typeof vertice.text === 'undefined') { | ||
verticeText = vertice.id; | ||
} | ||
else { | ||
verticeText = vertice.text; | ||
} | ||
var labelTypeStr = '' | ||
if (conf.htmlLabels) { | ||
labelTypeStr = 'html' | ||
verticeText = verticeText.replace(/fa:fa[\w-]+/g, function (s) { | ||
return '<i class="fa ' + s.substring(3) + '"></i>' | ||
}) | ||
} else { | ||
var svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text') | ||
var rows = verticeText.split(/<br>/) | ||
var j = 0 | ||
for (j = 0; j < rows.length; j++) { | ||
var tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan') | ||
tspan.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:space', 'preserve') | ||
tspan.setAttribute('dy', '1em') | ||
tspan.setAttribute('x', '1') | ||
tspan.textContent = rows[j] | ||
svgLabel.appendChild(tspan) | ||
} | ||
var labelTypeStr = ''; | ||
if(conf.htmlLabels) { | ||
labelTypeStr = 'html'; | ||
verticeText = verticeText.replace(/fa:fa[\w\-]+/g,function(s){ | ||
return '<i class="fa '+ s.substring(3)+'"></i>'; | ||
}); | ||
labelTypeStr = 'svg' | ||
verticeText = svgLabel | ||
} | ||
} else { | ||
var svg_label = document.createElementNS('http://www.w3.org/2000/svg', 'text'); | ||
var radious = 0 | ||
var _shape = '' | ||
var rows = verticeText.split(/<br>/); | ||
// Set the shape based parameters | ||
switch (vertice.type) { | ||
case 'round': | ||
radious = 5 | ||
_shape = 'rect' | ||
break | ||
case 'square': | ||
_shape = 'rect' | ||
break | ||
case 'diamond': | ||
_shape = 'question' | ||
break | ||
case 'odd': | ||
_shape = 'rect_left_inv_arrow' | ||
break | ||
case 'odd_right': | ||
_shape = 'rect_left_inv_arrow' | ||
break | ||
case 'circle': | ||
_shape = 'circle' | ||
break | ||
case 'ellipse': | ||
_shape = 'ellipse' | ||
break | ||
case 'group': | ||
_shape = 'rect' | ||
// Need to create a text node if using svg labels, see #367 | ||
verticeText = conf.htmlLabels ? '' : document.createElementNS('http://www.w3.org/2000/svg', 'text') | ||
break | ||
default: | ||
_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 }) | ||
}) | ||
} | ||
var j = 0; | ||
for(j=0;j<rows.length;j++){ | ||
var tspan = document.createElementNS('http://www.w3.org/2000/svg','tspan'); | ||
tspan.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:space', 'preserve'); | ||
tspan.setAttribute('dy', '1em'); | ||
tspan.setAttribute('x', '1'); | ||
tspan.textContent = rows[j]; | ||
svg_label.appendChild(tspan); | ||
} | ||
labelTypeStr = 'svg'; | ||
verticeText = svg_label; | ||
//verticeText = verticeText.replace(/<br\/>/g, '\n'); | ||
//labelTypeStr = 'text'; | ||
} | ||
var radious = 0; | ||
var _shape = ''; | ||
// Set the shape based parameters | ||
switch(vertice.type){ | ||
case 'round': | ||
radious = 5; | ||
_shape = 'rect'; | ||
break; | ||
case 'square': | ||
_shape = 'rect'; | ||
break; | ||
case 'diamond': | ||
_shape = 'question'; | ||
break; | ||
case 'odd': | ||
_shape = 'rect_left_inv_arrow'; | ||
break; | ||
case 'odd_right': | ||
_shape = 'rect_left_inv_arrow'; | ||
break; | ||
case 'circle': | ||
_shape = 'circle'; | ||
break; | ||
case 'ellipse': | ||
_shape = 'ellipse'; | ||
break; | ||
case 'group': | ||
_shape = 'rect'; | ||
// Need to create a text node if using svg labels, see #367 | ||
verticeText = conf.htmlLabels ? '' : document.createElementNS('http://www.w3.org/2000/svg', 'text'); | ||
break; | ||
default: | ||
_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}); | ||
}); | ||
}; | ||
/** | ||
@@ -155,79 +144,76 @@ * Add edges to graph based on parsed graph defninition | ||
exports.addEdges = function (edges, g) { | ||
var cnt=0; | ||
var defaultStyle; | ||
if(typeof edges.defaultStyle !== 'undefined'){ | ||
defaultStyle = edges.defaultStyle.toString().replace(/,/g , ';'); | ||
} | ||
var cnt = 0 | ||
edges.forEach(function (edge) { | ||
cnt++; | ||
var edgeData = {}; | ||
var defaultStyle | ||
if (typeof edges.defaultStyle !== 'undefined') { | ||
defaultStyle = edges.defaultStyle.toString().replace(/,/g, ';') | ||
} | ||
// Set link type for rendering | ||
if(edge.type === 'arrow_open'){ | ||
edgeData.arrowhead = 'none'; | ||
} | ||
else{ | ||
edgeData.arrowhead = 'normal'; | ||
} | ||
edges.forEach(function (edge) { | ||
cnt++ | ||
var edgeData = {} | ||
var style = ''; | ||
// Set link type for rendering | ||
if (edge.type === 'arrow_open') { | ||
edgeData.arrowhead = 'none' | ||
} else { | ||
edgeData.arrowhead = 'normal' | ||
} | ||
var style = '' | ||
if(typeof edge.style !== 'undefined'){ | ||
edge.style.forEach(function(s){ | ||
style = style + s +';'; | ||
}); | ||
} | ||
else{ | ||
switch(edge.stroke){ | ||
case 'normal': | ||
style = 'fill:none'; | ||
if(typeof defaultStyle !== 'undefined'){ | ||
style = defaultStyle; | ||
} | ||
break; | ||
case 'dotted': | ||
style = 'stroke: #333; fill:none;stroke-width:2px;stroke-dasharray:3;'; | ||
break; | ||
case 'thick': | ||
style = 'stroke: #333; stroke-width: 3.5px;fill:none'; | ||
break; | ||
} | ||
} | ||
edgeData.style = style; | ||
if (typeof edge.interpolate !== 'undefined') { | ||
edgeData.lineInterpolate = edge.interpolate; | ||
} else { | ||
if (typeof edges.defaultInterpolate !== 'undefined') { | ||
edgeData.lineInterpolate = edges.defaultInterpolate; | ||
} | ||
} | ||
if (typeof edge.style !== 'undefined') { | ||
edge.style.forEach(function (s) { | ||
style = style + s + ';' | ||
}) | ||
} else { | ||
switch (edge.stroke) { | ||
case 'normal': | ||
style = 'fill:none' | ||
if (typeof defaultStyle !== 'undefined') { | ||
style = defaultStyle | ||
} | ||
break | ||
case 'dotted': | ||
style = 'stroke: #333; fill:none;stroke-width:2px;stroke-dasharray:3;' | ||
break | ||
case 'thick': | ||
style = 'stroke: #333; stroke-width: 3.5px;fill:none' | ||
break | ||
} | ||
} | ||
edgeData.style = style | ||
if (typeof edge.text === 'undefined') { | ||
if (typeof edge.style !== 'undefined') { | ||
edgeData.arrowheadStyle = 'fill: #333'; | ||
} | ||
if (typeof edge.interpolate !== 'undefined') { | ||
edgeData.lineInterpolate = edge.interpolate | ||
} else { | ||
if (typeof edges.defaultInterpolate !== 'undefined') { | ||
edgeData.lineInterpolate = edges.defaultInterpolate | ||
} | ||
} | ||
if (typeof edge.text === 'undefined') { | ||
if (typeof edge.style !== 'undefined') { | ||
edgeData.arrowheadStyle = 'fill: #333' | ||
} | ||
} else { | ||
edgeData.arrowheadStyle = 'fill: #333' | ||
if (typeof edge.style === 'undefined') { | ||
edgeData.labelpos = 'c' | ||
if (conf.htmlLabels) { | ||
edgeData.labelType = 'html' | ||
edgeData.label = '<span class="edgeLabel">' + edge.text + '</span>' | ||
} else { | ||
edgeData.arrowheadStyle = 'fill: #333'; | ||
if(typeof edge.style === 'undefined') { | ||
edgeData.labelpos = 'c'; | ||
if (conf.htmlLabels) { | ||
edgeData.labelType = 'html'; | ||
edgeData.label = '<span class="edgeLabel">'+edge.text+'</span>'; | ||
} else { | ||
edgeData.labelType = 'text'; | ||
edgeData.style = 'stroke: #333; stroke-width: 1.5px;fill:none'; | ||
edgeData.label = edge.text.replace(/<br>/g, '\n'); | ||
} | ||
} else { | ||
edgeData.label = edge.text.replace(/<br>/g, '\n'); | ||
} | ||
edgeData.labelType = 'text' | ||
edgeData.style = 'stroke: #333; stroke-width: 1.5px;fill:none' | ||
edgeData.label = edge.text.replace(/<br>/g, '\n') | ||
} | ||
// Add the edge to the graph | ||
g.setEdge(edge.start, edge.end, edgeData, cnt); | ||
}); | ||
}; | ||
} else { | ||
edgeData.label = edge.text.replace(/<br>/g, '\n') | ||
} | ||
} | ||
// Add the edge to the graph | ||
g.setEdge(edge.start, edge.end, edgeData, cnt) | ||
}) | ||
} | ||
@@ -239,29 +225,27 @@ /** | ||
exports.getClasses = function (text, isDot) { | ||
var parser; | ||
graph.clear(); | ||
if(isDot){ | ||
parser = dot.parser; | ||
var parser | ||
graph.clear() | ||
if (isDot) { | ||
parser = dot.parser | ||
} else { | ||
parser = flow.parser | ||
} | ||
parser.yy = graph | ||
}else{ | ||
parser = flow.parser; | ||
} | ||
parser.yy = graph; | ||
// Parse the graph definition | ||
parser.parse(text) | ||
// Parse the graph definition | ||
parser.parse(text); | ||
var classes = graph.getClasses() | ||
var classes = graph.getClasses(); | ||
// Add default class if undefined | ||
if (typeof (classes.default) === 'undefined') { | ||
classes.default = { id: 'default' } | ||
classes.default.styles = [] | ||
classes.default.clusterStyles = ['rx:4px', 'fill: rgb(255, 255, 222)', 'rx: 4px', 'stroke: rgb(170, 170, 51)', 'stroke-width: 1px'] | ||
classes.default.nodeLabelStyles = ['fill:#000', 'stroke:none', 'font-weight:300', 'font-family:"Helvetica Neue",Helvetica,Arial,sans-serf', 'font-size:14px'] | ||
classes.default.edgeLabelStyles = ['fill:#000', 'stroke:none', 'font-weight:300', 'font-family:"Helvetica Neue",Helvetica,Arial,sans-serf', 'font-size:14px'] | ||
} | ||
return classes | ||
} | ||
// Add default class if undefined | ||
if(typeof(classes.default) === 'undefined') { | ||
classes.default = {id:'default'}; | ||
//classes.default.styles = ['fill:#ffa','stroke:#666','stroke-width:3px']; | ||
classes.default.styles = []; | ||
classes.default.clusterStyles = ['rx:4px','fill: rgb(255, 255, 222)','rx: 4px','stroke: rgb(170, 170, 51)','stroke-width: 1px']; | ||
classes.default.nodeLabelStyles = ['fill:#000','stroke:none','font-weight:300','font-family:"Helvetica Neue",Helvetica,Arial,sans-serf','font-size:14px']; | ||
classes.default.edgeLabelStyles = ['fill:#000','stroke:none','font-weight:300','font-family:"Helvetica Neue",Helvetica,Arial,sans-serf','font-size:14px']; | ||
} | ||
return classes; | ||
}; | ||
/** | ||
@@ -272,282 +256,256 @@ * Draws a flowchart in the tag with id: id based on the graph definition in text. | ||
*/ | ||
exports.draw = function (text, id,isDot) { | ||
log.debug('Drawing flowchart'); | ||
var parser; | ||
graph.clear(); | ||
if(isDot){ | ||
parser = dot.parser; | ||
exports.draw = function (text, id, isDot) { | ||
log.debug('Drawing flowchart') | ||
var parser | ||
graph.clear() | ||
if (isDot) { | ||
parser = dot.parser | ||
} else { | ||
parser = flow.parser | ||
} | ||
parser.yy = graph | ||
}else{ | ||
parser = flow.parser; | ||
} | ||
parser.yy = graph; | ||
// Parse the graph definition | ||
try { | ||
parser.parse(text) | ||
} catch (err) { | ||
log.debug('Parsing failed') | ||
} | ||
// Parse the graph definition | ||
try{ | ||
// Fetch the default direction, use TD if none was found | ||
var dir | ||
dir = graph.getDirection() | ||
if (typeof dir === 'undefined') { | ||
dir = 'TD' | ||
} | ||
parser.parse(text); | ||
} | ||
catch(err){ | ||
log.debug('Parsing failed'); | ||
} | ||
// Create the input mermaid.graph | ||
var g = new dagreD3.graphlib.Graph({ | ||
multigraph: true, | ||
compound: true | ||
}) | ||
.setGraph({ | ||
rankdir: dir, | ||
marginx: 20, | ||
marginy: 20 | ||
// Fetch the default direction, use TD if none was found | ||
var dir; | ||
dir = graph.getDirection(); | ||
if(typeof dir === 'undefined'){ | ||
dir='TD'; | ||
} | ||
// Create the input mermaid.graph | ||
var g = new dagreD3.graphlib.Graph({ | ||
multigraph:true, | ||
compound: true | ||
}) | ||
.setGraph({ | ||
rankdir: dir, | ||
marginx: 20, | ||
marginy: 20 | ||
.setDefaultEdgeLabel(function () { | ||
return {} | ||
}) | ||
}) | ||
.setDefaultEdgeLabel(function () { | ||
return {}; | ||
}); | ||
var subG | ||
var subGraphs = graph.getSubGraphs() | ||
var i = 0 | ||
for (i = subGraphs.length - 1; i >= 0; i--) { | ||
subG = subGraphs[i] | ||
graph.addVertex(subG.id, subG.title, 'group', undefined) | ||
} | ||
var subG; | ||
var subGraphs = graph.getSubGraphs(); | ||
var i = 0; | ||
for(i=subGraphs.length-1;i>=0;i--){ | ||
subG = subGraphs[i]; | ||
graph.addVertex(subG.id,subG.title,'group',undefined); | ||
} | ||
// Fetch the verices/nodes and edges/links from the parsed graph definition | ||
var vert = graph.getVertices() | ||
// Fetch the verices/nodes and edges/links from the parsed graph definition | ||
var vert = graph.getVertices(); | ||
var edges = graph.getEdges() | ||
//log.debug(vert); | ||
var edges = graph.getEdges(); | ||
i = 0 | ||
var j | ||
for (i = subGraphs.length - 1; i >= 0; i--) { | ||
subG = subGraphs[i] | ||
i = 0; | ||
var j; | ||
for(i=subGraphs.length-1;i>=0;i--){ | ||
subG = subGraphs[i]; | ||
d3.selectAll('cluster').append('text') | ||
d3.selectAll('cluster').append('text'); | ||
for(j=0;j<subG.nodes.length;j++){ | ||
//log.debug('Setting node',subG.nodes[j],' to subgraph '+id); | ||
g.setParent(subG.nodes[j],subG.id); | ||
} | ||
for (j = 0; j < subG.nodes.length; j++) { | ||
g.setParent(subG.nodes[j], subG.id) | ||
} | ||
exports.addVertices(vert, g); | ||
exports.addEdges(edges, g); | ||
} | ||
exports.addVertices(vert, g) | ||
exports.addEdges(edges, g) | ||
// Create the renderer | ||
var render = new dagreD3.render(); | ||
// Create the renderer | ||
var Render = dagreD3.render | ||
var render = new Render() | ||
// Add custom shape for rhombus type of boc (decision) | ||
render.shapes().question = function (parent, bbox, node) { | ||
var w = bbox.width, | ||
h = bbox.height, | ||
s = (w + h) * 0.8, | ||
points = [ | ||
{x: s / 2, y: 0}, | ||
{x: s, y: -s / 2}, | ||
{x: s / 2, y: -s}, | ||
{x: 0, y: -s / 2} | ||
]; | ||
var shapeSvg = parent.insert('polygon', ':first-child') | ||
.attr('points', points.map(function (d) { | ||
return d.x + ',' + d.y; | ||
}).join(' ')) | ||
.attr('rx', 5) | ||
.attr('ry', 5) | ||
.attr('transform', 'translate(' + (-s / 2) + ',' + (s * 2 / 4) + ')'); | ||
node.intersect = function (point) { | ||
return dagreD3.intersect.polygon(node, points, point); | ||
}; | ||
return shapeSvg; | ||
}; | ||
// Add custom shape for rhombus type of boc (decision) | ||
render.shapes().question = function (parent, bbox, node) { | ||
var w = bbox.width | ||
var h = bbox.height | ||
var s = (w + h) * 0.8 | ||
var points = [ | ||
{ x: s / 2, y: 0 }, | ||
{ x: s, y: -s / 2 }, | ||
{ x: s / 2, y: -s }, | ||
{ x: 0, y: -s / 2 } | ||
] | ||
var shapeSvg = parent.insert('polygon', ':first-child') | ||
.attr('points', points.map(function (d) { | ||
return d.x + ',' + d.y | ||
}).join(' ')) | ||
.attr('rx', 5) | ||
.attr('ry', 5) | ||
.attr('transform', 'translate(' + (-s / 2) + ',' + (s * 2 / 4) + ')') | ||
node.intersect = function (point) { | ||
return dagreD3.intersect.polygon(node, points, point) | ||
} | ||
return shapeSvg | ||
} | ||
// Add custom shape for box with inverted arrow on left side | ||
render.shapes().rect_left_inv_arrow = function (parent, bbox, node) { | ||
var w = bbox.width, | ||
h = bbox.height, | ||
points = [ | ||
{x: -h/2, y: 0}, | ||
{x: w, y: 0}, | ||
{x: w, y: -h}, | ||
{x: -h/2, y: -h}, | ||
{x: 0, y: -h/2} | ||
]; | ||
var shapeSvg = parent.insert('polygon', ':first-child') | ||
.attr('points', points.map(function (d) { | ||
return d.x + ',' + d.y; | ||
}).join(' ')) | ||
.attr('transform', 'translate(' + (-w / 2) + ',' + (h * 2 / 4) + ')'); | ||
node.intersect = function (point) { | ||
return dagreD3.intersect.polygon(node, points, point); | ||
}; | ||
return shapeSvg; | ||
}; | ||
// Add custom shape for box with inverted arrow on left side | ||
render.shapes().rect_left_inv_arrow = function (parent, bbox, node) { | ||
var w = bbox.width | ||
var h = bbox.height | ||
var points = [ | ||
{ x: -h / 2, y: 0 }, | ||
{ x: w, y: 0 }, | ||
{ x: w, y: -h }, | ||
{ x: -h / 2, y: -h }, | ||
{ x: 0, y: -h / 2 } | ||
] | ||
var shapeSvg = parent.insert('polygon', ':first-child') | ||
.attr('points', points.map(function (d) { | ||
return d.x + ',' + d.y | ||
}).join(' ')) | ||
.attr('transform', 'translate(' + (-w / 2) + ',' + (h * 2 / 4) + ')') | ||
node.intersect = function (point) { | ||
return dagreD3.intersect.polygon(node, points, point) | ||
} | ||
return shapeSvg | ||
} | ||
// Add custom shape for box with inverted arrow on right side | ||
render.shapes().rect_right_inv_arrow = function (parent, bbox, node) { | ||
var w = bbox.width, | ||
h = bbox.height, | ||
points = [ | ||
{x: 0, y: 0}, | ||
{x: w+h/2, y: 0}, | ||
{x: w, y: -h/2}, | ||
{x: w+h/2, y: -h}, | ||
{x: 0, y: -h} | ||
]; | ||
var shapeSvg = parent.insert('polygon', ':first-child') | ||
.attr('points', points.map(function (d) { | ||
return d.x + ',' + d.y; | ||
}).join(' ')) | ||
.attr('transform', 'translate(' + (-w / 2) + ',' + (h * 2 / 4) + ')'); | ||
node.intersect = function (point) { | ||
return dagreD3.intersect.polygon(node, points, point); | ||
}; | ||
return shapeSvg; | ||
}; | ||
// Add custom shape for box with inverted arrow on right side | ||
render.shapes().rect_right_inv_arrow = function (parent, bbox, node) { | ||
var w = bbox.width | ||
var h = bbox.height | ||
var points = [ | ||
{ x: 0, y: 0 }, | ||
{ x: w + h / 2, y: 0 }, | ||
{ x: w, y: -h / 2 }, | ||
{ x: w + h / 2, y: -h }, | ||
{ x: 0, y: -h } | ||
] | ||
var shapeSvg = parent.insert('polygon', ':first-child') | ||
.attr('points', points.map(function (d) { | ||
return d.x + ',' + d.y | ||
}).join(' ')) | ||
.attr('transform', 'translate(' + (-w / 2) + ',' + (h * 2 / 4) + ')') | ||
node.intersect = function (point) { | ||
return dagreD3.intersect.polygon(node, points, point) | ||
} | ||
return shapeSvg | ||
} | ||
// Add our custom arrow - an empty arrowhead | ||
render.arrows().none = function normal(parent, id, edge, type) { | ||
var marker = parent.append('marker') | ||
.attr('id', id) | ||
.attr('viewBox', '0 0 10 10') | ||
.attr('refX', 9) | ||
.attr('refY', 5) | ||
.attr('markerUnits', 'strokeWidth') | ||
.attr('markerWidth', 8) | ||
.attr('markerHeight', 6) | ||
.attr('orient', 'auto'); | ||
// Add our custom arrow - an empty arrowhead | ||
render.arrows().none = function normal (parent, id, edge, type) { | ||
var marker = parent.append('marker') | ||
.attr('id', id) | ||
.attr('viewBox', '0 0 10 10') | ||
.attr('refX', 9) | ||
.attr('refY', 5) | ||
.attr('markerUnits', 'strokeWidth') | ||
.attr('markerWidth', 8) | ||
.attr('markerHeight', 6) | ||
.attr('orient', 'auto') | ||
var path = marker.append('path') | ||
.attr('d', 'M 0 0 L 0 0 L 0 0 z'); | ||
dagreD3.util.applyStyle(path, edge[type + 'Style']); | ||
}; | ||
var path = marker.append('path') | ||
.attr('d', 'M 0 0 L 0 0 L 0 0 z') | ||
dagreD3.util.applyStyle(path, edge[type + 'Style']) | ||
} | ||
// Override normal arrowhead defined in d3. Remove style & add class to allow css styling. | ||
render.arrows().normal = function normal(parent, id, edge, type) { | ||
var marker = parent.append("marker") | ||
.attr("id", id) | ||
.attr("viewBox", "0 0 10 10") | ||
.attr("refX", 9) | ||
.attr("refY", 5) | ||
.attr("markerUnits", "strokeWidth") | ||
.attr("markerWidth", 8) | ||
.attr("markerHeight", 6) | ||
.attr("orient", "auto") | ||
// Override normal arrowhead defined in d3. Remove style & add class to allow css styling. | ||
render.arrows().normal = function normal (parent, id, edge, type) { | ||
var marker = parent.append('marker') | ||
.attr('id', id) | ||
.attr('viewBox', '0 0 10 10') | ||
.attr('refX', 9) | ||
.attr('refY', 5) | ||
.attr('markerUnits', 'strokeWidth') | ||
.attr('markerWidth', 8) | ||
.attr('markerHeight', 6) | ||
.attr('orient', 'auto') | ||
var path = marker.append("path") | ||
.attr("d", "M 0 0 L 10 5 L 0 10 z") | ||
.attr("class", "arrowheadPath") | ||
.style("stroke-width", 1) | ||
.style("stroke-dasharray", "1,0"); | ||
}; | ||
marker.append('path') | ||
.attr('d', 'M 0 0 L 10 5 L 0 10 z') | ||
.attr('class', 'arrowheadPath') | ||
.style('stroke-width', 1) | ||
.style('stroke-dasharray', '1,0') | ||
} | ||
// Set up an SVG group so that we can translate the final graph. | ||
var svg = d3.select('#' + id); | ||
//svgGroup = d3.select('#' + id + ' g'); | ||
// Set up an SVG group so that we can translate the final graph. | ||
var svg = d3.select('#' + id) | ||
// Run the renderer. This is what draws the final graph. | ||
var element = d3.select('#' + id + ' g'); | ||
render(element, g); | ||
// Run the renderer. This is what draws the final graph. | ||
var element = d3.select('#' + id + ' g') | ||
render(element, g) | ||
//var tip = d3.tip().html(function(d) { return d; }); | ||
element.selectAll('g.node') | ||
.attr('title', function(){ | ||
return graph.getTooltip(this.id); | ||
}); | ||
element.selectAll('g.node') | ||
.attr('title', function () { | ||
return graph.getTooltip(this.id) | ||
}) | ||
/* | ||
var xPos = document.querySelectorAll('.clusters rect')[0].x.baseVal.value; | ||
var width = document.querySelectorAll('.clusters rect')[0].width.baseVal.value; | ||
var cluster = d3.selectAll('.cluster'); | ||
var te = cluster.append('text'); | ||
te.attr('x', xPos+width/2); | ||
te.attr('y', 12); | ||
//te.stroke('black'); | ||
te.attr('id', 'apa12'); | ||
te.style('text-anchor', 'middle'); | ||
te.text('Title for cluster'); | ||
*/ | ||
if(conf.useMaxWidth) { | ||
// Center the graph | ||
svg.attr('height', '100%'); | ||
svg.attr('width', conf.width); | ||
//svg.attr('viewBox', svgb.getBBox().x + ' 0 '+ g.graph().width+' '+ g.graph().height); | ||
svg.attr('viewBox', '0 0 ' + (g.graph().width + 20) + ' ' + (g.graph().height + 20)); | ||
svg.attr('style', 'max-width:' + (g.graph().width + 20) + 'px;'); | ||
if (conf.useMaxWidth) { | ||
// Center the graph | ||
svg.attr('height', '100%') | ||
svg.attr('width', conf.width) | ||
svg.attr('viewBox', '0 0 ' + (g.graph().width + 20) + ' ' + (g.graph().height + 20)) | ||
svg.attr('style', 'max-width:' + (g.graph().width + 20) + 'px;') | ||
} else { | ||
// Center the graph | ||
svg.attr('height', g.graph().height) | ||
if (typeof conf.width === 'undefined') { | ||
svg.attr('width', g.graph().width) | ||
} else { | ||
svg.attr('width', conf.width) | ||
} | ||
else{ | ||
// Center the graph | ||
svg.attr('height', g.graph().height ); | ||
if(typeof conf.width === 'undefined'){ | ||
svg.attr('width', g.graph().width ); | ||
}else{ | ||
svg.attr('width', conf.width ); | ||
} | ||
//svg.attr('viewBox', svgb.getBBox().x + ' 0 '+ g.graph().width+' '+ g.graph().height); | ||
svg.attr('viewBox', '0 0 ' + (g.graph().width+20) + ' ' + (g.graph().height+20)); } | ||
svg.attr('viewBox', '0 0 ' + (g.graph().width + 20) + ' ' + (g.graph().height + 20)) | ||
} | ||
// Index nodes | ||
graph.indexNodes('subGraph' + i) | ||
// Index nodes | ||
graph.indexNodes('subGraph'+i); | ||
for(i=0;i<subGraphs.length;i++){ | ||
subG = subGraphs[i]; | ||
for (i = 0; i < subGraphs.length; i++) { | ||
subG = subGraphs[i] | ||
if (subG.title !== 'undefined') { | ||
var clusterRects = document.querySelectorAll('#' + id + ' #' + subG.id + ' rect'); | ||
//log.debug('looking up: #' + id + ' #' + subG.id) | ||
var clusterEl = document.querySelectorAll('#' + id + ' #' + subG.id); | ||
if (subG.title !== 'undefined') { | ||
var clusterRects = document.querySelectorAll('#' + id + ' #' + subG.id + ' rect') | ||
var clusterEl = document.querySelectorAll('#' + id + ' #' + subG.id) | ||
var xPos = clusterRects[0].x.baseVal.value; | ||
var yPos = clusterRects[0].y.baseVal.value; | ||
var width = clusterRects[0].width.baseVal.value; | ||
var cluster = d3.select(clusterEl[0]); | ||
var te = cluster.append('text'); | ||
te.attr('x', xPos + width / 2); | ||
te.attr('y', yPos + 14); | ||
te.attr('fill', 'black'); | ||
te.attr('stroke', 'none'); | ||
te.attr('id', id + 'Text'); | ||
te.style('text-anchor', 'middle'); | ||
var xPos = clusterRects[0].x.baseVal.value | ||
var yPos = clusterRects[0].y.baseVal.value | ||
var width = clusterRects[0].width.baseVal.value | ||
var cluster = d3.select(clusterEl[0]) | ||
var te = cluster.append('text') | ||
te.attr('x', xPos + width / 2) | ||
te.attr('y', yPos + 14) | ||
te.attr('fill', 'black') | ||
te.attr('stroke', 'none') | ||
te.attr('id', id + 'Text') | ||
te.style('text-anchor', 'middle') | ||
if(typeof subG.title === 'undefined'){ | ||
te.text('Undef'); | ||
}else{ | ||
//te.text(subGraphs[subGraphs.length-i-1].title); | ||
te.text(subG.title); | ||
} | ||
} | ||
if (typeof subG.title === 'undefined') { | ||
te.text('Undef') | ||
} else { | ||
te.text(subG.title) | ||
} | ||
} | ||
} | ||
// Add label rects for non html labels | ||
if(!conf.htmlLabels){ | ||
var labels = document.querySelectorAll('#' + id +' .edgeLabel .label'); | ||
var i; | ||
for(i=0;i<labels.length;i++){ | ||
var label = labels[i]; | ||
// Add label rects for non html labels | ||
if (!conf.htmlLabels) { | ||
var labels = document.querySelectorAll('#' + id + ' .edgeLabel .label') | ||
var k | ||
for (k = 0; k < labels.length; k++) { | ||
var label = labels[i] | ||
// Get dimensions of label | ||
var dim = label.getBBox(); | ||
// Get dimensions of label | ||
var dim = label.getBBox() | ||
var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); | ||
rect.setAttribute('rx',0); | ||
rect.setAttribute('ry',0); | ||
rect.setAttribute('width',dim.width); | ||
rect.setAttribute('height',dim.height); | ||
rect.setAttribute('style','fill:#e8e8e8;'); | ||
var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect') | ||
rect.setAttribute('rx', 0) | ||
rect.setAttribute('ry', 0) | ||
rect.setAttribute('width', dim.width) | ||
rect.setAttribute('height', dim.height) | ||
rect.setAttribute('style', 'fill:#e8e8e8;') | ||
label.insertBefore(rect, label.firstChild); | ||
} | ||
label.insertBefore(rect, label.firstChild) | ||
} | ||
}; | ||
} | ||
} |
/** | ||
* Created by knut on 14-11-03. | ||
*/ | ||
var Logger = require('../../logger'); | ||
var log = new Logger.Log(); | ||
var utils = require('../../utils'); | ||
var Logger = require('../../logger') | ||
var log = Logger.Log | ||
var utils = require('../../utils') | ||
var d3 = require('../../d3'); | ||
var vertices = {}; | ||
var edges = []; | ||
var classes = []; | ||
var subGraphs = []; | ||
var tooltips = {}; | ||
var subCount=0; | ||
var direction; | ||
var d3 = require('../../d3') | ||
var vertices = {} | ||
var edges = [] | ||
var classes = [] | ||
var subGraphs = [] | ||
var tooltips = {} | ||
var subCount = 0 | ||
var direction | ||
// Functions to be run after graph rendering | ||
var funs = []; | ||
var funs = [] | ||
/** | ||
@@ -26,38 +26,38 @@ * Function called by parser when a node definition has been found | ||
exports.addVertex = function (id, text, type, style) { | ||
var txt; | ||
if(typeof id === 'undefined'){ | ||
return; | ||
} | ||
if(id.trim().length === 0){ | ||
return; | ||
} | ||
var txt | ||
if (typeof vertices[id] === 'undefined') { | ||
vertices[id] = {id: id, styles: [], classes:[]}; | ||
if (typeof id === 'undefined') { | ||
return | ||
} | ||
if (id.trim().length === 0) { | ||
return | ||
} | ||
if (typeof vertices[id] === 'undefined') { | ||
vertices[id] = { id: id, styles: [], classes: [] } | ||
} | ||
if (typeof text !== 'undefined') { | ||
txt = text.trim() | ||
// strip quotes if string starts and exnds with a quote | ||
if (txt[0] === '"' && txt[txt.length - 1] === '"') { | ||
txt = txt.substring(1, txt.length - 1) | ||
} | ||
if (typeof text !== 'undefined') { | ||
txt = text.trim(); | ||
// strip quotes if string starts and exnds with a quote | ||
if(txt[0] === '"' && txt[txt.length-1] === '"'){ | ||
txt = txt.substring(1,txt.length-1); | ||
} | ||
vertices[id].text = txt; | ||
vertices[id].text = txt | ||
} | ||
if (typeof type !== 'undefined') { | ||
vertices[id].type = type | ||
} | ||
if (typeof type !== 'undefined') { | ||
vertices[id].type = type | ||
} | ||
if (typeof style !== 'undefined') { | ||
if (style !== null) { | ||
style.forEach(function (s) { | ||
vertices[id].styles.push(s) | ||
}) | ||
} | ||
if (typeof type !== 'undefined') { | ||
vertices[id].type = type; | ||
} | ||
if (typeof type !== 'undefined') { | ||
vertices[id].type = type; | ||
} | ||
if (typeof style !== 'undefined') { | ||
if (style !== null) { | ||
style.forEach(function (s) { | ||
vertices[id].styles.push(s); | ||
}); | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
@@ -72,22 +72,22 @@ /** | ||
exports.addLink = function (start, end, type, linktext) { | ||
log.info('Got edge...', start, end); | ||
var edge = {start: start, end: end, type: undefined, text: ''}; | ||
linktext = type.text; | ||
log.info('Got edge...', start, end) | ||
var edge = { start: start, end: end, type: undefined, text: '' } | ||
linktext = type.text | ||
if (typeof linktext !== 'undefined') { | ||
edge.text = linktext.trim(); | ||
// strip quotes if string starts and exnds with a quote | ||
if(edge.text[0] === '"' && edge.text[edge.text.length-1] === '"'){ | ||
edge.text = edge.text.substring(1,edge.text.length-1); | ||
} | ||
} | ||
if (typeof linktext !== 'undefined') { | ||
edge.text = linktext.trim() | ||
if (typeof type !== 'undefined') { | ||
edge.type = type.type; | ||
edge.stroke = type.stroke; | ||
// strip quotes if string starts and exnds with a quote | ||
if (edge.text[0] === '"' && edge.text[edge.text.length - 1] === '"') { | ||
edge.text = edge.text.substring(1, edge.text.length - 1) | ||
} | ||
edges.push(edge); | ||
}; | ||
} | ||
if (typeof type !== 'undefined') { | ||
edge.type = type.type | ||
edge.stroke = type.stroke | ||
} | ||
edges.push(edge) | ||
} | ||
/** | ||
@@ -99,8 +99,8 @@ * Updates a link's line interpolation algorithm | ||
exports.updateLinkInterpolate = function (pos, interp) { | ||
if(pos === 'default'){ | ||
edges.defaultInterpolate = interp; | ||
}else{ | ||
edges[pos].interpolate = interp; | ||
} | ||
}; | ||
if (pos === 'default') { | ||
edges.defaultInterpolate = interp | ||
} else { | ||
edges[pos].interpolate = interp | ||
} | ||
} | ||
@@ -113,25 +113,25 @@ /** | ||
exports.updateLink = function (pos, style) { | ||
if(pos === 'default'){ | ||
edges.defaultStyle = style; | ||
}else{ | ||
if(utils.isSubstringInArray('fill', style) === -1) { | ||
style.push('fill:none'); | ||
} | ||
edges[pos].style = style; | ||
if (pos === 'default') { | ||
edges.defaultStyle = style | ||
} else { | ||
if (utils.isSubstringInArray('fill', style) === -1) { | ||
style.push('fill:none') | ||
} | ||
}; | ||
edges[pos].style = style | ||
} | ||
} | ||
exports.addClass = function (id, style) { | ||
if (typeof classes[id] === 'undefined') { | ||
classes[id] = {id: id, styles: []}; | ||
} | ||
if (typeof classes[id] === 'undefined') { | ||
classes[id] = { id: id, styles: [] } | ||
} | ||
if (typeof style !== 'undefined') { | ||
if (style !== null) { | ||
style.forEach(function (s) { | ||
classes[id].styles.push(s); | ||
}); | ||
} | ||
if (typeof style !== 'undefined') { | ||
if (style !== null) { | ||
style.forEach(function (s) { | ||
classes[id].styles.push(s) | ||
}) | ||
} | ||
}; | ||
} | ||
} | ||
@@ -143,4 +143,4 @@ /** | ||
exports.setDirection = function (dir) { | ||
direction = dir; | ||
}; | ||
direction = dir | ||
} | ||
@@ -151,56 +151,56 @@ /** | ||
*/ | ||
exports.setClass = function (id,className) { | ||
if(id.indexOf(',')>0){ | ||
id.split(',').forEach(function(id2){ | ||
if(typeof vertices[id2] !== 'undefined'){ | ||
vertices[id2].classes.push(className); | ||
} | ||
}); | ||
}else{ | ||
if(typeof vertices[id] !== 'undefined'){ | ||
vertices[id].classes.push(className); | ||
} | ||
exports.setClass = function (id, className) { | ||
if (id.indexOf(',') > 0) { | ||
id.split(',').forEach(function (id2) { | ||
if (typeof vertices[id2] !== 'undefined') { | ||
vertices[id2].classes.push(className) | ||
} | ||
}) | ||
} else { | ||
if (typeof vertices[id] !== 'undefined') { | ||
vertices[id].classes.push(className) | ||
} | ||
}; | ||
} | ||
} | ||
var setTooltip = function(id,tooltip){ | ||
if(typeof tooltip !== 'undefined'){ | ||
tooltips[id]=tooltip; | ||
} | ||
}; | ||
var setTooltip = function (id, tooltip) { | ||
if (typeof tooltip !== 'undefined') { | ||
tooltips[id] = tooltip | ||
} | ||
} | ||
var setClickFun = function(id, functionName){ | ||
if(typeof functionName === 'undefined'){ | ||
return; | ||
} | ||
if (typeof vertices[id] !== 'undefined') { | ||
funs.push(function (element) { | ||
var elem = d3.select(element).select('#'+id); | ||
if (elem !== null) { | ||
elem.on('click', function () { | ||
eval(functionName + '(\'' + id + '\')'); // jshint ignore:line | ||
}); | ||
} | ||
}); | ||
} | ||
}; | ||
var setClickFun = function (id, functionName) { | ||
if (typeof functionName === 'undefined') { | ||
return | ||
} | ||
if (typeof vertices[id] !== 'undefined') { | ||
funs.push(function (element) { | ||
var elem = d3.select(element).select('#' + id) | ||
if (elem !== null) { | ||
elem.on('click', function () { | ||
window[functionName](id) | ||
}) | ||
} | ||
}) | ||
} | ||
} | ||
var setLink = function(id, linkStr){ | ||
if(typeof linkStr === 'undefined'){ | ||
return; | ||
} | ||
if (typeof vertices[id] !== 'undefined') { | ||
funs.push(function (element) { | ||
var elem = d3.select(element).select('#'+id); | ||
if (elem !== null) { | ||
elem.on('click', function () { | ||
window.open(linkStr,'newTab'); // jshint ignore:line | ||
}); | ||
} | ||
}); | ||
} | ||
}; | ||
exports.getTooltip = function(id){ | ||
return tooltips[id]; | ||
}; | ||
var setLink = function (id, linkStr) { | ||
if (typeof linkStr === 'undefined') { | ||
return | ||
} | ||
if (typeof vertices[id] !== 'undefined') { | ||
funs.push(function (element) { | ||
var elem = d3.select(element).select('#' + id) | ||
if (elem !== null) { | ||
elem.on('click', function () { | ||
window.open(linkStr, 'newTab') | ||
}) | ||
} | ||
}) | ||
} | ||
} | ||
exports.getTooltip = function (id) { | ||
return tooltips[id] | ||
} | ||
@@ -211,24 +211,24 @@ /** | ||
*/ | ||
exports.setClickEvent = function (id,functionName, link,tooltip) { | ||
if(id.indexOf(',')>0){ | ||
id.split(',').forEach(function(id2) { | ||
setTooltip(id2,tooltip); | ||
setClickFun(id2, functionName); | ||
setLink(id2, link); | ||
}); | ||
}else{ | ||
setTooltip(id,tooltip); | ||
setClickFun(id, functionName); | ||
setLink(id, link); | ||
} | ||
}; | ||
exports.setClickEvent = function (id, functionName, link, tooltip) { | ||
if (id.indexOf(',') > 0) { | ||
id.split(',').forEach(function (id2) { | ||
setTooltip(id2, tooltip) | ||
setClickFun(id2, functionName) | ||
setLink(id2, link) | ||
}) | ||
} else { | ||
setTooltip(id, tooltip) | ||
setClickFun(id, functionName) | ||
setLink(id, link) | ||
} | ||
} | ||
exports.bindFunctions = function(element){ | ||
funs.forEach(function(fun){ | ||
fun(element); | ||
}); | ||
}; | ||
exports.bindFunctions = function (element) { | ||
funs.forEach(function (fun) { | ||
fun(element) | ||
}) | ||
} | ||
exports.getDirection = function () { | ||
return direction; | ||
}; | ||
return direction | ||
} | ||
/** | ||
@@ -239,4 +239,4 @@ * Retrieval function for fetching the found nodes after parsing has completed. | ||
exports.getVertices = function () { | ||
return vertices; | ||
}; | ||
return vertices | ||
} | ||
@@ -248,4 +248,4 @@ /** | ||
exports.getEdges = function () { | ||
return edges; | ||
}; | ||
return edges | ||
} | ||
@@ -257,47 +257,45 @@ /** | ||
exports.getClasses = function () { | ||
return classes; | ||
}; | ||
return classes | ||
} | ||
var setupToolTips = function(element){ | ||
var setupToolTips = function (element) { | ||
var tooltipElem = d3.select('.mermaidTooltip') | ||
if (tooltipElem[0][0] === null) { | ||
tooltipElem = d3.select('body') | ||
.append('div') | ||
.attr('class', 'mermaidTooltip') | ||
.style('opacity', 0) | ||
} | ||
var tooltipElem = d3.select('.mermaidTooltip'); | ||
if(tooltipElem[0][0] === null){ | ||
tooltipElem = d3.select('body') | ||
.append('div') | ||
.attr('class', 'mermaidTooltip') | ||
.style('opacity', 0); | ||
} | ||
var svg = d3.select(element).select('svg') | ||
var svg = d3.select(element).select('svg'); | ||
var nodes = svg.selectAll('g.node') | ||
nodes | ||
.on('mouseover', function () { | ||
var el = d3.select(this) | ||
var title = el.attr('title') | ||
// Dont try to draw a tooltip if no data is provided | ||
if (title === null) { | ||
return | ||
} | ||
var rect = this.getBoundingClientRect() | ||
var nodes = svg.selectAll('g.node'); | ||
nodes | ||
.on('mouseover', function() { | ||
var el = d3.select(this); | ||
var title = el.attr('title'); | ||
// Dont try to draw a tooltip if no data is provided | ||
if(title === null){ | ||
return; | ||
} | ||
var rect = this.getBoundingClientRect(); | ||
tooltipElem.transition() | ||
.duration(200) | ||
.style('opacity', '.9') | ||
tooltipElem.html(el.attr('title')) | ||
.style('left', (rect.left + (rect.right - rect.left) / 2) + 'px') | ||
.style('top', (rect.top - 14 + document.body.scrollTop) + 'px') | ||
el.classed('hover', true) | ||
}) | ||
.on('mouseout', function () { | ||
tooltipElem.transition() | ||
.duration(500) | ||
.style('opacity', 0) | ||
var el = d3.select(this) | ||
el.classed('hover', false) | ||
}) | ||
} | ||
funs.push(setupToolTips) | ||
tooltipElem.transition() | ||
.duration(200) | ||
.style('opacity', '.9'); | ||
tooltipElem.html(el.attr('title')) | ||
.style('left', (rect.left+(rect.right-rect.left)/2) + 'px') | ||
.style('top', (rect.top-14+document.body.scrollTop) + 'px'); | ||
el.classed('hover',true); | ||
}) | ||
.on('mouseout', function() { | ||
tooltipElem.transition() | ||
.duration(500) | ||
.style('opacity', 0); | ||
var el = d3.select(this); | ||
el.classed('hover',false); | ||
}); | ||
}; | ||
funs.push(setupToolTips); | ||
/** | ||
@@ -307,11 +305,11 @@ * Clears the internal graph db so that a new graph can be parsed. | ||
exports.clear = function () { | ||
vertices = {}; | ||
classes = {}; | ||
edges = []; | ||
funs = []; | ||
funs.push(setupToolTips); | ||
subGraphs = []; | ||
subCount = 0; | ||
tooltips = []; | ||
}; | ||
vertices = {} | ||
classes = {} | ||
edges = [] | ||
funs = [] | ||
funs.push(setupToolTips) | ||
subGraphs = [] | ||
subCount = 0 | ||
tooltips = [] | ||
} | ||
/** | ||
@@ -322,4 +320,4 @@ * | ||
exports.defaultStyle = function () { | ||
return 'fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;'; | ||
}; | ||
return 'fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;' | ||
} | ||
@@ -330,105 +328,92 @@ /** | ||
exports.addSubGraph = function (list, title) { | ||
function uniq(a) { | ||
var prims = {'boolean':{}, 'number':{}, 'string':{}}, objs = []; | ||
function uniq (a) { | ||
var prims = { 'boolean': {}, 'number': {}, 'string': {} } | ||
var objs = [] | ||
return a.filter(function(item) { | ||
var type = typeof item; | ||
if(item===' '){ | ||
return false; | ||
} | ||
if(type in prims) | ||
return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true); | ||
else | ||
return objs.indexOf(item) >= 0 ? false : objs.push(item); | ||
}); | ||
} | ||
return a.filter(function (item) { | ||
var type = typeof item | ||
if (item === ' ') { | ||
return false | ||
} | ||
if (type in prims) { return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true) } else { return objs.indexOf(item) >= 0 ? false : objs.push(item) } | ||
}) | ||
} | ||
var nodeList = []; | ||
var nodeList = [] | ||
nodeList = uniq(nodeList.concat.apply(nodeList,list)); | ||
nodeList = uniq(nodeList.concat.apply(nodeList, list)) | ||
var subGraph = { id: 'subGraph' + subCount, nodes: nodeList, title: title } | ||
subGraphs.push(subGraph) | ||
subCount = subCount + 1 | ||
return subGraph.id | ||
} | ||
var subGraph = {id:'subGraph'+subCount, nodes:nodeList,title:title}; | ||
//log.debug('subGraph:' + subGraph.title + subGraph.id); | ||
//log.debug(subGraph.nodes); | ||
subGraphs.push(subGraph); | ||
subCount = subCount + 1; | ||
return subGraph.id; | ||
}; | ||
var getPosForId = function(id){ | ||
var i; | ||
for(i=0;i<subGraphs.length;i++){ | ||
if(subGraphs[i].id===id){ | ||
//log.debug('Found pos for ',id,' ',i); | ||
return i; | ||
} | ||
var getPosForId = function (id) { | ||
var i | ||
for (i = 0; i < subGraphs.length; i++) { | ||
if (subGraphs[i].id === id) { | ||
return i | ||
} | ||
//log.debug('No pos found for ',id,' ',i); | ||
return -1; | ||
}; | ||
var secCount = -1; | ||
var posCrossRef = []; | ||
} | ||
return -1 | ||
} | ||
var secCount = -1 | ||
var posCrossRef = [] | ||
var indexNodes = function (id, pos) { | ||
var nodes = subGraphs[pos].nodes; | ||
secCount = secCount + 1; | ||
if(secCount>2000){ | ||
return; | ||
var nodes = subGraphs[pos].nodes | ||
secCount = secCount + 1 | ||
if (secCount > 2000) { | ||
return | ||
} | ||
posCrossRef[secCount] = pos | ||
// Check if match | ||
if (subGraphs[pos].id === id) { | ||
return { | ||
result: true, | ||
count: 0 | ||
} | ||
//var nPos = getPosForId(subGraphs[pos].id); | ||
posCrossRef[secCount]=pos; | ||
// Check if match | ||
if(subGraphs[pos].id === id){ | ||
} | ||
var count = 0 | ||
var posCount = 1 | ||
while (count < nodes.length) { | ||
var childPos = getPosForId(nodes[count]) | ||
// Ignore regular nodes (pos will be -1) | ||
if (childPos >= 0) { | ||
var res = indexNodes(id, childPos) | ||
if (res.result) { | ||
return { | ||
result:true, | ||
count:0 | ||
}; | ||
} | ||
var count = 0; | ||
var posCount = 1; | ||
while(count<nodes.length){ | ||
var childPos = getPosForId(nodes[count]); | ||
// Ignore regular nodes (pos will be -1) | ||
if(childPos>=0){ | ||
var res = indexNodes(id,childPos); | ||
if(res.result){ | ||
return { | ||
result:true, | ||
count:posCount+res.count | ||
}; | ||
}else{ | ||
posCount = posCount + res.count; | ||
} | ||
result: true, | ||
count: posCount + res.count | ||
} | ||
count = count +1; | ||
} else { | ||
posCount = posCount + res.count | ||
} | ||
} | ||
return { | ||
result:false, | ||
count:posCount | ||
}; | ||
count = count + 1 | ||
} | ||
}; | ||
return { | ||
result: false, | ||
count: posCount | ||
} | ||
} | ||
exports.getDepthFirstPos = function (pos) { | ||
return posCrossRef[pos]; | ||
}; | ||
return posCrossRef[pos] | ||
} | ||
exports.indexNodes = function () { | ||
secCount = -1; | ||
if(subGraphs.length>0){ | ||
indexNodes('none',subGraphs.length-1,0); | ||
} | ||
}; | ||
secCount = -1 | ||
if (subGraphs.length > 0) { | ||
indexNodes('none', subGraphs.length - 1, 0) | ||
} | ||
} | ||
exports.getSubGraphs = function () { | ||
return subGraphs; | ||
}; | ||
return subGraphs | ||
} | ||
exports.parseError = function(err,hash){ | ||
global.mermaidAPI.parseError(err,hash); | ||
}; | ||
exports.parseError = function (err, hash) { | ||
global.mermaidAPI.parseError(err, hash) | ||
} |
@@ -53,3 +53,2 @@ /* parser generated by jison 0.4.17 */ | ||
token location info (@$, _$, etc.): { | ||
@@ -63,3 +62,2 @@ first_line: n, | ||
the parseError function receives a 'hash' object with these members for lexer and parser errors: { | ||
@@ -76,669 +74,666 @@ text: (matched text) | ||
*/ | ||
var parser = (function(){ | ||
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,5],$V1=[1,6],$V2=[1,12],$V3=[1,13],$V4=[1,14],$V5=[1,15],$V6=[1,16],$V7=[1,17],$V8=[1,18],$V9=[1,19],$Va=[1,20],$Vb=[1,21],$Vc=[1,22],$Vd=[8,16,17,18,19,20,21,22,23,24,25,26],$Ve=[1,37],$Vf=[1,33],$Vg=[1,34],$Vh=[1,35],$Vi=[1,36],$Vj=[8,10,16,17,18,19,20,21,22,23,24,25,26,28,32,37,39,40,45,57,58],$Vk=[10,28],$Vl=[10,28,37,57,58],$Vm=[2,49],$Vn=[1,45],$Vo=[1,48],$Vp=[1,49],$Vq=[1,52],$Vr=[2,65],$Vs=[1,65],$Vt=[1,66],$Vu=[1,67],$Vv=[1,68],$Vw=[1,69],$Vx=[1,70],$Vy=[1,71],$Vz=[1,72],$VA=[1,73],$VB=[8,16,17,18,19,20,21,22,23,24,25,26,47],$VC=[10,28,37]; | ||
var parser = {trace: function trace() { }, | ||
yy: {}, | ||
symbols_: {"error":2,"expressions":3,"graph":4,"EOF":5,"graphStatement":6,"idStatement":7,"{":8,"stmt_list":9,"}":10,"strict":11,"GRAPH":12,"DIGRAPH":13,"textNoTags":14,"textNoTagsToken":15,"ALPHA":16,"NUM":17,"COLON":18,"PLUS":19,"EQUALS":20,"MULT":21,"DOT":22,"BRKT":23,"SPACE":24,"MINUS":25,"keywords":26,"stmt":27,";":28,"node_stmt":29,"edge_stmt":30,"attr_stmt":31,"=":32,"subgraph":33,"attr_list":34,"NODE":35,"EDGE":36,"[":37,"a_list":38,"]":39,",":40,"edgeRHS":41,"node_id":42,"edgeop":43,"port":44,":":45,"compass_pt":46,"SUBGRAPH":47,"n":48,"ne":49,"e":50,"se":51,"s":52,"sw":53,"w":54,"nw":55,"c":56,"ARROW_POINT":57,"ARROW_OPEN":58,"$accept":0,"$end":1}, | ||
terminals_: {2:"error",5:"EOF",8:"{",10:"}",11:"strict",12:"GRAPH",13:"DIGRAPH",16:"ALPHA",17:"NUM",18:"COLON",19:"PLUS",20:"EQUALS",21:"MULT",22:"DOT",23:"BRKT",24:"SPACE",25:"MINUS",26:"keywords",28:";",32:"=",35:"NODE",36:"EDGE",37:"[",39:"]",40:",",45:":",47:"SUBGRAPH",48:"n",49:"ne",50:"e",51:"se",52:"s",53:"sw",54:"w",55:"nw",56:"c",57:"ARROW_POINT",58:"ARROW_OPEN"}, | ||
productions_: [0,[3,2],[4,5],[4,6],[4,4],[6,1],[6,1],[7,1],[14,1],[14,2],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[9,1],[9,3],[27,1],[27,1],[27,1],[27,3],[27,1],[31,2],[31,2],[31,2],[34,4],[34,3],[34,3],[34,2],[38,5],[38,5],[38,3],[30,3],[30,3],[30,2],[30,2],[41,3],[41,3],[41,2],[41,2],[29,2],[29,1],[42,2],[42,1],[44,4],[44,2],[44,2],[33,5],[33,4],[33,3],[46,1],[46,1],[46,1],[46,1],[46,1],[46,1],[46,1],[46,1],[46,1],[46,0],[43,1],[43,1]], | ||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
var parser = (function () { | ||
var o = function (k, v, o, l) { for (o = o || {}, l = k.length; l--; o[k[l]] = v);return o }, $V0 = [1, 5], $V1 = [1, 6], $V2 = [1, 12], $V3 = [1, 13], $V4 = [1, 14], $V5 = [1, 15], $V6 = [1, 16], $V7 = [1, 17], $V8 = [1, 18], $V9 = [1, 19], $Va = [1, 20], $Vb = [1, 21], $Vc = [1, 22], $Vd = [8, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26], $Ve = [1, 37], $Vf = [1, 33], $Vg = [1, 34], $Vh = [1, 35], $Vi = [1, 36], $Vj = [8, 10, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 32, 37, 39, 40, 45, 57, 58], $Vk = [10, 28], $Vl = [10, 28, 37, 57, 58], $Vm = [2, 49], $Vn = [1, 45], $Vo = [1, 48], $Vp = [1, 49], $Vq = [1, 52], $Vr = [2, 65], $Vs = [1, 65], $Vt = [1, 66], $Vu = [1, 67], $Vv = [1, 68], $Vw = [1, 69], $Vx = [1, 70], $Vy = [1, 71], $Vz = [1, 72], $VA = [1, 73], $VB = [8, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 47], $VC = [10, 28, 37] | ||
var parser = {trace: function trace () { }, | ||
yy: {}, | ||
symbols_: {'error': 2, 'expressions': 3, 'graph': 4, 'EOF': 5, 'graphStatement': 6, 'idStatement': 7, '{': 8, 'stmt_list': 9, '}': 10, 'strict': 11, 'GRAPH': 12, 'DIGRAPH': 13, 'textNoTags': 14, 'textNoTagsToken': 15, 'ALPHA': 16, 'NUM': 17, 'COLON': 18, 'PLUS': 19, 'EQUALS': 20, 'MULT': 21, 'DOT': 22, 'BRKT': 23, 'SPACE': 24, 'MINUS': 25, 'keywords': 26, 'stmt': 27, ';': 28, 'node_stmt': 29, 'edge_stmt': 30, 'attr_stmt': 31, '=': 32, 'subgraph': 33, 'attr_list': 34, 'NODE': 35, 'EDGE': 36, '[': 37, 'a_list': 38, ']': 39, ',': 40, 'edgeRHS': 41, 'node_id': 42, 'edgeop': 43, 'port': 44, ':': 45, 'compass_pt': 46, 'SUBGRAPH': 47, 'n': 48, 'ne': 49, 'e': 50, 'se': 51, 's': 52, 'sw': 53, 'w': 54, 'nw': 55, 'c': 56, 'ARROW_POINT': 57, 'ARROW_OPEN': 58, '$accept': 0, '$end': 1}, | ||
terminals_: {2: 'error', 5: 'EOF', 8: '{', 10: '}', 11: 'strict', 12: 'GRAPH', 13: 'DIGRAPH', 16: 'ALPHA', 17: 'NUM', 18: 'COLON', 19: 'PLUS', 20: 'EQUALS', 21: 'MULT', 22: 'DOT', 23: 'BRKT', 24: 'SPACE', 25: 'MINUS', 26: 'keywords', 28: ';', 32: '=', 35: 'NODE', 36: 'EDGE', 37: '[', 39: ']', 40: ',', 45: ':', 47: 'SUBGRAPH', 48: 'n', 49: 'ne', 50: 'e', 51: 'se', 52: 's', 53: 'sw', 54: 'w', 55: 'nw', 56: 'c', 57: 'ARROW_POINT', 58: 'ARROW_OPEN'}, | ||
productions_: [0, [3, 2], [4, 5], [4, 6], [4, 4], [6, 1], [6, 1], [7, 1], [14, 1], [14, 2], [15, 1], [15, 1], [15, 1], [15, 1], [15, 1], [15, 1], [15, 1], [15, 1], [15, 1], [15, 1], [15, 1], [9, 1], [9, 3], [27, 1], [27, 1], [27, 1], [27, 3], [27, 1], [31, 2], [31, 2], [31, 2], [34, 4], [34, 3], [34, 3], [34, 2], [38, 5], [38, 5], [38, 3], [30, 3], [30, 3], [30, 2], [30, 2], [41, 3], [41, 3], [41, 2], [41, 2], [29, 2], [29, 1], [42, 2], [42, 1], [44, 4], [44, 2], [44, 2], [33, 5], [33, 4], [33, 3], [46, 1], [46, 1], [46, 1], [46, 1], [46, 1], [46, 1], [46, 1], [46, 1], [46, 1], [46, 0], [43, 1], [43, 1]], | ||
performAction: function anonymous (yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
/* this == yyval */ | ||
var $0 = $$.length - 1; | ||
switch (yystate) { | ||
case 1: | ||
this.$=$$[$0-1]; | ||
break; | ||
case 2: | ||
this.$=$$[$0-4]; | ||
break; | ||
case 3: | ||
this.$=$$[$0-5]; | ||
break; | ||
case 4: | ||
this.$=$$[$0-3]; | ||
break; | ||
case 8: case 10: case 11: | ||
this.$=$$[$0]; | ||
break; | ||
case 9: | ||
this.$=$$[$0-1]+''+$$[$0]; | ||
break; | ||
case 12: case 13: case 14: case 15: case 16: case 18: case 19: case 20: | ||
this.$ = $$[$0]; | ||
break; | ||
case 17: | ||
this.$ = '<br>'; | ||
break; | ||
case 39: | ||
this.$='oy'; | ||
break; | ||
case 40: | ||
var $0 = $$.length - 1 | ||
switch (yystate) { | ||
case 1: | ||
this.$ = $$[$0 - 1] | ||
break | ||
case 2: | ||
this.$ = $$[$0 - 4] | ||
break | ||
case 3: | ||
this.$ = $$[$0 - 5] | ||
break | ||
case 4: | ||
this.$ = $$[$0 - 3] | ||
break | ||
case 8: case 10: case 11: | ||
this.$ = $$[$0] | ||
break | ||
case 9: | ||
this.$ = $$[$0 - 1] + '' + $$[$0] | ||
break | ||
case 12: case 13: case 14: case 15: case 16: case 18: case 19: case 20: | ||
this.$ = $$[$0] | ||
break | ||
case 17: | ||
this.$ = '<br>' | ||
break | ||
case 39: | ||
this.$ = 'oy' | ||
break | ||
case 40: | ||
yy.addLink($$[$0-1],$$[$0].id,$$[$0].op); | ||
this.$='oy'; | ||
break; | ||
case 42: | ||
yy.addLink($$[$0 - 1], $$[$0].id, $$[$0].op) | ||
this.$ = 'oy' | ||
break | ||
case 42: | ||
yy.addLink($$[$0-1],$$[$0].id,$$[$0].op); | ||
this.$={op:$$[$0-2],id:$$[$0-1]}; | ||
break; | ||
case 44: | ||
yy.addLink($$[$0 - 1], $$[$0].id, $$[$0].op) | ||
this.$ = {op: $$[$0 - 2], id: $$[$0 - 1]} | ||
this.$={op:$$[$0-1],id:$$[$0]}; | ||
break; | ||
case 48: | ||
yy.addVertex($$[$0-1]);this.$=$$[$0-1]; | ||
break; | ||
case 49: | ||
yy.addVertex($$[$0]);this.$=$$[$0]; | ||
break; | ||
case 66: | ||
this.$='arrow'; | ||
break; | ||
case 67: | ||
this.$='arrow_open'; | ||
break; | ||
} | ||
}, | ||
table: [{3:1,4:2,6:3,11:[1,4],12:$V0,13:$V1},{1:[3]},{5:[1,7]},{7:8,8:[1,9],14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc},{6:23,12:$V0,13:$V1},o($Vd,[2,5]),o($Vd,[2,6]),{1:[2,1]},{8:[1,24]},{7:30,8:$Ve,9:25,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},o([8,10,28,32,37,39,40,45,57,58],[2,7],{15:38,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc}),o($Vj,[2,8]),o($Vj,[2,10]),o($Vj,[2,11]),o($Vj,[2,12]),o($Vj,[2,13]),o($Vj,[2,14]),o($Vj,[2,15]),o($Vj,[2,16]),o($Vj,[2,17]),o($Vj,[2,18]),o($Vj,[2,19]),o($Vj,[2,20]),{7:39,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc},{7:30,8:$Ve,9:40,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},{10:[1,41]},{10:[2,21],28:[1,42]},o($Vk,[2,23]),o($Vk,[2,24]),o($Vk,[2,25]),o($Vl,$Vm,{44:44,32:[1,43],45:$Vn}),o($Vk,[2,27],{41:46,43:47,57:$Vo,58:$Vp}),o($Vk,[2,47],{43:47,34:50,41:51,37:$Vq,57:$Vo,58:$Vp}),{34:53,37:$Vq},{34:54,37:$Vq},{34:55,37:$Vq},{7:56,8:[1,57],14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc},{7:30,8:$Ve,9:58,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},o($Vj,[2,9]),{8:[1,59]},{10:[1,60]},{5:[2,4]},{7:30,8:$Ve,9:61,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},{7:62,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc},o($Vl,[2,48]),o($Vl,$Vr,{14:10,15:11,7:63,46:64,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,48:$Vs,49:$Vt,50:$Vu,51:$Vv,52:$Vw,53:$Vx,54:$Vy,55:$Vz,56:$VA}),o($Vk,[2,41],{34:74,37:$Vq}),{7:77,8:$Ve,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,33:76,42:75,47:$Vi},o($VB,[2,66]),o($VB,[2,67]),o($Vk,[2,46]),o($Vk,[2,40],{34:78,37:$Vq}),{7:81,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,38:79,39:[1,80]},o($Vk,[2,28]),o($Vk,[2,29]),o($Vk,[2,30]),{8:[1,82]},{7:30,8:$Ve,9:83,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},{10:[1,84]},{7:30,8:$Ve,9:85,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},{5:[2,2]},{10:[2,22]},o($Vk,[2,26]),o($Vl,[2,51],{45:[1,86]}),o($Vl,[2,52]),o($Vl,[2,56]),o($Vl,[2,57]),o($Vl,[2,58]),o($Vl,[2,59]),o($Vl,[2,60]),o($Vl,[2,61]),o($Vl,[2,62]),o($Vl,[2,63]),o($Vl,[2,64]),o($Vk,[2,38]),o($VC,[2,44],{43:47,41:87,57:$Vo,58:$Vp}),o($VC,[2,45],{43:47,41:88,57:$Vo,58:$Vp}),o($Vl,$Vm,{44:44,45:$Vn}),o($Vk,[2,39]),{39:[1,89]},o($Vk,[2,34],{34:90,37:$Vq}),{32:[1,91]},{7:30,8:$Ve,9:92,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},{10:[1,93]},o($Vl,[2,55]),{10:[1,94]},o($Vl,$Vr,{46:95,48:$Vs,49:$Vt,50:$Vu,51:$Vv,52:$Vw,53:$Vx,54:$Vy,55:$Vz,56:$VA}),o($VC,[2,42]),o($VC,[2,43]),o($Vk,[2,33],{34:96,37:$Vq}),o($Vk,[2,32]),{7:97,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc},{10:[1,98]},o($Vl,[2,54]),{5:[2,3]},o($Vl,[2,50]),o($Vk,[2,31]),{28:[1,99],39:[2,37],40:[1,100]},o($Vl,[2,53]),{7:81,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,38:101},{7:81,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,38:102},{39:[2,35]},{39:[2,36]}], | ||
defaultActions: {7:[2,1],41:[2,4],60:[2,2],61:[2,22],94:[2,3],101:[2,35],102:[2,36]}, | ||
parseError: function parseError(str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str); | ||
} else { | ||
break | ||
case 44: | ||
this.$ = {op: $$[$0 - 1], id: $$[$0]} | ||
break | ||
case 48: | ||
yy.addVertex($$[$0 - 1]); this.$ = $$[$0 - 1] | ||
break | ||
case 49: | ||
yy.addVertex($$[$0]); this.$ = $$[$0] | ||
break | ||
case 66: | ||
this.$ = 'arrow' | ||
break | ||
case 67: | ||
this.$ = 'arrow_open' | ||
break | ||
} | ||
}, | ||
table: [{3: 1, 4: 2, 6: 3, 11: [1, 4], 12: $V0, 13: $V1}, {1: [3]}, {5: [1, 7]}, {7: 8, 8: [1, 9], 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc}, {6: 23, 12: $V0, 13: $V1}, o($Vd, [2, 5]), o($Vd, [2, 6]), {1: [2, 1]}, {8: [1, 24]}, {7: 30, 8: $Ve, 9: 25, 12: $Vf, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: 26, 29: 27, 30: 28, 31: 29, 33: 31, 35: $Vg, 36: $Vh, 42: 32, 47: $Vi}, o([8, 10, 28, 32, 37, 39, 40, 45, 57, 58], [2, 7], {15: 38, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc}), o($Vj, [2, 8]), o($Vj, [2, 10]), o($Vj, [2, 11]), o($Vj, [2, 12]), o($Vj, [2, 13]), o($Vj, [2, 14]), o($Vj, [2, 15]), o($Vj, [2, 16]), o($Vj, [2, 17]), o($Vj, [2, 18]), o($Vj, [2, 19]), o($Vj, [2, 20]), {7: 39, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc}, {7: 30, 8: $Ve, 9: 40, 12: $Vf, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: 26, 29: 27, 30: 28, 31: 29, 33: 31, 35: $Vg, 36: $Vh, 42: 32, 47: $Vi}, {10: [1, 41]}, {10: [2, 21], 28: [1, 42]}, o($Vk, [2, 23]), o($Vk, [2, 24]), o($Vk, [2, 25]), o($Vl, $Vm, {44: 44, 32: [1, 43], 45: $Vn}), o($Vk, [2, 27], {41: 46, 43: 47, 57: $Vo, 58: $Vp}), o($Vk, [2, 47], {43: 47, 34: 50, 41: 51, 37: $Vq, 57: $Vo, 58: $Vp}), {34: 53, 37: $Vq}, {34: 54, 37: $Vq}, {34: 55, 37: $Vq}, {7: 56, 8: [1, 57], 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc}, {7: 30, 8: $Ve, 9: 58, 12: $Vf, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: 26, 29: 27, 30: 28, 31: 29, 33: 31, 35: $Vg, 36: $Vh, 42: 32, 47: $Vi}, o($Vj, [2, 9]), {8: [1, 59]}, {10: [1, 60]}, {5: [2, 4]}, {7: 30, 8: $Ve, 9: 61, 12: $Vf, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: 26, 29: 27, 30: 28, 31: 29, 33: 31, 35: $Vg, 36: $Vh, 42: 32, 47: $Vi}, {7: 62, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc}, o($Vl, [2, 48]), o($Vl, $Vr, {14: 10, 15: 11, 7: 63, 46: 64, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 48: $Vs, 49: $Vt, 50: $Vu, 51: $Vv, 52: $Vw, 53: $Vx, 54: $Vy, 55: $Vz, 56: $VA}), o($Vk, [2, 41], {34: 74, 37: $Vq}), {7: 77, 8: $Ve, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 33: 76, 42: 75, 47: $Vi}, o($VB, [2, 66]), o($VB, [2, 67]), o($Vk, [2, 46]), o($Vk, [2, 40], {34: 78, 37: $Vq}), {7: 81, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 38: 79, 39: [1, 80]}, o($Vk, [2, 28]), o($Vk, [2, 29]), o($Vk, [2, 30]), {8: [1, 82]}, {7: 30, 8: $Ve, 9: 83, 12: $Vf, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: 26, 29: 27, 30: 28, 31: 29, 33: 31, 35: $Vg, 36: $Vh, 42: 32, 47: $Vi}, {10: [1, 84]}, {7: 30, 8: $Ve, 9: 85, 12: $Vf, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: 26, 29: 27, 30: 28, 31: 29, 33: 31, 35: $Vg, 36: $Vh, 42: 32, 47: $Vi}, {5: [2, 2]}, {10: [2, 22]}, o($Vk, [2, 26]), o($Vl, [2, 51], {45: [1, 86]}), o($Vl, [2, 52]), o($Vl, [2, 56]), o($Vl, [2, 57]), o($Vl, [2, 58]), o($Vl, [2, 59]), o($Vl, [2, 60]), o($Vl, [2, 61]), o($Vl, [2, 62]), o($Vl, [2, 63]), o($Vl, [2, 64]), o($Vk, [2, 38]), o($VC, [2, 44], {43: 47, 41: 87, 57: $Vo, 58: $Vp}), o($VC, [2, 45], {43: 47, 41: 88, 57: $Vo, 58: $Vp}), o($Vl, $Vm, {44: 44, 45: $Vn}), o($Vk, [2, 39]), {39: [1, 89]}, o($Vk, [2, 34], {34: 90, 37: $Vq}), {32: [1, 91]}, {7: 30, 8: $Ve, 9: 92, 12: $Vf, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: 26, 29: 27, 30: 28, 31: 29, 33: 31, 35: $Vg, 36: $Vh, 42: 32, 47: $Vi}, {10: [1, 93]}, o($Vl, [2, 55]), {10: [1, 94]}, o($Vl, $Vr, {46: 95, 48: $Vs, 49: $Vt, 50: $Vu, 51: $Vv, 52: $Vw, 53: $Vx, 54: $Vy, 55: $Vz, 56: $VA}), o($VC, [2, 42]), o($VC, [2, 43]), o($Vk, [2, 33], {34: 96, 37: $Vq}), o($Vk, [2, 32]), {7: 97, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc}, {10: [1, 98]}, o($Vl, [2, 54]), {5: [2, 3]}, o($Vl, [2, 50]), o($Vk, [2, 31]), {28: [1, 99], 39: [2, 37], 40: [1, 100]}, o($Vl, [2, 53]), {7: 81, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 38: 101}, {7: 81, 14: 10, 15: 11, 16: $V2, 17: $V3, 18: $V4, 19: $V5, 20: $V6, 21: $V7, 22: $V8, 23: $V9, 24: $Va, 25: $Vb, 26: $Vc, 38: 102}, {39: [2, 35]}, {39: [2, 36]}], | ||
defaultActions: {7: [2, 1], 41: [2, 4], 60: [2, 2], 61: [2, 22], 94: [2, 3], 101: [2, 35], 102: [2, 36]}, | ||
parseError: function parseError (str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str) | ||
} else { | ||
function _parseError (msg, hash) { | ||
this.message = msg; | ||
this.hash = hash; | ||
this.message = msg | ||
this.hash = hash | ||
} | ||
_parseError.prototype = Error; | ||
_parseError.prototype = Error | ||
throw new _parseError(str, hash); | ||
} | ||
}, | ||
parse: function parse(input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; | ||
var args = lstack.slice.call(arguments, 1); | ||
var lexer = Object.create(this.lexer); | ||
var sharedState = { yy: {} }; | ||
for (var k in this.yy) { | ||
throw new _parseError(str, hash) | ||
} | ||
}, | ||
parse: function parse (input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1 | ||
var args = lstack.slice.call(arguments, 1) | ||
var lexer = Object.create(this.lexer) | ||
var sharedState = { yy: {} } | ||
for (var k in this.yy) { | ||
if (Object.prototype.hasOwnProperty.call(this.yy, k)) { | ||
sharedState.yy[k] = this.yy[k]; | ||
sharedState.yy[k] = this.yy[k] | ||
} | ||
} | ||
lexer.setInput(input, sharedState.yy); | ||
sharedState.yy.lexer = lexer; | ||
sharedState.yy.parser = this; | ||
if (typeof lexer.yylloc == 'undefined') { | ||
lexer.yylloc = {}; | ||
} | ||
var yyloc = lexer.yylloc; | ||
lstack.push(yyloc); | ||
var ranges = lexer.options && lexer.options.ranges; | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError; | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError; | ||
} | ||
function popStack(n) { | ||
stack.length = stack.length - 2 * n; | ||
vstack.length = vstack.length - n; | ||
lstack.length = lstack.length - n; | ||
} | ||
_token_stack: | ||
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]; | ||
} | ||
lexer.setInput(input, sharedState.yy) | ||
sharedState.yy.lexer = lexer | ||
sharedState.yy.parser = this | ||
if (typeof lexer.yylloc === 'undefined') { | ||
lexer.yylloc = {} | ||
} | ||
var yyloc = lexer.yylloc | ||
lstack.push(yyloc) | ||
var ranges = lexer.options && lexer.options.ranges | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError | ||
} | ||
function popStack (n) { | ||
stack.length = stack.length - 2 * n | ||
vstack.length = vstack.length - n | ||
lstack.length = lstack.length - n | ||
} | ||
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] | ||
if (this.defaultActions[state]) { | ||
action = this.defaultActions[state]; | ||
action = this.defaultActions[state] | ||
} else { | ||
if (symbol === null || typeof symbol == 'undefined') { | ||
symbol = lex(); | ||
if (symbol === null || typeof symbol === 'undefined') { | ||
symbol = lex() | ||
} | ||
action = table[state] && table[state][symbol] | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = '' | ||
expected = [] | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\'') | ||
} | ||
action = table[state] && table[state][symbol]; | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'' | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'') | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}) | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = ''; | ||
expected = []; | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\''); | ||
} | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}); | ||
} | ||
if (action[0] instanceof Array && action.length > 1) { | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol) | ||
} | ||
switch (action[0]) { | ||
case 1: | ||
stack.push(symbol); | ||
vstack.push(lexer.yytext); | ||
lstack.push(lexer.yylloc); | ||
stack.push(action[1]); | ||
symbol = null; | ||
case 1: | ||
stack.push(symbol) | ||
vstack.push(lexer.yytext) | ||
lstack.push(lexer.yylloc) | ||
stack.push(action[1]) | ||
symbol = null | ||
if (!preErrorSymbol) { | ||
yyleng = lexer.yyleng; | ||
yytext = lexer.yytext; | ||
yylineno = lexer.yylineno; | ||
yyloc = lexer.yylloc; | ||
if (recovering > 0) { | ||
recovering--; | ||
} | ||
yyleng = lexer.yyleng | ||
yytext = lexer.yytext | ||
yylineno = lexer.yylineno | ||
yyloc = lexer.yylloc | ||
if (recovering > 0) { | ||
recovering-- | ||
} | ||
} else { | ||
symbol = preErrorSymbol; | ||
preErrorSymbol = null; | ||
symbol = preErrorSymbol | ||
preErrorSymbol = null | ||
} | ||
break; | ||
case 2: | ||
len = this.productions_[action[1]][1]; | ||
yyval.$ = vstack[vstack.length - len]; | ||
break | ||
case 2: | ||
len = this.productions_[action[1]][1] | ||
yyval.$ = vstack[vstack.length - len] | ||
yyval._$ = { | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
}; | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
} | ||
if (ranges) { | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
]; | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
] | ||
} | ||
r = this.performAction.apply(yyval, [ | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)); | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)) | ||
if (typeof r !== 'undefined') { | ||
return r; | ||
return r | ||
} | ||
if (len) { | ||
stack = stack.slice(0, -1 * len * 2); | ||
vstack = vstack.slice(0, -1 * len); | ||
lstack = lstack.slice(0, -1 * len); | ||
stack = stack.slice(0, -1 * len * 2) | ||
vstack = vstack.slice(0, -1 * len) | ||
lstack = lstack.slice(0, -1 * len) | ||
} | ||
stack.push(this.productions_[action[1]][0]); | ||
vstack.push(yyval.$); | ||
lstack.push(yyval._$); | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; | ||
stack.push(newState); | ||
break; | ||
case 3: | ||
return true; | ||
stack.push(this.productions_[action[1]][0]) | ||
vstack.push(yyval.$) | ||
lstack.push(yyval._$) | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]] | ||
stack.push(newState) | ||
break | ||
case 3: | ||
return true | ||
} | ||
} | ||
return true; | ||
}}; | ||
} | ||
return true | ||
}} | ||
/* generated by jison-lex 0.3.4 */ | ||
var lexer = (function(){ | ||
var lexer = ({ | ||
var lexer = (function () { | ||
var lexer = ({ | ||
EOF:1, | ||
EOF: 1, | ||
parseError:function parseError(str, hash) { | ||
parseError: function parseError (str, hash) { | ||
if (this.yy.parser) { | ||
this.yy.parser.parseError(str, hash); | ||
this.yy.parser.parseError(str, hash) | ||
} else { | ||
throw new Error(str); | ||
throw new Error(str) | ||
} | ||
}, | ||
}, | ||
// resets the lexer, sets new input | ||
setInput:function (input, yy) { | ||
this.yy = yy || this.yy || {}; | ||
this._input = input; | ||
this._more = this._backtrack = this.done = false; | ||
this.yylineno = this.yyleng = 0; | ||
this.yytext = this.matched = this.match = ''; | ||
this.conditionStack = ['INITIAL']; | ||
setInput: function (input, yy) { | ||
this.yy = yy || this.yy || {} | ||
this._input = input | ||
this._more = this._backtrack = this.done = false | ||
this.yylineno = this.yyleng = 0 | ||
this.yytext = this.matched = this.match = '' | ||
this.conditionStack = ['INITIAL'] | ||
this.yylloc = { | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
}; | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [0,0]; | ||
this.yylloc.range = [0, 0] | ||
} | ||
this.offset = 0; | ||
return this; | ||
}, | ||
this.offset = 0 | ||
return this | ||
}, | ||
// consumes and returns one char from the input | ||
input:function () { | ||
var ch = this._input[0]; | ||
this.yytext += ch; | ||
this.yyleng++; | ||
this.offset++; | ||
this.match += ch; | ||
this.matched += ch; | ||
var lines = ch.match(/(?:\r\n?|\n).*/g); | ||
input: function () { | ||
var ch = this._input[0] | ||
this.yytext += ch | ||
this.yyleng++ | ||
this.offset++ | ||
this.match += ch | ||
this.matched += ch | ||
var lines = ch.match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno++; | ||
this.yylloc.last_line++; | ||
this.yylineno++ | ||
this.yylloc.last_line++ | ||
} else { | ||
this.yylloc.last_column++; | ||
this.yylloc.last_column++ | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range[1]++; | ||
this.yylloc.range[1]++ | ||
} | ||
this._input = this._input.slice(1); | ||
return ch; | ||
}, | ||
this._input = this._input.slice(1) | ||
return ch | ||
}, | ||
// unshifts one char (or a string) into the input | ||
unput:function (ch) { | ||
var len = ch.length; | ||
var lines = ch.split(/(?:\r\n?|\n)/g); | ||
unput: function (ch) { | ||
var len = ch.length | ||
var lines = ch.split(/(?:\r\n?|\n)/g) | ||
this._input = ch + this._input; | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len); | ||
//this.yyleng -= len; | ||
this.offset -= len; | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g); | ||
this.match = this.match.substr(0, this.match.length - 1); | ||
this.matched = this.matched.substr(0, this.matched.length - 1); | ||
this._input = ch + this._input | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len) | ||
// this.yyleng -= len; | ||
this.offset -= len | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g) | ||
this.match = this.match.substr(0, this.match.length - 1) | ||
this.matched = this.matched.substr(0, this.matched.length - 1) | ||
if (lines.length - 1) { | ||
this.yylineno -= lines.length - 1; | ||
this.yylineno -= lines.length - 1 | ||
} | ||
var r = this.yylloc.range; | ||
var r = this.yylloc.range | ||
this.yylloc = { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines ? | ||
(lines.length === oldLines.length ? this.yylloc.first_column : 0) | ||
+ oldLines[oldLines.length - lines.length].length - lines[0].length : | ||
this.yylloc.first_column - len | ||
}; | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines | ||
? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + | ||
oldLines[oldLines.length - lines.length].length - lines[0].length | ||
: this.yylloc.first_column - len | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len]; | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len] | ||
} | ||
this.yyleng = this.yytext.length; | ||
return this; | ||
}, | ||
this.yyleng = this.yytext.length | ||
return this | ||
}, | ||
// When called from action, caches matched text and appends it on next action | ||
more:function () { | ||
this._more = true; | ||
return this; | ||
}, | ||
more: function () { | ||
this._more = true | ||
return this | ||
}, | ||
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. | ||
reject:function () { | ||
reject: function () { | ||
if (this.options.backtrack_lexer) { | ||
this._backtrack = true; | ||
this._backtrack = true | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
return this; | ||
}, | ||
return this | ||
}, | ||
// retain first n characters of the match | ||
less:function (n) { | ||
this.unput(this.match.slice(n)); | ||
}, | ||
less: function (n) { | ||
this.unput(this.match.slice(n)) | ||
}, | ||
// displays already matched input, i.e. for error messages | ||
pastInput:function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length); | ||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); | ||
}, | ||
pastInput: function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length) | ||
return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') | ||
}, | ||
// displays upcoming input, i.e. for error messages | ||
upcomingInput:function () { | ||
var next = this.match; | ||
upcomingInput: function () { | ||
var next = this.match | ||
if (next.length < 20) { | ||
next += this._input.substr(0, 20-next.length); | ||
next += this._input.substr(0, 20 - next.length) | ||
} | ||
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); | ||
}, | ||
return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, '') | ||
}, | ||
// displays the character position where the lexing error occurred, i.e. for error messages | ||
showPosition:function () { | ||
var pre = this.pastInput(); | ||
var c = new Array(pre.length + 1).join("-"); | ||
return pre + this.upcomingInput() + "\n" + c + "^"; | ||
}, | ||
showPosition: function () { | ||
var pre = this.pastInput() | ||
var c = new Array(pre.length + 1).join('-') | ||
return pre + this.upcomingInput() + '\n' + c + '^' | ||
}, | ||
// test the lexed token: return FALSE when not a match, otherwise return token | ||
test_match:function (match, indexed_rule) { | ||
test_match: function (match, indexed_rule) { | ||
var token, | ||
lines, | ||
backup; | ||
lines, | ||
backup | ||
if (this.options.backtrack_lexer) { | ||
// save context | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
}; | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0); | ||
} | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
} | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0) | ||
} | ||
} | ||
lines = match[0].match(/(?:\r\n?|\n).*/g); | ||
lines = match[0].match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno += lines.length; | ||
this.yylineno += lines.length | ||
} | ||
this.yylloc = { | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines ? | ||
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : | ||
this.yylloc.last_column + match[0].length | ||
}; | ||
this.yytext += match[0]; | ||
this.match += match[0]; | ||
this.matches = match; | ||
this.yyleng = this.yytext.length; | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines | ||
? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length | ||
: this.yylloc.last_column + match[0].length | ||
} | ||
this.yytext += match[0] | ||
this.match += match[0] | ||
this.matches = match | ||
this.yyleng = this.yytext.length | ||
if (this.options.ranges) { | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng]; | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng] | ||
} | ||
this._more = false; | ||
this._backtrack = false; | ||
this._input = this._input.slice(match[0].length); | ||
this.matched += match[0]; | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); | ||
this._more = false | ||
this._backtrack = false | ||
this._input = this._input.slice(match[0].length) | ||
this.matched += match[0] | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]) | ||
if (this.done && this._input) { | ||
this.done = false; | ||
this.done = false | ||
} | ||
if (token) { | ||
return token; | ||
return token | ||
} else if (this._backtrack) { | ||
// recover context | ||
for (var k in backup) { | ||
this[k] = backup[k]; | ||
} | ||
return false; // rule action called reject() implying the next rule should be tested instead. | ||
for (var k in backup) { | ||
this[k] = backup[k] | ||
} | ||
return false // rule action called reject() implying the next rule should be tested instead. | ||
} | ||
return false; | ||
}, | ||
return false | ||
}, | ||
// return next match in input | ||
next:function () { | ||
next: function () { | ||
if (this.done) { | ||
return this.EOF; | ||
return this.EOF | ||
} | ||
if (!this._input) { | ||
this.done = true; | ||
this.done = true | ||
} | ||
var token, | ||
match, | ||
tempMatch, | ||
index; | ||
match, | ||
tempMatch, | ||
index | ||
if (!this._more) { | ||
this.yytext = ''; | ||
this.match = ''; | ||
this.yytext = '' | ||
this.match = '' | ||
} | ||
var rules = this._currentRules(); | ||
var rules = this._currentRules() | ||
for (var i = 0; i < rules.length; i++) { | ||
tempMatch = this._input.match(this.rules[rules[i]]); | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch; | ||
index = i; | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]); | ||
if (token !== false) { | ||
return token; | ||
} else if (this._backtrack) { | ||
match = false; | ||
continue; // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
tempMatch = this._input.match(this.rules[rules[i]]) | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch | ||
index = i | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]) | ||
if (token !== false) { | ||
return token | ||
} else if (this._backtrack) { | ||
match = false | ||
continue // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
} | ||
} else if (!this.options.flex) { | ||
break; | ||
} | ||
return false | ||
} | ||
} else if (!this.options.flex) { | ||
break | ||
} | ||
} | ||
} | ||
if (match) { | ||
token = this.test_match(match, rules[index]); | ||
if (token !== false) { | ||
return token; | ||
} | ||
token = this.test_match(match, rules[index]) | ||
if (token !== false) { | ||
return token | ||
} | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
return false | ||
} | ||
if (this._input === "") { | ||
return this.EOF; | ||
if (this._input === '') { | ||
return this.EOF | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
}, | ||
}, | ||
// return next match that has a token | ||
lex:function lex() { | ||
var r = this.next(); | ||
lex: function lex () { | ||
var r = this.next() | ||
if (r) { | ||
return r; | ||
return r | ||
} else { | ||
return this.lex(); | ||
return this.lex() | ||
} | ||
}, | ||
}, | ||
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) | ||
begin:function begin(condition) { | ||
this.conditionStack.push(condition); | ||
}, | ||
begin: function begin (condition) { | ||
this.conditionStack.push(condition) | ||
}, | ||
// pop the previously active lexer condition state off the condition stack | ||
popState:function popState() { | ||
var n = this.conditionStack.length - 1; | ||
popState: function popState () { | ||
var n = this.conditionStack.length - 1 | ||
if (n > 0) { | ||
return this.conditionStack.pop(); | ||
return this.conditionStack.pop() | ||
} else { | ||
return this.conditionStack[0]; | ||
return this.conditionStack[0] | ||
} | ||
}, | ||
}, | ||
// produce the lexer rule set which is active for the currently active lexer condition state | ||
_currentRules:function _currentRules() { | ||
_currentRules: function _currentRules () { | ||
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules | ||
} else { | ||
return this.conditions["INITIAL"].rules; | ||
return this.conditions['INITIAL'].rules | ||
} | ||
}, | ||
}, | ||
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available | ||
topState:function topState(n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0); | ||
topState: function topState (n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0) | ||
if (n >= 0) { | ||
return this.conditionStack[n]; | ||
return this.conditionStack[n] | ||
} else { | ||
return "INITIAL"; | ||
return 'INITIAL' | ||
} | ||
}, | ||
}, | ||
// alias for begin(condition) | ||
pushState:function pushState(condition) { | ||
this.begin(condition); | ||
}, | ||
pushState: function pushState (condition) { | ||
this.begin(condition) | ||
}, | ||
// return the number of states currently on the stack | ||
stateStackSize:function stateStackSize() { | ||
return this.conditionStack.length; | ||
}, | ||
options: {}, | ||
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { | ||
var YYSTATE=YY_START; | ||
switch($avoiding_name_collisions) { | ||
case 0:return 'STYLE'; | ||
break; | ||
case 1:return 'LINKSTYLE'; | ||
break; | ||
case 2:return 'CLASSDEF'; | ||
break; | ||
case 3:return 'CLASS'; | ||
break; | ||
case 4:return 'CLICK'; | ||
break; | ||
case 5:return 12; | ||
break; | ||
case 6:return 13; | ||
break; | ||
case 7:return 47; | ||
break; | ||
case 8:return 35; | ||
break; | ||
case 9:return 36; | ||
break; | ||
case 10:return 'DIR'; | ||
break; | ||
case 11:return 'DIR'; | ||
break; | ||
case 12:return 'DIR'; | ||
break; | ||
case 13:return 'DIR'; | ||
break; | ||
case 14:return 'DIR'; | ||
break; | ||
case 15:return 'DIR'; | ||
break; | ||
case 16:return 17; | ||
break; | ||
case 17:return 23; | ||
break; | ||
case 18:return 18; | ||
break; | ||
case 19:return 28; | ||
break; | ||
case 20:return 40; | ||
break; | ||
case 21:return 32; | ||
break; | ||
case 22:return 21; | ||
break; | ||
case 23:return 22; | ||
break; | ||
case 24:return 'ARROW_CROSS'; | ||
break; | ||
case 25:return 57; | ||
break; | ||
case 26:return 'ARROW_CIRCLE'; | ||
break; | ||
case 27:return 58; | ||
break; | ||
case 28:return 25; | ||
break; | ||
case 29:return 19; | ||
break; | ||
case 30:return 20; | ||
break; | ||
case 31:return 16; | ||
break; | ||
case 32:return 'PIPE'; | ||
break; | ||
case 33:return 'PS'; | ||
break; | ||
case 34:return 'PE'; | ||
break; | ||
case 35:return 37; | ||
break; | ||
case 36:return 39; | ||
break; | ||
case 37:return 8 | ||
break; | ||
case 38:return 10 | ||
break; | ||
case 39:return 'QUOTE'; | ||
break; | ||
case 40:return 24; | ||
break; | ||
case 41:return 'NEWLINE'; | ||
break; | ||
case 42:return 5; | ||
break; | ||
} | ||
}, | ||
rules: [/^(?:style\b)/,/^(?:linkStyle\b)/,/^(?:classDef\b)/,/^(?:class\b)/,/^(?:click\b)/,/^(?:graph\b)/,/^(?:digraph\b)/,/^(?:subgraph\b)/,/^(?:node\b)/,/^(?:edge\b)/,/^(?:LR\b)/,/^(?:RL\b)/,/^(?:TB\b)/,/^(?:BT\b)/,/^(?:TD\b)/,/^(?:BR\b)/,/^(?:[0-9])/,/^(?:#)/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:=)/,/^(?:\*)/,/^(?:\.)/,/^(?:--[x])/,/^(?:->)/,/^(?:--[o])/,/^(?:--)/,/^(?:-)/,/^(?:\+)/,/^(?:=)/,/^(?:[\u0021-\u0027\u002A-\u002E\u003F\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC_])/,/^(?:\|)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:")/,/^(?:\s)/,/^(?:\n)/,/^(?:$)/], | ||
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"inclusive":true}} | ||
}); | ||
return lexer; | ||
})(); | ||
parser.lexer = lexer; | ||
function Parser () { | ||
this.yy = {}; | ||
} | ||
Parser.prototype = parser;parser.Parser = Parser; | ||
return new Parser; | ||
})(); | ||
stateStackSize: function stateStackSize () { | ||
return this.conditionStack.length | ||
}, | ||
options: {}, | ||
performAction: function anonymous (yy, yy_, $avoiding_name_collisions, YY_START) { | ||
var YYSTATE = YY_START | ||
switch ($avoiding_name_collisions) { | ||
case 0:return 'STYLE' | ||
break | ||
case 1:return 'LINKSTYLE' | ||
break | ||
case 2:return 'CLASSDEF' | ||
break | ||
case 3:return 'CLASS' | ||
break | ||
case 4:return 'CLICK' | ||
break | ||
case 5:return 12 | ||
break | ||
case 6:return 13 | ||
break | ||
case 7:return 47 | ||
break | ||
case 8:return 35 | ||
break | ||
case 9:return 36 | ||
break | ||
case 10:return 'DIR' | ||
break | ||
case 11:return 'DIR' | ||
break | ||
case 12:return 'DIR' | ||
break | ||
case 13:return 'DIR' | ||
break | ||
case 14:return 'DIR' | ||
break | ||
case 15:return 'DIR' | ||
break | ||
case 16:return 17 | ||
break | ||
case 17:return 23 | ||
break | ||
case 18:return 18 | ||
break | ||
case 19:return 28 | ||
break | ||
case 20:return 40 | ||
break | ||
case 21:return 32 | ||
break | ||
case 22:return 21 | ||
break | ||
case 23:return 22 | ||
break | ||
case 24:return 'ARROW_CROSS' | ||
break | ||
case 25:return 57 | ||
break | ||
case 26:return 'ARROW_CIRCLE' | ||
break | ||
case 27:return 58 | ||
break | ||
case 28:return 25 | ||
break | ||
case 29:return 19 | ||
break | ||
case 30:return 20 | ||
break | ||
case 31:return 16 | ||
break | ||
case 32:return 'PIPE' | ||
break | ||
case 33:return 'PS' | ||
break | ||
case 34:return 'PE' | ||
break | ||
case 35:return 37 | ||
break | ||
case 36:return 39 | ||
break | ||
case 37:return 8 | ||
break | ||
case 38:return 10 | ||
break | ||
case 39:return 'QUOTE' | ||
break | ||
case 40:return 24 | ||
break | ||
case 41:return 'NEWLINE' | ||
break | ||
case 42:return 5 | ||
break | ||
} | ||
}, | ||
rules: [/^(?:style\b)/, /^(?:linkStyle\b)/, /^(?:classDef\b)/, /^(?:class\b)/, /^(?:click\b)/, /^(?:graph\b)/, /^(?:digraph\b)/, /^(?:subgraph\b)/, /^(?:node\b)/, /^(?:edge\b)/, /^(?:LR\b)/, /^(?:RL\b)/, /^(?:TB\b)/, /^(?:BT\b)/, /^(?:TD\b)/, /^(?:BR\b)/, /^(?:[0-9])/, /^(?:#)/, /^(?::)/, /^(?:;)/, /^(?:,)/, /^(?:=)/, /^(?:\*)/, /^(?:\.)/, /^(?:--[x])/, /^(?:->)/, /^(?:--[o])/, /^(?:--)/, /^(?:-)/, /^(?:\+)/, /^(?:=)/, /^(?:[\u0021-\u0027\u002A-\u002E\u003F\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC_])/, /^(?:\|)/, /^(?:\()/, /^(?:\))/, /^(?:\[)/, /^(?:\])/, /^(?:\{)/, /^(?:\})/, /^(?:")/, /^(?:\s)/, /^(?:\n)/, /^(?:$)/], | ||
conditions: {'INITIAL': {'rules': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42], 'inclusive': true}} | ||
}) | ||
return lexer | ||
})() | ||
parser.lexer = lexer | ||
function Parser () { | ||
this.yy = {} | ||
} | ||
Parser.prototype = parser; parser.Parser = Parser | ||
return new Parser() | ||
})() | ||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') { | ||
exports.parser = parser; | ||
exports.Parser = parser.Parser; | ||
exports.parse = function () { return parser.parse.apply(parser, arguments); }; | ||
exports.main = function commonjsMain(args) { | ||
exports.parser = parser | ||
exports.Parser = parser.Parser | ||
exports.parse = function () { return parser.parse.apply(parser, arguments) } | ||
exports.main = function commonjsMain (args) { | ||
if (!args[1]) { | ||
console.log('Usage: '+args[0]+' FILE'); | ||
process.exit(1); | ||
console.log('Usage: ' + args[0] + ' FILE') | ||
process.exit(1) | ||
} | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); | ||
return exports.parser.parse(source); | ||
}; | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)); | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), 'utf8') | ||
return exports.parser.parse(source) | ||
} | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)) | ||
} | ||
} | ||
} |
@@ -53,3 +53,2 @@ /* parser generated by jison 0.4.17 */ | ||
token location info (@$, _$, etc.): { | ||
@@ -63,3 +62,2 @@ first_line: n, | ||
the parseError function receives a 'hash' object with these members for lexer and parser errors: { | ||
@@ -76,890 +74,887 @@ text: (matched text) | ||
*/ | ||
var parser = (function(){ | ||
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,4],$V1=[1,3],$V2=[1,5],$V3=[1,8,9,10,11,13,18,30,46,71,72,73,74,75,81,86,88,89,91,92,94,95,96,97,98],$V4=[2,2],$V5=[1,12],$V6=[1,13],$V7=[1,14],$V8=[1,15],$V9=[1,31],$Va=[1,33],$Vb=[1,22],$Vc=[1,34],$Vd=[1,24],$Ve=[1,25],$Vf=[1,26],$Vg=[1,27],$Vh=[1,28],$Vi=[1,38],$Vj=[1,40],$Vk=[1,35],$Vl=[1,39],$Vm=[1,45],$Vn=[1,44],$Vo=[1,36],$Vp=[1,37],$Vq=[1,41],$Vr=[1,42],$Vs=[1,43],$Vt=[1,8,9,10,11,13,18,30,32,46,71,72,73,74,75,81,86,88,89,91,92,94,95,96,97,98],$Vu=[1,53],$Vv=[1,52],$Vw=[1,54],$Vx=[1,72],$Vy=[1,80],$Vz=[1,81],$VA=[1,66],$VB=[1,65],$VC=[1,85],$VD=[1,84],$VE=[1,82],$VF=[1,83],$VG=[1,73],$VH=[1,68],$VI=[1,67],$VJ=[1,63],$VK=[1,75],$VL=[1,76],$VM=[1,77],$VN=[1,78],$VO=[1,79],$VP=[1,70],$VQ=[1,69],$VR=[8,9,11],$VS=[8,9,11,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64],$VT=[1,115],$VU=[8,9,10,11,13,15,18,36,38,40,42,46,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,81,86,88,89,91,92,94,95,96,97,98],$VV=[8,9,10,11,12,13,15,16,17,18,30,32,36,37,38,39,40,41,42,43,46,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,71,72,73,74,75,78,81,84,86,88,89,91,92,94,95,96,97,98],$VW=[1,117],$VX=[1,118],$VY=[8,9,10,11,13,18,30,32,46,71,72,73,74,75,81,86,88,89,91,92,94,95,96,97,98],$VZ=[8,9,10,11,12,13,15,16,17,18,30,32,37,39,41,43,46,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,71,72,73,74,75,78,81,84,86,88,89,91,92,94,95,96,97,98],$V_=[13,18,46,81,86,88,89,91,92,94,95,96,97,98],$V$=[13,18,46,49,65,81,86,88,89,91,92,94,95,96,97,98],$V01=[1,191],$V11=[1,188],$V21=[1,195],$V31=[1,192],$V41=[1,189],$V51=[1,196],$V61=[1,186],$V71=[1,187],$V81=[1,190],$V91=[1,193],$Va1=[1,194],$Vb1=[1,213],$Vc1=[8,9,11,86],$Vd1=[8,9,10,11,46,71,80,81,84,86,88,89,90,91,92]; | ||
var parser = {trace: function trace() { }, | ||
yy: {}, | ||
symbols_: {"error":2,"mermaidDoc":3,"graphConfig":4,"document":5,"line":6,"statement":7,"SEMI":8,"NEWLINE":9,"SPACE":10,"EOF":11,"GRAPH":12,"DIR":13,"FirstStmtSeperator":14,"TAGEND":15,"TAGSTART":16,"UP":17,"DOWN":18,"ending":19,"endToken":20,"spaceList":21,"spaceListNewline":22,"verticeStatement":23,"separator":24,"styleStatement":25,"linkStyleStatement":26,"classDefStatement":27,"classStatement":28,"clickStatement":29,"subgraph":30,"text":31,"end":32,"vertex":33,"link":34,"alphaNum":35,"SQS":36,"SQE":37,"PS":38,"PE":39,"(-":40,"-)":41,"DIAMOND_START":42,"DIAMOND_STOP":43,"alphaNumStatement":44,"alphaNumToken":45,"MINUS":46,"linkStatement":47,"arrowText":48,"TESTSTR":49,"--":50,"ARROW_POINT":51,"ARROW_CIRCLE":52,"ARROW_CROSS":53,"ARROW_OPEN":54,"-.":55,"DOTTED_ARROW_POINT":56,"DOTTED_ARROW_CIRCLE":57,"DOTTED_ARROW_CROSS":58,"DOTTED_ARROW_OPEN":59,"==":60,"THICK_ARROW_POINT":61,"THICK_ARROW_CIRCLE":62,"THICK_ARROW_CROSS":63,"THICK_ARROW_OPEN":64,"PIPE":65,"textToken":66,"STR":67,"commentText":68,"commentToken":69,"keywords":70,"STYLE":71,"LINKSTYLE":72,"CLASSDEF":73,"CLASS":74,"CLICK":75,"textNoTags":76,"textNoTagsToken":77,"DEFAULT":78,"stylesOpt":79,"HEX":80,"NUM":81,"INTERPOLATE":82,"commentStatement":83,"PCT":84,"style":85,"COMMA":86,"styleComponent":87,"ALPHA":88,"COLON":89,"UNIT":90,"BRKT":91,"DOT":92,"graphCodeTokens":93,"PUNCTUATION":94,"UNICODE_TEXT":95,"PLUS":96,"EQUALS":97,"MULT":98,"TAG_START":99,"TAG_END":100,"QUOTE":101,"$accept":0,"$end":1}, | ||
terminals_: {2:"error",8:"SEMI",9:"NEWLINE",10:"SPACE",11:"EOF",12:"GRAPH",13:"DIR",15:"TAGEND",16:"TAGSTART",17:"UP",18:"DOWN",30:"subgraph",32:"end",36:"SQS",37:"SQE",38:"PS",39:"PE",40:"(-",41:"-)",42:"DIAMOND_START",43:"DIAMOND_STOP",46:"MINUS",49:"TESTSTR",50:"--",51:"ARROW_POINT",52:"ARROW_CIRCLE",53:"ARROW_CROSS",54:"ARROW_OPEN",55:"-.",56:"DOTTED_ARROW_POINT",57:"DOTTED_ARROW_CIRCLE",58:"DOTTED_ARROW_CROSS",59:"DOTTED_ARROW_OPEN",60:"==",61:"THICK_ARROW_POINT",62:"THICK_ARROW_CIRCLE",63:"THICK_ARROW_CROSS",64:"THICK_ARROW_OPEN",65:"PIPE",67:"STR",71:"STYLE",72:"LINKSTYLE",73:"CLASSDEF",74:"CLASS",75:"CLICK",78:"DEFAULT",80:"HEX",81:"NUM",82:"INTERPOLATE",84:"PCT",86:"COMMA",88:"ALPHA",89:"COLON",90:"UNIT",91:"BRKT",92:"DOT",94:"PUNCTUATION",95:"UNICODE_TEXT",96:"PLUS",97:"EQUALS",98:"MULT",99:"TAG_START",100:"TAG_END",101:"QUOTE"}, | ||
productions_: [0,[3,2],[5,0],[5,2],[6,1],[6,1],[6,1],[6,1],[6,1],[4,2],[4,2],[4,4],[4,4],[4,4],[4,4],[4,4],[19,2],[19,1],[20,1],[20,1],[20,1],[14,1],[14,1],[14,2],[22,2],[22,2],[22,1],[22,1],[21,2],[21,1],[7,2],[7,2],[7,2],[7,2],[7,2],[7,2],[7,5],[7,4],[24,1],[24,1],[24,1],[23,3],[23,1],[33,4],[33,5],[33,6],[33,7],[33,4],[33,5],[33,4],[33,5],[33,4],[33,5],[33,4],[33,5],[33,1],[33,2],[35,1],[35,2],[44,1],[44,1],[44,1],[44,1],[34,2],[34,3],[34,3],[34,1],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[48,3],[31,1],[31,2],[31,1],[68,1],[68,2],[70,1],[70,1],[70,1],[70,1],[70,1],[70,1],[70,1],[70,1],[70,1],[70,1],[70,1],[76,1],[76,2],[27,5],[27,5],[28,5],[29,5],[29,7],[29,5],[29,7],[25,5],[25,5],[26,5],[26,5],[26,9],[26,9],[26,7],[26,7],[83,3],[79,1],[79,3],[85,1],[85,2],[87,1],[87,1],[87,1],[87,1],[87,1],[87,1],[87,1],[87,1],[87,1],[87,1],[87,1],[69,1],[69,1],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[77,1],[77,1],[77,1],[77,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[93,1],[93,1],[93,1],[93,1],[93,1],[93,1],[93,1],[93,1],[93,1],[93,1],[93,1],[93,1],[93,1],[93,1],[93,1]], | ||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
var parser = (function () { | ||
var o = function (k, v, o, l) { for (o = o || {}, l = k.length; l--; o[k[l]] = v);return o }, $V0 = [1, 4], $V1 = [1, 3], $V2 = [1, 5], $V3 = [1, 8, 9, 10, 11, 13, 18, 30, 46, 71, 72, 73, 74, 75, 81, 86, 88, 89, 91, 92, 94, 95, 96, 97, 98], $V4 = [2, 2], $V5 = [1, 12], $V6 = [1, 13], $V7 = [1, 14], $V8 = [1, 15], $V9 = [1, 31], $Va = [1, 33], $Vb = [1, 22], $Vc = [1, 34], $Vd = [1, 24], $Ve = [1, 25], $Vf = [1, 26], $Vg = [1, 27], $Vh = [1, 28], $Vi = [1, 38], $Vj = [1, 40], $Vk = [1, 35], $Vl = [1, 39], $Vm = [1, 45], $Vn = [1, 44], $Vo = [1, 36], $Vp = [1, 37], $Vq = [1, 41], $Vr = [1, 42], $Vs = [1, 43], $Vt = [1, 8, 9, 10, 11, 13, 18, 30, 32, 46, 71, 72, 73, 74, 75, 81, 86, 88, 89, 91, 92, 94, 95, 96, 97, 98], $Vu = [1, 53], $Vv = [1, 52], $Vw = [1, 54], $Vx = [1, 72], $Vy = [1, 80], $Vz = [1, 81], $VA = [1, 66], $VB = [1, 65], $VC = [1, 85], $VD = [1, 84], $VE = [1, 82], $VF = [1, 83], $VG = [1, 73], $VH = [1, 68], $VI = [1, 67], $VJ = [1, 63], $VK = [1, 75], $VL = [1, 76], $VM = [1, 77], $VN = [1, 78], $VO = [1, 79], $VP = [1, 70], $VQ = [1, 69], $VR = [8, 9, 11], $VS = [8, 9, 11, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64], $VT = [1, 115], $VU = [8, 9, 10, 11, 13, 15, 18, 36, 38, 40, 42, 46, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 81, 86, 88, 89, 91, 92, 94, 95, 96, 97, 98], $VV = [8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 30, 32, 36, 37, 38, 39, 40, 41, 42, 43, 46, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 71, 72, 73, 74, 75, 78, 81, 84, 86, 88, 89, 91, 92, 94, 95, 96, 97, 98], $VW = [1, 117], $VX = [1, 118], $VY = [8, 9, 10, 11, 13, 18, 30, 32, 46, 71, 72, 73, 74, 75, 81, 86, 88, 89, 91, 92, 94, 95, 96, 97, 98], $VZ = [8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 30, 32, 37, 39, 41, 43, 46, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 71, 72, 73, 74, 75, 78, 81, 84, 86, 88, 89, 91, 92, 94, 95, 96, 97, 98], $V_ = [13, 18, 46, 81, 86, 88, 89, 91, 92, 94, 95, 96, 97, 98], $V$ = [13, 18, 46, 49, 65, 81, 86, 88, 89, 91, 92, 94, 95, 96, 97, 98], $V01 = [1, 191], $V11 = [1, 188], $V21 = [1, 195], $V31 = [1, 192], $V41 = [1, 189], $V51 = [1, 196], $V61 = [1, 186], $V71 = [1, 187], $V81 = [1, 190], $V91 = [1, 193], $Va1 = [1, 194], $Vb1 = [1, 213], $Vc1 = [8, 9, 11, 86], $Vd1 = [8, 9, 10, 11, 46, 71, 80, 81, 84, 86, 88, 89, 90, 91, 92] | ||
var parser = {trace: function trace () { }, | ||
yy: {}, | ||
symbols_: {'error': 2, 'mermaidDoc': 3, 'graphConfig': 4, 'document': 5, 'line': 6, 'statement': 7, 'SEMI': 8, 'NEWLINE': 9, 'SPACE': 10, 'EOF': 11, 'GRAPH': 12, 'DIR': 13, 'FirstStmtSeperator': 14, 'TAGEND': 15, 'TAGSTART': 16, 'UP': 17, 'DOWN': 18, 'ending': 19, 'endToken': 20, 'spaceList': 21, 'spaceListNewline': 22, 'verticeStatement': 23, 'separator': 24, 'styleStatement': 25, 'linkStyleStatement': 26, 'classDefStatement': 27, 'classStatement': 28, 'clickStatement': 29, 'subgraph': 30, 'text': 31, 'end': 32, 'vertex': 33, 'link': 34, 'alphaNum': 35, 'SQS': 36, 'SQE': 37, 'PS': 38, 'PE': 39, '(-': 40, '-)': 41, 'DIAMOND_START': 42, 'DIAMOND_STOP': 43, 'alphaNumStatement': 44, 'alphaNumToken': 45, 'MINUS': 46, 'linkStatement': 47, 'arrowText': 48, 'TESTSTR': 49, '--': 50, 'ARROW_POINT': 51, 'ARROW_CIRCLE': 52, 'ARROW_CROSS': 53, 'ARROW_OPEN': 54, '-.': 55, 'DOTTED_ARROW_POINT': 56, 'DOTTED_ARROW_CIRCLE': 57, 'DOTTED_ARROW_CROSS': 58, 'DOTTED_ARROW_OPEN': 59, '==': 60, 'THICK_ARROW_POINT': 61, 'THICK_ARROW_CIRCLE': 62, 'THICK_ARROW_CROSS': 63, 'THICK_ARROW_OPEN': 64, 'PIPE': 65, 'textToken': 66, 'STR': 67, 'commentText': 68, 'commentToken': 69, 'keywords': 70, 'STYLE': 71, 'LINKSTYLE': 72, 'CLASSDEF': 73, 'CLASS': 74, 'CLICK': 75, 'textNoTags': 76, 'textNoTagsToken': 77, 'DEFAULT': 78, 'stylesOpt': 79, 'HEX': 80, 'NUM': 81, 'INTERPOLATE': 82, 'commentStatement': 83, 'PCT': 84, 'style': 85, 'COMMA': 86, 'styleComponent': 87, 'ALPHA': 88, 'COLON': 89, 'UNIT': 90, 'BRKT': 91, 'DOT': 92, 'graphCodeTokens': 93, 'PUNCTUATION': 94, 'UNICODE_TEXT': 95, 'PLUS': 96, 'EQUALS': 97, 'MULT': 98, 'TAG_START': 99, 'TAG_END': 100, 'QUOTE': 101, '$accept': 0, '$end': 1}, | ||
terminals_: {2: 'error', 8: 'SEMI', 9: 'NEWLINE', 10: 'SPACE', 11: 'EOF', 12: 'GRAPH', 13: 'DIR', 15: 'TAGEND', 16: 'TAGSTART', 17: 'UP', 18: 'DOWN', 30: 'subgraph', 32: 'end', 36: 'SQS', 37: 'SQE', 38: 'PS', 39: 'PE', 40: '(-', 41: '-)', 42: 'DIAMOND_START', 43: 'DIAMOND_STOP', 46: 'MINUS', 49: 'TESTSTR', 50: '--', 51: 'ARROW_POINT', 52: 'ARROW_CIRCLE', 53: 'ARROW_CROSS', 54: 'ARROW_OPEN', 55: '-.', 56: 'DOTTED_ARROW_POINT', 57: 'DOTTED_ARROW_CIRCLE', 58: 'DOTTED_ARROW_CROSS', 59: 'DOTTED_ARROW_OPEN', 60: '==', 61: 'THICK_ARROW_POINT', 62: 'THICK_ARROW_CIRCLE', 63: 'THICK_ARROW_CROSS', 64: 'THICK_ARROW_OPEN', 65: 'PIPE', 67: 'STR', 71: 'STYLE', 72: 'LINKSTYLE', 73: 'CLASSDEF', 74: 'CLASS', 75: 'CLICK', 78: 'DEFAULT', 80: 'HEX', 81: 'NUM', 82: 'INTERPOLATE', 84: 'PCT', 86: 'COMMA', 88: 'ALPHA', 89: 'COLON', 90: 'UNIT', 91: 'BRKT', 92: 'DOT', 94: 'PUNCTUATION', 95: 'UNICODE_TEXT', 96: 'PLUS', 97: 'EQUALS', 98: 'MULT', 99: 'TAG_START', 100: 'TAG_END', 101: 'QUOTE'}, | ||
productions_: [0, [3, 2], [5, 0], [5, 2], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [4, 2], [4, 2], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [19, 2], [19, 1], [20, 1], [20, 1], [20, 1], [14, 1], [14, 1], [14, 2], [22, 2], [22, 2], [22, 1], [22, 1], [21, 2], [21, 1], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [7, 5], [7, 4], [24, 1], [24, 1], [24, 1], [23, 3], [23, 1], [33, 4], [33, 5], [33, 6], [33, 7], [33, 4], [33, 5], [33, 4], [33, 5], [33, 4], [33, 5], [33, 4], [33, 5], [33, 1], [33, 2], [35, 1], [35, 2], [44, 1], [44, 1], [44, 1], [44, 1], [34, 2], [34, 3], [34, 3], [34, 1], [34, 3], [34, 3], [34, 3], [34, 3], [34, 3], [34, 3], [34, 3], [34, 3], [34, 3], [34, 3], [34, 3], [34, 3], [47, 1], [47, 1], [47, 1], [47, 1], [47, 1], [47, 1], [47, 1], [47, 1], [47, 1], [47, 1], [47, 1], [47, 1], [48, 3], [31, 1], [31, 2], [31, 1], [68, 1], [68, 2], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [76, 1], [76, 2], [27, 5], [27, 5], [28, 5], [29, 5], [29, 7], [29, 5], [29, 7], [25, 5], [25, 5], [26, 5], [26, 5], [26, 9], [26, 9], [26, 7], [26, 7], [83, 3], [79, 1], [79, 3], [85, 1], [85, 2], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [69, 1], [69, 1], [66, 1], [66, 1], [66, 1], [66, 1], [66, 1], [66, 1], [66, 1], [77, 1], [77, 1], [77, 1], [77, 1], [45, 1], [45, 1], [45, 1], [45, 1], [45, 1], [45, 1], [45, 1], [45, 1], [45, 1], [45, 1], [45, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1], [93, 1]], | ||
performAction: function anonymous (yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
/* this == yyval */ | ||
var $0 = $$.length - 1; | ||
switch (yystate) { | ||
case 2: | ||
this.$ = []; | ||
break; | ||
case 3: | ||
var $0 = $$.length - 1 | ||
switch (yystate) { | ||
case 2: | ||
this.$ = [] | ||
break | ||
case 3: | ||
if($$[$0] !== []){ | ||
$$[$0-1].push($$[$0]); | ||
if ($$[$0] !== []) { | ||
$$[$0 - 1].push($$[$0]) | ||
} | ||
this.$=$$[$0-1]; | ||
break; | ||
case 4: case 57: case 59: case 60: case 92: case 94: case 95: case 108: | ||
this.$=$$[$0]; | ||
break; | ||
case 11: | ||
yy.setDirection($$[$0-1]);this.$ = $$[$0-1]; | ||
break; | ||
case 12: | ||
yy.setDirection("LR");this.$ = $$[$0-1]; | ||
break; | ||
case 13: | ||
yy.setDirection("RL");this.$ = $$[$0-1]; | ||
break; | ||
case 14: | ||
yy.setDirection("BT");this.$ = $$[$0-1]; | ||
break; | ||
case 15: | ||
yy.setDirection("TB");this.$ = $$[$0-1]; | ||
break; | ||
case 30: | ||
this.$=$$[$0-1] | ||
break; | ||
case 31: case 32: case 33: case 34: case 35: | ||
this.$=[]; | ||
break; | ||
case 36: | ||
this.$=yy.addSubGraph($$[$0-1],$$[$0-3]); | ||
break; | ||
case 37: | ||
this.$=yy.addSubGraph($$[$0-1],undefined); | ||
break; | ||
case 41: | ||
yy.addLink($$[$0-2],$$[$0],$$[$0-1]);this.$ = [$$[$0-2],$$[$0]]; | ||
break; | ||
case 42: | ||
this.$ = [$$[$0]]; | ||
break; | ||
case 43: | ||
this.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'square'); | ||
break; | ||
case 44: | ||
this.$ = $$[$0-4];yy.addVertex($$[$0-4],$$[$0-2],'square'); | ||
break; | ||
case 45: | ||
this.$ = $$[$0-5];yy.addVertex($$[$0-5],$$[$0-2],'circle'); | ||
break; | ||
case 46: | ||
this.$ = $$[$0-6];yy.addVertex($$[$0-6],$$[$0-3],'circle'); | ||
break; | ||
case 47: | ||
this.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'ellipse'); | ||
break; | ||
case 48: | ||
this.$ = $$[$0-4];yy.addVertex($$[$0-4],$$[$0-2],'ellipse'); | ||
break; | ||
case 49: | ||
this.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'round'); | ||
break; | ||
case 50: | ||
this.$ = $$[$0-4];yy.addVertex($$[$0-4],$$[$0-2],'round'); | ||
break; | ||
case 51: | ||
this.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'diamond'); | ||
break; | ||
case 52: | ||
this.$ = $$[$0-4];yy.addVertex($$[$0-4],$$[$0-2],'diamond'); | ||
break; | ||
case 53: | ||
this.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'odd'); | ||
break; | ||
case 54: | ||
this.$ = $$[$0-4];yy.addVertex($$[$0-4],$$[$0-2],'odd'); | ||
break; | ||
case 55: | ||
this.$ = $$[$0];yy.addVertex($$[$0]); | ||
break; | ||
case 56: | ||
this.$ = $$[$0-1];yy.addVertex($$[$0-1]); | ||
break; | ||
case 58: case 93: case 96: case 109: | ||
this.$=$$[$0-1]+''+$$[$0]; | ||
break; | ||
case 61: | ||
this.$='v'; | ||
break; | ||
case 62: | ||
this.$='-'; | ||
break; | ||
case 63: | ||
$$[$0-1].text = $$[$0];this.$ = $$[$0-1]; | ||
break; | ||
case 64: case 65: | ||
$$[$0-2].text = $$[$0-1];this.$ = $$[$0-2]; | ||
break; | ||
case 66: | ||
this.$ = $$[$0]; | ||
break; | ||
case 67: | ||
this.$ = {"type":"arrow","stroke":"normal","text":$$[$0-1]}; | ||
break; | ||
case 68: | ||
this.$ = {"type":"arrow_circle","stroke":"normal","text":$$[$0-1]}; | ||
break; | ||
case 69: | ||
this.$ = {"type":"arrow_cross","stroke":"normal","text":$$[$0-1]}; | ||
break; | ||
case 70: | ||
this.$ = {"type":"arrow_open","stroke":"normal","text":$$[$0-1]}; | ||
break; | ||
case 71: | ||
this.$ = {"type":"arrow","stroke":"dotted","text":$$[$0-1]}; | ||
break; | ||
case 72: | ||
this.$ = {"type":"arrow_circle","stroke":"dotted","text":$$[$0-1]}; | ||
break; | ||
case 73: | ||
this.$ = {"type":"arrow_cross","stroke":"dotted","text":$$[$0-1]}; | ||
break; | ||
case 74: | ||
this.$ = {"type":"arrow_open","stroke":"dotted","text":$$[$0-1]}; | ||
break; | ||
case 75: | ||
this.$ = {"type":"arrow","stroke":"thick","text":$$[$0-1]}; | ||
break; | ||
case 76: | ||
this.$ = {"type":"arrow_circle","stroke":"thick","text":$$[$0-1]}; | ||
break; | ||
case 77: | ||
this.$ = {"type":"arrow_cross","stroke":"thick","text":$$[$0-1]}; | ||
break; | ||
case 78: | ||
this.$ = {"type":"arrow_open","stroke":"thick","text":$$[$0-1]}; | ||
break; | ||
case 79: | ||
this.$ = {"type":"arrow","stroke":"normal"}; | ||
break; | ||
case 80: | ||
this.$ = {"type":"arrow_circle","stroke":"normal"}; | ||
break; | ||
case 81: | ||
this.$ = {"type":"arrow_cross","stroke":"normal"}; | ||
break; | ||
case 82: | ||
this.$ = {"type":"arrow_open","stroke":"normal"}; | ||
break; | ||
case 83: | ||
this.$ = {"type":"arrow","stroke":"dotted"}; | ||
break; | ||
case 84: | ||
this.$ = {"type":"arrow_circle","stroke":"dotted"}; | ||
break; | ||
case 85: | ||
this.$ = {"type":"arrow_cross","stroke":"dotted"}; | ||
break; | ||
case 86: | ||
this.$ = {"type":"arrow_open","stroke":"dotted"}; | ||
break; | ||
case 87: | ||
this.$ = {"type":"arrow","stroke":"thick"}; | ||
break; | ||
case 88: | ||
this.$ = {"type":"arrow_circle","stroke":"thick"}; | ||
break; | ||
case 89: | ||
this.$ = {"type":"arrow_cross","stroke":"thick"}; | ||
break; | ||
case 90: | ||
this.$ = {"type":"arrow_open","stroke":"thick"}; | ||
break; | ||
case 91: | ||
this.$ = $$[$0-1]; | ||
break; | ||
case 110: case 111: | ||
this.$ = $$[$0-4];yy.addClass($$[$0-2],$$[$0]); | ||
break; | ||
case 112: | ||
this.$ = $$[$0-4];yy.setClass($$[$0-2], $$[$0]); | ||
break; | ||
case 113: | ||
this.$ = $$[$0-4];yy.setClickEvent($$[$0-2], $$[$0], undefined, undefined); | ||
break; | ||
case 114: | ||
this.$ = $$[$0-6];yy.setClickEvent($$[$0-4], $$[$0-2], undefined, $$[$0]) ; | ||
break; | ||
case 115: | ||
this.$ = $$[$0-4];yy.setClickEvent($$[$0-2], undefined, $$[$0], undefined); | ||
break; | ||
case 116: | ||
this.$ = $$[$0-6];yy.setClickEvent($$[$0-4], undefined, $$[$0-2], $$[$0] ); | ||
break; | ||
case 117: | ||
this.$ = $$[$0-4];yy.addVertex($$[$0-2],undefined,undefined,$$[$0]); | ||
break; | ||
case 118: case 119: case 120: | ||
this.$ = $$[$0-4];yy.updateLink($$[$0-2],$$[$0]); | ||
break; | ||
case 121: case 122: | ||
this.$ = $$[$0-8];yy.updateLinkInterpolate($$[$0-6],$$[$0-2]);yy.updateLink($$[$0-6],$$[$0]); | ||
break; | ||
case 123: case 124: | ||
this.$ = $$[$0-6];yy.updateLinkInterpolate($$[$0-4],$$[$0]); | ||
break; | ||
case 126: | ||
this.$ = [$$[$0]] | ||
break; | ||
case 127: | ||
$$[$0-2].push($$[$0]);this.$ = $$[$0-2]; | ||
break; | ||
case 129: | ||
this.$ = $$[$0-1] + $$[$0]; | ||
break; | ||
} | ||
}, | ||
table: [{3:1,4:2,9:$V0,10:$V1,12:$V2},{1:[3]},o($V3,$V4,{5:6}),{4:7,9:$V0,10:$V1,12:$V2},{4:8,9:$V0,10:$V1,12:$V2},{10:[1,9]},{1:[2,1],6:10,7:11,8:$V5,9:$V6,10:$V7,11:$V8,13:$V9,18:$Va,23:16,25:17,26:18,27:19,28:20,29:21,30:$Vb,33:23,35:29,44:30,45:32,46:$Vc,71:$Vd,72:$Ve,73:$Vf,74:$Vg,75:$Vh,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($V3,[2,9]),o($V3,[2,10]),{13:[1,46],15:[1,47],16:[1,48],17:[1,49],18:[1,50]},o($Vt,[2,3]),o($Vt,[2,4]),o($Vt,[2,5]),o($Vt,[2,6]),o($Vt,[2,7]),o($Vt,[2,8]),{8:$Vu,9:$Vv,11:$Vw,24:51},{8:$Vu,9:$Vv,11:$Vw,24:55},{8:$Vu,9:$Vv,11:$Vw,24:56},{8:$Vu,9:$Vv,11:$Vw,24:57},{8:$Vu,9:$Vv,11:$Vw,24:58},{8:$Vu,9:$Vv,11:$Vw,24:59},{8:$Vu,9:$Vv,10:$Vx,11:$Vw,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,24:61,30:$VE,31:60,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($VR,[2,42],{34:86,47:87,50:[1,88],51:[1,91],52:[1,92],53:[1,93],54:[1,94],55:[1,89],56:[1,95],57:[1,96],58:[1,97],59:[1,98],60:[1,90],61:[1,99],62:[1,100],63:[1,101],64:[1,102]}),{10:[1,103]},{10:[1,104]},{10:[1,105]},{10:[1,106]},{10:[1,107]},o($VS,[2,55],{45:32,21:113,44:114,10:$VT,13:$V9,15:[1,112],18:$Va,36:[1,108],38:[1,109],40:[1,110],42:[1,111],46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs}),o($VU,[2,57]),o($VU,[2,59]),o($VU,[2,60]),o($VU,[2,61]),o($VU,[2,62]),o($VV,[2,154]),o($VV,[2,155]),o($VV,[2,156]),o($VV,[2,157]),o($VV,[2,158]),o($VV,[2,159]),o($VV,[2,160]),o($VV,[2,161]),o($VV,[2,162]),o($VV,[2,163]),o($VV,[2,164]),{8:$VW,9:$VX,10:$VT,14:116,21:119},{8:$VW,9:$VX,10:$VT,14:120,21:119},{8:$VW,9:$VX,10:$VT,14:121,21:119},{8:$VW,9:$VX,10:$VT,14:122,21:119},{8:$VW,9:$VX,10:$VT,14:123,21:119},o($Vt,[2,30]),o($Vt,[2,38]),o($Vt,[2,39]),o($Vt,[2,40]),o($Vt,[2,31]),o($Vt,[2,32]),o($Vt,[2,33]),o($Vt,[2,34]),o($Vt,[2,35]),{8:$Vu,9:$Vv,10:$Vx,11:$Vw,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,24:124,30:$VE,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($VY,$V4,{5:126}),o($VZ,[2,92]),o($VZ,[2,94]),o($VZ,[2,143]),o($VZ,[2,144]),o($VZ,[2,145]),o($VZ,[2,146]),o($VZ,[2,147]),o($VZ,[2,148]),o($VZ,[2,149]),o($VZ,[2,150]),o($VZ,[2,151]),o($VZ,[2,152]),o($VZ,[2,153]),o($VZ,[2,97]),o($VZ,[2,98]),o($VZ,[2,99]),o($VZ,[2,100]),o($VZ,[2,101]),o($VZ,[2,102]),o($VZ,[2,103]),o($VZ,[2,104]),o($VZ,[2,105]),o($VZ,[2,106]),o($VZ,[2,107]),{13:$V9,18:$Va,33:127,35:29,44:30,45:32,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($V_,[2,66],{48:128,49:[1,129],65:[1,130]}),{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,31:131,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,31:132,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,31:133,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($V$,[2,79]),o($V$,[2,80]),o($V$,[2,81]),o($V$,[2,82]),o($V$,[2,83]),o($V$,[2,84]),o($V$,[2,85]),o($V$,[2,86]),o($V$,[2,87]),o($V$,[2,88]),o($V$,[2,89]),o($V$,[2,90]),{13:$V9,18:$Va,35:134,44:30,45:32,46:$Vc,80:[1,135],81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{78:[1,136],81:[1,137]},{13:$V9,18:$Va,35:139,44:30,45:32,46:$Vc,78:[1,138],81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{13:$V9,18:$Va,35:140,44:30,45:32,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{13:$V9,18:$Va,35:141,44:30,45:32,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,31:142,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,31:144,32:$VF,38:[1,143],45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,31:145,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,31:146,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,31:147,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($VS,[2,56]),o($VU,[2,58]),o($VS,[2,29],{21:148,10:$VT}),o($V3,[2,11]),o($V3,[2,21]),o($V3,[2,22]),{9:[1,149]},o($V3,[2,12]),o($V3,[2,13]),o($V3,[2,14]),o($V3,[2,15]),o($VY,$V4,{5:150}),o($VZ,[2,93]),{6:10,7:11,8:$V5,9:$V6,10:$V7,11:$V8,13:$V9,18:$Va,23:16,25:17,26:18,27:19,28:20,29:21,30:$Vb,32:[1,151],33:23,35:29,44:30,45:32,46:$Vc,71:$Vd,72:$Ve,73:$Vf,74:$Vg,75:$Vh,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($VR,[2,41]),o($V_,[2,63],{10:[1,152]}),{10:[1,153]},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,31:154,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,32:$VF,45:71,46:$VG,50:$VH,51:[1,155],52:[1,156],53:[1,157],54:[1,158],60:$VI,66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,32:$VF,45:71,46:$VG,50:$VH,56:[1,159],57:[1,160],58:[1,161],59:[1,162],60:$VI,66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,32:$VF,45:71,46:$VG,50:$VH,60:$VI,61:[1,163],62:[1,164],63:[1,165],64:[1,166],66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:[1,167],13:$V9,18:$Va,44:114,45:32,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:[1,168]},{10:[1,169]},{10:[1,170]},{10:[1,171]},{10:[1,172],13:$V9,18:$Va,44:114,45:32,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:[1,173],13:$V9,18:$Va,44:114,45:32,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:[1,174],13:$V9,18:$Va,44:114,45:32,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,32:$VF,37:[1,175],45:71,46:$VG,50:$VH,60:$VI,66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,31:176,32:$VF,45:71,46:$VG,50:$VH,60:$VI,66:62,67:$VJ,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,32:$VF,39:[1,177],45:71,46:$VG,50:$VH,60:$VI,66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,32:$VF,41:[1,178],45:71,46:$VG,50:$VH,60:$VI,66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,32:$VF,43:[1,179],45:71,46:$VG,50:$VH,60:$VI,66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,32:$VF,37:[1,180],45:71,46:$VG,50:$VH,60:$VI,66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($VS,[2,28]),o($V3,[2,23]),{6:10,7:11,8:$V5,9:$V6,10:$V7,11:$V8,13:$V9,18:$Va,23:16,25:17,26:18,27:19,28:20,29:21,30:$Vb,32:[1,181],33:23,35:29,44:30,45:32,46:$Vc,71:$Vd,72:$Ve,73:$Vf,74:$Vg,75:$Vh,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($Vt,[2,37]),o($V_,[2,65]),o($V_,[2,64]),{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,32:$VF,45:71,46:$VG,50:$VH,60:$VI,65:[1,182],66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($V_,[2,67]),o($V_,[2,68]),o($V_,[2,69]),o($V_,[2,70]),o($V_,[2,71]),o($V_,[2,72]),o($V_,[2,73]),o($V_,[2,74]),o($V_,[2,75]),o($V_,[2,76]),o($V_,[2,77]),o($V_,[2,78]),{10:$V01,46:$V11,71:$V21,79:183,80:$V31,81:$V41,84:$V51,85:184,87:185,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1},{10:$V01,46:$V11,71:$V21,79:197,80:$V31,81:$V41,84:$V51,85:184,87:185,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1},{10:$V01,46:$V11,71:$V21,79:198,80:$V31,81:$V41,82:[1,199],84:$V51,85:184,87:185,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1},{10:$V01,46:$V11,71:$V21,79:200,80:$V31,81:$V41,82:[1,201],84:$V51,85:184,87:185,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1},{10:$V01,46:$V11,71:$V21,79:202,80:$V31,81:$V41,84:$V51,85:184,87:185,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1},{10:$V01,46:$V11,71:$V21,79:203,80:$V31,81:$V41,84:$V51,85:184,87:185,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1},{13:$V9,18:$Va,35:204,44:30,45:32,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{13:$V9,18:$Va,35:205,44:30,45:32,46:$Vc,67:[1,206],81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($VS,[2,43],{21:207,10:$VT}),{10:$Vx,12:$Vy,13:$Vz,15:$VA,16:$VB,17:$VC,18:$VD,30:$VE,32:$VF,39:[1,208],45:71,46:$VG,50:$VH,60:$VI,66:125,70:74,71:$VK,72:$VL,73:$VM,74:$VN,75:$VO,77:64,78:$VP,81:$Vi,84:$VQ,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},o($VS,[2,49],{21:209,10:$VT}),o($VS,[2,47],{21:210,10:$VT}),o($VS,[2,51],{21:211,10:$VT}),o($VS,[2,53],{21:212,10:$VT}),o($Vt,[2,36]),o([10,13,18,46,81,86,88,89,91,92,94,95,96,97,98],[2,91]),o($VR,[2,117],{86:$Vb1}),o($Vc1,[2,126],{87:214,10:$V01,46:$V11,71:$V21,80:$V31,81:$V41,84:$V51,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1}),o($Vd1,[2,128]),o($Vd1,[2,130]),o($Vd1,[2,131]),o($Vd1,[2,132]),o($Vd1,[2,133]),o($Vd1,[2,134]),o($Vd1,[2,135]),o($Vd1,[2,136]),o($Vd1,[2,137]),o($Vd1,[2,138]),o($Vd1,[2,139]),o($Vd1,[2,140]),o($VR,[2,118],{86:$Vb1}),o($VR,[2,119],{86:$Vb1}),{10:[1,215]},o($VR,[2,120],{86:$Vb1}),{10:[1,216]},o($VR,[2,110],{86:$Vb1}),o($VR,[2,111],{86:$Vb1}),o($VR,[2,112],{45:32,44:114,13:$V9,18:$Va,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs}),o($VR,[2,113],{45:32,44:114,10:[1,217],13:$V9,18:$Va,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs}),o($VR,[2,115],{10:[1,218]}),o($VS,[2,44]),{39:[1,219]},o($VS,[2,50]),o($VS,[2,48]),o($VS,[2,52]),o($VS,[2,54]),{10:$V01,46:$V11,71:$V21,80:$V31,81:$V41,84:$V51,85:220,87:185,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1},o($Vd1,[2,129]),{13:$V9,18:$Va,35:221,44:30,45:32,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{13:$V9,18:$Va,35:222,44:30,45:32,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs},{67:[1,223]},{67:[1,224]},o($VS,[2,45],{21:225,10:$VT}),o($Vc1,[2,127],{87:214,10:$V01,46:$V11,71:$V21,80:$V31,81:$V41,84:$V51,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1}),o($VR,[2,123],{45:32,44:114,10:[1,226],13:$V9,18:$Va,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs}),o($VR,[2,124],{45:32,44:114,10:[1,227],13:$V9,18:$Va,46:$Vc,81:$Vi,86:$Vj,88:$Vk,89:$Vl,91:$Vm,92:$Vn,94:$Vo,95:$Vp,96:$Vq,97:$Vr,98:$Vs}),o($VR,[2,114]),o($VR,[2,116]),o($VS,[2,46]),{10:$V01,46:$V11,71:$V21,79:228,80:$V31,81:$V41,84:$V51,85:184,87:185,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1},{10:$V01,46:$V11,71:$V21,79:229,80:$V31,81:$V41,84:$V51,85:184,87:185,88:$V61,89:$V71,90:$V81,91:$V91,92:$Va1},o($VR,[2,121],{86:$Vb1}),o($VR,[2,122],{86:$Vb1})], | ||
defaultActions: {}, | ||
parseError: function parseError(str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str); | ||
} else { | ||
this.$ = $$[$0 - 1] | ||
break | ||
case 4: case 57: case 59: case 60: case 92: case 94: case 95: case 108: | ||
this.$ = $$[$0] | ||
break | ||
case 11: | ||
yy.setDirection($$[$0 - 1]); this.$ = $$[$0 - 1] | ||
break | ||
case 12: | ||
yy.setDirection('LR'); this.$ = $$[$0 - 1] | ||
break | ||
case 13: | ||
yy.setDirection('RL'); this.$ = $$[$0 - 1] | ||
break | ||
case 14: | ||
yy.setDirection('BT'); this.$ = $$[$0 - 1] | ||
break | ||
case 15: | ||
yy.setDirection('TB'); this.$ = $$[$0 - 1] | ||
break | ||
case 30: | ||
this.$ = $$[$0 - 1] | ||
break | ||
case 31: case 32: case 33: case 34: case 35: | ||
this.$ = [] | ||
break | ||
case 36: | ||
this.$ = yy.addSubGraph($$[$0 - 1], $$[$0 - 3]) | ||
break | ||
case 37: | ||
this.$ = yy.addSubGraph($$[$0 - 1], undefined) | ||
break | ||
case 41: | ||
yy.addLink($$[$0 - 2], $$[$0], $$[$0 - 1]); this.$ = [$$[$0 - 2], $$[$0]] | ||
break | ||
case 42: | ||
this.$ = [$$[$0]] | ||
break | ||
case 43: | ||
this.$ = $$[$0 - 3]; yy.addVertex($$[$0 - 3], $$[$0 - 1], 'square') | ||
break | ||
case 44: | ||
this.$ = $$[$0 - 4]; yy.addVertex($$[$0 - 4], $$[$0 - 2], 'square') | ||
break | ||
case 45: | ||
this.$ = $$[$0 - 5]; yy.addVertex($$[$0 - 5], $$[$0 - 2], 'circle') | ||
break | ||
case 46: | ||
this.$ = $$[$0 - 6]; yy.addVertex($$[$0 - 6], $$[$0 - 3], 'circle') | ||
break | ||
case 47: | ||
this.$ = $$[$0 - 3]; yy.addVertex($$[$0 - 3], $$[$0 - 1], 'ellipse') | ||
break | ||
case 48: | ||
this.$ = $$[$0 - 4]; yy.addVertex($$[$0 - 4], $$[$0 - 2], 'ellipse') | ||
break | ||
case 49: | ||
this.$ = $$[$0 - 3]; yy.addVertex($$[$0 - 3], $$[$0 - 1], 'round') | ||
break | ||
case 50: | ||
this.$ = $$[$0 - 4]; yy.addVertex($$[$0 - 4], $$[$0 - 2], 'round') | ||
break | ||
case 51: | ||
this.$ = $$[$0 - 3]; yy.addVertex($$[$0 - 3], $$[$0 - 1], 'diamond') | ||
break | ||
case 52: | ||
this.$ = $$[$0 - 4]; yy.addVertex($$[$0 - 4], $$[$0 - 2], 'diamond') | ||
break | ||
case 53: | ||
this.$ = $$[$0 - 3]; yy.addVertex($$[$0 - 3], $$[$0 - 1], 'odd') | ||
break | ||
case 54: | ||
this.$ = $$[$0 - 4]; yy.addVertex($$[$0 - 4], $$[$0 - 2], 'odd') | ||
break | ||
case 55: | ||
this.$ = $$[$0]; yy.addVertex($$[$0]) | ||
break | ||
case 56: | ||
this.$ = $$[$0 - 1]; yy.addVertex($$[$0 - 1]) | ||
break | ||
case 58: case 93: case 96: case 109: | ||
this.$ = $$[$0 - 1] + '' + $$[$0] | ||
break | ||
case 61: | ||
this.$ = 'v' | ||
break | ||
case 62: | ||
this.$ = '-' | ||
break | ||
case 63: | ||
$$[$0 - 1].text = $$[$0]; this.$ = $$[$0 - 1] | ||
break | ||
case 64: case 65: | ||
$$[$0 - 2].text = $$[$0 - 1]; this.$ = $$[$0 - 2] | ||
break | ||
case 66: | ||
this.$ = $$[$0] | ||
break | ||
case 67: | ||
this.$ = {'type': 'arrow', 'stroke': 'normal', 'text': $$[$0 - 1]} | ||
break | ||
case 68: | ||
this.$ = {'type': 'arrow_circle', 'stroke': 'normal', 'text': $$[$0 - 1]} | ||
break | ||
case 69: | ||
this.$ = {'type': 'arrow_cross', 'stroke': 'normal', 'text': $$[$0 - 1]} | ||
break | ||
case 70: | ||
this.$ = {'type': 'arrow_open', 'stroke': 'normal', 'text': $$[$0 - 1]} | ||
break | ||
case 71: | ||
this.$ = {'type': 'arrow', 'stroke': 'dotted', 'text': $$[$0 - 1]} | ||
break | ||
case 72: | ||
this.$ = {'type': 'arrow_circle', 'stroke': 'dotted', 'text': $$[$0 - 1]} | ||
break | ||
case 73: | ||
this.$ = {'type': 'arrow_cross', 'stroke': 'dotted', 'text': $$[$0 - 1]} | ||
break | ||
case 74: | ||
this.$ = {'type': 'arrow_open', 'stroke': 'dotted', 'text': $$[$0 - 1]} | ||
break | ||
case 75: | ||
this.$ = {'type': 'arrow', 'stroke': 'thick', 'text': $$[$0 - 1]} | ||
break | ||
case 76: | ||
this.$ = {'type': 'arrow_circle', 'stroke': 'thick', 'text': $$[$0 - 1]} | ||
break | ||
case 77: | ||
this.$ = {'type': 'arrow_cross', 'stroke': 'thick', 'text': $$[$0 - 1]} | ||
break | ||
case 78: | ||
this.$ = {'type': 'arrow_open', 'stroke': 'thick', 'text': $$[$0 - 1]} | ||
break | ||
case 79: | ||
this.$ = {'type': 'arrow', 'stroke': 'normal'} | ||
break | ||
case 80: | ||
this.$ = {'type': 'arrow_circle', 'stroke': 'normal'} | ||
break | ||
case 81: | ||
this.$ = {'type': 'arrow_cross', 'stroke': 'normal'} | ||
break | ||
case 82: | ||
this.$ = {'type': 'arrow_open', 'stroke': 'normal'} | ||
break | ||
case 83: | ||
this.$ = {'type': 'arrow', 'stroke': 'dotted'} | ||
break | ||
case 84: | ||
this.$ = {'type': 'arrow_circle', 'stroke': 'dotted'} | ||
break | ||
case 85: | ||
this.$ = {'type': 'arrow_cross', 'stroke': 'dotted'} | ||
break | ||
case 86: | ||
this.$ = {'type': 'arrow_open', 'stroke': 'dotted'} | ||
break | ||
case 87: | ||
this.$ = {'type': 'arrow', 'stroke': 'thick'} | ||
break | ||
case 88: | ||
this.$ = {'type': 'arrow_circle', 'stroke': 'thick'} | ||
break | ||
case 89: | ||
this.$ = {'type': 'arrow_cross', 'stroke': 'thick'} | ||
break | ||
case 90: | ||
this.$ = {'type': 'arrow_open', 'stroke': 'thick'} | ||
break | ||
case 91: | ||
this.$ = $$[$0 - 1] | ||
break | ||
case 110: case 111: | ||
this.$ = $$[$0 - 4]; yy.addClass($$[$0 - 2], $$[$0]) | ||
break | ||
case 112: | ||
this.$ = $$[$0 - 4]; yy.setClass($$[$0 - 2], $$[$0]) | ||
break | ||
case 113: | ||
this.$ = $$[$0 - 4]; yy.setClickEvent($$[$0 - 2], $$[$0], undefined, undefined) | ||
break | ||
case 114: | ||
this.$ = $$[$0 - 6]; yy.setClickEvent($$[$0 - 4], $$[$0 - 2], undefined, $$[$0]) | ||
break | ||
case 115: | ||
this.$ = $$[$0 - 4]; yy.setClickEvent($$[$0 - 2], undefined, $$[$0], undefined) | ||
break | ||
case 116: | ||
this.$ = $$[$0 - 6]; yy.setClickEvent($$[$0 - 4], undefined, $$[$0 - 2], $$[$0]) | ||
break | ||
case 117: | ||
this.$ = $$[$0 - 4]; yy.addVertex($$[$0 - 2], undefined, undefined, $$[$0]) | ||
break | ||
case 118: case 119: case 120: | ||
this.$ = $$[$0 - 4]; yy.updateLink($$[$0 - 2], $$[$0]) | ||
break | ||
case 121: case 122: | ||
this.$ = $$[$0 - 8]; yy.updateLinkInterpolate($$[$0 - 6], $$[$0 - 2]); yy.updateLink($$[$0 - 6], $$[$0]) | ||
break | ||
case 123: case 124: | ||
this.$ = $$[$0 - 6]; yy.updateLinkInterpolate($$[$0 - 4], $$[$0]) | ||
break | ||
case 126: | ||
this.$ = [$$[$0]] | ||
break | ||
case 127: | ||
$$[$0 - 2].push($$[$0]); this.$ = $$[$0 - 2] | ||
break | ||
case 129: | ||
this.$ = $$[$0 - 1] + $$[$0] | ||
break | ||
} | ||
}, | ||
table: [{3: 1, 4: 2, 9: $V0, 10: $V1, 12: $V2}, {1: [3]}, o($V3, $V4, {5: 6}), {4: 7, 9: $V0, 10: $V1, 12: $V2}, {4: 8, 9: $V0, 10: $V1, 12: $V2}, {10: [1, 9]}, {1: [2, 1], 6: 10, 7: 11, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 13: $V9, 18: $Va, 23: 16, 25: 17, 26: 18, 27: 19, 28: 20, 29: 21, 30: $Vb, 33: 23, 35: 29, 44: 30, 45: 32, 46: $Vc, 71: $Vd, 72: $Ve, 73: $Vf, 74: $Vg, 75: $Vh, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($V3, [2, 9]), o($V3, [2, 10]), {13: [1, 46], 15: [1, 47], 16: [1, 48], 17: [1, 49], 18: [1, 50]}, o($Vt, [2, 3]), o($Vt, [2, 4]), o($Vt, [2, 5]), o($Vt, [2, 6]), o($Vt, [2, 7]), o($Vt, [2, 8]), {8: $Vu, 9: $Vv, 11: $Vw, 24: 51}, {8: $Vu, 9: $Vv, 11: $Vw, 24: 55}, {8: $Vu, 9: $Vv, 11: $Vw, 24: 56}, {8: $Vu, 9: $Vv, 11: $Vw, 24: 57}, {8: $Vu, 9: $Vv, 11: $Vw, 24: 58}, {8: $Vu, 9: $Vv, 11: $Vw, 24: 59}, {8: $Vu, 9: $Vv, 10: $Vx, 11: $Vw, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 24: 61, 30: $VE, 31: 60, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($VR, [2, 42], {34: 86, 47: 87, 50: [1, 88], 51: [1, 91], 52: [1, 92], 53: [1, 93], 54: [1, 94], 55: [1, 89], 56: [1, 95], 57: [1, 96], 58: [1, 97], 59: [1, 98], 60: [1, 90], 61: [1, 99], 62: [1, 100], 63: [1, 101], 64: [1, 102]}), {10: [1, 103]}, {10: [1, 104]}, {10: [1, 105]}, {10: [1, 106]}, {10: [1, 107]}, o($VS, [2, 55], {45: 32, 21: 113, 44: 114, 10: $VT, 13: $V9, 15: [1, 112], 18: $Va, 36: [1, 108], 38: [1, 109], 40: [1, 110], 42: [1, 111], 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}), o($VU, [2, 57]), o($VU, [2, 59]), o($VU, [2, 60]), o($VU, [2, 61]), o($VU, [2, 62]), o($VV, [2, 154]), o($VV, [2, 155]), o($VV, [2, 156]), o($VV, [2, 157]), o($VV, [2, 158]), o($VV, [2, 159]), o($VV, [2, 160]), o($VV, [2, 161]), o($VV, [2, 162]), o($VV, [2, 163]), o($VV, [2, 164]), {8: $VW, 9: $VX, 10: $VT, 14: 116, 21: 119}, {8: $VW, 9: $VX, 10: $VT, 14: 120, 21: 119}, {8: $VW, 9: $VX, 10: $VT, 14: 121, 21: 119}, {8: $VW, 9: $VX, 10: $VT, 14: 122, 21: 119}, {8: $VW, 9: $VX, 10: $VT, 14: 123, 21: 119}, o($Vt, [2, 30]), o($Vt, [2, 38]), o($Vt, [2, 39]), o($Vt, [2, 40]), o($Vt, [2, 31]), o($Vt, [2, 32]), o($Vt, [2, 33]), o($Vt, [2, 34]), o($Vt, [2, 35]), {8: $Vu, 9: $Vv, 10: $Vx, 11: $Vw, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 24: 124, 30: $VE, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($VY, $V4, {5: 126}), o($VZ, [2, 92]), o($VZ, [2, 94]), o($VZ, [2, 143]), o($VZ, [2, 144]), o($VZ, [2, 145]), o($VZ, [2, 146]), o($VZ, [2, 147]), o($VZ, [2, 148]), o($VZ, [2, 149]), o($VZ, [2, 150]), o($VZ, [2, 151]), o($VZ, [2, 152]), o($VZ, [2, 153]), o($VZ, [2, 97]), o($VZ, [2, 98]), o($VZ, [2, 99]), o($VZ, [2, 100]), o($VZ, [2, 101]), o($VZ, [2, 102]), o($VZ, [2, 103]), o($VZ, [2, 104]), o($VZ, [2, 105]), o($VZ, [2, 106]), o($VZ, [2, 107]), {13: $V9, 18: $Va, 33: 127, 35: 29, 44: 30, 45: 32, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($V_, [2, 66], {48: 128, 49: [1, 129], 65: [1, 130]}), {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 31: 131, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 31: 132, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 31: 133, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($V$, [2, 79]), o($V$, [2, 80]), o($V$, [2, 81]), o($V$, [2, 82]), o($V$, [2, 83]), o($V$, [2, 84]), o($V$, [2, 85]), o($V$, [2, 86]), o($V$, [2, 87]), o($V$, [2, 88]), o($V$, [2, 89]), o($V$, [2, 90]), {13: $V9, 18: $Va, 35: 134, 44: 30, 45: 32, 46: $Vc, 80: [1, 135], 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {78: [1, 136], 81: [1, 137]}, {13: $V9, 18: $Va, 35: 139, 44: 30, 45: 32, 46: $Vc, 78: [1, 138], 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {13: $V9, 18: $Va, 35: 140, 44: 30, 45: 32, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {13: $V9, 18: $Va, 35: 141, 44: 30, 45: 32, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 31: 142, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 31: 144, 32: $VF, 38: [1, 143], 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 31: 145, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 31: 146, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 31: 147, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($VS, [2, 56]), o($VU, [2, 58]), o($VS, [2, 29], {21: 148, 10: $VT}), o($V3, [2, 11]), o($V3, [2, 21]), o($V3, [2, 22]), {9: [1, 149]}, o($V3, [2, 12]), o($V3, [2, 13]), o($V3, [2, 14]), o($V3, [2, 15]), o($VY, $V4, {5: 150}), o($VZ, [2, 93]), {6: 10, 7: 11, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 13: $V9, 18: $Va, 23: 16, 25: 17, 26: 18, 27: 19, 28: 20, 29: 21, 30: $Vb, 32: [1, 151], 33: 23, 35: 29, 44: 30, 45: 32, 46: $Vc, 71: $Vd, 72: $Ve, 73: $Vf, 74: $Vg, 75: $Vh, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($VR, [2, 41]), o($V_, [2, 63], {10: [1, 152]}), {10: [1, 153]}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 31: 154, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 32: $VF, 45: 71, 46: $VG, 50: $VH, 51: [1, 155], 52: [1, 156], 53: [1, 157], 54: [1, 158], 60: $VI, 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 32: $VF, 45: 71, 46: $VG, 50: $VH, 56: [1, 159], 57: [1, 160], 58: [1, 161], 59: [1, 162], 60: $VI, 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 61: [1, 163], 62: [1, 164], 63: [1, 165], 64: [1, 166], 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: [1, 167], 13: $V9, 18: $Va, 44: 114, 45: 32, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: [1, 168]}, {10: [1, 169]}, {10: [1, 170]}, {10: [1, 171]}, {10: [1, 172], 13: $V9, 18: $Va, 44: 114, 45: 32, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: [1, 173], 13: $V9, 18: $Va, 44: 114, 45: 32, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: [1, 174], 13: $V9, 18: $Va, 44: 114, 45: 32, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 32: $VF, 37: [1, 175], 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 31: 176, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 62, 67: $VJ, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 32: $VF, 39: [1, 177], 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 32: $VF, 41: [1, 178], 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 32: $VF, 43: [1, 179], 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 32: $VF, 37: [1, 180], 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($VS, [2, 28]), o($V3, [2, 23]), {6: 10, 7: 11, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 13: $V9, 18: $Va, 23: 16, 25: 17, 26: 18, 27: 19, 28: 20, 29: 21, 30: $Vb, 32: [1, 181], 33: 23, 35: 29, 44: 30, 45: 32, 46: $Vc, 71: $Vd, 72: $Ve, 73: $Vf, 74: $Vg, 75: $Vh, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($Vt, [2, 37]), o($V_, [2, 65]), o($V_, [2, 64]), {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 32: $VF, 45: 71, 46: $VG, 50: $VH, 60: $VI, 65: [1, 182], 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($V_, [2, 67]), o($V_, [2, 68]), o($V_, [2, 69]), o($V_, [2, 70]), o($V_, [2, 71]), o($V_, [2, 72]), o($V_, [2, 73]), o($V_, [2, 74]), o($V_, [2, 75]), o($V_, [2, 76]), o($V_, [2, 77]), o($V_, [2, 78]), {10: $V01, 46: $V11, 71: $V21, 79: 183, 80: $V31, 81: $V41, 84: $V51, 85: 184, 87: 185, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}, {10: $V01, 46: $V11, 71: $V21, 79: 197, 80: $V31, 81: $V41, 84: $V51, 85: 184, 87: 185, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}, {10: $V01, 46: $V11, 71: $V21, 79: 198, 80: $V31, 81: $V41, 82: [1, 199], 84: $V51, 85: 184, 87: 185, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}, {10: $V01, 46: $V11, 71: $V21, 79: 200, 80: $V31, 81: $V41, 82: [1, 201], 84: $V51, 85: 184, 87: 185, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}, {10: $V01, 46: $V11, 71: $V21, 79: 202, 80: $V31, 81: $V41, 84: $V51, 85: 184, 87: 185, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}, {10: $V01, 46: $V11, 71: $V21, 79: 203, 80: $V31, 81: $V41, 84: $V51, 85: 184, 87: 185, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}, {13: $V9, 18: $Va, 35: 204, 44: 30, 45: 32, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {13: $V9, 18: $Va, 35: 205, 44: 30, 45: 32, 46: $Vc, 67: [1, 206], 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($VS, [2, 43], {21: 207, 10: $VT}), {10: $Vx, 12: $Vy, 13: $Vz, 15: $VA, 16: $VB, 17: $VC, 18: $VD, 30: $VE, 32: $VF, 39: [1, 208], 45: 71, 46: $VG, 50: $VH, 60: $VI, 66: 125, 70: 74, 71: $VK, 72: $VL, 73: $VM, 74: $VN, 75: $VO, 77: 64, 78: $VP, 81: $Vi, 84: $VQ, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, o($VS, [2, 49], {21: 209, 10: $VT}), o($VS, [2, 47], {21: 210, 10: $VT}), o($VS, [2, 51], {21: 211, 10: $VT}), o($VS, [2, 53], {21: 212, 10: $VT}), o($Vt, [2, 36]), o([10, 13, 18, 46, 81, 86, 88, 89, 91, 92, 94, 95, 96, 97, 98], [2, 91]), o($VR, [2, 117], {86: $Vb1}), o($Vc1, [2, 126], {87: 214, 10: $V01, 46: $V11, 71: $V21, 80: $V31, 81: $V41, 84: $V51, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}), o($Vd1, [2, 128]), o($Vd1, [2, 130]), o($Vd1, [2, 131]), o($Vd1, [2, 132]), o($Vd1, [2, 133]), o($Vd1, [2, 134]), o($Vd1, [2, 135]), o($Vd1, [2, 136]), o($Vd1, [2, 137]), o($Vd1, [2, 138]), o($Vd1, [2, 139]), o($Vd1, [2, 140]), o($VR, [2, 118], {86: $Vb1}), o($VR, [2, 119], {86: $Vb1}), {10: [1, 215]}, o($VR, [2, 120], {86: $Vb1}), {10: [1, 216]}, o($VR, [2, 110], {86: $Vb1}), o($VR, [2, 111], {86: $Vb1}), o($VR, [2, 112], {45: 32, 44: 114, 13: $V9, 18: $Va, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}), o($VR, [2, 113], {45: 32, 44: 114, 10: [1, 217], 13: $V9, 18: $Va, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}), o($VR, [2, 115], {10: [1, 218]}), o($VS, [2, 44]), {39: [1, 219]}, o($VS, [2, 50]), o($VS, [2, 48]), o($VS, [2, 52]), o($VS, [2, 54]), {10: $V01, 46: $V11, 71: $V21, 80: $V31, 81: $V41, 84: $V51, 85: 220, 87: 185, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}, o($Vd1, [2, 129]), {13: $V9, 18: $Va, 35: 221, 44: 30, 45: 32, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {13: $V9, 18: $Va, 35: 222, 44: 30, 45: 32, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}, {67: [1, 223]}, {67: [1, 224]}, o($VS, [2, 45], {21: 225, 10: $VT}), o($Vc1, [2, 127], {87: 214, 10: $V01, 46: $V11, 71: $V21, 80: $V31, 81: $V41, 84: $V51, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}), o($VR, [2, 123], {45: 32, 44: 114, 10: [1, 226], 13: $V9, 18: $Va, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}), o($VR, [2, 124], {45: 32, 44: 114, 10: [1, 227], 13: $V9, 18: $Va, 46: $Vc, 81: $Vi, 86: $Vj, 88: $Vk, 89: $Vl, 91: $Vm, 92: $Vn, 94: $Vo, 95: $Vp, 96: $Vq, 97: $Vr, 98: $Vs}), o($VR, [2, 114]), o($VR, [2, 116]), o($VS, [2, 46]), {10: $V01, 46: $V11, 71: $V21, 79: 228, 80: $V31, 81: $V41, 84: $V51, 85: 184, 87: 185, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}, {10: $V01, 46: $V11, 71: $V21, 79: 229, 80: $V31, 81: $V41, 84: $V51, 85: 184, 87: 185, 88: $V61, 89: $V71, 90: $V81, 91: $V91, 92: $Va1}, o($VR, [2, 121], {86: $Vb1}), o($VR, [2, 122], {86: $Vb1})], | ||
defaultActions: {}, | ||
parseError: function parseError (str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str) | ||
} else { | ||
function _parseError (msg, hash) { | ||
this.message = msg; | ||
this.hash = hash; | ||
this.message = msg | ||
this.hash = hash | ||
} | ||
_parseError.prototype = Error; | ||
_parseError.prototype = Error | ||
throw new _parseError(str, hash); | ||
} | ||
}, | ||
parse: function parse(input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; | ||
var args = lstack.slice.call(arguments, 1); | ||
var lexer = Object.create(this.lexer); | ||
var sharedState = { yy: {} }; | ||
for (var k in this.yy) { | ||
throw new _parseError(str, hash) | ||
} | ||
}, | ||
parse: function parse (input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1 | ||
var args = lstack.slice.call(arguments, 1) | ||
var lexer = Object.create(this.lexer) | ||
var sharedState = { yy: {} } | ||
for (var k in this.yy) { | ||
if (Object.prototype.hasOwnProperty.call(this.yy, k)) { | ||
sharedState.yy[k] = this.yy[k]; | ||
sharedState.yy[k] = this.yy[k] | ||
} | ||
} | ||
lexer.setInput(input, sharedState.yy); | ||
sharedState.yy.lexer = lexer; | ||
sharedState.yy.parser = this; | ||
if (typeof lexer.yylloc == 'undefined') { | ||
lexer.yylloc = {}; | ||
} | ||
var yyloc = lexer.yylloc; | ||
lstack.push(yyloc); | ||
var ranges = lexer.options && lexer.options.ranges; | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError; | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError; | ||
} | ||
function popStack(n) { | ||
stack.length = stack.length - 2 * n; | ||
vstack.length = vstack.length - n; | ||
lstack.length = lstack.length - n; | ||
} | ||
_token_stack: | ||
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]; | ||
} | ||
lexer.setInput(input, sharedState.yy) | ||
sharedState.yy.lexer = lexer | ||
sharedState.yy.parser = this | ||
if (typeof lexer.yylloc === 'undefined') { | ||
lexer.yylloc = {} | ||
} | ||
var yyloc = lexer.yylloc | ||
lstack.push(yyloc) | ||
var ranges = lexer.options && lexer.options.ranges | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError | ||
} | ||
function popStack (n) { | ||
stack.length = stack.length - 2 * n | ||
vstack.length = vstack.length - n | ||
lstack.length = lstack.length - n | ||
} | ||
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] | ||
if (this.defaultActions[state]) { | ||
action = this.defaultActions[state]; | ||
action = this.defaultActions[state] | ||
} else { | ||
if (symbol === null || typeof symbol == 'undefined') { | ||
symbol = lex(); | ||
if (symbol === null || typeof symbol === 'undefined') { | ||
symbol = lex() | ||
} | ||
action = table[state] && table[state][symbol] | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = '' | ||
expected = [] | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\'') | ||
} | ||
action = table[state] && table[state][symbol]; | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'' | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'') | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}) | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = ''; | ||
expected = []; | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\''); | ||
} | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}); | ||
} | ||
if (action[0] instanceof Array && action.length > 1) { | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol) | ||
} | ||
switch (action[0]) { | ||
case 1: | ||
stack.push(symbol); | ||
vstack.push(lexer.yytext); | ||
lstack.push(lexer.yylloc); | ||
stack.push(action[1]); | ||
symbol = null; | ||
case 1: | ||
stack.push(symbol) | ||
vstack.push(lexer.yytext) | ||
lstack.push(lexer.yylloc) | ||
stack.push(action[1]) | ||
symbol = null | ||
if (!preErrorSymbol) { | ||
yyleng = lexer.yyleng; | ||
yytext = lexer.yytext; | ||
yylineno = lexer.yylineno; | ||
yyloc = lexer.yylloc; | ||
if (recovering > 0) { | ||
recovering--; | ||
} | ||
yyleng = lexer.yyleng | ||
yytext = lexer.yytext | ||
yylineno = lexer.yylineno | ||
yyloc = lexer.yylloc | ||
if (recovering > 0) { | ||
recovering-- | ||
} | ||
} else { | ||
symbol = preErrorSymbol; | ||
preErrorSymbol = null; | ||
symbol = preErrorSymbol | ||
preErrorSymbol = null | ||
} | ||
break; | ||
case 2: | ||
len = this.productions_[action[1]][1]; | ||
yyval.$ = vstack[vstack.length - len]; | ||
break | ||
case 2: | ||
len = this.productions_[action[1]][1] | ||
yyval.$ = vstack[vstack.length - len] | ||
yyval._$ = { | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
}; | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
} | ||
if (ranges) { | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
]; | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
] | ||
} | ||
r = this.performAction.apply(yyval, [ | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)); | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)) | ||
if (typeof r !== 'undefined') { | ||
return r; | ||
return r | ||
} | ||
if (len) { | ||
stack = stack.slice(0, -1 * len * 2); | ||
vstack = vstack.slice(0, -1 * len); | ||
lstack = lstack.slice(0, -1 * len); | ||
stack = stack.slice(0, -1 * len * 2) | ||
vstack = vstack.slice(0, -1 * len) | ||
lstack = lstack.slice(0, -1 * len) | ||
} | ||
stack.push(this.productions_[action[1]][0]); | ||
vstack.push(yyval.$); | ||
lstack.push(yyval._$); | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; | ||
stack.push(newState); | ||
break; | ||
case 3: | ||
return true; | ||
stack.push(this.productions_[action[1]][0]) | ||
vstack.push(yyval.$) | ||
lstack.push(yyval._$) | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]] | ||
stack.push(newState) | ||
break | ||
case 3: | ||
return true | ||
} | ||
} | ||
return true; | ||
}}; | ||
} | ||
return true | ||
}} | ||
/* generated by jison-lex 0.3.4 */ | ||
var lexer = (function(){ | ||
var lexer = ({ | ||
var lexer = (function () { | ||
var lexer = ({ | ||
EOF:1, | ||
EOF: 1, | ||
parseError:function parseError(str, hash) { | ||
parseError: function parseError (str, hash) { | ||
if (this.yy.parser) { | ||
this.yy.parser.parseError(str, hash); | ||
this.yy.parser.parseError(str, hash) | ||
} else { | ||
throw new Error(str); | ||
throw new Error(str) | ||
} | ||
}, | ||
}, | ||
// resets the lexer, sets new input | ||
setInput:function (input, yy) { | ||
this.yy = yy || this.yy || {}; | ||
this._input = input; | ||
this._more = this._backtrack = this.done = false; | ||
this.yylineno = this.yyleng = 0; | ||
this.yytext = this.matched = this.match = ''; | ||
this.conditionStack = ['INITIAL']; | ||
setInput: function (input, yy) { | ||
this.yy = yy || this.yy || {} | ||
this._input = input | ||
this._more = this._backtrack = this.done = false | ||
this.yylineno = this.yyleng = 0 | ||
this.yytext = this.matched = this.match = '' | ||
this.conditionStack = ['INITIAL'] | ||
this.yylloc = { | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
}; | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [0,0]; | ||
this.yylloc.range = [0, 0] | ||
} | ||
this.offset = 0; | ||
return this; | ||
}, | ||
this.offset = 0 | ||
return this | ||
}, | ||
// consumes and returns one char from the input | ||
input:function () { | ||
var ch = this._input[0]; | ||
this.yytext += ch; | ||
this.yyleng++; | ||
this.offset++; | ||
this.match += ch; | ||
this.matched += ch; | ||
var lines = ch.match(/(?:\r\n?|\n).*/g); | ||
input: function () { | ||
var ch = this._input[0] | ||
this.yytext += ch | ||
this.yyleng++ | ||
this.offset++ | ||
this.match += ch | ||
this.matched += ch | ||
var lines = ch.match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno++; | ||
this.yylloc.last_line++; | ||
this.yylineno++ | ||
this.yylloc.last_line++ | ||
} else { | ||
this.yylloc.last_column++; | ||
this.yylloc.last_column++ | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range[1]++; | ||
this.yylloc.range[1]++ | ||
} | ||
this._input = this._input.slice(1); | ||
return ch; | ||
}, | ||
this._input = this._input.slice(1) | ||
return ch | ||
}, | ||
// unshifts one char (or a string) into the input | ||
unput:function (ch) { | ||
var len = ch.length; | ||
var lines = ch.split(/(?:\r\n?|\n)/g); | ||
unput: function (ch) { | ||
var len = ch.length | ||
var lines = ch.split(/(?:\r\n?|\n)/g) | ||
this._input = ch + this._input; | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len); | ||
//this.yyleng -= len; | ||
this.offset -= len; | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g); | ||
this.match = this.match.substr(0, this.match.length - 1); | ||
this.matched = this.matched.substr(0, this.matched.length - 1); | ||
this._input = ch + this._input | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len) | ||
// this.yyleng -= len; | ||
this.offset -= len | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g) | ||
this.match = this.match.substr(0, this.match.length - 1) | ||
this.matched = this.matched.substr(0, this.matched.length - 1) | ||
if (lines.length - 1) { | ||
this.yylineno -= lines.length - 1; | ||
this.yylineno -= lines.length - 1 | ||
} | ||
var r = this.yylloc.range; | ||
var r = this.yylloc.range | ||
this.yylloc = { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines ? | ||
(lines.length === oldLines.length ? this.yylloc.first_column : 0) | ||
+ oldLines[oldLines.length - lines.length].length - lines[0].length : | ||
this.yylloc.first_column - len | ||
}; | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines | ||
? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + | ||
oldLines[oldLines.length - lines.length].length - lines[0].length | ||
: this.yylloc.first_column - len | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len]; | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len] | ||
} | ||
this.yyleng = this.yytext.length; | ||
return this; | ||
}, | ||
this.yyleng = this.yytext.length | ||
return this | ||
}, | ||
// When called from action, caches matched text and appends it on next action | ||
more:function () { | ||
this._more = true; | ||
return this; | ||
}, | ||
more: function () { | ||
this._more = true | ||
return this | ||
}, | ||
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. | ||
reject:function () { | ||
reject: function () { | ||
if (this.options.backtrack_lexer) { | ||
this._backtrack = true; | ||
this._backtrack = true | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
return this; | ||
}, | ||
return this | ||
}, | ||
// retain first n characters of the match | ||
less:function (n) { | ||
this.unput(this.match.slice(n)); | ||
}, | ||
less: function (n) { | ||
this.unput(this.match.slice(n)) | ||
}, | ||
// displays already matched input, i.e. for error messages | ||
pastInput:function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length); | ||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); | ||
}, | ||
pastInput: function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length) | ||
return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') | ||
}, | ||
// displays upcoming input, i.e. for error messages | ||
upcomingInput:function () { | ||
var next = this.match; | ||
upcomingInput: function () { | ||
var next = this.match | ||
if (next.length < 20) { | ||
next += this._input.substr(0, 20-next.length); | ||
next += this._input.substr(0, 20 - next.length) | ||
} | ||
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); | ||
}, | ||
return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, '') | ||
}, | ||
// displays the character position where the lexing error occurred, i.e. for error messages | ||
showPosition:function () { | ||
var pre = this.pastInput(); | ||
var c = new Array(pre.length + 1).join("-"); | ||
return pre + this.upcomingInput() + "\n" + c + "^"; | ||
}, | ||
showPosition: function () { | ||
var pre = this.pastInput() | ||
var c = new Array(pre.length + 1).join('-') | ||
return pre + this.upcomingInput() + '\n' + c + '^' | ||
}, | ||
// test the lexed token: return FALSE when not a match, otherwise return token | ||
test_match:function (match, indexed_rule) { | ||
test_match: function (match, indexed_rule) { | ||
var token, | ||
lines, | ||
backup; | ||
lines, | ||
backup | ||
if (this.options.backtrack_lexer) { | ||
// save context | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
}; | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0); | ||
} | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
} | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0) | ||
} | ||
} | ||
lines = match[0].match(/(?:\r\n?|\n).*/g); | ||
lines = match[0].match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno += lines.length; | ||
this.yylineno += lines.length | ||
} | ||
this.yylloc = { | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines ? | ||
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : | ||
this.yylloc.last_column + match[0].length | ||
}; | ||
this.yytext += match[0]; | ||
this.match += match[0]; | ||
this.matches = match; | ||
this.yyleng = this.yytext.length; | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines | ||
? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length | ||
: this.yylloc.last_column + match[0].length | ||
} | ||
this.yytext += match[0] | ||
this.match += match[0] | ||
this.matches = match | ||
this.yyleng = this.yytext.length | ||
if (this.options.ranges) { | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng]; | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng] | ||
} | ||
this._more = false; | ||
this._backtrack = false; | ||
this._input = this._input.slice(match[0].length); | ||
this.matched += match[0]; | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); | ||
this._more = false | ||
this._backtrack = false | ||
this._input = this._input.slice(match[0].length) | ||
this.matched += match[0] | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]) | ||
if (this.done && this._input) { | ||
this.done = false; | ||
this.done = false | ||
} | ||
if (token) { | ||
return token; | ||
return token | ||
} else if (this._backtrack) { | ||
// recover context | ||
for (var k in backup) { | ||
this[k] = backup[k]; | ||
} | ||
return false; // rule action called reject() implying the next rule should be tested instead. | ||
for (var k in backup) { | ||
this[k] = backup[k] | ||
} | ||
return false // rule action called reject() implying the next rule should be tested instead. | ||
} | ||
return false; | ||
}, | ||
return false | ||
}, | ||
// return next match in input | ||
next:function () { | ||
next: function () { | ||
if (this.done) { | ||
return this.EOF; | ||
return this.EOF | ||
} | ||
if (!this._input) { | ||
this.done = true; | ||
this.done = true | ||
} | ||
var token, | ||
match, | ||
tempMatch, | ||
index; | ||
match, | ||
tempMatch, | ||
index | ||
if (!this._more) { | ||
this.yytext = ''; | ||
this.match = ''; | ||
this.yytext = '' | ||
this.match = '' | ||
} | ||
var rules = this._currentRules(); | ||
var rules = this._currentRules() | ||
for (var i = 0; i < rules.length; i++) { | ||
tempMatch = this._input.match(this.rules[rules[i]]); | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch; | ||
index = i; | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]); | ||
if (token !== false) { | ||
return token; | ||
} else if (this._backtrack) { | ||
match = false; | ||
continue; // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
tempMatch = this._input.match(this.rules[rules[i]]) | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch | ||
index = i | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]) | ||
if (token !== false) { | ||
return token | ||
} else if (this._backtrack) { | ||
match = false | ||
continue // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
} | ||
} else if (!this.options.flex) { | ||
break; | ||
} | ||
return false | ||
} | ||
} else if (!this.options.flex) { | ||
break | ||
} | ||
} | ||
} | ||
if (match) { | ||
token = this.test_match(match, rules[index]); | ||
if (token !== false) { | ||
return token; | ||
} | ||
token = this.test_match(match, rules[index]) | ||
if (token !== false) { | ||
return token | ||
} | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
return false | ||
} | ||
if (this._input === "") { | ||
return this.EOF; | ||
if (this._input === '') { | ||
return this.EOF | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
}, | ||
}, | ||
// return next match that has a token | ||
lex:function lex() { | ||
var r = this.next(); | ||
lex: function lex () { | ||
var r = this.next() | ||
if (r) { | ||
return r; | ||
return r | ||
} else { | ||
return this.lex(); | ||
return this.lex() | ||
} | ||
}, | ||
}, | ||
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) | ||
begin:function begin(condition) { | ||
this.conditionStack.push(condition); | ||
}, | ||
begin: function begin (condition) { | ||
this.conditionStack.push(condition) | ||
}, | ||
// pop the previously active lexer condition state off the condition stack | ||
popState:function popState() { | ||
var n = this.conditionStack.length - 1; | ||
popState: function popState () { | ||
var n = this.conditionStack.length - 1 | ||
if (n > 0) { | ||
return this.conditionStack.pop(); | ||
return this.conditionStack.pop() | ||
} else { | ||
return this.conditionStack[0]; | ||
return this.conditionStack[0] | ||
} | ||
}, | ||
}, | ||
// produce the lexer rule set which is active for the currently active lexer condition state | ||
_currentRules:function _currentRules() { | ||
_currentRules: function _currentRules () { | ||
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules | ||
} else { | ||
return this.conditions["INITIAL"].rules; | ||
return this.conditions['INITIAL'].rules | ||
} | ||
}, | ||
}, | ||
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available | ||
topState:function topState(n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0); | ||
topState: function topState (n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0) | ||
if (n >= 0) { | ||
return this.conditionStack[n]; | ||
return this.conditionStack[n] | ||
} else { | ||
return "INITIAL"; | ||
return 'INITIAL' | ||
} | ||
}, | ||
}, | ||
// alias for begin(condition) | ||
pushState:function pushState(condition) { | ||
this.begin(condition); | ||
}, | ||
pushState: function pushState (condition) { | ||
this.begin(condition) | ||
}, | ||
// return the number of states currently on the stack | ||
stateStackSize:function stateStackSize() { | ||
return this.conditionStack.length; | ||
}, | ||
options: {}, | ||
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { | ||
var YYSTATE=YY_START; | ||
switch($avoiding_name_collisions) { | ||
case 0:/* do nothing */ | ||
break; | ||
case 1:this.begin("string"); | ||
break; | ||
case 2:this.popState(); | ||
break; | ||
case 3:return "STR"; | ||
break; | ||
case 4:return 71; | ||
break; | ||
case 5:return 78; | ||
break; | ||
case 6:return 72; | ||
break; | ||
case 7:return 82; | ||
break; | ||
case 8:return 73; | ||
break; | ||
case 9:return 74; | ||
break; | ||
case 10:return 75; | ||
break; | ||
case 11:return 12; | ||
break; | ||
case 12:return 30; | ||
break; | ||
case 13:return 32; | ||
break; | ||
case 14:return 13; | ||
break; | ||
case 15:return 13; | ||
break; | ||
case 16:return 13; | ||
break; | ||
case 17:return 13; | ||
break; | ||
case 18:return 13; | ||
break; | ||
case 19:return 13; | ||
break; | ||
case 20:return 81; | ||
break; | ||
case 21:return 91; | ||
break; | ||
case 22:return 89; | ||
break; | ||
case 23:return 8; | ||
break; | ||
case 24:return 86; | ||
break; | ||
case 25:return 98; | ||
break; | ||
case 26:return 16; | ||
break; | ||
case 27:return 15; | ||
break; | ||
case 28:return 17; | ||
break; | ||
case 29:return 18; | ||
break; | ||
case 30:return 53; | ||
break; | ||
case 31:return 51; | ||
break; | ||
case 32:return 52; | ||
break; | ||
case 33:return 54; | ||
break; | ||
case 34:return 58; | ||
break; | ||
case 35:return 56; | ||
break; | ||
case 36:return 57; | ||
break; | ||
case 37:return 59; | ||
break; | ||
case 38:return 58; | ||
break; | ||
case 39:return 56; | ||
break; | ||
case 40:return 57; | ||
break; | ||
case 41:return 59; | ||
break; | ||
case 42:return 63; | ||
break; | ||
case 43:return 61; | ||
break; | ||
case 44:return 62; | ||
break; | ||
case 45:return 64; | ||
break; | ||
case 46:return 50; | ||
break; | ||
case 47:return 55; | ||
break; | ||
case 48:return 60; | ||
break; | ||
case 49:return 40; | ||
break; | ||
case 50:return 41; | ||
break; | ||
case 51:return 46; | ||
break; | ||
case 52:return 92; | ||
break; | ||
case 53:return 96; | ||
break; | ||
case 54:return 84; | ||
break; | ||
case 55:return 97; | ||
break; | ||
case 56:return 97; | ||
break; | ||
case 57:return 88; | ||
break; | ||
case 58:return 94; | ||
break; | ||
case 59:return 95; | ||
break; | ||
case 60:return 65; | ||
break; | ||
case 61:return 38; | ||
break; | ||
case 62:return 39; | ||
break; | ||
case 63:return 36; | ||
break; | ||
case 64:return 37; | ||
break; | ||
case 65:return 42 | ||
break; | ||
case 66:return 43 | ||
break; | ||
case 67:return 101; | ||
break; | ||
case 68:return 9; | ||
break; | ||
case 69:return 10; | ||
break; | ||
case 70:return 11; | ||
break; | ||
} | ||
}, | ||
rules: [/^(?:%%[^\n]*)/,/^(?:["])/,/^(?:["])/,/^(?:[^"]*)/,/^(?:style\b)/,/^(?:default\b)/,/^(?:linkStyle\b)/,/^(?:interpolate\b)/,/^(?:classDef\b)/,/^(?:class\b)/,/^(?:click\b)/,/^(?:graph\b)/,/^(?:subgraph\b)/,/^(?:end\b\s*)/,/^(?:LR\b)/,/^(?:RL\b)/,/^(?:TB\b)/,/^(?:BT\b)/,/^(?:TD\b)/,/^(?:BR\b)/,/^(?:[0-9]+)/,/^(?:#)/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:\*)/,/^(?:<)/,/^(?:>)/,/^(?:\^)/,/^(?:v\b)/,/^(?:\s*--[x]\s*)/,/^(?:\s*-->\s*)/,/^(?:\s*--[o]\s*)/,/^(?:\s*---\s*)/,/^(?:\s*-\.-[x]\s*)/,/^(?:\s*-\.->\s*)/,/^(?:\s*-\.-[o]\s*)/,/^(?:\s*-\.-\s*)/,/^(?:\s*.-[x]\s*)/,/^(?:\s*\.->\s*)/,/^(?:\s*\.-[o]\s*)/,/^(?:\s*\.-\s*)/,/^(?:\s*==[x]\s*)/,/^(?:\s*==>\s*)/,/^(?:\s*==[o]\s*)/,/^(?:\s*==[\=]\s*)/,/^(?:\s*--\s*)/,/^(?:\s*-\.\s*)/,/^(?:\s*==\s*)/,/^(?:\(-)/,/^(?:-\))/,/^(?:-)/,/^(?:\.)/,/^(?:\+)/,/^(?:%)/,/^(?:=)/,/^(?:=)/,/^(?:[A-Za-z]+)/,/^(?:[!"#$%&'*+,-.`?\\_\/])/,/^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/,/^(?:\|)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:")/,/^(?:\n+)/,/^(?:\s)/,/^(?:$)/], | ||
conditions: {"string":{"rules":[2,3],"inclusive":false},"INITIAL":{"rules":[0,1,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70],"inclusive":true}} | ||
}); | ||
return lexer; | ||
})(); | ||
parser.lexer = lexer; | ||
function Parser () { | ||
this.yy = {}; | ||
} | ||
Parser.prototype = parser;parser.Parser = Parser; | ||
return new Parser; | ||
})(); | ||
stateStackSize: function stateStackSize () { | ||
return this.conditionStack.length | ||
}, | ||
options: {}, | ||
performAction: function anonymous (yy, yy_, $avoiding_name_collisions, YY_START) { | ||
var YYSTATE = YY_START | ||
switch ($avoiding_name_collisions) { | ||
case 0:/* do nothing */ | ||
break | ||
case 1:this.begin('string') | ||
break | ||
case 2:this.popState() | ||
break | ||
case 3:return 'STR' | ||
break | ||
case 4:return 71 | ||
break | ||
case 5:return 78 | ||
break | ||
case 6:return 72 | ||
break | ||
case 7:return 82 | ||
break | ||
case 8:return 73 | ||
break | ||
case 9:return 74 | ||
break | ||
case 10:return 75 | ||
break | ||
case 11:return 12 | ||
break | ||
case 12:return 30 | ||
break | ||
case 13:return 32 | ||
break | ||
case 14:return 13 | ||
break | ||
case 15:return 13 | ||
break | ||
case 16:return 13 | ||
break | ||
case 17:return 13 | ||
break | ||
case 18:return 13 | ||
break | ||
case 19:return 13 | ||
break | ||
case 20:return 81 | ||
break | ||
case 21:return 91 | ||
break | ||
case 22:return 89 | ||
break | ||
case 23:return 8 | ||
break | ||
case 24:return 86 | ||
break | ||
case 25:return 98 | ||
break | ||
case 26:return 16 | ||
break | ||
case 27:return 15 | ||
break | ||
case 28:return 17 | ||
break | ||
case 29:return 18 | ||
break | ||
case 30:return 53 | ||
break | ||
case 31:return 51 | ||
break | ||
case 32:return 52 | ||
break | ||
case 33:return 54 | ||
break | ||
case 34:return 58 | ||
break | ||
case 35:return 56 | ||
break | ||
case 36:return 57 | ||
break | ||
case 37:return 59 | ||
break | ||
case 38:return 58 | ||
break | ||
case 39:return 56 | ||
break | ||
case 40:return 57 | ||
break | ||
case 41:return 59 | ||
break | ||
case 42:return 63 | ||
break | ||
case 43:return 61 | ||
break | ||
case 44:return 62 | ||
break | ||
case 45:return 64 | ||
break | ||
case 46:return 50 | ||
break | ||
case 47:return 55 | ||
break | ||
case 48:return 60 | ||
break | ||
case 49:return 40 | ||
break | ||
case 50:return 41 | ||
break | ||
case 51:return 46 | ||
break | ||
case 52:return 92 | ||
break | ||
case 53:return 96 | ||
break | ||
case 54:return 84 | ||
break | ||
case 55:return 97 | ||
break | ||
case 56:return 97 | ||
break | ||
case 57:return 88 | ||
break | ||
case 58:return 94 | ||
break | ||
case 59:return 95 | ||
break | ||
case 60:return 65 | ||
break | ||
case 61:return 38 | ||
break | ||
case 62:return 39 | ||
break | ||
case 63:return 36 | ||
break | ||
case 64:return 37 | ||
break | ||
case 65:return 42 | ||
break | ||
case 66:return 43 | ||
break | ||
case 67:return 101 | ||
break | ||
case 68:return 9 | ||
break | ||
case 69:return 10 | ||
break | ||
case 70:return 11 | ||
break | ||
} | ||
}, | ||
rules: [/^(?:%%[^\n]*)/, /^(?:["])/, /^(?:["])/, /^(?:[^"]*)/, /^(?:style\b)/, /^(?:default\b)/, /^(?:linkStyle\b)/, /^(?:interpolate\b)/, /^(?:classDef\b)/, /^(?:class\b)/, /^(?:click\b)/, /^(?:graph\b)/, /^(?:subgraph\b)/, /^(?:end\b\s*)/, /^(?:LR\b)/, /^(?:RL\b)/, /^(?:TB\b)/, /^(?:BT\b)/, /^(?:TD\b)/, /^(?:BR\b)/, /^(?:[0-9]+)/, /^(?:#)/, /^(?::)/, /^(?:;)/, /^(?:,)/, /^(?:\*)/, /^(?:<)/, /^(?:>)/, /^(?:\^)/, /^(?:v\b)/, /^(?:\s*--[x]\s*)/, /^(?:\s*-->\s*)/, /^(?:\s*--[o]\s*)/, /^(?:\s*---\s*)/, /^(?:\s*-\.-[x]\s*)/, /^(?:\s*-\.->\s*)/, /^(?:\s*-\.-[o]\s*)/, /^(?:\s*-\.-\s*)/, /^(?:\s*.-[x]\s*)/, /^(?:\s*\.->\s*)/, /^(?:\s*\.-[o]\s*)/, /^(?:\s*\.-\s*)/, /^(?:\s*==[x]\s*)/, /^(?:\s*==>\s*)/, /^(?:\s*==[o]\s*)/, /^(?:\s*==[\=]\s*)/, /^(?:\s*--\s*)/, /^(?:\s*-\.\s*)/, /^(?:\s*==\s*)/, /^(?:\(-)/, /^(?:-\))/, /^(?:-)/, /^(?:\.)/, /^(?:\+)/, /^(?:%)/, /^(?:=)/, /^(?:=)/, /^(?:[A-Za-z]+)/, /^(?:[!"#$%&'*+,-.`?\\_\/])/, /^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/, /^(?:\|)/, /^(?:\()/, /^(?:\))/, /^(?:\[)/, /^(?:\])/, /^(?:\{)/, /^(?:\})/, /^(?:")/, /^(?:\n+)/, /^(?:\s)/, /^(?:$)/], | ||
conditions: {'string': {'rules': [2, 3], 'inclusive': false}, 'INITIAL': {'rules': [0, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70], 'inclusive': true}} | ||
}) | ||
return lexer | ||
})() | ||
parser.lexer = lexer | ||
function Parser () { | ||
this.yy = {} | ||
} | ||
Parser.prototype = parser; parser.Parser = Parser | ||
return new Parser() | ||
})() | ||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') { | ||
exports.parser = parser; | ||
exports.Parser = parser.Parser; | ||
exports.parse = function () { return parser.parse.apply(parser, arguments); }; | ||
exports.main = function commonjsMain(args) { | ||
exports.parser = parser | ||
exports.Parser = parser.Parser | ||
exports.parse = function () { return parser.parse.apply(parser, arguments) } | ||
exports.main = function commonjsMain (args) { | ||
if (!args[1]) { | ||
console.log('Usage: '+args[0]+' FILE'); | ||
process.exit(1); | ||
console.log('Usage: ' + args[0] + ' FILE') | ||
process.exit(1) | ||
} | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); | ||
return exports.parser.parse(source); | ||
}; | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)); | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), 'utf8') | ||
return exports.parser.parse(source) | ||
} | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)) | ||
} | ||
} | ||
} |
@@ -5,383 +5,358 @@ /** | ||
var graph = require('../graphDb'); | ||
var flow = require('./flow'); | ||
var graph = require('../graphDb') | ||
var flow = require('./flow') | ||
describe('when parsing ',function(){ | ||
beforeEach(function(){ | ||
flow.parser.yy = require('../graphDb'); | ||
flow.parser.yy.clear(); | ||
/*flow.parser.parse.parseError= function parseError(str, hash) { | ||
describe('when parsing ', function () { | ||
beforeEach(function () { | ||
flow.parser.yy = require('../graphDb') | ||
flow.parser.yy.clear() | ||
/* flow.parser.parse.parseError= function parseError(str, hash) { | ||
log.debugconsole.log(str); | ||
}*/ | ||
}); | ||
} */ | ||
}) | ||
it('should handle a nodes and edges',function(){ | ||
var res = flow.parser.parse('graph TD;\nA-->B;'); | ||
it('should handle a nodes and edges', function () { | ||
var res = flow.parser.parse('graph TD;\nA-->B;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
it('should handle angle bracket ' > ' as direction LR', function () { | ||
var res = flow.parser.parse('graph >;A-->B;') | ||
it('should handle angle bracket '>' as direction LR',function(){ | ||
var res = flow.parser.parse('graph >;A-->B;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var direction = flow.parser.yy.getDirection() | ||
expect(direction).toBe('LR') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var direction = flow.parser.yy.getDirection(); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
expect(direction).toBe('LR'); | ||
it('should handle angle bracket ' < ' as direction RL', function () { | ||
var res = flow.parser.parse('graph <;A-->B;') | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var direction = flow.parser.yy.getDirection() | ||
it('should handle angle bracket '<' as direction RL',function(){ | ||
var res = flow.parser.parse('graph <;A-->B;'); | ||
expect(direction).toBe('RL') | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var direction = flow.parser.yy.getDirection(); | ||
it('should handle caret ' ^ ' as direction BT', function () { | ||
var res = flow.parser.parse('graph ^;A-->B;') | ||
expect(direction).toBe('RL'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var direction = flow.parser.yy.getDirection() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
expect(direction).toBe('BT') | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle caret '^' as direction BT',function(){ | ||
var res = flow.parser.parse('graph ^;A-->B;'); | ||
it('should handle lower-case \'v\' as direction TB', function () { | ||
var res = flow.parser.parse('graph v;A-->B;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var direction = flow.parser.yy.getDirection() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var direction = flow.parser.yy.getDirection(); | ||
expect(direction).toBe('TB') | ||
expect(direction).toBe('BT'); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
it('should handle a nodes and edges and a space between link and node', function () { | ||
var res = flow.parser.parse('graph TD;A --> B;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('should handle lower-case \'v\' as direction TB',function(){ | ||
var res = flow.parser.parse('graph v;A-->B;'); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle a nodes and edges, a space between link and node and each line ending without semicolon', function () { | ||
var res = flow.parser.parse('graph TD\nA --> B\n style e red') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var direction = flow.parser.yy.getDirection(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(direction).toBe('TB'); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle statements ending without semicolon', function () { | ||
var res = flow.parser.parse('graph TD\nA-->B\nB-->C') | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('should handle a nodes and edges and a space between link and node',function(){ | ||
var res = flow.parser.parse('graph TD;A --> B;'); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(2) | ||
expect(edges[1].start).toBe('B') | ||
expect(edges[1].end).toBe('C') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle a comments', function () { | ||
var res = flow.parser.parse('graph TD;\n%% CComment\n A-->B;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle comments a at the start', function () { | ||
var res = flow.parser.parse('%% Comment\ngraph TD;\n A-->B;') | ||
it('should handle a nodes and edges, a space between link and node and each line ending without semicolon',function(){ | ||
var res = flow.parser.parse('graph TD\nA --> B\n style e red'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle comments at the end', function () { | ||
var res = flow.parser.parse('graph TD;\n A-->B\n %% Comment at the find\n') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
it('should handle statements ending without semicolon',function(){ | ||
var res = flow.parser.parse('graph TD\nA-->B\nB-->C'); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle comments at the end no trailing newline', function () { | ||
var res = flow.parser.parse('graph TD;\n A-->B\n%% Commento') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle comments at the end many trailing newlines', function () { | ||
var res = flow.parser.parse('graph TD;\n A-->B\n%% Commento\n\n\n') | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(2); | ||
expect(edges[1].start).toBe('B'); | ||
expect(edges[1].end).toBe('C'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('should handle a comments',function(){ | ||
var res = flow.parser.parse('graph TD;\n%% CComment\n A-->B;'); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle no trailing newlines', function () { | ||
var res = flow.parser.parse('graph TD;\n A-->B') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle many trailing newlines', function () { | ||
var res = flow.parser.parse('graph TD;\n A-->B\n\n') | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
it('should handle comments a at the start',function(){ | ||
var res = flow.parser.parse('%% Comment\ngraph TD;\n A-->B;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle a comments with blank rows in-between', function () { | ||
var res = flow.parser.parse('graph TD;\n\n\n %% Comment\n A-->B;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
it('should handle comments at the end',function(){ | ||
var res = flow.parser.parse('graph TD;\n A-->B\n %% Comment at the find\n'); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle a comments mermaid flowchart code in them', function () { | ||
var res = flow.parser.parse('graph TD;\n\n\n %% Test od>Odd shape]-->|Two line<br>edge comment|ro;\n A-->B;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
it('should handle comments at the end no trailing newline',function(){ | ||
var res = flow.parser.parse('graph TD;\n A-->B\n%% Commento'); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(1) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('it should handle a trailing whitespaces after statememnts', function () { | ||
var res = flow.parser.parse('graph TD;\n\n\n %% Comment\n A-->B; \n B-->C;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
it('should handle comments at the end many trailing newlines',function(){ | ||
var res = flow.parser.parse('graph TD;\n A-->B\n%% Commento\n\n\n'); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(2) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('') | ||
}) | ||
it('should handle node names with "end" substring', function () { | ||
var res = flow.parser.parse('graph TD\nendpoint --> sender') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
it('should handle no trailing newlines',function(){ | ||
var res = flow.parser.parse('graph TD;\n A-->B'); | ||
expect(vert['endpoint'].id).toBe('endpoint') | ||
expect(vert['sender'].id).toBe('sender') | ||
expect(edges[0].start).toBe('endpoint') | ||
expect(edges[0].end).toBe('sender') | ||
}) | ||
it('should handle node names ending with keywords', function () { | ||
var res = flow.parser.parse('graph TD\nblend --> monograph') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
it('should handle many trailing newlines',function(){ | ||
var res = flow.parser.parse('graph TD;\n A-->B\n\n'); | ||
expect(vert['blend'].id).toBe('blend') | ||
expect(vert['monograph'].id).toBe('monograph') | ||
expect(edges[0].start).toBe('blend') | ||
expect(edges[0].end).toBe('monograph') | ||
}) | ||
it('should handle open ended edges', function () { | ||
var res = flow.parser.parse('graph TD;A---B;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
it('should handle a comments with blank rows in-between',function(){ | ||
var res = flow.parser.parse('graph TD;\n\n\n %% Comment\n A-->B;'); | ||
expect(edges[0].type).toBe('arrow_open') | ||
}) | ||
it('should handle cross ended edges', function () { | ||
var res = flow.parser.parse('graph TD;A--xB;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
}) | ||
it('should handle a comments mermaid flowchart code in them',function(){ | ||
var res = flow.parser.parse('graph TD;\n\n\n %% Test od>Odd shape]-->|Two line<br>edge comment|ro;\n A-->B;'); | ||
it('should handle open ended edges', function () { | ||
var res = flow.parser.parse('graph TD;A--oB;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_circle') | ||
}) | ||
it('should handle subgraphs', function () { | ||
var res = flow.parser.parse('graph TD;A-->B;subgraph myTitle;c-->d;end;') | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(1); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('it should handle a trailing whitespaces after statememnts',function(){ | ||
var res = flow.parser.parse('graph TD;\n\n\n %% Comment\n A-->B; \n B-->C;'); | ||
expect(edges[0].type).toBe('arrow') | ||
}) | ||
it('should handle subgraphs', function () { | ||
var res = flow.parser.parse('graph TD\nA-->B\nsubgraph myTitle\n\n c-->d \nend\n') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(2); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe(''); | ||
}); | ||
expect(edges[0].type).toBe('arrow') | ||
}) | ||
it('should handle node names with "end" substring',function(){ | ||
var res = flow.parser.parse('graph TD\nendpoint --> sender'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['endpoint'].id).toBe('endpoint'); | ||
expect(vert['sender'].id).toBe('sender'); | ||
expect(edges[0].start).toBe('endpoint'); | ||
expect(edges[0].end).toBe('sender'); | ||
}); | ||
it('should handle node names ending with keywords',function(){ | ||
var res = flow.parser.parse('graph TD\nblend --> monograph'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['blend'].id).toBe('blend'); | ||
expect(vert['monograph'].id).toBe('monograph'); | ||
expect(edges[0].start).toBe('blend'); | ||
expect(edges[0].end).toBe('monograph'); | ||
}); | ||
it('should handle open ended edges',function(){ | ||
var res = flow.parser.parse('graph TD;A---B;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_open'); | ||
}); | ||
it('should handle cross ended edges',function(){ | ||
var res = flow.parser.parse('graph TD;A--xB;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
}); | ||
it('should handle open ended edges',function(){ | ||
var res = flow.parser.parse('graph TD;A--oB;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_circle'); | ||
}); | ||
it('should handle subgraphs',function(){ | ||
var res = flow.parser.parse('graph TD;A-->B;subgraph myTitle;c-->d;end;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow'); | ||
}); | ||
it('should handle subgraphs',function(){ | ||
var res = flow.parser.parse('graph TD\nA-->B\nsubgraph myTitle\n\n c-->d \nend\n'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow'); | ||
}); | ||
it('should handle nested subgraphs',function(){ | ||
var str = 'graph TD\n' + | ||
it('should handle nested subgraphs', function () { | ||
var str = 'graph TD\n' + | ||
'A-->B\n' + | ||
@@ -392,49 +367,44 @@ 'subgraph myTitle\n\n' + | ||
' subgraph inner\n\n h-->i \n end \n\n' + | ||
'end\n'; | ||
var res = flow.parser.parse(str); | ||
'end\n' | ||
var res = flow.parser.parse(str) | ||
}) | ||
}); | ||
it('should handle subgraphs', function () { | ||
var res = flow.parser.parse('graph TD\nA-->B\nsubgraph myTitle\nc-->d\nend;') | ||
it('should handle subgraphs',function(){ | ||
var res = flow.parser.parse('graph TD\nA-->B\nsubgraph myTitle\nc-->d\nend;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow') | ||
}) | ||
it('should handle subgraphs', function () { | ||
var res = flow.parser.parse('graph TD\nA-->B\nsubgraph myTitle\nc-- text -->d\nd-->e\n end;') | ||
expect(edges[0].type).toBe('arrow'); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('should handle subgraphs',function(){ | ||
var res = flow.parser.parse('graph TD\nA-->B\nsubgraph myTitle\nc-- text -->d\nd-->e\n end;'); | ||
expect(edges[0].type).toBe('arrow') | ||
}) | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
it('should handle classDefs with style in classes', function () { | ||
var res = flow.parser.parse('graph TD\nA-->B\nclassDef exClass font-style:bold;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow'); | ||
}); | ||
expect(edges[0].type).toBe('arrow') | ||
}) | ||
it('should handle classDefs with style in classes',function(){ | ||
var res = flow.parser.parse('graph TD\nA-->B\nclassDef exClass font-style:bold;'); | ||
it('should handle classDefs with % in classes', function () { | ||
var res = flow.parser.parse('graph TD\nA-->B\nclassDef exClass fill:#f96,stroke:#333,stroke-width:4px,font-size:50%,font-style:bold;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow') | ||
}) | ||
expect(edges[0].type).toBe('arrow'); | ||
}); | ||
it('should handle classDefs with % in classes',function(){ | ||
var res = flow.parser.parse('graph TD\nA-->B\nclassDef exClass fill:#f96,stroke:#333,stroke-width:4px,font-size:50%,font-style:bold;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow'); | ||
}); | ||
it('should handle style definitons with more then 1 digit in a row',function(){ | ||
var res = flow.parser.parse('graph TD\n' + | ||
it('should handle style definitons with more then 1 digit in a row', function () { | ||
var res = flow.parser.parse('graph TD\n' + | ||
'A-->B1\n' + | ||
@@ -451,451 +421,404 @@ 'A-->B2\n' + | ||
'A-->B11\n' + | ||
'linkStyle 10 stroke-width:1px;'); | ||
'linkStyle 10 stroke-width:1px;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow') | ||
}) | ||
expect(edges[0].type).toBe('arrow'); | ||
}); | ||
it('should handle line interpolation default definitions',function(){ | ||
var res = flow.parser.parse('graph TD\n' + | ||
it('should handle line interpolation default definitions', function () { | ||
var res = flow.parser.parse('graph TD\n' + | ||
'A-->B\n' + | ||
'linkStyle default interpolate basis'); | ||
'linkStyle default interpolate basis') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.defaultInterpolate).toBe('basis') | ||
}) | ||
expect(edges.defaultInterpolate).toBe('basis'); | ||
}); | ||
it('should handle line interpolation numbered definitions',function(){ | ||
var res = flow.parser.parse('graph TD\n' + | ||
it('should handle line interpolation numbered definitions', function () { | ||
var res = flow.parser.parse('graph TD\n' + | ||
'A-->B\n' + | ||
'A-->C\n' + | ||
'linkStyle 0 interpolate basis\n' + | ||
'linkStyle 1 interpolate cardinal'); | ||
'linkStyle 1 interpolate cardinal') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].interpolate).toBe('basis'); | ||
expect(edges[1].interpolate).toBe('cardinal'); | ||
}); | ||
expect(edges[0].interpolate).toBe('basis') | ||
expect(edges[1].interpolate).toBe('cardinal') | ||
}) | ||
it('should handle line interpolation default with style',function(){ | ||
var res = flow.parser.parse('graph TD\n' + | ||
it('should handle line interpolation default with style', function () { | ||
var res = flow.parser.parse('graph TD\n' + | ||
'A-->B\n' + | ||
'linkStyle default interpolate basis stroke-width:1px;'); | ||
'linkStyle default interpolate basis stroke-width:1px;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.defaultInterpolate).toBe('basis') | ||
}) | ||
expect(edges.defaultInterpolate).toBe('basis'); | ||
}); | ||
it('should handle line interpolation numbered with style',function(){ | ||
var res = flow.parser.parse('graph TD\n' + | ||
it('should handle line interpolation numbered with style', function () { | ||
var res = flow.parser.parse('graph TD\n' + | ||
'A-->B\n' + | ||
'A-->C\n' + | ||
'linkStyle 0 interpolate basis stroke-width:1px;\n' + | ||
'linkStyle 1 interpolate cardinal stroke-width:1px;'); | ||
'linkStyle 1 interpolate cardinal stroke-width:1px;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].interpolate).toBe('basis'); | ||
expect(edges[1].interpolate).toBe('cardinal'); | ||
}); | ||
expect(edges[0].interpolate).toBe('basis') | ||
expect(edges[1].interpolate).toBe('cardinal') | ||
}) | ||
describe('it should handle interaction, ',function(){ | ||
describe('it should handle interaction, ', function () { | ||
it('it should be possible to use click to a callback', function () { | ||
spyOn(graph, 'setClickEvent') | ||
var res = flow.parser.parse('graph TD\nA-->B\nclick A callback') | ||
it('it should be possible to use click to a callback',function(){ | ||
spyOn(graph,'setClickEvent'); | ||
var res = flow.parser.parse('graph TD\nA-->B\nclick A callback'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(graph.setClickEvent).toHaveBeenCalledWith('A', 'callback', undefined, undefined) | ||
}) | ||
expect(graph.setClickEvent).toHaveBeenCalledWith('A','callback',undefined,undefined); | ||
}); | ||
it('it should be possible to use click to a callback with toolip', function () { | ||
spyOn(graph, 'setClickEvent') | ||
var res = flow.parser.parse('graph TD\nA-->B\nclick A callback "tooltip"') | ||
it('it should be possible to use click to a callback with toolip',function(){ | ||
spyOn(graph,'setClickEvent'); | ||
var res = flow.parser.parse('graph TD\nA-->B\nclick A callback "tooltip"'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(graph.setClickEvent).toHaveBeenCalledWith('A', 'callback', undefined, 'tooltip') | ||
}) | ||
expect(graph.setClickEvent).toHaveBeenCalledWith('A','callback',undefined,'tooltip'); | ||
}); | ||
it('should handle interaction - click to a link', function () { | ||
spyOn(graph, 'setClickEvent') | ||
var res = flow.parser.parse('graph TD\nA-->B\nclick A "click.html"') | ||
it('should handle interaction - click to a link',function(){ | ||
spyOn(graph,'setClickEvent'); | ||
var res = flow.parser.parse('graph TD\nA-->B\nclick A "click.html"'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(graph.setClickEvent).toHaveBeenCalledWith('A', undefined, 'click.html', undefined) | ||
}) | ||
it('should handle interaction - click to a link with tooltip', function () { | ||
spyOn(graph, 'setClickEvent') | ||
var res = flow.parser.parse('graph TD\nA-->B\nclick A "click.html" "tooltip"') | ||
expect(graph.setClickEvent).toHaveBeenCalledWith('A',undefined,'click.html',undefined); | ||
}); | ||
it('should handle interaction - click to a link with tooltip',function(){ | ||
spyOn(graph,'setClickEvent'); | ||
var res = flow.parser.parse('graph TD\nA-->B\nclick A "click.html" "tooltip"'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(graph.setClickEvent).toHaveBeenCalledWith('A', undefined, 'click.html', 'tooltip') | ||
}) | ||
}) | ||
expect(graph.setClickEvent).toHaveBeenCalledWith('A',undefined,'click.html','tooltip'); | ||
}); | ||
}); | ||
describe('it should handle text on edges', function () { | ||
it('it should handle text without space', function () { | ||
var res = flow.parser.parse('graph TD;A--x|textNoSpace|B;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
describe('it should handle text on edges',function(){ | ||
it('it should handle text without space',function(){ | ||
var res = flow.parser.parse('graph TD;A--x|textNoSpace|B;'); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
}) | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
it('should handle with space', function () { | ||
var res = flow.parser.parse('graph TD;A--x|text including space|B;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
}); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
}) | ||
it('should handle with space',function(){ | ||
var res = flow.parser.parse('graph TD;A--x|text including space|B;'); | ||
it('it should handle text with /', function () { | ||
var res = flow.parser.parse('graph TD;A--x|text with / should work|B;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].text).toBe('text with / should work') | ||
}) | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
}); | ||
it('it should handle space and space between vertices and link', function () { | ||
var res = flow.parser.parse('graph TD;A --x|textNoSpace| B;') | ||
it('it should handle text with /',function(){ | ||
var res = flow.parser.parse('graph TD;A--x|text with / should work|B;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
}) | ||
it('should handle space and CAPS', function () { | ||
var res = flow.parser.parse('graph TD;A--x|text including CAPS space|B;') | ||
expect(edges[0].text).toBe('text with / should work'); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('it should handle space and space between vertices and link',function(){ | ||
var res = flow.parser.parse('graph TD;A --x|textNoSpace| B;'); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
}) | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
it('should handle space and dir', function () { | ||
var res = flow.parser.parse('graph TD;A--x|text including URL space|B;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
}); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
expect(edges[0].text).toBe('text including URL space') | ||
}) | ||
it('should handle space and CAPS',function(){ | ||
var res = flow.parser.parse('graph TD;A--x|text including CAPS space|B;'); | ||
it('should handle space and send', function () { | ||
var res = flow.parser.parse('graph TD;A--text including URL space and send-->B;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('text including URL space and send') | ||
}) | ||
it('should handle space and send', function () { | ||
var res = flow.parser.parse('graph TD;A-- text including URL space and send -->B;') | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('should handle space and dir',function(){ | ||
var res = flow.parser.parse('graph TD;A--x|text including URL space|B;'); | ||
expect(edges[0].type).toBe('arrow') | ||
expect(edges[0].text).toBe('text including URL space and send') | ||
}) | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
it('should handle space and dir (TD)', function () { | ||
var res = flow.parser.parse('graph TD;A--x|text including R TD space|B;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
expect(edges[0].text).toBe('text including URL space'); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
expect(edges[0].text).toBe('text including R TD space') | ||
}) | ||
it('should handle `', function () { | ||
var res = flow.parser.parse('graph TD;A--x|text including `|B;') | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('should handle space and send',function(){ | ||
var res = flow.parser.parse('graph TD;A--text including URL space and send-->B;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe('text including URL space and send'); | ||
}); | ||
it('should handle space and send',function(){ | ||
var res = flow.parser.parse('graph TD;A-- text including URL space and send -->B;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow'); | ||
expect(edges[0].text).toBe('text including URL space and send'); | ||
}); | ||
it('should handle space and dir (TD)',function(){ | ||
var res = flow.parser.parse('graph TD;A--x|text including R TD space|B;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
expect(edges[0].text).toBe('text including R TD space'); | ||
}); | ||
it('should handle `',function(){ | ||
var res = flow.parser.parse('graph TD;A--x|text including `|B;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
expect(edges[0].text).toBe('text including `'); | ||
}); | ||
it('should handle v in node ids only v',function(){ | ||
expect(edges[0].type).toBe('arrow_cross') | ||
expect(edges[0].text).toBe('text including `') | ||
}) | ||
it('should handle v in node ids only v', function () { | ||
// only v | ||
var res = flow.parser.parse('graph TD;A--xv(my text);'); | ||
var res = flow.parser.parse('graph TD;A--xv(my text);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
expect(vert['v'].text).toBe('my text'); | ||
}); | ||
it('should handle v in node ids v at end',function(){ | ||
expect(edges[0].type).toBe('arrow_cross') | ||
expect(vert['v'].text).toBe('my text') | ||
}) | ||
it('should handle v in node ids v at end', function () { | ||
// v at end | ||
var res = flow.parser.parse('graph TD;A--xcsv(my text);'); | ||
var res = flow.parser.parse('graph TD;A--xcsv(my text);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
expect(vert['csv'].text).toBe('my text'); | ||
}); | ||
it('should handle v in node ids v in middle',function(){ | ||
expect(edges[0].type).toBe('arrow_cross') | ||
expect(vert['csv'].text).toBe('my text') | ||
}) | ||
it('should handle v in node ids v in middle', function () { | ||
// v in middle | ||
var res = flow.parser.parse('graph TD;A--xava(my text);'); | ||
var res = flow.parser.parse('graph TD;A--xava(my text);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
expect(vert['ava'].text).toBe('my text'); | ||
}); | ||
it('should handle v in node ids, v at start',function(){ | ||
expect(edges[0].type).toBe('arrow_cross') | ||
expect(vert['ava'].text).toBe('my text') | ||
}) | ||
it('should handle v in node ids, v at start', function () { | ||
// v at start | ||
var res = flow.parser.parse('graph TD;A--xva(my text);'); | ||
var res = flow.parser.parse('graph TD;A--xva(my text);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross') | ||
expect(vert['va'].text).toBe('my text') | ||
}) | ||
it('should handle keywords', function () { | ||
var res = flow.parser.parse('graph TD;A--x|text including graph space|B;') | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
expect(vert['va'].text).toBe('my text'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
}); | ||
it('should handle keywords',function(){ | ||
var res = flow.parser.parse('graph TD;A--x|text including graph space|B;'); | ||
expect(edges[0].text).toBe('text including graph space') | ||
}) | ||
it('should handle keywords', function () { | ||
var res = flow.parser.parse('graph TD;V-->a[v]') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['a'].text).toBe('v') | ||
}) | ||
it('should handle keywords', function () { | ||
var res = flow.parser.parse('graph TD;V-->a[v]') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['a'].text).toBe('v') | ||
}) | ||
it('should handle quoted text', function () { | ||
var res = flow.parser.parse('graph TD;V-- "test string()" -->a[v]') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].text).toBe('test string()') | ||
}) | ||
}) | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
describe('it should handle new line type notation', function () { | ||
it('it should handle regular lines', function () { | ||
var res = flow.parser.parse('graph TD;A-->B;') | ||
expect(edges[0].text).toBe('text including graph space'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
}); | ||
it('should handle keywords',function(){ | ||
var res = flow.parser.parse('graph TD;V-->a[v]'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['a'].text).toBe('v'); | ||
}); | ||
it('should handle keywords',function(){ | ||
var res = flow.parser.parse('graph TD;V-->a[v]'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['a'].text).toBe('v'); | ||
}); | ||
it('should handle quoted text',function(){ | ||
var res = flow.parser.parse('graph TD;V-- "test string()" -->a[v]'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].text).toBe('test string()'); | ||
}); | ||
}); | ||
expect(edges[0].stroke).toBe('normal') | ||
}) | ||
it('it should handle dotted lines', function () { | ||
var res = flow.parser.parse('graph TD;A-.->B;') | ||
describe('it should handle new line type notation',function() { | ||
it('it should handle regular lines', function () { | ||
var res = flow.parser.parse('graph TD;A-->B;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].stroke).toBe('dotted') | ||
}) | ||
it('it should handle dotted lines', function () { | ||
var res = flow.parser.parse('graph TD;A==>B;') | ||
expect(edges[0].stroke).toBe('normal'); | ||
}); | ||
it('it should handle dotted lines', function () { | ||
var res = flow.parser.parse('graph TD;A-.->B;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].stroke).toBe('thick') | ||
}) | ||
it('it should handle text on lines', function () { | ||
var res = flow.parser.parse('graph TD;A-- test text with == -->B;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].stroke).toBe('dotted'); | ||
}); | ||
it('it should handle dotted lines', function () { | ||
var res = flow.parser.parse('graph TD;A==>B;'); | ||
expect(edges[0].stroke).toBe('normal') | ||
}) | ||
it('it should handle text on lines', function () { | ||
var res = flow.parser.parse('graph TD;A-. test text with == .->B;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].stroke).toBe('dotted') | ||
}) | ||
it('it should handle text on lines', function () { | ||
var res = flow.parser.parse('graph TD;A== test text with - ==>B;') | ||
expect(edges[0].stroke).toBe('thick'); | ||
}); | ||
it('it should handle text on lines', function () { | ||
var res = flow.parser.parse('graph TD;A-- test text with == -->B;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].stroke).toBe('thick') | ||
}) | ||
}) | ||
describe('it should handle text on edges using the new notation', function () { | ||
it('it should handle text without space', function () { | ||
var res = flow.parser.parse('graph TD;A-- textNoSpace --xB;') | ||
expect(edges[0].stroke).toBe('normal'); | ||
}); | ||
it('it should handle text on lines', function () { | ||
var res = flow.parser.parse('graph TD;A-. test text with == .->B;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
}) | ||
it('it should handle text with multiple leading space', function () { | ||
var res = flow.parser.parse('graph TD;A-- textNoSpace --xB;') | ||
expect(edges[0].stroke).toBe('dotted'); | ||
}); | ||
it('it should handle text on lines', function () { | ||
var res = flow.parser.parse('graph TD;A== test text with - ==>B;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
}) | ||
it('should handle with space', function () { | ||
var res = flow.parser.parse('graph TD;A-- text including space --xB;') | ||
expect(edges[0].stroke).toBe('thick'); | ||
}); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
describe('it should handle text on edges using the new notation',function(){ | ||
it('it should handle text without space',function(){ | ||
var res = flow.parser.parse('graph TD;A-- textNoSpace --xB;'); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
}) | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
it('it should handle text with /', function () { | ||
var res = flow.parser.parse('graph TD;A -- text with / should work --x B;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
}); | ||
expect(edges[0].text).toBe('text with / should work') | ||
}) | ||
it('it should handle text with multiple leading space',function(){ | ||
var res = flow.parser.parse('graph TD;A-- textNoSpace --xB;'); | ||
it('it should handle space and space between vertices and link', function () { | ||
var res = flow.parser.parse('graph TD;A -- textNoSpace --x B;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross') | ||
}) | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
}); | ||
it('should handle space and CAPS', function () { | ||
var res = flow.parser.parse('graph TD;A-- text including CAPS space --xB;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('should handle with space',function(){ | ||
var res = flow.parser.parse('graph TD;A-- text including space --xB;'); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
}) | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
it('should handle space and dir', function () { | ||
var res = flow.parser.parse('graph TD;A-- text including URL space --xB;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
}); | ||
expect(edges[0].type).toBe('arrow_cross') | ||
expect(edges[0].text).toBe('text including URL space') | ||
}) | ||
it('it should handle text with /',function(){ | ||
var res = flow.parser.parse('graph TD;A -- text with / should work --x B;'); | ||
it('should handle space and dir (TD)', function () { | ||
var res = flow.parser.parse('graph TD;A-- text including R TD space --xB;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross') | ||
expect(edges[0].text).toBe('text including R TD space') | ||
}) | ||
it('should handle keywords', function () { | ||
var res = flow.parser.parse('graph TD;A-- text including graph space and v --xB;') | ||
expect(edges[0].text).toBe('text with / should work'); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('it should handle space and space between vertices and link',function(){ | ||
var res = flow.parser.parse('graph TD;A -- textNoSpace --x B;'); | ||
expect(edges[0].text).toBe('text including graph space and v') | ||
}) | ||
it('should handle keywords', function () { | ||
var res = flow.parser.parse('graph TD;A-- text including graph space and v --xB[blav]') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
}); | ||
it('should handle space and CAPS',function(){ | ||
var res = flow.parser.parse('graph TD;A-- text including CAPS space --xB;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
}); | ||
it('should handle space and dir',function(){ | ||
var res = flow.parser.parse('graph TD;A-- text including URL space --xB;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
expect(edges[0].text).toBe('text including URL space'); | ||
}); | ||
it('should handle space and dir (TD)',function(){ | ||
var res = flow.parser.parse('graph TD;A-- text including R TD space --xB;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].type).toBe('arrow_cross'); | ||
expect(edges[0].text).toBe('text including R TD space'); | ||
}); | ||
it('should handle keywords',function(){ | ||
var res = flow.parser.parse('graph TD;A-- text including graph space and v --xB;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].text).toBe('text including graph space and v'); | ||
}); | ||
it('should handle keywords',function(){ | ||
var res = flow.parser.parse('graph TD;A-- text including graph space and v --xB[blav]'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(edges[0].text).toBe('text including graph space and v'); | ||
}); | ||
//xit('should handle text on open links',function(){ | ||
expect(edges[0].text).toBe('text including graph space and v') | ||
}) | ||
// xit('should handle text on open links',function(){ | ||
// var res = flow.parser.parse('graph TD;A-- text including graph space --B'); | ||
@@ -908,165 +831,160 @@ // | ||
// | ||
//}); | ||
}); | ||
// }); | ||
}) | ||
it('should handle multi-line text', function () { | ||
var res = flow.parser.parse('graph TD;A--o|text space|B;\n B-->|more text with space|C;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges[0].type).toBe('arrow_circle') | ||
expect(edges[1].type).toBe('arrow') | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(vert['C'].id).toBe('C') | ||
expect(edges.length).toBe(2) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
// expect(edges[0].text).toBe('text space'); | ||
expect(edges[1].start).toBe('B') | ||
expect(edges[1].end).toBe('C') | ||
expect(edges[1].text).toBe('more text with space') | ||
}) | ||
it('should handle multi-line text',function(){ | ||
var res = flow.parser.parse('graph TD;A--o|text space|B;\n B-->|more text with space|C;'); | ||
it('should handle multiple edges', function () { | ||
var res = flow.parser.parse('graph TD;A---|This is the 123 s text|B;\nA---|This is the second edge|B;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(edges.length).toBe(2) | ||
expect(edges[0].start).toBe('A') | ||
expect(edges[0].end).toBe('B') | ||
expect(edges[0].text).toBe('This is the 123 s text') | ||
expect(edges[1].start).toBe('A') | ||
expect(edges[1].end).toBe('B') | ||
expect(edges[1].text).toBe('This is the second edge') | ||
}) | ||
expect(edges[0].type).toBe('arrow_circle'); | ||
expect(edges[1].type).toBe('arrow'); | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(vert['C'].id).toBe('C'); | ||
expect(edges.length).toBe(2); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
//expect(edges[0].text).toBe('text space'); | ||
expect(edges[1].start).toBe('B'); | ||
expect(edges[1].end).toBe('C'); | ||
expect(edges[1].text).toBe('more text with space'); | ||
}); | ||
it('should handle text in vertices with space', function () { | ||
var res = flow.parser.parse('graph TD;A[chimpansen hoppar]-->C;') | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('should handle multiple edges',function(){ | ||
var res = flow.parser.parse('graph TD;A---|This is the 123 s text|B;\nA---|This is the second edge|B;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].type).toBe('square') | ||
expect(vert['A'].text).toBe('chimpansen hoppar') | ||
}) | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(edges.length).toBe(2); | ||
expect(edges[0].start).toBe('A'); | ||
expect(edges[0].end).toBe('B'); | ||
expect(edges[0].text).toBe('This is the 123 s text'); | ||
expect(edges[1].start).toBe('A'); | ||
expect(edges[1].end).toBe('B'); | ||
expect(edges[1].text).toBe('This is the second edge'); | ||
}); | ||
it('should handle text in vertices with space with spaces between vertices and link', function () { | ||
var res = flow.parser.parse('graph TD;A[chimpansen hoppar] --> C;') | ||
it('should handle text in vertices with space',function(){ | ||
var res = flow.parser.parse('graph TD;A[chimpansen hoppar]-->C;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].type).toBe('square') | ||
expect(vert['A'].text).toBe('chimpansen hoppar') | ||
}) | ||
expect(vert['A'].type).toBe('square'); | ||
expect(vert['A'].text).toBe('chimpansen hoppar'); | ||
}); | ||
it('should handle quoted text in vertices ', function () { | ||
var res = flow.parser.parse('graph TD;A["chimpansen hoppar ()[]"] --> C;') | ||
it('should handle text in vertices with space with spaces between vertices and link',function(){ | ||
var res = flow.parser.parse('graph TD;A[chimpansen hoppar] --> C;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].type).toBe('square') | ||
expect(vert['A'].text).toBe('chimpansen hoppar ()[]') | ||
}) | ||
expect(vert['A'].type).toBe('square'); | ||
expect(vert['A'].text).toBe('chimpansen hoppar'); | ||
}); | ||
it('should handle text in circle vertices with space', function () { | ||
var res = flow.parser.parse('graph TD;A((chimpansen hoppar))-->C;') | ||
it('should handle quoted text in vertices ',function(){ | ||
var res = flow.parser.parse('graph TD;A["chimpansen hoppar ()[]"] --> C;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].type).toBe('circle') | ||
expect(vert['A'].text).toBe('chimpansen hoppar') | ||
}) | ||
expect(vert['A'].type).toBe('square'); | ||
expect(vert['A'].text).toBe('chimpansen hoppar ()[]'); | ||
}); | ||
it('should handle text in ellipse vertices', function () { | ||
var res = flow.parser.parse('graph TD\nA(-this is an ellipse-)-->B') | ||
it('should handle text in circle vertices with space',function(){ | ||
var res = flow.parser.parse('graph TD;A((chimpansen hoppar))-->C;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].type).toBe('ellipse') | ||
expect(vert['A'].text).toBe('this is an ellipse') | ||
}) | ||
expect(vert['A'].type).toBe('circle'); | ||
expect(vert['A'].text).toBe('chimpansen hoppar'); | ||
}); | ||
it('should handle text in diamond vertices with space', function () { | ||
var res = flow.parser.parse('graph TD;A(chimpansen hoppar)-->C;') | ||
it('should handle text in ellipse vertices', function(){ | ||
var res = flow.parser.parse('graph TD\nA(-this is an ellipse-)-->B'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].type).toBe('round') | ||
expect(vert['A'].text).toBe('chimpansen hoppar') | ||
}) | ||
expect(vert['A'].type).toBe('ellipse'); | ||
expect(vert['A'].text).toBe('this is an ellipse'); | ||
}); | ||
it('should handle text in with ?', function () { | ||
var res = flow.parser.parse('graph TD;A(?)-->|?|C;') | ||
it('should handle text in diamond vertices with space',function(){ | ||
var res = flow.parser.parse('graph TD;A(chimpansen hoppar)-->C;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].text).toBe('?') | ||
expect(edges[0].text).toBe('?') | ||
}) | ||
it('should handle text in with éèêàçô', function () { | ||
var res = flow.parser.parse('graph TD;A(éèêàçô)-->|éèêàçô|C;') | ||
expect(vert['A'].type).toBe('round'); | ||
expect(vert['A'].text).toBe('chimpansen hoppar'); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('should handle text in with ?',function(){ | ||
var res = flow.parser.parse('graph TD;A(?)-->|?|C;'); | ||
expect(vert['A'].text).toBe('éèêàçô') | ||
expect(edges[0].text).toBe('éèêàçô') | ||
}) | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
it('should handle text in with ,.?!+-*', function () { | ||
var res = flow.parser.parse('graph TD;A(,.?!+-*)-->|,.?!+-*|C;') | ||
expect(vert['A'].text).toBe('?'); | ||
expect(edges[0].text).toBe('?'); | ||
}); | ||
it('should handle text in with éèêàçô',function(){ | ||
var res = flow.parser.parse('graph TD;A(éèêàçô)-->|éèêàçô|C;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['A'].text).toBe(',.?!+-*') | ||
expect(edges[0].text).toBe(',.?!+-*') | ||
}) | ||
expect(vert['A'].text).toBe('éèêàçô'); | ||
expect(edges[0].text).toBe('éèêàçô'); | ||
}); | ||
describe('it should handle text in vertices, ', function () { | ||
it('it should handle space', function () { | ||
var res = flow.parser.parse('graph TD;A-->C(Chimpansen hoppar);') | ||
it('should handle text in with ,.?!+-*',function(){ | ||
var res = flow.parser.parse('graph TD;A(,.?!+-*)-->|,.?!+-*|C;'); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['C'].type).toBe('round') | ||
expect(vert['C'].text).toBe('Chimpansen hoppar') | ||
}) | ||
it('it should handle åäö and minus', function () { | ||
var res = flow.parser.parse('graph TD;A-->C{Chimpansen hoppar åäö-ÅÄÖ};') | ||
expect(vert['A'].text).toBe(',.?!+-*'); | ||
expect(edges[0].text).toBe(',.?!+-*'); | ||
}); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
describe('it should handle text in vertices, ',function(){ | ||
expect(vert['C'].type).toBe('diamond') | ||
expect(vert['C'].text).toBe('Chimpansen hoppar åäö-ÅÄÖ') | ||
}) | ||
it('it should handle space',function(){ | ||
var res = flow.parser.parse('graph TD;A-->C(Chimpansen hoppar);'); | ||
it('it should handle with åäö, minus and space and br', function () { | ||
var res = flow.parser.parse('graph TD;A-->C(Chimpansen hoppar åäö <br> - ÅÄÖ);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['C'].type).toBe('round'); | ||
expect(vert['C'].text).toBe('Chimpansen hoppar'); | ||
}); | ||
it('it should handle åäö and minus',function(){ | ||
var res = flow.parser.parse('graph TD;A-->C{Chimpansen hoppar åäö-ÅÄÖ};'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['C'].type).toBe('diamond'); | ||
expect(vert['C'].text).toBe('Chimpansen hoppar åäö-ÅÄÖ'); | ||
}); | ||
it('it should handle with åäö, minus and space and br',function(){ | ||
var res = flow.parser.parse('graph TD;A-->C(Chimpansen hoppar åäö <br> - ÅÄÖ);'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
expect(vert['C'].type).toBe('round'); | ||
expect(vert['C'].text).toBe('Chimpansen hoppar åäö <br> - ÅÄÖ'); | ||
}); | ||
//xit('it should handle åäö, minus and space and br',function(){ | ||
expect(vert['C'].type).toBe('round') | ||
expect(vert['C'].text).toBe('Chimpansen hoppar åäö <br> - ÅÄÖ') | ||
}) | ||
// xit('it should handle åäö, minus and space and br',function(){ | ||
// var res = flow.parser.parse('graph TD; A[Object(foo,bar)]-->B(Thing);'); | ||
@@ -1079,354 +997,351 @@ // | ||
// expect(vert['C'].text).toBe(' A[Object(foo,bar)]-->B(Thing);'); | ||
//}); | ||
it('it should handle unicode chars',function(){ | ||
var res = flow.parser.parse('graph TD;A-->C(Начало);'); | ||
// }); | ||
it('it should handle unicode chars', function () { | ||
var res = flow.parser.parse('graph TD;A-->C(Начало);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var vert = flow.parser.yy.getVertices() | ||
expect(vert['C'].text).toBe('Начало'); | ||
}); | ||
it('it should handle backslask',function(){ | ||
var res = flow.parser.parse('graph TD;A-->C(c:\\windows);'); | ||
expect(vert['C'].text).toBe('Начало') | ||
}) | ||
it('it should handle backslask', function () { | ||
var res = flow.parser.parse('graph TD;A-->C(c:\\windows);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var vert = flow.parser.yy.getVertices() | ||
expect(vert['C'].text).toBe('c:\\windows'); | ||
}); | ||
it('it should handle CAPS',function(){ | ||
var res = flow.parser.parse('graph TD;A-->C(some CAPS);'); | ||
expect(vert['C'].text).toBe('c:\\windows') | ||
}) | ||
it('it should handle CAPS', function () { | ||
var res = flow.parser.parse('graph TD;A-->C(some CAPS);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['C'].type).toBe('round'); | ||
expect(vert['C'].text).toBe('some CAPS'); | ||
}); | ||
it('it should handle directions',function(){ | ||
var res = flow.parser.parse('graph TD;A-->C(some URL);'); | ||
expect(vert['C'].type).toBe('round') | ||
expect(vert['C'].text).toBe('some CAPS') | ||
}) | ||
it('it should handle directions', function () { | ||
var res = flow.parser.parse('graph TD;A-->C(some URL);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['C'].type).toBe('round'); | ||
expect(vert['C'].text).toBe('some URL'); | ||
}); | ||
}); | ||
expect(vert['C'].type).toBe('round') | ||
expect(vert['C'].text).toBe('some URL') | ||
}) | ||
}) | ||
it('should handle a single node',function(){ | ||
it('should handle a single node', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;A;'); | ||
var res = flow.parser.parse('graph TD;A;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['A'].styles.length).toBe(0); | ||
}); | ||
expect(edges.length).toBe(0) | ||
expect(vert['A'].styles.length).toBe(0) | ||
}) | ||
it('should handle a single square node',function(){ | ||
it('should handle a single square node', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;a[A];'); | ||
var res = flow.parser.parse('graph TD;a[A];') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['a'].styles.length).toBe(0); | ||
expect(vert['a'].type).toBe('square'); | ||
}); | ||
it('should handle a single round square node',function(){ | ||
expect(edges.length).toBe(0) | ||
expect(vert['a'].styles.length).toBe(0) | ||
expect(vert['a'].type).toBe('square') | ||
}) | ||
it('should handle a single round square node', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;a[A];'); | ||
var res = flow.parser.parse('graph TD;a[A];') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['a'].styles.length).toBe(0); | ||
expect(vert['a'].type).toBe('square'); | ||
}); | ||
it('should handle a single circle node',function(){ | ||
expect(edges.length).toBe(0) | ||
expect(vert['a'].styles.length).toBe(0) | ||
expect(vert['a'].type).toBe('square') | ||
}) | ||
it('should handle a single circle node', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;a((A));'); | ||
var res = flow.parser.parse('graph TD;a((A));') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['a'].type).toBe('circle'); | ||
}); | ||
it('should handle a single round node',function(){ | ||
expect(edges.length).toBe(0) | ||
expect(vert['a'].type).toBe('circle') | ||
}) | ||
it('should handle a single round node', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;a(A);'); | ||
var res = flow.parser.parse('graph TD;a(A);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['a'].type).toBe('round'); | ||
}); | ||
it('should handle a single odd node',function(){ | ||
expect(edges.length).toBe(0) | ||
expect(vert['a'].type).toBe('round') | ||
}) | ||
it('should handle a single odd node', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;a>A];'); | ||
var res = flow.parser.parse('graph TD;a>A];') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['a'].type).toBe('odd'); | ||
}); | ||
it('should handle a single diamond node',function(){ | ||
expect(edges.length).toBe(0) | ||
expect(vert['a'].type).toBe('odd') | ||
}) | ||
it('should handle a single diamond node', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;a{A};'); | ||
var res = flow.parser.parse('graph TD;a{A};') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['a'].type).toBe('diamond'); | ||
}); | ||
it('should handle a single diamond node with html in it',function(){ | ||
expect(edges.length).toBe(0) | ||
expect(vert['a'].type).toBe('diamond') | ||
}) | ||
it('should handle a single diamond node with html in it', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;a{A <br> end};'); | ||
var res = flow.parser.parse('graph TD;a{A <br> end};') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['a'].type).toBe('diamond'); | ||
expect(vert['a'].text).toBe('A <br> end'); | ||
}); | ||
it('should handle a single round node with html in it',function(){ | ||
expect(edges.length).toBe(0) | ||
expect(vert['a'].type).toBe('diamond') | ||
expect(vert['a'].text).toBe('A <br> end') | ||
}) | ||
it('should handle a single round node with html in it', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;a(A <br> end);'); | ||
var res = flow.parser.parse('graph TD;a(A <br> end);') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['a'].type).toBe('round'); | ||
expect(vert['a'].text).toBe('A <br> end'); | ||
}); | ||
it('should handle a single node with alphanumerics starting on a char',function(){ | ||
expect(edges.length).toBe(0) | ||
expect(vert['a'].type).toBe('round') | ||
expect(vert['a'].text).toBe('A <br> end') | ||
}) | ||
it('should handle a single node with alphanumerics starting on a char', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;id1;'); | ||
var res = flow.parser.parse('graph TD;id1;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['id1'].styles.length).toBe(0); | ||
}); | ||
it('should handle a single node with alphanumerics starting on a num',function(){ | ||
expect(edges.length).toBe(0) | ||
expect(vert['id1'].styles.length).toBe(0) | ||
}) | ||
it('should handle a single node with alphanumerics starting on a num', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;1id;'); | ||
var res = flow.parser.parse('graph TD;1id;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['1id'].styles.length).toBe(0); | ||
}); | ||
it('should handle a single node with alphanumerics containing a minus sign',function(){ | ||
expect(edges.length).toBe(0) | ||
expect(vert['1id'].styles.length).toBe(0) | ||
}) | ||
it('should handle a single node with alphanumerics containing a minus sign', function () { | ||
// Silly but syntactically correct | ||
var res = flow.parser.parse('graph TD;i-d;'); | ||
var res = flow.parser.parse('graph TD;i-d;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(0); | ||
expect(vert['i-d'].styles.length).toBe(0); | ||
}); | ||
//log.debug(flow.parser.parse('graph TD;style Q background:#fff;')); | ||
it('should handle styles for vertices',function(){ | ||
var res = flow.parser.parse('graph TD;style Q background:#fff;'); | ||
expect(edges.length).toBe(0) | ||
expect(vert['i-d'].styles.length).toBe(0) | ||
}) | ||
// log.debug(flow.parser.parse('graph TD;style Q background:#fff;')); | ||
it('should handle styles for vertices', function () { | ||
var res = flow.parser.parse('graph TD;style Q background:#fff;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var style = vert['Q'].styles[0]; | ||
var style = vert['Q'].styles[0] | ||
expect(vert['Q'].styles.length).toBe(1); | ||
expect(vert['Q'].styles[0]).toBe('background:#fff'); | ||
}); | ||
expect(vert['Q'].styles.length).toBe(1) | ||
expect(vert['Q'].styles[0]).toBe('background:#fff') | ||
}) | ||
//log.debug(flow.parser.parse('graph TD;style Q background:#fff;')); | ||
it('should handle styles for edges',function(){ | ||
var res = flow.parser.parse('graph TD;a-->b;\nstyle #0 stroke: #f66;'); | ||
// log.debug(flow.parser.parse('graph TD;style Q background:#fff;')); | ||
it('should handle styles for edges', function () { | ||
var res = flow.parser.parse('graph TD;a-->b;\nstyle #0 stroke: #f66;') | ||
var edges = flow.parser.yy.getEdges(); | ||
var edges = flow.parser.yy.getEdges() | ||
expect(edges.length).toBe(1); | ||
}); | ||
expect(edges.length).toBe(1) | ||
}) | ||
it('should handle multiple styles for a vortex',function(){ | ||
var res = flow.parser.parse('graph TD;style R background:#fff,border:1px solid red;'); | ||
it('should handle multiple styles for a vortex', function () { | ||
var res = flow.parser.parse('graph TD;style R background:#fff,border:1px solid red;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['R'].styles.length).toBe(2); | ||
expect(vert['R'].styles[0]).toBe('background:#fff'); | ||
expect(vert['R'].styles[1]).toBe('border:1px solid red'); | ||
}); | ||
expect(vert['R'].styles.length).toBe(2) | ||
expect(vert['R'].styles[0]).toBe('background:#fff') | ||
expect(vert['R'].styles[1]).toBe('border:1px solid red') | ||
}) | ||
it('should handle multiple styles in a graph',function(){ | ||
var res = flow.parser.parse('graph TD;style S background:#aaa;\nstyle T background:#bbb,border:1px solid red;'); | ||
it('should handle multiple styles in a graph', function () { | ||
var res = flow.parser.parse('graph TD;style S background:#aaa;\nstyle T background:#bbb,border:1px solid red;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['S'].styles.length).toBe(1); | ||
expect(vert['T'].styles.length).toBe(2); | ||
expect(vert['S'].styles[0]).toBe('background:#aaa'); | ||
expect(vert['T'].styles[0]).toBe('background:#bbb'); | ||
expect(vert['T'].styles[1]).toBe('border:1px solid red'); | ||
}); | ||
expect(vert['S'].styles.length).toBe(1) | ||
expect(vert['T'].styles.length).toBe(2) | ||
expect(vert['S'].styles[0]).toBe('background:#aaa') | ||
expect(vert['T'].styles[0]).toBe('background:#bbb') | ||
expect(vert['T'].styles[1]).toBe('border:1px solid red') | ||
}) | ||
it('should handle styles and graph definitons in a graph',function(){ | ||
var res = flow.parser.parse('graph TD;S-->T;\nstyle S background:#aaa;\nstyle T background:#bbb,border:1px solid red;'); | ||
it('should handle styles and graph definitons in a graph', function () { | ||
var res = flow.parser.parse('graph TD;S-->T;\nstyle S background:#aaa;\nstyle T background:#bbb,border:1px solid red;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['S'].styles.length).toBe(1); | ||
expect(vert['T'].styles.length).toBe(2); | ||
expect(vert['S'].styles[0]).toBe('background:#aaa'); | ||
expect(vert['T'].styles[0]).toBe('background:#bbb'); | ||
expect(vert['T'].styles[1]).toBe('border:1px solid red'); | ||
}); | ||
it('should handle styles and graph definitons in a graph',function(){ | ||
var res = flow.parser.parse('graph TD;style T background:#bbb,border:1px solid red;'); | ||
//var res = flow.parser.parse('graph TD;style T background: #bbb;'); | ||
expect(vert['S'].styles.length).toBe(1) | ||
expect(vert['T'].styles.length).toBe(2) | ||
expect(vert['S'].styles[0]).toBe('background:#aaa') | ||
expect(vert['T'].styles[0]).toBe('background:#bbb') | ||
expect(vert['T'].styles[1]).toBe('border:1px solid red') | ||
}) | ||
it('should handle styles and graph definitons in a graph', function () { | ||
var res = flow.parser.parse('graph TD;style T background:#bbb,border:1px solid red;') | ||
// var res = flow.parser.parse('graph TD;style T background: #bbb;'); | ||
var vert = flow.parser.yy.getVertices(); | ||
var vert = flow.parser.yy.getVertices() | ||
expect(vert['T'].styles.length).toBe(2); | ||
expect(vert['T'].styles[0]).toBe('background:#bbb'); | ||
expect(vert['T'].styles[1]).toBe('border:1px solid red'); | ||
}); | ||
expect(vert['T'].styles.length).toBe(2) | ||
expect(vert['T'].styles[0]).toBe('background:#bbb') | ||
expect(vert['T'].styles[1]).toBe('border:1px solid red') | ||
}) | ||
describe('special characters should be be handled.',function(){ | ||
var charTest = function(char){ | ||
var res = flow.parser.parse('graph TD;A('+char+')-->B;'); | ||
describe('special characters should be be handled.', function () { | ||
var charTest = function (char) { | ||
var res = flow.parser.parse('graph TD;A(' + char + ')-->B;') | ||
var vert = flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var vert = flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
expect(vert['A'].id).toBe('A'); | ||
expect(vert['B'].id).toBe('B'); | ||
expect(vert['A'].text).toBe(char); | ||
}; | ||
expect(vert['A'].id).toBe('A') | ||
expect(vert['B'].id).toBe('B') | ||
expect(vert['A'].text).toBe(char) | ||
} | ||
it('it should be able to parse a \'.\'',function(){ | ||
charTest('.'); | ||
charTest('Start 103a.a1'); | ||
}); | ||
it('it should be able to parse a \'.\'', function () { | ||
charTest('.') | ||
charTest('Start 103a.a1') | ||
}) | ||
it('it should be able to parse text containing \'_\'',function(){ | ||
charTest('_'); | ||
}); | ||
it('it should be able to parse text containing \'_\'', function () { | ||
charTest('_') | ||
}) | ||
it('it should be able to parse a \':\'',function(){ | ||
charTest(':'); | ||
}); | ||
it('it should be able to parse a \':\'', function () { | ||
charTest(':') | ||
}) | ||
it('it should be able to parse a \',\'',function(){ | ||
charTest(','); | ||
}); | ||
it('it should be able to parse a \',\'', function () { | ||
charTest(',') | ||
}) | ||
it('it should be able to parse text containing \'-\'',function(){ | ||
charTest('a-b'); | ||
}); | ||
it('it should be able to parse text containing \'-\'', function () { | ||
charTest('a-b') | ||
}) | ||
it('it should be able to parse a \'+\'',function(){ | ||
charTest('+'); | ||
}); | ||
it('it should be able to parse a \'+\'', function () { | ||
charTest('+') | ||
}) | ||
it('it should be able to parse a \'*\'',function(){ | ||
charTest('*'); | ||
}); | ||
it('it should be able to parse a \'*\'', function () { | ||
charTest('*') | ||
}) | ||
it('it should be able to parse a \'<\'',function(){ | ||
charTest('<'); | ||
}); | ||
it('it should be able to parse a \'<\'', function () { | ||
charTest('<') | ||
}) | ||
it('it should be able to parse a \'>\'',function(){ | ||
charTest('>'); | ||
}); | ||
it('it should be able to parse a \'>\'', function () { | ||
charTest('>') | ||
}) | ||
it('it should be able to parse a \'=\'',function(){ | ||
charTest('='); | ||
}); | ||
it('it should be able to parse a \'=\'', function () { | ||
charTest('=') | ||
}) | ||
}) | ||
}); | ||
it('should be possible to declare a class', function () { | ||
var res = flow.parser.parse('graph TD;classDef exClass background:#bbb,border:1px solid red;') | ||
// var res = flow.parser.parse('graph TD;style T background: #bbb;'); | ||
it('should be possible to declare a class',function(){ | ||
var res = flow.parser.parse('graph TD;classDef exClass background:#bbb,border:1px solid red;'); | ||
//var res = flow.parser.parse('graph TD;style T background: #bbb;'); | ||
var classes = flow.parser.yy.getClasses() | ||
var classes = flow.parser.yy.getClasses(); | ||
expect(classes['exClass'].styles.length).toBe(2) | ||
expect(classes['exClass'].styles[0]).toBe('background:#bbb') | ||
expect(classes['exClass'].styles[1]).toBe('border:1px solid red') | ||
}) | ||
expect(classes['exClass'].styles.length).toBe(2); | ||
expect(classes['exClass'].styles[0]).toBe('background:#bbb'); | ||
expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); | ||
}); | ||
it('should be possible to declare a class with a dot in the style', function () { | ||
var res = flow.parser.parse('graph TD;classDef exClass background:#bbb,border:1.5px solid red;') | ||
// var res = flow.parser.parse('graph TD;style T background: #bbb;'); | ||
it('should be possible to declare a class with a dot in the style',function(){ | ||
var res = flow.parser.parse('graph TD;classDef exClass background:#bbb,border:1.5px solid red;'); | ||
//var res = flow.parser.parse('graph TD;style T background: #bbb;'); | ||
var classes = flow.parser.yy.getClasses() | ||
var classes = flow.parser.yy.getClasses(); | ||
expect(classes['exClass'].styles.length).toBe(2) | ||
expect(classes['exClass'].styles[0]).toBe('background:#bbb') | ||
expect(classes['exClass'].styles[1]).toBe('border:1.5px solid red') | ||
}) | ||
it('should be possible to declare a class with a space in the style', function () { | ||
var res = flow.parser.parse('graph TD;classDef exClass background: #bbb,border:1.5px solid red;') | ||
// var res = flow.parser.parse('graph TD;style T background : #bbb;'); | ||
expect(classes['exClass'].styles.length).toBe(2); | ||
expect(classes['exClass'].styles[0]).toBe('background:#bbb'); | ||
expect(classes['exClass'].styles[1]).toBe('border:1.5px solid red'); | ||
}); | ||
it('should be possible to declare a class with a space in the style',function(){ | ||
var res = flow.parser.parse('graph TD;classDef exClass background: #bbb,border:1.5px solid red;'); | ||
//var res = flow.parser.parse('graph TD;style T background : #bbb;'); | ||
var classes = flow.parser.yy.getClasses() | ||
var classes = flow.parser.yy.getClasses(); | ||
expect(classes['exClass'].styles.length).toBe(2) | ||
expect(classes['exClass'].styles[0]).toBe('background: #bbb') | ||
expect(classes['exClass'].styles[1]).toBe('border:1.5px solid red') | ||
}) | ||
it('should be possible to apply a class to a vertex', function () { | ||
var statement = '' | ||
expect(classes['exClass'].styles.length).toBe(2); | ||
expect(classes['exClass'].styles[0]).toBe('background: #bbb'); | ||
expect(classes['exClass'].styles[1]).toBe('border:1.5px solid red'); | ||
}); | ||
it('should be possible to apply a class to a vertex',function(){ | ||
var statement = ''; | ||
statement = statement + 'graph TD;' + '\n' | ||
statement = statement + 'classDef exClass background:#bbb,border:1px solid red;' + '\n' | ||
statement = statement + 'a-->b;' + '\n' | ||
statement = statement + 'class a exClass;' | ||
statement = statement + 'graph TD;' + '\n'; | ||
statement = statement + 'classDef exClass background:#bbb,border:1px solid red;' + '\n'; | ||
statement = statement + 'a-->b;' + '\n'; | ||
statement = statement + 'class a exClass;'; | ||
var res = flow.parser.parse(statement) | ||
var res = flow.parser.parse(statement); | ||
var classes = flow.parser.yy.getClasses() | ||
var classes = flow.parser.yy.getClasses(); | ||
expect(classes['exClass'].styles.length).toBe(2) | ||
expect(classes['exClass'].styles[0]).toBe('background:#bbb') | ||
expect(classes['exClass'].styles[1]).toBe('border:1px solid red') | ||
}) | ||
it('should be possible to apply a class to a comma separated list of vertices', function () { | ||
var statement = '' | ||
expect(classes['exClass'].styles.length).toBe(2); | ||
expect(classes['exClass'].styles[0]).toBe('background:#bbb'); | ||
expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); | ||
}); | ||
it('should be possible to apply a class to a comma separated list of vertices',function(){ | ||
var statement = ''; | ||
statement = statement + 'graph TD;' + '\n' | ||
statement = statement + 'classDef exClass background:#bbb,border:1px solid red;' + '\n' | ||
statement = statement + 'a-->b;' + '\n' | ||
statement = statement + 'class a,b exClass;' | ||
statement = statement + 'graph TD;' + '\n'; | ||
statement = statement + 'classDef exClass background:#bbb,border:1px solid red;' + '\n'; | ||
statement = statement + 'a-->b;' + '\n'; | ||
statement = statement + 'class a,b exClass;'; | ||
var res = flow.parser.parse(statement) | ||
var res = flow.parser.parse(statement); | ||
var classes = flow.parser.yy.getClasses() | ||
var vertices = flow.parser.yy.getVertices() | ||
var classes = flow.parser.yy.getClasses(); | ||
var vertices = flow.parser.yy.getVertices(); | ||
expect(classes['exClass'].styles.length).toBe(2); | ||
expect(classes['exClass'].styles[0]).toBe('background:#bbb'); | ||
expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); | ||
expect(vertices['a'].classes[0]).toBe('exClass'); | ||
expect(vertices['b'].classes[0]).toBe('exClass'); | ||
}); | ||
}); | ||
expect(classes['exClass'].styles.length).toBe(2) | ||
expect(classes['exClass'].styles[0]).toBe('background:#bbb') | ||
expect(classes['exClass'].styles[1]).toBe('border:1px solid red') | ||
expect(vertices['a'].classes[0]).toBe('exClass') | ||
expect(vertices['b'].classes[0]).toBe('exClass') | ||
}) | ||
}) |
@@ -0,55 +1,52 @@ | ||
/* eslint-env jasmine */ | ||
/** | ||
* Created by knut on 14-11-18. | ||
*/ | ||
describe('when parsing a gantt diagram it',function() { | ||
var gantt; | ||
beforeEach(function () { | ||
gantt = require('./parser/gantt').parser; | ||
gantt.yy = require('./ganttDb'); | ||
describe('when parsing a gantt diagram it', function () { | ||
var gantt | ||
beforeEach(function () { | ||
gantt = require('./parser/gantt').parser | ||
gantt.yy = require('./ganttDb') | ||
}) | ||
//ex.yy.parseError = parseError; | ||
}); | ||
it('should handle an dateFormat definition', function () { | ||
var str = 'gantt\ndateFormat yyyy-mm-dd' | ||
it('should handle an dateFormat definition', function () { | ||
var str = 'gantt\ndateFormat yyyy-mm-dd'; | ||
gantt.parse(str) | ||
}) | ||
it('should handle an dateFormat definition', function () { | ||
var str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid' | ||
gantt.parse(str); | ||
}); | ||
it('should handle an dateFormat definition', function () { | ||
var str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid'; | ||
gantt.parse(str) | ||
}) | ||
it('should handle an dateFormat definition', function () { | ||
var str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid' | ||
gantt.parse(str); | ||
}); | ||
it('should handle an dateFormat definition', function () { | ||
var str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid'; | ||
gantt.parse(str) | ||
}) | ||
it('should handle an section definition', function () { | ||
var str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid' | ||
gantt.parse(str); | ||
}); | ||
it('should handle an section definition', function () { | ||
var str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid'; | ||
gantt.parse(str) | ||
}) | ||
/** | ||
* Beslutsflöde inligt nedan. Obs bla bla bla | ||
* ``` | ||
* graph TD | ||
* A[Hard pledge] -- text on link -->B(Round edge) | ||
* B --> C{to do or not to do} | ||
* C -->|Too| D[Result one] | ||
* C -->|Doo| E[Result two] | ||
``` | ||
* params bapa - a unique bapap | ||
*/ | ||
it('should handle a task definition', function () { | ||
var str = 'gantt\n' + | ||
'dateFormat yyyy-mm-dd\n' + | ||
'title Adding gantt diagram functionality to mermaid\n' + | ||
'section Documentation\n' + | ||
'Design jison grammar:des1, 2014-01-01, 2014-01-04' | ||
gantt.parse(str); | ||
}); | ||
/** | ||
* Beslutsflöde inligt nedan. Obs bla bla bla | ||
* ``` | ||
* graph TD | ||
* A[Hard pledge] -- text on link -->B(Round edge) | ||
* B --> C{to do or not to do} | ||
* C -->|Too| D[Result one] | ||
* C -->|Doo| E[Result two] | ||
``` | ||
* params bapa - a unique bapap | ||
*/ | ||
it('should handle a task definition', function () { | ||
var str = 'gantt\n' + | ||
'dateFormat yyyy-mm-dd\n' + | ||
'title Adding gantt diagram functionality to mermaid\n' + | ||
'section Documentation\n' + | ||
'Design jison grammar:des1, 2014-01-01, 2014-01-04'; | ||
gantt.parse(str); | ||
}); | ||
}); | ||
// Ogiltigt id i after id | ||
gantt.parse(str) | ||
}) | ||
}) |
/** | ||
* Created by knut on 15-01-14. | ||
*/ | ||
var moment = require('moment'); | ||
var Logger = require('../../logger'); | ||
var log = new Logger.Log(); | ||
var moment = require('moment') | ||
var Logger = require('../../logger') | ||
var log = Logger.Log | ||
var dateFormat = '' | ||
var title = '' | ||
var sections = [] | ||
var tasks = [] | ||
var currentSection = '' | ||
var dateFormat = ''; | ||
var title = ''; | ||
var sections = []; | ||
var tasks = []; | ||
var currentSection = ''; | ||
exports.clear = function () { | ||
sections = [] | ||
tasks = [] | ||
currentSection = '' | ||
title = '' | ||
taskCnt = 0 | ||
lastTask = undefined | ||
lastTaskID = undefined | ||
rawTasks = [] | ||
} | ||
exports.clear = function(){ | ||
sections = []; | ||
tasks = []; | ||
currentSection = ''; | ||
title = ''; | ||
taskCnt = 0; | ||
lastTask = undefined; | ||
lastTaskID = undefined; | ||
rawTasks = []; | ||
}; | ||
exports.setDateFormat = function (txt) { | ||
dateFormat = txt | ||
} | ||
exports.setDateFormat = function(txt){ | ||
dateFormat = txt; | ||
}; | ||
exports.getDateFormat = function () { | ||
return dateFormat | ||
} | ||
exports.setTitle = function (txt) { | ||
title = txt | ||
} | ||
exports.getDateFormat = function(){ | ||
return dateFormat; | ||
}; | ||
exports.setTitle = function(txt){ | ||
title = txt; | ||
}; | ||
exports.getTitle = function () { | ||
return title | ||
} | ||
exports.getTitle = function(){ | ||
return title; | ||
}; | ||
exports.addSection = function (txt) { | ||
currentSection = txt | ||
sections.push(txt) | ||
} | ||
exports.addSection = function(txt){ | ||
currentSection = txt; | ||
sections.push(txt); | ||
}; | ||
exports.getTasks = function () { | ||
var allItemsPricessed = compileTasks() | ||
var maxDepth = 10 | ||
var iterationCount = 0 | ||
while (!allItemsPricessed && (iterationCount < maxDepth)) { | ||
allItemsPricessed = compileTasks() | ||
iterationCount++ | ||
} | ||
tasks = rawTasks | ||
exports.getTasks=function(){ | ||
var allItemsPricessed = compileTasks(); | ||
var maxDepth = 10; | ||
var iterationCount = 0; | ||
while(!allItemsPricessed && (iterationCount < maxDepth)){ | ||
allItemsPricessed = compileTasks(); | ||
iterationCount++; | ||
} | ||
return tasks | ||
} | ||
tasks = rawTasks; | ||
var getStartDate = function (prevTime, dateFormat, str) { | ||
str = str.trim() | ||
//var i; | ||
//for(i=10000;i<tasks.length;i++){ | ||
// tasks[i].startTime = moment(tasks[i].startTime).format(dateFormat); | ||
// tasks[i].endTime = moment(tasks[i].endTime).format(dateFormat); | ||
//} | ||
// Test for after | ||
var re = /^after\s+([\d\w-]+)/ | ||
var afterStatement = re.exec(str.trim()) | ||
return tasks; | ||
}; | ||
if (afterStatement !== null) { | ||
var task = exports.findTaskById(afterStatement[1]) | ||
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); | ||
str = str.trim(); | ||
// Test for after | ||
var re = /^after\s+([\d\w\-]+)/; | ||
var afterStatement = re.exec(str.trim()); | ||
if(afterStatement!==null){ | ||
var task = exports.findTaskById(afterStatement[1]); | ||
if(typeof task === 'undefined'){ | ||
var dt = new Date(); | ||
dt.setHours(0,0,0,0); | ||
return dt; | ||
//return undefined; | ||
} | ||
return task.endTime; | ||
if (typeof task === 'undefined') { | ||
var dt = new Date() | ||
dt.setHours(0, 0, 0, 0) | ||
return dt | ||
} | ||
return task.endTime | ||
} | ||
// Check for actual date set | ||
if(moment(str,dateFormat.trim(),true).isValid()){ | ||
return moment(str,dateFormat.trim(),true).toDate(); | ||
}else{ | ||
log.debug('Invalid date:'+str); | ||
log.debug('With date format:'+dateFormat.trim()); | ||
//log.debug('----'); | ||
} | ||
// Check for actual date set | ||
if (moment(str, dateFormat.trim(), true).isValid()) { | ||
return moment(str, dateFormat.trim(), true).toDate() | ||
} else { | ||
log.debug('Invalid date:' + str) | ||
log.debug('With date format:' + dateFormat.trim()) | ||
} | ||
// Default date - now | ||
return new Date(); | ||
}; | ||
// Default date - now | ||
return new Date() | ||
} | ||
var getEndDate = function(prevTime, dateFormat, str){ | ||
str = str.trim(); | ||
var getEndDate = function (prevTime, dateFormat, str) { | ||
str = str.trim() | ||
// Check for actual date | ||
if(moment(str,dateFormat.trim(),true).isValid()){ | ||
// Check for actual date | ||
if (moment(str, dateFormat.trim(), true).isValid()) { | ||
return moment(str, dateFormat.trim()).toDate() | ||
} | ||
return moment(str,dateFormat.trim()).toDate(); | ||
} | ||
var d = moment(prevTime) | ||
// Check for length | ||
var re = /^([\d]+)([wdhms])/ | ||
var durationStatement = re.exec(str.trim()) | ||
var d = moment(prevTime); | ||
// Check for length | ||
var re = /^([\d]+)([wdhms])/; | ||
var durationStatement = re.exec(str.trim()); | ||
if(durationStatement!== null){ | ||
switch(durationStatement[2]){ | ||
case 's': | ||
d.add(durationStatement[1], 'seconds'); | ||
break; | ||
case 'm': | ||
d.add(durationStatement[1], 'minutes'); | ||
break; | ||
case 'h': | ||
d.add(durationStatement[1], 'hours'); | ||
break; | ||
case 'd': | ||
d.add(durationStatement[1], 'days'); | ||
break; | ||
case 'w': | ||
d.add(durationStatement[1], 'weeks'); | ||
break; | ||
} | ||
return d.toDate(); | ||
if (durationStatement !== null) { | ||
switch (durationStatement[2]) { | ||
case 's': | ||
d.add(durationStatement[1], 'seconds') | ||
break | ||
case 'm': | ||
d.add(durationStatement[1], 'minutes') | ||
break | ||
case 'h': | ||
d.add(durationStatement[1], 'hours') | ||
break | ||
case 'd': | ||
d.add(durationStatement[1], 'days') | ||
break | ||
case 'w': | ||
d.add(durationStatement[1], 'weeks') | ||
break | ||
} | ||
// Default date - now | ||
return d.toDate(); | ||
}; | ||
return d.toDate() | ||
} | ||
// Default date - now | ||
return d.toDate() | ||
} | ||
var taskCnt = 0; | ||
var parseId = function(idStr){ | ||
if(typeof idStr === 'undefined'){ | ||
taskCnt = taskCnt + 1; | ||
return 'task'+taskCnt; | ||
} | ||
return idStr; | ||
}; | ||
var taskCnt = 0 | ||
var parseId = function (idStr) { | ||
if (typeof idStr === 'undefined') { | ||
taskCnt = taskCnt + 1 | ||
return 'task' + taskCnt | ||
} | ||
return idStr | ||
} | ||
// id, startDate, endDate | ||
@@ -161,239 +145,215 @@ // id, startDate, length | ||
var compileData = function(prevTask, dataStr){ | ||
var ds; | ||
var compileData = function (prevTask, dataStr) { | ||
var ds | ||
if(dataStr.substr(0,1) === ':'){ | ||
ds = dataStr.substr(1,dataStr.length); | ||
} | ||
else{ | ||
ds=dataStr; | ||
} | ||
if (dataStr.substr(0, 1) === ':') { | ||
ds = dataStr.substr(1, dataStr.length) | ||
} else { | ||
ds = dataStr | ||
} | ||
var data = ds.split(','); | ||
var data = ds.split(',') | ||
var task = {} | ||
var df = exports.getDateFormat() | ||
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; | ||
} | ||
// 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 | ||
} | ||
var i; | ||
for(i=0;i<data.length;i++){ | ||
data[i] = data[i].trim(); | ||
if (data[0].match(/^\s*done\s*$/)) { | ||
task.done = true | ||
data.shift(1) | ||
matchFound = true | ||
} | ||
switch(data.length){ | ||
case 1: | ||
task.id = parseId(); | ||
task.startTime = prevTask.endTime; | ||
task.endTime = getEndDate(task.startTime, df, data[0]); | ||
break; | ||
case 2: | ||
task.id = parseId(); | ||
task.startTime = getStartDate(undefined, df, data[0]); | ||
task.endTime = getEndDate(task.startTime, df, data[1]); | ||
break; | ||
case 3: | ||
task.id = parseId(data[0]); | ||
task.startTime = getStartDate(undefined, df, data[1]); | ||
task.endTime = getEndDate(task.startTime, df, data[2]); | ||
break; | ||
default: | ||
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() | ||
} | ||
return task; | ||
}; | ||
switch (data.length) { | ||
case 1: | ||
task.id = parseId() | ||
task.startTime = prevTask.endTime | ||
task.endTime = getEndDate(task.startTime, df, data[0]) | ||
break | ||
case 2: | ||
task.id = parseId() | ||
task.startTime = getStartDate(undefined, df, data[0]) | ||
task.endTime = getEndDate(task.startTime, df, data[1]) | ||
break | ||
case 3: | ||
task.id = parseId(data[0]) | ||
task.startTime = getStartDate(undefined, df, data[1]) | ||
task.endTime = getEndDate(task.startTime, df, data[2]) | ||
break | ||
default: | ||
} | ||
var parseData = function(prevTaskId, dataStr){ | ||
var ds; | ||
return task | ||
} | ||
if(dataStr.substr(0,1) === ':'){ | ||
ds = dataStr.substr(1,dataStr.length); | ||
} | ||
else{ | ||
ds=dataStr; | ||
} | ||
var parseData = function (prevTaskId, dataStr) { | ||
var ds | ||
var data = ds.split(','); | ||
if (dataStr.substr(0, 1) === ':') { | ||
ds = dataStr.substr(1, dataStr.length) | ||
} else { | ||
ds = dataStr | ||
} | ||
var data = ds.split(',') | ||
var task = {}; | ||
var task = {} | ||
// 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; | ||
} | ||
// 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 | ||
} | ||
var i; | ||
for(i=0;i<data.length;i++){ | ||
data[i] = data[i].trim(); | ||
if (data[0].match(/^\s*done\s*$/)) { | ||
task.done = true | ||
data.shift(1) | ||
matchFound = true | ||
} | ||
switch(data.length){ | ||
case 1: | ||
task.id = parseId(); | ||
task.startTime = {type: 'prevTaskEnd', id:prevTaskId}; | ||
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: | ||
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() | ||
} | ||
return task; | ||
}; | ||
switch (data.length) { | ||
case 1: | ||
task.id = parseId() | ||
task.startTime = { type: 'prevTaskEnd', id: prevTaskId } | ||
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.addTask = function (descr, data) { | ||
var rawTask = { | ||
section: currentSection, | ||
type: currentSection, | ||
processed: false, | ||
raw: { data: data }, | ||
task: descr | ||
} | ||
var taskInfo = parseData(lastTaskID, 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 lastTask; | ||
var lastTaskID; | ||
var rawTasks = []; | ||
var taskDb = {}; | ||
exports.addTask = function(descr,data){ | ||
var rawTask = { | ||
section:currentSection, | ||
type:currentSection, | ||
processed:false, | ||
raw:{data:data}, | ||
task:descr | ||
}; | ||
var taskInfo = parseData(lastTaskID, 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) | ||
var pos = rawTasks.push(rawTask); | ||
lastTaskID = rawTask.id | ||
// Store cross ref | ||
taskDb[rawTask.id] = pos - 1 | ||
} | ||
lastTaskID = rawTask.id; | ||
// Store cross ref | ||
taskDb[rawTask.id]= pos-1; | ||
exports.findTaskById = function (id) { | ||
var pos = taskDb[id] | ||
return rawTasks[pos] | ||
} | ||
}; | ||
exports.addTaskOrg = function (descr, data) { | ||
var newTask = { | ||
section: currentSection, | ||
type: currentSection, | ||
description: descr, | ||
task: descr | ||
} | ||
var taskInfo = compileData(lastTask, data) | ||
newTask.startTime = taskInfo.startTime | ||
newTask.endTime = taskInfo.endTime | ||
newTask.id = taskInfo.id | ||
newTask.active = taskInfo.active | ||
newTask.done = taskInfo.done | ||
newTask.crit = taskInfo.crit | ||
lastTask = newTask | ||
tasks.push(newTask) | ||
} | ||
var compileTasks = function () { | ||
var df = exports.getDateFormat() | ||
exports.findTaskById = function(id) { | ||
//var i; | ||
//for(i=0;i<tasks.length;i++){ | ||
// if(tasks[i].id === id){ | ||
// return tasks[i]; | ||
// } | ||
//} | ||
var pos = taskDb[id]; | ||
return rawTasks[pos]; | ||
}; | ||
exports.addTaskOrg = function(descr,data){ | ||
var newTask = { | ||
section:currentSection, | ||
type:currentSection, | ||
description:descr, | ||
task:descr | ||
}; | ||
var taskInfo = compileData(lastTask, data); | ||
newTask.startTime = taskInfo.startTime; | ||
newTask.endTime = taskInfo.endTime; | ||
newTask.id = taskInfo.id; | ||
newTask.active = taskInfo.active; | ||
newTask.done = taskInfo.done; | ||
newTask.crit = taskInfo.crit; | ||
lastTask = newTask; | ||
tasks.push(newTask); | ||
}; | ||
var compileTasks=function(){ | ||
var df = exports.getDateFormat(); | ||
var compileTask = function(pos){ | ||
var task = rawTasks[pos]; | ||
var startTime = ''; | ||
switch(rawTasks[pos].raw.startTime.type){ | ||
case 'prevTaskEnd': | ||
var prevTask = exports.findTaskById(task.prevTaskId); | ||
task.startTime = prevTask.endTime; | ||
break; | ||
case 'getStartDate': | ||
startTime = getStartDate(undefined, df, rawTasks[pos].raw.startTime.startData); | ||
if(startTime){ | ||
rawTasks[pos].startTime = startTime; | ||
} | ||
break; | ||
var compileTask = function (pos) { | ||
var task = rawTasks[pos] | ||
var startTime = '' | ||
switch (rawTasks[pos].raw.startTime.type) { | ||
case 'prevTaskEnd': | ||
var prevTask = exports.findTaskById(task.prevTaskId) | ||
task.startTime = prevTask.endTime | ||
break | ||
case 'getStartDate': | ||
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); | ||
if(rawTasks[pos].endTime){ | ||
rawTasks[pos].processed = true; | ||
} | ||
} | ||
if (rawTasks[pos].startTime) { | ||
rawTasks[pos].endTime = getEndDate(rawTasks[pos].startTime, df, rawTasks[pos].raw.endTime.data) | ||
if (rawTasks[pos].endTime) { | ||
rawTasks[pos].processed = true | ||
} | ||
} | ||
return rawTasks[pos].processed; | ||
return rawTasks[pos].processed | ||
} | ||
}; | ||
var i | ||
var allProcessed = true | ||
for (i = 0; i < rawTasks.length; i++) { | ||
compileTask(i) | ||
var i; | ||
var allProcessed = true; | ||
for(i=0;i<rawTasks.length;i++){ | ||
compileTask(i); | ||
allProcessed = allProcessed && rawTasks[i].processed | ||
} | ||
return allProcessed | ||
} | ||
allProcessed = allProcessed && rawTasks[i].processed; | ||
} | ||
return allProcessed; | ||
}; | ||
exports.parseError = function(err,hash){ | ||
global.mermaidAPI.parseError(err,hash); | ||
}; | ||
exports.parseError = function (err, hash) { | ||
global.mermaidAPI.parseError(err, hash) | ||
} |
@@ -0,184 +1,179 @@ | ||
/* eslint-env jasmine */ | ||
/** | ||
* Created by knut on 14-11-18. | ||
*/ | ||
describe('when using the ganttDb',function() { | ||
var gDb; | ||
var moment = require('moment'); | ||
beforeEach(function () { | ||
//gantt = require('./parser/gantt').parser; | ||
describe('when using the ganttDb', function () { | ||
var gDb | ||
var moment = require('moment') | ||
gDb = require('./ganttDb'); | ||
gDb.clear(); | ||
//ex.yy.parseError = parseError; | ||
}); | ||
beforeEach(function () { | ||
gDb = require('./ganttDb') | ||
gDb.clear() | ||
}) | ||
it('should handle an fixed dates', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2013-01-12'); | ||
var tasks = gDb.getTasks(); | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].endTime ).toEqual(moment('2013-01-12', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].id ).toEqual('id1'); | ||
expect(tasks[0].task).toEqual('test1'); | ||
}); | ||
it('should handle duration (days) instead of fixed date to determine end date', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2d'); | ||
var tasks = gDb.getTasks(); | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].endTime ).toEqual(moment('2013-01-03', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].id ).toEqual('id1'); | ||
expect(tasks[0].task).toEqual('test1'); | ||
}); | ||
it('should handle duration (hours) instead of fixed date to determine end date', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2h'); | ||
var tasks = gDb.getTasks(); | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].endTime ).toEqual(moment('2013-01-01 2:00', 'YYYY-MM-DD hh:mm').toDate()); | ||
expect(tasks[0].id ).toEqual('id1'); | ||
expect(tasks[0].task).toEqual('test1'); | ||
}); | ||
it('should handle duration (minutes) instead of fixed date to determine end date', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2m'); | ||
var tasks = gDb.getTasks(); | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].endTime ).toEqual(moment('2013-01-01 00:02', 'YYYY-MM-DD hh:mm').toDate()); | ||
expect(tasks[0].id ).toEqual('id1'); | ||
expect(tasks[0].task).toEqual('test1'); | ||
}); | ||
it('should handle duration (seconds) instead of fixed date to determine end date', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2s'); | ||
var tasks = gDb.getTasks(); | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].endTime ).toEqual(moment('2013-01-01 00:00:02', 'YYYY-MM-DD hh:mm:ss').toDate()); | ||
expect(tasks[0].id ).toEqual('id1'); | ||
expect(tasks[0].task).toEqual('test1'); | ||
}); | ||
it('should handle duration (weeks) instead of fixed date to determine end date', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2w'); | ||
var tasks = gDb.getTasks(); | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].endTime ).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].id ).toEqual('id1'); | ||
expect(tasks[0].task).toEqual('test1'); | ||
}); | ||
it('should handle relative start date based on id', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2w'); | ||
gDb.addTask('test2','id2,after id1,1d'); | ||
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].task).toEqual('test2'); | ||
}); | ||
it('should handle relative start date based on id when id is invalid', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2w'); | ||
gDb.addTask('test2','id2,after id3,1d'); | ||
var tasks = gDb.getTasks(); | ||
expect(tasks[1].startTime).toEqual(new Date((new Date()).setHours(0,0,0,0))); | ||
expect(tasks[1].id ).toEqual('id2'); | ||
expect(tasks[1].task).toEqual('test2'); | ||
}); | ||
it('should handle an fixed dates', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2013-01-12') | ||
var tasks = gDb.getTasks() | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].endTime).toEqual(moment('2013-01-12', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].id).toEqual('id1') | ||
expect(tasks[0].task).toEqual('test1') | ||
}) | ||
it('should handle duration (days) instead of fixed date to determine end date', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2d') | ||
var tasks = gDb.getTasks() | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].endTime).toEqual(moment('2013-01-03', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].id).toEqual('id1') | ||
expect(tasks[0].task).toEqual('test1') | ||
}) | ||
it('should handle duration (hours) instead of fixed date to determine end date', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2h') | ||
var tasks = gDb.getTasks() | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].endTime).toEqual(moment('2013-01-01 2:00', 'YYYY-MM-DD hh:mm').toDate()) | ||
expect(tasks[0].id).toEqual('id1') | ||
expect(tasks[0].task).toEqual('test1') | ||
}) | ||
it('should handle duration (minutes) instead of fixed date to determine end date', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2m') | ||
var tasks = gDb.getTasks() | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].endTime).toEqual(moment('2013-01-01 00:02', 'YYYY-MM-DD hh:mm').toDate()) | ||
expect(tasks[0].id).toEqual('id1') | ||
expect(tasks[0].task).toEqual('test1') | ||
}) | ||
it('should handle duration (seconds) instead of fixed date to determine end date', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2s') | ||
var tasks = gDb.getTasks() | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].endTime).toEqual(moment('2013-01-01 00:00:02', 'YYYY-MM-DD hh:mm:ss').toDate()) | ||
expect(tasks[0].id).toEqual('id1') | ||
expect(tasks[0].task).toEqual('test1') | ||
}) | ||
it('should handle duration (weeks) instead of fixed date to determine end date', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2w') | ||
var tasks = gDb.getTasks() | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].endTime).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].id).toEqual('id1') | ||
expect(tasks[0].task).toEqual('test1') | ||
}) | ||
it('should handle fixed dates without id', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','2013-01-01,2013-01-12'); | ||
var tasks = gDb.getTasks(); | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].endTime ).toEqual(moment('2013-01-12', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].id ).toEqual('task1'); | ||
expect(tasks[0].task).toEqual('test1'); | ||
}); | ||
it('should handle relative start date based on id', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2w') | ||
gDb.addTask('test2', 'id2,after id1,1d') | ||
it('should handle duration instead of a fixed date to determine end date without id', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','2013-01-01,4d'); | ||
var tasks = gDb.getTasks(); | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].endTime ).toEqual(moment('2013-01-05', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[0].id ).toEqual('task1'); | ||
expect(tasks[0].task).toEqual('test1'); | ||
}); | ||
var tasks = gDb.getTasks() | ||
it('should handle relative start date of a fixed date to determine end date without id', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2w'); | ||
gDb.addTask('test2','after id1,1d'); | ||
expect(tasks[1].startTime).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[1].id).toEqual('id2') | ||
expect(tasks[1].task).toEqual('test2') | ||
}) | ||
var tasks = gDb.getTasks(); | ||
it('should handle relative start date based on id when id is invalid', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2w') | ||
gDb.addTask('test2', 'id2,after id3,1d') | ||
var tasks = gDb.getTasks() | ||
expect(tasks[1].startTime).toEqual(new Date((new Date()).setHours(0, 0, 0, 0))) | ||
expect(tasks[1].id).toEqual('id2') | ||
expect(tasks[1].task).toEqual('test2') | ||
}) | ||
expect(tasks[1].startTime ).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[1].id ).toEqual('task1'); | ||
expect(tasks[1].task).toEqual('test2'); | ||
}); | ||
it('should handle a new task with only an end date as definition', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2w'); | ||
gDb.addTask('test2','2013-01-26'); | ||
it('should handle fixed dates without id', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', '2013-01-01,2013-01-12') | ||
var tasks = gDb.getTasks() | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].endTime).toEqual(moment('2013-01-12', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].id).toEqual('task1') | ||
expect(tasks[0].task).toEqual('test1') | ||
}) | ||
var tasks = gDb.getTasks(); | ||
it('should handle duration instead of a fixed date to determine end date without id', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', '2013-01-01,4d') | ||
var tasks = gDb.getTasks() | ||
expect(tasks[0].startTime).toEqual(moment('2013-01-01', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].endTime).toEqual(moment('2013-01-05', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[0].id).toEqual('task1') | ||
expect(tasks[0].task).toEqual('test1') | ||
}) | ||
expect(tasks[1].startTime).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[1].endTime ).toEqual(moment('2013-01-26', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[1].id ).toEqual('task1'); | ||
expect(tasks[1].task).toEqual('test2'); | ||
}); | ||
it('should handle a new task with only an end date as definition', function () { | ||
gDb.setDateFormat('YYYY-MM-DD'); | ||
gDb.addSection('testa1'); | ||
gDb.addTask('test1','id1,2013-01-01,2w'); | ||
gDb.addTask('test2','2d'); | ||
it('should handle relative start date of a fixed date to determine end date without id', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2w') | ||
gDb.addTask('test2', 'after id1,1d') | ||
var tasks = gDb.getTasks(); | ||
var tasks = gDb.getTasks() | ||
expect(tasks[1].startTime).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[1].endTime ).toEqual(moment('2013-01-17', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[1].id ).toEqual('task1'); | ||
expect(tasks[1].task).toEqual('test2'); | ||
}); | ||
it('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'); | ||
expect(tasks[1].startTime).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[1].id).toEqual('task1') | ||
expect(tasks[1].task).toEqual('test2') | ||
}) | ||
it('should handle a new task with only an end date as definition', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2w') | ||
gDb.addTask('test2', '2013-01-26') | ||
var tasks = gDb.getTasks(); | ||
var tasks = gDb.getTasks() | ||
expect(tasks[1].startTime ).toEqual(moment('2013-01-17', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[1].endTime ).toEqual(moment('2013-01-18', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[1].id ).toEqual('id2'); | ||
expect(tasks[1].task).toEqual('test2'); | ||
expect(tasks[1].startTime).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[1].endTime).toEqual(moment('2013-01-26', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[1].id).toEqual('task1') | ||
expect(tasks[1].task).toEqual('test2') | ||
}) | ||
it('should handle a new task with only an end date as definition', function () { | ||
gDb.setDateFormat('YYYY-MM-DD') | ||
gDb.addSection('testa1') | ||
gDb.addTask('test1', 'id1,2013-01-01,2w') | ||
gDb.addTask('test2', '2d') | ||
expect(tasks[2].id ).toEqual('id3'); | ||
expect(tasks[2].task).toEqual('test3'); | ||
expect(tasks[2].startTime ).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()); | ||
expect(tasks[2].endTime ).toEqual(moment('2013-01-17', 'YYYY-MM-DD').toDate()); | ||
}); | ||
var tasks = gDb.getTasks() | ||
}); | ||
expect(tasks[1].startTime).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[1].endTime).toEqual(moment('2013-01-17', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[1].id).toEqual('task1') | ||
expect(tasks[1].task).toEqual('test2') | ||
}) | ||
it('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') | ||
// Ogiltigt id i after id | ||
var tasks = gDb.getTasks() | ||
expect(tasks[1].startTime).toEqual(moment('2013-01-17', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[1].endTime).toEqual(moment('2013-01-18', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[1].id).toEqual('id2') | ||
expect(tasks[1].task).toEqual('test2') | ||
expect(tasks[2].id).toEqual('id3') | ||
expect(tasks[2].task).toEqual('test3') | ||
expect(tasks[2].startTime).toEqual(moment('2013-01-15', 'YYYY-MM-DD').toDate()) | ||
expect(tasks[2].endTime).toEqual(moment('2013-01-17', 'YYYY-MM-DD').toDate()) | ||
}) | ||
}) |
@@ -1,428 +0,399 @@ | ||
var gantt = require('./parser/gantt').parser; | ||
gantt.yy = require('./ganttDb'); | ||
var d3 = require('../../d3'); | ||
var moment = require('moment'); | ||
//var log = require('../../logger').create(); | ||
var gantt = require('./parser/gantt').parser | ||
gantt.yy = require('./ganttDb') | ||
var d3 = require('../../d3') | ||
var moment = require('moment') | ||
var daysInChart; | ||
var daysInChart | ||
var conf = { | ||
titleTopMargin: 25, | ||
barHeight: 20, | ||
barGap: 4, | ||
topPadding: 50, | ||
rightPadding: 75, | ||
leftPadding: 75, | ||
gridLineStartPadding: 35, | ||
fontSize: 11, | ||
fontFamily: '"Open-Sans", "sans-serif"' | ||
}; | ||
titleTopMargin: 25, | ||
barHeight: 20, | ||
barGap: 4, | ||
topPadding: 50, | ||
rightPadding: 75, | ||
leftPadding: 75, | ||
gridLineStartPadding: 35, | ||
fontSize: 11, | ||
fontFamily: '"Open-Sans", "sans-serif"' | ||
} | ||
module.exports.setConf = function (cnf) { | ||
var keys = Object.keys(cnf); | ||
var keys = Object.keys(cnf) | ||
keys.forEach(function (key) { | ||
conf[key] = cnf[key]; | ||
}); | ||
}; | ||
var w; | ||
keys.forEach(function (key) { | ||
conf[key] = cnf[key] | ||
}) | ||
} | ||
var w | ||
module.exports.draw = function (text, id) { | ||
gantt.yy.clear(); | ||
gantt.parse(text); | ||
gantt.yy.clear() | ||
gantt.parse(text) | ||
var elem = document.getElementById(id); | ||
w = elem.parentElement.offsetWidth; | ||
var elem = document.getElementById(id) | ||
w = elem.parentElement.offsetWidth | ||
if (typeof w === 'undefined') { | ||
w = 1200; | ||
} | ||
if (typeof w === 'undefined') { | ||
w = 1200 | ||
} | ||
if(typeof conf.useWidth !== 'undefined'){ | ||
w = conf.useWidth; | ||
} | ||
if (typeof conf.useWidth !== 'undefined') { | ||
w = conf.useWidth | ||
} | ||
var taskArray = gantt.yy.getTasks(); | ||
var taskArray = gantt.yy.getTasks() | ||
// Set height based on number of tasks | ||
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding; | ||
// Set height based on number of tasks | ||
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding | ||
elem.setAttribute('height', '100%'); | ||
// Set viewBox | ||
elem.setAttribute('viewBox','0 0 '+w+' '+h); | ||
var svg = d3.select('#' + id); | ||
elem.setAttribute('height', '100%') | ||
// Set viewBox | ||
elem.setAttribute('viewBox', '0 0 ' + w + ' ' + h) | ||
var svg = d3.select('#' + id) | ||
//var dateFormat = d3.time.format('%Y-%m-%d'); | ||
var startDate = d3.min(taskArray, function (d) { | ||
return d.startTime; | ||
}); | ||
var endDate = d3.max(taskArray, function (d) { | ||
return d.endTime; | ||
}); | ||
// Set timescale | ||
var timeScale = d3.time.scale() | ||
.domain([d3.min(taskArray, function (d) { | ||
return d.startTime; | ||
}), | ||
d3.max(taskArray, function (d) { | ||
return d.endTime; | ||
})]) | ||
.rangeRound([0, w - conf.leftPadding - conf.rightPadding]); | ||
//.nice(d3.time.monday); | ||
var startDate = d3.min(taskArray, function (d) { | ||
return d.startTime | ||
}) | ||
var endDate = d3.max(taskArray, function (d) { | ||
return d.endTime | ||
}) | ||
var categories = []; | ||
daysInChart = moment.duration(endDate-startDate).asDays(); | ||
// Set timescale | ||
var timeScale = d3.time.scale() | ||
.domain([d3.min(taskArray, function (d) { | ||
return d.startTime | ||
}), | ||
d3.max(taskArray, function (d) { | ||
return d.endTime | ||
})]) | ||
.rangeRound([0, w - conf.leftPadding - conf.rightPadding]) | ||
for (var i = 0; i < taskArray.length; i++) { | ||
categories.push(taskArray[i].type); | ||
} | ||
var categories = [] | ||
var catsUnfiltered = categories; //for vert labels | ||
daysInChart = moment.duration(endDate - startDate).asDays() | ||
categories = checkUnique(categories); | ||
for (var i = 0; i < taskArray.length; i++) { | ||
categories.push(taskArray[i].type) | ||
} | ||
var catsUnfiltered = categories // for vert labels | ||
makeGant(taskArray, w, h); | ||
if(typeof conf.useWidth !== 'undefined'){ | ||
elem.setAttribute('width', w); | ||
categories = checkUnique(categories) | ||
} | ||
makeGant(taskArray, w, h) | ||
if (typeof conf.useWidth !== 'undefined') { | ||
elem.setAttribute('width', w) | ||
} | ||
svg.append('text') | ||
.text(gantt.yy.getTitle()) | ||
.attr('x', w / 2) | ||
.attr('y', conf.titleTopMargin) | ||
.attr('class', 'titleText'); | ||
svg.append('text') | ||
.text(gantt.yy.getTitle()) | ||
.attr('x', w / 2) | ||
.attr('y', conf.titleTopMargin) | ||
.attr('class', 'titleText') | ||
function makeGant (tasks, pageWidth, pageHeight) { | ||
var barHeight = conf.barHeight | ||
var gap = barHeight + conf.barGap | ||
var topPadding = conf.topPadding | ||
var leftPadding = conf.leftPadding | ||
function makeGant(tasks, pageWidth, pageHeight) { | ||
var colorScale = d3.scale.linear() | ||
.domain([0, categories.length]) | ||
.range(['#00B9FA', '#F95002']) | ||
.interpolate(d3.interpolateHcl) | ||
var barHeight = conf.barHeight; | ||
var gap = barHeight + conf.barGap; | ||
var topPadding = conf.topPadding; | ||
var leftPadding = conf.leftPadding; | ||
makeGrid(leftPadding, topPadding, pageWidth, pageHeight) | ||
drawRects(tasks, gap, topPadding, leftPadding, barHeight, colorScale, pageWidth, pageHeight) | ||
vertLabels(gap, topPadding, leftPadding, barHeight, colorScale) | ||
drawToday(leftPadding, topPadding, pageWidth, pageHeight) | ||
} | ||
var colorScale = d3.scale.linear() | ||
.domain([0, categories.length]) | ||
.range(['#00B9FA', '#F95002']) | ||
.interpolate(d3.interpolateHcl); | ||
function drawRects (theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w, h) { | ||
svg.append('g') | ||
.selectAll('rect') | ||
.data(theArray) | ||
.enter() | ||
.append('rect') | ||
.attr('x', 0) | ||
.attr('y', function (d, i) { | ||
return i * theGap + theTopPad - 2 | ||
}) | ||
.attr('width', function () { | ||
return w - conf.rightPadding / 2 | ||
}) | ||
.attr('height', theGap) | ||
.attr('class', function (d) { | ||
for (var i = 0; i < categories.length; i++) { | ||
if (d.type === categories[i]) { | ||
return 'section section' + (i % conf.numberSectionStyles) | ||
} | ||
} | ||
return 'section section0' | ||
}) | ||
makeGrid(leftPadding, topPadding, pageWidth, pageHeight); | ||
drawRects(tasks, gap, topPadding, leftPadding, barHeight, colorScale, pageWidth, pageHeight); | ||
vertLabels(gap, topPadding, leftPadding, barHeight, colorScale); | ||
drawToday(leftPadding, topPadding, pageWidth, pageHeight); | ||
var rectangles = svg.append('g') | ||
.selectAll('rect') | ||
.data(theArray) | ||
.enter() | ||
} | ||
rectangles.append('rect') | ||
.attr('rx', 3) | ||
.attr('ry', 3) | ||
.attr('x', function (d) { | ||
return timeScale(d.startTime) + theSidePad | ||
}) | ||
.attr('y', function (d, i) { | ||
return i * theGap + theTopPad | ||
}) | ||
.attr('width', function (d) { | ||
return (timeScale(d.endTime) - timeScale(d.startTime)) | ||
}) | ||
.attr('height', theBarHeight) | ||
.attr('class', function (d) { | ||
var res = 'task ' | ||
var secNum = 0 | ||
for (var i = 0; i < categories.length; i++) { | ||
if (d.type === categories[i]) { | ||
secNum = (i % conf.numberSectionStyles) | ||
} | ||
} | ||
function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w, h) { //eslint-disable-line no-unused-vars | ||
if (d.active) { | ||
if (d.crit) { | ||
return res + ' activeCrit' + secNum | ||
} else { | ||
return res + ' active' + secNum | ||
} | ||
} | ||
svg.append('g') | ||
.selectAll('rect') | ||
.data(theArray) | ||
.enter() | ||
.append('rect') | ||
.attr('x', 0) | ||
.attr('y', function (d, i) { | ||
return i * theGap + theTopPad - 2; | ||
}) | ||
.attr('width', function () { | ||
return w - conf.rightPadding / 2; | ||
}) | ||
.attr('height', theGap) | ||
.attr('class', function (d) { //eslint-disable-line no-unused-vars | ||
for (var i = 0; i < categories.length; i++) { | ||
if (d.type === categories[i]) { | ||
return 'section section' + (i % conf.numberSectionStyles); | ||
} | ||
} | ||
return 'section section0'; | ||
}); | ||
if (d.done) { | ||
if (d.crit) { | ||
return res + ' doneCrit' + secNum | ||
} else { | ||
return res + ' done' + secNum | ||
} | ||
} | ||
if (d.crit) { | ||
return res + ' crit' + secNum | ||
} | ||
var rectangles = svg.append('g') | ||
.selectAll('rect') | ||
.data(theArray) | ||
.enter(); | ||
return res + ' task' + secNum | ||
}) | ||
rectangles.append('text') | ||
.text(function (d) { | ||
return d.task | ||
}) | ||
.attr('font-size', conf.fontSize) | ||
.attr('x', function (d) { | ||
var startX = timeScale(d.startTime) | ||
var endX = timeScale(d.endTime) | ||
var textWidth = this.getBBox().width | ||
rectangles.append('rect') | ||
.attr('rx', 3) | ||
.attr('ry', 3) | ||
.attr('x', function (d) { | ||
return timeScale(d.startTime) + theSidePad; | ||
}) | ||
.attr('y', function (d, i) { | ||
return i * theGap + theTopPad; | ||
}) | ||
.attr('width', function (d) { | ||
return (timeScale(d.endTime) - timeScale(d.startTime)); | ||
}) | ||
.attr('height', theBarHeight) | ||
.attr('class', function (d) { | ||
var res = 'task '; | ||
var secNum = 0; | ||
for (var i = 0; i < categories.length; i++) { | ||
if (d.type === categories[i]) { | ||
secNum = (i % conf.numberSectionStyles); | ||
} | ||
} | ||
if(d.active){ | ||
if (d.crit) { | ||
return res + ' activeCrit'+secNum; | ||
}else{ | ||
return res + ' active'+secNum; | ||
} | ||
} | ||
// Check id text width > width of rectangle | ||
if (textWidth > (endX - startX)) { | ||
if (endX + textWidth + 1.5 * conf.leftPadding > w) { | ||
return startX + theSidePad - 5 | ||
} else { | ||
return endX + theSidePad + 5 | ||
} | ||
} else { | ||
return (endX - startX) / 2 + startX + theSidePad | ||
} | ||
}) | ||
.attr('y', function (d, i) { | ||
return i * theGap + (conf.barHeight / 2) + (conf.fontSize / 2 - 2) + theTopPad | ||
}) | ||
.attr('text-height', theBarHeight) | ||
.attr('class', function (d) { | ||
var startX = timeScale(d.startTime) | ||
var endX = timeScale(d.endTime) | ||
var textWidth = this.getBBox().width | ||
var secNum = 0 | ||
for (var i = 0; i < categories.length; i++) { | ||
if (d.type === categories[i]) { | ||
secNum = (i % conf.numberSectionStyles) | ||
} | ||
} | ||
if (d.done) { | ||
if (d.crit) { | ||
return res + ' doneCrit'+secNum; | ||
}else{ | ||
return res + ' done'+secNum; | ||
} | ||
} | ||
var taskType = '' | ||
if (d.active) { | ||
if (d.crit) { | ||
taskType = 'activeCritText' + secNum | ||
} else { | ||
taskType = 'activeText' + secNum | ||
} | ||
} | ||
if (d.crit) { | ||
return res + ' crit'+secNum; | ||
} | ||
if (d.done) { | ||
if (d.crit) { | ||
taskType = taskType + ' doneCritText' + secNum | ||
} else { | ||
taskType = taskType + ' doneText' + secNum | ||
} | ||
} else { | ||
if (d.crit) { | ||
taskType = taskType + ' critText' + secNum | ||
} | ||
} | ||
// Check id text width > width of rectangle | ||
if (textWidth > (endX - startX)) { | ||
if (endX + textWidth + 1.5 * conf.leftPadding > w) { | ||
return 'taskTextOutsideLeft taskTextOutside' + secNum + ' ' + taskType | ||
} else { | ||
return 'taskTextOutsideRight taskTextOutside' + secNum + ' ' + taskType | ||
} | ||
} else { | ||
return 'taskText taskText' + secNum + ' ' + taskType | ||
} | ||
}) | ||
} | ||
return res + ' task'+secNum; | ||
}) | ||
; | ||
function makeGrid (theSidePad, theTopPad, w, h) { | ||
var pre = [ | ||
['.%L', function (d) { | ||
return d.getMilliseconds() | ||
}], | ||
[':%S', function (d) { | ||
return d.getSeconds() | ||
}], | ||
// Within a hour | ||
['h1 %I:%M', function (d) { | ||
return d.getMinutes() | ||
}]] | ||
var post = [ | ||
['%Y', function () { | ||
return true | ||
}]] | ||
var mid = [ | ||
// Within a day | ||
['%I:%M', function (d) { | ||
return d.getHours() | ||
}], | ||
// Day within a week (not monday) | ||
['%a %d', function (d) { | ||
return d.getDay() && d.getDate() !== 1 | ||
}], | ||
// within a month | ||
['%b %d', function (d) { | ||
return d.getDate() !== 1 | ||
}], | ||
// Month | ||
['%B', function (d) { | ||
return d.getMonth() | ||
}] | ||
] | ||
var formatter | ||
if (typeof conf.axisFormatter !== 'undefined') { | ||
mid = [] | ||
conf.axisFormatter.forEach(function (item) { | ||
var n = [] | ||
n[0] = item[0] | ||
n[1] = item[1] | ||
mid.push(n) | ||
}) | ||
} | ||
formatter = pre.concat(mid).concat(post) | ||
rectangles.append('text') | ||
.text(function (d) { | ||
return d.task; | ||
}) | ||
.attr('font-size',conf.fontSize) | ||
//.attr('font-family',conf.fontFamily) | ||
.attr('x', function (d) { | ||
var startX = timeScale(d.startTime), | ||
endX = timeScale(d.endTime), | ||
textWidth = this.getBBox().width; | ||
var xAxis = d3.svg.axis() | ||
.scale(timeScale) | ||
.orient('bottom') | ||
.tickSize(-h + theTopPad + conf.gridLineStartPadding, 0, 0) | ||
.tickFormat(d3.time.format.multi(formatter)) | ||
// Check id text width > width of rectangle | ||
if (textWidth > (endX - startX)) { | ||
if (endX + textWidth + 1.5*conf.leftPadding> w) { | ||
return startX + theSidePad - 5; | ||
} else { | ||
return endX + theSidePad + 5; | ||
} | ||
} else { | ||
return (endX - startX) / 2 + startX + theSidePad; | ||
} | ||
}) | ||
.attr('y', function (d, i) { | ||
return i * theGap + (conf.barHeight / 2) + (conf.fontSize / 2 - 2) + theTopPad; | ||
}) | ||
//.attr('text-anchor', 'middle') | ||
.attr('text-height', theBarHeight) | ||
.attr('class', function (d) { | ||
var startX = timeScale(d.startTime), | ||
endX = timeScale(d.endTime), | ||
textWidth = this.getBBox().width; | ||
var secNum = 0; | ||
for (var i = 0; i < categories.length; i++) { | ||
if (d.type === categories[i]) { | ||
secNum = (i % conf.numberSectionStyles); | ||
} | ||
} | ||
if (daysInChart > 7 && daysInChart < 230) { | ||
xAxis = xAxis.ticks(d3.time.monday.range) | ||
} | ||
var taskType = ''; | ||
if(d.active){ | ||
if (d.crit) { | ||
taskType = 'activeCritText'+secNum; | ||
}else{ | ||
taskType = 'activeText'+secNum; | ||
} | ||
} | ||
svg.append('g') | ||
.attr('class', 'grid') | ||
.attr('transform', 'translate(' + theSidePad + ', ' + (h - 50) + ')') | ||
.call(xAxis) | ||
.selectAll('text') | ||
.style('text-anchor', 'middle') | ||
.attr('fill', '#000') | ||
.attr('stroke', 'none') | ||
.attr('font-size', 10) | ||
.attr('dy', '1em') | ||
} | ||
if (d.done) { | ||
if (d.crit) { | ||
taskType = taskType + ' doneCritText'+secNum; | ||
}else{ | ||
taskType = taskType + ' doneText'+secNum; | ||
} | ||
}else{ | ||
if (d.crit) { | ||
taskType = taskType + ' critText'+secNum; | ||
} | ||
} | ||
function vertLabels (theGap, theTopPad) { | ||
var numOccurances = [] | ||
var prevGap = 0 | ||
// Check id text width > width of rectangle | ||
if (textWidth > (endX - startX)) { | ||
if (endX + textWidth + 1.5*conf.leftPadding > w) { | ||
return 'taskTextOutsideLeft taskTextOutside' + secNum + ' ' + taskType; | ||
} else { | ||
return 'taskTextOutsideRight taskTextOutside' + secNum+ ' ' + taskType; | ||
} | ||
} else { | ||
return 'taskText taskText' + secNum+ ' ' + taskType; | ||
} | ||
}); | ||
for (var i = 0; i < categories.length; i++) { | ||
numOccurances[i] = [categories[i], getCount(categories[i], catsUnfiltered)] | ||
} | ||
function makeGrid(theSidePad, theTopPad, w, h) { | ||
var pre = [ | ||
['.%L', function (d) { | ||
return d.getMilliseconds(); | ||
}], | ||
[':%S', function (d) { | ||
return d.getSeconds(); | ||
}], | ||
// Within a hour | ||
['h1 %I:%M', function (d) { | ||
return d.getMinutes(); | ||
}]]; | ||
var post = [ | ||
['%Y', function () { | ||
return true; | ||
}]]; | ||
var mid = [ | ||
// Within a day | ||
['%I:%M', function (d) { | ||
return d.getHours(); | ||
}], | ||
// Day within a week (not monday) | ||
['%a %d', function (d) { | ||
//return d.getDay() ==1; | ||
return d.getDay() && d.getDate() != 1; | ||
}], | ||
// within a month | ||
['%b %d', function (d) { | ||
return d.getDate() != 1; | ||
}], | ||
// Month | ||
['%B', function (d) { | ||
return d.getMonth(); | ||
}] | ||
]; | ||
var formatter; | ||
if(typeof conf.axisFormatter !== 'undefined'){ | ||
mid = []; | ||
conf.axisFormatter.forEach(function(item){ | ||
var n = []; | ||
n[0] = item[0]; | ||
n[1] = item[1]; | ||
mid.push(n); | ||
}); | ||
svg.append('g') // without doing this, impossible to put grid lines behind text | ||
.selectAll('text') | ||
.data(numOccurances) | ||
.enter() | ||
.append('text') | ||
.text(function (d) { | ||
return d[0] | ||
}) | ||
.attr('x', 10) | ||
.attr('y', function (d, i) { | ||
if (i > 0) { | ||
for (var j = 0; j < i; j++) { | ||
prevGap += numOccurances[i - 1][1] | ||
return d[1] * theGap / 2 + prevGap * theGap + theTopPad | ||
} | ||
} else { | ||
return d[1] * theGap / 2 + theTopPad | ||
} | ||
formatter = pre.concat(mid).concat(post); | ||
var xAxis = d3.svg.axis() | ||
.scale(timeScale) | ||
.orient('bottom') | ||
.tickSize(-h + theTopPad + conf.gridLineStartPadding, 0, 0) | ||
.tickFormat(d3.time.format.multi(formatter)) | ||
; | ||
if(daysInChart >7 && daysInChart<230){ | ||
xAxis = xAxis.ticks(d3.time.monday.range); | ||
} | ||
svg.append('g') | ||
.attr('class', 'grid') | ||
.attr('transform', 'translate(' + theSidePad + ', ' + (h - 50) + ')') | ||
.call(xAxis) | ||
.selectAll('text') | ||
.style('text-anchor', 'middle') | ||
.attr('fill', '#000') | ||
.attr('stroke', 'none') | ||
.attr('font-size', 10) | ||
.attr('dy', '1em'); | ||
} | ||
function vertLabels(theGap, theTopPad) { | ||
var numOccurances = []; | ||
var prevGap = 0; | ||
}) | ||
.attr('class', function (d) { | ||
for (var i = 0; i < categories.length; i++) { | ||
numOccurances[i] = [categories[i], getCount(categories[i], catsUnfiltered)]; | ||
if (d[0] === categories[i]) { | ||
return 'sectionTitle sectionTitle' + (i % conf.numberSectionStyles) | ||
} | ||
} | ||
return 'sectionTitle' | ||
}) | ||
} | ||
svg.append('g') //without doing this, impossible to put grid lines behind text | ||
.selectAll('text') | ||
.data(numOccurances) | ||
.enter() | ||
.append('text') | ||
.text(function (d) { | ||
return d[0]; | ||
}) | ||
.attr('x', 10) | ||
.attr('y', function (d, i) { | ||
if (i > 0) { | ||
for (var j = 0; j < i; j++) { | ||
prevGap += numOccurances[i - 1][1]; | ||
// log.debug(prevGap); | ||
return d[1] * theGap / 2 + prevGap * theGap + theTopPad; | ||
} | ||
} else { | ||
return d[1] * theGap / 2 + theTopPad; | ||
} | ||
}) | ||
.attr('class', function (d) { | ||
for (var i = 0; i < categories.length; i++) { | ||
if (d[0] === categories[i]) { | ||
return 'sectionTitle sectionTitle' + (i % conf.numberSectionStyles); | ||
} | ||
} | ||
return 'sectionTitle'; | ||
}); | ||
function drawToday (theSidePad, theTopPad, w, h) { | ||
var todayG = svg.append('g') | ||
.attr('class', 'today') | ||
} | ||
var today = new Date() | ||
function drawToday(theSidePad, theTopPad, w, h) { | ||
var todayG = svg.append('g') | ||
.attr('class', 'today'); | ||
todayG.append('line') | ||
.attr('x1', timeScale(today) + theSidePad) | ||
.attr('x2', timeScale(today) + theSidePad) | ||
.attr('y1', conf.titleTopMargin) | ||
.attr('y2', h - conf.titleTopMargin) | ||
.attr('class', 'today') | ||
} | ||
var today = new Date(); | ||
todayG.append('line') | ||
.attr('x1', timeScale(today) + theSidePad) | ||
.attr('x2', timeScale(today) + theSidePad) | ||
.attr('y1', conf.titleTopMargin) | ||
.attr('y2', h-conf.titleTopMargin) | ||
.attr('class', 'today') | ||
; | ||
// from this stackexchange question: http://stackoverflow.com/questions/1890203/unique-for-arrays-in-javascript | ||
function checkUnique (arr) { | ||
var hash = {} | ||
var result = [] | ||
for (var i = 0, l = arr.length; i < l; ++i) { | ||
if (!hash.hasOwnProperty(arr[i])) { // it works with objects! in FF, at least | ||
hash[arr[i]] = true | ||
result.push(arr[i]) | ||
} | ||
} | ||
return result | ||
} | ||
//from this stackexchange question: http://stackoverflow.com/questions/1890203/unique-for-arrays-in-javascript | ||
function checkUnique(arr) { | ||
var hash = {}, result = []; | ||
for (var i = 0, l = arr.length; i < l; ++i) { | ||
if (!hash.hasOwnProperty(arr[i])) { //it works with objects! in FF, at least | ||
hash[arr[i]] = true; | ||
result.push(arr[i]); | ||
} | ||
} | ||
return result; | ||
// from this stackexchange question: http://stackoverflow.com/questions/14227981/count-how-many-strings-in-an-array-have-duplicates-in-the-same-array | ||
function getCounts (arr) { | ||
var i = arr.length // var to loop over | ||
var obj = {} // obj to store results | ||
while (i) { | ||
obj[arr[--i]] = (obj[arr[i]] || 0) + 1 // count occurrences | ||
} | ||
return obj | ||
} | ||
//from this stackexchange question: http://stackoverflow.com/questions/14227981/count-how-many-strings-in-an-array-have-duplicates-in-the-same-array | ||
function getCounts(arr) { | ||
var i = arr.length, // var to loop over | ||
obj = {}; // obj to store results | ||
while (i) { | ||
obj[arr[--i]] = (obj[arr[i]] || 0) + 1; // count occurrences | ||
} | ||
return obj; | ||
} | ||
// get specific from everything | ||
function getCount(word, arr) { | ||
return getCounts(arr)[word] || 0; | ||
} | ||
}; | ||
// get specific from everything | ||
function getCount (word, arr) { | ||
return getCounts(arr)[word] || 0 | ||
} | ||
} |
@@ -53,3 +53,2 @@ /* parser generated by jison 0.4.17 */ | ||
token location info (@$, _$, etc.): { | ||
@@ -63,3 +62,2 @@ first_line: n, | ||
the parseError function receives a 'hash' object with these members for lexer and parser errors: { | ||
@@ -76,584 +74,583 @@ text: (matched text) | ||
*/ | ||
var parser = (function(){ | ||
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[6,8,10,11,12,13,14],$V1=[1,9],$V2=[1,10],$V3=[1,11],$V4=[1,12]; | ||
var parser = {trace: function trace() { }, | ||
yy: {}, | ||
symbols_: {"error":2,"start":3,"gantt":4,"document":5,"EOF":6,"line":7,"SPACE":8,"statement":9,"NL":10,"dateFormat":11,"title":12,"section":13,"taskTxt":14,"taskData":15,"$accept":0,"$end":1}, | ||
terminals_: {2:"error",4:"gantt",6:"EOF",8:"SPACE",10:"NL",11:"dateFormat",12:"title",13:"section",14:"taskTxt",15:"taskData"}, | ||
productions_: [0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,1],[9,1],[9,1],[9,2]], | ||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
/* this == yyval */ | ||
var parser = (function () { | ||
var o = function (k, v, o, l) { for (o = o || {}, l = k.length; l--; o[k[l]] = v); return o }, $V0 = [6, 8, 10, 11, 12, 13, 14], $V1 = [1, 9], $V2 = [1, 10], $V3 = [1, 11], $V4 = [1, 12] | ||
var parser = { | ||
trace: function trace () { }, | ||
yy: {}, | ||
symbols_: { 'error': 2, 'start': 3, 'gantt': 4, 'document': 5, 'EOF': 6, 'line': 7, 'SPACE': 8, 'statement': 9, 'NL': 10, 'dateFormat': 11, 'title': 12, 'section': 13, 'taskTxt': 14, 'taskData': 15, '$accept': 0, '$end': 1 }, | ||
terminals_: { 2: 'error', 4: 'gantt', 6: 'EOF', 8: 'SPACE', 10: 'NL', 11: 'dateFormat', 12: 'title', 13: 'section', 14: 'taskTxt', 15: 'taskData' }, | ||
productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 1], [9, 1], [9, 1], [9, 2]], | ||
performAction: function anonymous (yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
/* this == yyval */ | ||
var $0 = $$.length - 1; | ||
switch (yystate) { | ||
case 1: | ||
return $$[$0-1]; | ||
break; | ||
case 2: | ||
this.$ = [] | ||
break; | ||
case 3: | ||
$$[$0-1].push($$[$0]);this.$ = $$[$0-1] | ||
break; | ||
case 4: case 5: | ||
this.$ = $$[$0] | ||
break; | ||
case 6: case 7: | ||
this.$=[]; | ||
break; | ||
case 8: | ||
yy.setDateFormat($$[$0].substr(11));this.$=$$[$0].substr(11); | ||
break; | ||
case 9: | ||
yy.setTitle($$[$0].substr(6));this.$=$$[$0].substr(6); | ||
break; | ||
case 10: | ||
yy.addSection($$[$0].substr(8));this.$=$$[$0].substr(8); | ||
break; | ||
case 11: | ||
yy.addTask($$[$0-1],$$[$0]);this.$='task'; | ||
break; | ||
} | ||
}, | ||
table: [{3:1,4:[1,2]},{1:[3]},o($V0,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:$V1,12:$V2,13:$V3,14:$V4},o($V0,[2,7],{1:[2,1]}),o($V0,[2,3]),{9:13,11:$V1,12:$V2,13:$V3,14:$V4},o($V0,[2,5]),o($V0,[2,6]),o($V0,[2,8]),o($V0,[2,9]),o($V0,[2,10]),{15:[1,14]},o($V0,[2,4]),o($V0,[2,11])], | ||
defaultActions: {}, | ||
parseError: function parseError(str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str); | ||
} else { | ||
var $0 = $$.length - 1 | ||
switch (yystate) { | ||
case 1: | ||
return $$[$0 - 1] | ||
break | ||
case 2: | ||
this.$ = [] | ||
break | ||
case 3: | ||
$$[$0 - 1].push($$[$0]); this.$ = $$[$0 - 1] | ||
break | ||
case 4: case 5: | ||
this.$ = $$[$0] | ||
break | ||
case 6: case 7: | ||
this.$ = [] | ||
break | ||
case 8: | ||
yy.setDateFormat($$[$0].substr(11)); this.$ = $$[$0].substr(11) | ||
break | ||
case 9: | ||
yy.setTitle($$[$0].substr(6)); this.$ = $$[$0].substr(6) | ||
break | ||
case 10: | ||
yy.addSection($$[$0].substr(8)); this.$ = $$[$0].substr(8) | ||
break | ||
case 11: | ||
yy.addTask($$[$0 - 1], $$[$0]); this.$ = 'task' | ||
break | ||
} | ||
}, | ||
table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: $V1, 12: $V2, 13: $V3, 14: $V4 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 13, 11: $V1, 12: $V2, 13: $V3, 14: $V4 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 8]), o($V0, [2, 9]), o($V0, [2, 10]), { 15: [1, 14] }, o($V0, [2, 4]), o($V0, [2, 11])], | ||
defaultActions: {}, | ||
parseError: function parseError (str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str) | ||
} else { | ||
function _parseError (msg, hash) { | ||
this.message = msg; | ||
this.hash = hash; | ||
this.message = msg | ||
this.hash = hash | ||
} | ||
_parseError.prototype = Error; | ||
_parseError.prototype = Error | ||
throw new _parseError(str, hash); | ||
} | ||
}, | ||
parse: function parse(input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; | ||
var args = lstack.slice.call(arguments, 1); | ||
var lexer = Object.create(this.lexer); | ||
var sharedState = { yy: {} }; | ||
for (var k in this.yy) { | ||
throw new _parseError(str, hash) | ||
} | ||
}, | ||
parse: function parse (input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1 | ||
var args = lstack.slice.call(arguments, 1) | ||
var lexer = Object.create(this.lexer) | ||
var sharedState = { yy: {} } | ||
for (var k in this.yy) { | ||
if (Object.prototype.hasOwnProperty.call(this.yy, k)) { | ||
sharedState.yy[k] = this.yy[k]; | ||
sharedState.yy[k] = this.yy[k] | ||
} | ||
} | ||
lexer.setInput(input, sharedState.yy); | ||
sharedState.yy.lexer = lexer; | ||
sharedState.yy.parser = this; | ||
if (typeof lexer.yylloc == 'undefined') { | ||
lexer.yylloc = {}; | ||
} | ||
var yyloc = lexer.yylloc; | ||
lstack.push(yyloc); | ||
var ranges = lexer.options && lexer.options.ranges; | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError; | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError; | ||
} | ||
function popStack(n) { | ||
stack.length = stack.length - 2 * n; | ||
vstack.length = vstack.length - n; | ||
lstack.length = lstack.length - n; | ||
} | ||
_token_stack: | ||
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]; | ||
} | ||
lexer.setInput(input, sharedState.yy) | ||
sharedState.yy.lexer = lexer | ||
sharedState.yy.parser = this | ||
if (typeof lexer.yylloc === 'undefined') { | ||
lexer.yylloc = {} | ||
} | ||
var yyloc = lexer.yylloc | ||
lstack.push(yyloc) | ||
var ranges = lexer.options && lexer.options.ranges | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError | ||
} | ||
function popStack (n) { | ||
stack.length = stack.length - 2 * n | ||
vstack.length = vstack.length - n | ||
lstack.length = lstack.length - n | ||
} | ||
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] | ||
if (this.defaultActions[state]) { | ||
action = this.defaultActions[state]; | ||
action = this.defaultActions[state] | ||
} else { | ||
if (symbol === null || typeof symbol == 'undefined') { | ||
symbol = lex(); | ||
if (symbol === null || typeof symbol === 'undefined') { | ||
symbol = lex() | ||
} | ||
action = table[state] && table[state][symbol] | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = '' | ||
expected = [] | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\'') | ||
} | ||
action = table[state] && table[state][symbol]; | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'' | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'') | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}) | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = ''; | ||
expected = []; | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\''); | ||
} | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}); | ||
} | ||
if (action[0] instanceof Array && action.length > 1) { | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol) | ||
} | ||
switch (action[0]) { | ||
case 1: | ||
stack.push(symbol); | ||
vstack.push(lexer.yytext); | ||
lstack.push(lexer.yylloc); | ||
stack.push(action[1]); | ||
symbol = null; | ||
case 1: | ||
stack.push(symbol) | ||
vstack.push(lexer.yytext) | ||
lstack.push(lexer.yylloc) | ||
stack.push(action[1]) | ||
symbol = null | ||
if (!preErrorSymbol) { | ||
yyleng = lexer.yyleng; | ||
yytext = lexer.yytext; | ||
yylineno = lexer.yylineno; | ||
yyloc = lexer.yylloc; | ||
if (recovering > 0) { | ||
recovering--; | ||
} | ||
yyleng = lexer.yyleng | ||
yytext = lexer.yytext | ||
yylineno = lexer.yylineno | ||
yyloc = lexer.yylloc | ||
if (recovering > 0) { | ||
recovering-- | ||
} | ||
} else { | ||
symbol = preErrorSymbol; | ||
preErrorSymbol = null; | ||
symbol = preErrorSymbol | ||
preErrorSymbol = null | ||
} | ||
break; | ||
case 2: | ||
len = this.productions_[action[1]][1]; | ||
yyval.$ = vstack[vstack.length - len]; | ||
break | ||
case 2: | ||
len = this.productions_[action[1]][1] | ||
yyval.$ = vstack[vstack.length - len] | ||
yyval._$ = { | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
}; | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
} | ||
if (ranges) { | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
]; | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
] | ||
} | ||
r = this.performAction.apply(yyval, [ | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)); | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)) | ||
if (typeof r !== 'undefined') { | ||
return r; | ||
return r | ||
} | ||
if (len) { | ||
stack = stack.slice(0, -1 * len * 2); | ||
vstack = vstack.slice(0, -1 * len); | ||
lstack = lstack.slice(0, -1 * len); | ||
stack = stack.slice(0, -1 * len * 2) | ||
vstack = vstack.slice(0, -1 * len) | ||
lstack = lstack.slice(0, -1 * len) | ||
} | ||
stack.push(this.productions_[action[1]][0]); | ||
vstack.push(yyval.$); | ||
lstack.push(yyval._$); | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; | ||
stack.push(newState); | ||
break; | ||
case 3: | ||
return true; | ||
stack.push(this.productions_[action[1]][0]) | ||
vstack.push(yyval.$) | ||
lstack.push(yyval._$) | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]] | ||
stack.push(newState) | ||
break | ||
case 3: | ||
return true | ||
} | ||
} | ||
return true | ||
} | ||
return true; | ||
}}; | ||
/* generated by jison-lex 0.3.4 */ | ||
var lexer = (function(){ | ||
var lexer = ({ | ||
} | ||
/* generated by jison-lex 0.3.4 */ | ||
var lexer = (function () { | ||
var lexer = ({ | ||
EOF:1, | ||
EOF: 1, | ||
parseError:function parseError(str, hash) { | ||
parseError: function parseError (str, hash) { | ||
if (this.yy.parser) { | ||
this.yy.parser.parseError(str, hash); | ||
this.yy.parser.parseError(str, hash) | ||
} else { | ||
throw new Error(str); | ||
throw new Error(str) | ||
} | ||
}, | ||
}, | ||
// resets the lexer, sets new input | ||
setInput:function (input, yy) { | ||
this.yy = yy || this.yy || {}; | ||
this._input = input; | ||
this._more = this._backtrack = this.done = false; | ||
this.yylineno = this.yyleng = 0; | ||
this.yytext = this.matched = this.match = ''; | ||
this.conditionStack = ['INITIAL']; | ||
// resets the lexer, sets new input | ||
setInput: function (input, yy) { | ||
this.yy = yy || this.yy || {} | ||
this._input = input | ||
this._more = this._backtrack = this.done = false | ||
this.yylineno = this.yyleng = 0 | ||
this.yytext = this.matched = this.match = '' | ||
this.conditionStack = ['INITIAL'] | ||
this.yylloc = { | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
}; | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [0,0]; | ||
this.yylloc.range = [0, 0] | ||
} | ||
this.offset = 0; | ||
return this; | ||
}, | ||
this.offset = 0 | ||
return this | ||
}, | ||
// consumes and returns one char from the input | ||
input:function () { | ||
var ch = this._input[0]; | ||
this.yytext += ch; | ||
this.yyleng++; | ||
this.offset++; | ||
this.match += ch; | ||
this.matched += ch; | ||
var lines = ch.match(/(?:\r\n?|\n).*/g); | ||
// consumes and returns one char from the input | ||
input: function () { | ||
var ch = this._input[0] | ||
this.yytext += ch | ||
this.yyleng++ | ||
this.offset++ | ||
this.match += ch | ||
this.matched += ch | ||
var lines = ch.match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno++; | ||
this.yylloc.last_line++; | ||
this.yylineno++ | ||
this.yylloc.last_line++ | ||
} else { | ||
this.yylloc.last_column++; | ||
this.yylloc.last_column++ | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range[1]++; | ||
this.yylloc.range[1]++ | ||
} | ||
this._input = this._input.slice(1); | ||
return ch; | ||
}, | ||
this._input = this._input.slice(1) | ||
return ch | ||
}, | ||
// unshifts one char (or a string) into the input | ||
unput:function (ch) { | ||
var len = ch.length; | ||
var lines = ch.split(/(?:\r\n?|\n)/g); | ||
// unshifts one char (or a string) into the input | ||
unput: function (ch) { | ||
var len = ch.length | ||
var lines = ch.split(/(?:\r\n?|\n)/g) | ||
this._input = ch + this._input; | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len); | ||
//this.yyleng -= len; | ||
this.offset -= len; | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g); | ||
this.match = this.match.substr(0, this.match.length - 1); | ||
this.matched = this.matched.substr(0, this.matched.length - 1); | ||
this._input = ch + this._input | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len) | ||
// this.yyleng -= len; | ||
this.offset -= len | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g) | ||
this.match = this.match.substr(0, this.match.length - 1) | ||
this.matched = this.matched.substr(0, this.matched.length - 1) | ||
if (lines.length - 1) { | ||
this.yylineno -= lines.length - 1; | ||
this.yylineno -= lines.length - 1 | ||
} | ||
var r = this.yylloc.range; | ||
var r = this.yylloc.range | ||
this.yylloc = { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines ? | ||
(lines.length === oldLines.length ? this.yylloc.first_column : 0) | ||
+ oldLines[oldLines.length - lines.length].length - lines[0].length : | ||
this.yylloc.first_column - len | ||
}; | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines | ||
? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + | ||
oldLines[oldLines.length - lines.length].length - lines[0].length | ||
: this.yylloc.first_column - len | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len]; | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len] | ||
} | ||
this.yyleng = this.yytext.length; | ||
return this; | ||
}, | ||
this.yyleng = this.yytext.length | ||
return this | ||
}, | ||
// When called from action, caches matched text and appends it on next action | ||
more:function () { | ||
this._more = true; | ||
return this; | ||
}, | ||
// When called from action, caches matched text and appends it on next action | ||
more: function () { | ||
this._more = true | ||
return this | ||
}, | ||
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. | ||
reject:function () { | ||
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. | ||
reject: function () { | ||
if (this.options.backtrack_lexer) { | ||
this._backtrack = true; | ||
this._backtrack = true | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
return this; | ||
}, | ||
return this | ||
}, | ||
// retain first n characters of the match | ||
less:function (n) { | ||
this.unput(this.match.slice(n)); | ||
}, | ||
// retain first n characters of the match | ||
less: function (n) { | ||
this.unput(this.match.slice(n)) | ||
}, | ||
// displays already matched input, i.e. for error messages | ||
pastInput:function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length); | ||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); | ||
}, | ||
// displays already matched input, i.e. for error messages | ||
pastInput: function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length) | ||
return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') | ||
}, | ||
// displays upcoming input, i.e. for error messages | ||
upcomingInput:function () { | ||
var next = this.match; | ||
// displays upcoming input, i.e. for error messages | ||
upcomingInput: function () { | ||
var next = this.match | ||
if (next.length < 20) { | ||
next += this._input.substr(0, 20-next.length); | ||
next += this._input.substr(0, 20 - next.length) | ||
} | ||
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); | ||
}, | ||
return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, '') | ||
}, | ||
// displays the character position where the lexing error occurred, i.e. for error messages | ||
showPosition:function () { | ||
var pre = this.pastInput(); | ||
var c = new Array(pre.length + 1).join("-"); | ||
return pre + this.upcomingInput() + "\n" + c + "^"; | ||
}, | ||
// displays the character position where the lexing error occurred, i.e. for error messages | ||
showPosition: function () { | ||
var pre = this.pastInput() | ||
var c = new Array(pre.length + 1).join('-') | ||
return pre + this.upcomingInput() + '\n' + c + '^' | ||
}, | ||
// test the lexed token: return FALSE when not a match, otherwise return token | ||
test_match:function (match, indexed_rule) { | ||
// test the lexed token: return FALSE when not a match, otherwise return token | ||
test_match: function (match, indexed_rule) { | ||
var token, | ||
lines, | ||
backup; | ||
lines, | ||
backup | ||
if (this.options.backtrack_lexer) { | ||
// save context | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
}; | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0); | ||
} | ||
// save context | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
} | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0) | ||
} | ||
} | ||
lines = match[0].match(/(?:\r\n?|\n).*/g); | ||
lines = match[0].match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno += lines.length; | ||
this.yylineno += lines.length | ||
} | ||
this.yylloc = { | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines ? | ||
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : | ||
this.yylloc.last_column + match[0].length | ||
}; | ||
this.yytext += match[0]; | ||
this.match += match[0]; | ||
this.matches = match; | ||
this.yyleng = this.yytext.length; | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines | ||
? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length | ||
: this.yylloc.last_column + match[0].length | ||
} | ||
this.yytext += match[0] | ||
this.match += match[0] | ||
this.matches = match | ||
this.yyleng = this.yytext.length | ||
if (this.options.ranges) { | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng]; | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng] | ||
} | ||
this._more = false; | ||
this._backtrack = false; | ||
this._input = this._input.slice(match[0].length); | ||
this.matched += match[0]; | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); | ||
this._more = false | ||
this._backtrack = false | ||
this._input = this._input.slice(match[0].length) | ||
this.matched += match[0] | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]) | ||
if (this.done && this._input) { | ||
this.done = false; | ||
this.done = false | ||
} | ||
if (token) { | ||
return token; | ||
return token | ||
} else if (this._backtrack) { | ||
// recover context | ||
for (var k in backup) { | ||
this[k] = backup[k]; | ||
} | ||
return false; // rule action called reject() implying the next rule should be tested instead. | ||
// recover context | ||
for (var k in backup) { | ||
this[k] = backup[k] | ||
} | ||
return false // rule action called reject() implying the next rule should be tested instead. | ||
} | ||
return false; | ||
}, | ||
return false | ||
}, | ||
// return next match in input | ||
next:function () { | ||
// return next match in input | ||
next: function () { | ||
if (this.done) { | ||
return this.EOF; | ||
return this.EOF | ||
} | ||
if (!this._input) { | ||
this.done = true; | ||
this.done = true | ||
} | ||
var token, | ||
match, | ||
tempMatch, | ||
index; | ||
match, | ||
tempMatch, | ||
index | ||
if (!this._more) { | ||
this.yytext = ''; | ||
this.match = ''; | ||
this.yytext = '' | ||
this.match = '' | ||
} | ||
var rules = this._currentRules(); | ||
var rules = this._currentRules() | ||
for (var i = 0; i < rules.length; i++) { | ||
tempMatch = this._input.match(this.rules[rules[i]]); | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch; | ||
index = i; | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]); | ||
if (token !== false) { | ||
return token; | ||
} else if (this._backtrack) { | ||
match = false; | ||
continue; // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
} | ||
} else if (!this.options.flex) { | ||
break; | ||
} | ||
tempMatch = this._input.match(this.rules[rules[i]]) | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch | ||
index = i | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]) | ||
if (token !== false) { | ||
return token | ||
} else if (this._backtrack) { | ||
match = false | ||
continue // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false | ||
} | ||
} else if (!this.options.flex) { | ||
break | ||
} | ||
} | ||
} | ||
if (match) { | ||
token = this.test_match(match, rules[index]); | ||
if (token !== false) { | ||
return token; | ||
} | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
token = this.test_match(match, rules[index]) | ||
if (token !== false) { | ||
return token | ||
} | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false | ||
} | ||
if (this._input === "") { | ||
return this.EOF; | ||
if (this._input === '') { | ||
return this.EOF | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
}, | ||
}, | ||
// return next match that has a token | ||
lex:function lex() { | ||
var r = this.next(); | ||
// return next match that has a token | ||
lex: function lex () { | ||
var r = this.next() | ||
if (r) { | ||
return r; | ||
return r | ||
} else { | ||
return this.lex(); | ||
return this.lex() | ||
} | ||
}, | ||
}, | ||
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) | ||
begin:function begin(condition) { | ||
this.conditionStack.push(condition); | ||
}, | ||
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) | ||
begin: function begin (condition) { | ||
this.conditionStack.push(condition) | ||
}, | ||
// pop the previously active lexer condition state off the condition stack | ||
popState:function popState() { | ||
var n = this.conditionStack.length - 1; | ||
// pop the previously active lexer condition state off the condition stack | ||
popState: function popState () { | ||
var n = this.conditionStack.length - 1 | ||
if (n > 0) { | ||
return this.conditionStack.pop(); | ||
return this.conditionStack.pop() | ||
} else { | ||
return this.conditionStack[0]; | ||
return this.conditionStack[0] | ||
} | ||
}, | ||
}, | ||
// produce the lexer rule set which is active for the currently active lexer condition state | ||
_currentRules:function _currentRules() { | ||
// produce the lexer rule set which is active for the currently active lexer condition state | ||
_currentRules: function _currentRules () { | ||
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules | ||
} else { | ||
return this.conditions["INITIAL"].rules; | ||
return this.conditions['INITIAL'].rules | ||
} | ||
}, | ||
}, | ||
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available | ||
topState:function topState(n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0); | ||
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available | ||
topState: function topState (n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0) | ||
if (n >= 0) { | ||
return this.conditionStack[n]; | ||
return this.conditionStack[n] | ||
} else { | ||
return "INITIAL"; | ||
return 'INITIAL' | ||
} | ||
}, | ||
}, | ||
// alias for begin(condition) | ||
pushState:function pushState(condition) { | ||
this.begin(condition); | ||
}, | ||
// alias for begin(condition) | ||
pushState: function pushState (condition) { | ||
this.begin(condition) | ||
}, | ||
// return the number of states currently on the stack | ||
stateStackSize:function stateStackSize() { | ||
return this.conditionStack.length; | ||
}, | ||
options: {"case-insensitive":true}, | ||
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { | ||
// Pre-lexer code can go here | ||
// return the number of states currently on the stack | ||
stateStackSize: function stateStackSize () { | ||
return this.conditionStack.length | ||
}, | ||
options: { 'case-insensitive': true }, | ||
performAction: function anonymous (yy, yy_, $avoiding_name_collisions, YY_START) { | ||
// Pre-lexer code can go here | ||
var YYSTATE=YY_START; | ||
switch($avoiding_name_collisions) { | ||
case 0:return 10; | ||
break; | ||
case 1:/* skip whitespace */ | ||
break; | ||
case 2:/* skip comments */ | ||
break; | ||
case 3:/* skip comments */ | ||
break; | ||
case 4:return 4; | ||
break; | ||
case 5:return 11; | ||
break; | ||
case 6:return 'date'; | ||
break; | ||
case 7:return 12; | ||
break; | ||
case 8:return 13; | ||
break; | ||
case 9:return 14; | ||
break; | ||
case 10:return 15; | ||
break; | ||
case 11:return ':'; | ||
break; | ||
case 12:return 6; | ||
break; | ||
case 13:return 'INVALID'; | ||
break; | ||
} | ||
}, | ||
rules: [/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:gantt\b)/i,/^(?:dateFormat\s[^#\n;]+)/i,/^(?:\d\d\d\d-\d\d-\d\d\b)/i,/^(?:title\s[^#\n;]+)/i,/^(?:section\s[^#:\n;]+)/i,/^(?:[^#:\n;]+)/i,/^(?::[^#\n;]+)/i,/^(?::)/i,/^(?:$)/i,/^(?:.)/i], | ||
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}} | ||
}); | ||
return lexer; | ||
})(); | ||
parser.lexer = lexer; | ||
function Parser () { | ||
this.yy = {}; | ||
} | ||
Parser.prototype = parser;parser.Parser = Parser; | ||
return new Parser; | ||
})(); | ||
var YYSTATE = YY_START | ||
switch ($avoiding_name_collisions) { | ||
case 0: return 10 | ||
break | ||
case 1:/* skip whitespace */ | ||
break | ||
case 2:/* skip comments */ | ||
break | ||
case 3:/* skip comments */ | ||
break | ||
case 4: return 4 | ||
break | ||
case 5: return 11 | ||
break | ||
case 6: return 'date' | ||
break | ||
case 7: return 12 | ||
break | ||
case 8: return 13 | ||
break | ||
case 9: return 14 | ||
break | ||
case 10: return 15 | ||
break | ||
case 11: return ':' | ||
break | ||
case 12: return 6 | ||
break | ||
case 13: return 'INVALID' | ||
break | ||
} | ||
}, | ||
rules: [/^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:gantt\b)/i, /^(?:dateFormat\s[^#\n;]+)/i, /^(?:\d\d\d\d-\d\d-\d\d\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:section\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i], | ||
conditions: { 'INITIAL': { 'rules': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 'inclusive': true } } | ||
}) | ||
return lexer | ||
})() | ||
parser.lexer = lexer | ||
function Parser () { | ||
this.yy = {} | ||
} | ||
Parser.prototype = parser; parser.Parser = Parser | ||
return new Parser() | ||
})() | ||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') { | ||
exports.parser = parser; | ||
exports.Parser = parser.Parser; | ||
exports.parse = function () { return parser.parse.apply(parser, arguments); }; | ||
exports.main = function commonjsMain(args) { | ||
exports.parser = parser | ||
exports.Parser = parser.Parser | ||
exports.parse = function () { return parser.parse.apply(parser, arguments) } | ||
exports.main = function commonjsMain (args) { | ||
if (!args[1]) { | ||
console.log('Usage: '+args[0]+' FILE'); | ||
process.exit(1); | ||
console.log('Usage: ' + args[0] + ' FILE') | ||
process.exit(1) | ||
} | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); | ||
return exports.parser.parse(source); | ||
}; | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)); | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), 'utf8') | ||
return exports.parser.parse(source) | ||
} | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)) | ||
} | ||
} | ||
} |
@@ -1,216 +0,208 @@ | ||
var Logger = require('../../logger'); | ||
var _ = require('lodash'); | ||
const Logger = require('../../logger') | ||
const log = Logger.Log | ||
const _ = require('lodash') | ||
//var log = new Logger.Log(); | ||
var log = new Logger.Log(1); | ||
var commits = {} | ||
var head = null | ||
var branches = { 'master': head } | ||
var curBranch = 'master' | ||
var direction = 'LR' | ||
var seq = 0 | ||
var commits = {}; | ||
var head = null; | ||
var branches = { 'master' : head }; | ||
var curBranch = 'master'; | ||
var direction = 'LR'; | ||
var seq = 0; | ||
function getRandomInt(min, max) { | ||
return Math.floor(Math.random() * (max - min)) + min; | ||
function getRandomInt (min, max) { | ||
return Math.floor(Math.random() * (max - min)) + min | ||
} | ||
function getId() { | ||
var pool='0123456789abcdef'; | ||
var id = ''; | ||
for (var i = 0; i < 7; i++) { | ||
id += pool[getRandomInt(0,16)] | ||
} | ||
return id; | ||
function getId () { | ||
var pool = '0123456789abcdef' | ||
var id = '' | ||
for (var i = 0; i < 7; i++) { | ||
id += pool[getRandomInt(0, 16)] | ||
} | ||
return id | ||
} | ||
function isfastforwardable(currentCommit, otherCommit) { | ||
log.debug('Entering isfastforwardable:', currentCommit.id, otherCommit.id); | ||
while (currentCommit.seq <= otherCommit.seq && currentCommit != otherCommit) { | ||
// only if other branch has more commits | ||
if (otherCommit.parent == null) break; | ||
if (Array.isArray(otherCommit.parent)){ | ||
log.debug('In merge commit:', otherCommit.parent); | ||
return isfastforwardable(currentCommit, commits[otherCommit.parent[0]]) || | ||
isfastforwardable(currentCommit, commits[otherCommit.parent[1]]) | ||
} else { | ||
otherCommit = commits[otherCommit.parent]; | ||
} | ||
function isfastforwardable (currentCommit, otherCommit) { | ||
log.debug('Entering isfastforwardable:', currentCommit.id, otherCommit.id) | ||
while (currentCommit.seq <= otherCommit.seq && currentCommit !== otherCommit) { | ||
// only if other branch has more commits | ||
if (otherCommit.parent == null) break | ||
if (Array.isArray(otherCommit.parent)) { | ||
log.debug('In merge commit:', otherCommit.parent) | ||
return isfastforwardable(currentCommit, commits[otherCommit.parent[0]]) || | ||
isfastforwardable(currentCommit, commits[otherCommit.parent[1]]) | ||
} else { | ||
otherCommit = commits[otherCommit.parent] | ||
} | ||
log.debug(currentCommit.id, otherCommit.id); | ||
return currentCommit.id == otherCommit.id; | ||
} | ||
log.debug(currentCommit.id, otherCommit.id) | ||
return currentCommit.id === otherCommit.id | ||
} | ||
function isReachableFrom(currentCommit, otherCommit) { | ||
var currentSeq = currentCommit.seq; | ||
var otherSeq = otherCommit.seq; | ||
if (currentSeq > otherSeq) return isfastforwardable(otherCommit, currentCommit); | ||
return false; | ||
function isReachableFrom (currentCommit, otherCommit) { | ||
var currentSeq = currentCommit.seq | ||
var otherSeq = otherCommit.seq | ||
if (currentSeq > otherSeq) return isfastforwardable(otherCommit, currentCommit) | ||
return false | ||
} | ||
exports.setDirection = function(dir) { | ||
direction = dir; | ||
exports.setDirection = function (dir) { | ||
direction = dir | ||
} | ||
var options = {}; | ||
exports.setOptions = function(rawOptString) { | ||
log.debug('options str', rawOptString); | ||
rawOptString = rawOptString && rawOptString.trim(); | ||
rawOptString = rawOptString || '{}'; | ||
try { | ||
options = JSON.parse(rawOptString) | ||
} catch(e) { | ||
log.error('error while parsing gitGraph options', e.message); | ||
} | ||
var options = {} | ||
exports.setOptions = function (rawOptString) { | ||
log.debug('options str', rawOptString) | ||
rawOptString = rawOptString && rawOptString.trim() | ||
rawOptString = rawOptString || '{}' | ||
try { | ||
options = JSON.parse(rawOptString) | ||
} catch (e) { | ||
log.error('error while parsing gitGraph options', e.message) | ||
} | ||
} | ||
exports.getOptions = function() { | ||
return options; | ||
exports.getOptions = function () { | ||
return options | ||
} | ||
exports.commit = function(msg) { | ||
var commit = { id: getId(), | ||
message: msg, | ||
seq: seq++, | ||
parent: head == null ? null : head.id}; | ||
head = commit; | ||
commits[commit.id] = commit; | ||
branches[curBranch] = commit.id; | ||
log.debug('in pushCommit ' + commit.id); | ||
exports.commit = function (msg) { | ||
var commit = { | ||
id: getId(), | ||
message: msg, | ||
seq: seq++, | ||
parent: head == null ? null : head.id | ||
} | ||
head = commit | ||
commits[commit.id] = commit | ||
branches[curBranch] = commit.id | ||
log.debug('in pushCommit ' + commit.id) | ||
} | ||
exports.branch = function(name) { | ||
branches[name] = head != null ? head.id: null; | ||
log.debug('in createBranch'); | ||
exports.branch = function (name) { | ||
branches[name] = head != null ? head.id : null | ||
log.debug('in createBranch') | ||
} | ||
exports.merge = function(otherBranch) { | ||
var currentCommit = commits[branches[curBranch]]; | ||
var otherCommit = commits[branches[otherBranch]]; | ||
if (isReachableFrom(currentCommit, otherCommit)) { | ||
log.debug('Already merged'); | ||
return; | ||
exports.merge = function (otherBranch) { | ||
var currentCommit = commits[branches[curBranch]] | ||
var otherCommit = commits[branches[otherBranch]] | ||
if (isReachableFrom(currentCommit, otherCommit)) { | ||
log.debug('Already merged') | ||
return | ||
} | ||
if (isfastforwardable(currentCommit, otherCommit)) { | ||
branches[curBranch] = branches[otherBranch] | ||
head = commits[branches[curBranch]] | ||
} else { | ||
// create merge commit | ||
var commit = { | ||
id: getId(), | ||
message: 'merged branch ' + otherBranch + ' into ' + curBranch, | ||
seq: seq++, | ||
parent: [head == null ? null : head.id, branches[otherBranch]] | ||
} | ||
if (isfastforwardable(currentCommit, otherCommit)){ | ||
branches[curBranch] = branches[otherBranch]; | ||
head = commits[branches[curBranch]]; | ||
} else { | ||
// create merge commit | ||
var commit = { | ||
id: getId(), | ||
message: 'merged branch ' + otherBranch + ' into ' + curBranch, | ||
seq: seq++, | ||
parent: [head == null ? null : head.id, branches[otherBranch]] | ||
}; | ||
head = commit; | ||
commits[commit.id] = commit; | ||
branches[curBranch] = commit.id; | ||
} | ||
log.debug(branches); | ||
log.debug('in mergeBranch'); | ||
head = commit | ||
commits[commit.id] = commit | ||
branches[curBranch] = commit.id | ||
} | ||
log.debug(branches) | ||
log.debug('in mergeBranch') | ||
} | ||
exports.checkout = function(branch) { | ||
log.debug('in checkout'); | ||
curBranch = branch; | ||
var id = branches[curBranch]; | ||
head = commits[id]; | ||
exports.checkout = function (branch) { | ||
log.debug('in checkout') | ||
curBranch = branch | ||
var id = branches[curBranch] | ||
head = commits[id] | ||
} | ||
exports.reset = function(commitRef) { | ||
log.debug('in reset', commitRef); | ||
var ref = commitRef.split(':')[0]; | ||
var parentCount = parseInt(commitRef.split(':')[1]); | ||
var commit = ref == 'HEAD' ? head : commits[branches[ref]]; | ||
log.debug(commit, parentCount); | ||
while (parentCount > 0) { | ||
commit = commits[commit.parent]; | ||
parentCount--; | ||
if (!commit) { | ||
var err = 'Critical error - unique parent commit not found during reset'; | ||
log.error(err); | ||
throw err; | ||
} | ||
exports.reset = function (commitRef) { | ||
log.debug('in reset', commitRef) | ||
var ref = commitRef.split(':')[0] | ||
var parentCount = parseInt(commitRef.split(':')[1]) | ||
var commit = ref === 'HEAD' ? head : commits[branches[ref]] | ||
log.debug(commit, parentCount) | ||
while (parentCount > 0) { | ||
commit = commits[commit.parent] | ||
parentCount-- | ||
if (!commit) { | ||
var err = 'Critical error - unique parent commit not found during reset' | ||
log.error(err) | ||
throw err | ||
} | ||
head = commit; | ||
branches[curBranch] = commit.id; | ||
} | ||
head = commit | ||
branches[curBranch] = commit.id | ||
} | ||
function upsert(arr, key, newval) { | ||
var match = _.find(arr, key); | ||
if(match){ | ||
var index = _.indexOf(arr, _.find(arr, key)); | ||
arr.splice(index, 1, newval); | ||
} else { | ||
arr.push(newval); | ||
} | ||
//console.log(arr); | ||
function upsert (arr, key, newval) { | ||
const index = arr.indexOf(key) | ||
if (index === -1) { | ||
arr.push(newval) | ||
} else { | ||
arr.splice(index, 1, newval) | ||
} | ||
} | ||
function prettyPrintCommitHistory(commitArr) { | ||
var commit = _.maxBy(commitArr, 'seq'); | ||
var line = ''; | ||
_.each(commitArr, function(c) { | ||
if (c == commit) { | ||
line += '\t*' | ||
} else { | ||
line +='\t|' | ||
} | ||
}); | ||
var label = [line, commit.id, commit.seq]; | ||
_.each(branches, function(v,k){ | ||
if (v == commit.id) label.push(k); | ||
}); | ||
log.debug(label.join(' ')); | ||
if (Array.isArray(commit.parent)) { | ||
//console.log("here", commit.parent); | ||
var newCommit = commits[commit.parent[0]]; | ||
upsert(commitArr, commit, newCommit); | ||
commitArr.push(commits[commit.parent[1]]); | ||
//console.log("shoudl have 2", commitArr); | ||
} else if(commit.parent == null){ | ||
return; | ||
function prettyPrintCommitHistory (commitArr) { | ||
var commit = _.maxBy(commitArr, 'seq') | ||
var line = '' | ||
commitArr.forEach(function (c) { | ||
if (c === commit) { | ||
line += '\t*' | ||
} else { | ||
var nextCommit = commits[commit.parent]; | ||
upsert(commitArr, commit, nextCommit); | ||
line += '\t|' | ||
} | ||
commitArr = _.uniqBy(commitArr, 'id'); | ||
prettyPrintCommitHistory(commitArr); | ||
}) | ||
var label = [line, commit.id, commit.seq] | ||
_.each(branches, function (value, key) { | ||
if (value === commit.id) label.push(key) | ||
}) | ||
log.debug(label.join(' ')) | ||
if (Array.isArray(commit.parent)) { | ||
var newCommit = commits[commit.parent[0]] | ||
upsert(commitArr, commit, newCommit) | ||
commitArr.push(commits[commit.parent[1]]) | ||
} else if (commit.parent == null) { | ||
return | ||
} else { | ||
var nextCommit = commits[commit.parent] | ||
upsert(commitArr, commit, nextCommit) | ||
} | ||
commitArr = _.uniqBy(commitArr, 'id') | ||
prettyPrintCommitHistory(commitArr) | ||
} | ||
exports.prettyPrint = function() { | ||
log.debug(commits); | ||
var node = exports.getCommitsArray()[0]; | ||
prettyPrintCommitHistory([node]); | ||
exports.prettyPrint = function () { | ||
log.debug(commits) | ||
var node = exports.getCommitsArray()[0] | ||
prettyPrintCommitHistory([node]) | ||
} | ||
exports.clear = function () { | ||
commits = {}; | ||
head = null; | ||
branches = { 'master' : head }; | ||
curBranch = 'master'; | ||
seq =0; | ||
commits = {} | ||
head = null | ||
branches = { 'master': head } | ||
curBranch = 'master' | ||
seq = 0 | ||
} | ||
exports.getBranchesAsObjArray = function() { | ||
var branchArr = _.map(branches, function(v,k) { | ||
return {'name': k, 'commit': commits[v]}; | ||
}); | ||
//return _.orderBy(branchArr, [function(b) { return b.commit.seq}], ['desc']); | ||
return branchArr; | ||
exports.getBranchesAsObjArray = function () { | ||
const branchArr = _.map(branches, function (value, key) { | ||
return { 'name': key, 'commit': commits[value] } | ||
}) | ||
return branchArr | ||
} | ||
exports.getBranches = function() { return branches; } | ||
exports.getCommits = function() { return commits; } | ||
exports.getCommitsArray = function() { | ||
var commitArr = Object.keys(commits).map(function (key) { | ||
return commits[key]; | ||
}); | ||
_.each(commitArr, function(o) { log.debug(o.id) }); | ||
return _.orderBy(commitArr, ['seq'], ['desc']); | ||
} | ||
exports.getCurrentBranch = function() { return curBranch; } | ||
exports.getDirection = function() { return direction; } | ||
exports.getHead = function() { return head; } | ||
exports.getBranches = function () { return branches } | ||
exports.getCommits = function () { return commits } | ||
exports.getCommitsArray = function () { | ||
var commitArr = Object.keys(commits).map(function (key) { | ||
return commits[key] | ||
}) | ||
commitArr.forEach(function (o) { log.debug(o.id) }) | ||
return _.orderBy(commitArr, ['seq'], ['desc']) | ||
} | ||
exports.getCurrentBranch = function () { return curBranch } | ||
exports.getDirection = function () { return direction } | ||
exports.getHead = function () { return head } |
@@ -1,253 +0,243 @@ | ||
var parser = require('./parser/gitGraph').parser; | ||
var ast = require('./gitGraphAst.js'); | ||
describe('when parsing a gitGraph',function() { | ||
'use strict'; | ||
beforeEach(function () { | ||
console.log('ast',ast); | ||
console.log('parser',parser); | ||
parser.yy = ast; | ||
parser.yy.clear(); | ||
}); | ||
it('should handle a gitGraph defintion', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n'; | ||
/* eslint-env jasmine */ | ||
var parser = require('./parser/gitGraph').parser | ||
var ast = require('./gitGraphAst.js') | ||
describe('when parsing a gitGraph', function () { | ||
'use strict' | ||
beforeEach(function () { | ||
console.log('ast', ast) | ||
console.log('parser', parser) | ||
parser.yy = ast | ||
parser.yy.clear() | ||
}) | ||
it('should handle a gitGraph defintion', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' | ||
parser.parse(str); | ||
var commits = parser.yy.getCommits(); | ||
//console.log(commits); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(1); | ||
expect(parser.yy.getCurrentBranch()).toBe('master'); | ||
expect(parser.yy.getDirection()).toBe('LR'); | ||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1); | ||
}); | ||
expect(Object.keys(commits).length).toBe(1) | ||
expect(parser.yy.getCurrentBranch()).toBe('master') | ||
expect(parser.yy.getDirection()).toBe('LR') | ||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1) | ||
}) | ||
it('should handle a gitGraph defintion with empty options', function () { | ||
var str = 'gitGraph:\n' + | ||
'options\n' + | ||
'end\n' + | ||
'commit\n'; | ||
it('should handle a gitGraph defintion with empty options', function () { | ||
var str = 'gitGraph:\n' + | ||
'options\n' + | ||
'end\n' + | ||
'commit\n' | ||
parser.parse(str); | ||
var commits = parser.yy.getCommits(); | ||
//console.log(commits); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits() | ||
expect(parser.yy.getOptions()).toEqual({}); | ||
expect(Object.keys(commits).length).toBe(1); | ||
expect(parser.yy.getCurrentBranch()).toBe('master'); | ||
expect(parser.yy.getDirection()).toBe('LR'); | ||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1); | ||
}); | ||
expect(parser.yy.getOptions()).toEqual({}) | ||
expect(Object.keys(commits).length).toBe(1) | ||
expect(parser.yy.getCurrentBranch()).toBe('master') | ||
expect(parser.yy.getDirection()).toBe('LR') | ||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1) | ||
}) | ||
it('should handle a gitGraph defintion with valid options', function () { | ||
var str = 'gitGraph:\n' + | ||
'options\n' + | ||
'{"key": "value"}\n' + | ||
'end\n' + | ||
'commit\n'; | ||
it('should handle a gitGraph defintion with valid options', function () { | ||
var str = 'gitGraph:\n' + | ||
'options\n' + | ||
'{"key": "value"}\n' + | ||
'end\n' + | ||
'commit\n' | ||
parser.parse(str); | ||
var commits = parser.yy.getCommits(); | ||
//console.log(commits); | ||
//console.log('options object', parser.yy.getOptions()); | ||
expect(parser.yy.getOptions()['key']).toBe('value'); | ||
expect(Object.keys(commits).length).toBe(1); | ||
expect(parser.yy.getCurrentBranch()).toBe('master'); | ||
expect(parser.yy.getDirection()).toBe('LR'); | ||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1); | ||
}); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits() | ||
expect(parser.yy.getOptions()['key']).toBe('value') | ||
expect(Object.keys(commits).length).toBe(1) | ||
expect(parser.yy.getCurrentBranch()).toBe('master') | ||
expect(parser.yy.getDirection()).toBe('LR') | ||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1) | ||
}) | ||
it('should not fail on a gitGraph with malformed json', function () { | ||
var str = 'gitGraph:\n' + | ||
'options\n' + | ||
'{"key": "value"\n' + | ||
'end\n' + | ||
'commit\n'; | ||
it('should not fail on a gitGraph with malformed json', function () { | ||
var str = 'gitGraph:\n' + | ||
'options\n' + | ||
'{"key": "value"\n' + | ||
'end\n' + | ||
'commit\n' | ||
parser.parse(str); | ||
var commits = parser.yy.getCommits(); | ||
//console.log(commits); | ||
expect(Object.keys(commits).length).toBe(1); | ||
expect(parser.yy.getCurrentBranch()).toBe('master'); | ||
expect(parser.yy.getDirection()).toBe('LR'); | ||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1); | ||
}); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(1) | ||
expect(parser.yy.getCurrentBranch()).toBe('master') | ||
expect(parser.yy.getDirection()).toBe('LR') | ||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1) | ||
}) | ||
it('should handle set direction', function () { | ||
var str = 'gitGraph BT:\n' + | ||
'commit\n'; | ||
it('should handle set direction', function () { | ||
var str = 'gitGraph BT:\n' + | ||
'commit\n' | ||
parser.parse(str); | ||
var commits = parser.yy.getCommits(); | ||
//console.log(commits); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(1); | ||
expect(parser.yy.getCurrentBranch()).toBe('master'); | ||
expect(parser.yy.getDirection()).toBe('BT'); | ||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1); | ||
}); | ||
expect(Object.keys(commits).length).toBe(1) | ||
expect(parser.yy.getCurrentBranch()).toBe('master') | ||
expect(parser.yy.getDirection()).toBe('BT') | ||
expect(Object.keys(parser.yy.getBranches()).length).toBe(1) | ||
}) | ||
it('should checkout a branch', function () { | ||
var str = 'gitGraph:\n' + | ||
'branch new\n' + | ||
'checkout new\n' | ||
it('should checkout a branch', function () { | ||
var str = 'gitGraph:\n' + | ||
'branch new\n' + | ||
'checkout new\n' | ||
parser.parse(str); | ||
var commits = parser.yy.getCommits(); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(0); | ||
expect(parser.yy.getCurrentBranch()).toBe('new'); | ||
}); | ||
expect(Object.keys(commits).length).toBe(0) | ||
expect(parser.yy.getCurrentBranch()).toBe('new') | ||
}) | ||
it('should add commits to checked out branch', function () { | ||
var str = 'gitGraph:\n' + | ||
'branch new\n' + | ||
'checkout new\n' + | ||
'commit\n'+ | ||
'commit\n' | ||
it('should add commits to checked out branch', function () { | ||
var str = 'gitGraph:\n' + | ||
'branch new\n' + | ||
'checkout new\n' + | ||
'commit\n' + | ||
'commit\n' | ||
parser.parse(str); | ||
var commits = parser.yy.getCommits(); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(2); | ||
expect(parser.yy.getCurrentBranch()).toBe('new'); | ||
var branchCommit = parser.yy.getBranches()['new']; | ||
expect(branchCommit).not.toBeNull(); | ||
expect(commits[branchCommit].parent).not.toBeNull(); | ||
}); | ||
it('should handle commit with args', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit "a commit"\n'; | ||
expect(Object.keys(commits).length).toBe(2) | ||
expect(parser.yy.getCurrentBranch()).toBe('new') | ||
var branchCommit = parser.yy.getBranches()['new'] | ||
expect(branchCommit).not.toBeNull() | ||
expect(commits[branchCommit].parent).not.toBeNull() | ||
}) | ||
it('should handle commit with args', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit "a commit"\n' | ||
parser.parse(str); | ||
var commits = parser.yy.getCommits(); | ||
//console.log(commits); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(1); | ||
var key = Object.keys(commits)[0]; | ||
expect(commits[key].message).toBe('a commit'); | ||
expect(parser.yy.getCurrentBranch()).toBe('master'); | ||
}); | ||
expect(Object.keys(commits).length).toBe(1) | ||
var key = Object.keys(commits)[0] | ||
expect(commits[key].message).toBe('a commit') | ||
expect(parser.yy.getCurrentBranch()).toBe('master') | ||
}) | ||
it('it should reset a branch', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'reset master\n'; | ||
it('it should reset a branch', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'reset master\n' | ||
parser.parse(str); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits(); | ||
expect(Object.keys(commits).length).toBe(3); | ||
expect(parser.yy.getCurrentBranch()).toBe('newbranch'); | ||
expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['master']); | ||
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']); | ||
}); | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(3) | ||
expect(parser.yy.getCurrentBranch()).toBe('newbranch') | ||
expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['master']) | ||
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']) | ||
}) | ||
it('reset can take an argument', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'reset master^\n'; | ||
it('reset can take an argument', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'reset master^\n' | ||
parser.parse(str); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits(); | ||
expect(Object.keys(commits).length).toBe(3); | ||
expect(parser.yy.getCurrentBranch()).toBe('newbranch'); | ||
var master = commits[parser.yy.getBranches()['master']]; | ||
expect(parser.yy.getHead().id).toEqual(master.parent); | ||
}) | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(3) | ||
expect(parser.yy.getCurrentBranch()).toBe('newbranch') | ||
var master = commits[parser.yy.getBranches()['master']] | ||
expect(parser.yy.getHead().id).toEqual(master.parent) | ||
}) | ||
it('it should handle fast forwardable merges', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'checkout master\n'+ | ||
'merge newbranch\n'; | ||
it('it should handle fast forwardable merges', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'checkout master\n' + | ||
'merge newbranch\n' | ||
parser.parse(str); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits(); | ||
//console.log(commits); | ||
expect(Object.keys(commits).length).toBe(3); | ||
expect(parser.yy.getCurrentBranch()).toBe('master'); | ||
expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['master']); | ||
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']); | ||
}); | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(3) | ||
expect(parser.yy.getCurrentBranch()).toBe('master') | ||
expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['master']) | ||
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']) | ||
}) | ||
it('it should handle cases when merge is a noop', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'merge master\n'; | ||
it('it should handle cases when merge is a noop', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'merge master\n' | ||
parser.parse(str); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits(); | ||
//console.log(commits); | ||
expect(Object.keys(commits).length).toBe(3); | ||
expect(parser.yy.getCurrentBranch()).toBe('newbranch'); | ||
expect(parser.yy.getBranches()['newbranch']).not.toEqual(parser.yy.getBranches()['master']); | ||
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']); | ||
}); | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(3) | ||
expect(parser.yy.getCurrentBranch()).toBe('newbranch') | ||
expect(parser.yy.getBranches()['newbranch']).not.toEqual(parser.yy.getBranches()['master']) | ||
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']) | ||
}) | ||
it('it should handle merge with 2 parents', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'checkout master\n' + | ||
'commit\n' + | ||
'merge newbranch\n'; | ||
it('it should handle merge with 2 parents', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'checkout master\n' + | ||
'commit\n' + | ||
'merge newbranch\n' | ||
parser.parse(str); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits(); | ||
//console.log(commits); | ||
expect(Object.keys(commits).length).toBe(5); | ||
expect(parser.yy.getCurrentBranch()).toBe('master'); | ||
expect(parser.yy.getBranches()['newbranch']).not.toEqual(parser.yy.getBranches()['master']); | ||
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['master']); | ||
}); | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(5) | ||
expect(parser.yy.getCurrentBranch()).toBe('master') | ||
expect(parser.yy.getBranches()['newbranch']).not.toEqual(parser.yy.getBranches()['master']) | ||
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['master']) | ||
}) | ||
it('it should handle ff merge when history walk has two parents (merge commit)', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'checkout master\n' + | ||
'commit\n' + | ||
'merge newbranch\n' + | ||
'commit\n' + | ||
'checkout newbranch\n' + | ||
'merge master\n' ; | ||
it('it should handle ff merge when history walk has two parents (merge commit)', function () { | ||
var str = 'gitGraph:\n' + | ||
'commit\n' + | ||
'branch newbranch\n' + | ||
'checkout newbranch\n' + | ||
'commit\n' + | ||
'commit\n' + | ||
'checkout master\n' + | ||
'commit\n' + | ||
'merge newbranch\n' + | ||
'commit\n' + | ||
'checkout newbranch\n' + | ||
'merge master\n' | ||
parser.parse(str); | ||
parser.parse(str) | ||
var commits = parser.yy.getCommits(); | ||
//console.log(commits); | ||
expect(Object.keys(commits).length).toBe(6); | ||
expect(parser.yy.getCurrentBranch()).toBe('newbranch'); | ||
expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['master']); | ||
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['master']); | ||
var commits = parser.yy.getCommits() | ||
expect(Object.keys(commits).length).toBe(6) | ||
expect(parser.yy.getCurrentBranch()).toBe('newbranch') | ||
expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['master']) | ||
expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['master']) | ||
parser.yy.prettyPrint(); | ||
}); | ||
}); | ||
parser.yy.prettyPrint() | ||
}) | ||
}) |
@@ -1,282 +0,274 @@ | ||
var db = require('./gitGraphAst'); | ||
var _ = require('lodash'); | ||
var gitGraphParser = require('./parser/gitGraph'); | ||
var d3 = require('../../d3'); | ||
var Logger = require('../../logger'); | ||
const db = require('./gitGraphAst') | ||
const _ = require('lodash') | ||
const gitGraphParser = require('./parser/gitGraph') | ||
const d3 = require('../../d3') | ||
const Logger = require('../../logger') | ||
const log = Logger.Log | ||
var log = new Logger.Log(); | ||
var allCommitsDict = {}; | ||
var branchNum; | ||
var allCommitsDict = {} | ||
var branchNum | ||
var config = { | ||
nodeSpacing: 75, | ||
nodeFillColor: 'yellow', | ||
nodeStrokeWidth: 2, | ||
nodeStrokeColor: 'grey', | ||
lineStrokeWidth: 4, | ||
branchOffset: 50, | ||
lineColor: 'grey', | ||
leftMargin: 50, | ||
branchColors: ['#442f74', '#983351', '#609732', '#AA9A39'], | ||
nodeRadius: 15, | ||
nodeLabel: { | ||
width: 75, | ||
height: 100, | ||
x: -25, | ||
y: 15 | ||
} | ||
nodeSpacing: 150, | ||
nodeFillColor: 'yellow', | ||
nodeStrokeWidth: 2, | ||
nodeStrokeColor: 'grey', | ||
lineStrokeWidth: 4, | ||
branchOffset: 50, | ||
lineColor: 'grey', | ||
leftMargin: 50, | ||
branchColors: ['#442f74', '#983351', '#609732', '#AA9A39'], | ||
nodeRadius: 10, | ||
nodeLabel: { | ||
width: 75, | ||
height: 100, | ||
x: -25, | ||
y: 0 | ||
} | ||
} | ||
var apiConfig = {}; | ||
exports.setConf = function(c) { | ||
apiConfig = c; | ||
var apiConfig = {} | ||
exports.setConf = function (c) { | ||
apiConfig = c | ||
} | ||
function svgCreateDefs(svg) { | ||
svg | ||
.append('defs') | ||
.append('g') | ||
.attr('id', 'def-commit') | ||
.append('circle') | ||
.attr('r', config.nodeRadius) | ||
.attr('cx', 0) | ||
.attr('cy', 0); | ||
svg.select('#def-commit') | ||
.append('foreignObject') | ||
.attr('width', config.nodeLabel.width) | ||
.attr('height', config.nodeLabel.height) | ||
.attr('x', config.nodeLabel.x) | ||
.attr('y', config.nodeLabel.y) | ||
.attr('class', 'node-label') | ||
.attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility') | ||
.append('xhtml:p') | ||
.html(''); | ||
function svgCreateDefs (svg) { | ||
svg | ||
.append('defs') | ||
.append('g') | ||
.attr('id', 'def-commit') | ||
.append('circle') | ||
.attr('r', config.nodeRadius) | ||
.attr('cx', 0) | ||
.attr('cy', 0) | ||
svg.select('#def-commit') | ||
.append('foreignObject') | ||
.attr('width', config.nodeLabel.width) | ||
.attr('height', config.nodeLabel.height) | ||
.attr('x', config.nodeLabel.x) | ||
.attr('y', config.nodeLabel.y) | ||
.attr('class', 'node-label') | ||
.attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility') | ||
.append('xhtml:p') | ||
.html('') | ||
} | ||
function svgDrawLine (svg, points, colorIdx, interpolate) { | ||
interpolate = interpolate || 'basis' | ||
var color = config.branchColors[colorIdx % config.branchColors.length] | ||
var lineGen = d3.svg.line() | ||
.x(function (d) { | ||
return Math.round(d.x) | ||
}) | ||
.y(function (d) { | ||
return Math.round(d.y) | ||
}) | ||
.interpolate(interpolate) | ||
function svgDrawLine(svg, points, colorIdx, interpolate) { | ||
interpolate = interpolate || 'basis'; | ||
var color = config.branchColors[colorIdx % config.branchColors.length]; | ||
var lineGen = d3.svg.line() | ||
.x(function(d) { | ||
return Math.round(d.x) | ||
}) | ||
.y(function(d) { | ||
return Math.round(d.y) | ||
}) | ||
.interpolate(interpolate); | ||
svg | ||
.append('svg:path') | ||
.attr('d', lineGen(points)) | ||
.style('stroke', color) | ||
.style('stroke-width', config.lineStrokeWidth) | ||
.style('fill', 'none'); | ||
svg | ||
.append('svg:path') | ||
.attr('d', lineGen(points)) | ||
.style('stroke', color) | ||
.style('stroke-width', config.lineStrokeWidth) | ||
.style('fill', 'none') | ||
} | ||
// Pass in the element and its pre-transform coords | ||
function getElementCoords(element, coords) { | ||
coords = coords || element.node().getBBox(); | ||
var ctm = element.node().getCTM(), | ||
xn = ctm.e + coords.x * ctm.a, | ||
yn = ctm.f + coords.y * ctm.d; | ||
//log.debug(ctm, coords); | ||
return { | ||
left: xn, | ||
top: yn, | ||
width: coords.width, | ||
height: coords.height | ||
}; | ||
function getElementCoords (element, coords) { | ||
coords = coords || element.node().getBBox() | ||
var ctm = element.node().getCTM() | ||
var xn = ctm.e + coords.x * ctm.a | ||
var yn = ctm.f + coords.y * ctm.d | ||
return { | ||
left: xn, | ||
top: yn, | ||
width: coords.width, | ||
height: coords.height | ||
} | ||
} | ||
function svgDrawLineForCommits(svg, fromId, toId, direction, color) { | ||
log.debug('svgDrawLineForCommits: ', fromId, toId); | ||
var fromBbox = getElementCoords(svg.select('#node-' + fromId + ' circle')); | ||
var toBbox = getElementCoords(svg.select('#node-' + toId + ' circle')); | ||
//log.debug('svgDrawLineForCommits: ', fromBbox, toBbox); | ||
switch (direction) { | ||
case 'LR': | ||
// (toBbox) | ||
// +-------- | ||
// + (fromBbox) | ||
if (fromBbox.left - toBbox.left > config.nodeSpacing) { | ||
var lineStart = { x: fromBbox.left - config.nodeSpacing, y: toBbox.top + toBbox.height/2}; | ||
var lineEnd ={ x: toBbox.left + toBbox.width, y: toBbox.top + toBbox.height/2 }; | ||
svgDrawLine(svg, [lineStart , lineEnd], color, 'linear') | ||
svgDrawLine(svg, [ | ||
{x: fromBbox.left, y: fromBbox.top + fromBbox.height/2}, | ||
{x: fromBbox.left - config.nodeSpacing/2, y: fromBbox.top + fromBbox.height/2}, | ||
{x: fromBbox.left - config.nodeSpacing/2, y: lineStart.y}, | ||
lineStart], color); | ||
} else { | ||
svgDrawLine(svg, [{ | ||
'x': fromBbox.left, | ||
'y': fromBbox.top + fromBbox.height / 2 | ||
}, { | ||
'x': fromBbox.left - config.nodeSpacing/2, | ||
'y': fromBbox.top + fromBbox.height / 2 | ||
}, { | ||
'x': fromBbox.left - config.nodeSpacing/2, | ||
'y': toBbox.top + toBbox.height / 2 | ||
}, { | ||
'x': toBbox.left + toBbox.width, | ||
'y': toBbox.top + toBbox.height / 2 | ||
}], color); | ||
} | ||
break; | ||
case 'BT': | ||
// + (fromBbox) | ||
// | | ||
// | | ||
// + (toBbox) | ||
if (toBbox.top - fromBbox.top > config.nodeSpacing) { | ||
lineStart = { x: toBbox.left + toBbox.width/2, y: fromBbox.top + fromBbox.height + config.nodeSpacing}; | ||
lineEnd ={ x: toBbox.left + toBbox.width/2, y: toBbox.top }; | ||
svgDrawLine(svg, [lineStart , lineEnd], color, 'linear') | ||
svgDrawLine(svg, [ | ||
{x: fromBbox.left + fromBbox.width/2, y: fromBbox.top + fromBbox.height}, | ||
{x: fromBbox.left + fromBbox.width/2, y: fromBbox.top + fromBbox.height + config.nodeSpacing/2}, | ||
{x: toBbox.left + toBbox.width/2, y: lineStart.y - config.nodeSpacing/2}, | ||
lineStart], color); | ||
} else { | ||
svgDrawLine(svg, [{ | ||
'x': fromBbox.left + fromBbox.width/2, | ||
'y': fromBbox.top + fromBbox.height | ||
}, { | ||
'x': fromBbox.left + fromBbox.width/2, | ||
'y': fromBbox.top + config.nodeSpacing/2 | ||
}, { | ||
'x': toBbox.left + toBbox.width/2, | ||
'y': toBbox.top - config.nodeSpacing/2 | ||
}, { | ||
'x': toBbox.left + toBbox.width/2, | ||
'y': toBbox.top | ||
}], color); | ||
} | ||
break; | ||
} | ||
function svgDrawLineForCommits (svg, fromId, toId, direction, color) { | ||
log.debug('svgDrawLineForCommits: ', fromId, toId) | ||
var fromBbox = getElementCoords(svg.select('#node-' + fromId + ' circle')) | ||
var toBbox = getElementCoords(svg.select('#node-' + toId + ' circle')) | ||
switch (direction) { | ||
case 'LR': | ||
// (toBbox) | ||
// +-------- | ||
// + (fromBbox) | ||
if (fromBbox.left - toBbox.left > config.nodeSpacing) { | ||
var lineStart = { x: fromBbox.left - config.nodeSpacing, y: toBbox.top + toBbox.height / 2 } | ||
var lineEnd = { x: toBbox.left + toBbox.width, y: toBbox.top + toBbox.height / 2 } | ||
svgDrawLine(svg, [lineStart, lineEnd], color, 'linear') | ||
svgDrawLine(svg, [ | ||
{ x: fromBbox.left, y: fromBbox.top + fromBbox.height / 2 }, | ||
{ x: fromBbox.left - config.nodeSpacing / 2, y: fromBbox.top + fromBbox.height / 2 }, | ||
{ x: fromBbox.left - config.nodeSpacing / 2, y: lineStart.y }, | ||
lineStart], color) | ||
} else { | ||
svgDrawLine(svg, [{ | ||
'x': fromBbox.left, | ||
'y': fromBbox.top + fromBbox.height / 2 | ||
}, { | ||
'x': fromBbox.left - config.nodeSpacing / 2, | ||
'y': fromBbox.top + fromBbox.height / 2 | ||
}, { | ||
'x': fromBbox.left - config.nodeSpacing / 2, | ||
'y': toBbox.top + toBbox.height / 2 | ||
}, { | ||
'x': toBbox.left + toBbox.width, | ||
'y': toBbox.top + toBbox.height / 2 | ||
}], color) | ||
} | ||
break | ||
case 'BT': | ||
// + (fromBbox) | ||
// | | ||
// | | ||
// + (toBbox) | ||
if (toBbox.top - fromBbox.top > config.nodeSpacing) { | ||
lineStart = { x: toBbox.left + toBbox.width / 2, y: fromBbox.top + fromBbox.height + config.nodeSpacing } | ||
lineEnd = { x: toBbox.left + toBbox.width / 2, y: toBbox.top } | ||
svgDrawLine(svg, [lineStart, lineEnd], color, 'linear') | ||
svgDrawLine(svg, [ | ||
{ x: fromBbox.left + fromBbox.width / 2, y: fromBbox.top + fromBbox.height }, | ||
{ x: fromBbox.left + fromBbox.width / 2, y: fromBbox.top + fromBbox.height + config.nodeSpacing / 2 }, | ||
{ x: toBbox.left + toBbox.width / 2, y: lineStart.y - config.nodeSpacing / 2 }, | ||
lineStart], color) | ||
} else { | ||
svgDrawLine(svg, [{ | ||
'x': fromBbox.left + fromBbox.width / 2, | ||
'y': fromBbox.top + fromBbox.height | ||
}, { | ||
'x': fromBbox.left + fromBbox.width / 2, | ||
'y': fromBbox.top + config.nodeSpacing / 2 | ||
}, { | ||
'x': toBbox.left + toBbox.width / 2, | ||
'y': toBbox.top - config.nodeSpacing / 2 | ||
}, { | ||
'x': toBbox.left + toBbox.width / 2, | ||
'y': toBbox.top | ||
}], color) | ||
} | ||
break | ||
} | ||
} | ||
function cloneNode(svg, selector) { | ||
return svg.select(selector).node().cloneNode(true); | ||
function cloneNode (svg, selector) { | ||
return svg.select(selector).node().cloneNode(true) | ||
} | ||
function renderCommitHistory(svg, commitid, branches, direction) { | ||
var commit; | ||
var numCommits = Object.keys(allCommitsDict).length; | ||
if (_.isString(commitid)) { | ||
do { | ||
commit = allCommitsDict[commitid]; | ||
log.debug('in renderCommitHistory', commit.id, commit.seq); | ||
if (svg.select('#node-' + commitid).size() > 0) { | ||
return; | ||
} | ||
svg | ||
.append(function() { | ||
return cloneNode(svg, '#def-commit'); | ||
}) | ||
.attr('class', 'commit') | ||
.attr('id', function() { | ||
return 'node-' + commit.id; | ||
}) | ||
.attr('transform', function() { | ||
switch (direction) { | ||
case 'LR': | ||
return 'translate(' + (commit.seq * config.nodeSpacing + config.leftMargin) + ', ' | ||
+ (branchNum * config.branchOffset) + ')'; | ||
case 'BT': | ||
return 'translate(' + (branchNum * config.branchOffset + config.leftMargin) + ', ' | ||
+ ((numCommits - commit.seq) * config.nodeSpacing) + ')'; | ||
} | ||
}) | ||
.attr('fill', config.nodeFillColor) | ||
.attr('stroke', config.nodeStrokeColor) | ||
.attr('stroke-width', config.nodeStrokeWidth); | ||
function renderCommitHistory (svg, commitid, branches, direction) { | ||
var commit | ||
var numCommits = Object.keys(allCommitsDict).length | ||
if (_.isString(commitid)) { | ||
do { | ||
commit = allCommitsDict[commitid] | ||
log.debug('in renderCommitHistory', commit.id, commit.seq) | ||
if (svg.select('#node-' + commitid).size() > 0) { | ||
return | ||
} | ||
svg | ||
.append(function () { | ||
return cloneNode(svg, '#def-commit') | ||
}) | ||
.attr('class', 'commit') | ||
.attr('id', function () { | ||
return 'node-' + commit.id | ||
}) | ||
.attr('transform', function () { | ||
switch (direction) { | ||
case 'LR': | ||
return 'translate(' + (commit.seq * config.nodeSpacing + config.leftMargin) + ', ' + | ||
(branchNum * config.branchOffset) + ')' | ||
case 'BT': | ||
return 'translate(' + (branchNum * config.branchOffset + config.leftMargin) + ', ' + | ||
((numCommits - commit.seq) * config.nodeSpacing) + ')' | ||
} | ||
}) | ||
.attr('fill', config.nodeFillColor) | ||
.attr('stroke', config.nodeStrokeColor) | ||
.attr('stroke-width', config.nodeStrokeWidth) | ||
var branch = _.find(branches, ['commit', commit]); | ||
if (branch) { | ||
log.debug('found branch ', branch.name); | ||
svg.select('#node-' + commit.id + ' p') | ||
.append('xhtml:span') | ||
.attr('class', 'branch-label') | ||
.text(branch.name + ', '); | ||
} | ||
svg.select('#node-' + commit.id + ' p') | ||
.append('xhtml:span') | ||
.attr('class', 'commit-id') | ||
.text(commit.id); | ||
if (commit.message !== '' && direction === 'BT') { | ||
svg.select('#node-' + commit.id + ' p') | ||
.append('xhtml:span') | ||
.attr('class', 'commit-msg') | ||
.text( ', ' + commit.message); | ||
} | ||
commitid = commit.parent | ||
} while (commitid && allCommitsDict[commitid]); | ||
} | ||
var branch = _.find(branches, ['commit', commit]) | ||
if (branch) { | ||
log.debug('found branch ', branch.name) | ||
svg.select('#node-' + commit.id + ' p') | ||
.append('xhtml:span') | ||
.attr('class', 'branch-label') | ||
.text(branch.name + ', ') | ||
} | ||
svg.select('#node-' + commit.id + ' p') | ||
.append('xhtml:span') | ||
.attr('class', 'commit-id') | ||
.text(commit.id) | ||
if (commit.message !== '' && direction === 'BT') { | ||
svg.select('#node-' + commit.id + ' p') | ||
.append('xhtml:span') | ||
.attr('class', 'commit-msg') | ||
.text(', ' + commit.message) | ||
} | ||
commitid = commit.parent | ||
} while (commitid && allCommitsDict[commitid]) | ||
} | ||
if (_.isArray(commitid)) { | ||
log.debug('found merge commmit', commitid); | ||
renderCommitHistory(svg, commitid[0], branches, direction); | ||
branchNum++; | ||
renderCommitHistory(svg, commitid[1], branches, direction); | ||
branchNum--; | ||
} | ||
if (_.isArray(commitid)) { | ||
log.debug('found merge commmit', commitid) | ||
renderCommitHistory(svg, commitid[0], branches, direction) | ||
branchNum++ | ||
renderCommitHistory(svg, commitid[1], branches, direction) | ||
branchNum-- | ||
} | ||
} | ||
function renderLines(svg, commit, direction, branchColor) { | ||
branchColor = branchColor || 0; | ||
while (commit.seq > 0 && !commit.lineDrawn) { | ||
if (_.isString(commit.parent)) { | ||
svgDrawLineForCommits(svg, commit.id, commit.parent, direction, branchColor); | ||
commit.lineDrawn = true; | ||
commit = allCommitsDict[commit.parent]; | ||
} else if (_.isArray(commit.parent)) { | ||
svgDrawLineForCommits(svg, commit.id, commit.parent[0], direction, branchColor) | ||
svgDrawLineForCommits(svg, commit.id, commit.parent[1], direction, branchColor + 1) | ||
renderLines(svg, allCommitsDict[commit.parent[1]], direction, branchColor + 1); | ||
commit.lineDrawn = true; | ||
commit = allCommitsDict[commit.parent[0]]; | ||
} | ||
function renderLines (svg, commit, direction, branchColor) { | ||
branchColor = branchColor || 0 | ||
while (commit.seq > 0 && !commit.lineDrawn) { | ||
if (_.isString(commit.parent)) { | ||
svgDrawLineForCommits(svg, commit.id, commit.parent, direction, branchColor) | ||
commit.lineDrawn = true | ||
commit = allCommitsDict[commit.parent] | ||
} else if (_.isArray(commit.parent)) { | ||
svgDrawLineForCommits(svg, commit.id, commit.parent[0], direction, branchColor) | ||
svgDrawLineForCommits(svg, commit.id, commit.parent[1], direction, branchColor + 1) | ||
renderLines(svg, allCommitsDict[commit.parent[1]], direction, branchColor + 1) | ||
commit.lineDrawn = true | ||
commit = allCommitsDict[commit.parent[0]] | ||
} | ||
} | ||
} | ||
exports.draw = function(txt, id, ver) { | ||
try { | ||
var parser; | ||
parser = gitGraphParser.parser; | ||
parser.yy = db; | ||
exports.draw = function (txt, id, ver) { | ||
try { | ||
var parser | ||
parser = gitGraphParser.parser | ||
parser.yy = db | ||
log.debug('in gitgraph renderer', txt, id, ver); | ||
// Parse the graph definition | ||
parser.parse(txt + '\n'); | ||
log.debug('in gitgraph renderer', txt, id, ver) | ||
// Parse the graph definition | ||
parser.parse(txt + '\n') | ||
config = _.extend(config, apiConfig, db.getOptions()); | ||
log.debug('effective options', config); | ||
var direction = db.getDirection(); | ||
allCommitsDict = db.getCommits(); | ||
var branches = db.getBranchesAsObjArray(); | ||
if (direction === 'BT') { | ||
config.nodeLabel.x = branches.length * config.branchOffset; | ||
config.nodeLabel.width = '100%'; | ||
config.nodeLabel.y = -1 * 2* config.nodeRadius; | ||
} | ||
var svg = d3.select('#' + id); | ||
svgCreateDefs(svg); | ||
branchNum = 1; | ||
_.each(branches, function(v) { | ||
renderCommitHistory(svg, v.commit.id, branches, direction); | ||
renderLines(svg, v.commit, direction); | ||
branchNum++; | ||
}); | ||
svg.attr('height', function() { | ||
if (direction === 'BT') return Object.keys(allCommitsDict).length * config.nodeSpacing; | ||
return (branches.length + 1) * config.branchOffset; | ||
}); | ||
//svg.attr('width', function() { | ||
//if (direction === 'LR') return Object.keys(allCommitsDict).length * config.nodeSpacing + config.leftMargin; | ||
//return (branches.length + 1) * config.branchOffset; | ||
//}); | ||
} catch (e) { | ||
log.error('Error while rendering gitgraph'); | ||
log.error(e.message); | ||
config = _.extend(config, apiConfig, db.getOptions()) | ||
log.debug('effective options', config) | ||
var direction = db.getDirection() | ||
allCommitsDict = db.getCommits() | ||
var branches = db.getBranchesAsObjArray() | ||
if (direction === 'BT') { | ||
config.nodeLabel.x = branches.length * config.branchOffset | ||
config.nodeLabel.width = '100%' | ||
config.nodeLabel.y = -1 * 2 * config.nodeRadius | ||
} | ||
}; | ||
var svg = d3.select('#' + id) | ||
svgCreateDefs(svg) | ||
branchNum = 1 | ||
_.each(branches, function (v) { | ||
renderCommitHistory(svg, v.commit.id, branches, direction) | ||
renderLines(svg, v.commit, direction) | ||
branchNum++ | ||
}) | ||
svg.attr('height', function () { | ||
if (direction === 'BT') return Object.keys(allCommitsDict).length * config.nodeSpacing | ||
return (branches.length + 1) * config.branchOffset | ||
}) | ||
} catch (e) { | ||
log.error('Error while rendering gitgraph') | ||
log.error(e.message) | ||
} | ||
} |
@@ -53,3 +53,2 @@ /* parser generated by jison 0.4.17 */ | ||
token location info (@$, _$, etc.): { | ||
@@ -63,3 +62,2 @@ first_line: n, | ||
the parseError function receives a 'hash' object with these members for lexer and parser errors: { | ||
@@ -76,625 +74,622 @@ text: (matched text) | ||
*/ | ||
var parser = (function(){ | ||
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[2,3],$V1=[1,7],$V2=[7,12,15,17,19,20,21],$V3=[7,11,12,15,17,19,20,21],$V4=[2,20],$V5=[1,32]; | ||
var parser = {trace: function trace() { }, | ||
yy: {}, | ||
symbols_: {"error":2,"start":3,"GG":4,":":5,"document":6,"EOF":7,"DIR":8,"options":9,"body":10,"OPT":11,"NL":12,"line":13,"statement":14,"COMMIT":15,"commit_arg":16,"BRANCH":17,"ID":18,"CHECKOUT":19,"MERGE":20,"RESET":21,"reset_arg":22,"STR":23,"HEAD":24,"reset_parents":25,"CARET":26,"$accept":0,"$end":1}, | ||
terminals_: {2:"error",4:"GG",5:":",7:"EOF",8:"DIR",11:"OPT",12:"NL",15:"COMMIT",17:"BRANCH",18:"ID",19:"CHECKOUT",20:"MERGE",21:"RESET",23:"STR",24:"HEAD",26:"CARET"}, | ||
productions_: [0,[3,4],[3,5],[6,0],[6,2],[9,2],[9,1],[10,0],[10,2],[13,2],[13,1],[14,2],[14,2],[14,2],[14,2],[14,2],[16,0],[16,1],[22,2],[22,2],[25,0],[25,2]], | ||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
var parser = (function () { | ||
var o = function (k, v, o, l) { for (o = o || {}, l = k.length; l--; o[k[l]] = v);return o }, $V0 = [2, 3], $V1 = [1, 7], $V2 = [7, 12, 15, 17, 19, 20, 21], $V3 = [7, 11, 12, 15, 17, 19, 20, 21], $V4 = [2, 20], $V5 = [1, 32] | ||
var parser = {trace: function trace () { }, | ||
yy: {}, | ||
symbols_: {'error': 2, 'start': 3, 'GG': 4, ':': 5, 'document': 6, 'EOF': 7, 'DIR': 8, 'options': 9, 'body': 10, 'OPT': 11, 'NL': 12, 'line': 13, 'statement': 14, 'COMMIT': 15, 'commit_arg': 16, 'BRANCH': 17, 'ID': 18, 'CHECKOUT': 19, 'MERGE': 20, 'RESET': 21, 'reset_arg': 22, 'STR': 23, 'HEAD': 24, 'reset_parents': 25, 'CARET': 26, '$accept': 0, '$end': 1}, | ||
terminals_: {2: 'error', 4: 'GG', 5: ':', 7: 'EOF', 8: 'DIR', 11: 'OPT', 12: 'NL', 15: 'COMMIT', 17: 'BRANCH', 18: 'ID', 19: 'CHECKOUT', 20: 'MERGE', 21: 'RESET', 23: 'STR', 24: 'HEAD', 26: 'CARET'}, | ||
productions_: [0, [3, 4], [3, 5], [6, 0], [6, 2], [9, 2], [9, 1], [10, 0], [10, 2], [13, 2], [13, 1], [14, 2], [14, 2], [14, 2], [14, 2], [14, 2], [16, 0], [16, 1], [22, 2], [22, 2], [25, 0], [25, 2]], | ||
performAction: function anonymous (yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
/* this == yyval */ | ||
var $0 = $$.length - 1; | ||
switch (yystate) { | ||
case 1: | ||
return $$[$0-1]; | ||
break; | ||
case 2: | ||
yy.setDirection($$[$0-3]); return $$[$0-1]; | ||
break; | ||
case 4: | ||
yy.setOptions($$[$0-1]); this.$ = $$[$0] | ||
break; | ||
case 5: | ||
$$[$0-1] +=$$[$0]; this.$=$$[$0-1] | ||
break; | ||
case 7: | ||
this.$ = [] | ||
break; | ||
case 8: | ||
$$[$0-1].push($$[$0]); this.$=$$[$0-1]; | ||
break; | ||
case 9: | ||
this.$ =$$[$0-1] | ||
break; | ||
case 11: | ||
yy.commit($$[$0]) | ||
break; | ||
case 12: | ||
yy.branch($$[$0]) | ||
break; | ||
case 13: | ||
yy.checkout($$[$0]) | ||
break; | ||
case 14: | ||
yy.merge($$[$0]) | ||
break; | ||
case 15: | ||
yy.reset($$[$0]) | ||
break; | ||
case 16: | ||
this.$ = "" | ||
break; | ||
case 17: | ||
this.$=$$[$0] | ||
break; | ||
case 18: | ||
this.$ = $$[$0-1]+ ":" + $$[$0] | ||
break; | ||
case 19: | ||
this.$ = $$[$0-1]+ ":" + yy.count; yy.count = 0 | ||
break; | ||
case 20: | ||
yy.count = 0 | ||
break; | ||
case 21: | ||
yy.count += 1 | ||
break; | ||
} | ||
}, | ||
table: [{3:1,4:[1,2]},{1:[3]},{5:[1,3],8:[1,4]},{6:5,7:$V0,9:6,12:$V1},{5:[1,8]},{7:[1,9]},o($V2,[2,7],{10:10,11:[1,11]}),o($V3,[2,6]),{6:12,7:$V0,9:6,12:$V1},{1:[2,1]},{7:[2,4],12:[1,15],13:13,14:14,15:[1,16],17:[1,17],19:[1,18],20:[1,19],21:[1,20]},o($V3,[2,5]),{7:[1,21]},o($V2,[2,8]),{12:[1,22]},o($V2,[2,10]),{12:[2,16],16:23,23:[1,24]},{18:[1,25]},{18:[1,26]},{18:[1,27]},{18:[1,30],22:28,24:[1,29]},{1:[2,2]},o($V2,[2,9]),{12:[2,11]},{12:[2,17]},{12:[2,12]},{12:[2,13]},{12:[2,14]},{12:[2,15]},{12:$V4,25:31,26:$V5},{12:$V4,25:33,26:$V5},{12:[2,18]},{12:$V4,25:34,26:$V5},{12:[2,19]},{12:[2,21]}], | ||
defaultActions: {9:[2,1],21:[2,2],23:[2,11],24:[2,17],25:[2,12],26:[2,13],27:[2,14],28:[2,15],31:[2,18],33:[2,19],34:[2,21]}, | ||
parseError: function parseError(str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str); | ||
} else { | ||
var $0 = $$.length - 1 | ||
switch (yystate) { | ||
case 1: | ||
return $$[$0 - 1] | ||
break | ||
case 2: | ||
yy.setDirection($$[$0 - 3]); return $$[$0 - 1] | ||
break | ||
case 4: | ||
yy.setOptions($$[$0 - 1]); this.$ = $$[$0] | ||
break | ||
case 5: | ||
$$[$0 - 1] += $$[$0]; this.$ = $$[$0 - 1] | ||
break | ||
case 7: | ||
this.$ = [] | ||
break | ||
case 8: | ||
$$[$0 - 1].push($$[$0]); this.$ = $$[$0 - 1] | ||
break | ||
case 9: | ||
this.$ = $$[$0 - 1] | ||
break | ||
case 11: | ||
yy.commit($$[$0]) | ||
break | ||
case 12: | ||
yy.branch($$[$0]) | ||
break | ||
case 13: | ||
yy.checkout($$[$0]) | ||
break | ||
case 14: | ||
yy.merge($$[$0]) | ||
break | ||
case 15: | ||
yy.reset($$[$0]) | ||
break | ||
case 16: | ||
this.$ = '' | ||
break | ||
case 17: | ||
this.$ = $$[$0] | ||
break | ||
case 18: | ||
this.$ = $$[$0 - 1] + ':' + $$[$0] | ||
break | ||
case 19: | ||
this.$ = $$[$0 - 1] + ':' + yy.count; yy.count = 0 | ||
break | ||
case 20: | ||
yy.count = 0 | ||
break | ||
case 21: | ||
yy.count += 1 | ||
break | ||
} | ||
}, | ||
table: [{3: 1, 4: [1, 2]}, {1: [3]}, {5: [1, 3], 8: [1, 4]}, {6: 5, 7: $V0, 9: 6, 12: $V1}, {5: [1, 8]}, {7: [1, 9]}, o($V2, [2, 7], {10: 10, 11: [1, 11]}), o($V3, [2, 6]), {6: 12, 7: $V0, 9: 6, 12: $V1}, {1: [2, 1]}, {7: [2, 4], 12: [1, 15], 13: 13, 14: 14, 15: [1, 16], 17: [1, 17], 19: [1, 18], 20: [1, 19], 21: [1, 20]}, o($V3, [2, 5]), {7: [1, 21]}, o($V2, [2, 8]), {12: [1, 22]}, o($V2, [2, 10]), {12: [2, 16], 16: 23, 23: [1, 24]}, {18: [1, 25]}, {18: [1, 26]}, {18: [1, 27]}, {18: [1, 30], 22: 28, 24: [1, 29]}, {1: [2, 2]}, o($V2, [2, 9]), {12: [2, 11]}, {12: [2, 17]}, {12: [2, 12]}, {12: [2, 13]}, {12: [2, 14]}, {12: [2, 15]}, {12: $V4, 25: 31, 26: $V5}, {12: $V4, 25: 33, 26: $V5}, {12: [2, 18]}, {12: $V4, 25: 34, 26: $V5}, {12: [2, 19]}, {12: [2, 21]}], | ||
defaultActions: {9: [2, 1], 21: [2, 2], 23: [2, 11], 24: [2, 17], 25: [2, 12], 26: [2, 13], 27: [2, 14], 28: [2, 15], 31: [2, 18], 33: [2, 19], 34: [2, 21]}, | ||
parseError: function parseError (str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str) | ||
} else { | ||
function _parseError (msg, hash) { | ||
this.message = msg; | ||
this.hash = hash; | ||
this.message = msg | ||
this.hash = hash | ||
} | ||
_parseError.prototype = Error; | ||
_parseError.prototype = Error | ||
throw new _parseError(str, hash); | ||
} | ||
}, | ||
parse: function parse(input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; | ||
var args = lstack.slice.call(arguments, 1); | ||
var lexer = Object.create(this.lexer); | ||
var sharedState = { yy: {} }; | ||
for (var k in this.yy) { | ||
throw new _parseError(str, hash) | ||
} | ||
}, | ||
parse: function parse (input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1 | ||
var args = lstack.slice.call(arguments, 1) | ||
var lexer = Object.create(this.lexer) | ||
var sharedState = { yy: {} } | ||
for (var k in this.yy) { | ||
if (Object.prototype.hasOwnProperty.call(this.yy, k)) { | ||
sharedState.yy[k] = this.yy[k]; | ||
sharedState.yy[k] = this.yy[k] | ||
} | ||
} | ||
lexer.setInput(input, sharedState.yy); | ||
sharedState.yy.lexer = lexer; | ||
sharedState.yy.parser = this; | ||
if (typeof lexer.yylloc == 'undefined') { | ||
lexer.yylloc = {}; | ||
} | ||
var yyloc = lexer.yylloc; | ||
lstack.push(yyloc); | ||
var ranges = lexer.options && lexer.options.ranges; | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError; | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError; | ||
} | ||
function popStack(n) { | ||
stack.length = stack.length - 2 * n; | ||
vstack.length = vstack.length - n; | ||
lstack.length = lstack.length - n; | ||
} | ||
_token_stack: | ||
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]; | ||
} | ||
lexer.setInput(input, sharedState.yy) | ||
sharedState.yy.lexer = lexer | ||
sharedState.yy.parser = this | ||
if (typeof lexer.yylloc === 'undefined') { | ||
lexer.yylloc = {} | ||
} | ||
var yyloc = lexer.yylloc | ||
lstack.push(yyloc) | ||
var ranges = lexer.options && lexer.options.ranges | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError | ||
} | ||
function popStack (n) { | ||
stack.length = stack.length - 2 * n | ||
vstack.length = vstack.length - n | ||
lstack.length = lstack.length - n | ||
} | ||
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] | ||
if (this.defaultActions[state]) { | ||
action = this.defaultActions[state]; | ||
action = this.defaultActions[state] | ||
} else { | ||
if (symbol === null || typeof symbol == 'undefined') { | ||
symbol = lex(); | ||
if (symbol === null || typeof symbol === 'undefined') { | ||
symbol = lex() | ||
} | ||
action = table[state] && table[state][symbol] | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = '' | ||
expected = [] | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\'') | ||
} | ||
action = table[state] && table[state][symbol]; | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'' | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'') | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}) | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = ''; | ||
expected = []; | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\''); | ||
} | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}); | ||
} | ||
if (action[0] instanceof Array && action.length > 1) { | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol) | ||
} | ||
switch (action[0]) { | ||
case 1: | ||
stack.push(symbol); | ||
vstack.push(lexer.yytext); | ||
lstack.push(lexer.yylloc); | ||
stack.push(action[1]); | ||
symbol = null; | ||
case 1: | ||
stack.push(symbol) | ||
vstack.push(lexer.yytext) | ||
lstack.push(lexer.yylloc) | ||
stack.push(action[1]) | ||
symbol = null | ||
if (!preErrorSymbol) { | ||
yyleng = lexer.yyleng; | ||
yytext = lexer.yytext; | ||
yylineno = lexer.yylineno; | ||
yyloc = lexer.yylloc; | ||
if (recovering > 0) { | ||
recovering--; | ||
} | ||
yyleng = lexer.yyleng | ||
yytext = lexer.yytext | ||
yylineno = lexer.yylineno | ||
yyloc = lexer.yylloc | ||
if (recovering > 0) { | ||
recovering-- | ||
} | ||
} else { | ||
symbol = preErrorSymbol; | ||
preErrorSymbol = null; | ||
symbol = preErrorSymbol | ||
preErrorSymbol = null | ||
} | ||
break; | ||
case 2: | ||
len = this.productions_[action[1]][1]; | ||
yyval.$ = vstack[vstack.length - len]; | ||
break | ||
case 2: | ||
len = this.productions_[action[1]][1] | ||
yyval.$ = vstack[vstack.length - len] | ||
yyval._$ = { | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
}; | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
} | ||
if (ranges) { | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
]; | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
] | ||
} | ||
r = this.performAction.apply(yyval, [ | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)); | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)) | ||
if (typeof r !== 'undefined') { | ||
return r; | ||
return r | ||
} | ||
if (len) { | ||
stack = stack.slice(0, -1 * len * 2); | ||
vstack = vstack.slice(0, -1 * len); | ||
lstack = lstack.slice(0, -1 * len); | ||
stack = stack.slice(0, -1 * len * 2) | ||
vstack = vstack.slice(0, -1 * len) | ||
lstack = lstack.slice(0, -1 * len) | ||
} | ||
stack.push(this.productions_[action[1]][0]); | ||
vstack.push(yyval.$); | ||
lstack.push(yyval._$); | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; | ||
stack.push(newState); | ||
break; | ||
case 3: | ||
return true; | ||
stack.push(this.productions_[action[1]][0]) | ||
vstack.push(yyval.$) | ||
lstack.push(yyval._$) | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]] | ||
stack.push(newState) | ||
break | ||
case 3: | ||
return true | ||
} | ||
} | ||
return true; | ||
}}; | ||
} | ||
return true | ||
}} | ||
/* generated by jison-lex 0.3.4 */ | ||
var lexer = (function(){ | ||
var lexer = ({ | ||
var lexer = (function () { | ||
var lexer = ({ | ||
EOF:1, | ||
EOF: 1, | ||
parseError:function parseError(str, hash) { | ||
parseError: function parseError (str, hash) { | ||
if (this.yy.parser) { | ||
this.yy.parser.parseError(str, hash); | ||
this.yy.parser.parseError(str, hash) | ||
} else { | ||
throw new Error(str); | ||
throw new Error(str) | ||
} | ||
}, | ||
}, | ||
// resets the lexer, sets new input | ||
setInput:function (input, yy) { | ||
this.yy = yy || this.yy || {}; | ||
this._input = input; | ||
this._more = this._backtrack = this.done = false; | ||
this.yylineno = this.yyleng = 0; | ||
this.yytext = this.matched = this.match = ''; | ||
this.conditionStack = ['INITIAL']; | ||
setInput: function (input, yy) { | ||
this.yy = yy || this.yy || {} | ||
this._input = input | ||
this._more = this._backtrack = this.done = false | ||
this.yylineno = this.yyleng = 0 | ||
this.yytext = this.matched = this.match = '' | ||
this.conditionStack = ['INITIAL'] | ||
this.yylloc = { | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
}; | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [0,0]; | ||
this.yylloc.range = [0, 0] | ||
} | ||
this.offset = 0; | ||
return this; | ||
}, | ||
this.offset = 0 | ||
return this | ||
}, | ||
// consumes and returns one char from the input | ||
input:function () { | ||
var ch = this._input[0]; | ||
this.yytext += ch; | ||
this.yyleng++; | ||
this.offset++; | ||
this.match += ch; | ||
this.matched += ch; | ||
var lines = ch.match(/(?:\r\n?|\n).*/g); | ||
input: function () { | ||
var ch = this._input[0] | ||
this.yytext += ch | ||
this.yyleng++ | ||
this.offset++ | ||
this.match += ch | ||
this.matched += ch | ||
var lines = ch.match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno++; | ||
this.yylloc.last_line++; | ||
this.yylineno++ | ||
this.yylloc.last_line++ | ||
} else { | ||
this.yylloc.last_column++; | ||
this.yylloc.last_column++ | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range[1]++; | ||
this.yylloc.range[1]++ | ||
} | ||
this._input = this._input.slice(1); | ||
return ch; | ||
}, | ||
this._input = this._input.slice(1) | ||
return ch | ||
}, | ||
// unshifts one char (or a string) into the input | ||
unput:function (ch) { | ||
var len = ch.length; | ||
var lines = ch.split(/(?:\r\n?|\n)/g); | ||
unput: function (ch) { | ||
var len = ch.length | ||
var lines = ch.split(/(?:\r\n?|\n)/g) | ||
this._input = ch + this._input; | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len); | ||
//this.yyleng -= len; | ||
this.offset -= len; | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g); | ||
this.match = this.match.substr(0, this.match.length - 1); | ||
this.matched = this.matched.substr(0, this.matched.length - 1); | ||
this._input = ch + this._input | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len) | ||
// this.yyleng -= len; | ||
this.offset -= len | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g) | ||
this.match = this.match.substr(0, this.match.length - 1) | ||
this.matched = this.matched.substr(0, this.matched.length - 1) | ||
if (lines.length - 1) { | ||
this.yylineno -= lines.length - 1; | ||
this.yylineno -= lines.length - 1 | ||
} | ||
var r = this.yylloc.range; | ||
var r = this.yylloc.range | ||
this.yylloc = { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines ? | ||
(lines.length === oldLines.length ? this.yylloc.first_column : 0) | ||
+ oldLines[oldLines.length - lines.length].length - lines[0].length : | ||
this.yylloc.first_column - len | ||
}; | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines | ||
? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + | ||
oldLines[oldLines.length - lines.length].length - lines[0].length | ||
: this.yylloc.first_column - len | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len]; | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len] | ||
} | ||
this.yyleng = this.yytext.length; | ||
return this; | ||
}, | ||
this.yyleng = this.yytext.length | ||
return this | ||
}, | ||
// When called from action, caches matched text and appends it on next action | ||
more:function () { | ||
this._more = true; | ||
return this; | ||
}, | ||
more: function () { | ||
this._more = true | ||
return this | ||
}, | ||
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. | ||
reject:function () { | ||
reject: function () { | ||
if (this.options.backtrack_lexer) { | ||
this._backtrack = true; | ||
this._backtrack = true | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
return this; | ||
}, | ||
return this | ||
}, | ||
// retain first n characters of the match | ||
less:function (n) { | ||
this.unput(this.match.slice(n)); | ||
}, | ||
less: function (n) { | ||
this.unput(this.match.slice(n)) | ||
}, | ||
// displays already matched input, i.e. for error messages | ||
pastInput:function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length); | ||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); | ||
}, | ||
pastInput: function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length) | ||
return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') | ||
}, | ||
// displays upcoming input, i.e. for error messages | ||
upcomingInput:function () { | ||
var next = this.match; | ||
upcomingInput: function () { | ||
var next = this.match | ||
if (next.length < 20) { | ||
next += this._input.substr(0, 20-next.length); | ||
next += this._input.substr(0, 20 - next.length) | ||
} | ||
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); | ||
}, | ||
return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, '') | ||
}, | ||
// displays the character position where the lexing error occurred, i.e. for error messages | ||
showPosition:function () { | ||
var pre = this.pastInput(); | ||
var c = new Array(pre.length + 1).join("-"); | ||
return pre + this.upcomingInput() + "\n" + c + "^"; | ||
}, | ||
showPosition: function () { | ||
var pre = this.pastInput() | ||
var c = new Array(pre.length + 1).join('-') | ||
return pre + this.upcomingInput() + '\n' + c + '^' | ||
}, | ||
// test the lexed token: return FALSE when not a match, otherwise return token | ||
test_match:function (match, indexed_rule) { | ||
test_match: function (match, indexed_rule) { | ||
var token, | ||
lines, | ||
backup; | ||
lines, | ||
backup | ||
if (this.options.backtrack_lexer) { | ||
// save context | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
}; | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0); | ||
} | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
} | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0) | ||
} | ||
} | ||
lines = match[0].match(/(?:\r\n?|\n).*/g); | ||
lines = match[0].match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno += lines.length; | ||
this.yylineno += lines.length | ||
} | ||
this.yylloc = { | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines ? | ||
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : | ||
this.yylloc.last_column + match[0].length | ||
}; | ||
this.yytext += match[0]; | ||
this.match += match[0]; | ||
this.matches = match; | ||
this.yyleng = this.yytext.length; | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines | ||
? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length | ||
: this.yylloc.last_column + match[0].length | ||
} | ||
this.yytext += match[0] | ||
this.match += match[0] | ||
this.matches = match | ||
this.yyleng = this.yytext.length | ||
if (this.options.ranges) { | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng]; | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng] | ||
} | ||
this._more = false; | ||
this._backtrack = false; | ||
this._input = this._input.slice(match[0].length); | ||
this.matched += match[0]; | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); | ||
this._more = false | ||
this._backtrack = false | ||
this._input = this._input.slice(match[0].length) | ||
this.matched += match[0] | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]) | ||
if (this.done && this._input) { | ||
this.done = false; | ||
this.done = false | ||
} | ||
if (token) { | ||
return token; | ||
return token | ||
} else if (this._backtrack) { | ||
// recover context | ||
for (var k in backup) { | ||
this[k] = backup[k]; | ||
} | ||
return false; // rule action called reject() implying the next rule should be tested instead. | ||
for (var k in backup) { | ||
this[k] = backup[k] | ||
} | ||
return false // rule action called reject() implying the next rule should be tested instead. | ||
} | ||
return false; | ||
}, | ||
return false | ||
}, | ||
// return next match in input | ||
next:function () { | ||
next: function () { | ||
if (this.done) { | ||
return this.EOF; | ||
return this.EOF | ||
} | ||
if (!this._input) { | ||
this.done = true; | ||
this.done = true | ||
} | ||
var token, | ||
match, | ||
tempMatch, | ||
index; | ||
match, | ||
tempMatch, | ||
index | ||
if (!this._more) { | ||
this.yytext = ''; | ||
this.match = ''; | ||
this.yytext = '' | ||
this.match = '' | ||
} | ||
var rules = this._currentRules(); | ||
var rules = this._currentRules() | ||
for (var i = 0; i < rules.length; i++) { | ||
tempMatch = this._input.match(this.rules[rules[i]]); | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch; | ||
index = i; | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]); | ||
if (token !== false) { | ||
return token; | ||
} else if (this._backtrack) { | ||
match = false; | ||
continue; // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
tempMatch = this._input.match(this.rules[rules[i]]) | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch | ||
index = i | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]) | ||
if (token !== false) { | ||
return token | ||
} else if (this._backtrack) { | ||
match = false | ||
continue // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
} | ||
} else if (!this.options.flex) { | ||
break; | ||
} | ||
return false | ||
} | ||
} else if (!this.options.flex) { | ||
break | ||
} | ||
} | ||
} | ||
if (match) { | ||
token = this.test_match(match, rules[index]); | ||
if (token !== false) { | ||
return token; | ||
} | ||
token = this.test_match(match, rules[index]) | ||
if (token !== false) { | ||
return token | ||
} | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
return false | ||
} | ||
if (this._input === "") { | ||
return this.EOF; | ||
if (this._input === '') { | ||
return this.EOF | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
}, | ||
}, | ||
// return next match that has a token | ||
lex:function lex() { | ||
var r = this.next(); | ||
lex: function lex () { | ||
var r = this.next() | ||
if (r) { | ||
return r; | ||
return r | ||
} else { | ||
return this.lex(); | ||
return this.lex() | ||
} | ||
}, | ||
}, | ||
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) | ||
begin:function begin(condition) { | ||
this.conditionStack.push(condition); | ||
}, | ||
begin: function begin (condition) { | ||
this.conditionStack.push(condition) | ||
}, | ||
// pop the previously active lexer condition state off the condition stack | ||
popState:function popState() { | ||
var n = this.conditionStack.length - 1; | ||
popState: function popState () { | ||
var n = this.conditionStack.length - 1 | ||
if (n > 0) { | ||
return this.conditionStack.pop(); | ||
return this.conditionStack.pop() | ||
} else { | ||
return this.conditionStack[0]; | ||
return this.conditionStack[0] | ||
} | ||
}, | ||
}, | ||
// produce the lexer rule set which is active for the currently active lexer condition state | ||
_currentRules:function _currentRules() { | ||
_currentRules: function _currentRules () { | ||
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules | ||
} else { | ||
return this.conditions["INITIAL"].rules; | ||
return this.conditions['INITIAL'].rules | ||
} | ||
}, | ||
}, | ||
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available | ||
topState:function topState(n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0); | ||
topState: function topState (n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0) | ||
if (n >= 0) { | ||
return this.conditionStack[n]; | ||
return this.conditionStack[n] | ||
} else { | ||
return "INITIAL"; | ||
return 'INITIAL' | ||
} | ||
}, | ||
}, | ||
// alias for begin(condition) | ||
pushState:function pushState(condition) { | ||
this.begin(condition); | ||
}, | ||
pushState: function pushState (condition) { | ||
this.begin(condition) | ||
}, | ||
// return the number of states currently on the stack | ||
stateStackSize:function stateStackSize() { | ||
return this.conditionStack.length; | ||
}, | ||
options: {"case-insensitive":true}, | ||
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { | ||
var YYSTATE=YY_START; | ||
switch($avoiding_name_collisions) { | ||
case 0:return 12; | ||
break; | ||
case 1:/* skip all whitespace */ | ||
break; | ||
case 2:/* skip comments */ | ||
break; | ||
case 3:/* skip comments */ | ||
break; | ||
case 4:return 4; | ||
break; | ||
case 5:return 15; | ||
break; | ||
case 6:return 17; | ||
break; | ||
case 7:return 20; | ||
break; | ||
case 8:return 21; | ||
break; | ||
case 9:return 19; | ||
break; | ||
case 10:return 8; | ||
break; | ||
case 11:return 8; | ||
break; | ||
case 12:return 5; | ||
break; | ||
case 13:return 26 | ||
break; | ||
case 14:this.begin("options"); | ||
break; | ||
case 15:this.popState(); | ||
break; | ||
case 16:return 11; | ||
break; | ||
case 17:this.begin("string"); | ||
break; | ||
case 18:this.popState(); | ||
break; | ||
case 19:return 23; | ||
break; | ||
case 20:return 18; | ||
break; | ||
case 21:return 7; | ||
break; | ||
} | ||
}, | ||
rules: [/^(?:(\r?\n)+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:gitGraph\b)/i,/^(?:commit\b)/i,/^(?:branch\b)/i,/^(?:merge\b)/i,/^(?:reset\b)/i,/^(?:checkout\b)/i,/^(?:LR\b)/i,/^(?:BT\b)/i,/^(?::)/i,/^(?:\^)/i,/^(?:options\r?\n)/i,/^(?:end\r?\n)/i,/^(?:[^\n]+\r?\n)/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[a-zA-Z][a-zA-Z0-9_]+)/i,/^(?:$)/i], | ||
conditions: {"options":{"rules":[15,16],"inclusive":false},"string":{"rules":[18,19],"inclusive":false},"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17,20,21],"inclusive":true}} | ||
}); | ||
return lexer; | ||
})(); | ||
parser.lexer = lexer; | ||
function Parser () { | ||
this.yy = {}; | ||
} | ||
Parser.prototype = parser;parser.Parser = Parser; | ||
return new Parser; | ||
})(); | ||
stateStackSize: function stateStackSize () { | ||
return this.conditionStack.length | ||
}, | ||
options: {'case-insensitive': true}, | ||
performAction: function anonymous (yy, yy_, $avoiding_name_collisions, YY_START) { | ||
var YYSTATE = YY_START | ||
switch ($avoiding_name_collisions) { | ||
case 0:return 12 | ||
break | ||
case 1:/* skip all whitespace */ | ||
break | ||
case 2:/* skip comments */ | ||
break | ||
case 3:/* skip comments */ | ||
break | ||
case 4:return 4 | ||
break | ||
case 5:return 15 | ||
break | ||
case 6:return 17 | ||
break | ||
case 7:return 20 | ||
break | ||
case 8:return 21 | ||
break | ||
case 9:return 19 | ||
break | ||
case 10:return 8 | ||
break | ||
case 11:return 8 | ||
break | ||
case 12:return 5 | ||
break | ||
case 13:return 26 | ||
break | ||
case 14:this.begin('options') | ||
break | ||
case 15:this.popState() | ||
break | ||
case 16:return 11 | ||
break | ||
case 17:this.begin('string') | ||
break | ||
case 18:this.popState() | ||
break | ||
case 19:return 23 | ||
break | ||
case 20:return 18 | ||
break | ||
case 21:return 7 | ||
break | ||
} | ||
}, | ||
rules: [/^(?:(\r?\n)+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:gitGraph\b)/i, /^(?:commit\b)/i, /^(?:branch\b)/i, /^(?:merge\b)/i, /^(?:reset\b)/i, /^(?:checkout\b)/i, /^(?:LR\b)/i, /^(?:BT\b)/i, /^(?::)/i, /^(?:\^)/i, /^(?:options\r?\n)/i, /^(?:end\r?\n)/i, /^(?:[^\n]+\r?\n)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[a-zA-Z][a-zA-Z0-9_]+)/i, /^(?:$)/i], | ||
conditions: {'options': {'rules': [15, 16], 'inclusive': false}, 'string': {'rules': [18, 19], 'inclusive': false}, 'INITIAL': {'rules': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 20, 21], 'inclusive': true}} | ||
}) | ||
return lexer | ||
})() | ||
parser.lexer = lexer | ||
function Parser () { | ||
this.yy = {} | ||
} | ||
Parser.prototype = parser; parser.Parser = Parser | ||
return new Parser() | ||
})() | ||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') { | ||
exports.parser = parser; | ||
exports.Parser = parser.Parser; | ||
exports.parse = function () { return parser.parse.apply(parser, arguments); }; | ||
exports.main = function commonjsMain(args) { | ||
exports.parser = parser | ||
exports.Parser = parser.Parser | ||
exports.parse = function () { return parser.parse.apply(parser, arguments) } | ||
exports.main = function commonjsMain (args) { | ||
if (!args[1]) { | ||
console.log('Usage: '+args[0]+' FILE'); | ||
process.exit(1); | ||
console.log('Usage: ' + args[0] + ' FILE') | ||
process.exit(1) | ||
} | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); | ||
return exports.parser.parse(source); | ||
}; | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)); | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), 'utf8') | ||
return exports.parser.parse(source) | ||
} | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)) | ||
} | ||
} | ||
} |
@@ -53,3 +53,2 @@ /* parser generated by jison 0.4.17 */ | ||
token location info (@$, _$, etc.): { | ||
@@ -63,3 +62,2 @@ first_line: n, | ||
the parseError function receives a 'hash' object with these members for lexer and parser errors: { | ||
@@ -76,719 +74,728 @@ text: (matched text) | ||
*/ | ||
var parser = (function(){ | ||
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,2],$V1=[1,3],$V2=[1,4],$V3=[2,4],$V4=[1,9],$V5=[1,11],$V6=[1,12],$V7=[1,14],$V8=[1,15],$V9=[1,17],$Va=[1,18],$Vb=[1,19],$Vc=[1,20],$Vd=[1,22],$Ve=[1,23],$Vf=[1,4,5,10,15,16,18,20,21,22,23,24,25,36],$Vg=[1,31],$Vh=[4,5,10,15,16,18,20,21,22,23,25,36],$Vi=[34,35,36]; | ||
var parser = {trace: function trace() { }, | ||
yy: {}, | ||
symbols_: {"error":2,"start":3,"SPACE":4,"NL":5,"SD":6,"document":7,"line":8,"statement":9,"participant":10,"actor":11,"AS":12,"restOfLine":13,"signal":14,"activate":15,"deactivate":16,"note_statement":17,"title":18,"text2":19,"loop":20,"end":21,"opt":22,"alt":23,"else":24,"note":25,"placement":26,"over":27,"actor_pair":28,"spaceList":29,",":30,"left_of":31,"right_of":32,"signaltype":33,"+":34,"-":35,"ACTOR":36,"SOLID_OPEN_ARROW":37,"DOTTED_OPEN_ARROW":38,"SOLID_ARROW":39,"DOTTED_ARROW":40,"SOLID_CROSS":41,"DOTTED_CROSS":42,"TXT":43,"$accept":0,"$end":1}, | ||
terminals_: {2:"error",4:"SPACE",5:"NL",6:"SD",10:"participant",12:"AS",13:"restOfLine",15:"activate",16:"deactivate",18:"title",20:"loop",21:"end",22:"opt",23:"alt",24:"else",25:"note",27:"over",30:",",31:"left_of",32:"right_of",34:"+",35:"-",36:"ACTOR",37:"SOLID_OPEN_ARROW",38:"DOTTED_OPEN_ARROW",39:"SOLID_ARROW",40:"DOTTED_ARROW",41:"SOLID_CROSS",42:"DOTTED_CROSS",43:"TXT"}, | ||
productions_: [0,[3,2],[3,2],[3,2],[7,0],[7,2],[8,2],[8,1],[8,1],[9,5],[9,3],[9,2],[9,3],[9,3],[9,2],[9,3],[9,4],[9,4],[9,7],[17,4],[17,4],[29,2],[29,1],[28,3],[28,1],[26,1],[26,1],[14,5],[14,5],[14,4],[11,1],[33,1],[33,1],[33,1],[33,1],[33,1],[33,1],[19,1]], | ||
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
var parser = (function () { | ||
var o = function (k, v, o, l) { for (o = o || {}, l = k.length; l--; o[k[l]] = v);return o }, $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 4], $V3 = [2, 4], $V4 = [1, 9], $V5 = [1, 11], $V6 = [1, 12], $V7 = [1, 14], $V8 = [1, 15], $V9 = [1, 17], $Va = [1, 18], $Vb = [1, 19], $Vc = [1, 20], $Vd = [1, 21], $Ve = [1, 23], $Vf = [1, 24], $Vg = [1, 4, 5, 10, 15, 16, 18, 20, 21, 22, 23, 24, 25, 27, 28, 39], $Vh = [1, 32], $Vi = [4, 5, 10, 15, 16, 18, 20, 21, 22, 23, 25, 28, 39], $Vj = [4, 5, 10, 15, 16, 18, 20, 21, 22, 23, 25, 27, 28, 39], $Vk = [37, 38, 39] | ||
var parser = {trace: function trace () { }, | ||
yy: {}, | ||
symbols_: {'error': 2, 'start': 3, 'SPACE': 4, 'NL': 5, 'SD': 6, 'document': 7, 'line': 8, 'statement': 9, 'participant': 10, 'actor': 11, 'AS': 12, 'restOfLine': 13, 'signal': 14, 'activate': 15, 'deactivate': 16, 'note_statement': 17, 'title': 18, 'text2': 19, 'loop': 20, 'end': 21, 'opt': 22, 'alt': 23, 'else': 24, 'par': 25, 'par_sections': 26, 'and': 27, 'note': 28, 'placement': 29, 'over': 30, 'actor_pair': 31, 'spaceList': 32, ',': 33, 'left_of': 34, 'right_of': 35, 'signaltype': 36, '+': 37, '-': 38, 'ACTOR': 39, 'SOLID_OPEN_ARROW': 40, 'DOTTED_OPEN_ARROW': 41, 'SOLID_ARROW': 42, 'DOTTED_ARROW': 43, 'SOLID_CROSS': 44, 'DOTTED_CROSS': 45, 'TXT': 46, '$accept': 0, '$end': 1}, | ||
terminals_: {2: 'error', 4: 'SPACE', 5: 'NL', 6: 'SD', 10: 'participant', 12: 'AS', 13: 'restOfLine', 15: 'activate', 16: 'deactivate', 18: 'title', 20: 'loop', 21: 'end', 22: 'opt', 23: 'alt', 24: 'else', 25: 'par', 27: 'and', 28: 'note', 30: 'over', 33: ',', 34: 'left_of', 35: 'right_of', 37: '+', 38: '-', 39: 'ACTOR', 40: 'SOLID_OPEN_ARROW', 41: 'DOTTED_OPEN_ARROW', 42: 'SOLID_ARROW', 43: 'DOTTED_ARROW', 44: 'SOLID_CROSS', 45: 'DOTTED_CROSS', 46: 'TXT'}, | ||
productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [9, 5], [9, 3], [9, 2], [9, 3], [9, 3], [9, 2], [9, 3], [9, 4], [9, 4], [9, 7], [9, 4], [26, 1], [26, 4], [17, 4], [17, 4], [32, 2], [32, 1], [31, 3], [31, 1], [29, 1], [29, 1], [14, 5], [14, 5], [14, 4], [11, 1], [36, 1], [36, 1], [36, 1], [36, 1], [36, 1], [36, 1], [19, 1]], | ||
performAction: function anonymous (yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { | ||
/* this == yyval */ | ||
var $0 = $$.length - 1; | ||
switch (yystate) { | ||
case 3: | ||
yy.apply($$[$0]);return $$[$0]; | ||
break; | ||
case 4: | ||
this.$ = [] | ||
break; | ||
case 5: | ||
$$[$0-1].push($$[$0]);this.$ = $$[$0-1] | ||
break; | ||
case 6: case 7: | ||
this.$ = $$[$0] | ||
break; | ||
case 8: | ||
this.$=[]; | ||
break; | ||
case 9: | ||
$$[$0-3].description=$$[$0-1]; this.$=$$[$0-3]; | ||
break; | ||
case 10: | ||
this.$=$$[$0-1]; | ||
break; | ||
case 12: | ||
this.$={type: 'activeStart', signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0-1]}; | ||
break; | ||
case 13: | ||
this.$={type: 'activeEnd', signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0-1]}; | ||
break; | ||
case 15: | ||
this.$=[{type:'setTitle', text:$$[$0-1]}] | ||
break; | ||
case 16: | ||
var $0 = $$.length - 1 | ||
switch (yystate) { | ||
case 3: | ||
yy.apply($$[$0]); return $$[$0] | ||
break | ||
case 4: | ||
this.$ = [] | ||
break | ||
case 5: | ||
$$[$0 - 1].push($$[$0]); this.$ = $$[$0 - 1] | ||
break | ||
case 6: case 7: | ||
this.$ = $$[$0] | ||
break | ||
case 8: | ||
this.$ = [] | ||
break | ||
case 9: | ||
$$[$0 - 3].description = $$[$0 - 1]; this.$ = $$[$0 - 3] | ||
break | ||
case 10: | ||
this.$ = $$[$0 - 1] | ||
break | ||
case 12: | ||
this.$ = {type: 'activeStart', signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1]} | ||
break | ||
case 13: | ||
this.$ = {type: 'activeEnd', signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 1]} | ||
break | ||
case 15: | ||
this.$ = [{type: 'setTitle', text: $$[$0 - 1]}] | ||
break | ||
case 16: | ||
$$[$0-1].unshift({type: 'loopStart', loopText:$$[$0-2], signalType: yy.LINETYPE.LOOP_START}); | ||
$$[$0-1].push({type: 'loopEnd', loopText:$$[$0-2], signalType: yy.LINETYPE.LOOP_END}); | ||
this.$=$$[$0-1]; | ||
break; | ||
case 17: | ||
$$[$0 - 1].unshift({type: 'loopStart', loopText: $$[$0 - 2], signalType: yy.LINETYPE.LOOP_START}) | ||
$$[$0 - 1].push({type: 'loopEnd', loopText: $$[$0 - 2], signalType: yy.LINETYPE.LOOP_END}) | ||
this.$ = $$[$0 - 1] | ||
break | ||
case 17: | ||
$$[$0-1].unshift({type: 'optStart', optText:$$[$0-2], signalType: yy.LINETYPE.OPT_START}); | ||
$$[$0-1].push({type: 'optEnd', optText:$$[$0-2], signalType: yy.LINETYPE.OPT_END}); | ||
this.$=$$[$0-1]; | ||
break; | ||
case 18: | ||
$$[$0 - 1].unshift({type: 'optStart', optText: $$[$0 - 2], signalType: yy.LINETYPE.OPT_START}) | ||
$$[$0 - 1].push({type: 'optEnd', optText: $$[$0 - 2], signalType: yy.LINETYPE.OPT_END}) | ||
this.$ = $$[$0 - 1] | ||
break | ||
case 18: | ||
// Alt start | ||
$$[$0-4].unshift({type: 'altStart', altText:$$[$0-5], signalType: yy.LINETYPE.ALT_START}); | ||
$$[$0 - 4].unshift({type: 'altStart', altText: $$[$0 - 5], signalType: yy.LINETYPE.ALT_START}) | ||
// Content in alt is already in $$[$0-4] | ||
// Else | ||
$$[$0-4].push({type: 'else', altText:$$[$0-2], signalType: yy.LINETYPE.ALT_ELSE}); | ||
$$[$0 - 4].push({type: 'else', altText: $$[$0 - 2], signalType: yy.LINETYPE.ALT_ELSE}) | ||
// Content in other alt | ||
$$[$0-4] = $$[$0-4].concat($$[$0-1]); | ||
$$[$0 - 4] = $$[$0 - 4].concat($$[$0 - 1]) | ||
// End | ||
$$[$0-4].push({type: 'altEnd', signalType: yy.LINETYPE.ALT_END}); | ||
$$[$0 - 4].push({type: 'altEnd', signalType: yy.LINETYPE.ALT_END}) | ||
this.$=$$[$0-4]; | ||
break; | ||
case 19: | ||
this.$ = $$[$0 - 4] | ||
break | ||
case 19: | ||
this.$ = [$$[$0-1], {type:'addNote', placement:$$[$0-2], actor:$$[$0-1].actor, text:$$[$0]}]; | ||
break; | ||
case 20: | ||
// Parallel start | ||
$$[$0 - 1].unshift({type: 'parStart', parText: $$[$0 - 2], signalType: yy.LINETYPE.PAR_START}) | ||
// Content in par is already in $$[$0-1] | ||
// End | ||
$$[$0 - 1].push({type: 'parEnd', signalType: yy.LINETYPE.PAR_END}) | ||
this.$ = $$[$0 - 1] | ||
break | ||
case 21: | ||
this.$ = $$[$0 - 3].concat([{type: 'and', parText: $$[$0 - 1], signalType: yy.LINETYPE.PAR_AND}, $$[$0]]) | ||
break | ||
case 22: | ||
this.$ = [$$[$0 - 1], {type: 'addNote', placement: $$[$0 - 2], actor: $$[$0 - 1].actor, text: $$[$0]}] | ||
break | ||
case 23: | ||
// Coerce actor_pair into a [to, from, ...] array | ||
$$[$0-2] = [].concat($$[$0-1], $$[$0-1]).slice(0, 2); | ||
$$[$0-2][0] = $$[$0-2][0].actor; | ||
$$[$0-2][1] = $$[$0-2][1].actor; | ||
this.$ = [$$[$0-1], {type:'addNote', placement:yy.PLACEMENT.OVER, actor:$$[$0-2].slice(0, 2), text:$$[$0]}]; | ||
break; | ||
case 23: | ||
this.$ = [$$[$0-2], $$[$0]]; | ||
break; | ||
case 24: | ||
this.$ = $$[$0]; | ||
break; | ||
case 25: | ||
this.$ = yy.PLACEMENT.LEFTOF; | ||
break; | ||
case 26: | ||
this.$ = yy.PLACEMENT.RIGHTOF; | ||
break; | ||
case 27: | ||
this.$ = [$$[$0-4],$$[$0-1],{type: 'addMessage', from:$$[$0-4].actor, to:$$[$0-1].actor, signalType:$$[$0-3], msg:$$[$0]}, | ||
{type: 'activeStart', signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0-1]} | ||
$$[$0 - 2] = [].concat($$[$0 - 1], $$[$0 - 1]).slice(0, 2) | ||
$$[$0 - 2][0] = $$[$0 - 2][0].actor | ||
$$[$0 - 2][1] = $$[$0 - 2][1].actor | ||
this.$ = [$$[$0 - 1], {type: 'addNote', placement: yy.PLACEMENT.OVER, actor: $$[$0 - 2].slice(0, 2), text: $$[$0]}] | ||
break | ||
case 26: | ||
this.$ = [$$[$0 - 2], $$[$0]] | ||
break | ||
case 27: | ||
this.$ = $$[$0] | ||
break | ||
case 28: | ||
this.$ = yy.PLACEMENT.LEFTOF | ||
break | ||
case 29: | ||
this.$ = yy.PLACEMENT.RIGHTOF | ||
break | ||
case 30: | ||
this.$ = [$$[$0 - 4], $$[$0 - 1], {type: 'addMessage', from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0]}, | ||
{type: 'activeStart', signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1]} | ||
] | ||
break; | ||
case 28: | ||
this.$ = [$$[$0-4],$$[$0-1],{type: 'addMessage', from:$$[$0-4].actor, to:$$[$0-1].actor, signalType:$$[$0-3], msg:$$[$0]}, | ||
{type: 'activeEnd', signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0-4]} | ||
break | ||
case 31: | ||
this.$ = [$$[$0 - 4], $$[$0 - 1], {type: 'addMessage', from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0]}, | ||
{type: 'activeEnd', signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 4]} | ||
] | ||
break; | ||
case 29: | ||
this.$ = [$$[$0-3],$$[$0-1],{type: 'addMessage', from:$$[$0-3].actor, to:$$[$0-1].actor, signalType:$$[$0-2], msg:$$[$0]}] | ||
break; | ||
case 30: | ||
this.$={type: 'addActor', actor:$$[$0]} | ||
break; | ||
case 31: | ||
this.$ = yy.LINETYPE.SOLID_OPEN; | ||
break; | ||
case 32: | ||
this.$ = yy.LINETYPE.DOTTED_OPEN; | ||
break; | ||
case 33: | ||
this.$ = yy.LINETYPE.SOLID; | ||
break; | ||
case 34: | ||
this.$ = yy.LINETYPE.DOTTED; | ||
break; | ||
case 35: | ||
this.$ = yy.LINETYPE.SOLID_CROSS; | ||
break; | ||
case 36: | ||
this.$ = yy.LINETYPE.DOTTED_CROSS; | ||
break; | ||
case 37: | ||
this.$ = $$[$0].substring(1).trim().replace(/\\n/gm, "\n"); | ||
break; | ||
} | ||
}, | ||
table: [{3:1,4:$V0,5:$V1,6:$V2},{1:[3]},{3:5,4:$V0,5:$V1,6:$V2},{3:6,4:$V0,5:$V1,6:$V2},o([1,4,5,10,15,16,18,20,22,23,25,36],$V3,{7:7}),{1:[2,1]},{1:[2,2]},{1:[2,3],4:$V4,5:$V5,8:8,9:10,10:$V6,11:21,14:13,15:$V7,16:$V8,17:16,18:$V9,20:$Va,22:$Vb,23:$Vc,25:$Vd,36:$Ve},o($Vf,[2,5]),{9:24,10:$V6,11:21,14:13,15:$V7,16:$V8,17:16,18:$V9,20:$Va,22:$Vb,23:$Vc,25:$Vd,36:$Ve},o($Vf,[2,7]),o($Vf,[2,8]),{11:25,36:$Ve},{5:[1,26]},{11:27,36:$Ve},{11:28,36:$Ve},{5:[1,29]},{19:30,43:$Vg},{13:[1,32]},{13:[1,33]},{13:[1,34]},{33:35,37:[1,36],38:[1,37],39:[1,38],40:[1,39],41:[1,40],42:[1,41]},{26:42,27:[1,43],31:[1,44],32:[1,45]},o([5,12,30,37,38,39,40,41,42,43],[2,30]),o($Vf,[2,6]),{5:[1,47],12:[1,46]},o($Vf,[2,11]),{5:[1,48]},{5:[1,49]},o($Vf,[2,14]),{5:[1,50]},{5:[2,37]},o($Vh,$V3,{7:51}),o($Vh,$V3,{7:52}),o([4,5,10,15,16,18,20,22,23,24,25,36],$V3,{7:53}),{11:56,34:[1,54],35:[1,55],36:$Ve},o($Vi,[2,31]),o($Vi,[2,32]),o($Vi,[2,33]),o($Vi,[2,34]),o($Vi,[2,35]),o($Vi,[2,36]),{11:57,36:$Ve},{11:59,28:58,36:$Ve},{36:[2,25]},{36:[2,26]},{13:[1,60]},o($Vf,[2,10]),o($Vf,[2,12]),o($Vf,[2,13]),o($Vf,[2,15]),{4:$V4,5:$V5,8:8,9:10,10:$V6,11:21,14:13,15:$V7,16:$V8,17:16,18:$V9,20:$Va,21:[1,61],22:$Vb,23:$Vc,25:$Vd,36:$Ve},{4:$V4,5:$V5,8:8,9:10,10:$V6,11:21,14:13,15:$V7,16:$V8,17:16,18:$V9,20:$Va,21:[1,62],22:$Vb,23:$Vc,25:$Vd,36:$Ve},{4:$V4,5:$V5,8:8,9:10,10:$V6,11:21,14:13,15:$V7,16:$V8,17:16,18:$V9,20:$Va,22:$Vb,23:$Vc,24:[1,63],25:$Vd,36:$Ve},{11:64,36:$Ve},{11:65,36:$Ve},{19:66,43:$Vg},{19:67,43:$Vg},{19:68,43:$Vg},{30:[1,69],43:[2,24]},{5:[1,70]},o($Vf,[2,16]),o($Vf,[2,17]),{13:[1,71]},{19:72,43:$Vg},{19:73,43:$Vg},{5:[2,29]},{5:[2,19]},{5:[2,20]},{11:74,36:$Ve},o($Vf,[2,9]),o($Vh,$V3,{7:75}),{5:[2,27]},{5:[2,28]},{43:[2,23]},{4:$V4,5:$V5,8:8,9:10,10:$V6,11:21,14:13,15:$V7,16:$V8,17:16,18:$V9,20:$Va,21:[1,76],22:$Vb,23:$Vc,25:$Vd,36:$Ve},o($Vf,[2,18])], | ||
defaultActions: {5:[2,1],6:[2,2],31:[2,37],44:[2,25],45:[2,26],66:[2,29],67:[2,19],68:[2,20],72:[2,27],73:[2,28],74:[2,23]}, | ||
parseError: function parseError(str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str); | ||
} else { | ||
function _parseError (msg, hash) { | ||
this.message = msg; | ||
this.hash = hash; | ||
} | ||
_parseError.prototype = Error; | ||
throw new _parseError(str, hash); | ||
} | ||
}, | ||
parse: function parse(input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; | ||
var args = lstack.slice.call(arguments, 1); | ||
var lexer = Object.create(this.lexer); | ||
var sharedState = { yy: {} }; | ||
for (var k in this.yy) { | ||
break | ||
case 32: | ||
this.$ = [$$[$0 - 3], $$[$0 - 1], {type: 'addMessage', from: $$[$0 - 3].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 2], msg: $$[$0]}] | ||
break | ||
case 33: | ||
this.$ = {type: 'addActor', actor: $$[$0]} | ||
break | ||
case 34: | ||
this.$ = yy.LINETYPE.SOLID_OPEN | ||
break | ||
case 35: | ||
this.$ = yy.LINETYPE.DOTTED_OPEN | ||
break | ||
case 36: | ||
this.$ = yy.LINETYPE.SOLID | ||
break | ||
case 37: | ||
this.$ = yy.LINETYPE.DOTTED | ||
break | ||
case 38: | ||
this.$ = yy.LINETYPE.SOLID_CROSS | ||
break | ||
case 39: | ||
this.$ = yy.LINETYPE.DOTTED_CROSS | ||
break | ||
case 40: | ||
this.$ = $$[$0].substring(1).trim().replace(/\\n/gm, '\n') | ||
break | ||
} | ||
}, | ||
table: [{3: 1, 4: $V0, 5: $V1, 6: $V2}, {1: [3]}, {3: 5, 4: $V0, 5: $V1, 6: $V2}, {3: 6, 4: $V0, 5: $V1, 6: $V2}, o([1, 4, 5, 10, 15, 16, 18, 20, 22, 23, 25, 28, 39], $V3, {7: 7}), {1: [2, 1]}, {1: [2, 2]}, {1: [2, 3], 4: $V4, 5: $V5, 8: 8, 9: 10, 10: $V6, 11: 22, 14: 13, 15: $V7, 16: $V8, 17: 16, 18: $V9, 20: $Va, 22: $Vb, 23: $Vc, 25: $Vd, 28: $Ve, 39: $Vf}, o($Vg, [2, 5]), {9: 25, 10: $V6, 11: 22, 14: 13, 15: $V7, 16: $V8, 17: 16, 18: $V9, 20: $Va, 22: $Vb, 23: $Vc, 25: $Vd, 28: $Ve, 39: $Vf}, o($Vg, [2, 7]), o($Vg, [2, 8]), {11: 26, 39: $Vf}, {5: [1, 27]}, {11: 28, 39: $Vf}, {11: 29, 39: $Vf}, {5: [1, 30]}, {19: 31, 46: $Vh}, {13: [1, 33]}, {13: [1, 34]}, {13: [1, 35]}, {13: [1, 36]}, {36: 37, 40: [1, 38], 41: [1, 39], 42: [1, 40], 43: [1, 41], 44: [1, 42], 45: [1, 43]}, {29: 44, 30: [1, 45], 34: [1, 46], 35: [1, 47]}, o([5, 12, 33, 40, 41, 42, 43, 44, 45, 46], [2, 33]), o($Vg, [2, 6]), {5: [1, 49], 12: [1, 48]}, o($Vg, [2, 11]), {5: [1, 50]}, {5: [1, 51]}, o($Vg, [2, 14]), {5: [1, 52]}, {5: [2, 40]}, o($Vi, $V3, {7: 53}), o($Vi, $V3, {7: 54}), o([4, 5, 10, 15, 16, 18, 20, 22, 23, 24, 25, 28, 39], $V3, {7: 55}), o($Vj, $V3, {26: 56, 7: 57}), {11: 60, 37: [1, 58], 38: [1, 59], 39: $Vf}, o($Vk, [2, 34]), o($Vk, [2, 35]), o($Vk, [2, 36]), o($Vk, [2, 37]), o($Vk, [2, 38]), o($Vk, [2, 39]), {11: 61, 39: $Vf}, {11: 63, 31: 62, 39: $Vf}, {39: [2, 28]}, {39: [2, 29]}, {13: [1, 64]}, o($Vg, [2, 10]), o($Vg, [2, 12]), o($Vg, [2, 13]), o($Vg, [2, 15]), {4: $V4, 5: $V5, 8: 8, 9: 10, 10: $V6, 11: 22, 14: 13, 15: $V7, 16: $V8, 17: 16, 18: $V9, 20: $Va, 21: [1, 65], 22: $Vb, 23: $Vc, 25: $Vd, 28: $Ve, 39: $Vf}, {4: $V4, 5: $V5, 8: 8, 9: 10, 10: $V6, 11: 22, 14: 13, 15: $V7, 16: $V8, 17: 16, 18: $V9, 20: $Va, 21: [1, 66], 22: $Vb, 23: $Vc, 25: $Vd, 28: $Ve, 39: $Vf}, {4: $V4, 5: $V5, 8: 8, 9: 10, 10: $V6, 11: 22, 14: 13, 15: $V7, 16: $V8, 17: 16, 18: $V9, 20: $Va, 22: $Vb, 23: $Vc, 24: [1, 67], 25: $Vd, 28: $Ve, 39: $Vf}, {21: [1, 68]}, {4: $V4, 5: $V5, 8: 8, 9: 10, 10: $V6, 11: 22, 14: 13, 15: $V7, 16: $V8, 17: 16, 18: $V9, 20: $Va, 21: [2, 20], 22: $Vb, 23: $Vc, 25: $Vd, 27: [1, 69], 28: $Ve, 39: $Vf}, {11: 70, 39: $Vf}, {11: 71, 39: $Vf}, {19: 72, 46: $Vh}, {19: 73, 46: $Vh}, {19: 74, 46: $Vh}, {33: [1, 75], 46: [2, 27]}, {5: [1, 76]}, o($Vg, [2, 16]), o($Vg, [2, 17]), {13: [1, 77]}, o($Vg, [2, 19]), {13: [1, 78]}, {19: 79, 46: $Vh}, {19: 80, 46: $Vh}, {5: [2, 32]}, {5: [2, 22]}, {5: [2, 23]}, {11: 81, 39: $Vf}, o($Vg, [2, 9]), o($Vi, $V3, {7: 82}), o($Vj, $V3, {7: 57, 26: 83}), {5: [2, 30]}, {5: [2, 31]}, {46: [2, 26]}, {4: $V4, 5: $V5, 8: 8, 9: 10, 10: $V6, 11: 22, 14: 13, 15: $V7, 16: $V8, 17: 16, 18: $V9, 20: $Va, 21: [1, 84], 22: $Vb, 23: $Vc, 25: $Vd, 28: $Ve, 39: $Vf}, {21: [2, 21]}, o($Vg, [2, 18])], | ||
defaultActions: {5: [2, 1], 6: [2, 2], 32: [2, 40], 46: [2, 28], 47: [2, 29], 72: [2, 32], 73: [2, 22], 74: [2, 23], 79: [2, 30], 80: [2, 31], 81: [2, 26], 83: [2, 21]}, | ||
parseError: function parseError (str, hash) { | ||
if (hash.recoverable) { | ||
this.trace(str) | ||
} else { | ||
var error = new Error(str) | ||
error.hash = hash | ||
throw error | ||
} | ||
}, | ||
parse: function parse (input) { | ||
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1 | ||
var args = lstack.slice.call(arguments, 1) | ||
var lexer = Object.create(this.lexer) | ||
var sharedState = { yy: {} } | ||
for (var k in this.yy) { | ||
if (Object.prototype.hasOwnProperty.call(this.yy, k)) { | ||
sharedState.yy[k] = this.yy[k]; | ||
sharedState.yy[k] = this.yy[k] | ||
} | ||
} | ||
lexer.setInput(input, sharedState.yy); | ||
sharedState.yy.lexer = lexer; | ||
sharedState.yy.parser = this; | ||
if (typeof lexer.yylloc == 'undefined') { | ||
lexer.yylloc = {}; | ||
} | ||
var yyloc = lexer.yylloc; | ||
lstack.push(yyloc); | ||
var ranges = lexer.options && lexer.options.ranges; | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError; | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError; | ||
} | ||
function popStack(n) { | ||
stack.length = stack.length - 2 * n; | ||
vstack.length = vstack.length - n; | ||
lstack.length = lstack.length - n; | ||
} | ||
_token_stack: | ||
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]; | ||
} | ||
lexer.setInput(input, sharedState.yy) | ||
sharedState.yy.lexer = lexer | ||
sharedState.yy.parser = this | ||
if (typeof lexer.yylloc === 'undefined') { | ||
lexer.yylloc = {} | ||
} | ||
var yyloc = lexer.yylloc | ||
lstack.push(yyloc) | ||
var ranges = lexer.options && lexer.options.ranges | ||
if (typeof sharedState.yy.parseError === 'function') { | ||
this.parseError = sharedState.yy.parseError | ||
} else { | ||
this.parseError = Object.getPrototypeOf(this).parseError | ||
} | ||
function popStack (n) { | ||
stack.length = stack.length - 2 * n | ||
vstack.length = vstack.length - n | ||
lstack.length = lstack.length - n | ||
} | ||
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] | ||
if (this.defaultActions[state]) { | ||
action = this.defaultActions[state]; | ||
action = this.defaultActions[state] | ||
} else { | ||
if (symbol === null || typeof symbol == 'undefined') { | ||
symbol = lex(); | ||
if (symbol === null || typeof symbol === 'undefined') { | ||
symbol = lex() | ||
} | ||
action = table[state] && table[state][symbol] | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = '' | ||
expected = [] | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\'') | ||
} | ||
action = table[state] && table[state][symbol]; | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'' | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'') | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}) | ||
} | ||
if (typeof action === 'undefined' || !action.length || !action[0]) { | ||
var errStr = ''; | ||
expected = []; | ||
for (p in table[state]) { | ||
if (this.terminals_[p] && p > TERROR) { | ||
expected.push('\'' + this.terminals_[p] + '\''); | ||
} | ||
} | ||
if (lexer.showPosition) { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; | ||
} else { | ||
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); | ||
} | ||
this.parseError(errStr, { | ||
text: lexer.match, | ||
token: this.terminals_[symbol] || symbol, | ||
line: lexer.yylineno, | ||
loc: yyloc, | ||
expected: expected | ||
}); | ||
} | ||
if (action[0] instanceof Array && action.length > 1) { | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); | ||
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol) | ||
} | ||
switch (action[0]) { | ||
case 1: | ||
stack.push(symbol); | ||
vstack.push(lexer.yytext); | ||
lstack.push(lexer.yylloc); | ||
stack.push(action[1]); | ||
symbol = null; | ||
case 1: | ||
stack.push(symbol) | ||
vstack.push(lexer.yytext) | ||
lstack.push(lexer.yylloc) | ||
stack.push(action[1]) | ||
symbol = null | ||
if (!preErrorSymbol) { | ||
yyleng = lexer.yyleng; | ||
yytext = lexer.yytext; | ||
yylineno = lexer.yylineno; | ||
yyloc = lexer.yylloc; | ||
if (recovering > 0) { | ||
recovering--; | ||
} | ||
yyleng = lexer.yyleng | ||
yytext = lexer.yytext | ||
yylineno = lexer.yylineno | ||
yyloc = lexer.yylloc | ||
if (recovering > 0) { | ||
recovering-- | ||
} | ||
} else { | ||
symbol = preErrorSymbol; | ||
preErrorSymbol = null; | ||
symbol = preErrorSymbol | ||
preErrorSymbol = null | ||
} | ||
break; | ||
case 2: | ||
len = this.productions_[action[1]][1]; | ||
yyval.$ = vstack[vstack.length - len]; | ||
break | ||
case 2: | ||
len = this.productions_[action[1]][1] | ||
yyval.$ = vstack[vstack.length - len] | ||
yyval._$ = { | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
}; | ||
first_line: lstack[lstack.length - (len || 1)].first_line, | ||
last_line: lstack[lstack.length - 1].last_line, | ||
first_column: lstack[lstack.length - (len || 1)].first_column, | ||
last_column: lstack[lstack.length - 1].last_column | ||
} | ||
if (ranges) { | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
]; | ||
yyval._$.range = [ | ||
lstack[lstack.length - (len || 1)].range[0], | ||
lstack[lstack.length - 1].range[1] | ||
] | ||
} | ||
r = this.performAction.apply(yyval, [ | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)); | ||
yytext, | ||
yyleng, | ||
yylineno, | ||
sharedState.yy, | ||
action[1], | ||
vstack, | ||
lstack | ||
].concat(args)) | ||
if (typeof r !== 'undefined') { | ||
return r; | ||
return r | ||
} | ||
if (len) { | ||
stack = stack.slice(0, -1 * len * 2); | ||
vstack = vstack.slice(0, -1 * len); | ||
lstack = lstack.slice(0, -1 * len); | ||
stack = stack.slice(0, -1 * len * 2) | ||
vstack = vstack.slice(0, -1 * len) | ||
lstack = lstack.slice(0, -1 * len) | ||
} | ||
stack.push(this.productions_[action[1]][0]); | ||
vstack.push(yyval.$); | ||
lstack.push(yyval._$); | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; | ||
stack.push(newState); | ||
break; | ||
case 3: | ||
return true; | ||
stack.push(this.productions_[action[1]][0]) | ||
vstack.push(yyval.$) | ||
lstack.push(yyval._$) | ||
newState = table[stack[stack.length - 2]][stack[stack.length - 1]] | ||
stack.push(newState) | ||
break | ||
case 3: | ||
return true | ||
} | ||
} | ||
return true; | ||
}}; | ||
} | ||
return true | ||
}} | ||
/* generated by jison-lex 0.3.4 */ | ||
var lexer = (function(){ | ||
var lexer = ({ | ||
var lexer = (function () { | ||
var lexer = ({ | ||
EOF:1, | ||
EOF: 1, | ||
parseError:function parseError(str, hash) { | ||
parseError: function parseError (str, hash) { | ||
if (this.yy.parser) { | ||
this.yy.parser.parseError(str, hash); | ||
this.yy.parser.parseError(str, hash) | ||
} else { | ||
throw new Error(str); | ||
throw new Error(str) | ||
} | ||
}, | ||
}, | ||
// resets the lexer, sets new input | ||
setInput:function (input, yy) { | ||
this.yy = yy || this.yy || {}; | ||
this._input = input; | ||
this._more = this._backtrack = this.done = false; | ||
this.yylineno = this.yyleng = 0; | ||
this.yytext = this.matched = this.match = ''; | ||
this.conditionStack = ['INITIAL']; | ||
setInput: function (input, yy) { | ||
this.yy = yy || this.yy || {} | ||
this._input = input | ||
this._more = this._backtrack = this.done = false | ||
this.yylineno = this.yyleng = 0 | ||
this.yytext = this.matched = this.match = '' | ||
this.conditionStack = ['INITIAL'] | ||
this.yylloc = { | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
}; | ||
first_line: 1, | ||
first_column: 0, | ||
last_line: 1, | ||
last_column: 0 | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [0,0]; | ||
this.yylloc.range = [0, 0] | ||
} | ||
this.offset = 0; | ||
return this; | ||
}, | ||
this.offset = 0 | ||
return this | ||
}, | ||
// consumes and returns one char from the input | ||
input:function () { | ||
var ch = this._input[0]; | ||
this.yytext += ch; | ||
this.yyleng++; | ||
this.offset++; | ||
this.match += ch; | ||
this.matched += ch; | ||
var lines = ch.match(/(?:\r\n?|\n).*/g); | ||
input: function () { | ||
var ch = this._input[0] | ||
this.yytext += ch | ||
this.yyleng++ | ||
this.offset++ | ||
this.match += ch | ||
this.matched += ch | ||
var lines = ch.match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno++; | ||
this.yylloc.last_line++; | ||
this.yylineno++ | ||
this.yylloc.last_line++ | ||
} else { | ||
this.yylloc.last_column++; | ||
this.yylloc.last_column++ | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range[1]++; | ||
this.yylloc.range[1]++ | ||
} | ||
this._input = this._input.slice(1); | ||
return ch; | ||
}, | ||
this._input = this._input.slice(1) | ||
return ch | ||
}, | ||
// unshifts one char (or a string) into the input | ||
unput:function (ch) { | ||
var len = ch.length; | ||
var lines = ch.split(/(?:\r\n?|\n)/g); | ||
unput: function (ch) { | ||
var len = ch.length | ||
var lines = ch.split(/(?:\r\n?|\n)/g) | ||
this._input = ch + this._input; | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len); | ||
//this.yyleng -= len; | ||
this.offset -= len; | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g); | ||
this.match = this.match.substr(0, this.match.length - 1); | ||
this.matched = this.matched.substr(0, this.matched.length - 1); | ||
this._input = ch + this._input | ||
this.yytext = this.yytext.substr(0, this.yytext.length - len) | ||
// this.yyleng -= len; | ||
this.offset -= len | ||
var oldLines = this.match.split(/(?:\r\n?|\n)/g) | ||
this.match = this.match.substr(0, this.match.length - 1) | ||
this.matched = this.matched.substr(0, this.matched.length - 1) | ||
if (lines.length - 1) { | ||
this.yylineno -= lines.length - 1; | ||
this.yylineno -= lines.length - 1 | ||
} | ||
var r = this.yylloc.range; | ||
var r = this.yylloc.range | ||
this.yylloc = { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines ? | ||
(lines.length === oldLines.length ? this.yylloc.first_column : 0) | ||
+ oldLines[oldLines.length - lines.length].length - lines[0].length : | ||
this.yylloc.first_column - len | ||
}; | ||
first_line: this.yylloc.first_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.first_column, | ||
last_column: lines | ||
? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + | ||
oldLines[oldLines.length - lines.length].length - lines[0].length | ||
: this.yylloc.first_column - len | ||
} | ||
if (this.options.ranges) { | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len]; | ||
this.yylloc.range = [r[0], r[0] + this.yyleng - len] | ||
} | ||
this.yyleng = this.yytext.length; | ||
return this; | ||
}, | ||
this.yyleng = this.yytext.length | ||
return this | ||
}, | ||
// When called from action, caches matched text and appends it on next action | ||
more:function () { | ||
this._more = true; | ||
return this; | ||
}, | ||
more: function () { | ||
this._more = true | ||
return this | ||
}, | ||
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. | ||
reject:function () { | ||
reject: function () { | ||
if (this.options.backtrack_lexer) { | ||
this._backtrack = true; | ||
this._backtrack = true | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
return this; | ||
}, | ||
return this | ||
}, | ||
// retain first n characters of the match | ||
less:function (n) { | ||
this.unput(this.match.slice(n)); | ||
}, | ||
less: function (n) { | ||
this.unput(this.match.slice(n)) | ||
}, | ||
// displays already matched input, i.e. for error messages | ||
pastInput:function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length); | ||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); | ||
}, | ||
pastInput: function () { | ||
var past = this.matched.substr(0, this.matched.length - this.match.length) | ||
return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') | ||
}, | ||
// displays upcoming input, i.e. for error messages | ||
upcomingInput:function () { | ||
var next = this.match; | ||
upcomingInput: function () { | ||
var next = this.match | ||
if (next.length < 20) { | ||
next += this._input.substr(0, 20-next.length); | ||
next += this._input.substr(0, 20 - next.length) | ||
} | ||
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); | ||
}, | ||
return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, '') | ||
}, | ||
// displays the character position where the lexing error occurred, i.e. for error messages | ||
showPosition:function () { | ||
var pre = this.pastInput(); | ||
var c = new Array(pre.length + 1).join("-"); | ||
return pre + this.upcomingInput() + "\n" + c + "^"; | ||
}, | ||
showPosition: function () { | ||
var pre = this.pastInput() | ||
var c = new Array(pre.length + 1).join('-') | ||
return pre + this.upcomingInput() + '\n' + c + '^' | ||
}, | ||
// test the lexed token: return FALSE when not a match, otherwise return token | ||
test_match:function (match, indexed_rule) { | ||
test_match: function (match, indexed_rule) { | ||
var token, | ||
lines, | ||
backup; | ||
lines, | ||
backup | ||
if (this.options.backtrack_lexer) { | ||
// save context | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
}; | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0); | ||
} | ||
backup = { | ||
yylineno: this.yylineno, | ||
yylloc: { | ||
first_line: this.yylloc.first_line, | ||
last_line: this.last_line, | ||
first_column: this.yylloc.first_column, | ||
last_column: this.yylloc.last_column | ||
}, | ||
yytext: this.yytext, | ||
match: this.match, | ||
matches: this.matches, | ||
matched: this.matched, | ||
yyleng: this.yyleng, | ||
offset: this.offset, | ||
_more: this._more, | ||
_input: this._input, | ||
yy: this.yy, | ||
conditionStack: this.conditionStack.slice(0), | ||
done: this.done | ||
} | ||
if (this.options.ranges) { | ||
backup.yylloc.range = this.yylloc.range.slice(0) | ||
} | ||
} | ||
lines = match[0].match(/(?:\r\n?|\n).*/g); | ||
lines = match[0].match(/(?:\r\n?|\n).*/g) | ||
if (lines) { | ||
this.yylineno += lines.length; | ||
this.yylineno += lines.length | ||
} | ||
this.yylloc = { | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines ? | ||
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : | ||
this.yylloc.last_column + match[0].length | ||
}; | ||
this.yytext += match[0]; | ||
this.match += match[0]; | ||
this.matches = match; | ||
this.yyleng = this.yytext.length; | ||
first_line: this.yylloc.last_line, | ||
last_line: this.yylineno + 1, | ||
first_column: this.yylloc.last_column, | ||
last_column: lines | ||
? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length | ||
: this.yylloc.last_column + match[0].length | ||
} | ||
this.yytext += match[0] | ||
this.match += match[0] | ||
this.matches = match | ||
this.yyleng = this.yytext.length | ||
if (this.options.ranges) { | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng]; | ||
this.yylloc.range = [this.offset, this.offset += this.yyleng] | ||
} | ||
this._more = false; | ||
this._backtrack = false; | ||
this._input = this._input.slice(match[0].length); | ||
this.matched += match[0]; | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); | ||
this._more = false | ||
this._backtrack = false | ||
this._input = this._input.slice(match[0].length) | ||
this.matched += match[0] | ||
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]) | ||
if (this.done && this._input) { | ||
this.done = false; | ||
this.done = false | ||
} | ||
if (token) { | ||
return token; | ||
return token | ||
} else if (this._backtrack) { | ||
// recover context | ||
for (var k in backup) { | ||
this[k] = backup[k]; | ||
} | ||
return false; // rule action called reject() implying the next rule should be tested instead. | ||
for (var k in backup) { | ||
this[k] = backup[k] | ||
} | ||
return false // rule action called reject() implying the next rule should be tested instead. | ||
} | ||
return false; | ||
}, | ||
return false | ||
}, | ||
// return next match in input | ||
next:function () { | ||
next: function () { | ||
if (this.done) { | ||
return this.EOF; | ||
return this.EOF | ||
} | ||
if (!this._input) { | ||
this.done = true; | ||
this.done = true | ||
} | ||
var token, | ||
match, | ||
tempMatch, | ||
index; | ||
match, | ||
tempMatch, | ||
index | ||
if (!this._more) { | ||
this.yytext = ''; | ||
this.match = ''; | ||
this.yytext = '' | ||
this.match = '' | ||
} | ||
var rules = this._currentRules(); | ||
var rules = this._currentRules() | ||
for (var i = 0; i < rules.length; i++) { | ||
tempMatch = this._input.match(this.rules[rules[i]]); | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch; | ||
index = i; | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]); | ||
if (token !== false) { | ||
return token; | ||
} else if (this._backtrack) { | ||
match = false; | ||
continue; // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
tempMatch = this._input.match(this.rules[rules[i]]) | ||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { | ||
match = tempMatch | ||
index = i | ||
if (this.options.backtrack_lexer) { | ||
token = this.test_match(tempMatch, rules[i]) | ||
if (token !== false) { | ||
return token | ||
} else if (this._backtrack) { | ||
match = false | ||
continue // rule action called reject() implying a rule MISmatch. | ||
} else { | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
} | ||
} else if (!this.options.flex) { | ||
break; | ||
} | ||
return false | ||
} | ||
} else if (!this.options.flex) { | ||
break | ||
} | ||
} | ||
} | ||
if (match) { | ||
token = this.test_match(match, rules[index]); | ||
if (token !== false) { | ||
return token; | ||
} | ||
token = this.test_match(match, rules[index]) | ||
if (token !== false) { | ||
return token | ||
} | ||
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) | ||
return false; | ||
return false | ||
} | ||
if (this._input === "") { | ||
return this.EOF; | ||
if (this._input === '') { | ||
return this.EOF | ||
} else { | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: "", | ||
token: null, | ||
line: this.yylineno | ||
}); | ||
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { | ||
text: '', | ||
token: null, | ||
line: this.yylineno | ||
}) | ||
} | ||
}, | ||
}, | ||
// return next match that has a token | ||
lex:function lex() { | ||
var r = this.next(); | ||
lex: function lex () { | ||
var r = this.next() | ||
if (r) { | ||
return r; | ||
return r | ||
} else { | ||
return this.lex(); | ||
return this.lex() | ||
} | ||
}, | ||
}, | ||
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) | ||
begin:function begin(condition) { | ||
this.conditionStack.push(condition); | ||
}, | ||
begin: function begin (condition) { | ||
this.conditionStack.push(condition) | ||
}, | ||
// pop the previously active lexer condition state off the condition stack | ||
popState:function popState() { | ||
var n = this.conditionStack.length - 1; | ||
popState: function popState () { | ||
var n = this.conditionStack.length - 1 | ||
if (n > 0) { | ||
return this.conditionStack.pop(); | ||
return this.conditionStack.pop() | ||
} else { | ||
return this.conditionStack[0]; | ||
return this.conditionStack[0] | ||
} | ||
}, | ||
}, | ||
// produce the lexer rule set which is active for the currently active lexer condition state | ||
_currentRules:function _currentRules() { | ||
_currentRules: function _currentRules () { | ||
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; | ||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules | ||
} else { | ||
return this.conditions["INITIAL"].rules; | ||
return this.conditions['INITIAL'].rules | ||
} | ||
}, | ||
}, | ||
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available | ||
topState:function topState(n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0); | ||
topState: function topState (n) { | ||
n = this.conditionStack.length - 1 - Math.abs(n || 0) | ||
if (n >= 0) { | ||
return this.conditionStack[n]; | ||
return this.conditionStack[n] | ||
} else { | ||
return "INITIAL"; | ||
return 'INITIAL' | ||
} | ||
}, | ||
}, | ||
// alias for begin(condition) | ||
pushState:function pushState(condition) { | ||
this.begin(condition); | ||
}, | ||
pushState: function pushState (condition) { | ||
this.begin(condition) | ||
}, | ||
// return the number of states currently on the stack | ||
stateStackSize:function stateStackSize() { | ||
return this.conditionStack.length; | ||
}, | ||
options: {"case-insensitive":true}, | ||
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { | ||
var YYSTATE=YY_START; | ||
switch($avoiding_name_collisions) { | ||
case 0:return 5; | ||
break; | ||
case 1:/* skip all whitespace */ | ||
break; | ||
case 2:/* skip same-line whitespace */ | ||
break; | ||
case 3:/* skip comments */ | ||
break; | ||
case 4:/* skip comments */ | ||
break; | ||
case 5: this.begin('ID'); return 10; | ||
break; | ||
case 6: this.begin('ALIAS'); return 36; | ||
break; | ||
case 7: this.popState(); this.popState(); this.begin('LINE'); return 12; | ||
break; | ||
case 8: this.popState(); this.popState(); return 5; | ||
break; | ||
case 9: this.begin('LINE'); return 20; | ||
break; | ||
case 10: this.begin('LINE'); return 22; | ||
break; | ||
case 11: this.begin('LINE'); return 23; | ||
break; | ||
case 12: this.begin('LINE'); return 24; | ||
break; | ||
case 13: this.popState(); return 13; | ||
break; | ||
case 14:return 21; | ||
break; | ||
case 15:return 31; | ||
break; | ||
case 16:return 32; | ||
break; | ||
case 17:return 27; | ||
break; | ||
case 18:return 25; | ||
break; | ||
case 19: this.begin('ID'); return 15; | ||
break; | ||
case 20: this.begin('ID'); return 16; | ||
break; | ||
case 21:return 18; | ||
break; | ||
case 22:return 6; | ||
break; | ||
case 23:return 30; | ||
break; | ||
case 24:return 5; | ||
break; | ||
case 25: yy_.yytext = yy_.yytext.trim(); return 36; | ||
break; | ||
case 26:return 39; | ||
break; | ||
case 27:return 40; | ||
break; | ||
case 28:return 37; | ||
break; | ||
case 29:return 38; | ||
break; | ||
case 30:return 41; | ||
break; | ||
case 31:return 42; | ||
break; | ||
case 32:return 43; | ||
break; | ||
case 33:return 34; | ||
break; | ||
case 34:return 35; | ||
break; | ||
case 35:return 5; | ||
break; | ||
case 36:return 'INVALID'; | ||
break; | ||
} | ||
}, | ||
rules: [/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:((?!\n)\s)+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:participant\b)/i,/^(?:[^\->:\n,;]+?(?=((?!\n)\s)+as(?!\n)\s|[#\n;]|$))/i,/^(?:as\b)/i,/^(?:(?:))/i,/^(?:loop\b)/i,/^(?:opt\b)/i,/^(?:alt\b)/i,/^(?:else\b)/i,/^(?:[^#\n;]*)/i,/^(?:end\b)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:over\b)/i,/^(?:note\b)/i,/^(?:activate\b)/i,/^(?:deactivate\b)/i,/^(?:title\b)/i,/^(?:sequenceDiagram\b)/i,/^(?:,)/i,/^(?:;)/i,/^(?:[^\+\->:\n,;]+)/i,/^(?:->>)/i,/^(?:-->>)/i,/^(?:->)/i,/^(?:-->)/i,/^(?:-[x])/i,/^(?:--[x])/i,/^(?::[^#\n;]+)/i,/^(?:\+)/i,/^(?:-)/i,/^(?:$)/i,/^(?:.)/i], | ||
conditions: {"LINE":{"rules":[2,3,13],"inclusive":false},"ALIAS":{"rules":[2,3,7,8],"inclusive":false},"ID":{"rules":[2,3,6],"inclusive":false},"INITIAL":{"rules":[0,1,3,4,5,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"inclusive":true}} | ||
}); | ||
return lexer; | ||
})(); | ||
parser.lexer = lexer; | ||
function Parser () { | ||
this.yy = {}; | ||
} | ||
Parser.prototype = parser;parser.Parser = Parser; | ||
return new Parser; | ||
})(); | ||
stateStackSize: function stateStackSize () { | ||
return this.conditionStack.length | ||
}, | ||
options: {'case-insensitive': true}, | ||
performAction: function anonymous (yy, yy_, $avoiding_name_collisions, YY_START) { | ||
var YYSTATE = YY_START | ||
switch ($avoiding_name_collisions) { | ||
case 0:return 5 | ||
break | ||
case 1:/* skip all whitespace */ | ||
break | ||
case 2:/* skip same-line whitespace */ | ||
break | ||
case 3:/* skip comments */ | ||
break | ||
case 4:/* skip comments */ | ||
break | ||
case 5: this.begin('ID'); return 10 | ||
break | ||
case 6: this.begin('ALIAS'); return 39 | ||
break | ||
case 7: this.popState(); this.popState(); this.begin('LINE'); return 12 | ||
break | ||
case 8: this.popState(); this.popState(); return 5 | ||
break | ||
case 9: this.begin('LINE'); return 20 | ||
break | ||
case 10: this.begin('LINE'); return 22 | ||
break | ||
case 11: this.begin('LINE'); return 23 | ||
break | ||
case 12: this.begin('LINE'); return 24 | ||
break | ||
case 13: this.begin('LINE'); return 25 | ||
break | ||
case 14: this.begin('LINE'); return 27 | ||
break | ||
case 15: this.popState(); return 13 | ||
break | ||
case 16:return 21 | ||
break | ||
case 17:return 34 | ||
break | ||
case 18:return 35 | ||
break | ||
case 19:return 30 | ||
break | ||
case 20:return 28 | ||
break | ||
case 21: this.begin('ID'); return 15 | ||
break | ||
case 22: this.begin('ID'); return 16 | ||
break | ||
case 23:return 18 | ||
break | ||
case 24:return 6 | ||
break | ||
case 25:return 33 | ||
break | ||
case 26:return 5 | ||
break | ||
case 27: yy_.yytext = yy_.yytext.trim(); return 39 | ||
break | ||
case 28:return 42 | ||
break | ||
case 29:return 43 | ||
break | ||
case 30:return 40 | ||
break | ||
case 31:return 41 | ||
break | ||
case 32:return 44 | ||
break | ||
case 33:return 45 | ||
break | ||
case 34:return 46 | ||
break | ||
case 35:return 37 | ||
break | ||
case 36:return 38 | ||
break | ||
case 37:return 5 | ||
break | ||
case 38:return 'INVALID' | ||
break | ||
} | ||
}, | ||
rules: [/^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:participant\b)/i, /^(?:[^\->:\n,;]+?(?=((?!\n)\s)+as(?!\n)\s|[#\n;]|$))/i, /^(?:as\b)/i, /^(?:(?:))/i, /^(?:loop\b)/i, /^(?:opt\b)/i, /^(?:alt\b)/i, /^(?:else\b)/i, /^(?:par\b)/i, /^(?:and\b)/i, /^(?:[^#\n;]*)/i, /^(?:end\b)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:over\b)/i, /^(?:note\b)/i, /^(?:activate\b)/i, /^(?:deactivate\b)/i, /^(?:title\b)/i, /^(?:sequenceDiagram\b)/i, /^(?:,)/i, /^(?:;)/i, /^(?:[^\+\->:\n,;]+)/i, /^(?:->>)/i, /^(?:-->>)/i, /^(?:->)/i, /^(?:-->)/i, /^(?:-[x])/i, /^(?:--[x])/i, /^(?::[^#\n;]+)/i, /^(?:\+)/i, /^(?:-)/i, /^(?:$)/i, /^(?:.)/i], | ||
conditions: {'LINE': {'rules': [2, 3, 15], 'inclusive': false}, 'ALIAS': {'rules': [2, 3, 7, 8], 'inclusive': false}, 'ID': {'rules': [2, 3, 6], 'inclusive': false}, 'INITIAL': {'rules': [0, 1, 3, 4, 5, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38], 'inclusive': true}} | ||
}) | ||
return lexer | ||
})() | ||
parser.lexer = lexer | ||
function Parser () { | ||
this.yy = {} | ||
} | ||
Parser.prototype = parser; parser.Parser = Parser | ||
return new Parser() | ||
})() | ||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') { | ||
exports.parser = parser; | ||
exports.Parser = parser.Parser; | ||
exports.parse = function () { return parser.parse.apply(parser, arguments); }; | ||
exports.main = function commonjsMain(args) { | ||
exports.parser = parser | ||
exports.Parser = parser.Parser | ||
exports.parse = function () { return parser.parse.apply(parser, arguments) } | ||
exports.main = function commonjsMain (args) { | ||
if (!args[1]) { | ||
console.log('Usage: '+args[0]+' FILE'); | ||
process.exit(1); | ||
console.log('Usage: ' + args[0] + ' FILE') | ||
process.exit(1) | ||
} | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); | ||
return exports.parser.parse(source); | ||
}; | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)); | ||
var source = require('fs').readFileSync(require('path').normalize(args[1]), 'utf8') | ||
return exports.parser.parse(source) | ||
} | ||
if (typeof module !== 'undefined' && require.main === module) { | ||
exports.main(process.argv.slice(1)) | ||
} | ||
} | ||
} |
/** | ||
* Created by knut on 14-11-19. | ||
*/ | ||
var actors = {}; | ||
var messages = []; | ||
var notes = []; | ||
var title = ''; | ||
var Logger = require('../../logger'); | ||
var log = new Logger.Log(); | ||
var actors = {} | ||
var messages = [] | ||
var notes = [] | ||
var title = '' | ||
var Logger = require('../../logger') | ||
var log = Logger.Log | ||
exports.addActor = function (id, name, description) { | ||
// Don't allow description nulling | ||
var old = actors[id] | ||
if (old && name === old.name && description == null) return | ||
// Don't allow null descriptions, either | ||
if (description == null) description = name | ||
exports.addActor = function(id,name,description){ | ||
// Don't allow description nulling | ||
var old = actors[id]; | ||
if ( old && name === old.name && description == null ) return; | ||
actors[id] = { name: name, description: description } | ||
} | ||
// Don't allow null descriptions, either | ||
if ( description == null ) description = name; | ||
exports.addMessage = function (idFrom, idTo, message, answer) { | ||
messages.push({ from: idFrom, to: idTo, message: message, answer: answer }) | ||
} | ||
actors[id] = {name:name, description:description}; | ||
}; | ||
exports.addSignal = function (idFrom, idTo, message, messageType) { | ||
log.debug('Adding message from=' + idFrom + ' to=' + idTo + ' message=' + message + ' type=' + messageType) | ||
messages.push({ from: idFrom, to: idTo, message: message, type: messageType }) | ||
} | ||
exports.addMessage = function(idFrom, idTo, message, answer){ | ||
messages.push({from:idFrom, to:idTo, message:message, answer:answer}); | ||
}; | ||
exports.getMessages = function () { | ||
return messages | ||
} | ||
/** | ||
* | ||
*/ | ||
exports.addSignal = function(idFrom, idTo, message, messageType){ | ||
log.debug('Adding message from='+idFrom+' to='+idTo+' message='+message+' type='+messageType); | ||
messages.push({from:idFrom, to:idTo, message:message, type:messageType}); | ||
}; | ||
exports.getActors = function () { | ||
return actors | ||
} | ||
exports.getActor = function (id) { | ||
return actors[id] | ||
} | ||
exports.getActorKeys = function () { | ||
return Object.keys(actors) | ||
} | ||
exports.getTitle = function () { | ||
return title | ||
} | ||
exports.getMessages = function(){ | ||
return messages; | ||
}; | ||
exports.getActors = function(){ | ||
return actors; | ||
}; | ||
exports.getActor = function(id){ | ||
return actors[id]; | ||
}; | ||
exports.getActorKeys = function(){ | ||
return Object.keys(actors); | ||
}; | ||
exports.getTitle = function() { | ||
return title; | ||
exports.clear = function () { | ||
actors = {} | ||
messages = [] | ||
} | ||
exports.clear = function(){ | ||
actors = {}; | ||
messages = []; | ||
}; | ||
exports.LINETYPE = { | ||
SOLID : 0 , | ||
DOTTED : 1 , | ||
NOTE : 2 , | ||
SOLID_CROSS : 3 , | ||
DOTTED_CROSS : 4 , | ||
SOLID_OPEN : 5 , | ||
DOTTED_OPEN : 6 , | ||
LOOP_START : 10 , | ||
LOOP_END : 11 , | ||
ALT_START : 12 , | ||
ALT_ELSE : 13 , | ||
ALT_END : 14 , | ||
OPT_START : 15 , | ||
OPT_END : 16 , | ||
ACTIVE_START : 17 , | ||
ACTIVE_END : 18 | ||
}; | ||
SOLID: 0, | ||
DOTTED: 1, | ||
NOTE: 2, | ||
SOLID_CROSS: 3, | ||
DOTTED_CROSS: 4, | ||
SOLID_OPEN: 5, | ||
DOTTED_OPEN: 6, | ||
LOOP_START: 10, | ||
LOOP_END: 11, | ||
ALT_START: 12, | ||
ALT_ELSE: 13, | ||
ALT_END: 14, | ||
OPT_START: 15, | ||
OPT_END: 16, | ||
ACTIVE_START: 17, | ||
ACTIVE_END: 18, | ||
PAR_START: 19, | ||
PAR_AND: 20, | ||
PAR_END: 21 | ||
} | ||
exports.ARROWTYPE = { | ||
FILLED : 0, | ||
OPEN : 1 | ||
}; | ||
FILLED: 0, | ||
OPEN: 1 | ||
} | ||
exports.PLACEMENT = { | ||
LEFTOF : 0, | ||
RIGHTOF : 1, | ||
OVER : 2 | ||
}; | ||
LEFTOF: 0, | ||
RIGHTOF: 1, | ||
OVER: 2 | ||
} | ||
exports.addNote = function (actor, placement, message){ | ||
var note = {actor:actor, placement: placement, message:message}; | ||
exports.addNote = function (actor, placement, message) { | ||
var note = { actor: actor, placement: placement, message: message } | ||
// Coerce actor into a [to, from, ...] array | ||
var actors = [].concat(actor, actor); | ||
// Coerce actor into a [to, from, ...] array | ||
var actors = [].concat(actor, actor) | ||
notes.push(note); | ||
messages.push({from:actors[0], to:actors[1], message:message, type:exports.LINETYPE.NOTE, placement: placement}); | ||
}; | ||
notes.push(note) | ||
messages.push({ from: actors[0], to: actors[1], message: message, type: exports.LINETYPE.NOTE, placement: placement }) | ||
} | ||
exports.setTitle = function(titleText){ | ||
title = titleText; | ||
exports.setTitle = function (titleText) { | ||
title = titleText | ||
} | ||
exports.parseError = function (err, hash) { | ||
global.mermaidAPI.parseError(err, hash) | ||
} | ||
exports.parseError = function(err,hash){ | ||
global.mermaidAPI.parseError(err,hash); | ||
}; | ||
exports.apply = function(param){ | ||
if(param instanceof Array ){ | ||
param.forEach(function(item){ | ||
exports.apply(item); | ||
}); | ||
} else { | ||
// console.info(param); | ||
switch(param.type){ | ||
case 'addActor': | ||
exports.addActor(param.actor, param.actor, param.description); | ||
break; | ||
case 'activeStart': | ||
exports.addSignal(param.actor, undefined, undefined, param.signalType); | ||
break; | ||
case 'activeEnd': | ||
exports.addSignal(param.actor, undefined, undefined, param.signalType); | ||
break; | ||
case 'addNote': | ||
exports.addNote(param.actor,param.placement, param.text); | ||
break; | ||
case 'addMessage': | ||
exports.addSignal(param.from, param.to, param.msg, param.signalType); | ||
break; | ||
case 'loopStart': | ||
//log.debug('Loop text: ',param.loopText); | ||
exports.addSignal(undefined, undefined, param.loopText, param.signalType); | ||
//yy.addSignal(undefined, undefined, $2, yy.LINETYPE.LOOP_START); | ||
break; | ||
case 'loopEnd': | ||
exports.addSignal(undefined, undefined, undefined, param.signalType); | ||
break; | ||
case 'optStart': | ||
//log.debug('Loop text: ',param.loopText); | ||
exports.addSignal(undefined, undefined, param.optText, param.signalType); | ||
//yy.addSignal(undefined, undefined, $2, yy.LINETYPE.LOOP_START); | ||
break; | ||
case 'optEnd': | ||
exports.addSignal(undefined, undefined, undefined, param.signalType); | ||
break; | ||
case 'altStart': | ||
//log.debug('Loop text: ',param.loopText); | ||
exports.addSignal(undefined, undefined, param.altText, param.signalType); | ||
//yy.addSignal(undefined, undefined, $2, yy.LINETYPE.LOOP_START); | ||
break; | ||
case 'else': | ||
exports.addSignal(undefined, undefined, param.altText, param.signalType); | ||
break; | ||
case 'altEnd': | ||
exports.addSignal(undefined, undefined, undefined, param.signalType); | ||
break; | ||
case 'setTitle': | ||
exports.setTitle(param.text); | ||
} | ||
exports.apply = function (param) { | ||
if (param instanceof Array) { | ||
param.forEach(function (item) { | ||
exports.apply(item) | ||
}) | ||
} else { | ||
switch (param.type) { | ||
case 'addActor': | ||
exports.addActor(param.actor, param.actor, param.description) | ||
break | ||
case 'activeStart': | ||
exports.addSignal(param.actor, undefined, undefined, param.signalType) | ||
break | ||
case 'activeEnd': | ||
exports.addSignal(param.actor, undefined, undefined, param.signalType) | ||
break | ||
case 'addNote': | ||
exports.addNote(param.actor, param.placement, param.text) | ||
break | ||
case 'addMessage': | ||
exports.addSignal(param.from, param.to, param.msg, param.signalType) | ||
break | ||
case 'loopStart': | ||
exports.addSignal(undefined, undefined, param.loopText, param.signalType) | ||
break | ||
case 'loopEnd': | ||
exports.addSignal(undefined, undefined, undefined, param.signalType) | ||
break | ||
case 'optStart': | ||
exports.addSignal(undefined, undefined, param.optText, param.signalType) | ||
break | ||
case 'optEnd': | ||
exports.addSignal(undefined, undefined, undefined, param.signalType) | ||
break | ||
case 'altStart': | ||
exports.addSignal(undefined, undefined, param.altText, param.signalType) | ||
break | ||
case 'else': | ||
exports.addSignal(undefined, undefined, param.altText, param.signalType) | ||
break | ||
case 'altEnd': | ||
exports.addSignal(undefined, undefined, undefined, param.signalType) | ||
break | ||
case 'setTitle': | ||
exports.setTitle(param.text) | ||
break | ||
case 'parStart': | ||
exports.addSignal(undefined, undefined, param.parText, param.signalType) | ||
break | ||
case 'and': | ||
exports.addSignal(undefined, undefined, param.parText, param.signalType) | ||
break | ||
case 'parEnd': | ||
exports.addSignal(undefined, undefined, undefined, param.signalType) | ||
break | ||
} | ||
}; | ||
} | ||
} |
@@ -1,1016 +0,1027 @@ | ||
var proxyquire = require('proxyquire'); | ||
/* eslint-env jasmine */ | ||
/** | ||
* Created by knut on 14-11-18. | ||
*/ | ||
//var proxyquire = require('proxyquire'); | ||
//var log = require('../../logger').create(); | ||
var sq = require('./parser/sequenceDiagram').parser; | ||
var newD3; | ||
var sq = require('./parser/sequenceDiagram').parser | ||
var NewD3 | ||
var d3 = { | ||
select:function(){ | ||
return new newD3(); | ||
}, | ||
selectAll:function(){ | ||
return new newD3(); | ||
} | ||
}; | ||
//var sd = proxyquire('./sequenceRenderer', { './d3': d3 }); | ||
var sd = proxyquire('./sequenceRenderer', { '../../d3': d3 }); | ||
select: function () { | ||
return new NewD3() | ||
}, | ||
selectAll: function () { | ||
return new NewD3() | ||
} | ||
} | ||
const MyModuleInjector = require('inject-loader!./sequenceRenderer') // eslint-disable-line import/no-webpack-loader-syntax | ||
var sd = MyModuleInjector({ | ||
'../../d3': d3 | ||
}) | ||
// | ||
// | ||
//var sd = require('./sequenceRenderer'); | ||
function addConf(conf, key, value) { | ||
function addConf (conf, key, value) { | ||
if (value !== undefined) { | ||
conf[key]=value; | ||
conf[key] = value | ||
} | ||
return conf; | ||
return conf | ||
} | ||
var str; | ||
describe('when parsing a sequenceDiagram',function() { | ||
beforeEach(function () { | ||
sq.yy = require('./sequenceDb'); | ||
sq.yy.clear(); | ||
//parseError = function(err, hash) { | ||
// log.debug('Syntax error:' + err); | ||
// log.debug(hash); | ||
//}; | ||
//sq.yy.parseError = parseError; | ||
}); | ||
it('it should handle a sequenceDiagram defintion', function () { | ||
str = 'sequenceDiagram\n' + | ||
'Alice->Bob:Hello Bob, how are you?\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!'; | ||
var str | ||
describe('when parsing a sequenceDiagram', function () { | ||
beforeEach(function () { | ||
sq.yy = require('./sequenceDb') | ||
sq.yy.clear() | ||
}) | ||
it('it should handle a sequenceDiagram defintion', function () { | ||
str = 'sequenceDiagram\n' + | ||
'Alice->Bob:Hello Bob, how are you?\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(3); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[2].from).toBe('Bob'); | ||
}); | ||
it('it should handle a sequenceDiagram definition with a title', function () { | ||
str = 'sequenceDiagram\n' + | ||
'title: Diagram Title\n' + | ||
'Alice->Bob:Hello Bob, how are you?\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!'; | ||
expect(messages.length).toBe(3) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[2].from).toBe('Bob') | ||
}) | ||
it('it should handle a sequenceDiagram definition with a title', function () { | ||
str = 'sequenceDiagram\n' + | ||
'title: Diagram Title\n' + | ||
'Alice->Bob:Hello Bob, how are you?\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var title = sq.yy.getTitle(); | ||
var messages = sq.yy.getMessages() | ||
var title = sq.yy.getTitle() | ||
expect(messages.length).toBe(3); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[2].from).toBe('Bob'); | ||
expect(title).toBe('Diagram Title'); | ||
}); | ||
it('it should space in actor names', function () { | ||
str = 'sequenceDiagram\n' + | ||
'Alice->Bob:Hello Bob, how are - you?\n' + | ||
'Bob-->Alice: I am good thanks!'; | ||
expect(messages.length).toBe(3) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[2].from).toBe('Bob') | ||
expect(title).toBe('Diagram Title') | ||
}) | ||
it('it should space in actor names', function () { | ||
str = 'sequenceDiagram\n' + | ||
'Alice->Bob:Hello Bob, how are - you?\n' + | ||
'Bob-->Alice: I am good thanks!' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(2); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[1].from).toBe('Bob'); | ||
}); | ||
it('it should alias participants', function () { | ||
str = 'sequenceDiagram\n' + | ||
'participant A as Alice\n' + | ||
'participant B as Bob\n' + | ||
'A->B:Hello Bob, how are you?\n' + | ||
'B-->A: I am good thanks!'; | ||
expect(messages.length).toBe(2) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[1].from).toBe('Bob') | ||
}) | ||
it('it should alias participants', function () { | ||
str = 'sequenceDiagram\n' + | ||
'participant A as Alice\n' + | ||
'participant B as Bob\n' + | ||
'A->B:Hello Bob, how are you?\n' + | ||
'B-->A: I am good thanks!' | ||
sq.parse(str); | ||
sq.parse(str) | ||
var actors = sq.yy.getActors(); | ||
expect(Object.keys(actors)).toEqual(['A', 'B']); | ||
expect(actors.A.description).toBe('Alice'); | ||
expect(actors.B.description).toBe('Bob'); | ||
var actors = sq.yy.getActors() | ||
expect(Object.keys(actors)).toEqual(['A', 'B']) | ||
expect(actors.A.description).toBe('Alice') | ||
expect(actors.B.description).toBe('Bob') | ||
var messages = sq.yy.getMessages(); | ||
expect(messages.length).toBe(2); | ||
expect(messages[0].from).toBe('A'); | ||
expect(messages[1].from).toBe('B'); | ||
}); | ||
it('it should handle in async messages', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice-xBob:Hello Bob, how are you?'; | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(2) | ||
expect(messages[0].from).toBe('A') | ||
expect(messages[1].from).toBe('B') | ||
}) | ||
it('it should handle in async messages', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice-xBob:Hello Bob, how are you?' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
expect(actors.Bob.description).toBe('Bob'); | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
expect(actors.Bob.description).toBe('Bob') | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(1); | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.SOLID_CROSS); | ||
}); | ||
it('it should handle in async dotted messages', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice--xBob:Hello Bob, how are you?'; | ||
expect(messages.length).toBe(1) | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.SOLID_CROSS) | ||
}) | ||
it('it should handle in async dotted messages', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice--xBob:Hello Bob, how are you?' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
expect(actors.Bob.description).toBe('Bob'); | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
expect(actors.Bob.description).toBe('Bob') | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(1); | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.DOTTED_CROSS); | ||
}); | ||
it('it should handle in arrow messages', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->>Bob:Hello Bob, how are you?'; | ||
expect(messages.length).toBe(1) | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.DOTTED_CROSS) | ||
}) | ||
it('it should handle in arrow messages', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->>Bob:Hello Bob, how are you?' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
expect(actors.Bob.description).toBe('Bob'); | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
expect(actors.Bob.description).toBe('Bob') | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(1); | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.SOLID); | ||
}); | ||
it('it should handle in arrow messages', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice-->>Bob:Hello Bob, how are you?'; | ||
expect(messages.length).toBe(1) | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.SOLID) | ||
}) | ||
it('it should handle in arrow messages', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice-->>Bob:Hello Bob, how are you?' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
expect(actors.Bob.description).toBe('Bob'); | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
expect(actors.Bob.description).toBe('Bob') | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(1); | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.DOTTED); | ||
}); | ||
it('it should handle actor activation', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice-->>Bob:Hello Bob, how are you?\n' + | ||
'activate Bob\n' + | ||
'Bob-->>Alice:Hello Alice, I\'m fine and you?\n' + | ||
'deactivate Bob'; | ||
expect(messages.length).toBe(1) | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.DOTTED) | ||
}) | ||
it('it should handle actor activation', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice-->>Bob:Hello Bob, how are you?\n' + | ||
'activate Bob\n' + | ||
'Bob-->>Alice:Hello Alice, I\'m fine and you?\n' + | ||
'deactivate Bob' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
expect(actors.Bob.description).toBe('Bob'); | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
expect(actors.Bob.description).toBe('Bob') | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(4); | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.DOTTED); | ||
expect(messages[1].type).toBe(sq.yy.LINETYPE.ACTIVE_START); | ||
expect(messages[1].from.actor).toBe('Bob'); | ||
expect(messages[2].type).toBe(sq.yy.LINETYPE.DOTTED); | ||
expect(messages[3].type).toBe(sq.yy.LINETYPE.ACTIVE_END); | ||
expect(messages[3].from.actor).toBe('Bob'); | ||
}); | ||
it('it should handle actor one line notation activation', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice-->>+Bob:Hello Bob, how are you?\n' + | ||
'Bob-->>- Alice:Hello Alice, I\'m fine and you?'; | ||
expect(messages.length).toBe(4) | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.DOTTED) | ||
expect(messages[1].type).toBe(sq.yy.LINETYPE.ACTIVE_START) | ||
expect(messages[1].from.actor).toBe('Bob') | ||
expect(messages[2].type).toBe(sq.yy.LINETYPE.DOTTED) | ||
expect(messages[3].type).toBe(sq.yy.LINETYPE.ACTIVE_END) | ||
expect(messages[3].from.actor).toBe('Bob') | ||
}) | ||
it('it should handle actor one line notation activation', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice-->>+Bob:Hello Bob, how are you?\n' + | ||
'Bob-->>- Alice:Hello Alice, I\'m fine and you?' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
expect(actors.Bob.description).toBe('Bob'); | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
expect(actors.Bob.description).toBe('Bob') | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(4); | ||
console.log('msg', messages[0]); | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.DOTTED); | ||
console.log('msg', messages[1]); | ||
expect(messages[1].type).toBe(sq.yy.LINETYPE.ACTIVE_START); | ||
expect(messages[1].from.actor).toBe('Bob'); | ||
console.log('msg', messages[2]); | ||
expect(messages[2].type).toBe(sq.yy.LINETYPE.DOTTED); | ||
console.log('msg', messages[3]); | ||
expect(messages[3].type).toBe(sq.yy.LINETYPE.ACTIVE_END); | ||
expect(messages[3].from.actor).toBe('Bob'); | ||
}); | ||
it('it should handle stacked activations', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice-->>+Bob:Hello Bob, how are you?\n' + | ||
'Bob-->>+Carol:Carol, let me introduce Alice?\n' + | ||
'Bob-->>- Alice:Hello Alice, please meet Carol?\n' + | ||
'Carol->>- Bob:Oh Bob, I\'m so happy to be here!'; | ||
expect(messages.length).toBe(4) | ||
console.log('msg', messages[0]) | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.DOTTED) | ||
console.log('msg', messages[1]) | ||
expect(messages[1].type).toBe(sq.yy.LINETYPE.ACTIVE_START) | ||
expect(messages[1].from.actor).toBe('Bob') | ||
console.log('msg', messages[2]) | ||
expect(messages[2].type).toBe(sq.yy.LINETYPE.DOTTED) | ||
console.log('msg', messages[3]) | ||
expect(messages[3].type).toBe(sq.yy.LINETYPE.ACTIVE_END) | ||
expect(messages[3].from.actor).toBe('Bob') | ||
}) | ||
it('it should handle stacked activations', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice-->>+Bob:Hello Bob, how are you?\n' + | ||
'Bob-->>+Carol:Carol, let me introduce Alice?\n' + | ||
'Bob-->>- Alice:Hello Alice, please meet Carol?\n' + | ||
'Carol->>- Bob:Oh Bob, I\'m so happy to be here!' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
expect(actors.Bob.description).toBe('Bob'); | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
expect(actors.Bob.description).toBe('Bob') | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(8); | ||
console.log('msg', messages[0]); | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.DOTTED); | ||
console.log('msg', messages[1]); | ||
expect(messages[1].type).toBe(sq.yy.LINETYPE.ACTIVE_START); | ||
expect(messages[1].from.actor).toBe('Bob'); | ||
console.log('msg', messages[2]); | ||
expect(messages[2].type).toBe(sq.yy.LINETYPE.DOTTED); | ||
console.log('msg', messages[3]); | ||
expect(messages[3].type).toBe(sq.yy.LINETYPE.ACTIVE_START); | ||
expect(messages[3].from.actor).toBe('Carol'); | ||
console.log('msg', messages[5]); | ||
expect(messages[5].type).toBe(sq.yy.LINETYPE.ACTIVE_END); | ||
expect(messages[5].from.actor).toBe('Bob'); | ||
console.log('msg', messages[7]); | ||
expect(messages[7].type).toBe(sq.yy.LINETYPE.ACTIVE_END); | ||
expect(messages[7].from.actor).toBe('Carol'); | ||
}); | ||
it('it should handle comments in a sequenceDiagram', function () { | ||
str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n'+ | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!'; | ||
expect(messages.length).toBe(8) | ||
console.log('msg', messages[0]) | ||
expect(messages[0].type).toBe(sq.yy.LINETYPE.DOTTED) | ||
console.log('msg', messages[1]) | ||
expect(messages[1].type).toBe(sq.yy.LINETYPE.ACTIVE_START) | ||
expect(messages[1].from.actor).toBe('Bob') | ||
console.log('msg', messages[2]) | ||
expect(messages[2].type).toBe(sq.yy.LINETYPE.DOTTED) | ||
console.log('msg', messages[3]) | ||
expect(messages[3].type).toBe(sq.yy.LINETYPE.ACTIVE_START) | ||
expect(messages[3].from.actor).toBe('Carol') | ||
console.log('msg', messages[5]) | ||
expect(messages[5].type).toBe(sq.yy.LINETYPE.ACTIVE_END) | ||
expect(messages[5].from.actor).toBe('Bob') | ||
console.log('msg', messages[7]) | ||
expect(messages[7].type).toBe(sq.yy.LINETYPE.ACTIVE_END) | ||
expect(messages[7].from.actor).toBe('Carol') | ||
}) | ||
it('it should handle comments in a sequenceDiagram', function () { | ||
str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(3); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[2].from).toBe('Bob'); | ||
}); | ||
it('it should handle new lines in a sequenceDiagram', function () { | ||
str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!\n'; | ||
expect(messages.length).toBe(3) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[2].from).toBe('Bob') | ||
}) | ||
it('it should handle new lines in a sequenceDiagram', function () { | ||
str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!\n' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(3); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[2].from).toBe('Bob'); | ||
}); | ||
it('it should handle semicolons', function () { | ||
str = 'sequenceDiagram;' + | ||
'Alice->Bob: Hello Bob, how are you?;' + | ||
'Note right of Bob: Bob thinks;' + | ||
'Bob-->Alice: I am good thanks!;'; | ||
expect(messages.length).toBe(3) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[2].from).toBe('Bob') | ||
}) | ||
it('it should handle semicolons', function () { | ||
str = 'sequenceDiagram;' + | ||
'Alice->Bob: Hello Bob, how are you?;' + | ||
'Note right of Bob: Bob thinks;' + | ||
'Bob-->Alice: I am good thanks!;' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(3); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[2].from).toBe('Bob'); | ||
}); | ||
it('it should handle one leading space in lines in a sequenceDiagram', function () { | ||
str = 'sequenceDiagram\n' + | ||
' Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!'; | ||
expect(messages.length).toBe(3) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[2].from).toBe('Bob') | ||
}) | ||
it('it should handle one leading space in lines in a sequenceDiagram', function () { | ||
str = 'sequenceDiagram\n' + | ||
' Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(3); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[2].from).toBe('Bob'); | ||
}); | ||
it('it should handle several leading spaces in lines in a sequenceDiagram', function () { | ||
str = 'sequenceDiagram\n' + | ||
' Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!'; | ||
expect(messages.length).toBe(3) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[2].from).toBe('Bob') | ||
}) | ||
it('it should handle several leading spaces in lines in a sequenceDiagram', function () { | ||
str = 'sequenceDiagram\n' + | ||
' Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob-->Alice: I am good thanks!' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(3); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[2].from).toBe('Bob'); | ||
}); | ||
it('it should handle several leading spaces in lines in a sequenceDiagram', function () { | ||
str = 'sequenceDiagram\n'+ | ||
'participant Alice\n'+ | ||
'participant Bob\n'+ | ||
'Alice->John: Hello John, how are you?\n'+ | ||
' loop Healthcheck\n'+ | ||
'John->John: Fight against hypochondria\n'+ | ||
' end\n'+ | ||
'Note right of John: Rational thoughts<br/>prevail...\n'+ | ||
' John-->Alice: Great!\n'+ | ||
' John->Bob: How about you?\n'+ | ||
'Bob-->John: Jolly good!'; | ||
expect(messages.length).toBe(3) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[2].from).toBe('Bob') | ||
}) | ||
it('it should handle several leading spaces in lines in a sequenceDiagram', function () { | ||
str = 'sequenceDiagram\n' + | ||
'participant Alice\n' + | ||
'participant Bob\n' + | ||
'Alice->John: Hello John, how are you?\n' + | ||
' loop Healthcheck\n' + | ||
'John->John: Fight against hypochondria\n' + | ||
' end\n' + | ||
'Note right of John: Rational thoughts<br/>prevail...\n' + | ||
' John-->Alice: Great!\n' + | ||
' John->Bob: How about you?\n' + | ||
'Bob-->John: Jolly good!' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(8); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[2].from).toBe('John'); | ||
}); | ||
it('it should handle notes over a single actor', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'Note over Bob: Bob thinks\n'; | ||
expect(messages.length).toBe(8) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[2].from).toBe('John') | ||
}) | ||
it('it should handle notes over a single actor', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'Note over Bob: Bob thinks\n' | ||
sq.parse(str); | ||
sq.parse(str) | ||
var messages = sq.yy.getMessages(); | ||
expect(messages[1].from).toBe('Bob'); | ||
expect(messages[1].to).toBe('Bob'); | ||
}); | ||
it('it should handle notes over multiple actors', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'Note over Alice,Bob: confusion\n' + | ||
'Note over Bob,Alice: resolution\n'; | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].from).toBe('Bob') | ||
expect(messages[1].to).toBe('Bob') | ||
}) | ||
it('it should handle notes over multiple actors', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'Note over Alice,Bob: confusion\n' + | ||
'Note over Bob,Alice: resolution\n' | ||
sq.parse(str); | ||
sq.parse(str) | ||
var messages = sq.yy.getMessages(); | ||
expect(messages[1].from).toBe('Alice'); | ||
expect(messages[1].to).toBe('Bob'); | ||
expect(messages[2].from).toBe('Bob'); | ||
expect(messages[2].to).toBe('Alice'); | ||
}); | ||
it('it should handle loop statements a sequenceDiagram', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'loop Multiple happy responses\n\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end'; | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].from).toBe('Alice') | ||
expect(messages[1].to).toBe('Bob') | ||
expect(messages[2].from).toBe('Bob') | ||
expect(messages[2].to).toBe('Alice') | ||
}) | ||
it('it should handle loop statements a sequenceDiagram', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'loop Multiple happy responses\n\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(5); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[1].from).toBe('Bob'); | ||
}); | ||
it('it should handle opt statements a sequenceDiagram', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'opt Perhaps a happy response\n\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end'; | ||
expect(messages.length).toBe(5) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[1].from).toBe('Bob') | ||
}) | ||
it('it should handle opt statements a sequenceDiagram', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'opt Perhaps a happy response\n\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(5); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[1].from).toBe('Bob'); | ||
}); | ||
it('it should handle alt statements a sequenceDiagram', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'alt isWell\n\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'else isSick\n' + | ||
'Bob-->Alice: Feel sick...\n' + | ||
'end'; | ||
expect(messages.length).toBe(5) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[1].from).toBe('Bob') | ||
}) | ||
it('it should handle alt statements a sequenceDiagram', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n\n' + | ||
'%% Comment\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'alt isWell\n\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'else isSick\n' + | ||
'Bob-->Alice: Feel sick...\n' + | ||
'end' | ||
sq.parse(str); | ||
var actors = sq.yy.getActors(); | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
expect(actors.Alice.description).toBe('Alice'); | ||
actors.Bob.description = 'Bob'; | ||
expect(actors.Alice.description).toBe('Alice') | ||
actors.Bob.description = 'Bob' | ||
var messages = sq.yy.getMessages(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages.length).toBe(7); | ||
expect(messages[0].from).toBe('Alice'); | ||
expect(messages[1].from).toBe('Bob'); | ||
}); | ||
it('it should handle special characters in signals', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: -:<>,;# comment'; | ||
expect(messages.length).toBe(7) | ||
expect(messages[0].from).toBe('Alice') | ||
expect(messages[1].from).toBe('Bob') | ||
}) | ||
it('it should handle par statements a sequenceDiagram', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'par Parallel one\n' + | ||
'Alice->>Bob: Hello Bob, how are you?\n' + | ||
'Bob-->>Alice: I am good thanks!\n' + | ||
'and Parallel two\n' + | ||
'Alice->>Bob: Are you OK?\n' + | ||
'Bob-->>Alice: Fine!\n' + | ||
'and Parallel three\n' + | ||
'Alice->>Bob: What do you think about it?\n' + | ||
'Bob-->>Alice: It\'s good!\n' + | ||
'end' | ||
sq.parse(str); | ||
sq.parse(str) | ||
var actors = sq.yy.getActors() | ||
var messages = sq.yy.getMessages(); | ||
expect(messages[0].message).toBe('-:<>,'); | ||
}); | ||
it('it should handle special characters in notes', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'Note right of Bob: -:<>,;# comment'; | ||
expect(actors.Alice.description).toBe('Alice') | ||
expect(actors.Bob.description).toBe('Bob') | ||
sq.parse(str); | ||
var messages = sq.yy.getMessages() | ||
var messages = sq.yy.getMessages(); | ||
expect(messages[1].message).toBe('-:<>,'); | ||
}); | ||
it('it should handle special characters in loop', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'loop -:<>,;# comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end'; | ||
expect(messages.length).toBe(10) | ||
expect(messages[0].message).toBe('Parallel one') | ||
expect(messages[1].from).toBe('Alice') | ||
expect(messages[2].from).toBe('Bob') | ||
}) | ||
it('it should handle special characters in signals', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: -:<>,;# comment' | ||
sq.parse(str); | ||
sq.parse(str) | ||
var messages = sq.yy.getMessages(); | ||
expect(messages[1].message).toBe('-:<>,'); | ||
}); | ||
it('it should handle special characters in opt', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'opt -:<>,;# comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end'; | ||
var messages = sq.yy.getMessages() | ||
expect(messages[0].message).toBe('-:<>,') | ||
}) | ||
it('it should handle special characters in notes', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'Note right of Bob: -:<>,;# comment' | ||
sq.parse(str); | ||
sq.parse(str) | ||
var messages = sq.yy.getMessages(); | ||
expect(messages[1].message).toBe('-:<>,'); | ||
}); | ||
it('it should handle special characters in alt', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'alt -:<>,;# comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'else ,<>:-#; comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end'; | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].message).toBe('-:<>,') | ||
}) | ||
it('it should handle special characters in loop', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'loop -:<>,;# comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end' | ||
sq.parse(str); | ||
sq.parse(str) | ||
var messages = sq.yy.getMessages(); | ||
expect(messages[1].message).toBe('-:<>,'); | ||
expect(messages[3].message).toBe(',<>:-'); | ||
}); | ||
it('it should handle no-label loop', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'loop\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end'; | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].message).toBe('-:<>,') | ||
}) | ||
it('it should handle special characters in opt', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'opt -:<>,;# comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end' | ||
sq.parse(str); | ||
sq.parse(str) | ||
var messages = sq.yy.getMessages(); | ||
expect(messages[1].message).toBe(''); | ||
expect(messages[2].message).toBe('I am good thanks!'); | ||
}); | ||
it('it should handle no-label opt', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'opt # comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end'; | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].message).toBe('-:<>,') | ||
}) | ||
it('it should handle special characters in alt', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'alt -:<>,;# comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'else ,<>:-#; comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end' | ||
sq.parse(str); | ||
sq.parse(str) | ||
var messages = sq.yy.getMessages(); | ||
expect(messages[1].message).toBe(''); | ||
expect(messages[2].message).toBe('I am good thanks!'); | ||
}); | ||
it('it should handle no-label alt', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'alt;' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'else # comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end'; | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].message).toBe('-:<>,') | ||
expect(messages[3].message).toBe(',<>:-') | ||
}) | ||
it('it should handle special characters in par', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'par -:<>,;# comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'and ,<>:-#; comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end' | ||
sq.parse(str); | ||
sq.parse(str) | ||
var messages = sq.yy.getMessages(); | ||
expect(messages[1].message).toBe(''); | ||
expect(messages[2].message).toBe('I am good thanks!'); | ||
expect(messages[3].message).toBe(''); | ||
expect(messages[4].message).toBe('I am good thanks!'); | ||
}); | ||
}); | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].message).toBe('-:<>,') | ||
expect(messages[3].message).toBe(',<>:-') | ||
}) | ||
it('it should handle no-label loop', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'loop\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end' | ||
describe('when checking the bounds in a sequenceDiagram',function() { | ||
var conf; | ||
beforeEach(function () { | ||
sq.yy = require('./sequenceDb'); | ||
sq.yy.clear(); | ||
//parseError = function(err, hash) { | ||
// log.debug('Syntax error:' + err); | ||
// log.debug(hash); | ||
//}; | ||
//sq.yy.parseError = parseError; | ||
sq.parse(str) | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].message).toBe('') | ||
expect(messages[2].message).toBe('I am good thanks!') | ||
}) | ||
it('it should handle no-label opt', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'opt # comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end' | ||
conf = { | ||
diagramMarginX:50, | ||
diagramMarginY:10, | ||
actorMargin:50, | ||
width:150, | ||
// Height of actor boxes | ||
height:65, | ||
boxMargin:10, | ||
messageMargin:40, | ||
boxTextMargin:15, | ||
noteMargin:25 | ||
}; | ||
sd.setConf(conf); | ||
}); | ||
it('it should handle a simple bound call', function () { | ||
sd.bounds.init(); | ||
sq.parse(str) | ||
sd.bounds.insert(100,100,200,200); | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].message).toBe('') | ||
expect(messages[2].message).toBe('I am good thanks!') | ||
}) | ||
it('it should handle no-label alt', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'alt;' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'else # comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end' | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(100); | ||
expect(bounds.starty).toBe(100); | ||
expect(bounds.stopx ).toBe(200); | ||
expect(bounds.stopy ).toBe(200); | ||
sq.parse(str) | ||
}); | ||
it('it should handle an expanding bound', function () { | ||
sd.bounds.init(); | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].message).toBe('') | ||
expect(messages[2].message).toBe('I am good thanks!') | ||
expect(messages[3].message).toBe('') | ||
expect(messages[4].message).toBe('I am good thanks!') | ||
}) | ||
it('it should handle no-label par', function () { | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'par;' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'and # comment\n' + | ||
'Bob-->Alice: I am good thanks!\n' + | ||
'end' | ||
sd.bounds.insert(100,100,200,200); | ||
sd.bounds.insert(25,50,300,400); | ||
sq.parse(str) | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(25); | ||
expect(bounds.starty).toBe(50); | ||
expect(bounds.stopx ).toBe(300); | ||
expect(bounds.stopy ).toBe(400); | ||
var messages = sq.yy.getMessages() | ||
expect(messages[1].message).toBe('') | ||
expect(messages[2].message).toBe('I am good thanks!') | ||
expect(messages[3].message).toBe('') | ||
expect(messages[4].message).toBe('I am good thanks!') | ||
}) | ||
}) | ||
}); | ||
it('it should handle inserts within the bound without changing the outer bounds', function () { | ||
sd.bounds.init(); | ||
describe('when checking the bounds in a sequenceDiagram', function () { | ||
var conf | ||
beforeEach(function () { | ||
sq.yy = require('./sequenceDb') | ||
sq.yy.clear() | ||
conf = { | ||
diagramMarginX: 50, | ||
diagramMarginY: 10, | ||
actorMargin: 50, | ||
width: 150, | ||
// Height of actor boxes | ||
height: 65, | ||
boxMargin: 10, | ||
messageMargin: 40, | ||
boxTextMargin: 15, | ||
noteMargin: 25 | ||
} | ||
sd.setConf(conf) | ||
}) | ||
it('it should handle a simple bound call', function () { | ||
sd.bounds.init() | ||
sd.bounds.insert(100,100,200,200); | ||
sd.bounds.insert(25,50,300,400); | ||
sd.bounds.insert(125,150,150,200); | ||
sd.bounds.insert(100, 100, 200, 200) | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(25); | ||
expect(bounds.starty).toBe(50); | ||
expect(bounds.stopx ).toBe(300); | ||
expect(bounds.stopy ).toBe(400); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(100) | ||
expect(bounds.starty).toBe(100) | ||
expect(bounds.stopx).toBe(200) | ||
expect(bounds.stopy).toBe(200) | ||
}) | ||
it('it should handle an expanding bound', function () { | ||
sd.bounds.init() | ||
}); | ||
it('it should handle a loop without expanding the area', function () { | ||
sd.bounds.init(); | ||
sd.bounds.insert(100, 100, 200, 200) | ||
sd.bounds.insert(25, 50, 300, 400) | ||
sd.bounds.insert(25,50,300,400); | ||
sd.bounds.verticalPos = 150; | ||
sd.bounds.newLoop(); | ||
sd.bounds.insert(125,150,150,200); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(25) | ||
expect(bounds.starty).toBe(50) | ||
expect(bounds.stopx).toBe(300) | ||
expect(bounds.stopy).toBe(400) | ||
}) | ||
it('it should handle inserts within the bound without changing the outer bounds', function () { | ||
sd.bounds.init() | ||
var loop = sd.bounds.endLoop(); | ||
sd.bounds.insert(100, 100, 200, 200) | ||
sd.bounds.insert(25, 50, 300, 400) | ||
sd.bounds.insert(125, 150, 150, 200) | ||
expect(loop.startx).toBe(125-conf.boxMargin); | ||
expect(loop.starty).toBe(150-conf.boxMargin); | ||
expect(loop.stopx ).toBe(150+conf.boxMargin); | ||
expect(loop.stopy ).toBe(200+conf.boxMargin); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(25) | ||
expect(bounds.starty).toBe(50) | ||
expect(bounds.stopx).toBe(300) | ||
expect(bounds.stopy).toBe(400) | ||
}) | ||
it('it should handle a loop without expanding the area', function () { | ||
sd.bounds.init() | ||
// Check bounds of first loop | ||
var bounds = sd.bounds.getBounds(); | ||
sd.bounds.insert(25, 50, 300, 400) | ||
sd.bounds.verticalPos = 150 | ||
sd.bounds.newLoop() | ||
sd.bounds.insert(125, 150, 150, 200) | ||
expect(bounds.startx).toBe(25); | ||
expect(bounds.starty).toBe(50); | ||
expect(bounds.stopx ).toBe(300); | ||
expect(bounds.stopy ).toBe(400); | ||
}); | ||
it('it should handle multiple loops withtout expanding the bounds', function () { | ||
sd.bounds.init(); | ||
var loop = sd.bounds.endLoop() | ||
sd.bounds.insert(100,100,1000,1000); | ||
sd.bounds.verticalPos = 200; | ||
sd.bounds.newLoop(); | ||
sd.bounds.newLoop(); | ||
sd.bounds.insert(200,200,300,300); | ||
expect(loop.startx).toBe(125 - conf.boxMargin) | ||
expect(loop.starty).toBe(150 - conf.boxMargin) | ||
expect(loop.stopx).toBe(150 + conf.boxMargin) | ||
expect(loop.stopy).toBe(200 + conf.boxMargin) | ||
// Check bounds of first loop | ||
var loop = sd.bounds.endLoop(); | ||
// Check bounds of first loop | ||
var bounds = sd.bounds.getBounds() | ||
expect(loop.startx).toBe(200-conf.boxMargin); | ||
expect(loop.starty).toBe(200-conf.boxMargin); | ||
expect(loop.stopx ).toBe(300+conf.boxMargin); | ||
expect(loop.stopy ).toBe(300+conf.boxMargin); | ||
expect(bounds.startx).toBe(25) | ||
expect(bounds.starty).toBe(50) | ||
expect(bounds.stopx).toBe(300) | ||
expect(bounds.stopy).toBe(400) | ||
}) | ||
it('it should handle multiple loops withtout expanding the bounds', function () { | ||
sd.bounds.init() | ||
// Check bounds of second loop | ||
loop = sd.bounds.endLoop(); | ||
sd.bounds.insert(100, 100, 1000, 1000) | ||
sd.bounds.verticalPos = 200 | ||
sd.bounds.newLoop() | ||
sd.bounds.newLoop() | ||
sd.bounds.insert(200, 200, 300, 300) | ||
expect(loop.startx).toBe(200-2*conf.boxMargin); | ||
expect(loop.starty).toBe(200-2*conf.boxMargin); | ||
expect(loop.stopx ).toBe(300+2*conf.boxMargin); | ||
expect(loop.stopy ).toBe(300+2*conf.boxMargin); | ||
// Check bounds of first loop | ||
var loop = sd.bounds.endLoop() | ||
// Check bounds of first loop | ||
var bounds = sd.bounds.getBounds(); | ||
expect(loop.startx).toBe(200 - conf.boxMargin) | ||
expect(loop.starty).toBe(200 - conf.boxMargin) | ||
expect(loop.stopx).toBe(300 + conf.boxMargin) | ||
expect(loop.stopy).toBe(300 + conf.boxMargin) | ||
expect(bounds.startx).toBe(100); | ||
expect(bounds.starty).toBe(100); | ||
expect(bounds.stopx ).toBe(1000); | ||
expect(bounds.stopy ).toBe(1000); | ||
}); | ||
it('it should handle a loop that expands the area', function () { | ||
sd.bounds.init(); | ||
// Check bounds of second loop | ||
loop = sd.bounds.endLoop() | ||
sd.bounds.insert(100,100,200,200); | ||
sd.bounds.verticalPos = 200; | ||
sd.bounds.newLoop(); | ||
sd.bounds.insert(50,50,300,300); | ||
expect(loop.startx).toBe(200 - 2 * conf.boxMargin) | ||
expect(loop.starty).toBe(200 - 2 * conf.boxMargin) | ||
expect(loop.stopx).toBe(300 + 2 * conf.boxMargin) | ||
expect(loop.stopy).toBe(300 + 2 * conf.boxMargin) | ||
var loop = sd.bounds.endLoop(); | ||
// Check bounds of first loop | ||
var bounds = sd.bounds.getBounds() | ||
expect(loop.startx).toBe(50 - conf.boxMargin); | ||
expect(loop.starty).toBe(50 - conf.boxMargin); | ||
expect(loop.stopx ).toBe(300 + conf.boxMargin); | ||
expect(loop.stopy ).toBe(300 + conf.boxMargin); | ||
expect(bounds.startx).toBe(100) | ||
expect(bounds.starty).toBe(100) | ||
expect(bounds.stopx).toBe(1000) | ||
expect(bounds.stopy).toBe(1000) | ||
}) | ||
it('it should handle a loop that expands the area', function () { | ||
sd.bounds.init() | ||
// Check bounds after the loop | ||
var bounds = sd.bounds.getBounds(); | ||
sd.bounds.insert(100, 100, 200, 200) | ||
sd.bounds.verticalPos = 200 | ||
sd.bounds.newLoop() | ||
sd.bounds.insert(50, 50, 300, 300) | ||
expect(bounds.startx).toBe(loop.startx); | ||
expect(bounds.starty).toBe(loop.starty); | ||
expect(bounds.stopx ).toBe(loop.stopx); | ||
expect(bounds.stopy ).toBe(loop.stopy); | ||
}); | ||
}); | ||
var loop = sd.bounds.endLoop() | ||
describe('when rendering a sequenceDiagram',function() { | ||
var conf; | ||
beforeEach(function () { | ||
sq.yy = require('./sequenceDb'); | ||
sq.yy.clear(); | ||
expect(loop.startx).toBe(50 - conf.boxMargin) | ||
expect(loop.starty).toBe(50 - conf.boxMargin) | ||
expect(loop.stopx).toBe(300 + conf.boxMargin) | ||
expect(loop.stopy).toBe(300 + conf.boxMargin) | ||
//var MockBrowser = require('mock-browser').mocks.MockBrowser; | ||
//var mock = new MockBrowser(); | ||
// Check bounds after the loop | ||
var bounds = sd.bounds.getBounds() | ||
delete global.mermaid_config; | ||
expect(bounds.startx).toBe(loop.startx) | ||
expect(bounds.starty).toBe(loop.starty) | ||
expect(bounds.stopx).toBe(loop.stopx) | ||
expect(bounds.stopy).toBe(loop.stopy) | ||
}) | ||
}) | ||
// and in the run-code inside some object | ||
//global.document = mock.getDocument(); | ||
//global.window = mock.getWindow(); | ||
describe('when rendering a sequenceDiagram', function () { | ||
var conf | ||
beforeEach(function () { | ||
sq.yy = require('./sequenceDb') | ||
sq.yy.clear() | ||
//parseError = function(err, hash) { | ||
// log.debug('Syntax error:' + err); | ||
// log.debug(hash); | ||
//}; | ||
//sq.yy.parseError = parseError; | ||
delete global.mermaid_config | ||
newD3 = function() { | ||
var o = { | ||
append: function () { | ||
return newD3(); | ||
}, | ||
attr: function () { | ||
return this; | ||
}, | ||
style: function () { | ||
return this; | ||
}, | ||
text: function () { | ||
return this; | ||
}, | ||
0:{ | ||
0: { | ||
getBBox: function () { | ||
return { | ||
height: 10, | ||
width: 20 | ||
}; | ||
} | ||
} | ||
NewD3 = function () { | ||
var o = { | ||
append: function () { | ||
return NewD3() | ||
}, | ||
attr: function () { | ||
return this | ||
}, | ||
style: function () { | ||
return this | ||
}, | ||
text: function () { | ||
return this | ||
}, | ||
0: { | ||
0: { | ||
getBBox: function () { | ||
return { | ||
height: 10, | ||
width: 20 | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
return o; | ||
}; | ||
return o | ||
} | ||
conf = { | ||
diagramMarginX:50, | ||
diagramMarginY:10, | ||
actorMargin:50, | ||
width:150, | ||
// Height of actor boxes | ||
height:65, | ||
boxMargin:10, | ||
messageMargin:40, | ||
boxTextMargin:15, | ||
noteMargin:25 | ||
}; | ||
sd.setConf(conf); | ||
//document.body.innerHTML = '<div id="tst"></div>'; | ||
//document.body.innerHTML = '<svg height="30" width="200"><text id="tst" x="0" y="15" fill="red">I love SVG!</text></svg>'; | ||
//document.body.innerHTML = '<svg height="30" width="200"><text x="0" y="15" fill="red"><tspan x="46" id="tst">Alice thinks</tspan></text></svg>'; | ||
//console.log('document.body'); | ||
//console.log(document.querySelector('#tst').getBBox()); | ||
conf = { | ||
diagramMarginX: 50, | ||
diagramMarginY: 10, | ||
actorMargin: 50, | ||
width: 150, | ||
// Height of actor boxes | ||
height: 65, | ||
boxMargin: 10, | ||
messageMargin: 40, | ||
boxTextMargin: 15, | ||
noteMargin: 25 | ||
} | ||
sd.setConf(conf) | ||
}); | ||
['tspan', 'fo', 'old', undefined].forEach(function (textPlacement) { | ||
it('it should handle one actor, when textPlacement is ' + textPlacement, function () { | ||
sd.setConf(addConf(conf, 'textPlacement', textPlacement)) | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'participant Alice' | ||
}); | ||
['tspan','fo','old',undefined].forEach(function(textPlacement) { | ||
it('it should handle one actor, when textPlacement is '+textPlacement, function () { | ||
sd.setConf(addConf(conf, 'textPlacement', textPlacement)); | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'participant Alice'; | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(0) | ||
expect(bounds.starty).toBe(0) | ||
expect(bounds.stopx).toBe(conf.width) | ||
expect(bounds.stopy).toBe(conf.height) | ||
}) | ||
}) | ||
it('it should handle one actor and a centered note', function () { | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'participant Alice\n' + | ||
'Note over Alice: Alice thinks\n' | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(0); | ||
expect(bounds.starty).toBe(0); | ||
expect(bounds.stopx ).toBe( conf.width); | ||
expect(bounds.stopy ).toBe(conf.height); | ||
}); | ||
}); | ||
it('it should handle one actor and a centered note', function () { | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'participant Alice\n' + | ||
'Note over Alice: Alice thinks\n'; | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(0) | ||
expect(bounds.starty).toBe(0) | ||
expect(bounds.stopx).toBe(conf.width) | ||
// 10 comes from mock of text height | ||
expect(bounds.stopy).toBe(conf.height + conf.boxMargin + 2 * conf.noteMargin + 10) | ||
}) | ||
it('it should handle one actor and a note to the left', function () { | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'participant Alice\n' + | ||
'Note left of Alice: Alice thinks' | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(0); | ||
expect(bounds.starty).toBe(0); | ||
expect(bounds.stopx ).toBe( conf.width); | ||
// 10 comes from mock of text height | ||
expect(bounds.stopy ).toBe( conf.height + conf.boxMargin + 2*conf.noteMargin +10); | ||
}); | ||
it('it should handle one actor and a note to the left', function () { | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'participant Alice\n' + | ||
'Note left of Alice: Alice thinks'; | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(-(conf.width / 2) - (conf.actorMargin / 2)) | ||
expect(bounds.starty).toBe(0) | ||
expect(bounds.stopx).toBe(conf.width) | ||
// 10 comes from mock of text height | ||
expect(bounds.stopy).toBe(conf.height + conf.boxMargin + 2 * conf.noteMargin + 10) | ||
}) | ||
it('it should handle one actor and a note to the right', function () { | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'participant Alice\n' + | ||
'Note right of Alice: Alice thinks' | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(-(conf.width/2)-(conf.actorMargin/2)); | ||
expect(bounds.starty).toBe(0); | ||
expect(bounds.stopx ).toBe( conf.width ); | ||
// 10 comes from mock of text height | ||
expect(bounds.stopy ).toBe( conf.height + conf.boxMargin + 2*conf.noteMargin +10); | ||
}); | ||
it('it should handle one actor and a note to the right', function () { | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'participant Alice\n' + | ||
'Note right of Alice: Alice thinks'; | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(0) | ||
expect(bounds.starty).toBe(0) | ||
expect(bounds.stopx).toBe((conf.width / 2) + (conf.actorMargin / 2) + conf.width) | ||
// 10 comes from mock of text height | ||
expect(bounds.stopy).toBe(conf.height + conf.boxMargin + 2 * conf.noteMargin + 10) | ||
}) | ||
it('it should handle two actors', function () { | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?' | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(0); | ||
expect(bounds.starty).toBe(0); | ||
expect(bounds.stopx ).toBe( (conf.width/2) + (conf.actorMargin/2) + conf.width); | ||
// 10 comes from mock of text height | ||
expect(bounds.stopy ).toBe( conf.height + conf.boxMargin + 2*conf.noteMargin +10); | ||
}); | ||
it('it should handle two actors', function () { | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?'; | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(0) | ||
expect(bounds.starty).toBe(0) | ||
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin) | ||
expect(bounds.stopy).toBe(0 + conf.messageMargin + conf.height) | ||
}) | ||
it('it should handle two actors and two centered shared notes', function () { | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'Note over Alice,Bob: Looks\n' + | ||
'Note over Bob,Alice: Looks back\n' | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(0); | ||
expect(bounds.starty).toBe(0); | ||
expect(bounds.stopx ).toBe(conf.width*2 + conf.actorMargin); | ||
expect(bounds.stopy ).toBe(0 + conf.messageMargin + conf.height); | ||
}); | ||
it('it should handle two actors and two centered shared notes', function () { | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n'+ | ||
'Note over Alice,Bob: Looks\n' + | ||
'Note over Bob,Alice: Looks back\n'; | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(0) | ||
expect(bounds.starty).toBe(0) | ||
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin) | ||
expect(bounds.stopy).toBe(conf.height + conf.messageMargin + 2 * (conf.boxMargin + 2 * conf.noteMargin + 10)) | ||
}) | ||
it('it should draw two actors and two messages', function () { | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'Bob->Alice: Fine!' | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(0); | ||
expect(bounds.starty).toBe(0); | ||
expect(bounds.stopx ).toBe(conf.width*2 + conf.actorMargin); | ||
expect(bounds.stopy ).toBe( conf.height + conf.messageMargin + 2*(conf.boxMargin + 2*conf.noteMargin + 10)); | ||
}); | ||
it('it should draw two actors and two messages', function () { | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n'+ | ||
'Bob->Alice: Fine!'; | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(0) | ||
expect(bounds.starty).toBe(0) | ||
expect(bounds.stopx).toBe(0 + conf.width * 2 + conf.actorMargin) | ||
expect(bounds.stopy).toBe(0 + 2 * conf.messageMargin + conf.height) | ||
}) | ||
it('it should draw two actors notes to the right', function () { | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob->Alice: Fine!' | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(0); | ||
expect(bounds.starty).toBe(0); | ||
expect(bounds.stopx ).toBe(0 + conf.width*2 + conf.actorMargin); | ||
expect(bounds.stopy ).toBe(0 + 2*conf.messageMargin + conf.height); | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
}); | ||
it('it should draw two actors notes to the right', function () { | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n'+ | ||
'Note right of Bob: Bob thinks\n' + | ||
'Bob->Alice: Fine!'; | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(0) | ||
expect(bounds.starty).toBe(0) | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
var expStopX = conf.actorMargin + conf.width + (conf.width / 2) + conf.noteMargin + conf.width | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(0); | ||
expect(bounds.starty).toBe(0); | ||
expect(bounds.stopx).toBe(expStopX) | ||
expect(bounds.stopy).toBe(2 * conf.messageMargin + conf.height + conf.boxMargin + 10 + 2 * conf.noteMargin) | ||
}) | ||
it('it should draw two actors notes to the left', function () { | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'Note left of Alice: Bob thinks\n' + | ||
'Bob->Alice: Fine!' | ||
var expStopX = conf.actorMargin +conf.width+ (conf.width/2) + conf.noteMargin + conf.width; | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
expect(bounds.stopx ).toBe(expStopX); | ||
expect(bounds.stopy ).toBe(2*conf.messageMargin + conf.height + conf.boxMargin + 10+ 2*conf.noteMargin); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(-(conf.width / 2) - (conf.actorMargin / 2)) | ||
expect(bounds.starty).toBe(0) | ||
}); | ||
it('it should draw two actors notes to the left', function () { | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n'+ | ||
'Note left of Alice: Bob thinks\n' + | ||
'Bob->Alice: Fine!'; | ||
expect(bounds.stopx).toBe(conf.width * 2 + conf.actorMargin) | ||
expect(bounds.stopy).toBe(2 * conf.messageMargin + conf.height + conf.boxMargin + 10 + 2 * conf.noteMargin) | ||
}) | ||
it('it should draw two loops', function () { | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n' + | ||
'loop Cheers\n' + | ||
'Bob->Alice: Fine!\n' + | ||
'end' | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(0) | ||
expect(bounds.starty).toBe(0) | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe( -(conf.width/2)-(conf.actorMargin/2)); | ||
expect(bounds.starty).toBe(0); | ||
expect(bounds.stopx).toBe(0 + conf.width * 2 + conf.actorMargin) | ||
expect(bounds.stopy).toBe(0 + 2 * conf.messageMargin + conf.height + 3 * conf.boxMargin + conf.boxTextMargin) | ||
}) | ||
}) | ||
expect(bounds.stopx ).toBe( conf.width*2 + conf.actorMargin); | ||
expect(bounds.stopy ).toBe( 2*conf.messageMargin + conf.height + conf.boxMargin +10+ 2*conf.noteMargin); | ||
describe('when rendering a sequenceDiagram with actor mirror activated', function () { | ||
var conf | ||
beforeEach(function () { | ||
sq.yy = require('./sequenceDb') | ||
sq.yy.clear() | ||
}); | ||
it('it should draw two loops', function () { | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n'+ | ||
'loop Cheers\n' + | ||
'Bob->Alice: Fine!\n' + | ||
'end'; | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
NewD3 = function () { | ||
var o = { | ||
append: function () { | ||
return NewD3() | ||
}, | ||
attr: function () { | ||
return this | ||
}, | ||
style: function () { | ||
return this | ||
}, | ||
text: function () { | ||
return this | ||
}, | ||
0: { | ||
0: { | ||
getBBox: function () { | ||
return { | ||
height: 10, | ||
width: 20 | ||
} | ||
} | ||
} | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(0); | ||
expect(bounds.starty).toBe(0); | ||
} | ||
} | ||
expect(bounds.stopx ).toBe(0 + conf.width*2 + conf.actorMargin); | ||
expect(bounds.stopy ).toBe(0 + 2*conf.messageMargin + conf.height + 3*conf.boxMargin + conf.boxTextMargin); | ||
return o | ||
} | ||
}); | ||
}); | ||
conf = { | ||
diagramMarginX: 50, | ||
diagramMarginY: 10, | ||
actorMargin: 50, | ||
width: 150, | ||
// Height of actor boxes | ||
height: 65, | ||
boxMargin: 10, | ||
messageMargin: 40, | ||
boxTextMargin: 15, | ||
noteMargin: 25, | ||
mirrorActors: true, | ||
// Depending on css styling this might need adjustment | ||
// Prolongs the edge of the diagram downwards | ||
bottomMarginAdj: 1 | ||
} | ||
sd.setConf(conf) | ||
}); | ||
['tspan', 'fo', 'old', undefined].forEach(function (textPlacement) { | ||
it('it should handle one actor, when textPlacement is' + textPlacement, function () { | ||
sd.setConf(addConf(conf, 'textPlacement', textPlacement)) | ||
sd.bounds.init() | ||
var str = 'sequenceDiagram\n' + | ||
'participant Alice' | ||
describe('when rendering a sequenceDiagram with actor mirror activated',function() { | ||
var conf; | ||
beforeEach(function () { | ||
sq.yy = require('./sequenceDb'); | ||
sq.yy.clear(); | ||
//parseError = function(err, hash) { | ||
// log.debug('Syntax error:' + err); | ||
// log.debug(hash); | ||
//}; | ||
//sq.yy.parseError = parseError; | ||
sq.parse(str) | ||
sd.draw(str, 'tst') | ||
newD3 = function() { | ||
var o = { | ||
append: function () { | ||
return newD3(); | ||
}, | ||
attr: function () { | ||
return this; | ||
}, | ||
style: function () { | ||
return this; | ||
}, | ||
text: function () { | ||
return this; | ||
}, | ||
0:{ | ||
0: { | ||
getBBox: function () { | ||
return { | ||
height: 10, | ||
width: 20 | ||
}; | ||
} | ||
} | ||
} | ||
}; | ||
return o; | ||
}; | ||
conf = { | ||
diagramMarginX:50, | ||
diagramMarginY:10, | ||
actorMargin:50, | ||
width:150, | ||
// Height of actor boxes | ||
height:65, | ||
boxMargin:10, | ||
messageMargin:40, | ||
boxTextMargin:15, | ||
noteMargin:25, | ||
mirrorActors:true, | ||
// Depending on css styling this might need adjustment | ||
// Prolongs the edge of the diagram downwards | ||
bottomMarginAdj:1 | ||
}; | ||
sd.setConf(conf); | ||
}); | ||
['tspan','fo','old',undefined].forEach(function(textPlacement) { | ||
it('it should handle one actor, when textPlacement is'+textPlacement, function () { | ||
sd.setConf(addConf(conf, 'textPlacement', textPlacement)); | ||
sd.bounds.init(); | ||
var str = 'sequenceDiagram\n' + | ||
'participant Alice'; | ||
sq.parse(str); | ||
sd.draw(str,'tst'); | ||
var bounds = sd.bounds.getBounds(); | ||
expect(bounds.startx).toBe(0); | ||
expect(bounds.starty).toBe(0); | ||
expect(bounds.stopx ).toBe( conf.width); | ||
expect(bounds.stopy ).toBe(2*conf.height+2*conf.boxMargin); | ||
}); | ||
}); | ||
}); | ||
var bounds = sd.bounds.getBounds() | ||
expect(bounds.startx).toBe(0) | ||
expect(bounds.starty).toBe(0) | ||
expect(bounds.stopx).toBe(conf.width) | ||
expect(bounds.stopy).toBe(2 * conf.height + 2 * conf.boxMargin) | ||
}) | ||
}) | ||
}) |
@@ -5,152 +5,158 @@ /** | ||
var sq = require('./parser/sequenceDiagram').parser; | ||
sq.yy = require('./sequenceDb'); | ||
var svgDraw = require('./svgDraw'); | ||
var d3 = require('../../d3'); | ||
var Logger = require('../../logger'); | ||
var log = new Logger.Log(); | ||
var sq = require('./parser/sequenceDiagram').parser | ||
sq.yy = require('./sequenceDb') | ||
var svgDraw = require('./svgDraw') | ||
var d3 = require('../../d3') | ||
var Logger = require('../../logger') | ||
var log = Logger.Log | ||
var conf = { | ||
diagramMarginX:50, | ||
diagramMarginY:30, | ||
// Margin between actors | ||
actorMargin:50, | ||
// Width of actor boxes | ||
width:150, | ||
// Height of actor boxes | ||
height:65, | ||
// Margin around loop boxes | ||
boxMargin:10, | ||
boxTextMargin:5, | ||
noteMargin:10, | ||
// Space between messages | ||
messageMargin:35, | ||
//mirror actors under diagram | ||
mirrorActors:false, | ||
// Depending on css styling this might need adjustment | ||
// Prolongs the edge of the diagram downwards | ||
bottomMarginAdj:1, | ||
diagramMarginX: 50, | ||
diagramMarginY: 30, | ||
// Margin between actors | ||
actorMargin: 50, | ||
// Width of actor boxes | ||
width: 150, | ||
// Height of actor boxes | ||
height: 65, | ||
// Margin around loop boxes | ||
boxMargin: 10, | ||
boxTextMargin: 5, | ||
noteMargin: 10, | ||
// Space between messages | ||
messageMargin: 35, | ||
// mirror actors under diagram | ||
mirrorActors: false, | ||
// Depending on css styling this might need adjustment | ||
// Prolongs the edge of the diagram downwards | ||
bottomMarginAdj: 1, | ||
// width of activation box | ||
activationWidth:10, | ||
// width of activation box | ||
activationWidth: 10, | ||
//text placement as: tspan | fo | old only text as before | ||
textPlacement: 'tspan', | ||
}; | ||
// text placement as: tspan | fo | old only text as before | ||
textPlacement: 'tspan' | ||
} | ||
exports.bounds = { | ||
data:{ | ||
startx:undefined, | ||
stopx :undefined, | ||
starty:undefined, | ||
stopy :undefined | ||
}, | ||
verticalPos:0, | ||
data: { | ||
startx: undefined, | ||
stopx: undefined, | ||
starty: undefined, | ||
stopy: undefined | ||
}, | ||
verticalPos: 0, | ||
sequenceItems: [], | ||
activations: [], | ||
init : function(){ | ||
this.sequenceItems = []; | ||
this.activations = []; | ||
this.data = { | ||
startx:undefined, | ||
stopx :undefined, | ||
starty:undefined, | ||
stopy :undefined | ||
}; | ||
this.verticalPos =0; | ||
}, | ||
updateVal : function (obj,key,val,fun){ | ||
if(typeof obj[key] === 'undefined'){ | ||
obj[key] = val; | ||
}else{ | ||
obj[key] = fun(val,obj[key]); | ||
} | ||
}, | ||
updateBounds:function(startx,starty,stopx,stopy){ | ||
var _self = this; | ||
var cnt = 0; | ||
function updateFn(type) { return function updateItemBounds(item) { | ||
cnt++; | ||
// The loop sequenceItems is a stack so the biggest margins in the beginning of the sequenceItems | ||
var n = _self.sequenceItems.length-cnt+1; | ||
sequenceItems: [], | ||
activations: [], | ||
init: function () { | ||
this.sequenceItems = [] | ||
this.activations = [] | ||
this.data = { | ||
startx: undefined, | ||
stopx: undefined, | ||
starty: undefined, | ||
stopy: undefined | ||
} | ||
this.verticalPos = 0 | ||
}, | ||
updateVal: function (obj, key, val, fun) { | ||
if (typeof obj[key] === 'undefined') { | ||
obj[key] = val | ||
} else { | ||
obj[key] = fun(val, obj[key]) | ||
} | ||
}, | ||
updateBounds: function (startx, starty, stopx, stopy) { | ||
var _self = this | ||
var cnt = 0 | ||
function updateFn (type) { | ||
return function updateItemBounds (item) { | ||
cnt++ | ||
// The loop sequenceItems is a stack so the biggest margins in the beginning of the sequenceItems | ||
var n = _self.sequenceItems.length - cnt + 1 | ||
_self.updateVal(item, 'starty',starty - n*conf.boxMargin, Math.min); | ||
_self.updateVal(item, 'stopy' ,stopy + n*conf.boxMargin, Math.max); | ||
_self.updateVal(item, 'starty', starty - n * conf.boxMargin, Math.min) | ||
_self.updateVal(item, 'stopy', stopy + n * conf.boxMargin, Math.max) | ||
_self.updateVal(exports.bounds.data, 'startx', startx - n * conf.boxMargin, Math.min); | ||
_self.updateVal(exports.bounds.data, 'stopx', stopx + n * conf.boxMargin, Math.max); | ||
_self.updateVal(exports.bounds.data, 'startx', startx - n * conf.boxMargin, Math.min) | ||
_self.updateVal(exports.bounds.data, 'stopx', stopx + n * conf.boxMargin, Math.max) | ||
if (!(type == 'activation')) { | ||
_self.updateVal(item, 'startx',startx - n*conf.boxMargin, Math.min); | ||
_self.updateVal(item, 'stopx' ,stopx + n*conf.boxMargin, Math.max); | ||
if (!(type === 'activation')) { | ||
_self.updateVal(item, 'startx', startx - n * conf.boxMargin, Math.min) | ||
_self.updateVal(item, 'stopx', stopx + n * conf.boxMargin, Math.max) | ||
_self.updateVal(exports.bounds.data, 'starty', starty - n * conf.boxMargin, Math.min); | ||
_self.updateVal(exports.bounds.data, 'stopy', stopy + n * conf.boxMargin, Math.max); | ||
} | ||
}} | ||
_self.updateVal(exports.bounds.data, 'starty', starty - n * conf.boxMargin, Math.min) | ||
_self.updateVal(exports.bounds.data, 'stopy', stopy + n * conf.boxMargin, Math.max) | ||
} | ||
} | ||
} | ||
this.sequenceItems.forEach(updateFn()); | ||
this.activations.forEach(updateFn('activation')); | ||
}, | ||
insert:function(startx,starty,stopx,stopy){ | ||
this.sequenceItems.forEach(updateFn()) | ||
this.activations.forEach(updateFn('activation')) | ||
}, | ||
insert: function (startx, starty, stopx, stopy) { | ||
var _startx, _starty, _stopx, _stopy | ||
var _startx, _starty, _stopx, _stopy; | ||
_startx = Math.min(startx, stopx) | ||
_stopx = Math.max(startx, stopx) | ||
_starty = Math.min(starty, stopy) | ||
_stopy = Math.max(starty, stopy) | ||
_startx = Math.min(startx,stopx); | ||
_stopx = Math.max(startx,stopx); | ||
_starty = Math.min(starty,stopy); | ||
_stopy = Math.max(starty,stopy); | ||
this.updateVal(exports.bounds.data, 'startx', _startx, Math.min) | ||
this.updateVal(exports.bounds.data, 'starty', _starty, Math.min) | ||
this.updateVal(exports.bounds.data, 'stopx', _stopx, Math.max) | ||
this.updateVal(exports.bounds.data, 'stopy', _stopy, Math.max) | ||
this.updateVal(exports.bounds.data,'startx',_startx,Math.min); | ||
this.updateVal(exports.bounds.data,'starty',_starty,Math.min); | ||
this.updateVal(exports.bounds.data,'stopx' ,_stopx ,Math.max); | ||
this.updateVal(exports.bounds.data,'stopy' ,_stopy ,Math.max); | ||
this.updateBounds(_startx, _starty, _stopx, _stopy) | ||
}, | ||
newActivation: function (message, diagram) { | ||
var actorRect = sq.yy.getActors()[message.from.actor] | ||
var stackedSize = actorActivations(message.from.actor).length | ||
var x = actorRect.x + conf.width / 2 + (stackedSize - 1) * conf.activationWidth / 2 | ||
this.activations.push({ | ||
startx: x, | ||
starty: this.verticalPos + 2, | ||
stopx: x + conf.activationWidth, | ||
stopy: undefined, | ||
actor: message.from.actor, | ||
anchored: svgDraw.anchorElement(diagram) | ||
}) | ||
}, | ||
endActivation: function (message) { | ||
// find most recent activation for given actor | ||
var lastActorActivationIdx = this.activations | ||
.map(function (activation) { return activation.actor }) | ||
.lastIndexOf(message.from.actor) | ||
var activation = this.activations.splice(lastActorActivationIdx, 1)[0] | ||
return activation | ||
}, | ||
newLoop: function (title) { | ||
this.sequenceItems.push({ startx: undefined, starty: this.verticalPos, stopx: undefined, stopy: undefined, title: title }) | ||
}, | ||
endLoop: function () { | ||
var loop = this.sequenceItems.pop() | ||
return loop | ||
}, | ||
addSectionToLoop: function (message) { | ||
var loop = this.sequenceItems.pop() | ||
loop.sections = loop.sections || [] | ||
loop.sectionTitles = loop.sectionTitles || [] | ||
loop.sections.push(exports.bounds.getVerticalPos()) | ||
loop.sectionTitles.push(message) | ||
this.sequenceItems.push(loop) | ||
}, | ||
bumpVerticalPos: function (bump) { | ||
this.verticalPos = this.verticalPos + bump | ||
this.data.stopy = this.verticalPos | ||
}, | ||
getVerticalPos: function () { | ||
return this.verticalPos | ||
}, | ||
getBounds: function () { | ||
return this.data | ||
} | ||
} | ||
this.updateBounds(_startx,_starty,_stopx,_stopy); | ||
}, | ||
newActivation:function(message, diagram){ | ||
var actorRect = sq.yy.getActors()[message.from.actor]; | ||
var stackedSize = actorActivations(message.from.actor).length; | ||
var x = actorRect.x + conf.width/2 + (stackedSize-1)*conf.activationWidth/2; | ||
this.activations.push({startx:x,starty:this.verticalPos+2,stopx:x+conf.activationWidth,stopy:undefined, | ||
actor: message.from.actor, | ||
anchored: svgDraw.anchorElement(diagram) | ||
}); | ||
}, | ||
endActivation:function(message){ | ||
// find most recent activation for given actor | ||
var lastActorActivationIdx = this.activations | ||
.map(function(activation) { return activation.actor }) | ||
.lastIndexOf(message.from.actor); | ||
var activation = this.activations.splice(lastActorActivationIdx, 1)[0]; | ||
return activation; | ||
}, | ||
newLoop:function(title){ | ||
this.sequenceItems.push({startx:undefined,starty:this.verticalPos,stopx:undefined,stopy:undefined, title:title}); | ||
}, | ||
endLoop:function(){ | ||
var loop = this.sequenceItems.pop(); | ||
return loop; | ||
}, | ||
addElseToLoop:function(message){ | ||
var loop = this.sequenceItems.pop(); | ||
loop.elsey = exports.bounds.getVerticalPos(); | ||
loop.elseText = message; | ||
this.sequenceItems.push(loop); | ||
}, | ||
bumpVerticalPos:function(bump){ | ||
this.verticalPos = this.verticalPos + bump; | ||
this.data.stopy = this.verticalPos; | ||
}, | ||
getVerticalPos:function(){ | ||
return this.verticalPos; | ||
}, | ||
getBounds:function(){ | ||
return this.data; | ||
} | ||
}; | ||
/** | ||
@@ -162,40 +168,39 @@ * Draws an actor in the diagram with the attaced line | ||
*/ | ||
var drawNote = function(elem, startx, verticalPos, msg, forceWidth){ | ||
var rect = svgDraw.getNoteRect(); | ||
rect.x = startx; | ||
rect.y = verticalPos; | ||
rect.width = forceWidth || conf.width; | ||
rect.class = 'note'; | ||
var drawNote = function (elem, startx, verticalPos, msg, forceWidth) { | ||
var rect = svgDraw.getNoteRect() | ||
rect.x = startx | ||
rect.y = verticalPos | ||
rect.width = forceWidth || conf.width | ||
rect.class = 'note' | ||
var g = elem.append('g'); | ||
var rectElem = svgDraw.drawRect(g, rect); | ||
var g = elem.append('g') | ||
var rectElem = svgDraw.drawRect(g, rect) | ||
var textObj = svgDraw.getTextObj(); | ||
textObj.x = startx-4; | ||
textObj.y = verticalPos-13; | ||
textObj.textMargin = conf.noteMargin; | ||
textObj.dy = '1em'; | ||
textObj.text = msg.message; | ||
textObj.class = 'noteText'; | ||
var textObj = svgDraw.getTextObj() | ||
textObj.x = startx - 4 | ||
textObj.y = verticalPos - 13 | ||
textObj.textMargin = conf.noteMargin | ||
textObj.dy = '1em' | ||
textObj.text = msg.message | ||
textObj.class = 'noteText' | ||
var textElem = svgDraw.drawText(g,textObj, rect.width-conf.noteMargin); | ||
var textElem = svgDraw.drawText(g, textObj, rect.width - conf.noteMargin) | ||
var textHeight = textElem[0][0].getBBox().height; | ||
if(!forceWidth && textHeight > conf.width){ | ||
textElem.remove(); | ||
g = elem.append('g'); | ||
var textHeight = textElem[0][0].getBBox().height | ||
if (!forceWidth && textHeight > conf.width) { | ||
textElem.remove() | ||
g = elem.append('g') | ||
textElem = svgDraw.drawText(g,textObj, 2*rect.width-conf.noteMargin); | ||
textHeight = textElem[0][0].getBBox().height; | ||
rectElem.attr('width',2*rect.width); | ||
exports.bounds.insert(startx, verticalPos, startx + 2*rect.width, verticalPos + 2*conf.noteMargin + textHeight); | ||
}else{ | ||
exports.bounds.insert(startx, verticalPos, startx + rect.width, verticalPos + 2*conf.noteMargin + textHeight); | ||
} | ||
textElem = svgDraw.drawText(g, textObj, 2 * rect.width - conf.noteMargin) | ||
textHeight = textElem[0][0].getBBox().height | ||
rectElem.attr('width', 2 * rect.width) | ||
exports.bounds.insert(startx, verticalPos, startx + 2 * rect.width, verticalPos + 2 * conf.noteMargin + textHeight) | ||
} else { | ||
exports.bounds.insert(startx, verticalPos, startx + rect.width, verticalPos + 2 * conf.noteMargin + textHeight) | ||
} | ||
rectElem.attr('height',textHeight+ 2*conf.noteMargin); | ||
exports.bounds.bumpVerticalPos(textHeight+ 2*conf.noteMargin); | ||
}; | ||
rectElem.attr('height', textHeight + 2 * conf.noteMargin) | ||
exports.bounds.bumpVerticalPos(textHeight + 2 * conf.noteMargin) | ||
} | ||
/** | ||
@@ -210,121 +215,112 @@ * Draws a message | ||
*/ | ||
var drawMessage = function(elem, startx, stopx, verticalPos, msg){ | ||
var g = elem.append('g'); | ||
var txtCenter = startx + (stopx-startx)/2; | ||
var drawMessage = function (elem, startx, stopx, verticalPos, msg) { | ||
var g = elem.append('g') | ||
var txtCenter = startx + (stopx - startx) / 2 | ||
var textElem = g.append('text') // text label for the x axis | ||
.attr('x', txtCenter) | ||
.attr('y', verticalPos - 7) | ||
.style('text-anchor', 'middle') | ||
.attr('class', 'messageText') | ||
.text(msg.message); | ||
var textElem = g.append('text') // text label for the x axis | ||
.attr('x', txtCenter) | ||
.attr('y', verticalPos - 7) | ||
.style('text-anchor', 'middle') | ||
.attr('class', 'messageText') | ||
.text(msg.message) | ||
var textWidth; | ||
var textWidth | ||
if(typeof textElem[0][0].getBBox !== 'undefined'){ | ||
textWidth = textElem[0][0].getBBox().width; | ||
} | ||
else{ | ||
//textWidth = getBBox(textElem).width; //.getComputedTextLength() | ||
textWidth = textElem[0][0].getBoundingClientRect(); | ||
//textWidth = textElem[0][0].getComputedTextLength(); | ||
} | ||
if (typeof textElem[0][0].getBBox !== 'undefined') { | ||
textWidth = textElem[0][0].getBBox().width | ||
} else { | ||
textWidth = textElem[0][0].getBoundingClientRect() | ||
} | ||
var line; | ||
var line | ||
if(startx===stopx){ | ||
line = g.append('path') | ||
.attr('d', 'M ' +startx+ ','+verticalPos+' C ' +(startx+60)+ ','+(verticalPos-10)+' ' +(startx+60)+ ',' + | ||
(verticalPos+30)+' ' +startx+ ','+(verticalPos+20)); | ||
if (startx === stopx) { | ||
line = g.append('path') | ||
.attr('d', 'M ' + startx + ',' + verticalPos + ' C ' + (startx + 60) + ',' + (verticalPos - 10) + ' ' + (startx + 60) + ',' + | ||
(verticalPos + 30) + ' ' + startx + ',' + (verticalPos + 20)) | ||
exports.bounds.bumpVerticalPos(30); | ||
var dx = Math.max(textWidth/2,100); | ||
exports.bounds.insert(startx-dx, exports.bounds.getVerticalPos() -10, stopx+dx, exports.bounds.getVerticalPos()); | ||
}else{ | ||
line = g.append('line'); | ||
line.attr('x1', startx); | ||
line.attr('y1', verticalPos); | ||
line.attr('x2', stopx); | ||
line.attr('y2', verticalPos); | ||
exports.bounds.insert(startx, exports.bounds.getVerticalPos() -10, stopx, exports.bounds.getVerticalPos()); | ||
} | ||
//Make an SVG Container | ||
//Draw the line | ||
if (msg.type === sq.yy.LINETYPE.DOTTED || msg.type === sq.yy.LINETYPE.DOTTED_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_OPEN) { | ||
line.style('stroke-dasharray', ('3, 3')); | ||
line.attr('class', 'messageLine1'); | ||
} | ||
else { | ||
line.attr('class', 'messageLine0'); | ||
} | ||
exports.bounds.bumpVerticalPos(30) | ||
var dx = Math.max(textWidth / 2, 100) | ||
exports.bounds.insert(startx - dx, exports.bounds.getVerticalPos() - 10, stopx + dx, exports.bounds.getVerticalPos()) | ||
} else { | ||
line = g.append('line') | ||
line.attr('x1', startx) | ||
line.attr('y1', verticalPos) | ||
line.attr('x2', stopx) | ||
line.attr('y2', verticalPos) | ||
exports.bounds.insert(startx, exports.bounds.getVerticalPos() - 10, stopx, exports.bounds.getVerticalPos()) | ||
} | ||
// Make an SVG Container | ||
// Draw the line | ||
if (msg.type === sq.yy.LINETYPE.DOTTED || msg.type === sq.yy.LINETYPE.DOTTED_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_OPEN) { | ||
line.style('stroke-dasharray', ('3, 3')) | ||
line.attr('class', 'messageLine1') | ||
} else { | ||
line.attr('class', 'messageLine0') | ||
} | ||
var url = ''; | ||
if(conf.arrowMarkerAbsolute){ | ||
url = window.location.protocol+'//'+window.location.host+window.location.pathname +window.location.search; | ||
url = url.replace(/\(/g,'\\('); | ||
url = url.replace(/\)/g,'\\)'); | ||
} | ||
var url = '' | ||
if (conf.arrowMarkerAbsolute) { | ||
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(' + url + '#arrowhead)'); | ||
} | ||
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(' + url + '#arrowhead)') | ||
} | ||
if (msg.type === sq.yy.LINETYPE.SOLID_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_CROSS){ | ||
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(' + url + '#crosshead)') | ||
} | ||
} | ||
}; | ||
module.exports.drawActors = function (diagram, actors, actorKeys, verticalPos) { | ||
var i | ||
// Draw the actors | ||
for (i = 0; i < actorKeys.length; i++) { | ||
var key = actorKeys[i] | ||
// Add some rendering data to the object | ||
actors[key].x = i * conf.actorMargin + i * conf.width | ||
actors[key].y = verticalPos | ||
actors[key].width = conf.diagramMarginX | ||
actors[key].height = conf.diagramMarginY | ||
module.exports.drawActors = function(diagram, actors, actorKeys,verticalPos){ | ||
var i; | ||
// Draw the actors | ||
for(i=0;i<actorKeys.length;i++){ | ||
var key = actorKeys[i]; | ||
// Draw the box with the attached line | ||
svgDraw.drawActor(diagram, actors[key].x, verticalPos, actors[key].description, conf) | ||
exports.bounds.insert(actors[key].x, verticalPos, actors[key].x + conf.width, conf.height) | ||
} | ||
// Add some rendering data to the object | ||
actors[key].x = i*conf.actorMargin +i*conf.width; | ||
actors[key].y = verticalPos; | ||
actors[key].width = conf.diagramMarginX; | ||
actors[key].height = conf.diagramMarginY; | ||
// Add a margin between the actor boxes and the first arrow | ||
exports.bounds.bumpVerticalPos(conf.height) | ||
} | ||
// Draw the box with the attached line | ||
svgDraw.drawActor(diagram, actors[key].x, verticalPos, actors[key].description, conf); | ||
exports.bounds.insert(actors[key].x, verticalPos, actors[key].x + conf.width, conf.height); | ||
module.exports.setConf = function (cnf) { | ||
var keys = Object.keys(cnf) | ||
} | ||
keys.forEach(function (key) { | ||
conf[key] = cnf[key] | ||
}) | ||
} | ||
// Add a margin between the actor boxes and the first arrow | ||
//exports.bounds.bumpVerticalPos(conf.height+conf.messageMargin); | ||
exports.bounds.bumpVerticalPos(conf.height); | ||
}; | ||
var actorActivations = function (actor) { | ||
return module.exports.bounds.activations.filter(function (activation) { | ||
return activation.actor === actor | ||
}) | ||
} | ||
var actorFlowVerticaBounds = function (actor) { | ||
// handle multiple stacked activations for same actor | ||
var actors = sq.yy.getActors() | ||
var activations = actorActivations(actor) | ||
module.exports.setConf = function(cnf){ | ||
var keys = Object.keys(cnf); | ||
var left = activations.reduce(function (acc, activation) { return Math.min(acc, activation.startx) }, actors[actor].x + conf.width / 2) | ||
var right = activations.reduce(function (acc, activation) { return Math.max(acc, activation.stopx) }, actors[actor].x + conf.width / 2) | ||
return [left, right] | ||
} | ||
keys.forEach(function(key){ | ||
conf[key] = cnf[key]; | ||
}); | ||
}; | ||
var actorActivations = function(actor) { | ||
return module.exports.bounds.activations.filter(function(activation) { | ||
return activation.actor == actor; | ||
}); | ||
}; | ||
var actorFlowVerticaBounds = function(actor) { | ||
// handle multiple stacked activations for same actor | ||
var actors = sq.yy.getActors(); | ||
var activations = actorActivations(actor); | ||
var left = activations.reduce(function(acc,activation) { return Math.min(acc,activation.startx)}, actors[actor].x + conf.width/2); | ||
var right = activations.reduce(function(acc,activation) { return Math.max(acc,activation.stopx)}, actors[actor].x + conf.width/2); | ||
return [left,right]; | ||
}; | ||
/** | ||
@@ -336,169 +332,179 @@ * Draws a flowchart in the tag with id: id based on the graph definition in text. | ||
module.exports.draw = function (text, id) { | ||
sq.yy.clear(); | ||
sq.parse(text+'\n'); | ||
sq.yy.clear() | ||
sq.parse(text + '\n') | ||
exports.bounds.init(); | ||
var diagram = d3.select('#'+id); | ||
exports.bounds.init() | ||
var diagram = d3.select('#' + id) | ||
var startx; | ||
var stopx; | ||
var forceWidth; | ||
var startx | ||
var stopx | ||
var forceWidth | ||
// Fetch data from the parsing | ||
var actors = sq.yy.getActors(); | ||
var actorKeys = sq.yy.getActorKeys(); | ||
var messages = sq.yy.getMessages(); | ||
var title = sq.yy.getTitle(); | ||
module.exports.drawActors(diagram, actors, actorKeys, 0); | ||
// Fetch data from the parsing | ||
var actors = sq.yy.getActors() | ||
var actorKeys = sq.yy.getActorKeys() | ||
var messages = sq.yy.getMessages() | ||
var title = sq.yy.getTitle() | ||
module.exports.drawActors(diagram, actors, actorKeys, 0) | ||
// The arrow head definition is attached to the svg once | ||
svgDraw.insertArrowHead(diagram); | ||
svgDraw.insertArrowCrossHead(diagram); | ||
// The arrow head definition is attached to the svg once | ||
svgDraw.insertArrowHead(diagram) | ||
svgDraw.insertArrowCrossHead(diagram) | ||
function activeEnd(msg, verticalPos) { | ||
var activationData = exports.bounds.endActivation(msg); | ||
if(activationData.starty + 18 > verticalPos) { | ||
activationData.starty = verticalPos - 6; | ||
verticalPos += 12; | ||
} | ||
svgDraw.drawActivation(diagram, activationData, verticalPos, conf); | ||
exports.bounds.insert(activationData.startx, verticalPos -10, activationData.stopx, verticalPos); | ||
function activeEnd (msg, verticalPos) { | ||
var activationData = exports.bounds.endActivation(msg) | ||
if (activationData.starty + 18 > verticalPos) { | ||
activationData.starty = verticalPos - 6 | ||
verticalPos += 12 | ||
} | ||
svgDraw.drawActivation(diagram, activationData, verticalPos, conf) | ||
var lastMsg; | ||
exports.bounds.insert(activationData.startx, verticalPos - 10, activationData.stopx, verticalPos) | ||
} | ||
// Draw the messages/signals | ||
messages.forEach(function(msg){ | ||
var loopData; | ||
// var lastMsg | ||
switch(msg.type){ | ||
case sq.yy.LINETYPE.NOTE: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin); | ||
// Draw the messages/signals | ||
messages.forEach(function (msg) { | ||
var loopData | ||
startx = actors[msg.from].x; | ||
stopx = actors[msg.to].x; | ||
switch (msg.type) { | ||
case sq.yy.LINETYPE.NOTE: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
if(msg.placement === sq.yy.PLACEMENT.RIGHTOF){ | ||
drawNote(diagram, startx + (conf.width + conf.actorMargin)/2, exports.bounds.getVerticalPos(), msg); | ||
startx = actors[msg.from].x | ||
stopx = actors[msg.to].x | ||
}else if(msg.placement === sq.yy.PLACEMENT.LEFTOF){ | ||
drawNote(diagram, startx - (conf.width + conf.actorMargin)/2, exports.bounds.getVerticalPos(), msg); | ||
}else if(msg.to === msg.from) { | ||
// Single-actor over | ||
drawNote(diagram, startx, exports.bounds.getVerticalPos(), msg); | ||
}else{ | ||
// Multi-actor over | ||
forceWidth = Math.abs(startx - stopx) + conf.actorMargin; | ||
drawNote(diagram, (startx + stopx + conf.width - forceWidth)/2, exports.bounds.getVerticalPos(), msg, | ||
forceWidth); | ||
} | ||
break; | ||
case sq.yy.LINETYPE.ACTIVE_START: | ||
exports.bounds.newActivation(msg, diagram); | ||
break; | ||
case sq.yy.LINETYPE.ACTIVE_END: | ||
activeEnd(msg, exports.bounds.getVerticalPos()); | ||
break; | ||
case sq.yy.LINETYPE.LOOP_START: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin); | ||
exports.bounds.newLoop(msg.message); | ||
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin); | ||
break; | ||
case sq.yy.LINETYPE.LOOP_END: | ||
loopData = exports.bounds.endLoop(); | ||
if (msg.placement === sq.yy.PLACEMENT.RIGHTOF) { | ||
drawNote(diagram, startx + (conf.width + conf.actorMargin) / 2, exports.bounds.getVerticalPos(), msg) | ||
} else if (msg.placement === sq.yy.PLACEMENT.LEFTOF) { | ||
drawNote(diagram, startx - (conf.width + conf.actorMargin) / 2, exports.bounds.getVerticalPos(), msg) | ||
} else if (msg.to === msg.from) { | ||
// Single-actor over | ||
drawNote(diagram, startx, exports.bounds.getVerticalPos(), msg) | ||
} else { | ||
// Multi-actor over | ||
forceWidth = Math.abs(startx - stopx) + conf.actorMargin | ||
drawNote(diagram, (startx + stopx + conf.width - forceWidth) / 2, exports.bounds.getVerticalPos(), msg, | ||
forceWidth) | ||
} | ||
break | ||
case sq.yy.LINETYPE.ACTIVE_START: | ||
exports.bounds.newActivation(msg, diagram) | ||
break | ||
case sq.yy.LINETYPE.ACTIVE_END: | ||
activeEnd(msg, exports.bounds.getVerticalPos()) | ||
break | ||
case sq.yy.LINETYPE.LOOP_START: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
exports.bounds.newLoop(msg.message) | ||
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin) | ||
break | ||
case sq.yy.LINETYPE.LOOP_END: | ||
loopData = exports.bounds.endLoop() | ||
svgDraw.drawLoop(diagram, loopData,'loop', conf); | ||
exports.bounds.bumpVerticalPos(conf.boxMargin); | ||
break; | ||
case sq.yy.LINETYPE.OPT_START: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin); | ||
exports.bounds.newLoop(msg.message); | ||
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin); | ||
break; | ||
case sq.yy.LINETYPE.OPT_END: | ||
loopData = exports.bounds.endLoop(); | ||
svgDraw.drawLoop(diagram, loopData, 'loop', conf) | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
break | ||
case sq.yy.LINETYPE.OPT_START: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
exports.bounds.newLoop(msg.message) | ||
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin) | ||
break | ||
case sq.yy.LINETYPE.OPT_END: | ||
loopData = exports.bounds.endLoop() | ||
svgDraw.drawLoop(diagram, loopData, 'opt', conf); | ||
exports.bounds.bumpVerticalPos(conf.boxMargin); | ||
break; | ||
case sq.yy.LINETYPE.ALT_START: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin); | ||
exports.bounds.newLoop(msg.message); | ||
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin); | ||
break; | ||
case sq.yy.LINETYPE.ALT_ELSE: | ||
svgDraw.drawLoop(diagram, loopData, 'opt', conf) | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
break | ||
case sq.yy.LINETYPE.ALT_START: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
exports.bounds.newLoop(msg.message) | ||
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin) | ||
break | ||
case sq.yy.LINETYPE.ALT_ELSE: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
loopData = exports.bounds.addSectionToLoop(msg.message) | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
break | ||
case sq.yy.LINETYPE.ALT_END: | ||
loopData = exports.bounds.endLoop() | ||
//exports.drawLoop(diagram, loopData); | ||
exports.bounds.bumpVerticalPos(conf.boxMargin); | ||
loopData = exports.bounds.addElseToLoop(msg.message); | ||
exports.bounds.bumpVerticalPos(conf.boxMargin); | ||
break; | ||
case sq.yy.LINETYPE.ALT_END: | ||
loopData = exports.bounds.endLoop(); | ||
svgDraw.drawLoop(diagram, loopData, 'alt', conf) | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
break | ||
case sq.yy.LINETYPE.PAR_START: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
exports.bounds.newLoop(msg.message) | ||
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin) | ||
break | ||
case sq.yy.LINETYPE.PAR_AND: | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
loopData = exports.bounds.addSectionToLoop(msg.message) | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
break | ||
case sq.yy.LINETYPE.PAR_END: | ||
loopData = exports.bounds.endLoop() | ||
svgDraw.drawLoop(diagram, loopData, 'par', conf) | ||
exports.bounds.bumpVerticalPos(conf.boxMargin) | ||
break | ||
default: | ||
try { | ||
// lastMsg = msg | ||
exports.bounds.bumpVerticalPos(conf.messageMargin) | ||
var fromBounds = actorFlowVerticaBounds(msg.from) | ||
var toBounds = actorFlowVerticaBounds(msg.to) | ||
var fromIdx = fromBounds[0] <= toBounds[0] ? 1 : 0 | ||
var toIdx = fromBounds[0] < toBounds[0] ? 0 : 1 | ||
startx = fromBounds[fromIdx] | ||
stopx = toBounds[toIdx] | ||
svgDraw.drawLoop(diagram, loopData,'alt', conf); | ||
exports.bounds.bumpVerticalPos(conf.boxMargin); | ||
break; | ||
default: | ||
try { | ||
lastMsg = msg; | ||
exports.bounds.bumpVerticalPos(conf.messageMargin); | ||
var fromBounds = actorFlowVerticaBounds(msg.from); | ||
var toBounds = actorFlowVerticaBounds(msg.to); | ||
var fromIdx = fromBounds[0] <= toBounds[0]?1:0; | ||
var toIdx = fromBounds[0] < toBounds[0]?0:1; | ||
startx = fromBounds[fromIdx]; | ||
stopx = toBounds[toIdx]; | ||
var verticalPos = exports.bounds.getVerticalPos(); | ||
drawMessage(diagram, startx, stopx, verticalPos, msg); | ||
var allBounds = fromBounds.concat(toBounds); | ||
exports.bounds.insert(Math.min.apply(null, allBounds), verticalPos, Math.max.apply(null, allBounds), verticalPos); | ||
} catch (e) { | ||
console.error('error while drawing message', e); | ||
} | ||
var verticalPos = exports.bounds.getVerticalPos() | ||
drawMessage(diagram, startx, stopx, verticalPos, msg) | ||
var allBounds = fromBounds.concat(toBounds) | ||
exports.bounds.insert(Math.min.apply(null, allBounds), verticalPos, Math.max.apply(null, allBounds), verticalPos) | ||
} catch (e) { | ||
console.error('error while drawing message', e) | ||
} | ||
}); | ||
if(conf.mirrorActors){ | ||
// Draw actors below diagram | ||
exports.bounds.bumpVerticalPos(conf.boxMargin*2); | ||
module.exports.drawActors(diagram, actors, actorKeys, exports.bounds.getVerticalPos()); | ||
} | ||
}) | ||
var box = exports.bounds.getBounds(); | ||
if (conf.mirrorActors) { | ||
// Draw actors below diagram | ||
exports.bounds.bumpVerticalPos(conf.boxMargin * 2) | ||
module.exports.drawActors(diagram, actors, actorKeys, exports.bounds.getVerticalPos()) | ||
} | ||
// Adjust line height of actor lines now that the height of the diagram is known | ||
log.debug('For line height fix Querying: #' + id + ' .actor-line'); | ||
var actorLines = d3.selectAll('#' + id + ' .actor-line'); | ||
actorLines.attr('y2',box.stopy); | ||
var box = exports.bounds.getBounds() | ||
// Adjust line height of actor lines now that the height of the diagram is known | ||
log.debug('For line height fix Querying: #' + id + ' .actor-line') | ||
var actorLines = d3.selectAll('#' + id + ' .actor-line') | ||
actorLines.attr('y2', box.stopy) | ||
var height = box.stopy - box.starty + 2*conf.diagramMarginY; | ||
var height = box.stopy - box.starty + 2 * conf.diagramMarginY | ||
if(conf.mirrorActors){ | ||
height = height - conf.boxMargin + conf.bottomMarginAdj; | ||
} | ||
if (conf.mirrorActors) { | ||
height = height - conf.boxMargin + conf.bottomMarginAdj | ||
} | ||
var width = (box.stopx - box.startx) + (2 * conf.diagramMarginX); | ||
var width = (box.stopx - box.startx) + (2 * conf.diagramMarginX) | ||
if(title) { | ||
diagram.append('text') | ||
.text(title) | ||
.attr('x', ( ( box.stopx-box.startx) / 2 ) - ( 2 * conf.diagramMarginX ) ) | ||
.attr('y', -25); | ||
} | ||
if (title) { | ||
diagram.append('text') | ||
.text(title) | ||
.attr('x', ((box.stopx - box.startx) / 2) - (2 * conf.diagramMarginX)) | ||
.attr('y', -25) | ||
} | ||
if(conf.useMaxWidth) { | ||
diagram.attr('height', '100%'); | ||
diagram.attr('width', '100%'); | ||
diagram.attr('style', 'max-width:' + (width) + 'px;'); | ||
}else{ | ||
diagram.attr('height',height); | ||
diagram.attr('width', width ); | ||
} | ||
var extraVertForTitle = title ? 40 : 0; | ||
diagram.attr('viewBox', (box.startx - conf.diagramMarginX) + ' -' + (conf.diagramMarginY + extraVertForTitle) + ' ' + width + ' ' + (height + extraVertForTitle)); | ||
}; | ||
if (conf.useMaxWidth) { | ||
diagram.attr('height', '100%') | ||
diagram.attr('width', '100%') | ||
diagram.attr('style', 'max-width:' + (width) + 'px;') | ||
} else { | ||
diagram.attr('height', height) | ||
diagram.attr('width', width) | ||
} | ||
var extraVertForTitle = title ? 40 : 0 | ||
diagram.attr('viewBox', (box.startx - conf.diagramMarginX) + ' -' + (conf.diagramMarginY + extraVertForTitle) + ' ' + width + ' ' + (height + extraVertForTitle)) | ||
} |
/** | ||
* Created by knut on 14-12-20. | ||
*/ | ||
//var log = require('../../logger').create(); | ||
exports.drawRect = function(elem , rectData){ | ||
var rectElem = elem.append('rect'); | ||
rectElem.attr('x', rectData.x); | ||
rectElem.attr('y', rectData.y); | ||
rectElem.attr('fill', rectData.fill); | ||
rectElem.attr('stroke', rectData.stroke); | ||
rectElem.attr('width', rectData.width); | ||
rectElem.attr('height', rectData.height); | ||
rectElem.attr('rx', rectData.rx); | ||
rectElem.attr('ry', rectData.ry); | ||
exports.drawRect = function (elem, rectData) { | ||
var rectElem = elem.append('rect') | ||
rectElem.attr('x', rectData.x) | ||
rectElem.attr('y', rectData.y) | ||
rectElem.attr('fill', rectData.fill) | ||
rectElem.attr('stroke', rectData.stroke) | ||
rectElem.attr('width', rectData.width) | ||
rectElem.attr('height', rectData.height) | ||
rectElem.attr('rx', rectData.rx) | ||
rectElem.attr('ry', rectData.ry) | ||
if(typeof rectData.class !== 'undefined'){ | ||
rectElem.attr('class', rectData.class); | ||
} | ||
if (typeof rectData.class !== 'undefined') { | ||
rectElem.attr('class', rectData.class) | ||
} | ||
return rectElem; | ||
}; | ||
return rectElem | ||
} | ||
exports.drawText = function(elem, textData, width) { | ||
// Remove and ignore br:s | ||
var nText = textData.text.replace(/<br\/?>/ig,' '); | ||
exports.drawText = function (elem, textData, width) { | ||
// Remove and ignore br:s | ||
var nText = textData.text.replace(/<br\/?>/ig, ' ') | ||
var textElem = elem.append('text'); | ||
textElem.attr('x', textData.x); | ||
textElem.attr('y', textData.y); | ||
textElem.style('text-anchor', textData.anchor); | ||
textElem.attr('fill', textData.fill); | ||
if (typeof textData.class !== 'undefined') { | ||
textElem.attr('class', textData.class); | ||
} | ||
/* textData.text.split(/<br\/?>/ig).forEach(function(rowText){ | ||
var span = textElem.append('tspan'); | ||
span.attr('x', textData.x +textData.textMargin); | ||
span.attr('dy', textData.dy); | ||
span.text(rowText); | ||
});*/ | ||
var textElem = elem.append('text') | ||
textElem.attr('x', textData.x) | ||
textElem.attr('y', textData.y) | ||
textElem.style('text-anchor', textData.anchor) | ||
textElem.attr('fill', textData.fill) | ||
if (typeof textData.class !== 'undefined') { | ||
textElem.attr('class', textData.class) | ||
} | ||
var span = textElem.append('tspan') | ||
span.attr('x', textData.x + textData.textMargin * 2) | ||
span.attr('fill', textData.fill) | ||
span.text(nText) | ||
if (typeof textElem.textwrap !== 'undefined') { | ||
textElem.textwrap({ | ||
x: textData.x, // bounding box is 300 pixels from the left | ||
y: textData.y, // bounding box is 400 pixels from the top | ||
width: width, // bounding box is 500 pixels across | ||
height: 1800 // bounding box is 600 pixels tall | ||
}, textData.textMargin) | ||
} | ||
var span = textElem.append('tspan'); | ||
//span.attr('x', textData.x); | ||
span.attr('x', textData.x+textData.textMargin*2); | ||
//span.attr('dy', textData.dy); | ||
span.text(nText); | ||
if(typeof textElem.textwrap !== 'undefined'){ | ||
return textElem | ||
} | ||
textElem.textwrap({ | ||
x: textData.x, // bounding box is 300 pixels from the left | ||
y: textData.y, // bounding box is 400 pixels from the top | ||
width: width, // bounding box is 500 pixels across | ||
height: 1800 // bounding box is 600 pixels tall | ||
}, textData.textMargin); | ||
} | ||
exports.drawLabel = function (elem, txtObject) { | ||
function genPoints (x, y, width, height, cut) { | ||
return x + ',' + y + ' ' + | ||
(x + width) + ',' + y + ' ' + | ||
(x + width) + ',' + (y + height - cut) + ' ' + | ||
(x + width - cut * 1.2) + ',' + (y + height) + ' ' + | ||
(x) + ',' + (y + height) | ||
} | ||
var polygon = elem.append('polygon') | ||
polygon.attr('points', genPoints(txtObject.x, txtObject.y, 50, 20, 7)) | ||
polygon.attr('class', 'labelBox') | ||
return textElem; | ||
}; | ||
exports.drawLabel = function(elem , txtObject){ | ||
var rectData = exports.getNoteRect(); | ||
rectData.x = txtObject.x; | ||
rectData.y = txtObject.y; | ||
rectData.width = 50; | ||
rectData.height = 20; | ||
rectData.fill = '#526e52'; | ||
rectData.stroke = 'none'; | ||
rectData.class = 'labelBox'; | ||
//rectData.color = 'white'; | ||
exports.drawRect(elem, rectData); | ||
txtObject.y = txtObject.y + txtObject.labelMargin; | ||
txtObject.x = txtObject.x + 0.5*txtObject.labelMargin; | ||
txtObject.fill = 'white'; | ||
exports.drawText(elem, txtObject); | ||
//return textElem; | ||
}; | ||
var actorCnt = -1; | ||
txtObject.y = txtObject.y + txtObject.labelMargin | ||
txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin | ||
exports.drawText(elem, txtObject) | ||
} | ||
var actorCnt = -1 | ||
/** | ||
@@ -88,36 +74,36 @@ * Draws an actor in the diagram with the attaced line | ||
*/ | ||
exports.drawActor = function(elem, left, verticalPos, description,conf){ | ||
var center = left + (conf.width/2); | ||
var g = elem.append('g'); | ||
if(verticalPos === 0) { | ||
actorCnt++; | ||
g.append('line') | ||
.attr('id', 'actor'+actorCnt) | ||
.attr('x1', center) | ||
.attr('y1', 5) | ||
.attr('x2', center) | ||
.attr('y2', 2000) | ||
.attr('class', 'actor-line') | ||
.attr('stroke-width', '0.5px') | ||
.attr('stroke', '#999'); | ||
} | ||
exports.drawActor = function (elem, left, verticalPos, description, conf) { | ||
var center = left + (conf.width / 2) | ||
var g = elem.append('g') | ||
if (verticalPos === 0) { | ||
actorCnt++ | ||
g.append('line') | ||
.attr('id', 'actor' + actorCnt) | ||
.attr('x1', center) | ||
.attr('y1', 5) | ||
.attr('x2', center) | ||
.attr('y2', 2000) | ||
.attr('class', 'actor-line') | ||
.attr('stroke-width', '0.5px') | ||
.attr('stroke', '#999') | ||
} | ||
var rect = exports.getNoteRect(); | ||
rect.x = left; | ||
rect.y = verticalPos; | ||
rect.fill = '#eaeaea'; | ||
rect.width = conf.width; | ||
rect.height = conf.height; | ||
rect.class = 'actor'; | ||
rect.rx = 3; | ||
rect.ry = 3; | ||
exports.drawRect(g, rect); | ||
var rect = exports.getNoteRect() | ||
rect.x = left | ||
rect.y = verticalPos | ||
rect.fill = '#eaeaea' | ||
rect.width = conf.width | ||
rect.height = conf.height | ||
rect.class = 'actor' | ||
rect.rx = 3 | ||
rect.ry = 3 | ||
exports.drawRect(g, rect) | ||
_drawTextCandidateFunc(conf)(description, g, | ||
rect.x, rect.y, rect.width, rect.height, {'class':'actor'}); | ||
}; | ||
_drawTextCandidateFunc(conf)(description, g, | ||
rect.x, rect.y, rect.width, rect.height, { 'class': 'actor' }) | ||
} | ||
exports.anchorElement = function(elem) { | ||
return elem.append('g'); | ||
}; | ||
exports.anchorElement = function (elem) { | ||
return elem.append('g') | ||
} | ||
/** | ||
@@ -129,12 +115,12 @@ * Draws an actor in the diagram with the attaced line | ||
*/ | ||
exports.drawActivation = function(elem,bounds,verticalPos){ | ||
var rect = exports.getNoteRect(); | ||
var g = bounds.anchored; | ||
rect.x = bounds.startx; | ||
rect.y = bounds.starty; | ||
rect.fill = '#f4f4f4'; | ||
rect.width = bounds.stopx - bounds.startx; | ||
rect.height = verticalPos - bounds.starty; | ||
exports.drawRect(g, rect); | ||
}; | ||
exports.drawActivation = function (elem, bounds, verticalPos) { | ||
var rect = exports.getNoteRect() | ||
var g = bounds.anchored | ||
rect.x = bounds.startx | ||
rect.y = bounds.starty | ||
rect.fill = '#f4f4f4' | ||
rect.width = bounds.stopx - bounds.startx | ||
rect.height = verticalPos - bounds.starty | ||
exports.drawRect(g, rect) | ||
} | ||
@@ -147,47 +133,50 @@ /** | ||
*/ | ||
exports.drawLoop = function(elem,bounds,labelText, conf){ | ||
var g = elem.append('g'); | ||
var drawLoopLine = function(startx,starty,stopx,stopy){ | ||
g.append('line') | ||
.attr('x1', startx) | ||
.attr('y1', starty) | ||
.attr('x2', stopx ) | ||
.attr('y2', stopy ) | ||
.attr('stroke-width', 2) | ||
.attr('stroke', '#526e52') | ||
.attr('class','loopLine'); | ||
}; | ||
drawLoopLine(bounds.startx, bounds.starty, bounds.stopx , bounds.starty); | ||
drawLoopLine(bounds.stopx , bounds.starty, bounds.stopx , bounds.stopy ); | ||
drawLoopLine(bounds.startx, bounds.stopy , bounds.stopx , bounds.stopy ); | ||
drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy ); | ||
if(typeof bounds.elsey !== 'undefined'){ | ||
drawLoopLine(bounds.startx, bounds.elsey, bounds.stopx, bounds.elsey ); | ||
} | ||
exports.drawLoop = function (elem, bounds, labelText, conf) { | ||
var g = elem.append('g') | ||
var drawLoopLine = function (startx, starty, stopx, stopy) { | ||
return g.append('line') | ||
.attr('x1', startx) | ||
.attr('y1', starty) | ||
.attr('x2', stopx) | ||
.attr('y2', stopy) | ||
.attr('class', 'loopLine') | ||
} | ||
drawLoopLine(bounds.startx, bounds.starty, bounds.stopx, bounds.starty) | ||
drawLoopLine(bounds.stopx, bounds.starty, bounds.stopx, bounds.stopy) | ||
drawLoopLine(bounds.startx, bounds.stopy, bounds.stopx, bounds.stopy) | ||
drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy) | ||
if (typeof bounds.sections !== 'undefined') { | ||
bounds.sections.forEach(function (item) { | ||
drawLoopLine(bounds.startx, item, bounds.stopx, item).style('stroke-dasharray', '3, 3') | ||
}) | ||
} | ||
var txt = exports.getTextObj(); | ||
txt.text = labelText; | ||
txt.x = bounds.startx; | ||
txt.y = bounds.starty; | ||
txt.labelMargin = 1.5 * 10; // This is the small box that says "loop" | ||
txt.class = 'labelText'; // Its size & position are fixed. | ||
txt.fill = 'white'; | ||
var txt = exports.getTextObj() | ||
txt.text = labelText | ||
txt.x = bounds.startx | ||
txt.y = bounds.starty | ||
txt.labelMargin = 1.5 * 10 // This is the small box that says "loop" | ||
txt.class = 'labelText' // Its size & position are fixed. | ||
exports.drawLabel(g,txt); | ||
exports.drawLabel(g, txt) | ||
txt = exports.getTextObj(); | ||
txt.text = '[ ' + bounds.title + ' ]'; | ||
txt.x = bounds.startx + (bounds.stopx - bounds.startx)/2; | ||
txt.y = bounds.starty + 1.5 * conf.boxMargin; | ||
txt.anchor = 'middle'; | ||
txt.class = 'loopText'; | ||
txt = exports.getTextObj() | ||
txt.text = '[ ' + bounds.title + ' ]' | ||
txt.x = bounds.startx + (bounds.stopx - bounds.startx) / 2 | ||
txt.y = bounds.starty + 1.5 * conf.boxMargin | ||
txt.anchor = 'middle' | ||
txt.class = 'loopText' | ||
exports.drawText(g,txt); | ||
exports.drawText(g, txt) | ||
if(typeof bounds.elseText !== 'undefined') { | ||
txt.text = '[ ' + bounds.elseText + ' ]'; | ||
txt.y = bounds.elsey + 1.5 * conf.boxMargin; | ||
exports.drawText(g, txt); | ||
} | ||
}; | ||
if (typeof bounds.sectionTitles !== 'undefined') { | ||
bounds.sectionTitles.forEach(function (item, idx) { | ||
if (item !== '') { | ||
txt.text = '[ ' + item + ' ]' | ||
txt.y = bounds.sections[idx] + 1.5 * conf.boxMargin | ||
exports.drawText(g, txt) | ||
} | ||
}) | ||
} | ||
} | ||
@@ -197,139 +186,138 @@ /** | ||
*/ | ||
exports.insertArrowHead = function(elem){ | ||
elem.append('defs').append('marker') | ||
.attr('id', 'arrowhead') | ||
.attr('refX', 5) | ||
.attr('refY', 2) | ||
.attr('markerWidth', 6) | ||
.attr('markerHeight', 4) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 0,0 V 4 L6,2 Z'); //this is actual shape for arrowhead | ||
}; | ||
exports.insertArrowHead = function (elem) { | ||
elem.append('defs').append('marker') | ||
.attr('id', 'arrowhead') | ||
.attr('refX', 5) | ||
.attr('refY', 2) | ||
.attr('markerWidth', 6) | ||
.attr('markerHeight', 4) | ||
.attr('orient', 'auto') | ||
.append('path') | ||
.attr('d', 'M 0,0 V 4 L6,2 Z') // this is actual shape for arrowhead | ||
} | ||
/** | ||
* Setup arrow head and define the marker. The result is appended to the svg. | ||
*/ | ||
exports.insertArrowCrossHead = function(elem){ | ||
var defs = elem.append('defs'); | ||
var marker = defs.append('marker') | ||
.attr('id', 'crosshead') | ||
.attr('markerWidth', 15) | ||
.attr('markerHeight', 8) | ||
.attr('orient', 'auto') | ||
.attr('refX', 16) | ||
.attr('refY', 4); | ||
exports.insertArrowCrossHead = function (elem) { | ||
var defs = elem.append('defs') | ||
var marker = defs.append('marker') | ||
.attr('id', 'crosshead') | ||
.attr('markerWidth', 15) | ||
.attr('markerHeight', 8) | ||
.attr('orient', 'auto') | ||
.attr('refX', 16) | ||
.attr('refY', 4) | ||
// The arrow | ||
marker.append('path') | ||
.attr('fill','black') | ||
.attr('stroke','#000000') | ||
.style('stroke-dasharray', ('0, 0')) | ||
.attr('stroke-width','1px') | ||
.attr('d', 'M 9,2 V 6 L16,4 Z'); | ||
// The arrow | ||
marker.append('path') | ||
.attr('fill', 'black') | ||
.attr('stroke', '#000000') | ||
.style('stroke-dasharray', ('0, 0')) | ||
.attr('stroke-width', '1px') | ||
.attr('d', 'M 9,2 V 6 L16,4 Z') | ||
// The cross | ||
marker.append('path') | ||
.attr('fill','none') | ||
.attr('stroke','#000000') | ||
.style('stroke-dasharray', ('0, 0')) | ||
.attr('stroke-width','1px') | ||
.attr('d', 'M 0,1 L 6,7 M 6,1 L 0,7') | ||
; //this is actual shape for arrowhead | ||
// The cross | ||
marker.append('path') | ||
.attr('fill', 'none') | ||
.attr('stroke', '#000000') | ||
.style('stroke-dasharray', ('0, 0')) | ||
.attr('stroke-width', '1px') | ||
.attr('d', 'M 0,1 L 6,7 M 6,1 L 0,7') | ||
// this is actual shape for arrowhead | ||
} | ||
}; | ||
exports.getTextObj = function () { | ||
var txt = { | ||
x: 0, | ||
y: 0, | ||
'fill': 'black', | ||
'text-anchor': 'start', | ||
style: '#666', | ||
width: 100, | ||
height: 100, | ||
textMargin: 0, | ||
rx: 0, | ||
ry: 0 | ||
} | ||
return txt | ||
} | ||
exports.getTextObj = function(){ | ||
var txt = { | ||
x: 0, | ||
y: 0, | ||
'fill':'black', | ||
'text-anchor': 'start', | ||
style: '#666', | ||
width: 100, | ||
height: 100, | ||
textMargin:0, | ||
rx: 0, | ||
ry: 0 | ||
}; | ||
return txt; | ||
}; | ||
exports.getNoteRect = function () { | ||
var rect = { | ||
x: 0, | ||
y: 0, | ||
fill: '#EDF2AE', | ||
stroke: '#666', | ||
width: 100, | ||
anchor: 'start', | ||
height: 100, | ||
rx: 0, | ||
ry: 0 | ||
} | ||
return rect | ||
} | ||
exports.getNoteRect = function(){ | ||
var rect = { | ||
x : 0, | ||
y : 0, | ||
fill : '#EDF2AE', | ||
stroke : '#666', | ||
width : 100, | ||
anchor : 'start', | ||
height : 100, | ||
rx : 0, | ||
ry : 0 | ||
}; | ||
return rect; | ||
}; | ||
var _drawTextCandidateFunc = (function () { | ||
function byText (content, g, x, y, width, height, textAttrs) { | ||
var text = g.append('text') | ||
.attr('x', x + width / 2).attr('y', y + height / 2 + 5) | ||
.style('text-anchor', 'middle') | ||
.text(content) | ||
_setTextAttrs(text, textAttrs) | ||
} | ||
var _drawTextCandidateFunc = (function() { | ||
function byText(content, g, x, y, width, height, textAttrs) { | ||
var text = g.append('text') | ||
.attr('x', x + width / 2).attr('y', y + height / 2 + 5) | ||
.style('text-anchor', 'middle') | ||
.text(content); | ||
_setTextAttrs(text, textAttrs); | ||
} | ||
function byTspan (content, g, x, y, width, height, textAttrs) { | ||
var text = g.append('text') | ||
.attr('x', x + width / 2).attr('y', y) | ||
.style('text-anchor', 'middle') | ||
text.append('tspan') | ||
.attr('x', x + width / 2).attr('dy', '0') | ||
.text(content) | ||
function byTspan(content, g, x, y, width, height, textAttrs) { | ||
var text = g.append('text') | ||
.attr('x', x + width / 2).attr('y', y) | ||
.style('text-anchor', 'middle'); | ||
text.append('tspan') | ||
.attr('x', x + width / 2).attr('dy', '0') | ||
.text(content); | ||
if(typeof(text.textwrap) !== 'undefined'){ | ||
text.textwrap({ //d3textwrap | ||
x: x + width / 2, y: y, width: width, height: height | ||
}, 0); | ||
//vertical aligment after d3textwrap expans tspan to multiple tspans | ||
var tspans = text.selectAll('tspan'); | ||
if (tspans.length > 0 && tspans[0].length > 0) { | ||
tspans = tspans[0]; | ||
//set y of <text> to the mid y of the first line | ||
text.attr('y', y + (height/2.0 - text[0][0].getBBox().height*(1 - 1.0/tspans.length)/2.0)) | ||
.attr("dominant-baseline", "central") | ||
.attr("alignment-baseline", "central"); | ||
} | ||
} | ||
_setTextAttrs(text, textAttrs); | ||
if (typeof (text.textwrap) !== 'undefined') { | ||
text.textwrap({ // d3textwrap | ||
x: x + width / 2, y: y, width: width, height: height | ||
}, 0) | ||
// vertical aligment after d3textwrap expans tspan to multiple tspans | ||
var tspans = text.selectAll('tspan') | ||
if (tspans.length > 0 && tspans[0].length > 0) { | ||
tspans = tspans[0] | ||
// set y of <text> to the mid y of the first line | ||
text.attr('y', y + (height / 2.0 - text[0][0].getBBox().height * (1 - 1.0 / tspans.length) / 2.0)) | ||
.attr('dominant-baseline', 'central') | ||
.attr('alignment-baseline', 'central') | ||
} | ||
} | ||
_setTextAttrs(text, textAttrs) | ||
} | ||
function byFo(content, g, x, y, width, height, textAttrs) { | ||
var s = g.append('switch'); | ||
var f = s.append("foreignObject") | ||
.attr('x', x).attr('y', y) | ||
.attr('width', width).attr('height', height); | ||
function byFo (content, g, x, y, width, height, textAttrs) { | ||
var s = g.append('switch') | ||
var f = s.append('foreignObject') | ||
.attr('x', x).attr('y', y) | ||
.attr('width', width).attr('height', height) | ||
var text = f.append('div').style('display', 'table') | ||
.style('height', '100%').style('width', '100%'); | ||
var text = f.append('div').style('display', 'table') | ||
.style('height', '100%').style('width', '100%') | ||
text.append('div').style('display', 'table-cell') | ||
.style('text-align', 'center').style('vertical-align', 'middle') | ||
.text(content); | ||
text.append('div').style('display', 'table-cell') | ||
.style('text-align', 'center').style('vertical-align', 'middle') | ||
.text(content) | ||
byTspan(content, s, x, y, width, height, textAttrs); | ||
_setTextAttrs(text, textAttrs); | ||
} | ||
byTspan(content, s, x, y, width, height, textAttrs) | ||
_setTextAttrs(text, textAttrs) | ||
} | ||
function _setTextAttrs(toText, fromTextAttrsDict) { | ||
for (var key in fromTextAttrsDict) { | ||
if (fromTextAttrsDict.hasOwnProperty(key)) { | ||
toText.attr(key, fromTextAttrsDict[key]); | ||
} | ||
function _setTextAttrs (toText, fromTextAttrsDict) { | ||
for (var key in fromTextAttrsDict) { | ||
if (fromTextAttrsDict.hasOwnProperty(key)) { | ||
toText.attr(key, fromTextAttrsDict[key]) | ||
} | ||
} | ||
} | ||
return function(conf) { | ||
return conf.textPlacement==='fo' ? byFo : ( | ||
conf.textPlacement==='old' ? byText: byTspan); | ||
}; | ||
})(); | ||
return function (conf) { | ||
return conf.textPlacement === 'fo' ? byFo : ( | ||
conf.textPlacement === 'old' ? byText : byTspan) | ||
} | ||
})() |
function decodeHTMLEntities (str) { | ||
if(str && typeof str === 'string') { | ||
// strip script/html tags | ||
var element = document.querySelector('.editor'); | ||
str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi, ''); | ||
str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, ''); | ||
element.innerHTML = str; | ||
str = element.textContent; | ||
element.textContent = ''; | ||
} | ||
if (str && typeof str === 'string') { | ||
// strip script/html tags | ||
var element = document.querySelector('.editor') | ||
return str; | ||
str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi, '') | ||
str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, '') | ||
element.innerHTML = str | ||
str = element.textContent | ||
element.textContent = '' | ||
} | ||
return str | ||
} | ||
var mermaidEditor = { | ||
$ : document.querySelector, | ||
textField : '', | ||
submit : '', | ||
graph : '', | ||
var mermaidEditor = { | ||
$: document.querySelector, | ||
textField: '', | ||
submit: '', | ||
graph: '', | ||
init: function () { | ||
init: function () { | ||
document.querySelector('.button').addEventListener('click', function () { | ||
mermaidEditor.update() | ||
}) | ||
}, | ||
document.querySelector('.button').addEventListener('click', function () { | ||
mermaidEditor.update(); | ||
}.bind(this)); | ||
}, | ||
update: function () { | ||
var txt = document.querySelector('.editor').value; | ||
txt = txt.replace(/>/g,'>'); | ||
txt = txt.replace(/</g,'<'); | ||
txt = decodeHTMLEntities(txt).trim(); | ||
update: function () { | ||
var txt = document.querySelector('.editor').value | ||
txt = txt.replace(/>/g, '>') | ||
txt = txt.replace(/</g, '<') | ||
txt = decodeHTMLEntities(txt).trim() | ||
document.querySelector('.mermaid').innerHTML = txt; | ||
global.mermaid.init(); | ||
document.querySelector('.editor').value = txt; | ||
} | ||
}; | ||
document.querySelector('.mermaid').innerHTML = txt | ||
global.mermaid.init() | ||
document.querySelector('.editor').value = txt | ||
} | ||
} | ||
document.addEventListener('DOMContentLoaded', function () { | ||
mermaidEditor.init() | ||
}, false) | ||
mermaidEditor.init(); | ||
}, false); | ||
exports = mermaidEditor; | ||
exports = mermaidEditor |
@@ -13,84 +13,73 @@ /** | ||
const LEVELS = { | ||
debug: 1, | ||
info: 2, | ||
warn: 3, | ||
error: 4, | ||
fatal: 5, | ||
default: 5 | ||
}; | ||
var defaultLevel = LEVELS.error; | ||
exports.setLogLevel = function (level) { | ||
defaultLevel = level; | ||
}; | ||
function formatTime(timestamp) { | ||
var hh = timestamp.getUTCHours(); | ||
var mm = timestamp.getUTCMinutes(); | ||
var ss = timestamp.getSeconds(); | ||
var ms = timestamp.getMilliseconds(); | ||
// If you were building a timestamp instead of a duration, you would uncomment the following line to get 12-hour (not 24) time | ||
// if (hh > 12) {hh = hh % 12;} | ||
// These lines ensure you have two-digits | ||
if (hh < 10) { | ||
hh = '0' + hh; | ||
} | ||
if (mm < 10) { | ||
mm = '0' + mm; | ||
} | ||
if (ss < 10) { | ||
ss = '0' + ss; | ||
} | ||
if (ms < 100) { | ||
ms = '0' + ms; | ||
} | ||
if (ms < 10) { | ||
ms = '00' + ms; | ||
} | ||
// This formats your string to HH:MM:SS | ||
var t = hh + ':' + mm + ':' + ss + ' (' + ms + ')'; | ||
return t; | ||
function formatTime (timestamp) { | ||
var hh = timestamp.getUTCHours() | ||
var mm = timestamp.getUTCMinutes() | ||
var ss = timestamp.getSeconds() | ||
var ms = timestamp.getMilliseconds() | ||
// If you were building a timestamp instead of a duration, you would uncomment the following line to get 12-hour (not 24) time | ||
// if (hh > 12) {hh = hh % 12;} | ||
// These lines ensure you have two-digits | ||
if (hh < 10) { | ||
hh = '0' + hh | ||
} | ||
if (mm < 10) { | ||
mm = '0' + mm | ||
} | ||
if (ss < 10) { | ||
ss = '0' + ss | ||
} | ||
if (ms < 100) { | ||
ms = '0' + ms | ||
} | ||
if (ms < 10) { | ||
ms = '00' + ms | ||
} | ||
// This formats your string to HH:MM:SS | ||
var t = hh + ':' + mm + ':' + ss + ' (' + ms + ')' | ||
return t | ||
} | ||
function format(level) { | ||
const time = formatTime(new Date()); | ||
return '%c ' + time +' :%c' + level + ': '; | ||
function format (level) { | ||
const time = formatTime(new Date()) | ||
return '%c ' + time + ' :%c' + level + ': ' | ||
} | ||
function Log(level) { | ||
this.level = level; | ||
var debug = function () { } | ||
var info = function () { } | ||
var warn = function () { } | ||
var error = function () { } | ||
var fatal = function () { } | ||
this.log = function() { | ||
var args = Array.prototype.slice.call(arguments); | ||
var level = args.shift(); | ||
var logLevel = this.level; | ||
if(typeof logLevel === 'undefined'){ | ||
logLevel = defaultLevel; | ||
} | ||
if (logLevel <= level) { | ||
if (typeof console !== 'undefined') { //eslint-disable-line no-console | ||
if (typeof console.log !== 'undefined') { //eslint-disable-line no-console | ||
//return console.log('[' + formatTime(new Date()) + '] ' , str); //eslint-disable-line no-console | ||
args.unshift('[' + formatTime(new Date()) + '] '); | ||
console.log.apply(console, args.map(function(a){ | ||
if (typeof a === "object") { | ||
return a.toString() + JSON.stringify(a, null, 2); | ||
} | ||
return a; | ||
})); | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
* logLevel , decides the amount of logging to be used. | ||
* * debug: 1 | ||
* * info: 2 | ||
* * warn: 3 | ||
* * error: 4 | ||
* * fatal: 5 | ||
*/ | ||
exports.setLogLevel = function (level) { | ||
if (level < 6) { | ||
exports.Log.fatal = console.log.bind(console, format('FATAL'), 'color:grey;', 'color: red;') | ||
} | ||
if (level < 5) { | ||
exports.Log.error = console.log.bind(console, format('ERROR'), 'color:grey;', 'color: red;') | ||
} | ||
if (level < 4) { | ||
exports.Log.warn = console.log.bind(console, format('WARN'), 'color:grey;', 'color: orange;') | ||
} | ||
if (level < 3) { | ||
exports.Log.info = console.log.bind(console, format('INFO'), 'color:grey;', 'color: info;') | ||
} | ||
if (level < 2) { | ||
exports.Log.debug = console.log.bind(console, format('DEBUG'), 'color:grey;', 'color: green;') | ||
} | ||
} | ||
this.trace = window.console.debug.bind(window.console, format('TRACE', name), 'color:grey;', 'color: grey;'); | ||
this.debug = window.console.debug.bind(window.console, format('DEBUG', name), 'color:grey;', 'color: green;'); | ||
this.info = window.console.debug.bind(window.console, format('INFO', name), 'color:grey;', 'color: blue;'); | ||
this.warn = window.console.debug.bind(window.console, format('WARN', name), 'color:grey;', 'color: orange;'); | ||
this.error = window.console.debug.bind(window.console, format('ERROR', name), 'color:grey;', 'color: red;'); | ||
exports.Log = { | ||
debug: debug, | ||
info: info, | ||
warn: warn, | ||
error: error, | ||
fatal: fatal | ||
} | ||
exports.Log = Log; |
@@ -6,11 +6,10 @@ /** | ||
var Logger = require('./logger'); | ||
var Logger = require('./logger') | ||
var log = Logger.Log | ||
var mermaidAPI = require('./mermaidAPI') | ||
var nextId = 0 | ||
var log = new Logger.Log(); | ||
var mermaidAPI = require('./mermaidAPI'); | ||
var nextId = 0; | ||
var he = require('he') | ||
var he = require('he'); | ||
module.exports.mermaidAPI = mermaidAPI; | ||
module.exports.mermaidAPI = mermaidAPI | ||
/** | ||
@@ -38,92 +37,82 @@ * ## init | ||
var init = function () { | ||
var conf= mermaidAPI.getConfig(); | ||
log.debug('Starting rendering diagrams'); | ||
var nodes; | ||
if(arguments.length >= 2){ | ||
/*! sequence config was passed as #1 */ | ||
if(typeof arguments[0] !== 'undefined'){ | ||
global.mermaid.sequenceConfig = arguments[0]; | ||
} | ||
nodes = arguments[1]; | ||
var conf = mermaidAPI.getConfig() | ||
log.debug('Starting rendering diagrams') | ||
var nodes | ||
if (arguments.length >= 2) { | ||
/*! sequence config was passed as #1 */ | ||
if (typeof arguments[0] !== 'undefined') { | ||
global.mermaid.sequenceConfig = arguments[0] | ||
} | ||
else{ | ||
nodes = arguments[0]; | ||
} | ||
// if last argument is a function this is the callback function | ||
var callback; | ||
if(typeof arguments[arguments.length-1] === 'function'){ | ||
callback = arguments[arguments.length-1]; | ||
log.debug('Callback function found'); | ||
}else{ | ||
if(typeof conf.mermaid !== 'undefined'){ | ||
if(typeof conf.mermaid.callback === 'function'){ | ||
callback = conf.mermaid.callback; | ||
log.debug('Callback function found'); | ||
}else{ | ||
log.debug('No Callback function found'); | ||
} | ||
} | ||
nodes = arguments[1] | ||
} else { | ||
nodes = arguments[0] | ||
} | ||
// if last argument is a function this is the callback function | ||
var callback | ||
if (typeof arguments[arguments.length - 1] === 'function') { | ||
callback = arguments[arguments.length - 1] | ||
log.debug('Callback function found') | ||
} else { | ||
if (typeof conf.mermaid !== 'undefined') { | ||
if (typeof conf.mermaid.callback === 'function') { | ||
callback = conf.mermaid.callback | ||
log.debug('Callback function found') | ||
} else { | ||
log.debug('No Callback function found') | ||
} | ||
} | ||
nodes = nodes === undefined ? document.querySelectorAll('.mermaid') | ||
: typeof nodes === 'string' ? document.querySelectorAll(nodes) | ||
: nodes instanceof Node ? [nodes] | ||
: nodes; // Last case - sequence config was passed pick next | ||
} | ||
nodes = nodes === undefined ? document.querySelectorAll('.mermaid') | ||
: typeof nodes === 'string' ? document.querySelectorAll(nodes) | ||
: nodes instanceof window.Node ? [nodes] | ||
: nodes // Last case - sequence config was passed pick next | ||
var i; | ||
if (typeof global.mermaid_config !== 'undefined') { | ||
mermaidAPI.initialize(global.mermaid_config) | ||
} | ||
log.debug('Start On Load before: ' + global.mermaid.startOnLoad) | ||
if (typeof global.mermaid.startOnLoad !== 'undefined') { | ||
log.debug('Start On Load inner: ' + global.mermaid.startOnLoad) | ||
mermaidAPI.initialize({ startOnLoad: global.mermaid.startOnLoad }) | ||
} | ||
if(typeof mermaid_config !== 'undefined'){ | ||
mermaidAPI.initialize(global.mermaid_config); | ||
} | ||
log.debug('Start On Load before: '+global.mermaid.startOnLoad); | ||
if(typeof global.mermaid.startOnLoad !== 'undefined'){ | ||
log.debug('Start On Load inner: '+global.mermaid.startOnLoad); | ||
mermaidAPI.initialize({startOnLoad:global.mermaid.startOnLoad}); | ||
if (typeof global.mermaid.ganttConfig !== 'undefined') { | ||
mermaidAPI.initialize({ gantt: global.mermaid.ganttConfig }) | ||
} | ||
var txt | ||
var insertSvg = function (svgCode, bindFunctions) { | ||
element.innerHTML = svgCode | ||
if (typeof callback !== 'undefined') { | ||
callback(id) | ||
} | ||
bindFunctions(element) | ||
} | ||
for (var i = 0; i < nodes.length; i++) { | ||
var element = nodes[i] | ||
if(typeof global.mermaid.ganttConfig !== 'undefined'){ | ||
mermaidAPI.initialize({gantt:global.mermaid.ganttConfig}); | ||
/*! Check if previously processed */ | ||
if (!element.getAttribute('data-processed')) { | ||
element.setAttribute('data-processed', true) | ||
} else { | ||
continue | ||
} | ||
var txt; | ||
var insertSvg = function(svgCode, bindFunctions){ | ||
element.innerHTML = svgCode; | ||
if(typeof callback !== 'undefined'){ | ||
callback(id); | ||
} | ||
bindFunctions(element); | ||
}; | ||
var id = 'mermaidChart' + nextId++ | ||
for (i = 0; i < nodes.length; i++) { | ||
var element = nodes[i]; | ||
// Fetch the graph definition including tags | ||
txt = element.innerHTML | ||
/*! Check if previously processed */ | ||
if(!element.getAttribute('data-processed')) { | ||
element.setAttribute('data-processed', true); | ||
} else { | ||
continue; | ||
} | ||
// transforms the html to pure text | ||
txt = he.decode(txt).trim() | ||
var id = 'mermaidChart' + nextId++; | ||
mermaidAPI.render(id, txt, insertSvg, element) | ||
} | ||
} | ||
// Fetch the graph definition including tags | ||
txt = element.innerHTML; | ||
//console.warn('delivererd from the browser: '); | ||
//console.warn(txt); | ||
// transforms the html to pure text | ||
txt = he.decode(txt).trim(); | ||
//console.warn('he decode: '); | ||
//console.warn(txt); | ||
mermaidAPI.render(id,txt,insertSvg, element); | ||
} | ||
}; | ||
exports.init = init; | ||
exports.parse = mermaidAPI.parse; | ||
exports.init = init | ||
exports.parse = mermaidAPI.parse | ||
/** | ||
@@ -134,5 +123,5 @@ * ## version | ||
*/ | ||
exports.version = function(){ | ||
return 'v'+require('../package.json').version; | ||
}; | ||
exports.version = function () { | ||
return 'v' + require('../package.json').version | ||
} | ||
@@ -144,25 +133,23 @@ /** | ||
*/ | ||
exports.initialize = function(config){ | ||
log.debug('Initializing mermaid'); | ||
if(typeof config.mermaid !== 'undefined') { | ||
if (typeof config.mermaid.startOnLoad !== 'undefined') { | ||
global.mermaid.startOnLoad = config.mermaid.startOnLoad; | ||
} | ||
if (typeof config.mermaid.htmlLabels !== 'undefined') { | ||
global.mermaid.htmlLabels = config.mermaid.htmlLabels; | ||
} | ||
exports.initialize = function (config) { | ||
log.debug('Initializing mermaid') | ||
if (typeof config.mermaid !== 'undefined') { | ||
if (typeof config.mermaid.startOnLoad !== 'undefined') { | ||
global.mermaid.startOnLoad = config.mermaid.startOnLoad | ||
} | ||
mermaidAPI.initialize(config); | ||
}; | ||
if (typeof config.mermaid.htmlLabels !== 'undefined') { | ||
global.mermaid.htmlLabels = config.mermaid.htmlLabels | ||
} | ||
} | ||
mermaidAPI.initialize(config) | ||
} | ||
var equals = function (val, variable) { | ||
if (typeof variable === 'undefined') { | ||
return false | ||
} else { | ||
return (val === variable) | ||
} | ||
} | ||
var equals = function (val, variable){ | ||
if(typeof variable === 'undefined'){ | ||
return false; | ||
} | ||
else{ | ||
return (val === variable); | ||
} | ||
}; | ||
/** | ||
@@ -178,25 +165,25 @@ * Global mermaid object. Contains the functions: | ||
global.mermaid = { | ||
startOnLoad: true, | ||
htmlLabels: true, | ||
startOnLoad: true, | ||
htmlLabels: true, | ||
init: function() { | ||
init.apply(null, arguments); | ||
}, | ||
initialize: function(config) { | ||
exports.initialize(config); | ||
}, | ||
version: function() { | ||
return mermaidAPI.version(); | ||
}, | ||
parse: function(text) { | ||
return mermaidAPI.parse(text); | ||
}, | ||
parseError: function(err) { | ||
log.debug('Mermaid Syntax error:'); | ||
log.debug(err); | ||
}, | ||
render:function(id, text,callback, element){ | ||
return mermaidAPI.render(id, text,callback, element); | ||
} | ||
}; | ||
init: function () { | ||
init.apply(null, arguments) | ||
}, | ||
initialize: function (config) { | ||
exports.initialize(config) | ||
}, | ||
version: function () { | ||
return mermaidAPI.version() | ||
}, | ||
parse: function (text) { | ||
return mermaidAPI.parse(text) | ||
}, | ||
parseError: function (err) { | ||
log.debug('Mermaid Syntax error:') | ||
log.debug(err) | ||
}, | ||
render: function (id, text, callback, element) { | ||
return mermaidAPI.render(id, text, callback, element) | ||
} | ||
} | ||
@@ -208,3 +195,3 @@ /** | ||
*/ | ||
exports.parseError = global.mermaid.parseError; | ||
exports.parseError = global.mermaid.parseError | ||
@@ -216,57 +203,43 @@ /** | ||
*/ | ||
exports.contentLoaded = function(){ | ||
var config; | ||
// Check state of start config mermaid namespace | ||
if (typeof mermaid_config !== 'undefined') { | ||
if (equals(false, global.mermaid_config.htmlLabels)) { | ||
global.mermaid.htmlLabels = false; | ||
} | ||
exports.contentLoaded = function () { | ||
var config | ||
// Check state of start config mermaid namespace | ||
if (typeof global.mermaid_config !== 'undefined') { | ||
if (equals(false, global.mermaid_config.htmlLabels)) { | ||
global.mermaid.htmlLabels = false | ||
} | ||
} | ||
if(global.mermaid.startOnLoad) { | ||
// For backwards compatability reasons also check mermaid_config variable | ||
if (typeof global.mermaid_config !== 'undefined') { | ||
// Check if property startOnLoad is set | ||
if (equals(true, global.mermaid_config.startOnLoad)) { | ||
global.mermaid.init(); | ||
} | ||
} | ||
else { | ||
// No config found, do check API config | ||
config = mermaidAPI.getConfig(); | ||
if(config.startOnLoad){ | ||
global.mermaid.init(); | ||
} | ||
} | ||
}else{ | ||
//if(typeof global.mermaid === 'undefined' ){ | ||
if(typeof global.mermaid.startOnLoad === 'undefined' ){ | ||
log.debug('In start, no config'); | ||
config = mermaidAPI.getConfig(); | ||
if(config.startOnLoad){ | ||
global.mermaid.init(); | ||
} | ||
//}else{ | ||
// | ||
//} | ||
} | ||
if (global.mermaid.startOnLoad) { | ||
// For backwards compatability reasons also check mermaid_config variable | ||
if (typeof global.mermaid_config !== 'undefined') { | ||
// Check if property startOnLoad is set | ||
if (equals(true, global.mermaid_config.startOnLoad)) { | ||
global.mermaid.init() | ||
} | ||
} else { | ||
// No config found, do check API config | ||
config = mermaidAPI.getConfig() | ||
if (config.startOnLoad) { | ||
global.mermaid.init() | ||
} | ||
} | ||
} else { | ||
if (typeof global.mermaid.startOnLoad === 'undefined') { | ||
log.debug('In start, no config') | ||
config = mermaidAPI.getConfig() | ||
if (config.startOnLoad) { | ||
global.mermaid.init() | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
if(typeof document !== 'undefined'){ | ||
/*! | ||
* Wait for document loaded before starting the execution | ||
*/ | ||
window.addEventListener('load', function(){ | ||
exports.contentLoaded(); | ||
}, false); | ||
if (typeof document !== 'undefined') { | ||
/*! | ||
* Wait for document loaded before starting the execution | ||
*/ | ||
window.addEventListener('load', function () { | ||
exports.contentLoaded() | ||
}, false) | ||
} | ||
// // Your actual module | ||
// return module.exports; | ||
//})); |
@@ -0,1 +1,2 @@ | ||
/* eslint-env jasmine */ | ||
/** | ||
@@ -7,249 +8,220 @@ * Created by knut on 14-11-26. | ||
*/ | ||
//var rewire = require('rewire'); | ||
var mermaid = require('./mermaid'); | ||
//var log = require('./logger').create(); | ||
var mermaid = require('./mermaid') | ||
describe('when using mermaid and ',function() { | ||
describe('when detecting chart type ',function() { | ||
//var mermaid; | ||
//var document; | ||
//var window; | ||
beforeEach(function () { | ||
//var MockBrowser = require('mock-browser').mocks.MockBrowser; | ||
//var mock = new MockBrowser(); | ||
// | ||
//delete global.mermaid_config; | ||
// | ||
//// and in the run-code inside some object | ||
//global.document = mock.getDocument(); | ||
//global.window = mock.getWindow(); | ||
describe('when using mermaid and ', function () { | ||
describe('when detecting chart type ', function () { | ||
it('should not start rendering with mermaid_config.startOnLoad set to false', function () { | ||
global.mermaid_config = {startOnLoad: false} | ||
}); | ||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>' | ||
spyOn(global.mermaid, 'init') | ||
mermaid.contentLoaded() | ||
expect(global.mermaid.init).not.toHaveBeenCalled() | ||
}) | ||
it('should not start rendering with mermaid_config.startOnLoad set to false', function () { | ||
//mermaid = rewire('./mermaid'); | ||
global.mermaid_config ={startOnLoad : false}; | ||
it('should not start rendering with mermaid.startOnLoad set to false', function () { | ||
global.mermaid.startOnLoad = false | ||
global.mermaid_config = {startOnLoad: true} | ||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'; | ||
spyOn(global.mermaid,'init'); | ||
//log.debug(mermaid); | ||
mermaid.contentLoaded(); | ||
expect(global.mermaid.init).not.toHaveBeenCalled(); | ||
}); | ||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>' | ||
spyOn(global.mermaid, 'init') | ||
mermaid.contentLoaded() | ||
expect(global.mermaid.init).not.toHaveBeenCalled() | ||
}) | ||
it('should not start rendering with mermaid.startOnLoad set to false', function () { | ||
//mermaid = rewire('./mermaid'); | ||
global.mermaid.startOnLoad = false; | ||
global.mermaid_config ={startOnLoad : true}; | ||
it('should start rendering with both startOnLoad set', function () { | ||
global.mermaid.startOnLoad = true | ||
global.mermaid_config = {startOnLoad: true} | ||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>' | ||
spyOn(global.mermaid, 'init') | ||
mermaid.contentLoaded() | ||
expect(global.mermaid.init).toHaveBeenCalled() | ||
}) | ||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'; | ||
spyOn(global.mermaid,'init'); | ||
mermaid.contentLoaded(); | ||
expect(global.mermaid.init).not.toHaveBeenCalled(); | ||
}); | ||
it('should start rendering with mermaid.startOnLoad set and no mermaid_config defined', function () { | ||
global.mermaid.startOnLoad = true | ||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>' | ||
spyOn(global.mermaid, 'init') | ||
mermaid.contentLoaded() | ||
expect(global.mermaid.init).toHaveBeenCalled() | ||
}) | ||
it('should start rendering with both startOnLoad set', function () { | ||
//mermaid = rewire('./mermaid'); | ||
global.mermaid.startOnLoad = true; | ||
global.mermaid_config ={startOnLoad : true}; | ||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'; | ||
spyOn(global.mermaid,'init'); | ||
mermaid.contentLoaded(); | ||
expect(global.mermaid.init).toHaveBeenCalled(); | ||
}); | ||
it('should start rendering as a default with no changes performed', function () { | ||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>' | ||
spyOn(global.mermaid, 'init') | ||
mermaid.contentLoaded() | ||
expect(global.mermaid.init).toHaveBeenCalled() | ||
}) | ||
}) | ||
it('should start rendering with mermaid.startOnLoad set and no mermaid_config defined', function () { | ||
//mermaid = rewire('./mermaid'); | ||
global.mermaid.startOnLoad = true; | ||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'; | ||
spyOn(global.mermaid,'init'); | ||
mermaid.contentLoaded(); | ||
expect(global.mermaid.init).toHaveBeenCalled(); | ||
}); | ||
describe('when calling addEdges ', function () { | ||
var graph = require('./diagrams/flowchart/graphDb') | ||
var flow = require('./diagrams/flowchart/parser/flow') | ||
var flowRend = require('./diagrams/flowchart/flowRenderer') | ||
it('should start rendering as a default with no changes performed', function () { | ||
//mermaid = rewire('./mermaid'); | ||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'; | ||
spyOn(global.mermaid,'init'); | ||
mermaid.contentLoaded(); | ||
expect(global.mermaid.init).toHaveBeenCalled(); | ||
}); | ||
beforeEach(function () { | ||
global.mermaid_config = {startOnLoad: false} | ||
flow.parser.yy = graph | ||
graph.clear() | ||
}) | ||
it('it should handle edges with text', function () { | ||
flow.parser.parse('graph TD;A-->|text ex|B;') | ||
flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
}); | ||
var mockG = { | ||
setEdge: function (start, end, options) { | ||
expect(start).toBe('A') | ||
expect(end).toBe('B') | ||
expect(options.arrowhead).toBe('normal') | ||
expect(options.label.match('text ex')).toBeTruthy() | ||
} | ||
} | ||
describe('when calling addEdges ',function() { | ||
var graph = require('./diagrams/flowchart/graphDb'); | ||
var flow = require('./diagrams/flowchart/parser/flow'); | ||
var flowRend = require('./diagrams/flowchart/flowRenderer'); | ||
flowRend.addEdges(edges, mockG) | ||
}) | ||
beforeEach(function () { | ||
global.mermaid_config ={startOnLoad : false}; | ||
//var MockBrowser = require('mock-browser').mocks.MockBrowser; | ||
//var mock = new MockBrowser(); | ||
flow.parser.yy =graph; | ||
graph.clear(); | ||
//global.document = mock.getDocument(); | ||
//mermaid = rewire('./mermaid'); | ||
}); | ||
it('it should handle edges with text', function () { | ||
flow.parser.parse('graph TD;A-->|text ex|B;'); | ||
flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
it('should handle edges without text', function () { | ||
flow.parser.parse('graph TD;A-->B;') | ||
flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var mockG = { | ||
setEdge:function(start, end,options){ | ||
expect(start).toBe('A'); | ||
expect(end).toBe('B'); | ||
expect(options.arrowhead).toBe('normal'); | ||
expect(options.label.match('text ex')).toBeTruthy(); | ||
} | ||
}; | ||
var mockG = { | ||
setEdge: function (start, end, options) { | ||
expect(start).toBe('A') | ||
expect(end).toBe('B') | ||
expect(options.arrowhead).toBe('normal') | ||
} | ||
} | ||
flowRend.addEdges(edges,mockG); | ||
}); | ||
flowRend.addEdges(edges, mockG) | ||
}) | ||
it('should handle edges without text', function () { | ||
flow.parser.parse('graph TD;A-->B;'); | ||
flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
it('should handle open-ended edges', function () { | ||
flow.parser.parse('graph TD;A---B;') | ||
flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var mockG = { | ||
setEdge:function(start, end,options){ | ||
expect(start).toBe('A'); | ||
expect(end).toBe('B'); | ||
expect(options.arrowhead).toBe('normal'); | ||
} | ||
}; | ||
var mockG = { | ||
setEdge: function (start, end, options) { | ||
expect(start).toBe('A') | ||
expect(end).toBe('B') | ||
expect(options.arrowhead).toBe('none') | ||
} | ||
} | ||
flowRend.addEdges(edges,mockG); | ||
}); | ||
flowRend.addEdges(edges, mockG) | ||
}) | ||
it('should handle edges with styles defined', function () { | ||
flow.parser.parse('graph TD;A---B; linkStyle 0 stroke:val1,stroke-width:val2;') | ||
flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
it('should handle open-ended edges', function () { | ||
flow.parser.parse('graph TD;A---B;'); | ||
flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var mockG = { | ||
setEdge: function (start, end, options) { | ||
expect(start).toBe('A') | ||
expect(end).toBe('B') | ||
expect(options.arrowhead).toBe('none') | ||
expect(options.style).toBe('stroke:val1;stroke-width:val2;fill:none;') | ||
} | ||
} | ||
var mockG = { | ||
setEdge:function(start, end,options){ | ||
expect(start).toBe('A'); | ||
expect(end).toBe('B'); | ||
expect(options.arrowhead).toBe('none'); | ||
} | ||
}; | ||
flowRend.addEdges(edges, mockG) | ||
}) | ||
it('should handle edges with interpolation defined', function () { | ||
flow.parser.parse('graph TD;A---B; linkStyle 0 interpolate basis') | ||
flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
flowRend.addEdges(edges,mockG); | ||
}); | ||
var mockG = { | ||
setEdge: function (start, end, options) { | ||
expect(start).toBe('A') | ||
expect(end).toBe('B') | ||
expect(options.arrowhead).toBe('none') | ||
expect(options.lineInterpolate).toBe('basis') | ||
} | ||
} | ||
it('should handle edges with styles defined', function () { | ||
flow.parser.parse('graph TD;A---B; linkStyle 0 stroke:val1,stroke-width:val2;'); | ||
flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
flowRend.addEdges(edges, mockG) | ||
}) | ||
it('should handle edges with text and styles defined', function () { | ||
flow.parser.parse('graph TD;A---|the text|B; linkStyle 0 stroke:val1,stroke-width:val2;') | ||
flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var mockG = { | ||
setEdge:function(start, end,options){ | ||
expect(start).toBe('A'); | ||
expect(end).toBe('B'); | ||
expect(options.arrowhead).toBe('none'); | ||
expect(options.style).toBe('stroke:val1;stroke-width:val2;fill:none;'); | ||
} | ||
}; | ||
var mockG = { | ||
setEdge: function (start, end, options) { | ||
expect(start).toBe('A') | ||
expect(end).toBe('B') | ||
expect(options.arrowhead).toBe('none') | ||
expect(options.label.match('the text')).toBeTruthy() | ||
expect(options.style).toBe('stroke:val1;stroke-width:val2;fill:none;') | ||
} | ||
} | ||
flowRend.addEdges(edges,mockG); | ||
}); | ||
it('should handle edges with interpolation defined', function () { | ||
flow.parser.parse('graph TD;A---B; linkStyle 0 interpolate basis'); | ||
flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
flowRend.addEdges(edges, mockG) | ||
}) | ||
var mockG = { | ||
setEdge:function(start, end,options){ | ||
expect(start).toBe('A'); | ||
expect(end).toBe('B'); | ||
expect(options.arrowhead).toBe('none'); | ||
expect(options.lineInterpolate).toBe('basis'); | ||
} | ||
}; | ||
it('should set fill to "none" by default when handling edges', function () { | ||
flow.parser.parse('graph TD;A---B; linkStyle 0 stroke:val1,stroke-width:val2;') | ||
flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
flowRend.addEdges(edges,mockG); | ||
}); | ||
it('should handle edges with text and styles defined', function () { | ||
flow.parser.parse('graph TD;A---|the text|B; linkStyle 0 stroke:val1,stroke-width:val2;'); | ||
flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var mockG = { | ||
setEdge: function (start, end, options) { | ||
expect(start).toBe('A') | ||
expect(end).toBe('B') | ||
expect(options.arrowhead).toBe('none') | ||
expect(options.style).toBe('stroke:val1;stroke-width:val2;fill:none;') | ||
} | ||
} | ||
var mockG = { | ||
setEdge:function(start, end,options){ | ||
expect(start).toBe('A'); | ||
expect(end).toBe('B'); | ||
expect(options.arrowhead).toBe('none'); | ||
expect(options.label.match('the text')).toBeTruthy(); | ||
expect(options.style).toBe('stroke:val1;stroke-width:val2;fill:none;'); | ||
} | ||
}; | ||
flowRend.addEdges(edges, mockG) | ||
}) | ||
flowRend.addEdges(edges,mockG); | ||
}); | ||
it('should not set fill to none if fill is set in linkStyle', function () { | ||
flow.parser.parse('graph TD;A---B; linkStyle 0 stroke:val1,stroke-width:val2,fill:blue;') | ||
flow.parser.yy.getVertices() | ||
var edges = flow.parser.yy.getEdges() | ||
var mockG = { | ||
setEdge: function (start, end, options) { | ||
expect(start).toBe('A') | ||
expect(end).toBe('B') | ||
expect(options.arrowhead).toBe('none') | ||
expect(options.style).toBe('stroke:val1;stroke-width:val2;fill:blue;') | ||
} | ||
} | ||
it('should set fill to "none" by default when handling edges', function () { | ||
flow.parser.parse('graph TD;A---B; linkStyle 0 stroke:val1,stroke-width:val2;'); | ||
flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
flowRend.addEdges(edges, mockG) | ||
}) | ||
}) | ||
var mockG = { | ||
setEdge:function(start, end,options){ | ||
expect(start).toBe('A'); | ||
expect(end).toBe('B'); | ||
expect(options.arrowhead).toBe('none'); | ||
expect(options.style).toBe('stroke:val1;stroke-width:val2;fill:none;'); | ||
} | ||
}; | ||
describe('checking validity of input ', function () { | ||
it('it should return false for an invalid definiton', function () { | ||
spyOn(global.mermaid, 'parseError') | ||
var res = mermaid.parse('this is not a mermaid diagram definition') | ||
flowRend.addEdges(edges,mockG); | ||
}); | ||
expect(res).toBe(false) | ||
expect(global.mermaid.parseError).toHaveBeenCalled() | ||
}) | ||
it('should not set fill to none if fill is set in linkStyle', function () { | ||
flow.parser.parse('graph TD;A---B; linkStyle 0 stroke:val1,stroke-width:val2,fill:blue;'); | ||
flow.parser.yy.getVertices(); | ||
var edges = flow.parser.yy.getEdges(); | ||
var mockG = { | ||
setEdge:function(start, end,options){ | ||
expect(start).toBe('A'); | ||
expect(end).toBe('B'); | ||
expect(options.arrowhead).toBe('none'); | ||
expect(options.style).toBe('stroke:val1;stroke-width:val2;fill:blue;'); | ||
} | ||
}; | ||
it('it should return true for a valid flow definition', function () { | ||
spyOn(global.mermaid, 'parseError') | ||
var res = mermaid.parse('graph TD;A--x|text including URL space|B;') | ||
flowRend.addEdges(edges,mockG); | ||
}); | ||
}); | ||
expect(res).toBe(true) | ||
expect(global.mermaid.parseError).not.toHaveBeenCalled() | ||
}) | ||
it('it should return false for an invalid flow definition', function () { | ||
spyOn(global.mermaid, 'parseError') | ||
var res = mermaid.parse('graph TQ;A--x|text including URL space|B;') | ||
describe('checking validity of input ', function(){ | ||
it('it should return false for an invalid definiton',function(){ | ||
spyOn(global.mermaid,'parseError'); | ||
var res = mermaid.parse('this is not a mermaid diagram definition'); | ||
expect(res).toBe(false) | ||
expect(global.mermaid.parseError).toHaveBeenCalled() | ||
}) | ||
expect(res).toBe(false); | ||
expect(global.mermaid.parseError).toHaveBeenCalled(); | ||
}); | ||
it('it should return true for a valid flow definition',function(){ | ||
spyOn(global.mermaid,'parseError'); | ||
var res = mermaid.parse('graph TD;A--x|text including URL space|B;'); | ||
expect(res).toBe(true); | ||
expect(global.mermaid.parseError).not.toHaveBeenCalled(); | ||
}); | ||
it('it should return false for an invalid flow definition',function(){ | ||
spyOn(global.mermaid,'parseError'); | ||
var res = mermaid.parse('graph TQ;A--x|text including URL space|B;'); | ||
expect(res).toBe(false); | ||
expect(global.mermaid.parseError).toHaveBeenCalled(); | ||
}); | ||
it('it should return true for a valid sequenceDiagram definition',function(){ | ||
spyOn(global.mermaid,'parseError'); | ||
var str = 'sequenceDiagram\n' + | ||
it('it should return true for a valid sequenceDiagram definition', function () { | ||
spyOn(global.mermaid, 'parseError') | ||
var str = 'sequenceDiagram\n' + | ||
'Alice->Bob: Hello Bob, how are you?\n\n' + | ||
@@ -262,12 +234,12 @@ '%% Comment\n' + | ||
'Bob-->Alice: Feel sick...\n' + | ||
'end'; | ||
var res = mermaid.parse(str); | ||
'end' | ||
var res = mermaid.parse(str) | ||
expect(res).toBe(true); | ||
expect(global.mermaid.parseError).not.toHaveBeenCalled(); | ||
}); | ||
expect(res).toBe(true) | ||
expect(global.mermaid.parseError).not.toHaveBeenCalled() | ||
}) | ||
it('it should return false for an invalid sequenceDiagram definition',function(){ | ||
spyOn(global.mermaid,'parseError'); | ||
var str = 'sequenceDiagram\n' + | ||
it('it should return false for an invalid sequenceDiagram definition', function () { | ||
spyOn(global.mermaid, 'parseError') | ||
var str = 'sequenceDiagram\n' + | ||
'Alice:->Bob: Hello Bob, how are you?\n\n' + | ||
@@ -280,34 +252,32 @@ '%% Comment\n' + | ||
'Bob-->Alice: Feel sick...\n' + | ||
'end'; | ||
var res = mermaid.parse(str); | ||
'end' | ||
var res = mermaid.parse(str) | ||
expect(res).toBe(false); | ||
expect(global.mermaid.parseError).toHaveBeenCalled(); | ||
}); | ||
expect(res).toBe(false) | ||
expect(global.mermaid.parseError).toHaveBeenCalled() | ||
}) | ||
it('it should return true for a valid dot definition',function(){ | ||
spyOn(global.mermaid,'parseError'); | ||
var res = mermaid.parse('digraph\n' + | ||
it('it should return true for a valid dot definition', function () { | ||
spyOn(global.mermaid, 'parseError') | ||
var res = mermaid.parse('digraph\n' + | ||
'{\n' + | ||
' a -> b -> c -- d -> e;\n' + | ||
' a -- e;\n' + | ||
'}'); | ||
'}') | ||
expect(res).toBe(true); | ||
expect(global.mermaid.parseError).not.toHaveBeenCalled(); | ||
}); | ||
it('it should return false for an invalid dot definition',function(){ | ||
spyOn(global.mermaid,'parseError'); | ||
var res = mermaid.parse('digraph\n' + | ||
expect(res).toBe(true) | ||
expect(global.mermaid.parseError).not.toHaveBeenCalled() | ||
}) | ||
it('it should return false for an invalid dot definition', function () { | ||
spyOn(global.mermaid, 'parseError') | ||
var res = mermaid.parse('digraph\n' + | ||
'{\n' + | ||
'a -:> b -> c -- d -> e;\n' + | ||
'a -- e;\n' + | ||
'}'); | ||
'}') | ||
expect(res).toBe(false); | ||
expect(global.mermaid.parseError).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); | ||
expect(res).toBe(false) | ||
expect(global.mermaid.parseError).toHaveBeenCalled() | ||
}) | ||
}) | ||
}) |
@@ -14,30 +14,27 @@ /** | ||
*/ | ||
var Logger = require('./logger'); | ||
var log = new Logger.Log(); | ||
var Logger = require('./logger') | ||
var log = Logger.Log | ||
var graph = require('./diagrams/flowchart/graphDb'); | ||
var utils = require('./utils'); | ||
var flowRenderer = require('./diagrams/flowchart/flowRenderer'); | ||
var seq = require('./diagrams/sequenceDiagram/sequenceRenderer'); | ||
var info = require('./diagrams/example/exampleRenderer'); | ||
var infoParser = require('./diagrams/example/parser/example'); | ||
var flowParser = require('./diagrams/flowchart/parser/flow'); | ||
var dotParser = require('./diagrams/flowchart/parser/dot'); | ||
var sequenceParser = require('./diagrams/sequenceDiagram/parser/sequenceDiagram'); | ||
var sequenceDb = require('./diagrams/sequenceDiagram/sequenceDb'); | ||
var infoDb = require('./diagrams/example/exampleDb'); | ||
var gantt = require('./diagrams/gantt/ganttRenderer'); | ||
var ganttParser = require('./diagrams/gantt/parser/gantt'); | ||
var ganttDb = require('./diagrams/gantt/ganttDb'); | ||
var classParser = require('./diagrams/classDiagram/parser/classDiagram'); | ||
var classRenderer = require('./diagrams/classDiagram/classRenderer'); | ||
var classDb = require('./diagrams/classDiagram/classDb'); | ||
var gitGraphParser = require('./diagrams/gitGraph/parser/gitGraph'); | ||
var gitGraphRenderer = require('./diagrams/gitGraph/gitGraphRenderer'); | ||
var gitGraphAst = require('./diagrams/gitGraph/gitGraphAst'); | ||
var d3 = require('./d3'); | ||
var graph = require('./diagrams/flowchart/graphDb') | ||
var utils = require('./utils') | ||
var flowRenderer = require('./diagrams/flowchart/flowRenderer') | ||
var seq = require('./diagrams/sequenceDiagram/sequenceRenderer') | ||
var info = require('./diagrams/example/exampleRenderer') | ||
var infoParser = require('./diagrams/example/parser/example') | ||
var flowParser = require('./diagrams/flowchart/parser/flow') | ||
var dotParser = require('./diagrams/flowchart/parser/dot') | ||
var sequenceParser = require('./diagrams/sequenceDiagram/parser/sequenceDiagram') | ||
var sequenceDb = require('./diagrams/sequenceDiagram/sequenceDb') | ||
var infoDb = require('./diagrams/example/exampleDb') | ||
var gantt = require('./diagrams/gantt/ganttRenderer') | ||
var ganttParser = require('./diagrams/gantt/parser/gantt') | ||
var ganttDb = require('./diagrams/gantt/ganttDb') | ||
var classParser = require('./diagrams/classDiagram/parser/classDiagram') | ||
var classRenderer = require('./diagrams/classDiagram/classRenderer') | ||
var classDb = require('./diagrams/classDiagram/classDb') | ||
var gitGraphParser = require('./diagrams/gitGraph/parser/gitGraph') | ||
var gitGraphRenderer = require('./diagrams/gitGraph/gitGraphRenderer') | ||
var gitGraphAst = require('./diagrams/gitGraph/gitGraphAst') | ||
var d3 = require('./d3') | ||
SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformToElement || function(toElement) { | ||
return toElement.getScreenCTM().inverse().multiply(this.getScreenCTM()); | ||
}; | ||
/** | ||
@@ -55,64 +52,64 @@ * ## Configuration | ||
var config = { | ||
/** | ||
* logLevel , decides the amount of logging to be used. | ||
* * debug: 1 | ||
* * info: 2 | ||
* * warn: 3 | ||
* * error: 4 | ||
* * fatal: 5 | ||
*/ | ||
logLevel: 5, | ||
/** | ||
* **cloneCssStyles** - This options controls whether or not the css rules should be copied into the generated svg | ||
*/ | ||
cloneCssStyles: true, | ||
/** | ||
* **startOnLoad** - This options controls whether or mermaid starts when the page loads | ||
*/ | ||
startOnLoad: true, | ||
/** | ||
* **arrowMarkerAbsolute** - This options controls whether or arrow markers in html code will be absolute paths or | ||
* an anchor, #. This matters if you are using base tag settings. | ||
*/ | ||
arrowMarkerAbsolute: false, | ||
/** | ||
* ### flowchart | ||
* *The object containing configurations specific for flowcharts* | ||
*/ | ||
flowchart: { | ||
/** | ||
* logLevel , decides the amount of logging to be used. | ||
* * debug: 1 | ||
* * info: 2 | ||
* * warn: 3 | ||
* * error: 4 | ||
* * fatal: 5 | ||
* **htmlLabels** - Flag for setting whether or not a html tag should be used for rendering labels | ||
* on the edges | ||
*/ | ||
logLevel: 5, | ||
htmlLabels: true, | ||
/** | ||
* **cloneCssStyles** - This options controls whether or not the css rules should be copied into the generated svg | ||
* **useMaxWidth** - Flag for setting whether or not a all available width should be used for | ||
* the diagram. | ||
*/ | ||
cloneCssStyles: true, | ||
useMaxWidth: true | ||
}, | ||
/** | ||
* **startOnLoad** - This options controls whether or mermaid starts when the page loads | ||
*/ | ||
startOnLoad: true, | ||
/** | ||
* ### sequenceDiagram | ||
* The object containing configurations specific for sequence diagrams | ||
*/ | ||
sequenceDiagram: { | ||
/** | ||
* **arrowMarkerAbsolute** - This options controls whether or arrow markers in html code will be absolute paths or | ||
* an anchor, #. This matters if you are using base tag settings. | ||
* **diagramMarginX** - margin to the right and left of the sequence diagram | ||
*/ | ||
arrowMarkerAbsolute: false, | ||
diagramMarginX: 50, | ||
/** | ||
* ### flowchart | ||
* *The object containing configurations specific for flowcharts* | ||
* **diagramMarginY** - margin to the over and under the sequence diagram | ||
*/ | ||
flowchart:{ | ||
/** | ||
* **htmlLabels** - Flag for setting whether or not a html tag should be used for rendering labels | ||
* on the edges | ||
*/ | ||
htmlLabels:true, | ||
/** | ||
* **useMaxWidth** - Flag for setting whether or not a all available width should be used for | ||
* the diagram. | ||
*/ | ||
useMaxWidth:true | ||
}, | ||
diagramMarginY: 10, | ||
/** | ||
* ### sequenceDiagram | ||
* The object containing configurations specific for sequence diagrams | ||
*/ | ||
sequenceDiagram:{ | ||
/** | ||
* **diagramMarginX** - margin to the right and left of the sequence diagram | ||
*/ | ||
diagramMarginX:50, | ||
/** | ||
* **diagramMarginY** - margin to the over and under the sequence diagram | ||
*/ | ||
diagramMarginY:10, | ||
/** | ||
* **actorMargin** - Margin between actors | ||
*/ | ||
actorMargin:50, | ||
actorMargin: 50, | ||
@@ -122,3 +119,3 @@ /** | ||
*/ | ||
width:150, | ||
width: 150, | ||
@@ -128,3 +125,3 @@ /** | ||
*/ | ||
height:65, | ||
height: 65, | ||
@@ -134,18 +131,18 @@ /** | ||
*/ | ||
boxMargin:10, | ||
boxMargin: 10, | ||
/** | ||
* **boxTextMargin** - margin around the text in loop/alt/opt boxes | ||
*/ | ||
boxTextMargin:5, | ||
/** | ||
* **boxTextMargin** - margin around the text in loop/alt/opt boxes | ||
*/ | ||
boxTextMargin: 5, | ||
/** | ||
/** | ||
* **noteMargin** - margin around notes | ||
*/ | ||
noteMargin:10, | ||
*/ | ||
noteMargin: 10, | ||
/** | ||
/** | ||
* **messageMargin** - Space between messages | ||
*/ | ||
messageMargin:35, | ||
*/ | ||
messageMargin: 35, | ||
@@ -155,3 +152,3 @@ /** | ||
*/ | ||
mirrorActors:true, | ||
mirrorActors: true, | ||
@@ -162,3 +159,3 @@ /** | ||
*/ | ||
bottomMarginAdj:1, | ||
bottomMarginAdj: 1, | ||
@@ -169,89 +166,88 @@ /** | ||
*/ | ||
useMaxWidth:true | ||
}, | ||
useMaxWidth: true | ||
}, | ||
/** ### gantt | ||
* The object containing configurations specific for gantt diagrams* | ||
/** ### gantt | ||
* The object containing configurations specific for gantt diagrams* | ||
*/ | ||
gantt: { | ||
/** | ||
* **titleTopMargin** - margin top for the text over the gantt diagram | ||
*/ | ||
gantt:{ | ||
/** | ||
* **titleTopMargin** - margin top for the text over the gantt diagram | ||
*/ | ||
titleTopMargin: 25, | ||
titleTopMargin: 25, | ||
/** | ||
* **barHeight** - the height of the bars in the graph | ||
*/ | ||
barHeight: 20, | ||
/** | ||
* **barHeight** - the height of the bars in the graph | ||
*/ | ||
barHeight: 20, | ||
/** | ||
* **barGap** - the margin between the different activities in the gantt diagram | ||
*/ | ||
barGap: 4, | ||
/** | ||
* **barGap** - the margin between the different activities in the gantt diagram | ||
*/ | ||
barGap: 4, | ||
/** | ||
* **topPadding** - margin between title and gantt diagram and between axis and gantt diagram. | ||
*/ | ||
topPadding: 50, | ||
/** | ||
* **topPadding** - margin between title and gantt diagram and between axis and gantt diagram. | ||
*/ | ||
topPadding: 50, | ||
/** | ||
* **leftPadding** - the space allocated for the section name to the left of the activities. | ||
*/ | ||
leftPadding: 75, | ||
/** | ||
* **leftPadding** - the space allocated for the section name to the left of the activities. | ||
*/ | ||
leftPadding: 75, | ||
/** | ||
* **gridLineStartPadding** - Vertical starting position of the grid lines | ||
*/ | ||
gridLineStartPadding: 35, | ||
/** | ||
* **gridLineStartPadding** - Vertical starting position of the grid lines | ||
*/ | ||
gridLineStartPadding: 35, | ||
/** | ||
* **fontSize** - font size ... | ||
*/ | ||
fontSize: 11, | ||
/** | ||
* **fontSize** - font size ... | ||
*/ | ||
fontSize: 11, | ||
/** | ||
* **fontFamily** - font family ... | ||
*/ | ||
fontFamily: '"Open-Sans", "sans-serif"', | ||
/** | ||
* **fontFamily** - font family ... | ||
*/ | ||
fontFamily: '"Open-Sans", "sans-serif"', | ||
/** | ||
* **numberSectionStyles** - the number of alternating section styles | ||
*/ | ||
numberSectionStyles:3, | ||
/** | ||
* **numberSectionStyles** - the number of alternating section styles | ||
*/ | ||
numberSectionStyles: 3, | ||
/** | ||
* **axisFormatter** - formatting of the axis, this might need adjustment to match your locale and preferences | ||
*/ | ||
axisFormatter: [ | ||
/** | ||
* **axisFormatter** - formatting of the axis, this might need adjustment to match your locale and preferences | ||
*/ | ||
axisFormatter: [ | ||
// Within a day | ||
['%I:%M', function (d) { | ||
return d.getHours(); | ||
}], | ||
// Monday a week | ||
['w. %U', function (d) { | ||
return d.getDay() == 1; | ||
}], | ||
// Day within a week (not monday) | ||
['%a %d', function (d) { | ||
return d.getDay() && d.getDate() != 1; | ||
}], | ||
// within a month | ||
['%b %d', function (d) { | ||
return d.getDate() != 1; | ||
}], | ||
// Month | ||
['%m-%y', function (d) { | ||
return d.getMonth(); | ||
}] | ||
] | ||
}, | ||
classDiagram:{}, | ||
gitGraph: {}, | ||
info:{} | ||
}; | ||
// Within a day | ||
['%I:%M', function (d) { | ||
return d.getHours() | ||
}], | ||
// Monday a week | ||
['w. %U', function (d) { | ||
return d.getDay() === 1 | ||
}], | ||
// Day within a week (not monday) | ||
['%a %d', function (d) { | ||
return d.getDay() && d.getDate() !== 1 | ||
}], | ||
// within a month | ||
['%b %d', function (d) { | ||
return d.getDate() !== 1 | ||
}], | ||
// Month | ||
['%m-%y', function (d) { | ||
return d.getMonth() | ||
}] | ||
] | ||
}, | ||
classDiagram: {}, | ||
gitGraph: {}, | ||
info: {} | ||
} | ||
Logger.setLogLevel(config.logLevel); | ||
Logger.setLogLevel(config.logLevel) | ||
/** | ||
@@ -263,46 +259,45 @@ * ## parse | ||
*/ | ||
var parse = function(text){ | ||
var graphType = utils.detectType(text); | ||
var parser; | ||
var parse = function (text) { | ||
var graphType = utils.detectType(text) | ||
var parser | ||
switch(graphType){ | ||
case 'gitGraph': | ||
parser = gitGraphParser; | ||
parser.parser.yy = gitGraphAst; | ||
break; | ||
case 'graph': | ||
parser = flowParser; | ||
parser.parser.yy = graph; | ||
break; | ||
case 'dotGraph': | ||
parser = dotParser; | ||
parser.parser.yy = graph; | ||
break; | ||
case 'sequenceDiagram': | ||
parser = sequenceParser; | ||
parser.parser.yy = sequenceDb; | ||
break; | ||
case 'info': | ||
parser = infoParser; | ||
parser.parser.yy = infoDb; | ||
break; | ||
case 'gantt': | ||
parser = ganttParser; | ||
parser.parser.yy = ganttDb; | ||
break; | ||
case 'classDiagram': | ||
parser = classParser; | ||
parser.parser.yy = classDb; | ||
break; | ||
} | ||
switch (graphType) { | ||
case 'gitGraph': | ||
parser = gitGraphParser | ||
parser.parser.yy = gitGraphAst | ||
break | ||
case 'graph': | ||
parser = flowParser | ||
parser.parser.yy = graph | ||
break | ||
case 'dotGraph': | ||
parser = dotParser | ||
parser.parser.yy = graph | ||
break | ||
case 'sequenceDiagram': | ||
parser = sequenceParser | ||
parser.parser.yy = sequenceDb | ||
break | ||
case 'info': | ||
parser = infoParser | ||
parser.parser.yy = infoDb | ||
break | ||
case 'gantt': | ||
parser = ganttParser | ||
parser.parser.yy = ganttDb | ||
break | ||
case 'classDiagram': | ||
parser = classParser | ||
parser.parser.yy = classDb | ||
break | ||
} | ||
try{ | ||
parser.parse(text); | ||
return true; | ||
} | ||
catch(err){ | ||
return false; | ||
} | ||
}; | ||
exports.parse = parse; | ||
try { | ||
parser.parse(text) | ||
return true | ||
} catch (err) { | ||
return false | ||
} | ||
} | ||
exports.parse = parse | ||
@@ -314,48 +309,47 @@ /** | ||
*/ | ||
exports.version = function(){ | ||
return require('../package.json').version; | ||
}; | ||
exports.version = function () { | ||
return require('../package.json').version | ||
} | ||
exports.encodeEntities = function(text){ | ||
var txt = text; | ||
exports.encodeEntities = function (text) { | ||
var txt = text | ||
txt = txt.replace(/style.*:\S*#.*;/g,function(s){ | ||
var innerTxt = s.substring(0,s.length-1); | ||
return innerTxt; | ||
}); | ||
txt = txt.replace(/classDef.*:\S*#.*;/g,function(s){ | ||
var innerTxt = s.substring(0,s.length-1); | ||
return innerTxt; | ||
}); | ||
txt = txt.replace(/style.*:\S*#.*;/g, function (s) { | ||
var innerTxt = s.substring(0, s.length - 1) | ||
return innerTxt | ||
}) | ||
txt = txt.replace(/classDef.*:\S*#.*;/g, function (s) { | ||
var innerTxt = s.substring(0, s.length - 1) | ||
return innerTxt | ||
}) | ||
txt = txt.replace(/#\w+\;/g,function(s){ | ||
var innerTxt = s.substring(1,s.length-1); | ||
txt = txt.replace(/#\w+;/g, function (s) { | ||
var innerTxt = s.substring(1, s.length - 1) | ||
var isInt = /^\+?\d+$/.test(innerTxt); | ||
if(isInt){ | ||
return 'fl°°'+innerTxt+'¶ß'; | ||
}else{ | ||
return 'fl°'+innerTxt+'¶ß'; | ||
} | ||
var isInt = /^\+?\d+$/.test(innerTxt) | ||
if (isInt) { | ||
return 'fl°°' + innerTxt + '¶ß' | ||
} else { | ||
return 'fl°' + innerTxt + '¶ß' | ||
} | ||
}) | ||
}); | ||
return txt | ||
} | ||
return txt; | ||
}; | ||
exports.decodeEntities = function (text) { | ||
var txt = text | ||
exports.decodeEntities = function(text){ | ||
var txt = text; | ||
txt = txt.replace(/fl°°/g, function () { | ||
return '&#' | ||
}) | ||
txt = txt.replace(/fl°/g, function () { | ||
return '&' | ||
}) | ||
txt = txt.replace(/¶ß/g, function () { | ||
return ';' | ||
}) | ||
txt = txt.replace(/\fl\°\°/g,function(){ | ||
return '&#'; | ||
}); | ||
txt = txt.replace(/\fl\°/g,function(){ | ||
return '&'; | ||
}); | ||
txt = txt.replace(/¶ß/g,function(){ | ||
return ';'; | ||
}); | ||
return txt; | ||
}; | ||
return txt | ||
} | ||
/** | ||
@@ -384,205 +378,187 @@ * ##render | ||
*/ | ||
var render = function(id, txt, cb, container){ | ||
var render = function (id, txt, cb, container) { | ||
if (typeof container !== 'undefined') { | ||
container.innerHTML = '' | ||
if(typeof container !== 'undefined'){ | ||
container.innerHTML = ''; | ||
d3.select(container).append('div') | ||
.attr('id', 'd'+id) | ||
.append('svg') | ||
.attr('id', id) | ||
.attr('width','100%') | ||
.attr('xmlns','http://www.w3.org/2000/svg') | ||
.append('g'); | ||
d3.select(container).append('div') | ||
.attr('id', 'd' + id) | ||
.append('svg') | ||
.attr('id', id) | ||
.attr('width', '100%') | ||
.attr('xmlns', 'http://www.w3.org/2000/svg') | ||
.append('g') | ||
} else { | ||
const element = document.querySelector('#' + 'd' + id) | ||
if (element) { | ||
element.innerHTML = '' | ||
} | ||
else{ | ||
var element = document.querySelector('#' + 'd'+id); | ||
if(element){ | ||
element.innerHTML = ''; | ||
} | ||
d3.select('body').append('div') | ||
.attr('id', 'd'+id) | ||
.append('svg') | ||
.attr('id', id) | ||
.attr('width','100%') | ||
.attr('xmlns','http://www.w3.org/2000/svg') | ||
.append('g'); | ||
} | ||
d3.select('body').append('div') | ||
.attr('id', 'd' + id) | ||
.append('svg') | ||
.attr('id', id) | ||
.attr('width', '100%') | ||
.attr('xmlns', 'http://www.w3.org/2000/svg') | ||
.append('g') | ||
} | ||
window.txt = txt; | ||
txt = exports.encodeEntities(txt); | ||
//console.warn('mermaid encode: '); | ||
//console.warn(txt); | ||
window.txt = txt | ||
txt = exports.encodeEntities(txt) | ||
var element = d3.select('#d'+id).node(); | ||
var graphType = utils.detectType(txt); | ||
var classes = {}; | ||
switch(graphType){ | ||
case 'gitGraph': | ||
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute; | ||
gitGraphRenderer.setConf(config.gitGraph); | ||
gitGraphRenderer.draw(txt, id, false); | ||
//if(config.cloneCssStyles){ | ||
//classes = gitGraphRenderer.getClasses(txt, false); | ||
//utils.cloneCssStyles(element.firstChild, classes); | ||
//} | ||
break; | ||
case 'graph': | ||
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute; | ||
flowRenderer.setConf(config.flowchart); | ||
flowRenderer.draw(txt, id, false); | ||
if(config.cloneCssStyles){ | ||
classes = flowRenderer.getClasses(txt, false); | ||
utils.cloneCssStyles(element.firstChild, classes); | ||
} | ||
break; | ||
case 'dotGraph': | ||
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute; | ||
flowRenderer.setConf(config.flowchart); | ||
flowRenderer.draw(txt, id, true); | ||
if(config.cloneCssStyles) { | ||
classes = flowRenderer.getClasses(txt, true); | ||
utils.cloneCssStyles(element.firstChild, classes); | ||
} | ||
break; | ||
case 'sequenceDiagram': | ||
config.sequenceDiagram.arrowMarkerAbsolute = config.arrowMarkerAbsolute; | ||
seq.setConf(config.sequenceDiagram); | ||
seq.draw(txt,id); | ||
if(config.cloneCssStyles) { | ||
utils.cloneCssStyles(element.firstChild, []); | ||
} | ||
break; | ||
case 'gantt': | ||
config.gantt.arrowMarkerAbsolute = config.arrowMarkerAbsolute; | ||
gantt.setConf(config.gantt); | ||
gantt.draw(txt,id); | ||
if(config.cloneCssStyles) { | ||
utils.cloneCssStyles(element.firstChild, []); | ||
} | ||
break; | ||
case 'classDiagram': | ||
config.classDiagram.arrowMarkerAbsolute = config.arrowMarkerAbsolute; | ||
classRenderer.setConf(config.classDiagram); | ||
classRenderer.draw(txt,id); | ||
if(config.cloneCssStyles) { | ||
utils.cloneCssStyles(element.firstChild, []); | ||
} | ||
break; | ||
case 'info': | ||
config.info.arrowMarkerAbsolute = config.arrowMarkerAbsolute; | ||
info.draw(txt,id,exports.version()); | ||
if(config.cloneCssStyles) { | ||
utils.cloneCssStyles(element.firstChild, []); | ||
} | ||
break; | ||
} | ||
var element = d3.select('#d' + id).node() | ||
var graphType = utils.detectType(txt) | ||
var classes = {} | ||
switch (graphType) { | ||
case 'gitGraph': | ||
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute | ||
gitGraphRenderer.setConf(config.gitGraph) | ||
gitGraphRenderer.draw(txt, id, false) | ||
break | ||
case 'graph': | ||
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute | ||
flowRenderer.setConf(config.flowchart) | ||
flowRenderer.draw(txt, id, false) | ||
if (config.cloneCssStyles) { | ||
classes = flowRenderer.getClasses(txt, false) | ||
utils.cloneCssStyles(element.firstChild, classes) | ||
} | ||
break | ||
case 'dotGraph': | ||
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute | ||
flowRenderer.setConf(config.flowchart) | ||
flowRenderer.draw(txt, id, true) | ||
if (config.cloneCssStyles) { | ||
classes = flowRenderer.getClasses(txt, true) | ||
utils.cloneCssStyles(element.firstChild, classes) | ||
} | ||
break | ||
case 'sequenceDiagram': | ||
config.sequenceDiagram.arrowMarkerAbsolute = config.arrowMarkerAbsolute | ||
seq.setConf(config.sequenceDiagram) | ||
seq.draw(txt, id) | ||
if (config.cloneCssStyles) { | ||
utils.cloneCssStyles(element.firstChild, []) | ||
} | ||
break | ||
case 'gantt': | ||
config.gantt.arrowMarkerAbsolute = config.arrowMarkerAbsolute | ||
gantt.setConf(config.gantt) | ||
gantt.draw(txt, id) | ||
if (config.cloneCssStyles) { | ||
utils.cloneCssStyles(element.firstChild, []) | ||
} | ||
break | ||
case 'classDiagram': | ||
config.classDiagram.arrowMarkerAbsolute = config.arrowMarkerAbsolute | ||
classRenderer.setConf(config.classDiagram) | ||
classRenderer.draw(txt, id) | ||
if (config.cloneCssStyles) { | ||
utils.cloneCssStyles(element.firstChild, []) | ||
} | ||
break | ||
case 'info': | ||
config.info.arrowMarkerAbsolute = config.arrowMarkerAbsolute | ||
info.draw(txt, id, exports.version()) | ||
if (config.cloneCssStyles) { | ||
utils.cloneCssStyles(element.firstChild, []) | ||
} | ||
break | ||
} | ||
d3.select('#d'+id).selectAll('foreignobject div').attr('xmlns','http://www.w3.org/1999/xhtml'); | ||
d3.select('#d' + id).selectAll('foreignobject div').attr('xmlns', 'http://www.w3.org/1999/xhtml') | ||
var url = ''; | ||
if(config.arrowMarkerAbsolute){ | ||
url = window.location.protocol+'//'+window.location.host+window.location.pathname +window.location.search; | ||
url = url.replace(/\(/g,'\\('); | ||
url = url.replace(/\)/g,'\\)'); | ||
} | ||
var url = '' | ||
if (config.arrowMarkerAbsolute) { | ||
url = window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search | ||
url = url.replace(/\(/g, '\\(') | ||
url = url.replace(/\)/g, '\\)') | ||
} | ||
// Fix for when the base tag is used | ||
var svgCode = d3.select('#d'+id).node().innerHTML.replace(/url\(#arrowhead/g,'url('+url +'#arrowhead','g'); | ||
// Fix for when the base tag is used | ||
var svgCode = d3.select('#d' + id).node().innerHTML.replace(/url\(#arrowhead/g, 'url(' + url + '#arrowhead', 'g') | ||
svgCode = exports.decodeEntities(svgCode); | ||
svgCode = exports.decodeEntities(svgCode) | ||
//console.warn('mermaid decode: '); | ||
//console.warn(svgCode); | ||
//var he = require('he'); | ||
//svgCode = he.decode(svgCode); | ||
if(typeof cb !== 'undefined'){ | ||
cb(svgCode,graph.bindFunctions); | ||
}else{ | ||
log.warn('CB = undefined!'); | ||
} | ||
if (typeof cb !== 'undefined') { | ||
cb(svgCode, graph.bindFunctions) | ||
} else { | ||
log.warn('CB = undefined!') | ||
} | ||
var node = d3.select('#d'+id).node(); | ||
if(node !== null && typeof node.remove === 'function'){ | ||
d3.select('#d'+id).node().remove(); | ||
} | ||
var node = d3.select('#d' + id).node() | ||
if (node !== null && typeof node.remove === 'function') { | ||
d3.select('#d' + id).node().remove() | ||
} | ||
return svgCode; | ||
}; | ||
return svgCode | ||
} | ||
exports.render = function (id, text, cb, containerElement) { | ||
try{ | ||
if(arguments.length === 1){ | ||
text = id; | ||
id = 'mermaidId0'; | ||
} | ||
try { | ||
if (arguments.length === 1) { | ||
text = id | ||
id = 'mermaidId0' | ||
} | ||
if (typeof document === 'undefined') { | ||
// Todo handle rendering serverside using phantomjs | ||
} | ||
else { | ||
// In browser | ||
return render(id, text, cb, containerElement); | ||
} | ||
}catch(e){ | ||
log.warn(e); | ||
if (typeof document === 'undefined') { | ||
// Todo handle rendering serverside using phantomjs | ||
} else { | ||
// In browser | ||
return render(id, text, cb, containerElement) | ||
} | ||
}; | ||
} catch (e) { | ||
log.warn(e) | ||
} | ||
} | ||
var setConf = function (cnf) { | ||
// Top level initially mermaid, gflow, sequenceDiagram and gantt | ||
var lvl1Keys = Object.keys(cnf) | ||
var i | ||
for (i = 0; i < lvl1Keys.length; i++) { | ||
if (typeof cnf[lvl1Keys[i]] === 'object') { | ||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]) | ||
var setConf = function(cnf){ | ||
// Top level initially mermaid, gflow, sequenceDiagram and gantt | ||
var lvl1Keys = Object.keys(cnf); | ||
var i; | ||
for(i=0;i<lvl1Keys.length;i++){ | ||
if(typeof cnf[lvl1Keys[i]] === 'object' ){ | ||
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]); | ||
var j; | ||
for(j=0;j<lvl2Keys.length;j++) { | ||
log.debug('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]); | ||
if(typeof config[lvl1Keys[i]] === 'undefined'){ | ||
config[lvl1Keys[i]] = {}; | ||
} | ||
log.debug('Setting config: '+lvl1Keys[i]+' '+lvl2Keys[j]+' to '+cnf[lvl1Keys[i]][lvl2Keys[j]]); | ||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]]; | ||
} | ||
}else{ | ||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]]; | ||
var j | ||
for (j = 0; j < lvl2Keys.length; j++) { | ||
log.debug('Setting conf ', lvl1Keys[i], '-', lvl2Keys[j]) | ||
if (typeof config[lvl1Keys[i]] === 'undefined') { | ||
config[lvl1Keys[i]] = {} | ||
} | ||
log.debug('Setting config: ' + lvl1Keys[i] + ' ' + lvl2Keys[j] + ' to ' + cnf[lvl1Keys[i]][lvl2Keys[j]]) | ||
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]] | ||
} | ||
} else { | ||
config[lvl1Keys[i]] = cnf[lvl1Keys[i]] | ||
} | ||
}; | ||
} | ||
} | ||
exports.initialize = function(options){ | ||
log.debug('Initializing mermaidAPI'); | ||
// Update default config with options supplied at initialization | ||
if(typeof options === 'object'){ | ||
setConf(options); | ||
} | ||
Logger.setLogLevel(config.logLevel); | ||
exports.initialize = function (options) { | ||
log.debug('Initializing mermaidAPI') | ||
// Update default config with options supplied at initialization | ||
if (typeof options === 'object') { | ||
setConf(options) | ||
} | ||
Logger.setLogLevel(config.logLevel) | ||
} | ||
exports.getConfig = function () { | ||
return config | ||
} | ||
}; | ||
exports.getConfig = function(){ | ||
return config; | ||
}; | ||
exports.parseError = function(err, hash) { | ||
if(typeof mermaid !== 'undefined') { | ||
global.mermaid.parseError(err,hash); | ||
}else{ | ||
log.debug('Mermaid Syntax error:'); | ||
log.debug(err); | ||
} | ||
}; | ||
exports.parseError = function (err, hash) { | ||
if (typeof mermaid !== 'undefined') { | ||
global.mermaid.parseError(err, hash) | ||
} else { | ||
log.debug('Mermaid Syntax error:') | ||
log.debug(err) | ||
} | ||
} | ||
global.mermaidAPI = { | ||
render : exports.render, | ||
parse : exports.parse, | ||
initialize : exports.initialize, | ||
detectType : utils.detectType, | ||
parseError : exports.parseError, | ||
getConfig : exports.getConfig | ||
}; | ||
render: exports.render, | ||
parse: exports.parse, | ||
initialize: exports.initialize, | ||
detectType: utils.detectType, | ||
parseError: exports.parseError, | ||
getConfig: exports.getConfig | ||
} |
@@ -0,1 +1,2 @@ | ||
/* eslint-env jasmine */ | ||
/** | ||
@@ -7,69 +8,56 @@ * Created by knut on 14-11-26. | ||
*/ | ||
var api = require('./mermaidAPI.js'); | ||
//var log = require('./logger').create(); | ||
var api = require('./mermaidAPI.js') | ||
describe('when using mermaidAPI and ',function() { | ||
describe('doing initialize ',function() { | ||
//var main; | ||
//var document; | ||
//var window; | ||
beforeEach(function () { | ||
//var MockBrowser = require('mock-browser').mocks.MockBrowser; | ||
//var mock = new MockBrowser(); | ||
describe('when using mermaidAPI and ', function () { | ||
describe('doing initialize ', function () { | ||
beforeEach(function () { | ||
delete global.mermaid_config | ||
document.body.innerHTML = '' | ||
}) | ||
delete global.mermaid_config; | ||
it('should copy a literal into the configuration', function () { | ||
var orgConfig = api.getConfig() | ||
expect(orgConfig.testLiteral).toBe(undefined) | ||
// and in the run-code inside some object | ||
//global.document = mock.getDocument(); | ||
//global.window = mock.getWindow(); | ||
document.body.innerHTML = ''; | ||
}); | ||
api.initialize({ 'testLiteral': true }) | ||
var config = api.getConfig() | ||
it('should copy a literal into the configuration', function () { | ||
var orgConfig = api.getConfig(); | ||
expect(orgConfig.testLiteral).toBe(undefined); | ||
expect(config.testLiteral).toBe(true) | ||
}) | ||
it('should copy a an object into the configuration', function () { | ||
var orgConfig = api.getConfig() | ||
expect(orgConfig.testObject).toBe(undefined) | ||
api.initialize({'testLiteral':true}); | ||
var config = api.getConfig(); | ||
var object = { | ||
test1: 1, | ||
test2: false | ||
} | ||
expect(config.testLiteral).toBe(true); | ||
}); | ||
it('should copy a an object into the configuration', function () { | ||
var orgConfig = api.getConfig(); | ||
expect(orgConfig.testObject).toBe(undefined); | ||
api.initialize({ 'testObject': object }) | ||
api.initialize({ 'testObject': { 'test3': true } }) | ||
var config = api.getConfig() | ||
var object = { | ||
test1:1, | ||
test2:false | ||
}; | ||
api.initialize({'testObject':object}); | ||
api.initialize({'testObject':{'test3':true}}); | ||
var config = api.getConfig(); | ||
expect(config.testObject.test1).toBe(1) | ||
expect(config.testObject.test2).toBe(false) | ||
expect(config.testObject.test3).toBe(true) | ||
expect(config.cloneCssStyles).toBe(orgConfig.cloneCssStyles) | ||
}) | ||
}) | ||
describe('checking validity of input ', function () { | ||
it('it should return false for an invalid definiton', function () { | ||
global.mermaidAPI.parseError = function () { } | ||
spyOn(global.mermaidAPI, 'parseError') | ||
var res = api.parse('this is not a mermaid diagram definition') | ||
expect(config.testObject.test1).toBe(1); | ||
expect(config.testObject.test2).toBe(false); | ||
expect(config.testObject.test3).toBe(true); | ||
expect(config.cloneCssStyles).toBe(orgConfig.cloneCssStyles); | ||
}); | ||
expect(res).toBe(false) | ||
expect(global.mermaidAPI.parseError).toHaveBeenCalled() | ||
}) | ||
it('it should return true for a valid definiton', function () { | ||
spyOn(global.mermaidAPI, 'parseError') | ||
var res = api.parse('graph TD;A--x|text including URL space|B;') | ||
}); | ||
describe('checking validity of input ', function(){ | ||
it('it should return false for an invalid definiton',function(){ | ||
global.mermaidAPI.parseError= function(){}; | ||
spyOn(global.mermaidAPI,'parseError'); | ||
var res = api.parse('this is not a mermaid diagram definition'); | ||
expect(res).toBe(false); | ||
expect(global.mermaidAPI.parseError).toHaveBeenCalled(); | ||
}); | ||
it('it should return true for a valid definiton',function(){ | ||
spyOn(global.mermaidAPI,'parseError'); | ||
var res = api.parse('graph TD;A--x|text including URL space|B;'); | ||
expect(res).toBe(true); | ||
expect(global.mermaidAPI.parseError).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); | ||
expect(res).toBe(true) | ||
expect(global.mermaidAPI.parseError).not.toHaveBeenCalled() | ||
}) | ||
}) | ||
}) |
196
src/utils.js
/** | ||
* Created by knut on 14-11-23. | ||
*/ | ||
var Logger = require('./logger'); | ||
var log = new Logger.Log(); | ||
var Logger = require('./logger') | ||
var log = Logger.Log | ||
@@ -24,35 +24,32 @@ /** | ||
*/ | ||
var detectType = function(text){ | ||
text = text.replace(/^\s*%%.*\n/g,'\n'); | ||
if(text.match(/^\s*sequenceDiagram/)){ | ||
return 'sequenceDiagram'; | ||
} | ||
var detectType = function (text) { | ||
text = text.replace(/^\s*%%.*\n/g, '\n') | ||
if (text.match(/^\s*sequenceDiagram/)) { | ||
return 'sequenceDiagram' | ||
} | ||
if(text.match(/^\s*digraph/)) { | ||
//log.debug('Detected dot syntax'); | ||
return 'dotGraph'; | ||
} | ||
if (text.match(/^\s*digraph/)) { | ||
return 'dotGraph' | ||
} | ||
if(text.match(/^\s*info/)) { | ||
//log.debug('Detected info syntax'); | ||
return 'info'; | ||
} | ||
if (text.match(/^\s*info/)) { | ||
return 'info' | ||
} | ||
if(text.match(/^\s*gantt/)) { | ||
//log.debug('Detected info syntax'); | ||
return 'gantt'; | ||
} | ||
if (text.match(/^\s*gantt/)) { | ||
return 'gantt' | ||
} | ||
if(text.match(/^\s*classDiagram/)) { | ||
log.debug('Detected classDiagram syntax'); | ||
return 'classDiagram'; | ||
} | ||
if (text.match(/^\s*classDiagram/)) { | ||
log.debug('Detected classDiagram syntax') | ||
return 'classDiagram' | ||
} | ||
if(text.match(/^\s*gitGraph/)) { | ||
log.debug('Detected gitGraph syntax'); | ||
return 'gitGraph'; | ||
} | ||
return 'graph'; | ||
}; | ||
exports.detectType= detectType; | ||
if (text.match(/^\s*gitGraph/)) { | ||
log.debug('Detected gitGraph syntax') | ||
return 'gitGraph' | ||
} | ||
return 'graph' | ||
} | ||
exports.detectType = detectType | ||
@@ -65,81 +62,78 @@ /** | ||
*/ | ||
var cloneCssStyles = function(svg, classes){ | ||
var usedStyles = ''; | ||
var sheets = document.styleSheets; | ||
var rule; | ||
for (var i = 0; i < sheets.length; i++) { | ||
// Avoid multiple inclusion on pages with multiple graphs | ||
if (sheets[i].title !== 'mermaid-svg-internal-css') { | ||
try { | ||
var rules = sheets[i].cssRules; | ||
if (rules !== null) { | ||
for (var j = 0; j < rules.length; j++) { | ||
rule = rules[j]; | ||
if (typeof(rule.style) !== 'undefined') { | ||
var elems; | ||
elems = svg.querySelectorAll(rule.selectorText); | ||
if (elems.length > 0) { | ||
usedStyles += rule.selectorText + ' { ' + rule.style.cssText + '}\n'; | ||
} | ||
} | ||
} | ||
} | ||
var cloneCssStyles = function (svg, classes) { | ||
var usedStyles = '' | ||
var sheets = document.styleSheets | ||
var rule | ||
for (var i = 0; i < sheets.length; i++) { | ||
// Avoid multiple inclusion on pages with multiple graphs | ||
if (sheets[i].title !== 'mermaid-svg-internal-css') { | ||
try { | ||
var rules = sheets[i].cssRules | ||
if (rules !== null) { | ||
for (var j = 0; j < rules.length; j++) { | ||
rule = rules[j] | ||
if (typeof (rule.style) !== 'undefined') { | ||
var elems | ||
elems = svg.querySelectorAll(rule.selectorText) | ||
if (elems.length > 0) { | ||
usedStyles += rule.selectorText + ' { ' + rule.style.cssText + '}\n' | ||
} | ||
} | ||
catch (err) { | ||
if (typeof(rule) !== 'undefined') { | ||
log.warn('Invalid CSS selector "' + rule.selectorText + '"', err); | ||
} | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
if (typeof (rule) !== 'undefined') { | ||
log.warn('Invalid CSS selector "' + rule.selectorText + '"', err) | ||
} | ||
} | ||
} | ||
} | ||
var defaultStyles = ''; | ||
var embeddedStyles = ''; | ||
var defaultStyles = '' | ||
var embeddedStyles = '' | ||
for (var className in classes) { | ||
if (classes.hasOwnProperty(className) && typeof(className) != 'undefined') { | ||
if (className === 'default') { | ||
if (classes.default.styles instanceof Array) { | ||
defaultStyles += '#' + svg.id.trim() + ' .node' + '>rect { ' + classes[className].styles.join('; ') + '; }\n'; | ||
} | ||
if (classes.default.nodeLabelStyles instanceof Array) { | ||
defaultStyles += '#' + svg.id.trim() + ' .node text ' + ' { ' + classes[className].nodeLabelStyles.join('; ') + '; }\n'; | ||
} | ||
if (classes.default.edgeLabelStyles instanceof Array) { | ||
defaultStyles += '#' + svg.id.trim() + ' .edgeLabel text ' + ' { ' + classes[className].edgeLabelStyles.join('; ') + '; }\n'; | ||
} | ||
if (classes.default.clusterStyles instanceof Array) { | ||
defaultStyles += '#' + svg.id.trim() + ' .cluster rect ' + ' { ' + classes[className].clusterStyles.join('; ') + '; }\n'; | ||
} | ||
} else { | ||
if (classes[className].styles instanceof Array) { | ||
embeddedStyles += '#' + svg.id.trim() + ' .' + className + '>rect, .' + className + '>polygon, .' + className + '>circle, .' + className + '>ellipse { ' + classes[className].styles.join('; ') + '; }\n'; | ||
} | ||
} | ||
for (var className in classes) { | ||
if (classes.hasOwnProperty(className) && typeof (className) !== 'undefined') { | ||
if (className === 'default') { | ||
if (classes.default.styles instanceof Array) { | ||
defaultStyles += '#' + svg.id.trim() + ' .node' + '>rect { ' + classes[className].styles.join('; ') + '; }\n' | ||
} | ||
} | ||
if (usedStyles !== '' || defaultStyles !== '' || embeddedStyles !== '') { | ||
var s = document.createElement('style'); | ||
s.setAttribute('type', 'text/css'); | ||
s.setAttribute('title', 'mermaid-svg-internal-css'); | ||
s.innerHTML = '/* <![CDATA[ */\n'; | ||
// Make this CSS local to this SVG | ||
if (defaultStyles !== '') { | ||
s.innerHTML += defaultStyles; | ||
if (classes.default.nodeLabelStyles instanceof Array) { | ||
defaultStyles += '#' + svg.id.trim() + ' .node text ' + ' { ' + classes[className].nodeLabelStyles.join('; ') + '; }\n' | ||
} | ||
if (usedStyles !== '') { | ||
s.innerHTML += usedStyles; | ||
if (classes.default.edgeLabelStyles instanceof Array) { | ||
defaultStyles += '#' + svg.id.trim() + ' .edgeLabel text ' + ' { ' + classes[className].edgeLabelStyles.join('; ') + '; }\n' | ||
} | ||
if (embeddedStyles !== '') { | ||
s.innerHTML += embeddedStyles; | ||
if (classes.default.clusterStyles instanceof Array) { | ||
defaultStyles += '#' + svg.id.trim() + ' .cluster rect ' + ' { ' + classes[className].clusterStyles.join('; ') + '; }\n' | ||
} | ||
s.innerHTML += '/* ]]> */\n'; | ||
svg.insertBefore(s, svg.firstChild); | ||
} else { | ||
if (classes[className].styles instanceof Array) { | ||
embeddedStyles += '#' + svg.id.trim() + ' .' + className + '>rect, .' + className + '>polygon, .' + className + '>circle, .' + className + '>ellipse { ' + classes[className].styles.join('; ') + '; }\n' | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
exports.cloneCssStyles = cloneCssStyles; | ||
if (usedStyles !== '' || defaultStyles !== '' || embeddedStyles !== '') { | ||
var s = document.createElement('style') | ||
s.setAttribute('type', 'text/css') | ||
s.setAttribute('title', 'mermaid-svg-internal-css') | ||
s.innerHTML = '/* <![CDATA[ */\n' | ||
// Make this CSS local to this SVG | ||
if (defaultStyles !== '') { | ||
s.innerHTML += defaultStyles | ||
} | ||
if (usedStyles !== '') { | ||
s.innerHTML += usedStyles | ||
} | ||
if (embeddedStyles !== '') { | ||
s.innerHTML += embeddedStyles | ||
} | ||
s.innerHTML += '/* ]]> */\n' | ||
svg.insertBefore(s, svg.firstChild) | ||
} | ||
} | ||
exports.cloneCssStyles = cloneCssStyles | ||
@@ -155,7 +149,7 @@ /** | ||
for (var i = 0; i < arr.length; i++) { | ||
if (arr[i].match(str)) return i; | ||
if (arr[i].match(str)) return i | ||
} | ||
return -1; | ||
}; | ||
return -1 | ||
} | ||
exports.isSubstringInArray = isSubstringInArray; | ||
exports.isSubstringInArray = isSubstringInArray |
@@ -0,216 +1,204 @@ | ||
/* eslint-env jasmine */ | ||
/** | ||
* Created by knut on 14-11-23. | ||
*/ | ||
var utils = require('./utils'); | ||
var utils = require('./utils') | ||
//var log = require('./logger').create(); | ||
describe('when detecting chart type ', function () { | ||
var str; | ||
beforeEach(function () { | ||
var str | ||
it('should handle a graph defintion', function () { | ||
str = 'graph TB\nbfs1:queue' | ||
}); | ||
var type = utils.detectType(str) | ||
expect(type).toBe('graph') | ||
}) | ||
it('should handle a graph defintion with leading spaces', function () { | ||
str = ' graph TB\nbfs1:queue' | ||
it('should handle a graph defintion', function () { | ||
str = 'graph TB\nbfs1:queue'; | ||
var type = utils.detectType(str) | ||
expect(type).toBe('graph') | ||
}) | ||
var type = utils.detectType(str); | ||
expect(type).toBe('graph'); | ||
}); | ||
it('should handle a graph defintion with leading spaces', function () { | ||
str = ' graph TB\nbfs1:queue'; | ||
it('should handle a graph defintion with leading spaces and newline', function () { | ||
str = ' \n graph TB\nbfs1:queue' | ||
var type = utils.detectType(str); | ||
expect(type).toBe('graph'); | ||
}); | ||
var type = utils.detectType(str) | ||
expect(type).toBe('graph') | ||
}) | ||
it('should handle a graph defintion for gitGraph', function () { | ||
str = ' \n gitGraph TB:\nbfs1:queue' | ||
it('should handle a graph defintion with leading spaces and newline', function () { | ||
str = ' \n graph TB\nbfs1:queue'; | ||
var type = utils.detectType(str) | ||
expect(type).toBe('gitGraph') | ||
}) | ||
}) | ||
var type = utils.detectType(str); | ||
expect(type).toBe('graph'); | ||
}); | ||
it('should handle a graph defintion for gitGraph', function () { | ||
str = ' \n gitGraph TB:\nbfs1:queue'; | ||
var type = utils.detectType(str); | ||
expect(type).toBe('gitGraph'); | ||
}); | ||
}); | ||
describe('when cloning CSS ', function () { | ||
beforeEach(function () { | ||
document.body.innerHTML = '' | ||
}) | ||
function stylesToArray (svg) { | ||
var styleSheets = svg.getElementsByTagName('style') | ||
expect(styleSheets.length).toBe(1) | ||
var styleSheet = styleSheets[0] | ||
beforeEach(function () { | ||
//var MockBrowser = require('mock-browser').mocks.MockBrowser; | ||
//var mock = new MockBrowser(); | ||
var innerStyle = styleSheet.innerHTML | ||
var styleArr = innerStyle.split('\n') | ||
// and in the run-code inside some object | ||
//global.document = mock.getDocument(); | ||
document.body.innerHTML = ''; | ||
// Remove first and last two lines to remove the CDATA | ||
expect(styleArr.length).toBeGreaterThan(2) | ||
var styleArrTrim = styleArr.slice(1, -2) | ||
}); | ||
// Remove all empty lines | ||
for (var i = 0; i < styleArrTrim.length; i++) { | ||
if (styleArrTrim[i].trim() === '') { | ||
styleArrTrim.splice(i, 1) | ||
i-- | ||
} | ||
styleArrTrim[i] = styleArrTrim[i].trim() | ||
} | ||
function stylesToArray(svg) { | ||
var styleSheets = svg.getElementsByTagName('style'); | ||
expect(styleSheets.length).toBe(1); | ||
var styleSheet = styleSheets[0]; | ||
return styleArrTrim | ||
} | ||
var innerStyle = styleSheet.innerHTML; | ||
var styleArr = innerStyle.split('\n'); | ||
function addStyleToDocument () { | ||
var s = document.createElement('style') | ||
s.innerHTML = '.node { stroke:rgb(238, 238, 238); }\n.node-square { stroke:rgb(187, 187, 187); }\n' | ||
document.body.appendChild(s) | ||
} | ||
// Remove first and last two lines to remove the CDATA | ||
expect(styleArr.length).toBeGreaterThan(2); | ||
var styleArrTrim = styleArr.slice(1, -2); | ||
function addSecondStyleToDocument () { | ||
var s = document.createElement('style') | ||
s.innerHTML = '.node2 { stroke:rgb(238, 238, 238); }\n.node-square { stroke:#beb; }\n' | ||
document.body.appendChild(s) | ||
} | ||
// Remove all empty lines | ||
for (var i = 0; i < styleArrTrim.length; i++) { | ||
if (styleArrTrim[i].trim() === '') { | ||
styleArrTrim.splice(i, 1); | ||
i--; | ||
} | ||
styleArrTrim[i] = styleArrTrim[i].trim(); | ||
} | ||
function generateSVG () { | ||
var svg = document.createElement('svg') | ||
svg.setAttribute('id', 'mermaid-01') | ||
var g1 = document.createElement('g') | ||
g1.setAttribute('class', 'node') | ||
svg.appendChild(g1) | ||
var g2 = document.createElement('g') | ||
g2.setAttribute('class', 'node-square') | ||
svg.appendChild(g2) | ||
return svg | ||
} | ||
return styleArrTrim; | ||
} | ||
function addMermaidSVGwithStyleToDocument () { | ||
var styleSheetCount = document.styleSheets.length | ||
var svg = document.createElement('svg') | ||
svg.setAttribute('id', 'mermaid-03') | ||
var s = document.createElement('style') | ||
s.setAttribute('type', 'text/css') | ||
s.setAttribute('title', 'mermaid-svg-internal-css') | ||
s.innerHTML = '#mermaid-05 .node2 { stroke:#eee; }\n.node-square { stroke:#bfe; }\n' | ||
svg.appendChild(s) | ||
document.body.appendChild(svg) | ||
document.styleSheets[styleSheetCount].title = 'mermaid-svg-internal-css' | ||
} | ||
function addStyleToDocument() { | ||
var s = document.createElement('style'); | ||
s.innerHTML = '.node { stroke:#eeeeee; }\n.node-square { stroke:#bbbbbb; }\n'; | ||
document.body.appendChild(s); | ||
} | ||
it('should handle errors thrown when accessing CSS rules', function () { | ||
var svg = document.createElement('svg') | ||
svg.setAttribute('id', 'mermaid-01') | ||
function addSecondStyleToDocument() { | ||
var s = document.createElement('style'); | ||
s.innerHTML = '.node2 { stroke:#eeeeee; }\n.node-square { stroke:#beb; }\n'; | ||
document.body.appendChild(s); | ||
// Firefox throws a SecurityError when trying to access cssRules | ||
document.styleSheets[document.styleSheets.length++] = { | ||
get cssRules () { throw new Error('SecurityError') } | ||
} | ||
function generateSVG() { | ||
var svg = document.createElement('svg'); | ||
svg.setAttribute('id', 'mermaid-01'); | ||
var g1 = document.createElement('g'); | ||
g1.setAttribute('class', 'node'); | ||
svg.appendChild(g1); | ||
var g2 = document.createElement('g'); | ||
g2.setAttribute('class', 'node-square'); | ||
svg.appendChild(g2); | ||
return svg; | ||
} | ||
expect(function () { | ||
utils.cloneCssStyles(svg, {}) | ||
}).not.toThrow() | ||
}) | ||
function addMermaidSVGwithStyleToDocument() { | ||
var styleSheetCount = document.styleSheets.length; | ||
var svg = document.createElement('svg'); | ||
svg.setAttribute('id', 'mermaid-03'); | ||
var s = document.createElement('style'); | ||
s.setAttribute('type', 'text/css'); | ||
s.setAttribute('title', 'mermaid-svg-internal-css'); | ||
s.innerHTML = '#mermaid-05 .node2 { stroke:#eee; }\n.node-square { stroke:#bfe; }\n'; | ||
svg.appendChild(s); | ||
document.body.appendChild(svg); | ||
document.styleSheets[styleSheetCount].title = 'mermaid-svg-internal-css'; | ||
} | ||
it('should handle an empty set of classes', function () { | ||
var svg = document.createElement('svg') | ||
svg.setAttribute('id', 'mermaid-01') | ||
it('should handle errors thrown when accessing CSS rules', function() { | ||
var svg = document.createElement('svg'); | ||
svg.setAttribute('id', 'mermaid-01'); | ||
utils.cloneCssStyles(svg, {}) | ||
// Should not create style element if not needed | ||
expect(svg.innerHTML).toBe('') | ||
}) | ||
// Firefox throws a SecurityError when trying to access cssRules | ||
document.styleSheets[document.styleSheets.length++] = { | ||
get cssRules() { throw new Error('SecurityError'); } | ||
}; | ||
it('should handle a default class', function () { | ||
var svg = document.createElement('svg') | ||
svg.setAttribute('id', 'mermaid-01') | ||
expect(function() { | ||
utils.cloneCssStyles(svg, {}); | ||
}).not.toThrow(); | ||
}); | ||
utils.cloneCssStyles(svg, { 'default': { 'styles': ['stroke:#fff', 'stroke-width:1.5px'] } }) | ||
expect(stylesToArray(svg)).toEqual(['#mermaid-01 .node>rect { stroke:#fff; stroke-width:1.5px; }']) | ||
// Also verify the elements around the styling | ||
expect(svg.innerHTML).toBe('<style type="text/css" title="mermaid-svg-internal-css">/* <![CDATA[ */\n#mermaid-01 .node>rect { stroke:#fff; stroke-width:1.5px; }\n/* ]]> */\n</style>') | ||
}) | ||
it('should handle an empty set of classes', function () { | ||
var svg = document.createElement('svg'); | ||
svg.setAttribute('id', 'mermaid-01'); | ||
it('should handle stylesheet in document with no classes in SVG', function () { | ||
var svg = document.createElement('svg') | ||
svg.setAttribute('id', 'mermaid-01') | ||
utils.cloneCssStyles(svg, {}); | ||
// Should not create style element if not needed | ||
expect(svg.innerHTML).toBe(''); | ||
}); | ||
addStyleToDocument('mermaid') | ||
utils.cloneCssStyles(svg, {}) | ||
// Should not create style element if not needed | ||
expect(svg.innerHTML).toBe('') | ||
}) | ||
it('should handle a default class', function () { | ||
var svg = document.createElement('svg'); | ||
svg.setAttribute('id', 'mermaid-01'); | ||
it('should handle stylesheet in document with classes in SVG', function () { | ||
var svg = generateSVG() | ||
addStyleToDocument() | ||
utils.cloneCssStyles(svg, {}) | ||
expect(stylesToArray(svg)).toEqual(['.node { stroke: rgb(238, 238, 238);}', '.node-square { stroke: rgb(187, 187, 187);}']) | ||
}) | ||
utils.cloneCssStyles(svg, {'default': {'styles': ['stroke:#fff', 'stroke-width:1.5px']}}); | ||
expect(stylesToArray(svg)).toEqual(['#mermaid-01 .node>rect { stroke:#fff; stroke-width:1.5px; }']); | ||
// Also verify the elements around the styling | ||
expect(svg.innerHTML).toBe('<style type="text/css" title="mermaid-svg-internal-css">/* <![CDATA[ */\n#mermaid-01 .node>rect { stroke:#fff; stroke-width:1.5px; }\n/* ]]> */\n</style>'); | ||
}); | ||
it('should handle multiple stylesheets in document with classes in SVG', function () { | ||
var svg = generateSVG() | ||
addStyleToDocument() | ||
addSecondStyleToDocument() | ||
utils.cloneCssStyles(svg, {}) | ||
expect(stylesToArray(svg)).toEqual(['.node { stroke: rgb(238, 238, 238);}', '.node-square { stroke: rgb(187, 187, 187);}', '.node-square { stroke: rgb(187, 238, 187);}']) | ||
}) | ||
it('should handle stylesheet in document with no classes in SVG', function () { | ||
var svg = document.createElement('svg'); | ||
svg.setAttribute('id', 'mermaid-01'); | ||
it('should handle multiple stylesheets + ignore styles in other mermaid SVG', function () { | ||
var svg = generateSVG() | ||
addStyleToDocument() | ||
addSecondStyleToDocument() | ||
addMermaidSVGwithStyleToDocument() | ||
utils.cloneCssStyles(svg, {}) | ||
expect(stylesToArray(svg)).toEqual(['.node { stroke: rgb(238, 238, 238);}', '.node-square { stroke: rgb(187, 187, 187);}', '.node-square { stroke: rgb(187, 238, 187);}']) | ||
}) | ||
addStyleToDocument('mermaid'); | ||
utils.cloneCssStyles(svg, {}); | ||
// Should not create style element if not needed | ||
expect(svg.innerHTML).toBe(''); | ||
}); | ||
it('should handle a default class together with stylesheet in document with classes in SVG', function () { | ||
var svg = generateSVG() | ||
addStyleToDocument() | ||
utils.cloneCssStyles(svg, { 'default': { 'styles': ['stroke:#ffffff', 'stroke-width:1.5px'] } }) | ||
expect(stylesToArray(svg)).toEqual(['#mermaid-01 .node>rect { stroke:#ffffff; stroke-width:1.5px; }', '.node { stroke: rgb(238, 238, 238);}', '.node-square { stroke: rgb(187, 187, 187);}']) | ||
}) | ||
it('should handle stylesheet in document with classes in SVG', function () { | ||
var svg = generateSVG(); | ||
addStyleToDocument(); | ||
utils.cloneCssStyles(svg, {}); | ||
expect(stylesToArray(svg)).toEqual(['.node { stroke: #eeeeee;}', '.node-square { stroke: #bbbbbb;}']); | ||
}); | ||
it('should handle a default class together with stylesheet in document and classDefs', function () { | ||
var svg = generateSVG() | ||
addStyleToDocument() | ||
utils.cloneCssStyles(svg, { | ||
'default': { 'styles': ['stroke:#ffffff', 'stroke-width:1.5px'] }, | ||
'node-square': { 'styles': ['fill:rgb(238, 238, 238)', 'stroke:#aaaaaa'] }, | ||
'node-circle': { 'styles': ['fill:#444444', 'stroke:#111111'] } | ||
}) | ||
expect(stylesToArray(svg)).toEqual(['#mermaid-01 .node>rect { stroke:#ffffff; stroke-width:1.5px; }', | ||
'.node { stroke: rgb(238, 238, 238);}', | ||
'.node-square { stroke: rgb(187, 187, 187);}', | ||
'#mermaid-01 .node-square>rect, .node-square>polygon, .node-square>circle, .node-square>ellipse { fill:rgb(238, 238, 238); stroke:#aaaaaa; }', | ||
'#mermaid-01 .node-circle>rect, .node-circle>polygon, .node-circle>circle, .node-circle>ellipse { fill:#444444; stroke:#111111; }' | ||
]) | ||
}) | ||
}) | ||
it('should handle multiple stylesheets in document with classes in SVG', function () { | ||
var svg = generateSVG(); | ||
addStyleToDocument(); | ||
addSecondStyleToDocument(); | ||
utils.cloneCssStyles(svg, {}); | ||
expect(stylesToArray(svg)).toEqual(['.node { stroke: #eeeeee;}', '.node-square { stroke: #bbbbbb;}', '.node-square { stroke: #bbeebb;}']); | ||
}); | ||
it('should handle multiple stylesheets + ignore styles in other mermaid SVG', function () { | ||
var svg = generateSVG(); | ||
addStyleToDocument(); | ||
addSecondStyleToDocument(); | ||
addMermaidSVGwithStyleToDocument(); | ||
utils.cloneCssStyles(svg, {}); | ||
expect(stylesToArray(svg)).toEqual(['.node { stroke: #eeeeee;}', '.node-square { stroke: #bbbbbb;}', '.node-square { stroke: #bbeebb;}']); | ||
}); | ||
it('should handle a default class together with stylesheet in document with classes in SVG', function () { | ||
var svg = generateSVG(); | ||
addStyleToDocument(); | ||
utils.cloneCssStyles(svg, {'default': {'styles': ['stroke:#ffffff', 'stroke-width:1.5px']}}); | ||
expect(stylesToArray(svg)).toEqual(['#mermaid-01 .node>rect { stroke:#ffffff; stroke-width:1.5px; }', '.node { stroke: #eeeeee;}', '.node-square { stroke: #bbbbbb;}']); | ||
}); | ||
it('should handle a default class together with stylesheet in document and classDefs', function () { | ||
var svg = generateSVG(); | ||
addStyleToDocument(); | ||
utils.cloneCssStyles(svg, { | ||
'default': {'styles': ['stroke:#ffffff', 'stroke-width:1.5px']}, | ||
'node-square': {'styles': ['fill:#eeeeee', 'stroke:#aaaaaa']}, | ||
'node-circle': {'styles': ['fill:#444444', 'stroke:#111111']} | ||
}); | ||
expect(stylesToArray(svg)).toEqual(['#mermaid-01 .node>rect { stroke:#ffffff; stroke-width:1.5px; }', | ||
'.node { stroke: #eeeeee;}', | ||
'.node-square { stroke: #bbbbbb;}', | ||
'#mermaid-01 .node-square>rect, .node-square>polygon, .node-square>circle, .node-square>ellipse { fill:#eeeeee; stroke:#aaaaaa; }', | ||
'#mermaid-01 .node-circle>rect, .node-circle>polygon, .node-circle>circle, .node-circle>ellipse { fill:#444444; stroke:#111111; }' | ||
]); | ||
}); | ||
}); | ||
describe('when finding substring in array ', function () { | ||
it('should return the array index that contains the substring', function () { | ||
var arr = ['stroke:val1', 'fill:val2']; | ||
var result = utils.isSubstringInArray('fill', arr); | ||
expect(result).toEqual(1); | ||
}); | ||
it('should return -1 if the substring is not found in the array', function () { | ||
var arr = ['stroke:val1', 'stroke-width:val2']; | ||
var result = utils.isSubstringInArray('fill', arr); | ||
expect(result).toEqual(-1); | ||
}); | ||
}); | ||
it('should return the array index that contains the substring', function () { | ||
var arr = ['stroke:val1', 'fill:val2'] | ||
var result = utils.isSubstringInArray('fill', arr) | ||
expect(result).toEqual(1) | ||
}) | ||
it('should return -1 if the substring is not found in the array', function () { | ||
var arr = ['stroke:val1', 'stroke-width:val2'] | ||
var result = utils.isSubstringInArray('fill', arr) | ||
expect(result).toEqual(-1) | ||
}) | ||
}) |
@@ -1,55 +0,52 @@ | ||
var fs = require('fs') | ||
, path = require('path') | ||
const fs = require('fs') | ||
const path = require('path') | ||
var test = require('tape') | ||
, async = require('async') | ||
, clone = require('clone') | ||
, rimraf = require('rimraf') | ||
const test = require('tape') | ||
const async = require('async') | ||
const clone = require('clone') | ||
const rimraf = require('rimraf') | ||
var mermaid = require('../lib') | ||
const mermaid = require('../lib') | ||
var fileTestMermaid = path.join('test','fixtures','test.mermaid'); | ||
var isWin = /^win/.test(process.platform); | ||
var phantomCmd; | ||
if(isWin){ | ||
const fileTestMermaid = path.join('test', 'fixtures', 'test.mermaid') | ||
const isWin = /^win/.test(process.platform) | ||
let phantomCmd | ||
if (isWin) { | ||
phantomCmd = 'node_modules/.bin/phantomjs.cmd' | ||
console.log('is win') | ||
} | ||
else{ | ||
} else { | ||
phantomCmd = 'node_modules/.bin/phantomjs' | ||
} | ||
var singleFile = { | ||
files: [fileTestMermaid] | ||
, outputDir: path.join(process.cwd(),'test/tmp_single') | ||
, phantomPath: path.join(process.cwd(),phantomCmd) | ||
, width : 1200 | ||
, css: path.join(__dirname, '..', 'dist', 'mermaid.css') | ||
, sequenceConfig: null | ||
, ganttConfig: null | ||
} | ||
, multiFile = { | ||
files: [path.join('test','fixtures','test.mermaid'), | ||
path.join('test','fixtures','test2.mermaid'), | ||
path.join('test','fixtures','gantt.mermaid'), | ||
path.join('test','fixtures','sequence.mermaid'), | ||
] | ||
, outputDir: 'test/tmp_multi' | ||
, phantomPath: path.join(process.cwd(),phantomCmd) | ||
, width : 1200 | ||
, css: path.join(__dirname, '..', 'dist', 'mermaid.css') | ||
, sequenceConfig: null | ||
, ganttConfig: null | ||
} | ||
const singleFile = { | ||
files: [fileTestMermaid], | ||
outputDir: path.join(process.cwd(), 'test/tmp_single'), | ||
phantomPath: path.join(process.cwd(), phantomCmd), | ||
width: 1200, | ||
css: path.join(__dirname, '..', 'dist', 'mermaid.css'), | ||
sequenceConfig: null, | ||
ganttConfig: null | ||
} | ||
const multiFile = { | ||
files: [path.join('test', 'fixtures', 'test.mermaid'), | ||
path.join('test', 'fixtures', 'test2.mermaid'), | ||
path.join('test', 'fixtures', 'gantt.mermaid'), | ||
path.join('test', 'fixtures', 'sequence.mermaid') | ||
], | ||
outputDir: 'test/tmp_multi', | ||
phantomPath: path.join(process.cwd(), phantomCmd), | ||
width: 1200, | ||
css: path.join(__dirname, '..', 'dist', 'mermaid.css'), | ||
sequenceConfig: null, | ||
ganttConfig: null | ||
} | ||
test('output of single png', function(t) { | ||
test('output of single png', function (t) { | ||
t.plan(3) | ||
var expected = ['test.mermaid.png'] | ||
const expected = ['test.mermaid.png'] | ||
var opt = clone(singleFile) | ||
const opt = clone(singleFile) | ||
opt.outputDir += '_png' | ||
opt.png = true | ||
mermaid.process(opt.files, opt, function(code) { | ||
mermaid.process(opt.files, opt, function (code) { | ||
t.equal(code, 0, 'has clean exit code') | ||
@@ -61,13 +58,13 @@ | ||
test('output of multiple png', function(t) { | ||
test('output of multiple png', function (t) { | ||
t.plan(3) | ||
var expected = ['test.mermaid.png', 'test2.mermaid.png', | ||
const expected = ['test.mermaid.png', 'test2.mermaid.png', | ||
'gantt.mermaid.png', 'sequence.mermaid.png'] | ||
var opt = clone(multiFile) | ||
const opt = clone(multiFile) | ||
opt.outputDir += '_png' | ||
opt.png = true | ||
mermaid.process(opt.files, opt, function(code) { | ||
mermaid.process(opt.files, opt, function (code) { | ||
t.equal(code, 0, 'has clean exit code') | ||
@@ -79,12 +76,12 @@ | ||
test('output of single svg', function(t) { | ||
test('output of single svg', function (t) { | ||
t.plan(3) | ||
var expected = ['test.mermaid.svg'] | ||
const expected = ['test.mermaid.svg'] | ||
var opt = clone(singleFile) | ||
const opt = clone(singleFile) | ||
opt.outputDir += '_svg' | ||
opt.svg = true | ||
mermaid.process(opt.files, opt, function(code) { | ||
mermaid.process(opt.files, opt, function (code) { | ||
t.equal(code, 0, 'has clean exit code') | ||
@@ -96,13 +93,13 @@ | ||
test('output of multiple svg', function(t) { | ||
test('output of multiple svg', function (t) { | ||
t.plan(3) | ||
var expected = ['test.mermaid.svg', 'test2.mermaid.svg', | ||
const expected = ['test.mermaid.svg', 'test2.mermaid.svg', | ||
'gantt.mermaid.svg', 'sequence.mermaid.svg'] | ||
var opt = clone(multiFile) | ||
const opt = clone(multiFile) | ||
opt.outputDir += '_svg' | ||
opt.svg = true | ||
mermaid.process(opt.files, opt, function(code) { | ||
mermaid.process(opt.files, opt, function (code) { | ||
t.equal(code, 0, 'has clean exit code') | ||
@@ -114,11 +111,8 @@ | ||
test('output including CSS', function(t) { | ||
test('output including CSS', function (t) { | ||
t.plan(5) | ||
var expected = ['test.mermaid.png'] | ||
, opt = clone(singleFile) | ||
, opt2 = clone(singleFile) | ||
, filename | ||
, one | ||
, two | ||
const expected = ['test.mermaid.png'] | ||
const opt = clone(singleFile) | ||
const opt2 = clone(singleFile) | ||
@@ -130,14 +124,12 @@ opt.png = true | ||
mermaid.process(opt.files, opt, function(code) { | ||
mermaid.process(opt.files, opt, function (code) { | ||
t.equal(code, 0, 'has clean exit code') | ||
filename = path.join(opt.outputDir, path.basename(expected[0])) | ||
one = fs.statSync(filename) | ||
const filename = path.join(opt.outputDir, path.basename(expected[0])) | ||
const one = fs.statSync(filename) | ||
opt2.css = path.join('test','fixtures','test.css') | ||
opt2.css = path.join('test', 'fixtures', 'test.css') | ||
console.log('Generating #2'); | ||
mermaid.process(opt2.files, opt2, function(code) { | ||
mermaid.process(opt2.files, opt2, function (code) { | ||
t.equal(code, 0, 'has clean exit code') | ||
two = fs.statSync(filename) | ||
const two = fs.statSync(filename) | ||
t.notEqual(one.size, two.size) | ||
@@ -150,22 +142,19 @@ | ||
function verifyFiles(expected, dir, t) { | ||
function verifyFiles (expected, dir, t) { | ||
async.each( | ||
expected | ||
, function(file, cb) { | ||
filename = path.join(dir, path.basename(file)) | ||
//console.log('Expected filename:'+filename); | ||
fs.stat(filename, function(err, stat) { | ||
cb(err) | ||
}) | ||
} | ||
, function(err) { | ||
t.notOk(err, 'all files passed') | ||
var delete_tmps = true | ||
var _rimraf=delete_tmps ? rimraf : function(dir, f) { f(0); } | ||
_rimraf(dir, function(rmerr) { | ||
t.notOk(rmerr, 'cleaned up') | ||
t.end() | ||
}) | ||
} | ||
expected, function (file, cb) { | ||
const filename = path.join(dir, path.basename(file)) | ||
fs.stat(filename, function (err, stat) { | ||
cb(err) | ||
}) | ||
}, function (err) { | ||
t.notOk(err, 'all files passed') | ||
const deleteTmps = true | ||
const _rimraf = deleteTmps ? rimraf : function (dir, f) { f(0) } | ||
_rimraf(dir, function (rmerr) { | ||
t.notOk(rmerr, 'cleaned up') | ||
t.end() | ||
}) | ||
} | ||
) | ||
} |
@@ -1,12 +0,14 @@ | ||
var test = require('tape') | ||
, cliPath = '../lib/cli' | ||
const test = require('tape') | ||
test('parses multiple files', function(t) { | ||
t.plan(2) | ||
const cliPath = '../lib/cli' | ||
var cli = require(cliPath) | ||
, argv = ['example/file1.mermaid', 'file2.mermaid', 'file3.mermaid'] | ||
, expect = ['example/file1.mermaid', 'file2.mermaid', 'file3.mermaid'] | ||
test('parses multiple files', function (t) { | ||
t.plan(3) | ||
cli.parse(argv, function(err, msg, opt) { | ||
const cli = require(cliPath) | ||
const argv = ['example/file1.mermaid', 'file2.mermaid', 'file3.mermaid'] | ||
const expect = ['example/file1.mermaid', 'file2.mermaid', 'file3.mermaid'] | ||
cli.parse(argv, function (err, msg, opt) { | ||
t.ok(!err, 'no err') | ||
t.equal(opt.files.length, 3, 'should have 3 parameters') | ||
@@ -19,9 +21,10 @@ t.deepEqual(opt.files, expect, 'should match expected values') | ||
test('defaults to png', function(t) { | ||
t.plan(2) | ||
test('defaults to png', function (t) { | ||
t.plan(3) | ||
var cli = require(cliPath) | ||
, argv = ['example/file1.mermaid'] | ||
const cli = require(cliPath) | ||
const argv = ['example/file1.mermaid'] | ||
cli.parse(argv, function(err, msg, opt) { | ||
cli.parse(argv, function (err, msg, opt) { | ||
t.ok(!err, 'no err') | ||
t.ok(opt.png, 'png is set by default') | ||
@@ -34,10 +37,10 @@ t.notOk(opt.svg, 'svg is not set by default') | ||
test('setting svg unsets png', function(t) { | ||
t.plan(2) | ||
test('setting svg unsets png', function (t) { | ||
t.plan(3) | ||
var cli = require(cliPath) | ||
, argv = ['example/file1.mermaid', '-s'] | ||
const cli = require(cliPath) | ||
const argv = ['example/file1.mermaid', '-s'] | ||
cli.parse(argv, function(err, msg, opt) { | ||
cli.parse(argv, function (err, msg, opt) { | ||
t.ok(!err, 'no err') | ||
t.ok(opt.svg, 'svg is set when requested') | ||
@@ -50,9 +53,10 @@ t.notOk(opt.png, 'png is unset when svg is set') | ||
test('setting png and svg is allowed', function(t) { | ||
t.plan(2) | ||
test('setting png and svg is allowed', function (t) { | ||
t.plan(3) | ||
var cli = require(cliPath) | ||
, argv = ['example/file1.mermaid', '-s', '-p'] | ||
const cli = require(cliPath) | ||
const argv = ['example/file1.mermaid', '-s', '-p'] | ||
cli.parse(argv, function(err, msg, opt) { | ||
cli.parse(argv, function (err, msg, opt) { | ||
t.ok(!err, 'no err') | ||
t.ok(opt.png, 'png is set when requested') | ||
@@ -65,9 +69,10 @@ t.ok(opt.svg, 'svg is set when requested') | ||
test('setting an output directory succeeds', function(t) { | ||
t.plan(1) | ||
test('setting an output directory succeeds', function (t) { | ||
t.plan(2) | ||
var cli = require(cliPath) | ||
, argv = ['-o', 'example/'] | ||
const cli = require(cliPath) | ||
const argv = ['example/file1.mermaid', '-o', 'example/'] | ||
cli.parse(argv, function(err, msg, opt) { | ||
cli.parse(argv, function (err, msg, opt) { | ||
t.ok(!err, 'no err') | ||
t.equal(opt.outputDir, 'example/', 'output directory is set') | ||
@@ -78,8 +83,10 @@ t.end() | ||
test('not setting a css source file uses a default style', function(t) { | ||
t.plan(1) | ||
test('not setting a css source file uses a default style', function (t) { | ||
t.plan(2) | ||
var cli = require(cliPath) | ||
const cli = require(cliPath) | ||
const argv = ['example/file1.mermaid'] | ||
cli.parse([], function(err, msg, opt) { | ||
cli.parse(argv, function (err, msg, opt) { | ||
t.ok(!err, 'no err') | ||
t.ok(opt.css, 'css file is populated') | ||
@@ -90,9 +97,10 @@ t.end() | ||
test('setting a css source file succeeds', function(t) { | ||
t.plan(1) | ||
test('setting a css source file succeeds', function (t) { | ||
t.plan(2) | ||
var cli = require(cliPath) | ||
, argv = ['-t', 'test/fixtures/test.css'] | ||
const cli = require(cliPath) | ||
const argv = ['example/file1.mermaid', '-t', 'test/fixtures/test.css'] | ||
cli.parse(argv, function(err, msg, opt) { | ||
cli.parse(argv, function (err, msg, opt) { | ||
t.ok(!err, 'no err') | ||
t.ok(opt.css, 'css file is populated') | ||
@@ -103,9 +111,9 @@ t.end() | ||
test('setting an output directory incorrectly causes an error', function(t) { | ||
test('setting an output directory incorrectly causes an error', function (t) { | ||
t.plan(1) | ||
var cli = require(cliPath) | ||
, argv = ['-o'] | ||
const cli = require(cliPath) | ||
const argv = ['-o'] | ||
cli.parse(argv, function(err) { | ||
cli.parse(argv, function (err) { | ||
t.ok(err, 'an error is raised') | ||
@@ -117,10 +125,10 @@ | ||
test('a callback function is called after parsing', function(t) { | ||
t.plan(2) | ||
test('a callback function is called after parsing', function (t) { | ||
t.plan(3) | ||
var cli = require(cliPath) | ||
, argv = ['example/test.mermaid'] | ||
, expects = ['example/test.mermaid'] | ||
const cli = require(cliPath) | ||
const argv = ['example/file1.mermaid'] | ||
cli.parse(argv, function(err, msg, opts) { | ||
cli.parse(argv, function (err, msg, opts) { | ||
t.ok(!err, 'no err') | ||
t.ok(true, 'callback was called') | ||
@@ -127,0 +135,0 @@ t.deepEqual(argv, opts.files, 'options are as expected') |
@@ -1,42 +0,43 @@ | ||
'use strict'; | ||
var exec = require('child_process').exec; | ||
var path = require('path') | ||
const exec = require('child_process').exec | ||
const path = require('path') | ||
var test = require('tape') | ||
, rimraf = require('rimraf') | ||
const test = require('tape') | ||
const rimraf = require('rimraf') | ||
var test_dir = 'test/fixtures/samples/'.replace('/',path.sep) | ||
var phantomjs = 'node_modules/.bin/phantomjs '.replace('/',path.sep) | ||
var load_html_save_screenshot_png_scripts = test_dir+path.sep+'load_html_save_screenshot_png.phantomjs' | ||
const localSearchPath = './node_modules/.bin' + path.delimiter + process.env.PATH | ||
const testDir = 'test/fixtures/samples/'.replace('/', path.sep) | ||
const phantomjs = 'node_modules/.bin/phantomjs '.replace('/', path.sep) | ||
const loadHtmlSaveScreenshotPngScripts = testDir + path.sep + 'load_html_save_screenshot_png.phantomjs' | ||
rimraf.sync(test_dir+'*.actual.*'); | ||
rimraf.sync(testDir + '*.actual.*') | ||
function prepend_output_args(args) { | ||
return '--outputDir=' + test_dir + ' --outputSuffix=.actual' + args | ||
function prependOutputArgs (args) { | ||
return '--outputDir=' + testDir + ' --outputSuffix=.actual' + args | ||
} | ||
function exec_mermaid(args, verify) { | ||
var cmd = 'bin/mermaid.js ' + args | ||
exec_cmd(cmd, verify) | ||
function execMermaid (args, verify) { | ||
const cmd = 'bin/mermaid.js ' + args | ||
execCmd(cmd, verify) | ||
} | ||
function exec_phantomjs_to_load_html_save_screenshot_png(html, verify) { | ||
var cmd = (phantomjs + ' ' + load_html_save_screenshot_png_scripts + | ||
' ' + html + ' ' + html + '.actual.png'); | ||
exec_cmd(cmd, verify) | ||
function execPhantomjsToLoadHtmlSaveScreenshotPng (html, verify) { | ||
const cmd = (phantomjs + ' ' + loadHtmlSaveScreenshotPngScripts + | ||
' ' + html + ' ' + html + '.actual.png') | ||
execCmd(cmd, verify) | ||
} | ||
function exec_cmd(cmd, verify) { | ||
function execCmd (cmd, verify) { | ||
console.log('cmd: ', cmd) | ||
exec(cmd, | ||
{env: {PATH: './node_modules/.bin'+path.delimiter+process.env.PATH}}, | ||
function(error, stdout, stderr) { | ||
console.log('error:',error,'\nstdout:\n',stdout,'\nstderr:\n',stderr); | ||
verify(error, stdout, stderr); | ||
}); | ||
{ env: Object.assign({}, process.env, { PATH: localSearchPath }) }, | ||
function (error, stdout, stderr) { | ||
console.log('error:', error, '\nstdout:\n', stdout, '\nstderr:\n', stderr) | ||
verify(error, stdout, stderr) | ||
}) | ||
} | ||
function verify_no_error(t) { | ||
return function(error, stdout, stderr) { | ||
t.notOk(stderr, 'no error') | ||
function verifyNoError (t) { | ||
return function (error, stdout, stderr) { | ||
t.ok(!error, 'no error') | ||
t.notOk(stderr, 'no stderr') | ||
t.end() | ||
@@ -46,5 +47,6 @@ } | ||
function verify_error(t) { | ||
return function(error, stdout, stderr) { | ||
t.ok(stderr, 'should get error') | ||
function verifyError (t) { | ||
return function (error, stdout, stderr) { | ||
t.ok(!error, 'no error') | ||
t.ok(stderr, 'should get stderr') | ||
t.end() | ||
@@ -54,90 +56,89 @@ } | ||
test('mermaid cli help', function(t) { | ||
t.plan(1); | ||
var args = [ '--help' ] | ||
exec_mermaid(args.join(' '), verify_no_error(t)); | ||
}); | ||
test('mermaid cli help', function (t) { | ||
t.plan(2) | ||
const args = ['--help'] | ||
execMermaid(args.join(' '), verifyNoError(t)) | ||
}) | ||
test('mermaid cli help', function(t) { | ||
t.plan(1); | ||
var args = [ '--badopt' ] | ||
exec_mermaid(args.join(' '), verify_error(t)); | ||
}); | ||
test('mermaid cli help', function (t) { | ||
t.plan(2) | ||
const args = ['--badopt'] | ||
execMermaid(args.join(' '), verifyError(t)) | ||
}) | ||
test.skip('sequence syntax error', function(t) { | ||
t.plan(1); | ||
var args = [ '--svg', | ||
test_dir+'sequence_err.mmd' | ||
test.skip('sequence syntax error', function (t) { | ||
t.plan(2) | ||
const args = ['--svg', | ||
testDir + 'sequence_err.mmd' | ||
] | ||
exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t)); | ||
execMermaid(prependOutputArgs(args.join(' ')), verifyNoError(t)) | ||
}); | ||
['', 'fo', 'tspan', 'old'].forEach(function(textPlacement) { | ||
test('sequence svg text placelment: '+textPlacement, function(t) { | ||
t.plan(1); | ||
var args = [ '--svg', | ||
'--outputDir=' + test_dir, | ||
'--outputSuffix='+(textPlacement ? '_'+textPlacement : '')+'.actual', | ||
textPlacement ? '--sequenceConfig='+test_dir+'sequence_text_'+textPlacement+'.cfg' : '', | ||
test_dir+'sequence_text.mmd' | ||
['', 'fo', 'tspan', 'old'].forEach(function (textPlacement) { | ||
test('sequence svg text placement: ' + textPlacement, function (t) { | ||
t.plan(2) | ||
const args = ['--svg', | ||
'--outputDir=' + testDir, | ||
'--outputSuffix=' + (textPlacement ? '_' + textPlacement : '') + '.actual', | ||
textPlacement ? '--sequenceConfig=' + testDir + 'sequence_text_' + textPlacement + '.cfg' : '', | ||
testDir + 'sequence_text.mmd' | ||
] | ||
exec_mermaid(args.join(' '), verify_no_error(t)); | ||
execMermaid(args.join(' '), verifyNoError(t)) | ||
}) | ||
}); | ||
}) | ||
test('sequence png', function(t) { | ||
t.plan(1); | ||
var args = [ '--png', | ||
test_dir+'sequence_text.mmd' | ||
test('sequence png', function (t) { | ||
t.plan(2) | ||
const args = ['--png', | ||
testDir + 'sequence_text.mmd' | ||
] | ||
exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t)); | ||
}); | ||
execMermaid(prependOutputArgs(args.join(' ')), verifyNoError(t)) | ||
}) | ||
test('flowchart svg text', function(t) { | ||
t.plan(1); | ||
var args = [ '--svg', | ||
test('flowchart svg text', function (t) { | ||
t.plan(2) | ||
const args = ['--svg', | ||
'--css=dist/mermaid.css', | ||
'--width=500', | ||
test_dir+'flowchart_text.mmd' | ||
testDir + 'flowchart_text.mmd' | ||
] | ||
exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t)); | ||
execMermaid(prependOutputArgs(args.join(' ')), verifyNoError(t)) | ||
}); | ||
['svg', 'png'].forEach(function(format) { | ||
test('flowchart '+format+'text2', function(t) { | ||
t.plan(1); | ||
var args = [ '--'+format, | ||
'--css=dist/mermaid.forest.css', | ||
'--width=500', | ||
test_dir+'flowchart_text2.mmd' | ||
] | ||
exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t)); | ||
}) }); | ||
['svg', 'png'].forEach(function (format) { | ||
test('flowchart ' + format + 'text2', function (t) { | ||
t.plan(2) | ||
const args = ['--' + format, | ||
'--css=dist/mermaid.forest.css', | ||
'--width=500', | ||
testDir + 'flowchart_text2.mmd' | ||
] | ||
execMermaid(prependOutputArgs(args.join(' ')), verifyNoError(t)) | ||
}) | ||
}) | ||
test('gantt axis formatter svg', function(t) { | ||
t.plan(1); | ||
var args = [ '--svg', | ||
test('gantt axis formatter svg', function (t) { | ||
t.plan(2) | ||
const args = ['--svg', | ||
'--css=dist/mermaid.css', | ||
'--width=500', | ||
'--ganttConfig='+test_dir+'gantt_axis_formatter.cfg', | ||
test_dir+'gantt_axis_formatter.mmd' | ||
'--ganttConfig=' + testDir + 'gantt_axis_formatter.cfg', | ||
testDir + 'gantt_axis_formatter.mmd' | ||
] | ||
exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t)); | ||
}); | ||
execMermaid(prependOutputArgs(args.join(' ')), verifyNoError(t)) | ||
}) | ||
test('gitgraph sample svg', function(t) { | ||
t.plan(1); | ||
var args = [ '-s', '-v', | ||
test('gitgraph sample svg', function (t) { | ||
t.plan(2) | ||
const args = ['-s', '-v', | ||
'--width=500', | ||
test_dir+'gitgraph.mmd' | ||
testDir + 'gitgraph.mmd' | ||
] | ||
exec_mermaid(prepend_output_args(args.join(' ')), verify_no_error(t)); | ||
}); | ||
execMermaid(prependOutputArgs(args.join(' ')), verifyNoError(t)) | ||
}) | ||
test('load sample.html in phantomjs and save screenshot png', function(t) { | ||
t.plan(1); | ||
exec_phantomjs_to_load_html_save_screenshot_png(test_dir+'samples.html', | ||
verify_no_error(t)); | ||
}); | ||
test('load sample.html in phantomjs and save screenshot png', function (t) { | ||
t.plan(2) | ||
execPhantomjsToLoadHtmlSaveScreenshotPng(testDir + 'samples.html', | ||
verifyNoError(t)) | ||
}) |
/** | ||
* Created by knut on 2015-09-15. | ||
*/ | ||
var navApp = angular.module('navApp', []); | ||
var navApp = window.angular.module('navApp', []) | ||
navApp.controller('NavAppCtrl', function ($scope) { | ||
$scope.items = [ | ||
{'name': 'Ett', | ||
'url': 'cases/ett.html'}, | ||
{'name': 'Two', | ||
'url': 'cases/two.html'} | ||
]; | ||
$scope.items = [ | ||
{ | ||
'name': 'Ett', | ||
'url': 'cases/ett.html' | ||
}, | ||
{ | ||
'name': 'Two', | ||
'url': 'cases/two.html' | ||
} | ||
] | ||
$scope.frameUrl = "web.html" | ||
$scope.frameUrl = 'web.html' | ||
$scope.go = function(url){ | ||
alert(url); | ||
} | ||
}); | ||
$scope.go = function (url) { | ||
window.alert(url) | ||
} | ||
}) |
{ | ||
"mirrorActors":false | ||
"mirrorActors": false | ||
} |
/** | ||
* Created by knut on 14-11-03. | ||
*/ | ||
var tests = []; | ||
var tests = [] | ||
for (var file in window.__karma__.files) { | ||
if (window.__karma__.files.hasOwnProperty(file)) { | ||
if (/spec\.js$/.test(file)) { | ||
var file2 = file.substr(10,file.length-13); | ||
console.log('Testing with: '+file2); | ||
if (window.__karma__.files.hasOwnProperty(file)) { | ||
if (/spec\.js$/.test(file)) { | ||
var file2 = file.substr(10, file.length - 13) | ||
console.log('Testing with: ' + file2) | ||
tests.push(file2); | ||
// | ||
} | ||
tests.push(file2) | ||
} | ||
} | ||
} | ||
//tests.push('parser/flow.spec'); | ||
require.config({ | ||
// Karma serves files from '/base' | ||
baseUrl: '/base/src', | ||
// Karma serves files from '/base' | ||
baseUrl: '/base/src', | ||
// ask Require.js to load these files (all our tests) | ||
deps: tests, | ||
// ask Require.js to load these files (all our tests) | ||
deps: tests, | ||
// start test run, once Require.js is done | ||
callback: window.__karma__.start | ||
}); | ||
// start test run, once Require.js is done | ||
callback: window.__karma__.start | ||
}) |
@@ -9,8 +9,4 @@ { | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
"license": "MIT" | ||
} |
@@ -0,29 +1,30 @@ | ||
/* eslint-env qunit */ | ||
require.config({ | ||
paths: { | ||
mermaid: '../../dist/mermaid' | ||
}, | ||
shim: { | ||
mermaid: { | ||
exports: 'mermaid' | ||
} | ||
paths: { | ||
mermaid: '../../dist/mermaid' | ||
}, | ||
shim: { | ||
mermaid: { | ||
exports: 'mermaid' | ||
} | ||
}); | ||
} | ||
}) | ||
require([], function (){ | ||
QUnit.module('requireTest.html'); | ||
require([], function () { | ||
QUnit.module('requireTest.html') | ||
QUnit.test('using mermaid in requirejs', function (assert){ | ||
var done = assert.async(); | ||
require(['mermaid'], function (mermaid) { | ||
assert.ok(mermaid, 'mermaid is not null'); | ||
console.log(mermaid); | ||
mermaid.init(); | ||
assert.equal(window.d3.selectAll('path')[0].length, 8, | ||
'drew 8 paths'); | ||
done(); | ||
}); | ||
}); | ||
QUnit.test('using mermaid in requirejs', function (assert) { | ||
var done = assert.async() | ||
require(['mermaid'], function (mermaid) { | ||
assert.ok(mermaid, 'mermaid is not null') | ||
console.log(mermaid) | ||
mermaid.init() | ||
assert.equal(window.d3.selectAll('path')[0].length, 8, | ||
'drew 8 paths') | ||
done() | ||
}) | ||
}) | ||
QUnit.load(); | ||
QUnit.start(); | ||
}); | ||
QUnit.load() | ||
QUnit.start() | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
63
0
5
195
38
9
6224998
231
77865
+ Addeddagre-d3-renderer@0.1.6
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedd3@3.5.17(transitive)
+ Addeddagre-d3-renderer@0.1.6(transitive)
+ Addedgraphlib@2.1.8(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhe@1.2.0(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
- Removeddagre-d3@0.4.10
- Removedansi-regex@0.2.1(transitive)
- Removedansi-styles@1.1.0(transitive)
- Removedchalk@0.5.1(transitive)
- Removedd3@3.5.6(transitive)
- Removeddagre-d3@0.4.10(transitive)
- Removedhas-ansi@0.1.0(transitive)
- Removedhe@0.5.0(transitive)
- Removedsemver@4.3.6(transitive)
- Removedstrip-ansi@0.3.0(transitive)
- Removedsupports-color@0.2.0(transitive)
Updatedchalk@^1.1.3
Updatedd3@3.5.17
Updatedhe@^1.1.1
Updatedlodash@^4.17.4
Updatedminimist@^1.2.0
Updatedmkdirp@^0.5.1
Updatedmoment@^2.18.1
Updatedsemver@^5.3.0
Updatedwhich@^1.2.14