mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Adding adc2 & new temperature calibration proceedures. [WiP] (#361)
* Add rough calls to ADC2 [untested] * Using dual ADC injected modes * Start both ADCs * Move some IRQ's to ram exec * Stabilize PID a bit more * Add in ideas for tip type selection * Add tiptype formula / settings struct * Add function ids to the settings menu * Rough tip selection * Rough out new cal routine for simple tips * Hardware test is fairly close for first pass * Add Simple calibration case [UNTESTED] This adds the calibration option that uses boiling water to the calibration menu. This is untested, and may need gain adjustments before use. * Simple Cal Roughly working * Rough out advanced cal
This commit is contained in:
@@ -1,245 +1,245 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
<script src="translations_commons.js"></script>
|
||||
<title>TS100 Bitmap Editor</title>
|
||||
<style>
|
||||
.matrix {
|
||||
display: inline-block;
|
||||
padding: 0px 0px 1px 1px ;
|
||||
background-color: #666;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.matrix * {
|
||||
font-size:0;
|
||||
}
|
||||
.c {
|
||||
margin:1px 1px 0px 0px;
|
||||
display: inline-block;
|
||||
background-color: #fff;
|
||||
height:10px;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
.x {
|
||||
background-color: #000;
|
||||
}
|
||||
|
||||
.header {
|
||||
}
|
||||
|
||||
.data input, .data textarea {
|
||||
margin-top: 1em;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.actions {
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
var ink, pressed, ev;
|
||||
function mousedown(e) {
|
||||
c = window.event.target;
|
||||
classes = c.className.split(" ");
|
||||
if (classes.indexOf("c")<0) {
|
||||
return;
|
||||
}
|
||||
ink = classes.indexOf("x")<0;
|
||||
pressed = true;
|
||||
ev = e;
|
||||
enter(e);
|
||||
}
|
||||
|
||||
function mouseup(e) {
|
||||
ev = e;
|
||||
pressed = false;
|
||||
}
|
||||
|
||||
function enter(e) {
|
||||
if (!pressed) {
|
||||
return;
|
||||
}
|
||||
ev = e;
|
||||
c = window.event.target;
|
||||
paint(c, ink);
|
||||
stringFromMatrix();
|
||||
}
|
||||
|
||||
function paint(c, ink) {
|
||||
var cellInk = isInk(c);
|
||||
if (ink) {
|
||||
if (!cellInk) {
|
||||
c.className += " x";
|
||||
}
|
||||
} else {
|
||||
if (cellInk) {
|
||||
c.className = "c";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isInk(c) {
|
||||
try {
|
||||
var classes = c.className.split(" ");
|
||||
return classes.indexOf("x") >= 0;
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getMatrix() {
|
||||
return document.getElementById("matrix");
|
||||
}
|
||||
|
||||
function getCoordinatesFromId(str) {
|
||||
i = str.indexOf('_');
|
||||
return {
|
||||
row: parseInt(str.substring(1, i)),
|
||||
col: parseInt(str.substring(i+1))
|
||||
}
|
||||
}
|
||||
|
||||
function clearMatrix() {
|
||||
for (var r = 0; r < app.matrix.rows; r++) {
|
||||
for (var c = 0; c < app.matrix.cols; c++) {
|
||||
paint(getCell(r, c), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCell(row, col) {
|
||||
return document.getElementById("C"+row+"_"+col);
|
||||
}
|
||||
|
||||
function toMatrix(str) {
|
||||
app.encodedData = str;
|
||||
clearMatrix();
|
||||
var strs = str.split(/[ ,]/);
|
||||
var pair = false;
|
||||
var c = 0;
|
||||
var rs = 7;
|
||||
for (var i = 0; i<strs.length; i++) {
|
||||
var d = strs[i];
|
||||
if (d.length > 0) {
|
||||
if (startsWith(d, "0x")) {
|
||||
v = parseInt(d.substring(2), 16);
|
||||
} else {
|
||||
v = parseInt(d);
|
||||
}
|
||||
sv = padLeft(v.toString(2), "0", 8);
|
||||
for (r = 0; r < 8; r++) {
|
||||
paint(getCell(rs - r, c), sv.charAt(r) == '1');
|
||||
}
|
||||
c++;
|
||||
if (c >= app.matrix.cols) {
|
||||
c = 0;
|
||||
rs += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stringFromMatrix() {
|
||||
var str = "";
|
||||
var delim = "";
|
||||
var blocks = app.matrix.rows / 8;
|
||||
var rs = 7;
|
||||
for (var block = 0; block < blocks; block++) {
|
||||
for (var c = 0; c < app.matrix.cols; c++) {
|
||||
var b = 0;
|
||||
for (var r = 0; r < 8; r++) {
|
||||
var cell = document.getElementById("C"+(rs-r)+"_"+c);
|
||||
if (isInk(cell)) {
|
||||
b |= (1 << (7-r));
|
||||
}
|
||||
}
|
||||
str += delim + "0x" + padLeft(b.toString(16).toUpperCase(), "0", 2);
|
||||
delim = ",";
|
||||
}
|
||||
rs += 8;
|
||||
}
|
||||
app.encodedData = str;
|
||||
return str;
|
||||
}
|
||||
|
||||
function start() {
|
||||
app = new Vue({
|
||||
el : '#app',
|
||||
data : {
|
||||
matrix: {
|
||||
cols: 12,
|
||||
rows: 16
|
||||
},
|
||||
type: "big",
|
||||
encodedData: ""
|
||||
},
|
||||
methods : {
|
||||
VtoMatrix : function(val) {
|
||||
toMatrix(val);
|
||||
},
|
||||
|
||||
VchangeSize : function() {
|
||||
if (app.type == "big") {
|
||||
app.matrix.cols = 12;
|
||||
app.matrix.rows = 16;
|
||||
} else if (app.type == "small") {
|
||||
app.matrix.cols = 6;
|
||||
app.matrix.rows = 8;
|
||||
} else if (app.type == "icon") {
|
||||
app.matrix.cols = 16;
|
||||
app.matrix.rows = 16;
|
||||
} else if (app.type == "icon24") {
|
||||
app.matrix.cols = 24;
|
||||
app.matrix.rows = 16;
|
||||
} else if (app.type == "screen") {
|
||||
app.matrix.cols = 84;
|
||||
app.matrix.rows = 16;
|
||||
} else if (app.type == "fullscreen") {
|
||||
app.matrix.cols = 96;
|
||||
app.matrix.rows = 16;
|
||||
}
|
||||
stringFromMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
toMatrix("0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5C,0x5C,0x5C,0x5C,0x5C,0x5C,0x40,0x3F,0x00");
|
||||
}
|
||||
|
||||
window.onload=start;
|
||||
</script>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="header">
|
||||
<select v-model="type" v-on:change="VchangeSize()">
|
||||
<option value="small">Small Font (6x8)</option>
|
||||
<option value="big">Big Font (12x16)</option>
|
||||
<option value="icon">Icon (16x16)</option>
|
||||
<option value="icon24">Icon (24x16)</option>
|
||||
<option value="screen">Screen (84x16)</option>
|
||||
<option value="fullscreen">Full Screen (96x16)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="matrix" class="matrix" onmousedown="mousedown(this)" onmouseup="mouseup(this)" ondragstart="return false">
|
||||
<div :id="'R'+(r-1)" class="r" v-for="r in matrix.rows">
|
||||
<div :id="'C'+(r-1)+'_'+(c-1)" class="c" onmouseenter="enter(this)" v-for="c in matrix.cols"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<input type="button" value="Clear" onclick="clearMatrix();stringFromMatrix()">
|
||||
</div>
|
||||
<div class="data">
|
||||
<textarea v-model="encodedData" style="width:100%" v-on:change="VtoMatrix(encodedData)" rows=5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
<script src="translations_commons.js"></script>
|
||||
<title>TS100 Bitmap Editor</title>
|
||||
<style>
|
||||
.matrix {
|
||||
display: inline-block;
|
||||
padding: 0px 0px 1px 1px ;
|
||||
background-color: #666;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.matrix * {
|
||||
font-size:0;
|
||||
}
|
||||
.c {
|
||||
margin:1px 1px 0px 0px;
|
||||
display: inline-block;
|
||||
background-color: #fff;
|
||||
height:10px;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
.x {
|
||||
background-color: #000;
|
||||
}
|
||||
|
||||
.header {
|
||||
}
|
||||
|
||||
.data input, .data textarea {
|
||||
margin-top: 1em;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.actions {
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
var ink, pressed, ev;
|
||||
function mousedown(e) {
|
||||
c = window.event.target;
|
||||
classes = c.className.split(" ");
|
||||
if (classes.indexOf("c")<0) {
|
||||
return;
|
||||
}
|
||||
ink = classes.indexOf("x")<0;
|
||||
pressed = true;
|
||||
ev = e;
|
||||
enter(e);
|
||||
}
|
||||
|
||||
function mouseup(e) {
|
||||
ev = e;
|
||||
pressed = false;
|
||||
}
|
||||
|
||||
function enter(e) {
|
||||
if (!pressed) {
|
||||
return;
|
||||
}
|
||||
ev = e;
|
||||
c = window.event.target;
|
||||
paint(c, ink);
|
||||
stringFromMatrix();
|
||||
}
|
||||
|
||||
function paint(c, ink) {
|
||||
var cellInk = isInk(c);
|
||||
if (ink) {
|
||||
if (!cellInk) {
|
||||
c.className += " x";
|
||||
}
|
||||
} else {
|
||||
if (cellInk) {
|
||||
c.className = "c";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isInk(c) {
|
||||
try {
|
||||
var classes = c.className.split(" ");
|
||||
return classes.indexOf("x") >= 0;
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getMatrix() {
|
||||
return document.getElementById("matrix");
|
||||
}
|
||||
|
||||
function getCoordinatesFromId(str) {
|
||||
i = str.indexOf('_');
|
||||
return {
|
||||
row: parseInt(str.substring(1, i)),
|
||||
col: parseInt(str.substring(i+1))
|
||||
}
|
||||
}
|
||||
|
||||
function clearMatrix() {
|
||||
for (var r = 0; r < app.matrix.rows; r++) {
|
||||
for (var c = 0; c < app.matrix.cols; c++) {
|
||||
paint(getCell(r, c), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCell(row, col) {
|
||||
return document.getElementById("C"+row+"_"+col);
|
||||
}
|
||||
|
||||
function toMatrix(str) {
|
||||
app.encodedData = str;
|
||||
clearMatrix();
|
||||
var strs = str.split(/[ ,]/);
|
||||
var pair = false;
|
||||
var c = 0;
|
||||
var rs = 7;
|
||||
for (var i = 0; i<strs.length; i++) {
|
||||
var d = strs[i];
|
||||
if (d.length > 0) {
|
||||
if (startsWith(d, "0x")) {
|
||||
v = parseInt(d.substring(2), 16);
|
||||
} else {
|
||||
v = parseInt(d);
|
||||
}
|
||||
sv = padLeft(v.toString(2), "0", 8);
|
||||
for (r = 0; r < 8; r++) {
|
||||
paint(getCell(rs - r, c), sv.charAt(r) == '1');
|
||||
}
|
||||
c++;
|
||||
if (c >= app.matrix.cols) {
|
||||
c = 0;
|
||||
rs += 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stringFromMatrix() {
|
||||
var str = "";
|
||||
var delim = "";
|
||||
var blocks = app.matrix.rows / 8;
|
||||
var rs = 7;
|
||||
for (var block = 0; block < blocks; block++) {
|
||||
for (var c = 0; c < app.matrix.cols; c++) {
|
||||
var b = 0;
|
||||
for (var r = 0; r < 8; r++) {
|
||||
var cell = document.getElementById("C"+(rs-r)+"_"+c);
|
||||
if (isInk(cell)) {
|
||||
b |= (1 << (7-r));
|
||||
}
|
||||
}
|
||||
str += delim + "0x" + padLeft(b.toString(16).toUpperCase(), "0", 2);
|
||||
delim = ",";
|
||||
}
|
||||
rs += 8;
|
||||
}
|
||||
app.encodedData = str;
|
||||
return str;
|
||||
}
|
||||
|
||||
function start() {
|
||||
app = new Vue({
|
||||
el : '#app',
|
||||
data : {
|
||||
matrix: {
|
||||
cols: 12,
|
||||
rows: 16
|
||||
},
|
||||
type: "big",
|
||||
encodedData: ""
|
||||
},
|
||||
methods : {
|
||||
VtoMatrix : function(val) {
|
||||
toMatrix(val);
|
||||
},
|
||||
|
||||
VchangeSize : function() {
|
||||
if (app.type == "big") {
|
||||
app.matrix.cols = 12;
|
||||
app.matrix.rows = 16;
|
||||
} else if (app.type == "small") {
|
||||
app.matrix.cols = 6;
|
||||
app.matrix.rows = 8;
|
||||
} else if (app.type == "icon") {
|
||||
app.matrix.cols = 16;
|
||||
app.matrix.rows = 16;
|
||||
} else if (app.type == "icon24") {
|
||||
app.matrix.cols = 24;
|
||||
app.matrix.rows = 16;
|
||||
} else if (app.type == "screen") {
|
||||
app.matrix.cols = 84;
|
||||
app.matrix.rows = 16;
|
||||
} else if (app.type == "fullscreen") {
|
||||
app.matrix.cols = 96;
|
||||
app.matrix.rows = 16;
|
||||
}
|
||||
stringFromMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
toMatrix("0x00,0xF0,0x08,0x0E,0x02,0x02,0x02,0x02,0x0E,0x08,0xF0,0x00,0x00,0x3F,0x40,0x5C,0x5C,0x5C,0x5C,0x5C,0x5C,0x40,0x3F,0x00");
|
||||
}
|
||||
|
||||
window.onload=start;
|
||||
</script>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="header">
|
||||
<select v-model="type" v-on:change="VchangeSize()">
|
||||
<option value="small">Small Font (6x8)</option>
|
||||
<option value="big">Big Font (12x16)</option>
|
||||
<option value="icon">Icon (16x16)</option>
|
||||
<option value="icon24">Icon (24x16)</option>
|
||||
<option value="screen">Screen (84x16)</option>
|
||||
<option value="fullscreen">Full Screen (96x16)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="matrix" class="matrix" onmousedown="mousedown(this)" onmouseup="mouseup(this)" ondragstart="return false">
|
||||
<div :id="'R'+(r-1)" class="r" v-for="r in matrix.rows">
|
||||
<div :id="'C'+(r-1)+'_'+(c-1)" class="c" onmouseenter="enter(this)" v-for="c in matrix.cols"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<input type="button" value="Clear" onclick="clearMatrix();stringFromMatrix()">
|
||||
</div>
|
||||
<div class="data">
|
||||
<textarea v-model="encodedData" style="width:100%" v-on:change="VtoMatrix(encodedData)" rows=5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,341 +1,341 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>TS100 Translation Editor</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
<script src="translations_commons.js"></script>
|
||||
<script src="translations_def.js"></script>
|
||||
<script>
|
||||
|
||||
var app;
|
||||
var defMap = {};
|
||||
|
||||
function save(){
|
||||
saveJSON(app.current, "translation_"+app.current.languageCode.toLowerCase()+".json");
|
||||
}
|
||||
|
||||
function view(){
|
||||
showJSON(app.current, "translation_"+app.current.languageCode.toLowerCase()+".json");
|
||||
}
|
||||
|
||||
function fileChanged(e) {
|
||||
var target = e;
|
||||
var id = target.id;
|
||||
|
||||
var file = target.files[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
var fr = new FileReader();
|
||||
fr.onload = function(e) {
|
||||
try {
|
||||
var json = JSON.parse(e.target.result);
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
alert("Invalid JSON file: " + file.name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (id == "referent-lang-file") {
|
||||
if (checkTranslationFile(file.name)) {
|
||||
app.referent = json;
|
||||
app.meta.referentLoaded = true;
|
||||
}
|
||||
} else if (id == "current-lang-file") {
|
||||
if (checkTranslationFile(file.name)) {
|
||||
app.current = json;
|
||||
app.meta.currentLoaded = true;
|
||||
}
|
||||
}
|
||||
synchronizeData();
|
||||
}
|
||||
fr.readAsText(file);
|
||||
|
||||
}
|
||||
|
||||
function synchronizeData() {
|
||||
app.obsolete = {};
|
||||
copyMissing(app.def.messages, app.referent.messages, app.current.messages);
|
||||
copyMissing(app.def.characters, app.referent.characters, app.current.characters);
|
||||
copyMissing(app.def.menuGroups, app.referent.menuGroups, app.current.menuGroups);
|
||||
copyMissing(app.def.menuOptions, app.referent.menuOptions, app.current.menuOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy all missing properties from referent to current
|
||||
* for each entry in definition
|
||||
*/
|
||||
function copyMissing(defList, referentMap, currentMap) {
|
||||
if (!isDefined(defList) || !isDefined(referentMap) || !isDefined(currentMap)) {
|
||||
return;
|
||||
}
|
||||
var len = defList.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var id = defList[i].id;
|
||||
if (!isDefined(referentMap[id])) {
|
||||
referentMap[id] = '';
|
||||
}
|
||||
if (!isDefined(currentMap[id])) {
|
||||
currentMap[id] = referentMap[id];
|
||||
}
|
||||
}
|
||||
processObsolete(defList, currentMap);
|
||||
}
|
||||
|
||||
// Passes through all entries from the given map.
|
||||
// If a corresponding entry is not found in the defList, it is removed from the map, and added into the obsolete map.
|
||||
function processObsolete(defList, map) {
|
||||
// Index list to map for faster search
|
||||
var defMap = copyArrayToMap(defList);
|
||||
Object.keys(map).forEach(function(key) {
|
||||
if (!isDefined(defMap[key])) {
|
||||
app.obsolete[key] = { id : key, value : map[key]};
|
||||
delete map[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function length(obj, mode) {
|
||||
if (!isDefined(mode) || mode == 0) {
|
||||
// return direct length
|
||||
return obj.length;
|
||||
} else if (mode == 1) {
|
||||
// return length of text property
|
||||
return obj.text.length;
|
||||
} else if (mode == 2) {
|
||||
// return the longest length in text2 array
|
||||
return Math.max(isDefinedNN(obj.text2[0]) ? obj.text2[0].length : 0, isDefinedNN(obj.text2[1]) ? obj.text2[1].length : 0);
|
||||
}
|
||||
}
|
||||
|
||||
function getAttribute(obj, attribute, isDouble) {
|
||||
var d = isDouble ? "2" : "";
|
||||
var v = obj[attribute+d];
|
||||
if (isDefined(v))
|
||||
return v;
|
||||
return obj[attribute];
|
||||
}
|
||||
|
||||
function loaded() {
|
||||
app = new Vue({
|
||||
el : '#app',
|
||||
data : {
|
||||
meta : {
|
||||
referentLoaded : false,
|
||||
currentLoaded : false,
|
||||
},
|
||||
def : {
|
||||
},
|
||||
referent : {
|
||||
messages : {}
|
||||
},
|
||||
current : {
|
||||
loaded: false,
|
||||
},
|
||||
obsolete : {},
|
||||
menuDouble : false
|
||||
},
|
||||
methods : {
|
||||
validateInput: function(valMap, id, mode) {
|
||||
var d = defMap[id];
|
||||
var vLen = 0;
|
||||
if (!isDefined(mode))
|
||||
mode = 0;
|
||||
|
||||
try {
|
||||
// Sum for complex length
|
||||
for (var i = 0; i < d.lenSum.fields.length; i++) {
|
||||
vLen += length(valMap[d.lenSum.fields[i]], mode);
|
||||
}
|
||||
d = d.lenSum;
|
||||
} catch (e) {
|
||||
// Single field length
|
||||
vLen = length(valMap[id], mode);
|
||||
}
|
||||
var maxLen = getAttribute(d, 'maxLen', mode == 2);
|
||||
var minLen = getAttribute(d, 'minLen', mode == 2);
|
||||
var len = getAttribute(d, 'len', mode == 2);
|
||||
if (isNumber(maxLen) && vLen > maxLen
|
||||
|| isNumber(minLen) && vLen < minLen
|
||||
|| isNumber(len) && vLen != len
|
||||
) {
|
||||
return "invalid";
|
||||
}
|
||||
},
|
||||
|
||||
constraintString: function(e, d) {
|
||||
var str = "";
|
||||
var delim = "";
|
||||
var v;
|
||||
if (!isDefined(d) || d == false) {
|
||||
d = "";
|
||||
} else {
|
||||
d = "2";
|
||||
}
|
||||
|
||||
if (isDefinedNN(e.lenSum)) {
|
||||
str = "len("+(e.lenSum.fields+"").replace(/,/g," + ")+") -> ";
|
||||
e = e.lenSum;
|
||||
}
|
||||
v = getAttribute(e, 'len', d);
|
||||
if (isNumber(v)) {
|
||||
str += delim + "len=" + v;
|
||||
delim = " and ";
|
||||
}
|
||||
v = getAttribute(e, 'minLen', d);
|
||||
if (isNumber(v)) {
|
||||
str += delim + "len>=" + v;
|
||||
delim = " and ";
|
||||
}
|
||||
v = getAttribute(e, 'maxLen', d);
|
||||
if (isNumber(v)) {
|
||||
str += delim + "len<=" + v;
|
||||
delim = " and ";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
});
|
||||
app.def = def;
|
||||
copyArrayToMap(app.def.messages, defMap);
|
||||
copyArrayToMap(app.def.characters, defMap);
|
||||
copyArrayToMap(app.def.menuGroups, defMap);
|
||||
copyArrayToMap(app.def.menuOptions, defMap);
|
||||
}
|
||||
|
||||
window.onload=loaded;
|
||||
</script>
|
||||
<link href="translations.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="app">
|
||||
<h1>TS100 Translation Editor<span v-if="meta.currentLoaded"> - {{ current.languageLocalName }} [{{current.languageCode}}]</span></h1>
|
||||
<table class="header data">
|
||||
<tr>
|
||||
<td class="label">Referent Language</td>
|
||||
<td class="value">
|
||||
<input type="file" id="referent-lang-file" onchange="fileChanged(this)" accept=".json">
|
||||
<span class="selected" v-if="meta.referentLoaded">{{ referent.languageLocalName }} [{{referent.languageCode}}]</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="meta.referentLoaded">
|
||||
<td class="label">Current Language</td>
|
||||
<td class="value">
|
||||
<input type="file" id="current-lang-file" onchange="fileChanged(this)" accept=".json">
|
||||
<span class="selected" v-if="meta.currentLoaded">{{ current.languageLocalName }} [{{current.languageCode}}]</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="meta.currentLoaded">
|
||||
<td class="label">Local Language Code</td>
|
||||
<td class="value"><input type="text" v-model="current.languageCode" maxlength="8" v-on:change="current.languageCode=current.languageCode.toUpperCase()" class="short"></td>
|
||||
</tr>
|
||||
<tr v-if="meta.currentLoaded">
|
||||
<td class="label">Local Language Name</td>
|
||||
<td class="value"><input type="text" v-model="current.languageLocalName" class="short"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div v-if="def.messages && referent.messages && current.messages">
|
||||
|
||||
<div class="footer">
|
||||
<input type="button" value="Save" onclick="save()">
|
||||
<input type="button" value="View" onclick="view()">
|
||||
</div>
|
||||
|
||||
<div v-if="Object.keys(obsolete).length > 0">
|
||||
<h2>Obsolete</h2>
|
||||
<table class="data">
|
||||
<tr v-for="entry in obsolete">
|
||||
<td class="label"><div class="stringId">{{entry.id}}</div></td>
|
||||
<td class="value"><div class="ref">{{entry.value}}</div></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h2>Messages and Strings</h2>
|
||||
<table class="data">
|
||||
<tr v-for="message in def.messages" v-bind:class="validateInput(current.messages, message.id)">
|
||||
<td class="label"><div class="stringId">{{message.id}}</div></td>
|
||||
<td class="value">
|
||||
<div class="constraint">{{constraintString(message)}}</div>
|
||||
<div class="ref">{{referent.messages[message.id]}}</div>
|
||||
<div class="note" v-if="message.note">{{message.note}}</div>
|
||||
<div class="tran"><input :id="'in_'+message.id" type="text" v-model="current.messages[message.id]" v-bind:class="{unchanged : current.messages[message.id] == referent.messages[message.id], empty : current.messages[message.id]==''}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Characters</h2>
|
||||
<table class="data">
|
||||
<tr v-for="char in def.characters" v-bind:class="validateInput(current.characters, char.id)">
|
||||
<td class="label"><div class="stringId">{{char.id}}</div></td>
|
||||
<td class="value">
|
||||
<div class="constraint">{{constraintString(char)}}</div>
|
||||
<div class="ref">{{referent.characters[char.id]}}</div>
|
||||
<div class="tran"><input type="text" v-model="current.characters[char.id]" v-bind:class="{unchanged : current.characters[char.id] == referent.characters[char.id], empty : current.characters[char.id].length != 1}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Menu Groups</h2>
|
||||
<table class="data">
|
||||
<tr v-for="menu in def.menuGroups" v-bind:class="validateInput(current.menuGroups, menu.id, 2)">
|
||||
<td class="label"><div class="stringId">{{menu.id}}</div></td>
|
||||
<td class="value">
|
||||
<div class="label">Menu Name</div>
|
||||
<div class="constraint">{{constraintString(menu)}}</div>
|
||||
<div class="ref">{{referent.menuGroups[menu.id].text2}}</div>
|
||||
<div class="tran" v-bind:class="{unchanged : current.menuGroups[menu.id].text2[0] == referent.menuGroups[menu.id].text2[0] && current.menuGroups[menu.id].text2[1] == referent.menuGroups[menu.id].text2[1], empty : current.menuGroups[menu.id].text2[0] == '' || current.menuGroups[menu.id].text2[1] == ''}"><input type="text" v-model="current.menuGroups[menu.id].text2[0]"><input type="text" v-model="current.menuGroups[menu.id].text2[1]"></div>
|
||||
<div class="label">Description</div>
|
||||
<div class="ref">{{referent.menuGroups[menu.id].desc}}</div>
|
||||
<div class="tran"><input type="text" v-model="current.menuGroups[menu.id].desc" v-bind:class="{unchanged : current.menuGroups[menu.id].desc == referent.menuGroups[menu.id].desc, empty : current.menuGroups[menu.id].desc == ''}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Menu Options</h2>
|
||||
<table class="data">
|
||||
<tr>
|
||||
<td class="label">Menu Type</td>
|
||||
<td class="value">
|
||||
<select v-model="current.menuDouble" v-on:change="current.menuDouble = current.menuDouble=='true'">
|
||||
<option value="false">Single-Line</option>
|
||||
<option value="true">Double-Line</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="menu in def.menuOptions" v-bind:class="validateInput(current.menuOptions, menu.id, (current.menuDouble ? 2 : 1))">
|
||||
<td class="label"><div class="stringId">{{menu.id}}</div></td>
|
||||
<td class="value">
|
||||
<div v-bind:class="{hidden : current.menuDouble}">
|
||||
<div class="label">Menu Name (Single-Line)</div>
|
||||
<div class="constraint">{{constraintString(menu, current.menuDouble)}}</div>
|
||||
<div class="ref">{{referent.menuOptions[menu.id].text}}</div>
|
||||
<div class="tran"><input type="text" v-model="current.menuOptions[menu.id].text" v-bind:class="{unchanged : current.menuOptions[menu.id].text == referent.menuOptions[menu.id].text, empty : current.menuOptions[menu.id].text == ''}"></div>
|
||||
</div>
|
||||
<div v-bind:class="{hidden : !current.menuDouble}">
|
||||
<div class="label">Menu Name (Double-Line)</div>
|
||||
<div class="constraint">{{constraintString(menu, current.menuDouble)}}</div>
|
||||
<div class="ref">{{referent.menuOptions[menu.id].text2}}</div>
|
||||
<div class="tran" v-bind:class="{unchanged : current.menuOptions[menu.id].text2[0] == referent.menuOptions[menu.id].text2[0] && current.menuOptions[menu.id].text2[1] == referent.menuOptions[menu.id].text2[1], empty : current.menuOptions[menu.id].text2[0] == '' || current.menuOptions[menu.id].text2[1] == ''}"><input type="text" v-model="current.menuOptions[menu.id].text2[0]"><input type="text" v-model="current.menuOptions[menu.id].text2[1]"></div>
|
||||
</div>
|
||||
<div class="label">Description</div>
|
||||
<div class="ref">{{referent.menuOptions[menu.id].desc}}</div>
|
||||
<div class="tran"><input type="text" v-model="current.menuOptions[menu.id].desc" v-bind:class="{unchanged : current.menuOptions[menu.id].desc == referent.menuOptions[menu.id].desc, empty : current.menuOptions[menu.id].desc == ''}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="footer">
|
||||
<input type="button" value="Save" onclick="save()">
|
||||
<input type="button" value="View" onclick="view()">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>TS100 Translation Editor</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
<script src="translations_commons.js"></script>
|
||||
<script src="translations_def.js"></script>
|
||||
<script>
|
||||
|
||||
var app;
|
||||
var defMap = {};
|
||||
|
||||
function save(){
|
||||
saveJSON(app.current, "translation_"+app.current.languageCode.toLowerCase()+".json");
|
||||
}
|
||||
|
||||
function view(){
|
||||
showJSON(app.current, "translation_"+app.current.languageCode.toLowerCase()+".json");
|
||||
}
|
||||
|
||||
function fileChanged(e) {
|
||||
var target = e;
|
||||
var id = target.id;
|
||||
|
||||
var file = target.files[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
var fr = new FileReader();
|
||||
fr.onload = function(e) {
|
||||
try {
|
||||
var json = JSON.parse(e.target.result);
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
alert("Invalid JSON file: " + file.name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (id == "referent-lang-file") {
|
||||
if (checkTranslationFile(file.name)) {
|
||||
app.referent = json;
|
||||
app.meta.referentLoaded = true;
|
||||
}
|
||||
} else if (id == "current-lang-file") {
|
||||
if (checkTranslationFile(file.name)) {
|
||||
app.current = json;
|
||||
app.meta.currentLoaded = true;
|
||||
}
|
||||
}
|
||||
synchronizeData();
|
||||
}
|
||||
fr.readAsText(file);
|
||||
|
||||
}
|
||||
|
||||
function synchronizeData() {
|
||||
app.obsolete = {};
|
||||
copyMissing(app.def.messages, app.referent.messages, app.current.messages);
|
||||
copyMissing(app.def.characters, app.referent.characters, app.current.characters);
|
||||
copyMissing(app.def.menuGroups, app.referent.menuGroups, app.current.menuGroups);
|
||||
copyMissing(app.def.menuOptions, app.referent.menuOptions, app.current.menuOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy all missing properties from referent to current
|
||||
* for each entry in definition
|
||||
*/
|
||||
function copyMissing(defList, referentMap, currentMap) {
|
||||
if (!isDefined(defList) || !isDefined(referentMap) || !isDefined(currentMap)) {
|
||||
return;
|
||||
}
|
||||
var len = defList.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var id = defList[i].id;
|
||||
if (!isDefined(referentMap[id])) {
|
||||
referentMap[id] = '';
|
||||
}
|
||||
if (!isDefined(currentMap[id])) {
|
||||
currentMap[id] = referentMap[id];
|
||||
}
|
||||
}
|
||||
processObsolete(defList, currentMap);
|
||||
}
|
||||
|
||||
// Passes through all entries from the given map.
|
||||
// If a corresponding entry is not found in the defList, it is removed from the map, and added into the obsolete map.
|
||||
function processObsolete(defList, map) {
|
||||
// Index list to map for faster search
|
||||
var defMap = copyArrayToMap(defList);
|
||||
Object.keys(map).forEach(function(key) {
|
||||
if (!isDefined(defMap[key])) {
|
||||
app.obsolete[key] = { id : key, value : map[key]};
|
||||
delete map[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function length(obj, mode) {
|
||||
if (!isDefined(mode) || mode == 0) {
|
||||
// return direct length
|
||||
return obj.length;
|
||||
} else if (mode == 1) {
|
||||
// return length of text property
|
||||
return obj.text.length;
|
||||
} else if (mode == 2) {
|
||||
// return the longest length in text2 array
|
||||
return Math.max(isDefinedNN(obj.text2[0]) ? obj.text2[0].length : 0, isDefinedNN(obj.text2[1]) ? obj.text2[1].length : 0);
|
||||
}
|
||||
}
|
||||
|
||||
function getAttribute(obj, attribute, isDouble) {
|
||||
var d = isDouble ? "2" : "";
|
||||
var v = obj[attribute+d];
|
||||
if (isDefined(v))
|
||||
return v;
|
||||
return obj[attribute];
|
||||
}
|
||||
|
||||
function loaded() {
|
||||
app = new Vue({
|
||||
el : '#app',
|
||||
data : {
|
||||
meta : {
|
||||
referentLoaded : false,
|
||||
currentLoaded : false,
|
||||
},
|
||||
def : {
|
||||
},
|
||||
referent : {
|
||||
messages : {}
|
||||
},
|
||||
current : {
|
||||
loaded: false,
|
||||
},
|
||||
obsolete : {},
|
||||
menuDouble : false
|
||||
},
|
||||
methods : {
|
||||
validateInput: function(valMap, id, mode) {
|
||||
var d = defMap[id];
|
||||
var vLen = 0;
|
||||
if (!isDefined(mode))
|
||||
mode = 0;
|
||||
|
||||
try {
|
||||
// Sum for complex length
|
||||
for (var i = 0; i < d.lenSum.fields.length; i++) {
|
||||
vLen += length(valMap[d.lenSum.fields[i]], mode);
|
||||
}
|
||||
d = d.lenSum;
|
||||
} catch (e) {
|
||||
// Single field length
|
||||
vLen = length(valMap[id], mode);
|
||||
}
|
||||
var maxLen = getAttribute(d, 'maxLen', mode == 2);
|
||||
var minLen = getAttribute(d, 'minLen', mode == 2);
|
||||
var len = getAttribute(d, 'len', mode == 2);
|
||||
if (isNumber(maxLen) && vLen > maxLen
|
||||
|| isNumber(minLen) && vLen < minLen
|
||||
|| isNumber(len) && vLen != len
|
||||
) {
|
||||
return "invalid";
|
||||
}
|
||||
},
|
||||
|
||||
constraintString: function(e, d) {
|
||||
var str = "";
|
||||
var delim = "";
|
||||
var v;
|
||||
if (!isDefined(d) || d == false) {
|
||||
d = "";
|
||||
} else {
|
||||
d = "2";
|
||||
}
|
||||
|
||||
if (isDefinedNN(e.lenSum)) {
|
||||
str = "len("+(e.lenSum.fields+"").replace(/,/g," + ")+") -> ";
|
||||
e = e.lenSum;
|
||||
}
|
||||
v = getAttribute(e, 'len', d);
|
||||
if (isNumber(v)) {
|
||||
str += delim + "len=" + v;
|
||||
delim = " and ";
|
||||
}
|
||||
v = getAttribute(e, 'minLen', d);
|
||||
if (isNumber(v)) {
|
||||
str += delim + "len>=" + v;
|
||||
delim = " and ";
|
||||
}
|
||||
v = getAttribute(e, 'maxLen', d);
|
||||
if (isNumber(v)) {
|
||||
str += delim + "len<=" + v;
|
||||
delim = " and ";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
});
|
||||
app.def = def;
|
||||
copyArrayToMap(app.def.messages, defMap);
|
||||
copyArrayToMap(app.def.characters, defMap);
|
||||
copyArrayToMap(app.def.menuGroups, defMap);
|
||||
copyArrayToMap(app.def.menuOptions, defMap);
|
||||
}
|
||||
|
||||
window.onload=loaded;
|
||||
</script>
|
||||
<link href="translations.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="app">
|
||||
<h1>TS100 Translation Editor<span v-if="meta.currentLoaded"> - {{ current.languageLocalName }} [{{current.languageCode}}]</span></h1>
|
||||
<table class="header data">
|
||||
<tr>
|
||||
<td class="label">Referent Language</td>
|
||||
<td class="value">
|
||||
<input type="file" id="referent-lang-file" onchange="fileChanged(this)" accept=".json">
|
||||
<span class="selected" v-if="meta.referentLoaded">{{ referent.languageLocalName }} [{{referent.languageCode}}]</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="meta.referentLoaded">
|
||||
<td class="label">Current Language</td>
|
||||
<td class="value">
|
||||
<input type="file" id="current-lang-file" onchange="fileChanged(this)" accept=".json">
|
||||
<span class="selected" v-if="meta.currentLoaded">{{ current.languageLocalName }} [{{current.languageCode}}]</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="meta.currentLoaded">
|
||||
<td class="label">Local Language Code</td>
|
||||
<td class="value"><input type="text" v-model="current.languageCode" maxlength="8" v-on:change="current.languageCode=current.languageCode.toUpperCase()" class="short"></td>
|
||||
</tr>
|
||||
<tr v-if="meta.currentLoaded">
|
||||
<td class="label">Local Language Name</td>
|
||||
<td class="value"><input type="text" v-model="current.languageLocalName" class="short"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div v-if="def.messages && referent.messages && current.messages">
|
||||
|
||||
<div class="footer">
|
||||
<input type="button" value="Save" onclick="save()">
|
||||
<input type="button" value="View" onclick="view()">
|
||||
</div>
|
||||
|
||||
<div v-if="Object.keys(obsolete).length > 0">
|
||||
<h2>Obsolete</h2>
|
||||
<table class="data">
|
||||
<tr v-for="entry in obsolete">
|
||||
<td class="label"><div class="stringId">{{entry.id}}</div></td>
|
||||
<td class="value"><div class="ref">{{entry.value}}</div></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h2>Messages and Strings</h2>
|
||||
<table class="data">
|
||||
<tr v-for="message in def.messages" v-bind:class="validateInput(current.messages, message.id)">
|
||||
<td class="label"><div class="stringId">{{message.id}}</div></td>
|
||||
<td class="value">
|
||||
<div class="constraint">{{constraintString(message)}}</div>
|
||||
<div class="ref">{{referent.messages[message.id]}}</div>
|
||||
<div class="note" v-if="message.note">{{message.note}}</div>
|
||||
<div class="tran"><input :id="'in_'+message.id" type="text" v-model="current.messages[message.id]" v-bind:class="{unchanged : current.messages[message.id] == referent.messages[message.id], empty : current.messages[message.id]==''}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Characters</h2>
|
||||
<table class="data">
|
||||
<tr v-for="char in def.characters" v-bind:class="validateInput(current.characters, char.id)">
|
||||
<td class="label"><div class="stringId">{{char.id}}</div></td>
|
||||
<td class="value">
|
||||
<div class="constraint">{{constraintString(char)}}</div>
|
||||
<div class="ref">{{referent.characters[char.id]}}</div>
|
||||
<div class="tran"><input type="text" v-model="current.characters[char.id]" v-bind:class="{unchanged : current.characters[char.id] == referent.characters[char.id], empty : current.characters[char.id].length != 1}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Menu Groups</h2>
|
||||
<table class="data">
|
||||
<tr v-for="menu in def.menuGroups" v-bind:class="validateInput(current.menuGroups, menu.id, 2)">
|
||||
<td class="label"><div class="stringId">{{menu.id}}</div></td>
|
||||
<td class="value">
|
||||
<div class="label">Menu Name</div>
|
||||
<div class="constraint">{{constraintString(menu)}}</div>
|
||||
<div class="ref">{{referent.menuGroups[menu.id].text2}}</div>
|
||||
<div class="tran" v-bind:class="{unchanged : current.menuGroups[menu.id].text2[0] == referent.menuGroups[menu.id].text2[0] && current.menuGroups[menu.id].text2[1] == referent.menuGroups[menu.id].text2[1], empty : current.menuGroups[menu.id].text2[0] == '' || current.menuGroups[menu.id].text2[1] == ''}"><input type="text" v-model="current.menuGroups[menu.id].text2[0]"><input type="text" v-model="current.menuGroups[menu.id].text2[1]"></div>
|
||||
<div class="label">Description</div>
|
||||
<div class="ref">{{referent.menuGroups[menu.id].desc}}</div>
|
||||
<div class="tran"><input type="text" v-model="current.menuGroups[menu.id].desc" v-bind:class="{unchanged : current.menuGroups[menu.id].desc == referent.menuGroups[menu.id].desc, empty : current.menuGroups[menu.id].desc == ''}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Menu Options</h2>
|
||||
<table class="data">
|
||||
<tr>
|
||||
<td class="label">Menu Type</td>
|
||||
<td class="value">
|
||||
<select v-model="current.menuDouble" v-on:change="current.menuDouble = current.menuDouble=='true'">
|
||||
<option value="false">Single-Line</option>
|
||||
<option value="true">Double-Line</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="menu in def.menuOptions" v-bind:class="validateInput(current.menuOptions, menu.id, (current.menuDouble ? 2 : 1))">
|
||||
<td class="label"><div class="stringId">{{menu.id}}</div></td>
|
||||
<td class="value">
|
||||
<div v-bind:class="{hidden : current.menuDouble}">
|
||||
<div class="label">Menu Name (Single-Line)</div>
|
||||
<div class="constraint">{{constraintString(menu, current.menuDouble)}}</div>
|
||||
<div class="ref">{{referent.menuOptions[menu.id].text}}</div>
|
||||
<div class="tran"><input type="text" v-model="current.menuOptions[menu.id].text" v-bind:class="{unchanged : current.menuOptions[menu.id].text == referent.menuOptions[menu.id].text, empty : current.menuOptions[menu.id].text == ''}"></div>
|
||||
</div>
|
||||
<div v-bind:class="{hidden : !current.menuDouble}">
|
||||
<div class="label">Menu Name (Double-Line)</div>
|
||||
<div class="constraint">{{constraintString(menu, current.menuDouble)}}</div>
|
||||
<div class="ref">{{referent.menuOptions[menu.id].text2}}</div>
|
||||
<div class="tran" v-bind:class="{unchanged : current.menuOptions[menu.id].text2[0] == referent.menuOptions[menu.id].text2[0] && current.menuOptions[menu.id].text2[1] == referent.menuOptions[menu.id].text2[1], empty : current.menuOptions[menu.id].text2[0] == '' || current.menuOptions[menu.id].text2[1] == ''}"><input type="text" v-model="current.menuOptions[menu.id].text2[0]"><input type="text" v-model="current.menuOptions[menu.id].text2[1]"></div>
|
||||
</div>
|
||||
<div class="label">Description</div>
|
||||
<div class="ref">{{referent.menuOptions[menu.id].desc}}</div>
|
||||
<div class="tran"><input type="text" v-model="current.menuOptions[menu.id].desc" v-bind:class="{unchanged : current.menuOptions[menu.id].desc == referent.menuOptions[menu.id].desc, empty : current.menuOptions[menu.id].desc == ''}"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="footer">
|
||||
<input type="button" value="Save" onclick="save()">
|
||||
<input type="button" value="View" onclick="view()">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,317 +1,317 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>TS100 Translation Parser</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
<script src="translations_commons.js"></script>
|
||||
<script src="translations_def.js"></script>
|
||||
<script>
|
||||
|
||||
var app;
|
||||
var defMap = {};
|
||||
var langMap = {};
|
||||
var lang;
|
||||
|
||||
var defMsgMap;
|
||||
var defCharMap;
|
||||
var defGrpMap;
|
||||
var defOptMap;
|
||||
|
||||
function save(langCode){
|
||||
saveJSON(langMap[langCode], "translation_"+langCode.toLowerCase()+".json");
|
||||
}
|
||||
|
||||
function view(langCode){
|
||||
showJSON(langMap[langCode], "translation_"+langCode.toLowerCase()+".json");
|
||||
}
|
||||
|
||||
function translationFileSelected(e) {
|
||||
var target = e;
|
||||
var id = target.id;
|
||||
|
||||
var file = target.files[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
var fr = new FileReader();
|
||||
fr.onload = function(e) {
|
||||
parseTranslationFile(file.name, e.target.result);
|
||||
}
|
||||
fr.readAsText(file);
|
||||
|
||||
}
|
||||
|
||||
function parseTranslationFile(name, src) {
|
||||
// remove multiline comments
|
||||
src = src.replace(/\/\*[\s\S.]*?\*\//mg, "");
|
||||
// remove single-line comments
|
||||
src = src.replace(/\/\/.*/mg, "");
|
||||
// remove empty lines
|
||||
src = src.replace(/^\s*\n/gm, "");
|
||||
|
||||
var langCode = "";
|
||||
var srcLines = src.split("\n");
|
||||
|
||||
var reMessage = /const\s+char\s*\*\s+([\w\d]+)\s*=\s*"(.*)"/;
|
||||
var reSettingsDescStart = /const\s+char\s*\*\s+SettingsDescriptions\[/;
|
||||
var reSettingsNamesStart = /const\s+char\s*\*\s+SettingsShortNames\[/;
|
||||
var reSettingsMenuDescStart = /const\s+char\s*\*\s+SettingsMenuEntriesDescriptions\[/;
|
||||
var reChar = /const\s+char\s+([\w\d]+)\s*=\s*'(\w)'/;
|
||||
var reMenuMode = /SettingsShortNameType\s*=\s*SHORT_NAME_(\w+)_LINE/;
|
||||
|
||||
var reMenuStart = /\s*const\s+char\s*\*\s+SettingsMenuEntries\[/;
|
||||
|
||||
// var reString = /^\s*"(.*)"/;
|
||||
var reString = /"(.*)"/;
|
||||
var reSingleLine = /{\s*"(.*)"\s*}/;
|
||||
var reDoubleLine = /{\s*"(.*)"\s*,\s*"(.*)"\s*}/;
|
||||
|
||||
var mode = '';
|
||||
var entryIndex = 0;
|
||||
for (var li = 0; li < srcLines.length; li++) {
|
||||
// trim lines
|
||||
line = srcLines[li] = srcLines[li].trim();
|
||||
|
||||
// if entering a new lang block
|
||||
if (startsWith(line, "#ifdef LANG_")) {
|
||||
mode = 'new-language';
|
||||
langCode = line.substring(12);
|
||||
lang = langMap[langCode];
|
||||
// use existing or instantiate new
|
||||
if (!isDefined(lang)) {
|
||||
lang = {
|
||||
languageCode: langCode,
|
||||
messages: {},
|
||||
characters: {},
|
||||
menuDouble : false,
|
||||
menuGroups: {},
|
||||
menuOptions: {}
|
||||
};
|
||||
langMap[langCode] = lang;
|
||||
app.languages[app.languages.length] = langCode;
|
||||
}
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Menu type
|
||||
reMenuMode.lastIndex = 0;
|
||||
match = reMenuMode.exec(line);
|
||||
if (match) {
|
||||
lang.menuDouble = match[1] == 'DOUBLE';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Messages
|
||||
reMessage.lastIndex = 0;
|
||||
match = reMessage.exec(line);
|
||||
if (match) {
|
||||
lang.messages[match[1]] = xunescape(match[2]);
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Chars descriptions
|
||||
reChar.lastIndex = 0;
|
||||
match = reChar.exec(line);
|
||||
if (match) {
|
||||
// found description block start
|
||||
mode = 'char';
|
||||
lang.characters[match[1]] = xunescape(match[2]);
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
// Settings descriptions
|
||||
reSettingsDescStart.lastIndex = 0;
|
||||
match = reSettingsDescStart.exec(line);
|
||||
if (match) {
|
||||
// found description block start
|
||||
mode = 'settingsDesc';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
reSettingsNamesStart.lastIndex = 0;
|
||||
match = reSettingsNamesStart.exec(line);
|
||||
if (match) {
|
||||
// found description block start
|
||||
mode = 'settingsNames';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
reMenuStart.lastIndex = 0;
|
||||
match = reMenuStart.exec(line);
|
||||
if (match) {
|
||||
// found description block start
|
||||
mode = 'menu';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
reSettingsMenuDescStart.lastIndex = 0;
|
||||
match = reSettingsMenuDescStart.exec(line);
|
||||
if (match) {
|
||||
// found description block start
|
||||
mode = 'menuDesc';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mode == 'menu') {
|
||||
// processing menu group names
|
||||
reString.lastIndex = 0;
|
||||
match = reString.exec(line);
|
||||
if (match) {
|
||||
// found description string
|
||||
var entry = getMenuGroup(entryIndex);
|
||||
var m = match[1].split("\\n");
|
||||
entry.text2[0] = xunescape(m[0]);
|
||||
entry.text2[1] = xunescape(m[1]);
|
||||
entryIndex++;
|
||||
}
|
||||
} else if (mode == 'menuDesc') {
|
||||
// processing menu group descriptions
|
||||
reString.lastIndex = 0;
|
||||
match = reString.exec(line);
|
||||
if (match) {
|
||||
// found description string
|
||||
var entry = getMenuGroup(entryIndex);
|
||||
entry.desc = xunescape(match[1]);
|
||||
entryIndex++;
|
||||
}
|
||||
} else if (mode == 'settingsDesc') {
|
||||
// processing option descriptions
|
||||
reString.lastIndex = 0;
|
||||
match = reString.exec(line);
|
||||
if (match) {
|
||||
// found description string
|
||||
var entry = getMenuOption(entryIndex);
|
||||
entry.desc = xunescape(match[1]);
|
||||
entryIndex++;
|
||||
}
|
||||
} else if (mode == 'settingsNames') {
|
||||
reDoubleLine.lastIndex = 0;
|
||||
match = reDoubleLine.exec(line);
|
||||
if (match) {
|
||||
var entry = getMenuOption(entryIndex);
|
||||
entry.text2[0] = xunescape(match[1]);
|
||||
entry.text2[1] = xunescape(match[2]);
|
||||
entryIndex++;
|
||||
} else {
|
||||
reSingleLine.lastIndex = 0;
|
||||
match = reSingleLine.exec(line);
|
||||
if (match) {
|
||||
var entry = getMenuOption(entryIndex);
|
||||
entry.text = xunescape(match[1]);
|
||||
entryIndex++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
app.done = 1;
|
||||
}
|
||||
|
||||
function getMenuOption(entryIndex) {
|
||||
var optionDef = def.menuOptions[entryIndex];
|
||||
if (!isDefined(optionDef)) {
|
||||
var s = "Could not find menu option with index "+entryIndex;
|
||||
alert(s);
|
||||
throw s;
|
||||
}
|
||||
var id = optionDef.id;
|
||||
var entry = lang.menuOptions[id];
|
||||
if (!isDefined(entry)) {
|
||||
entry =
|
||||
{
|
||||
"text": "",
|
||||
"text2": ["", ""],
|
||||
"desc": ""
|
||||
}
|
||||
lang.menuOptions[id] = entry;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
function getMenuGroup(entryIndex) {
|
||||
var optionDef = def.menuGroups[entryIndex];
|
||||
if (!isDefined(optionDef)) {
|
||||
var s = "Could not find menu group with index "+entryIndex;
|
||||
alert(s);
|
||||
throw s;
|
||||
}
|
||||
var id = optionDef.id;
|
||||
var entry = lang.menuGroups[id];
|
||||
if (!isDefined(entry)) {
|
||||
entry =
|
||||
{
|
||||
"text2": ["", ""],
|
||||
"desc": ""
|
||||
}
|
||||
lang.menuGroups[id] = entry;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
function markSaved(lang) {
|
||||
document.getElementById("row_"+lang).classList.add("saved");
|
||||
}
|
||||
|
||||
function loaded() {
|
||||
app = new Vue({
|
||||
el : '#app',
|
||||
data : {
|
||||
languages: [],
|
||||
done : false,
|
||||
def : {
|
||||
}
|
||||
|
||||
},
|
||||
methods : {
|
||||
vSave : function(lang) {
|
||||
save(lang);
|
||||
markSaved(lang);
|
||||
},
|
||||
vView : function(lang) {
|
||||
view(lang);
|
||||
markSaved(lang);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.def = def;
|
||||
defMsgMap = copyArrayToMap(app.def.messages);
|
||||
defCharMap = copyArrayToMap(app.def.characters);
|
||||
defGrpMap = copyArrayToMap(app.def.menuGroups);
|
||||
defOptMap = copyArrayToMap(app.def.menuOptions);
|
||||
}
|
||||
|
||||
window.onload=loaded;
|
||||
</script>
|
||||
<link href="translations.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="app">
|
||||
<h1>TS100 Translation Parser</h1>
|
||||
<table class="header data">
|
||||
<tr>
|
||||
<td class="label">Translation.cpp</td>
|
||||
<td class="value">
|
||||
<input type="file" id="translation-cpp-file" onchange="translationFileSelected(this)" accept=".cpp">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="data" v-if="done">
|
||||
<div class="value" v-for="lang in languages" :id="'row_'+lang">
|
||||
<input type="button" :value="'Save '+lang" v-on:click="vSave(lang)">
|
||||
<input type="button" :value="'View '+lang" v-on:click="vView(lang)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>TS100 Translation Parser</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
<script src="translations_commons.js"></script>
|
||||
<script src="translations_def.js"></script>
|
||||
<script>
|
||||
|
||||
var app;
|
||||
var defMap = {};
|
||||
var langMap = {};
|
||||
var lang;
|
||||
|
||||
var defMsgMap;
|
||||
var defCharMap;
|
||||
var defGrpMap;
|
||||
var defOptMap;
|
||||
|
||||
function save(langCode){
|
||||
saveJSON(langMap[langCode], "translation_"+langCode.toLowerCase()+".json");
|
||||
}
|
||||
|
||||
function view(langCode){
|
||||
showJSON(langMap[langCode], "translation_"+langCode.toLowerCase()+".json");
|
||||
}
|
||||
|
||||
function translationFileSelected(e) {
|
||||
var target = e;
|
||||
var id = target.id;
|
||||
|
||||
var file = target.files[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
var fr = new FileReader();
|
||||
fr.onload = function(e) {
|
||||
parseTranslationFile(file.name, e.target.result);
|
||||
}
|
||||
fr.readAsText(file);
|
||||
|
||||
}
|
||||
|
||||
function parseTranslationFile(name, src) {
|
||||
// remove multiline comments
|
||||
src = src.replace(/\/\*[\s\S.]*?\*\//mg, "");
|
||||
// remove single-line comments
|
||||
src = src.replace(/\/\/.*/mg, "");
|
||||
// remove empty lines
|
||||
src = src.replace(/^\s*\n/gm, "");
|
||||
|
||||
var langCode = "";
|
||||
var srcLines = src.split("\n");
|
||||
|
||||
var reMessage = /const\s+char\s*\*\s+([\w\d]+)\s*=\s*"(.*)"/;
|
||||
var reSettingsDescStart = /const\s+char\s*\*\s+SettingsDescriptions\[/;
|
||||
var reSettingsNamesStart = /const\s+char\s*\*\s+SettingsShortNames\[/;
|
||||
var reSettingsMenuDescStart = /const\s+char\s*\*\s+SettingsMenuEntriesDescriptions\[/;
|
||||
var reChar = /const\s+char\s+([\w\d]+)\s*=\s*'(\w)'/;
|
||||
var reMenuMode = /SettingsShortNameType\s*=\s*SHORT_NAME_(\w+)_LINE/;
|
||||
|
||||
var reMenuStart = /\s*const\s+char\s*\*\s+SettingsMenuEntries\[/;
|
||||
|
||||
// var reString = /^\s*"(.*)"/;
|
||||
var reString = /"(.*)"/;
|
||||
var reSingleLine = /{\s*"(.*)"\s*}/;
|
||||
var reDoubleLine = /{\s*"(.*)"\s*,\s*"(.*)"\s*}/;
|
||||
|
||||
var mode = '';
|
||||
var entryIndex = 0;
|
||||
for (var li = 0; li < srcLines.length; li++) {
|
||||
// trim lines
|
||||
line = srcLines[li] = srcLines[li].trim();
|
||||
|
||||
// if entering a new lang block
|
||||
if (startsWith(line, "#ifdef LANG_")) {
|
||||
mode = 'new-language';
|
||||
langCode = line.substring(12);
|
||||
lang = langMap[langCode];
|
||||
// use existing or instantiate new
|
||||
if (!isDefined(lang)) {
|
||||
lang = {
|
||||
languageCode: langCode,
|
||||
messages: {},
|
||||
characters: {},
|
||||
menuDouble : false,
|
||||
menuGroups: {},
|
||||
menuOptions: {}
|
||||
};
|
||||
langMap[langCode] = lang;
|
||||
app.languages[app.languages.length] = langCode;
|
||||
}
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Menu type
|
||||
reMenuMode.lastIndex = 0;
|
||||
match = reMenuMode.exec(line);
|
||||
if (match) {
|
||||
lang.menuDouble = match[1] == 'DOUBLE';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Messages
|
||||
reMessage.lastIndex = 0;
|
||||
match = reMessage.exec(line);
|
||||
if (match) {
|
||||
lang.messages[match[1]] = xunescape(match[2]);
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Chars descriptions
|
||||
reChar.lastIndex = 0;
|
||||
match = reChar.exec(line);
|
||||
if (match) {
|
||||
// found description block start
|
||||
mode = 'char';
|
||||
lang.characters[match[1]] = xunescape(match[2]);
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
// Settings descriptions
|
||||
reSettingsDescStart.lastIndex = 0;
|
||||
match = reSettingsDescStart.exec(line);
|
||||
if (match) {
|
||||
// found description block start
|
||||
mode = 'settingsDesc';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
reSettingsNamesStart.lastIndex = 0;
|
||||
match = reSettingsNamesStart.exec(line);
|
||||
if (match) {
|
||||
// found description block start
|
||||
mode = 'settingsNames';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
reMenuStart.lastIndex = 0;
|
||||
match = reMenuStart.exec(line);
|
||||
if (match) {
|
||||
// found description block start
|
||||
mode = 'menu';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
reSettingsMenuDescStart.lastIndex = 0;
|
||||
match = reSettingsMenuDescStart.exec(line);
|
||||
if (match) {
|
||||
// found description block start
|
||||
mode = 'menuDesc';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mode == 'menu') {
|
||||
// processing menu group names
|
||||
reString.lastIndex = 0;
|
||||
match = reString.exec(line);
|
||||
if (match) {
|
||||
// found description string
|
||||
var entry = getMenuGroup(entryIndex);
|
||||
var m = match[1].split("\\n");
|
||||
entry.text2[0] = xunescape(m[0]);
|
||||
entry.text2[1] = xunescape(m[1]);
|
||||
entryIndex++;
|
||||
}
|
||||
} else if (mode == 'menuDesc') {
|
||||
// processing menu group descriptions
|
||||
reString.lastIndex = 0;
|
||||
match = reString.exec(line);
|
||||
if (match) {
|
||||
// found description string
|
||||
var entry = getMenuGroup(entryIndex);
|
||||
entry.desc = xunescape(match[1]);
|
||||
entryIndex++;
|
||||
}
|
||||
} else if (mode == 'settingsDesc') {
|
||||
// processing option descriptions
|
||||
reString.lastIndex = 0;
|
||||
match = reString.exec(line);
|
||||
if (match) {
|
||||
// found description string
|
||||
var entry = getMenuOption(entryIndex);
|
||||
entry.desc = xunescape(match[1]);
|
||||
entryIndex++;
|
||||
}
|
||||
} else if (mode == 'settingsNames') {
|
||||
reDoubleLine.lastIndex = 0;
|
||||
match = reDoubleLine.exec(line);
|
||||
if (match) {
|
||||
var entry = getMenuOption(entryIndex);
|
||||
entry.text2[0] = xunescape(match[1]);
|
||||
entry.text2[1] = xunescape(match[2]);
|
||||
entryIndex++;
|
||||
} else {
|
||||
reSingleLine.lastIndex = 0;
|
||||
match = reSingleLine.exec(line);
|
||||
if (match) {
|
||||
var entry = getMenuOption(entryIndex);
|
||||
entry.text = xunescape(match[1]);
|
||||
entryIndex++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
app.done = 1;
|
||||
}
|
||||
|
||||
function getMenuOption(entryIndex) {
|
||||
var optionDef = def.menuOptions[entryIndex];
|
||||
if (!isDefined(optionDef)) {
|
||||
var s = "Could not find menu option with index "+entryIndex;
|
||||
alert(s);
|
||||
throw s;
|
||||
}
|
||||
var id = optionDef.id;
|
||||
var entry = lang.menuOptions[id];
|
||||
if (!isDefined(entry)) {
|
||||
entry =
|
||||
{
|
||||
"text": "",
|
||||
"text2": ["", ""],
|
||||
"desc": ""
|
||||
}
|
||||
lang.menuOptions[id] = entry;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
function getMenuGroup(entryIndex) {
|
||||
var optionDef = def.menuGroups[entryIndex];
|
||||
if (!isDefined(optionDef)) {
|
||||
var s = "Could not find menu group with index "+entryIndex;
|
||||
alert(s);
|
||||
throw s;
|
||||
}
|
||||
var id = optionDef.id;
|
||||
var entry = lang.menuGroups[id];
|
||||
if (!isDefined(entry)) {
|
||||
entry =
|
||||
{
|
||||
"text2": ["", ""],
|
||||
"desc": ""
|
||||
}
|
||||
lang.menuGroups[id] = entry;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
function markSaved(lang) {
|
||||
document.getElementById("row_"+lang).classList.add("saved");
|
||||
}
|
||||
|
||||
function loaded() {
|
||||
app = new Vue({
|
||||
el : '#app',
|
||||
data : {
|
||||
languages: [],
|
||||
done : false,
|
||||
def : {
|
||||
}
|
||||
|
||||
},
|
||||
methods : {
|
||||
vSave : function(lang) {
|
||||
save(lang);
|
||||
markSaved(lang);
|
||||
},
|
||||
vView : function(lang) {
|
||||
view(lang);
|
||||
markSaved(lang);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.def = def;
|
||||
defMsgMap = copyArrayToMap(app.def.messages);
|
||||
defCharMap = copyArrayToMap(app.def.characters);
|
||||
defGrpMap = copyArrayToMap(app.def.menuGroups);
|
||||
defOptMap = copyArrayToMap(app.def.menuOptions);
|
||||
}
|
||||
|
||||
window.onload=loaded;
|
||||
</script>
|
||||
<link href="translations.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="app">
|
||||
<h1>TS100 Translation Parser</h1>
|
||||
<table class="header data">
|
||||
<tr>
|
||||
<td class="label">Translation.cpp</td>
|
||||
<td class="value">
|
||||
<input type="file" id="translation-cpp-file" onchange="translationFileSelected(this)" accept=".cpp">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="data" v-if="done">
|
||||
<div class="value" v-for="lang in languages" :id="'row_'+lang">
|
||||
<input type="button" :value="'Save '+lang" v-on:click="vSave(lang)">
|
||||
<input type="button" :value="'View '+lang" v-on:click="vView(lang)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,110 +1,110 @@
|
||||
* {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #66A;
|
||||
}
|
||||
|
||||
h1 span {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
table.data, div.data {
|
||||
border: 1px solid #888;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.value {
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.header input {
|
||||
width: 50% !important;
|
||||
}
|
||||
|
||||
input.short {
|
||||
width: 150px !important;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.header .selected {
|
||||
display: block;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.stringId {
|
||||
font-family: monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.label {
|
||||
background-color: #ddf;
|
||||
padding: 0.5em;
|
||||
width: 20%;
|
||||
color: #66A;
|
||||
}
|
||||
|
||||
.value {
|
||||
background-color: #eef;
|
||||
}
|
||||
|
||||
.value .label {
|
||||
width: 99%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
td input {
|
||||
width: 99%;
|
||||
}
|
||||
|
||||
input.unchanged, input.empty, .unchanged input, .empty input {
|
||||
background-color: #ffc;
|
||||
}
|
||||
|
||||
input.invalid, .invalid input {
|
||||
background-color: #f99;
|
||||
}
|
||||
|
||||
.ref, .tran input {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.ref::before, .ref::after {
|
||||
color: #99F;
|
||||
font-family: sans-serif;
|
||||
content: "\"";
|
||||
}
|
||||
|
||||
.note {
|
||||
color : #66A;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.constraint {
|
||||
float: right;
|
||||
display: inline-block;
|
||||
font-family: monospace;
|
||||
color: #66A;
|
||||
}
|
||||
|
||||
.invalid .constraint {
|
||||
color: #f00;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.saved {
|
||||
background-color: #ddd;
|
||||
* {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #66A;
|
||||
}
|
||||
|
||||
h1 span {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
table.data, div.data {
|
||||
border: 1px solid #888;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.value {
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.header input {
|
||||
width: 50% !important;
|
||||
}
|
||||
|
||||
input.short {
|
||||
width: 150px !important;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.header .selected {
|
||||
display: block;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.stringId {
|
||||
font-family: monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.label {
|
||||
background-color: #ddf;
|
||||
padding: 0.5em;
|
||||
width: 20%;
|
||||
color: #66A;
|
||||
}
|
||||
|
||||
.value {
|
||||
background-color: #eef;
|
||||
}
|
||||
|
||||
.value .label {
|
||||
width: 99%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
td input {
|
||||
width: 99%;
|
||||
}
|
||||
|
||||
input.unchanged, input.empty, .unchanged input, .empty input {
|
||||
background-color: #ffc;
|
||||
}
|
||||
|
||||
input.invalid, .invalid input {
|
||||
background-color: #f99;
|
||||
}
|
||||
|
||||
.ref, .tran input {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.ref::before, .ref::after {
|
||||
color: #99F;
|
||||
font-family: sans-serif;
|
||||
content: "\"";
|
||||
}
|
||||
|
||||
.note {
|
||||
color : #66A;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.constraint {
|
||||
float: right;
|
||||
display: inline-block;
|
||||
font-family: monospace;
|
||||
color: #66A;
|
||||
}
|
||||
|
||||
.invalid .constraint {
|
||||
color: #f00;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.saved {
|
||||
background-color: #ddd;
|
||||
}
|
||||
@@ -1,68 +1,68 @@
|
||||
function saveToFile(txt, filename){
|
||||
var a = document.createElement('a');
|
||||
a.setAttribute("style", "display: none");
|
||||
document.body.appendChild(a);
|
||||
a.setAttribute('href', 'data:application/json;charset=utf-8,'+encodeURIComponent(txt));
|
||||
a.setAttribute('download', filename);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
}
|
||||
|
||||
function saveJSON(obj, filename){
|
||||
var txt = JSON.stringify(obj,"", "\t");
|
||||
saveToFile(txt, filename);
|
||||
}
|
||||
|
||||
function showJSON(obj, filename) {
|
||||
var txt = JSON.stringify(obj,"", "\t");
|
||||
var a = window.open("", "_blank").document;
|
||||
a.write("<PLAINTEXT>");
|
||||
a.write(txt);
|
||||
a.title = filename;
|
||||
}
|
||||
|
||||
function startsWith(str, prefix) {
|
||||
return str.substring(0, prefix.length) == prefix;
|
||||
}
|
||||
|
||||
function endsWith(str, suffix) {
|
||||
return str.substring(str.length-suffix.length) == suffix;
|
||||
}
|
||||
|
||||
function isDefined(obj) {
|
||||
return typeof obj !== 'undefined';
|
||||
}
|
||||
|
||||
function isNumber(obj) {
|
||||
return isDefined(obj) && obj != null;
|
||||
}
|
||||
|
||||
function isDefinedNN(obj) {
|
||||
return isDefined(obj) && obj != null;
|
||||
}
|
||||
|
||||
function padLeft(str, chr, maxLen) {
|
||||
str = str.toString();
|
||||
return str.length < maxLen ? padLeft(chr + str, chr, maxLen) : str;
|
||||
}
|
||||
|
||||
// sourceArray contains a list of objects that have a property "id". This methods makes a map using the "id" as a key, and the owning object as a value.
|
||||
function copyArrayToMap(sourceArray, map) {
|
||||
if (!isDefined(map)) {
|
||||
map = {};
|
||||
}
|
||||
var len = sourceArray.length;
|
||||
for (var i = 0; i<len; i++) {
|
||||
var v = sourceArray[i];
|
||||
map[v.id] = v;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
function checkTranslationFile(fileName) {
|
||||
return startsWith(fileName, "translation_") && endsWith(fileName, ".json") || confirm("Are you sure that you want to use "+fileName+" instead of a translation_*.json file?");
|
||||
}
|
||||
|
||||
function xunescape(str) {
|
||||
return str.replace(/\\/g, "");
|
||||
}
|
||||
function saveToFile(txt, filename){
|
||||
var a = document.createElement('a');
|
||||
a.setAttribute("style", "display: none");
|
||||
document.body.appendChild(a);
|
||||
a.setAttribute('href', 'data:application/json;charset=utf-8,'+encodeURIComponent(txt));
|
||||
a.setAttribute('download', filename);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
}
|
||||
|
||||
function saveJSON(obj, filename){
|
||||
var txt = JSON.stringify(obj,"", "\t");
|
||||
saveToFile(txt, filename);
|
||||
}
|
||||
|
||||
function showJSON(obj, filename) {
|
||||
var txt = JSON.stringify(obj,"", "\t");
|
||||
var a = window.open("", "_blank").document;
|
||||
a.write("<PLAINTEXT>");
|
||||
a.write(txt);
|
||||
a.title = filename;
|
||||
}
|
||||
|
||||
function startsWith(str, prefix) {
|
||||
return str.substring(0, prefix.length) == prefix;
|
||||
}
|
||||
|
||||
function endsWith(str, suffix) {
|
||||
return str.substring(str.length-suffix.length) == suffix;
|
||||
}
|
||||
|
||||
function isDefined(obj) {
|
||||
return typeof obj !== 'undefined';
|
||||
}
|
||||
|
||||
function isNumber(obj) {
|
||||
return isDefined(obj) && obj != null;
|
||||
}
|
||||
|
||||
function isDefinedNN(obj) {
|
||||
return isDefined(obj) && obj != null;
|
||||
}
|
||||
|
||||
function padLeft(str, chr, maxLen) {
|
||||
str = str.toString();
|
||||
return str.length < maxLen ? padLeft(chr + str, chr, maxLen) : str;
|
||||
}
|
||||
|
||||
// sourceArray contains a list of objects that have a property "id". This methods makes a map using the "id" as a key, and the owning object as a value.
|
||||
function copyArrayToMap(sourceArray, map) {
|
||||
if (!isDefined(map)) {
|
||||
map = {};
|
||||
}
|
||||
var len = sourceArray.length;
|
||||
for (var i = 0; i<len; i++) {
|
||||
var v = sourceArray[i];
|
||||
map[v.id] = v;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
function checkTranslationFile(fileName) {
|
||||
return startsWith(fileName, "translation_") && endsWith(fileName, ".json") || confirm("Are you sure that you want to use "+fileName+" instead of a translation_*.json file?");
|
||||
}
|
||||
|
||||
function xunescape(str) {
|
||||
return str.replace(/\\/g, "");
|
||||
}
|
||||
|
||||
@@ -1,205 +1,205 @@
|
||||
var def =
|
||||
{
|
||||
"messages": [
|
||||
{
|
||||
"id": "SettingsCalibrationWarning"
|
||||
},
|
||||
{
|
||||
"id": "SettingsResetWarning"
|
||||
},
|
||||
{
|
||||
"id": "UVLOWarningString",
|
||||
"maxLen": 8
|
||||
},
|
||||
{
|
||||
"id": "UndervoltageString",
|
||||
"maxLen": 16
|
||||
},
|
||||
{
|
||||
"id": "InputVoltageString",
|
||||
"maxLen": 11,
|
||||
"note": "Preferably end with a space"
|
||||
},
|
||||
{
|
||||
"id": "WarningTipTempString",
|
||||
"maxLen": 12,
|
||||
"note": "Preferably end with a space"
|
||||
},
|
||||
{
|
||||
"id": "BadTipString",
|
||||
"maxLen": 8
|
||||
},
|
||||
{
|
||||
"id": "SleepingSimpleString",
|
||||
"maxLen": 4
|
||||
},
|
||||
{
|
||||
"id": "SleepingAdvancedString",
|
||||
"maxLen": 16
|
||||
},
|
||||
{
|
||||
"id": "WarningSimpleString",
|
||||
"maxLen": 4
|
||||
},
|
||||
{
|
||||
"id": "WarningAdvancedString",
|
||||
"maxLen": 16
|
||||
},
|
||||
{
|
||||
"id": "SleepingTipAdvancedString",
|
||||
"maxLen": 6
|
||||
},
|
||||
{
|
||||
"id": "IdleTipString",
|
||||
"lenSum":
|
||||
{
|
||||
"fields": ["IdleTipString", "IdleSetString"],
|
||||
"maxLen": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "IdleSetString",
|
||||
"lenSum":
|
||||
{
|
||||
"fields": ["IdleTipString", "IdleSetString"],
|
||||
"maxLen": 10
|
||||
},
|
||||
"note": "Preferably start with a space"
|
||||
},
|
||||
{
|
||||
"id": "TipDisconnectedString",
|
||||
"maxLen": 16
|
||||
},
|
||||
{
|
||||
"id" :"SolderingAdvancedPowerPrompt",
|
||||
"maxLen": null
|
||||
}
|
||||
],
|
||||
"characters": [
|
||||
{
|
||||
"id": "SettingRightChar",
|
||||
"len": 1
|
||||
},
|
||||
{
|
||||
"id": "SettingLeftChar",
|
||||
"len": 1
|
||||
},
|
||||
{
|
||||
"id": "SettingAutoChar",
|
||||
"len": 1
|
||||
},
|
||||
{
|
||||
"id": "SettingFastChar",
|
||||
"len": 1
|
||||
},
|
||||
{
|
||||
"id": "SettingSlowChar",
|
||||
"len": 1
|
||||
}
|
||||
],
|
||||
"menuGroups": [
|
||||
{
|
||||
"id": "SolderingMenu",
|
||||
"maxLen": 11
|
||||
},
|
||||
{
|
||||
"id": "PowerSavingMenu",
|
||||
"maxLen": 11
|
||||
},
|
||||
{
|
||||
"id": "UIMenu",
|
||||
"maxLen": 11
|
||||
},
|
||||
{
|
||||
"id": "AdvancedMenu",
|
||||
"maxLen": 11
|
||||
}
|
||||
],
|
||||
"menuOptions": [
|
||||
{
|
||||
"id": "PowerSource",
|
||||
"maxLen": 5,
|
||||
"maxLen2": 11
|
||||
},
|
||||
{
|
||||
"id": "SleepTemperature",
|
||||
"maxLen": 4,
|
||||
"maxLen2": 9
|
||||
},
|
||||
{
|
||||
"id": "SleepTimeout",
|
||||
"maxLen": 4,
|
||||
"maxLen2": 9
|
||||
},
|
||||
{
|
||||
"id": "ShutdownTimeout",
|
||||
"maxLen": 5,
|
||||
"maxLen2": 11
|
||||
},
|
||||
{
|
||||
"id": "MotionSensitivity",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "TemperatureUnit",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "AdvancedIdle",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "DisplayRotation",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "BoostEnabled",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "BoostTemperature",
|
||||
"maxLen": 4,
|
||||
"maxLen2": 9
|
||||
},
|
||||
{
|
||||
"id": "AutoStart",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "CooldownBlink",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "TemperatureCalibration",
|
||||
"maxLen": 8,
|
||||
"maxLen2": 16
|
||||
},
|
||||
{
|
||||
"id": "SettingsReset",
|
||||
"maxLen": 8,
|
||||
"maxLen2": 16
|
||||
},
|
||||
{
|
||||
"id": "VoltageCalibration",
|
||||
"maxLen": 8,
|
||||
"maxLen2": 16
|
||||
},
|
||||
{
|
||||
"id": "AdvancedSoldering",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "ScrollingSpeed",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 11
|
||||
}
|
||||
]
|
||||
var def =
|
||||
{
|
||||
"messages": [
|
||||
{
|
||||
"id": "SettingsCalibrationWarning"
|
||||
},
|
||||
{
|
||||
"id": "SettingsResetWarning"
|
||||
},
|
||||
{
|
||||
"id": "UVLOWarningString",
|
||||
"maxLen": 8
|
||||
},
|
||||
{
|
||||
"id": "UndervoltageString",
|
||||
"maxLen": 16
|
||||
},
|
||||
{
|
||||
"id": "InputVoltageString",
|
||||
"maxLen": 11,
|
||||
"note": "Preferably end with a space"
|
||||
},
|
||||
{
|
||||
"id": "WarningTipTempString",
|
||||
"maxLen": 12,
|
||||
"note": "Preferably end with a space"
|
||||
},
|
||||
{
|
||||
"id": "BadTipString",
|
||||
"maxLen": 8
|
||||
},
|
||||
{
|
||||
"id": "SleepingSimpleString",
|
||||
"maxLen": 4
|
||||
},
|
||||
{
|
||||
"id": "SleepingAdvancedString",
|
||||
"maxLen": 16
|
||||
},
|
||||
{
|
||||
"id": "WarningSimpleString",
|
||||
"maxLen": 4
|
||||
},
|
||||
{
|
||||
"id": "WarningAdvancedString",
|
||||
"maxLen": 16
|
||||
},
|
||||
{
|
||||
"id": "SleepingTipAdvancedString",
|
||||
"maxLen": 6
|
||||
},
|
||||
{
|
||||
"id": "IdleTipString",
|
||||
"lenSum":
|
||||
{
|
||||
"fields": ["IdleTipString", "IdleSetString"],
|
||||
"maxLen": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "IdleSetString",
|
||||
"lenSum":
|
||||
{
|
||||
"fields": ["IdleTipString", "IdleSetString"],
|
||||
"maxLen": 10
|
||||
},
|
||||
"note": "Preferably start with a space"
|
||||
},
|
||||
{
|
||||
"id": "TipDisconnectedString",
|
||||
"maxLen": 16
|
||||
},
|
||||
{
|
||||
"id" :"SolderingAdvancedPowerPrompt",
|
||||
"maxLen": null
|
||||
}
|
||||
],
|
||||
"characters": [
|
||||
{
|
||||
"id": "SettingRightChar",
|
||||
"len": 1
|
||||
},
|
||||
{
|
||||
"id": "SettingLeftChar",
|
||||
"len": 1
|
||||
},
|
||||
{
|
||||
"id": "SettingAutoChar",
|
||||
"len": 1
|
||||
},
|
||||
{
|
||||
"id": "SettingFastChar",
|
||||
"len": 1
|
||||
},
|
||||
{
|
||||
"id": "SettingSlowChar",
|
||||
"len": 1
|
||||
}
|
||||
],
|
||||
"menuGroups": [
|
||||
{
|
||||
"id": "SolderingMenu",
|
||||
"maxLen": 11
|
||||
},
|
||||
{
|
||||
"id": "PowerSavingMenu",
|
||||
"maxLen": 11
|
||||
},
|
||||
{
|
||||
"id": "UIMenu",
|
||||
"maxLen": 11
|
||||
},
|
||||
{
|
||||
"id": "AdvancedMenu",
|
||||
"maxLen": 11
|
||||
}
|
||||
],
|
||||
"menuOptions": [
|
||||
{
|
||||
"id": "PowerSource",
|
||||
"maxLen": 5,
|
||||
"maxLen2": 11
|
||||
},
|
||||
{
|
||||
"id": "SleepTemperature",
|
||||
"maxLen": 4,
|
||||
"maxLen2": 9
|
||||
},
|
||||
{
|
||||
"id": "SleepTimeout",
|
||||
"maxLen": 4,
|
||||
"maxLen2": 9
|
||||
},
|
||||
{
|
||||
"id": "ShutdownTimeout",
|
||||
"maxLen": 5,
|
||||
"maxLen2": 11
|
||||
},
|
||||
{
|
||||
"id": "MotionSensitivity",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "TemperatureUnit",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "AdvancedIdle",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "DisplayRotation",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "BoostEnabled",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "BoostTemperature",
|
||||
"maxLen": 4,
|
||||
"maxLen2": 9
|
||||
},
|
||||
{
|
||||
"id": "AutoStart",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "CooldownBlink",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "TemperatureCalibration",
|
||||
"maxLen": 8,
|
||||
"maxLen2": 16
|
||||
},
|
||||
{
|
||||
"id": "SettingsReset",
|
||||
"maxLen": 8,
|
||||
"maxLen2": 16
|
||||
},
|
||||
{
|
||||
"id": "VoltageCalibration",
|
||||
"maxLen": 8,
|
||||
"maxLen2": 16
|
||||
},
|
||||
{
|
||||
"id": "AdvancedSoldering",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 13
|
||||
},
|
||||
{
|
||||
"id": "ScrollingSpeed",
|
||||
"maxLen": 6,
|
||||
"maxLen2": 11
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user