Add the Dark version to the data.js file and render it in the webpage.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -110,6 +110,23 @@ function getNiceName(name) {
|
|||||||
return name.substring(indices[2] + 1, indices[3]);
|
return name.substring(indices[2] + 1, indices[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createMissingImageElement() {
|
||||||
|
const text = document.createElement('p');
|
||||||
|
text.className = "missing";
|
||||||
|
text.textContent = 'No image';
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createImageElement(fullFile) {
|
||||||
|
const img = document.createElement('img');
|
||||||
|
img.className = "screenshot";
|
||||||
|
img.src = `${baseUrl}/${fullFile}`;
|
||||||
|
img.title = fullFile;
|
||||||
|
img.alt = "Missing image";
|
||||||
|
img.width = imageWidth;
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
function addTable() {
|
function addTable() {
|
||||||
// Remove any previous table
|
// Remove any previous table
|
||||||
document.getElementById('screenshots_container').innerHTML = '';
|
document.getElementById('screenshots_container').innerHTML = '';
|
||||||
@@ -143,33 +160,26 @@ function addTable() {
|
|||||||
}
|
}
|
||||||
const td = document.createElement('td');
|
const td = document.createElement('td');
|
||||||
if (languageIndex == 0) {
|
if (languageIndex == 0) {
|
||||||
const fullFile = `${englishBasePath}/${englishFile}.png`;
|
// English file
|
||||||
const img = document.createElement('img');
|
td.appendChild(createImageElement(`${englishBasePath}/${englishFile}.png`));
|
||||||
img.className = "screenshot";
|
} else if (languageIndex == 1) {
|
||||||
img.src = `${baseUrl}/${fullFile}`;
|
// Dark English file
|
||||||
img.title = fullFile;
|
if (screenshots[screenshotIndex][1].length > 0) {
|
||||||
img.alt = "Missing image";
|
hasTranslatedFiles = true;
|
||||||
img.width = imageWidth;
|
td.appendChild(createImageElement(`${englishBasePath}/${screenshots[screenshotIndex][1]}.png`));
|
||||||
td.appendChild(img);
|
} else {
|
||||||
|
td.appendChild(createMissingImageElement());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let hasFile = screenshots[screenshotIndex][languageIndex];
|
let hasFile = screenshots[screenshotIndex][languageIndex];
|
||||||
if (hasFile === 0) {
|
if (hasFile === 0) {
|
||||||
const text = document.createElement('p');
|
td.appendChild(createMissingImageElement());
|
||||||
text.className = "missing";
|
|
||||||
text.textContent = 'No image';
|
|
||||||
td.appendChild(text);
|
|
||||||
} else {
|
} else {
|
||||||
hasTranslatedFiles = true;
|
hasTranslatedFiles = true;
|
||||||
// Foreign file is the same as the english file, replacing the language
|
// Foreign file is the same as the english file, replacing the language
|
||||||
const foreignFile = englishFile.replace("en]", `${dataLanguages[languageIndex]}]`).replace("_S_", "_T_")
|
const foreignFile = englishFile.replace("en]", `${dataLanguages[languageIndex]}]`).replace("_S_", "_T_")
|
||||||
const fullForeignFile = `${dataLanguages[languageIndex]}/${foreignFile}.png`;
|
const fullForeignFile = `${dataLanguages[languageIndex]}/${foreignFile}.png`;
|
||||||
const img = document.createElement('img');
|
td.appendChild(createImageElement(fullForeignFile));
|
||||||
img.className = "screenshot";
|
|
||||||
img.src = `${baseUrl}/${fullForeignFile}`;
|
|
||||||
img.title = fullForeignFile;
|
|
||||||
img.alt = "Missing image";
|
|
||||||
img.width = imageWidth;
|
|
||||||
td.appendChild(img);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
|
|||||||
@@ -100,21 +100,34 @@ def detectRecordedLanguages():
|
|||||||
return sorted([f for f in os.listdir("screenshots") if len(f) == 2])
|
return sorted([f for f in os.listdir("screenshots") if len(f) == 2])
|
||||||
|
|
||||||
|
|
||||||
|
def computeDarkFileName(lightFileName):
|
||||||
|
if "-Day_0" in lightFileName:
|
||||||
|
return lightFileName.replace("-Day_0", "-Night_1")
|
||||||
|
match = re.match("(.*)-Day-(\d+)_(\d+)(.*)", lightFileName, flags=re.ASCII)
|
||||||
|
if match:
|
||||||
|
return match.group(1) + "-Night-" + match.group(2) + "_" + str((int(match.group(3)) + 1)) + match.group(4)
|
||||||
|
return ""
|
||||||
|
|
||||||
def generateJavascriptFile():
|
def generateJavascriptFile():
|
||||||
__doc__ = "Generate a javascript file to load the screenshots"
|
__doc__ = "Generate a javascript file to load the screenshots"
|
||||||
print("Generating javascript file...")
|
print("Generating javascript file...")
|
||||||
languages = detectRecordedLanguages()
|
languages = detectRecordedLanguages()
|
||||||
# First item is the list of languages, adding "en" at the beginning
|
# First item is the list of languages, adding "en" and "en-dark" at the beginning
|
||||||
data = [["en"] + languages]
|
data = [["en", "en-dark"] + languages]
|
||||||
files = sorted(
|
files = sorted(
|
||||||
os.listdir("tests/uitests/src/test/snapshots/images/"),
|
os.listdir("tests/uitests/src/test/snapshots/images/"),
|
||||||
key=lambda file: file[file.find("_", 6):],
|
key=lambda file: file[file.find("_", 6):],
|
||||||
)
|
)
|
||||||
for file in files:
|
for file in files:
|
||||||
# Continue if file contains "-Night", keep only light screenshots (maybe the night screenshots could be on the second column?)
|
# Continue if file contains "-Night", keep only light screenshots
|
||||||
if "-Night" in file:
|
if "-Night" in file:
|
||||||
continue
|
continue
|
||||||
dataForFile = [file[:-4]]
|
dataForFile = [file[:-4]]
|
||||||
|
darkFile = computeDarkFileName(file)
|
||||||
|
if os.path.exists("./tests/uitests/src/test/snapshots/images/" + darkFile):
|
||||||
|
dataForFile.append(darkFile[:-4])
|
||||||
|
else:
|
||||||
|
dataForFile.append("")
|
||||||
for l in languages:
|
for l in languages:
|
||||||
simpleFile = file[:3] + "T" + file[4:-7] + l + file[-5:-4]
|
simpleFile = file[:3] + "T" + file[4:-7] + l + file[-5:-4]
|
||||||
translatedFile = "./screenshots/" + l + "/" + simpleFile + ".png"
|
translatedFile = "./screenshots/" + l + "/" + simpleFile + ".png"
|
||||||
|
|||||||
Reference in New Issue
Block a user