Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Portal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fachschaft
Portal
Commits
47ae0cec
Verified
Commit
47ae0cec
authored
8 months ago
by
Jakob Moser
Browse files
Options
Downloads
Patches
Plain Diff
Try to always wait until the image is rendered
parent
5ab9f823
No related branches found
No related tags found
No related merge requests found
Pipeline
#6534
passed
8 months ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
portal/static/js/gitlab.mjs
+23
-0
23 additions, 0 deletions
portal/static/js/gitlab.mjs
with
23 additions
and
0 deletions
portal/static/js/gitlab.mjs
+
23
−
0
View file @
47ae0cec
...
...
@@ -58,6 +58,27 @@ function toIsoString(year, month, day) {
return
`
${
year
.
toString
().
padStart
(
4
,
"
0
"
)}
-
${
month
.
toString
().
padStart
(
2
,
"
0
"
)}
-
${
day
.
toString
().
padStart
(
2
,
"
0
"
)}
`
}
/**
* Wait until the image is rendered, i.e. until its width or height are different from 0
*/
async
function
waitUntilRendered
(
img
)
{
function
isRendered
(
img
)
{
return
img
.
width
!=
0
||
img
.
height
!=
0
}
if
(
isRendered
(
img
))
return
// that was easy
await
new
Promise
((
resolve
,
_
)
=>
{
const
observer
=
new
MutationObserver
((
_
,
observer
)
=>
{
if
(
isRendered
(
img
))
{
observer
.
disconnect
()
resolve
()
}
})
observer
.
observe
(
img
,
{
attributes
:
true
})
})
}
/**
* Return an object with metadata about the latest protocol, or null, if the metadata cannot be accessed
* (e.g., because the user is not logged in to GitLab, is logged in but has no access to the repo, or an error occurred in the pipeline).
...
...
@@ -83,6 +104,8 @@ export async function getLatestProtocolMetadata() {
return
null
}
await
waitUntilRendered
(
img
)
const
year
=
img
.
width
const
month
=
Math
.
floor
(
img
.
height
/
100
)
const
dayAndMaybeOffset
=
img
.
height
-
100
*
month
...
...
This diff is collapsed.
Click to expand it.
Jakob Moser
@moser
mentioned in issue
#32
·
8 months ago
mentioned in issue
#32
mentioned in issue #32
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment