Change newline comma style

This commit is contained in:
Hans5958 2023-03-19 13:10:21 +07:00
parent 0678c20e7e
commit ae80b28c2f
3 changed files with 59 additions and 61 deletions

View file

@ -487,8 +487,8 @@ function initDraw() {
function updateHovering(e, tapped) { function updateHovering(e, tapped) {
if (!dragging && (!fixed || tapped)) { if (!dragging && (!fixed || tapped)) {
const pos = [ const pos = [
(e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom (e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom,
, (e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom (e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom
] ]
const coords_p = document.getElementById("coords_p") const coords_p = document.getElementById("coords_p")

View file

@ -122,12 +122,12 @@ let linesDistance = 1
for (let i = 0; i <= Math.ceil((mostCounts / linesDistance) / 5) * 5; i++) { for (let i = 0; i <= Math.ceil((mostCounts / linesDistance) / 5) * 5; i++) {
ctx.beginPath() ctx.beginPath()
ctx.moveTo( ctx.moveTo(
50 50,
, ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5 ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
) )
ctx.lineTo( ctx.lineTo(
el.width - 25 el.width - 25,
, ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5 ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
) )
ctx.stroke() ctx.stroke()
} }
@ -138,19 +138,19 @@ linesDistance = 5
for (let i = 0; i <= Math.ceil(mostCounts / linesDistance); i++) { for (let i = 0; i <= Math.ceil(mostCounts / linesDistance); i++) {
ctx.beginPath() ctx.beginPath()
ctx.moveTo( ctx.moveTo(
50 50,
, ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5 ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
) )
ctx.lineTo( ctx.lineTo(
el.width - 25 el.width - 25,
, ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5 ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
) )
ctx.stroke() ctx.stroke()
ctx.fillText( ctx.fillText(
i * linesDistance i * linesDistance,
, 40 40,
, ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5 ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
) )
} }
@ -172,19 +172,19 @@ for (let i = 0; i <= counts.length; i++) {
a++ a++
ctx.beginPath() ctx.beginPath()
ctx.moveTo( ctx.moveTo(
~~(((i) / steps) * (el.width - 125) + 75) + 0.5 ~~(((i) / steps) * (el.width - 125) + 75) + 0.5,
, ~~(el.height - 50) + 0.5 ~~(el.height - 50) + 0.5
) )
ctx.lineTo( ctx.lineTo(
~~(((i) / steps) * (el.width - 125) + 75) + 0.5 ~~(((i) / steps) * (el.width - 125) + 75) + 0.5,
, y y
) )
ctx.stroke() ctx.stroke()
ctx.fillText( ctx.fillText(
(i) * (max / steps) (i) * (max / steps),
, ~~(((i) / steps) * (el.width - 125) + 75) - 0.5 ~~(((i) / steps) * (el.width - 125) + 75) - 0.5,
, y + 5 y + 5
) )
} }
} }
@ -200,10 +200,10 @@ for (let i = 0; i < counts.length; i++) {
} }
ctx.fillRect( ctx.fillRect(
~~((i / steps) * (el.width - 125) + 75) ~~((i / steps) * (el.width - 125) + 75),
, el.height - 50 el.height - 50,
, Math.ceil(1 / steps * (el.width - 125)) Math.ceil(1 / steps * (el.width - 125)),
, ~~(-(counts[i] / mostCounts) * (el.height - 100)) ~~(-(counts[i] / mostCounts) * (el.height - 100))
) )
/*ctx.beginPath() /*ctx.beginPath()

View file

@ -224,18 +224,18 @@ function updateLines() {
// Align line based on which side the card is on // Align line based on which side the card is on
if ((element.getBoundingClientRect().left + element.clientWidth / 2) < (document.documentElement.clientWidth / 2)) { if ((element.getBoundingClientRect().left + element.clientWidth / 2) < (document.documentElement.clientWidth / 2)) {
linesContext.moveTo( linesContext.moveTo(
element.getBoundingClientRect().left + document.documentElement.scrollLeft + element.clientWidth - 5 element.getBoundingClientRect().left + document.documentElement.scrollLeft + element.clientWidth - 5,
, element.getBoundingClientRect().top + document.documentElement.scrollTop + 20 element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
) )
} else { } else {
linesContext.moveTo( linesContext.moveTo(
element.getBoundingClientRect().left + document.documentElement.scrollLeft + 5 element.getBoundingClientRect().left + document.documentElement.scrollLeft + 5,
, element.getBoundingClientRect().top + document.documentElement.scrollTop + 20 element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
) )
} }
linesContext.lineTo( linesContext.lineTo(
~~(hovered[i].center[0] * zoom) + innerContainer.offsetLeft ~~(hovered[i].center[0] * zoom) + innerContainer.offsetLeft,
, ~~(hovered[i].center[1] * zoom) + innerContainer.offsetTop ~~(hovered[i].center[1] * zoom) + innerContainer.offsetTop
) )
linesContext.stroke() linesContext.stroke()
} }
@ -254,18 +254,18 @@ function updateLines() {
// Align line based on which side the card is on // Align line based on which side the card is on
if ((element.getBoundingClientRect().left + element.clientWidth / 2) < (document.documentElement.clientWidth / 2)) { if ((element.getBoundingClientRect().left + element.clientWidth / 2) < (document.documentElement.clientWidth / 2)) {
linesContext.moveTo( linesContext.moveTo(
element.getBoundingClientRect().left + document.documentElement.scrollLeft + element.clientWidth - 5 element.getBoundingClientRect().left + document.documentElement.scrollLeft + element.clientWidth - 5,
, element.getBoundingClientRect().top + document.documentElement.scrollTop + 20 element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
) )
} else { } else {
linesContext.moveTo( linesContext.moveTo(
element.getBoundingClientRect().left + document.documentElement.scrollLeft + 5 element.getBoundingClientRect().left + document.documentElement.scrollLeft + 5,
, element.getBoundingClientRect().top + document.documentElement.scrollTop + 20 element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
) )
} }
linesContext.lineTo( linesContext.lineTo(
~~(hovered[i].center[0] * zoom) + innerContainer.offsetLeft ~~(hovered[i].center[0] * zoom) + innerContainer.offsetLeft,
, ~~(hovered[i].center[1] * zoom) + innerContainer.offsetTop ~~(hovered[i].center[1] * zoom) + innerContainer.offsetTop
) )
linesContext.stroke() linesContext.stroke()
} }
@ -465,13 +465,13 @@ function buildObjectsList(filter = null, sort = null) {
applyView() applyView()
zoomOrigin = [ zoomOrigin = [
innerContainer.clientWidth / 2 - this.entry.center[0] * zoom// + container.offsetLeft innerContainer.clientWidth / 2 - this.entry.center[0] * zoom, // + container.offsetLeft
, innerContainer.clientHeight / 2 - this.entry.center[1] * zoom// + container.offsetTop innerContainer.clientHeight / 2 - this.entry.center[1] * zoom // + container.offsetTop
] ]
scaleZoomOrigin = [ scaleZoomOrigin = [
canvasCenter.x - this.entry.center[0] canvasCenter.x - this.entry.center[0],
, canvasCenter.y - this.entry.center[1] canvasCenter.y - this.entry.center[1]
] ]
//console.log(zoomOrigin) //console.log(zoomOrigin)
@ -508,13 +508,13 @@ function buildObjectsList(filter = null, sort = null) {
updateHovering(e) updateHovering(e)
zoomOrigin = [ zoomOrigin = [
innerContainer.clientWidth / 2 - this.entry.center[0] * zoom// + container.offsetLeft innerContainer.clientWidth / 2 - this.entry.center[0] * zoom// + container.offsetLeft,
, innerContainer.clientHeight / 2 - this.entry.center[1] * zoom// + container.offsetTop innerContainer.clientHeight / 2 - this.entry.center[1] * zoom// + container.offsetTop
] ]
scaleZoomOrigin = [ scaleZoomOrigin = [
2000 / 2 - this.entry.center[0] 2000 / 2 - this.entry.center[0],
, 2000 / 2 - this.entry.center[1] 2000 / 2 - this.entry.center[1]
] ]
previousZoomOrigin = [zoomOrigin[0], zoomOrigin[1]] previousZoomOrigin = [zoomOrigin[0], zoomOrigin[1]]
@ -684,8 +684,8 @@ function updateHovering(e, tapped) {
if (!dragging && (!fixed || tapped)) { if (!dragging && (!fixed || tapped)) {
const pos = [ const pos = [
(e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom (e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom,
, (e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom (e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom
] ]
const coords_p = document.getElementById("coords_p") const coords_p = document.getElementById("coords_p")
@ -812,13 +812,13 @@ function highlightEntryFromUrl() {
applyView() applyView()
zoomOrigin = [ zoomOrigin = [
innerContainer.clientWidth / 2 - entry.center[0] * zoom// + container.offsetLeft innerContainer.clientWidth / 2 - entry.center[0] * zoom, // + container.offsetLeft
, innerContainer.clientHeight / 2 - entry.center[1] * zoom// + container.offsetTop innerContainer.clientHeight / 2 - entry.center[1] * zoom // + container.offsetTop
] ]
scaleZoomOrigin = [ scaleZoomOrigin = [
canvasCenter.x - entry.center[0] // + container.offsetLeft canvasCenter.x - entry.center[0], // + container.offsetLeft
, canvasCenter.y - entry.center[1] // + container.offsetTop canvasCenter.y - entry.center[1] // + container.offsetTop
] ]
closeObjectsListButton.classList.remove("d-none") closeObjectsListButton.classList.remove("d-none")
@ -865,8 +865,8 @@ function initExplore() {
function updateHovering(e, tapped) { function updateHovering(e, tapped) {
if (!dragging && (!fixed || tapped)) { if (!dragging && (!fixed || tapped)) {
const pos = [ const pos = [
(e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom (e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom,
, (e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom (e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom
] ]
const coords_p = document.getElementById("coords_p") const coords_p = document.getElementById("coords_p")
// Displays coordinates as zero instead of NaN // Displays coordinates as zero instead of NaN
@ -905,16 +905,16 @@ function initGlobal() {
function initViewGlobal() { function initViewGlobal() {
container.addEventListener("mousedown", function (e) { container.addEventListener("mousedown", function (e) {
lastPos = [ lastPos = [
e.clientX e.clientX,
, e.clientY e.clientY
] ]
}) })
container.addEventListener("touchstart", function (e) { container.addEventListener("touchstart", function (e) {
if (e.touches.length === 1) { if (e.touches.length === 1) {
lastPos = [ lastPos = [
e.touches[0].clientX e.touches[0].clientX,
, e.touches[0].clientY e.touches[0].clientY
] ]
} }
}, { passive: true }) }, { passive: true })
@ -937,11 +937,9 @@ function initViewGlobal() {
//console.log("Foo!!") //console.log("Foo!!")
dragging = false dragging = false
fixed = false fixed = false
setTimeout( setTimeout(function () {
function () { updateHovering(e, true)
updateHovering(e, true) }, 10)
}
, 10)
} }
} }
}) })