Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
Vildravn
today-in-wow-widget
Commits
f6d3e607
Commit
f6d3e607
authored
Dec 16, 2020
by
Vildravn
Browse files
Merge branch 'beta' into 'master'
Beta See merge request
!5
parents
05d8b083
2706cff1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Today in WoW.js
View file @
f6d3e607
...
...
@@ -19,7 +19,7 @@
*/
const
colors
=
{
bg
:
new
Color
(
'
#1C1C1C
'
),
header
:
new
Color
(
'
#FFFFFF
'
),
textWhite
:
new
Color
(
'
#FFFFFF
'
),
textYellow
:
new
Color
(
'
#FFD100
'
),
textGrey
:
new
Color
(
'
#BBBBBB
'
),
faction
:
{
...
...
@@ -35,7 +35,7 @@ const colors = {
const
textStyles
=
{
header
:
{
font
:
new
Font
(
'
HelveticaNeue-Bold
'
,
12
),
color
:
colors
.
header
color
:
colors
.
textWhite
},
line
:
{
font
:
new
Font
(
'
HelveticaNeue
'
,
12
),
...
...
@@ -44,6 +44,10 @@ const textStyles = {
lineBold
:
{
font
:
new
Font
(
'
HelveticaNeue-Bold
'
,
9
),
color
:
colors
.
textGrey
},
lineWhite
:
{
font
:
new
Font
(
'
HelveticaNeue
'
,
12
),
color
:
colors
.
textWhite
}
}
...
...
@@ -58,7 +62,8 @@ const slBosses = {
}
// -----------------------------
const
REGION
=
(
args
.
widgetParameter
.
toUpperCase
()
==
'
US
'
?
'
US
'
:
'
EU
'
);
let
REGION
=
args
.
widgetParameter
||
'
EU
'
;
REGION
=
(
REGION
.
toUpperCase
()
==
'
US
'
?
'
US
'
:
'
EU
'
);
const
cheerio
=
importModule
(
'
cheerio
'
);
let
$
=
undefined
;
...
...
@@ -97,7 +102,7 @@ async function createWidget(size) {
let
whData
=
await
fetchData
(
"
https://www.wowhead.com
"
,
"
loadString
"
);
$
=
cheerio
.
load
(
whData
);
let
data
=
undefined
;
let
data
=
null
;
whData
=
undefined
;
delete
(
whData
);
...
...
@@ -122,19 +127,24 @@ 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
]]);
const
bossLink
=
(
data
?
slBosses
[
data
[
0
]]
:
null
);
await
buildTextDisplay
(
rightColumn
,
"
world boss
"
,
data
,
bossLink
);
$
=
undefined
;
delete
(
$
);
}
else
{
const
text
=
widget
.
addText
(
'
The widget is not configured correctly.
'
);
text
.
textColor
=
textStyles
.
header
.
color
;
text
.
font
=
textStyles
.
header
.
font
;
text
.
textColor
=
textStyles
.
lineWhite
.
color
;
text
.
font
=
textStyles
.
lineWhite
.
font
;
}
}
else
{
const
text
=
widget
.
addText
(
`
${
size
}
widget is currently not supported.`
);
text
.
textColor
=
textStyles
.
header
.
color
;
text
.
font
=
textStyles
.
header
.
font
;
const
contentStack
=
widget
.
addStack
();
contentStack
.
layoutHorizontally
();
contentStack
.
addSpacer
();
const
text
=
contentStack
.
addText
(
`
${
size
}
widget is currently not supported.`
);
text
.
textColor
=
textStyles
.
lineWhite
.
color
;
text
.
font
=
textStyles
.
lineWhite
.
font
;
contentStack
.
addSpacer
();
}
return
widget
;
...
...
@@ -142,10 +152,12 @@ async function createWidget(size) {
async
function
buildAffixDisplay
(
parent
,
affixes
)
{
const
levels
=
[
"
2+
"
,
"
4+
"
,
"
7+
"
,
"
10+
"
];
for
(
let
i
=
0
;
i
<
affixes
.
length
;
i
++
)
{
let
affix
=
affixes
[
i
];
if
(
affixes
)
{
for
(
let
i
=
0
;
i
<
affixes
.
length
;
i
++
)
{
let
affix
=
affixes
[
i
];
affix
.
text
=
levels
[
i
];
affix
.
text
=
levels
[
i
];
}
}
await
buildImageDisplay
(
parent
,
"
mythic+ affixes
"
,
affixes
);
...
...
@@ -160,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
;
...
...
@@ -175,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
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment