thehogfather/pvsio-web — pull request #51 by edge7 (2014-01-04 11:41:11+00:00)
Title: Changed approach in processing Tag, further details in comments

In this new version of parserSpecification.js I've changed approach in processing tag:

In old version we processed string tag looking for fields using function like 'substring()' 'indexOf()' .

Now, we transform a string like:

%{"_block" : "BlockStart", "_id" : " tick", " _source" : " X0", "_target" : "X1", "_type": "Transition"}

in an object using JSON.parse(); this way we can get properties in an easier way, also deleting space both in keys and values we avoid problems which we had .
Example:
var initialTag = %{"_block" : "BlockStart", "_id" : " tick", " _source" : " X0", "_target" : "X1", "_type": "Transition"};
var stringJson = initialTag.substring(initialTag.indexOf('{') );
var objectBlock = JSON.parse(stringJson);
objectBlock = this.transformKeyAndValueAvoidingSpaces(objectBlock);
var source = objectBlock._source;
var target = objectBlock._target;
..

Note that this way we can add properties in the tag in an easy way.

In this commit there is also some code about parsing switch conditions, please don't look at that, I have to change that implementation properly to this new approach.