123 lines
5.7 KiB
HTML
Raw Normal View History

2025-04-05 22:25:06 +00:00
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>QBCore - Spawnlocation</title>
<link rel="stylesheet" type="text/css" href="reset.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.1.3/axios.min.js"></script>
<script src="vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet" />
</head>
<body>
<v-app data-app>
<div id="app">
<div class="container">
<div class="noselect">
<div class="spawn-locations" :class="{'slide-top-fade-leave-active': show == false, 'slide-top-fade-leave-to': show == false}">
<div class="spawn_locations-header">
<p>
<span id="null">{{translate('where_would_you_like_to_start')}}</span>
</p>
</div>
<v-btn elevation="0" color="#00000000" v-if="newChar !== true" class="location" x-large v-ripple :class="{'selected': 'current' == selectedValue.type && 'current' == selectedValue.name}" @click="click_location('current', 'current')"> {{translate('last_location')}} </v-btn>
<div v-for="(locations, locationGroupIdx) in positions">
<v-btn v-for="(location, locationIdx) in locations" :key="locationGroupIdx + '-' + locationIdx" elevation="0" color="#00000000" :class="{'selected': locationGroupIdx == selectedValue.type && ((locationGroupIdx !== 'house' && locationIdx == selectedValue.name) || (locationGroupIdx == 'house' && location.house == selectedValue.name))}" class="location" x-large v-ripple @click="click_location(locationGroupIdx, locationGroupIdx == 'house' ? location.house : locationIdx)"> {{ location.label }} </v-btn>
</div>
<v-btn @click="submit_spawn" v-ripple x-large class="submit-spawn" v-if="selectedValue.type !== '' && selectedValue.name !== ''"> {{translate('confirm')}} </v-btn>
</div>
</div>
</div>
</div>
</v-app>
<script>
const viewmodel = new Vue({
el: "#app",
vuetify: new Vuetify(),
data: {
positions: {
normal: [],
appartment: [],
house: [],
},
selectedValue: {
type: "",
name: "",
},
newChar: false,
show: false,
translations: {},
},
methods: {
click_location: function (type, name) {
if (type == "normal") {
axios.post("https://qb-spawn/setCam", {
posname: name,
type: type,
});
}
this.selectedValue = { type: type, name: name };
},
submit_spawn: function () {
this.show = false;
const data = this.selectedValue;
if (data.type !== "appartment") {
axios.post("https://qb-spawn/spawnplayer", {
spawnloc: data.name,
typeLoc: data.type,
});
} else {
axios.post("https://qb-spawn/chooseAppa", {
appType: data.name,
});
}
},
translate(phrase) {
return this.translations[phrase] || `Could not find phrase: ${phrase}`;
},
},
mounted() {
window.addEventListener("message", function (event) {
let data = event.data;
switch (data.action) {
case "showUi":
viewmodel.show = data.status;
viewmodel.translations = event.data.translations;
break;
case "setupLocations":
viewmodel.positions = { normal: [], appartment: [], house: [] };
viewmodel.selectedValue = { type: "", index: -1 };
viewmodel.positions.normal = data.locations;
viewmodel.positions.house = data.houses;
viewmodel.newChar = data.isNew;
break;
case "setupAppartements":
viewmodel.positions = { normal: [], appartment: [], house: [] };
viewmodel.selectedValue = { type: "", index: -1 };
viewmodel.positions.appartment = data.locations;
viewmodel.newChar = data.isNew;
break;
}
});
},
});
</script>
</body>
</html>