Sort mapped entries

This commit is contained in:
2025-11-11 10:48:34 +01:00
parent 859fb0e19e
commit 3d9266fdd9
3 changed files with 20 additions and 6 deletions

View File

@@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="static/css/qa.css?6903a867d3d53" /> <link rel="stylesheet" type="text/css" href="static/css/qa.css?69130637d6711" />
<link rel="manifest" href="/manifest.webmanifest" /> <link rel="manifest" href="/manifest.webmanifest" />
<meta name="theme-color" content="#aa4400" /> <meta name="theme-color" content="#aa4400" />
@@ -32,8 +32,8 @@
</head> </head>
<body class="loading"> <body class="loading">
<!-- <script src="/static/js/qa.js?6903a867d3d54" type="text/javascript" async></script> --> <!-- <script src="/static/js/qa.js?69130637d6714" type="text/javascript" async></script> -->
<script src="/static/js/qa.min.js?6903a867d3d55" type="text/javascript" async></script> <script src="/static/js/qa.min.js?69130637d6715" type="text/javascript" async></script>
</body> </body>
</html> </html>

View File

@@ -284,12 +284,13 @@ class ConcPage {
const resultsWrap = document.createElement("div"); const resultsWrap = document.createElement("div");
convertB.addEventListener('click', function() { convertB.addEventListener('click', function() {
let lines = [];
let keysAreNumeric = false; let keysAreNumeric = false;
if (listOptions[1] !== undefined && listOptions[1] !== null) { if (listOptions[1] !== undefined && listOptions[1] !== null) {
keysAreNumeric = true; keysAreNumeric = true;
} }
// First gather lines by target type for rough sorting
let linesByType = {};
for (let m of matchSelects) { for (let m of matchSelects) {
let line = ("'" + m.getAttribute("data-input") + "'").padEnd(40, " ") + " => "; let line = ("'" + m.getAttribute("data-input") + "'").padEnd(40, " ") + " => ";
@@ -300,11 +301,24 @@ class ConcPage {
line += "'" + m.value + "',"; line += "'" + m.value + "',";
} }
line += ' // ' + listOptionsEn[m.value]; line += ' // ' + listOptionsEn[m.value];
lines.push(line);
// A
if (linesByType[m.value] === undefined) {
linesByType[m.value] = [];
}
linesByType[m.value].push(line);
m.setAttribute("readonly", "readonly"); m.setAttribute("readonly", "readonly");
} }
// Then put the lines together so they can be joined
let lines = [];
for (let key in linesByType) {
for (let l of linesByType[key]) {
lines.push(l);
}
}
const output = " ".repeat(8) + lines.join("\n" + " ".repeat(8)); const output = " ".repeat(8) + lines.join("\n" + " ".repeat(8));
console.log(output); console.log(output);

File diff suppressed because one or more lines are too long