Add initial project structure with backend and frontend setup
- Created backend structure with Go, including main application logic and API endpoints. - Added Docker support for both development and production environments. - Introduced frontend using Nuxt 3 with Tailwind CSS for styling. - Included configuration files for Docker and environment variables. - Established basic documentation for contributing, development, and deployment processes. - Set up .gitignore and .dockerignore files to manage ignored files in the repository.
This commit is contained in:
61
frontend-nuxt/lib/Character.js
Normal file
61
frontend-nuxt/lib/Character.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import { HnHMaxZoom } from '~/lib/LeafletCustomTypes'
|
||||
import * as L from 'leaflet'
|
||||
|
||||
export class Character {
|
||||
constructor(characterData) {
|
||||
this.name = characterData.name
|
||||
this.position = characterData.position
|
||||
this.type = characterData.type
|
||||
this.id = characterData.id
|
||||
this.map = characterData.map
|
||||
this.marker = null
|
||||
this.text = this.name
|
||||
this.value = this.id
|
||||
this.onClick = null
|
||||
}
|
||||
|
||||
getId() {
|
||||
return `${this.name}`
|
||||
}
|
||||
|
||||
remove(mapview) {
|
||||
if (this.marker) {
|
||||
const layer = mapview.markerLayer ?? mapview.map
|
||||
layer.removeLayer(this.marker)
|
||||
this.marker = null
|
||||
}
|
||||
}
|
||||
|
||||
add(mapview) {
|
||||
if (this.map === mapview.mapid) {
|
||||
const position = mapview.map.unproject([this.position.x, this.position.y], HnHMaxZoom)
|
||||
this.marker = L.marker(position, { title: this.name })
|
||||
this.marker.on('click', this.callCallback.bind(this))
|
||||
const targetLayer = mapview.markerLayer ?? mapview.map
|
||||
this.marker.addTo(targetLayer)
|
||||
}
|
||||
}
|
||||
|
||||
update(mapview, updated) {
|
||||
if (this.map !== updated.map) {
|
||||
this.remove(mapview)
|
||||
}
|
||||
this.map = updated.map
|
||||
this.position = updated.position
|
||||
if (!this.marker && this.map === mapview.mapid) {
|
||||
this.add(mapview)
|
||||
}
|
||||
if (this.marker) {
|
||||
const position = mapview.map.unproject([updated.position.x, updated.position.y], HnHMaxZoom)
|
||||
this.marker.setLatLng(position)
|
||||
}
|
||||
}
|
||||
|
||||
setClickCallback(callback) {
|
||||
this.onClick = callback
|
||||
}
|
||||
|
||||
callCallback(e) {
|
||||
if (this.onClick != null) this.onClick(e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user