Skip to content

Commit

Permalink
Update codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans5958 committed Jun 1, 2023
1 parent 2c06d72 commit 659af07
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 37 deletions.
35 changes: 22 additions & 13 deletions web/_css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ body[data-mode]:not([data-mode="draw"]) #drawNavButtons, [data-mode="draw"] #def
}

#innerContainer {
height: 2000px;
width: 2000px;
position: absolute;
z-index: -2000;
height: 2000px;
width: 2000px;
position: absolute;
z-index: -2000;
}

body[data-init-done] .listTransitioning #innerContainer {
Expand All @@ -120,22 +120,21 @@ body[data-init-done] .listTransitioning #innerContainer {
}
}

#image {
#innerContainer > * {
position: absolute;
height: 100%;
width: 100%;
z-index: -1500;
image-rendering: -webkit-optimize-contrast;
image-rendering: pixelated;
user-select: none;
}

#image {
z-index: -1500;
}

#highlightCanvas {
z-index: -1200;
position: absolute;
height: 100%;
width: 100%;
image-rendering: -webkit-optimize-contrast;
image-rendering: pixelated;
}

#atlasSize:empty {
Expand Down Expand Up @@ -260,7 +259,7 @@ body[data-init-done] .listTransitioning #innerContainer {
}

#variantControls {
flex: 1 1 auto;
flex: 1 0 auto;
}

#timeControls {
Expand Down Expand Up @@ -374,7 +373,7 @@ body[data-init-done] #timeControlsTooltip[data-force-visible] {
}

[data-mode="explore"] #entriesListControls {
display: none;
display: none;
}

body:not([data-dev]) .show-only-on-dev {
Expand Down Expand Up @@ -437,4 +436,14 @@ body:not([data-dev]) .show-only-on-dev {
display: none !important;
}

/* about.html */

#credits a {
text-decoration: none;
}

#credits a:hover {
text-decoration: underline;
}

/* purgecss end ignore */
2 changes: 1 addition & 1 deletion web/_js/favicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function updateFavicon(colorScheme) {
const favicon = document.head.querySelector('.js-site-favicon[type="image/svg+xml"]')
const faviconFallback = document.head.querySelector('.js-site-favicon[type="image/png"]')
if (favicon && faviconFallback) {
if (colorScheme || colorScheme == 'dark') {
if (colorScheme || colorScheme === 'dark') {
favicon.href = '_img/favicon-dark.svg'
faviconFallback.href = '_img/favicon-dark.png'
} else {
Expand Down
2 changes: 1 addition & 1 deletion web/_js/main/infoblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function createInfoBlock(entry, isPreview) {
if (!link) return
const wikiLinkElement = baseLinkElement.cloneNode()
wikiLinkElement.href = "https://place-wiki.stefanocoding.me/wiki/" + link.replace(/ /g, '_')
wikiLinkElement.innerHTML = `<i class="bi bi-book" aria-hidden="true"></i> Wiki Article`
wikiLinkElement.innerHTML = `<i class="bi bi-book" aria-hidden="true"></i>r/place Wiki Article`
wikiGroupElement.appendChild(wikiLinkElement)
})
}
Expand Down
25 changes: 11 additions & 14 deletions web/_js/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,24 +286,21 @@ async function init() {
)

function mousemove(x, y) {
if (dragging) {
container.style.cursor = "move"

const deltaX = x - lastPosition[0]
const deltaY = y - lastPosition[1]
lastPosition = [x, y]
if (!dragging) return
container.style.cursor = "move"

zoomOrigin[0] += deltaX
zoomOrigin[1] += deltaY
const deltaX = x - lastPosition[0]
const deltaY = y - lastPosition[1]
lastPosition = [x, y]

scaleZoomOrigin[0] += deltaX / zoom
scaleZoomOrigin[1] += deltaY / zoom
zoomOrigin[0] += deltaX
zoomOrigin[1] += deltaY

previousZoomOrigin = [zoomOrigin[0], zoomOrigin[1]]
previousScaleZoomOrigin = [scaleZoomOrigin[0], scaleZoomOrigin[1]]
scaleZoomOrigin[0] += deltaX / zoom
scaleZoomOrigin[1] += deltaY / zoom

applyView()
}
updateLines()
applyView()
}

function touchmove(e) {
Expand Down
14 changes: 11 additions & 3 deletions web/_js/main/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let canvasUrl = ""
const variantsEl = document.getElementById("variants")

for (const variation in variationsConfig) {
codeReference[variationsConfig[variation].code] = variation
const optionEl = document.createElement('option')
variantsEl.appendChild(optionEl)
optionEl.textContent = variationsConfig[variation].name
Expand All @@ -23,6 +24,8 @@ for (const variation in variationsConfig) {
codeReference[variationsConfig[variation].code] = variation
codeReference[variation] = variation
optionEl.value = variation
optionEl.textContent = variationsConfig[variation].name
variantsEl.appendChild(optionEl)
}

const timelineSlider = document.getElementById("timeControlsSlider")
Expand Down Expand Up @@ -113,18 +116,20 @@ async function updateBackground(newPeriod = currentPeriod, newVariation = curren
}
const canvas = document.createElement('canvas')
const context = canvas.getContext('2d')
for await (const url of layerUrls) {

layers.length = layerUrls.length
await Promise.all(layerUrls.map(async (url, i) => {
const imageLayer = new Image()
await new Promise(resolve => {
imageLayer.onload = () => {
context.canvas.width = Math.max(imageLayer.width, context.canvas.width)
context.canvas.height = Math.max(imageLayer.height, context.canvas.height)
layers.push(imageLayer)
layers[i] = imageLayer
resolve()
}
imageLayer.src = url
})
}
}))

for (const imageLayer of layers) {
context.drawImage(imageLayer, 0, 0)
Expand All @@ -137,6 +142,9 @@ async function updateBackground(newPeriod = currentPeriod, newVariation = curren
}

async function updateTime(newPeriod = currentPeriod, newVariation = currentVariation, forceLoad = false) {
if (newPeriod === currentPeriod && !forceLoad) {
return;
}
document.body.dataset.canvasLoading = ""

const oldPeriod = currentPeriod
Expand Down
9 changes: 4 additions & 5 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ <h4 class="mb-3">Hang on…</h4>
</div>
<canvas id="linesCanvas"></canvas>
<div id="innerContainer">
<canvas id="highlightCanvas" width="2000" height="2000"></canvas>

<img id="image" width="2000" height="2000" alt="" />
<canvas id="highlightCanvas"></canvas>
<img id="image" alt="" />
</div>
</div>
<div class="offcanvas offcanvas-start bg-body" data-bs-scroll="true" data-bs-backdrop="false" tabindex="-1" id="offcanvasList" aria-labelledby="offcanvasListLabel">
Expand All @@ -120,7 +119,7 @@ <h5 class="offcanvas-title" id="offcanvasListLabel">Information</h5>
</div>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</header>
<div class="pt-3 mx-3">
<div class="py-3 mx-3">
<div class="btn-group w-100 mb-3" role="group" aria-label="Social links and donate button">
<a class="btn btn-outline-primary" href="https://discord.gg/pJkm23b2nA" target="_blank" rel="noopener noreferrer">
<i class="bi bi-discord" aria-hidden="true"></i>
Expand All @@ -138,7 +137,7 @@ <h5 class="offcanvas-title" id="offcanvasListLabel">Information</h5>
</div>
<div id="entriesList" class="card-deck px-2 mx-2 pt-2 overflow-auto"></div>
</div>
<div id="bottomBar" class="d-flex flex-wrap gap-2 p-2">
<div id="bottomBar" class="d-flex flex-wrap gap-2 p-3">
<div id="zoomControls" class="btn-group shadow" role="group" aria-label="Zoom controls">
<button type="button" class="btn btn-secondary" id="zoomInButton" title="Zoom in">
<i class="bi bi-plus-lg" aria-hidden="true"></i>
Expand Down

0 comments on commit 659af07

Please sign in to comment.