Commit 2579ef69 authored by Vildravn's avatar Vildravn
Browse files

Fix region check, widgets with no data

parent 639eadb0
......@@ -62,7 +62,9 @@ const slBosses = {
}
// -----------------------------
const REGION = (args.widgetParameter.toUpperCase() == 'US' ? 'US' : 'EU');
let REGION = args.widgetParameter || 'EU';
REGION = (REGION.toUpperCase() == 'US' ? 'US' : 'EU');
log(REGION);
const cheerio = importModule('cheerio');
let $ = undefined;
......@@ -126,7 +128,9 @@ async function createWidget(size) {
await buildAffixDisplay(rightColumn, data);
rightColumn.addSpacer(20);
data = await parseTextGroup(`#${REGION}-group-epiceliteworldsl`, `.tiw-region[data-region="${REGION}"]`);
await buildTextDisplay(rightColumn, "world boss", data, slBosses[data[0]]);
log(data);
const bossLink = (data ? slBosses[data[0]] : null);
await buildTextDisplay(rightColumn, "world boss", data, bossLink);
$ = undefined;
delete ($);
......@@ -168,6 +172,13 @@ async function buildTextDisplay(parent, heading, data, url) {
header.textColor = textStyles.header.color;
header.font = textStyles.header.font;
if (!data) {
const line = contentStack.addText('No data');
line.textColor = textStyles.lineWhite.color;
line.font = textStyles.lineWhite.font;
return;
}
for (const item of data) {
const line = contentStack.addText(item);
line.textColor = textStyles.line.color;
......@@ -183,6 +194,13 @@ async function buildImageDisplay(parent, heading, data) {
header.textColor = textStyles.header.color;
header.font = textStyles.header.font;
if (!data) {
const line = contentStack.addText('No data');
line.textColor = textStyles.lineWhite.color;
line.font = textStyles.lineWhite.font;
return;
}
const horizontalStack = contentStack.addStack();
horizontalStack.layoutHorizontally();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment