linny-r 1.1.11 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linny-r",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "description": "Executable graphical language with WYSIWYG editor for MILP models",
5
5
  "main": "server.js",
6
6
  "scripts": {
package/server.js CHANGED
@@ -1236,13 +1236,13 @@ function serveStaticFile(res, path) {
1236
1236
  if(path.startsWith('/diagrams/')) {
1237
1237
  // Serve diagrams from the (main)/user/diagrams/ sub-directory
1238
1238
  logAction('Diagram: ' + path);
1239
- path = '/user' + path;
1239
+ path = WORKING_DIRECTORY + '/user' + path;
1240
1240
  } else {
1241
1241
  // Other files from the (main)/static/ subdirectory
1242
1242
  logAction('Static file: ' + path);
1243
- path = '/static' + path;
1243
+ path = MODULE_DIRECTORY + '/static' + path;
1244
1244
  }
1245
- fs.readFile(MODULE_DIRECTORY + path, (err, data) => {
1245
+ fs.readFile(path, (err, data) => {
1246
1246
  if(err) {
1247
1247
  console.log(err);
1248
1248
  res.writeHead(404);
@@ -171,7 +171,10 @@ class LinnyRModel {
171
171
  get legacyVersion() {
172
172
  // Return TRUE if the model as it has been loaded was not saved by
173
173
  // JavaScript Linny-R
174
- return this.version.indexOf('JS-') < 0;
174
+ const
175
+ vnl = this.version.split('.'),
176
+ legacy = vnl[0] === '0' || (vnl[0] === '1' && vnl.length > 3);
177
+ return legacy;
175
178
  }
176
179
 
177
180
  get newProcessCode() {
@@ -7188,11 +7191,14 @@ class Link {
7188
7191
  this.relative_rate.text = xmlDecoded(
7189
7192
  nodeContentByTag(node, 'relative-rate'));
7190
7193
  this.flow_delay.text = xmlDecoded(nodeContentByTag(node, 'delay'));
7191
- // NOTE: default share-of-cost for links in legacy Linny-R was 100%;
7192
- // this is dysfunctional in JS Linny-R => set to 0 if equal to 1
7193
7194
  this.share_of_cost = safeStrToFloat(
7194
7195
  nodeContentByTag(node, 'share-of-cost'), 0);
7195
- if(MODEL.legacyVersion && this.share_of_cost == 1) this.share_of_cost = 0;
7196
+ if(MODEL.legacyVersion) {
7197
+ // NOTE: default share-of-cost for links in legacy Linny-R was 100%;
7198
+ // this is dysfunctional in JS Linny-R => set to 0 if equal to 1
7199
+ this.flow_delay.text = '0';
7200
+ if(this.share_of_cost == 1) this.share_of_cost = 0;
7201
+ }
7196
7202
  this.comments = xmlDecoded(nodeContentByTag(node, 'notes'));
7197
7203
  if(IO_CONTEXT) {
7198
7204
  // Record that this link was included