Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
<textarea id="recipeconfig" class="config-text" v-model="text" rows="20" cols="64" spellcheck="false"
placeholder="Converted recipe config will be shown here." readonly></textarea>
</div>
</div>
</div>

<div style="text-align: center; font-family: sans-serif;">
Advanced Options:
<span id="baseindex">
先頭のインデックス番号: <input v-model="num" placeholder="100" size="8">
</span>
</div>

<ul id="status" style="list-style-type: none; margin: 10px 50px;">
Expand Down Expand Up @@ -81,6 +89,13 @@
}
})

var baseindex = new Vue({
el: '#baseindex',
data: {
num: 100
}
})

var seilconfig = new Vue({
el: '#seilconfig',
data: {
Expand Down Expand Up @@ -163,7 +178,8 @@
},
computed: {
s2r: function () {
return new Converter(seilconfig.text, dst.selected);
idxbase = Number.parseInt(baseindex.num, 10);
return new Converter(seilconfig.text, dst.selected, idxbase);
}
}
})
Expand Down
11 changes: 6 additions & 5 deletions seil2recipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
*/

class Converter {
constructor(seilconfig, dst) {
constructor(seilconfig, dst, baseindex=1000) {
this.seilconfig = seilconfig;
this.conversions = [];
this.note = new Note(dst);
this.note = new Note(dst, baseindex);

this.convert();
}
Expand Down Expand Up @@ -134,13 +134,14 @@ Converter.defers = [];


class Note {
constructor(dst) {
constructor(dst, idxbase) {
this.indices = new Map(); // (prefix) -> (last index number)
this.params = new Map();
this.ifindex = new Map(); // (prefix) -> (interface) -> (index)
this.memo = new Map();
this.deps = new DependencySet();
this.dst = new Device(dst);
this.idxbase = idxbase;

this.memo.set('bridge.group', new Map());
this.memo.set('floatlink.interfaces', []);
Expand Down Expand Up @@ -310,7 +311,7 @@ class Conversion {
if (!zero_origin) {
// 前後にコンフィグを追加しやすいように 100, 200, 300, ... とする。
if (idx == null) {
idx = 100;
idx = this.note.idxbase;
} else {
idx += 100;
}
Expand Down Expand Up @@ -689,7 +690,7 @@ function beautify(recipe_lines) {
return 1;
}
} else if (!b[j]) {
retrun -1;
return -1;
}

const ma = a.substring(i).match(/^\d+/g);
Expand Down