Revised the summary editor to allow the "*" start character as the multiplication operation in addition to the "×" times character.

This commit is contained in:
依瑪貓 2023-03-04 00:05:15 +08:00
parent b5aaee4d15
commit f6ed6b10a7

View File

@ -769,7 +769,7 @@ class GeneralTripTab extends TagTabPlane {
* @override
*/
populate() {
const found = this.editor.summary.value.match(/^([^—]+)—([^—→↔]+)([→↔])(.+?)(?:×\d+)?(?:\([^)]+\))?$/);
const found = this.editor.summary.value.match(/^([^—]+)—([^—→↔]+)([→↔])(.+?)(?:[*×]\d+)?(?:\([^)]+\))?$/);
if (found === null) {
return false;
}
@ -957,7 +957,7 @@ class BusTripTab extends TagTabPlane {
* @override
*/
populate() {
const found = this.editor.summary.value.match(/^([^—]+)—([^—]+)—([^—→]+)→(.+?)(?:×\d+)?(?:\([^)]+\))?$/);
const found = this.editor.summary.value.match(/^([^—]+)—([^—]+)—([^—→]+)→(.+?)(?:[*×]\d+)?(?:\([^)]+\))?$/);
if (found === null) {
return false;
}
@ -1142,7 +1142,7 @@ class AnnotationTab extends TabPlane {
* @override
*/
updateSummary() {
const found = this.editor.summary.value.match(/^(.*?)(?:×\d+)?(?:\([^)]+\))?$/);
const found = this.editor.summary.value.match(/^(.*?)(?:[*×]\d+)?(?:\([^)]+\))?$/);
if (found !== null) {
this.editor.summary.value = found[1];
}
@ -1171,16 +1171,19 @@ class AnnotationTab extends TabPlane {
* @override
*/
populate() {
const found = this.editor.summary.value.match(/^(.*?)(?:×(\d+))?(?:\(([^)]+)\))?$/);
if (found[2] === undefined) {
const found = this.editor.summary.value.match(/^(.*?)(?:[*×](\d+))?(?:\(([^)]+)\))?$/);
this.editor.summary.value = found[1];
if (found[2] === undefined || parseInt(found[2]) === 1) {
this.editor.number.value = "";
} else {
this.editor.number.value = found[2];
this.editor.summary.value = this.editor.summary.value + "×" + this.editor.number.value;
}
if (found[3] === undefined) {
this.editor.note.value = "";
} else {
this.editor.note.value = found[3];
this.editor.summary.value = this.editor.summary.value + "(" + this.editor.note.value + ")";
}
return true;
}