Skip to content

Commit

Permalink
devtool: use more modern string interpolation instead of concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Mar 3, 2022
1 parent 4818b08 commit c94a6d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions apps/tools/librelingo_tools/templates/converter.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<div id="output">
<div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
var source_to_target = null;
Expand All @@ -38,13 +37,16 @@
const cleaned = original.replace(/[^a-zA-Z-]/g, " ");
const words = cleaned.split(" ");
var html = `<table class="table">`;
html += '<thead>';
html += '<tr>';
if (direction == 'target-to-source') {
html += '<th>' + course_data['target_language_name'] + '</th><th>' + course_data['source_language_name'] + '</th>'
html += `<th>${course_data['target_language_name']}</th><th>${course_data['source_language_name']}</th>`;
} else {
html += '<th>' + course_data['source_language_name'] + '</th><th>' + course_data['target_language_name'] + '</th>'
html += `<th>${course_data['source_language_name']}</th><th>${course_data['target_language_name']}</th>`;
}
html += '</tr>';
html += '</thead>';
html += '<tbody>';
for (var ix = 0; ix < words.length; ix++) {
if (words[ix] == "") {
continue;
Expand All @@ -55,21 +57,22 @@
if (direction == 'target-to-source') {
const translation = target_to_source[word];
if (translation) {
html += '<td><a href="target/' + word + '.html">' + words[ix] + '</a></td><td>' + translation + '</td>';
html += `<td><a href="target/${word}.html">${words[ix]}</a></td><td>${translation}</td>`;
} else {
html += '<td class="has-background-danger-light">' + words[ix] + '</td><td class="has-background-danger-light">' + '</td>';
html += `<td class="has-background-danger-light">${words[ix]}</td><td class="has-background-danger-light"></td>`;
}
} else {
const translation = source_to_target[word];
if (translation) {
html += '<td><a href="source/' + word + '.html">' + words[ix] + '</a></td><td>' + translation + '</td>';
html += `<td><a href="source/${word}.html">${words[ix]}</a></td><td>${translation}</td>`;
} else {
html += '<td class="has-background-danger-light">' + words[ix] + '</td><td class="has-background-danger-light">' + '</td>';
html += `<td class="has-background-danger-light">${words[ix]}</td><td class="has-background-danger-light"></td>`;
}
}

html += '</tr>';
}
html += '</tbody>';
html += "</table>";

$("#output").html(html);
Expand Down
2 changes: 1 addition & 1 deletion apps/tools/librelingo_tools/templates/missing_words.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h1 class="title">Missing Words</h1>
words_array.sort();

var count_our_words = 0;
var html = "<table>";
var html = `<table class="table">`;
html += "<tr><th>word</th><th>count</th></tr>";
for (var ix=0; ix < words_array.length; ix++) {
var word = words_array[ix];
Expand Down

0 comments on commit c94a6d8

Please sign in to comment.