Skip to content

Commit

Permalink
update format of result
Browse files Browse the repository at this point in the history
  • Loading branch information
minorua committed Jul 13, 2024
1 parent 04b1dcd commit 505b6ad
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 40 deletions.
91 changes: 89 additions & 2 deletions checker.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
html {

height: 100%;

}

body {
background-color: #4682B4;

height: 100%;
margin: 0;

}

#main {

background-color: white;
min-height: 100%;
margin: auto;

}

#main > div {

padding: 0 10px;

}

#title {

margin: 0;
padding: 0.5em 1em;
width: 100%;
Expand All @@ -27,57 +35,136 @@ body {
line-height: 1em;
color: #EEEEEE;
background-color: #124766;

}

#output {
#result {

font-size: small;

}

section {

padding-bottom: 30px;

}

h3 {

margin: 0;
padding: 10px;
height: 20px;
border-bottom: 1px solid gray;
background-color: #EEEEEE;

}

h3 > span.count {

display: inline-block;
min-width: 30px;
height: 20px;
text-align: center;
line-height: 20px;
margin-left: 5px;
font-size: smaller;

}

h4 {

padding: 3px 8px;

}

section.error h4 {

background-color: rgba(255, 0, 0, 0.5)

}

section.warning h4 {

background-color: rgba(255, 255, 0, 0.5)

}

h4 > span.count {

display: inline-block;
min-width: 20px;
height: 15px;
text-align: center;
line-height: 15px;
margin-left: 10px;
font-size: smaller;

}

#footer {

border-top: 1px solid #4682B4;
position: sticky;
top: 100vh;

}

#panel {

position: absolute;
left: 26%;
top: 10%;
width: 48%;
height: 80%;

}

.method {

color: gray;
font-size: large;

}

#panel table {

display: flex;
justify-content: center;

}

#panel td {

padding: 10px;

}

#panel select {

width: 120px;

}

#fetch_button_line {

text-align: center;

}

#progress {

display: none;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
text-align: center;

}

#progress > div {

background-color: white;

}
100 changes: 63 additions & 37 deletions checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ window.addEventListener("load", function () {

}

document.getElementById("panel").style.display = "none";

const filename = "qgis_" + lang + ".ts";

setStatusText("Fetching " + filename + ' in "' + branch + '" branch from GitHub...');
Expand Down Expand Up @@ -118,56 +120,79 @@ window.addEventListener("load", function () {

function writeResult(checker) {

document.getElementById("panel").style.display = "none";
const escape = function (str) {

return str.replaceAll('&', '&amp').replaceAll('<', '&lt').replaceAll('>', '&gt;');

const outList = document.getElementById("output").getElementsByTagName("ul")[0];
const addListItem = (html) => {
outList.innerHTML += html;
};

let r, html = "";
const htmlGroupdedByMsg = function (res_list) {

html += "<li>" + (checker.filename || "Unknown") + ":";
html += " <ul>";
let html = '';
let groups = {};

html += " <li>" + checker.stats.contextCount + " contexts, " + checker.stats.messageCount + " messages, " + checker.stats.untranslatedCount + " untranslated</li>";
for (let r of res_list) {

html += " <li>" + checker.results[ERROR_LEVEL.CRITICAL].length + " critical errors";
html += " <ul>";
for (r of checker.results[ERROR_LEVEL.CRITICAL]) {
html += "<li>" + r.msg;
html += "<div>[" + r.context + "]</div>";
html += "<div>" + r.source + "</div>";
html += "<div>" + r.translation + "</div></li>";
}
html += " </ul>";
html += " </li>";

html += " <li>" + checker.results[ERROR_LEVEL.WARNING].length + " warnings";
html += " <ul>";
for (r of checker.results[ERROR_LEVEL.WARNING]) {
html += "<li>" + r.msg;
html += "<div>[" + r.context + "]</div>";
html += "<div>" + r.source + "</div>";
html += "<div>" + r.translation + "</div></li>";
}
html += " </ul>";
html += " </li>";
if (groups[r.msg] === undefined) {

groups[r.msg] = [r];

html += " </ul>";
html += "</li>";
}
else {

addListItem(html);
groups[r.msg].push(r);

}

}

for (let [msg, items] of Object.entries(groups)) {

html += '<h4>' + msg + ' <span class="count">(' + items.length + ')</span></h4>';
html += '<ul>';
for (let r of items) {

html += '<li><div>[' + r.context + ']</div>';
html += '<div>' + escape(r.source) + '</div>';
html += '<div>' + escape(r.translation) + '</div></li>';

}
html += '</ul>';

}

return html;
};

let html = '';

html += '<h2>' + (checker.filename || 'Unknown') + '</h2>';

html += '<section class="stats">';
html += '<h3>Statistics</h3>';
html += '<ul>';
html += ' <li>' + checker.stats.contextCount + ' contexts, ' + checker.stats.messageCount + ' messages, ' + checker.stats.untranslatedCount + ' untranslated</li>';
html += '</ul>';
html += '</section>';

html += '<section class="error">';
html += '<h3>Critical Errors <span class="count">(' + checker.results[ERROR_LEVEL.CRITICAL].length + ')</span></h3>';
html += htmlGroupdedByMsg(checker.results[ERROR_LEVEL.CRITICAL]);
html += '</section>';

html += '<section class="warning">';
html += '<h3>Warnings <span class="count">(' + checker.results[ERROR_LEVEL.WARNING].length + ')</span></h3>';
html += htmlGroupdedByMsg(checker.results[ERROR_LEVEL.WARNING]);
html += '</section>';

document.getElementById("result").innerHTML += html;

}


function loadFiles(files) {

const outList = document.getElementById("output").getElementsByTagName("ul")[0];
const addListItem = (html) => {
outList.innerHTML += html;
};
document.getElementById("panel").style.display = "none";

token = {};

Expand Down Expand Up @@ -201,7 +226,8 @@ function loadFiles(files) {
for (let k of Object.keys(token).sort()) {
words.push("<div>" + k.replace("<", "&lt;").replace(">", "&gt") + ": " + token[k] + "</div>");
}
addListItem("<li>" + words.join("") + "</li>");

document.getElementById("result").innerHTML += "<div>" + words.join("") + "</div>";

setStatusText("Completed!", 2000);
});
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body>
<div id="main">
<h1 id="title">QGIS Translation Checker</h1>
<div id="output"><ul></ul></div>
<div id="result"><ul></ul></div>
<div id="footer"><a href="https://github.com/minorua">GitHub</a></div>
</div>
<div id="panel">
Expand Down

0 comments on commit 505b6ad

Please sign in to comment.