do
Szkolenie grenadiera mające na celu zapoznanie Was z obsługą wszelakiej maści granatników, pocisków i pojazdów z tym związanych oraz zasady BHP.
Ukończenie szkolenia skutkuje uzyskaniem srebrnej baretki MC: Grenadier.
({slot.opis}) -
({slot.wpisany})
Wypisz
Zapisz się
`;
let dane;
let errormessage;
try {
dane = JSON.parse('');
errormessage = '';
} catch (err) {
console.log(err);
dane = {
log: [],
uzytkownik: {wpisany: null}
};
}
const zapisyApp = new Vue({
el: '#zapisy-app',
delimiters: ['({', '})'],
template: templateApp,
data: {
message: '',
dane: dane,
wpisany: {},
errormessage: errormessage,
showlog: false,
pokazPrzyciski: false,
max_fetches: 12,
sleeping: false,
firstLoading: true,
eventEnded: false,
},
computed: {
max_sloty: function () {
let ilosc = 0;
for (let grupa in this.dane.grupy) {
for (let slot in this.dane.grupy[grupa].sloty) {
ilosc++;
}
}
return ilosc
},
otwarte_sloty: function () {
let ilosc = 0;
for (let grupa in this.dane.grupy) {
for (let slot in this.dane.grupy[grupa].sloty) {
if (this.dane.grupy[grupa].sloty[slot].wpisany === '') {
ilosc++;
}
}
}
return ilosc
},
otwarte_opcjonalne: function () {
let ilosc = 0;
for (let grupa in this.dane.grupy) {
for (let slot in this.dane.grupy[grupa].sloty) {
if (this.dane.grupy[grupa].sloty[slot].wpisany === '' && this.dane.grupy[grupa].sloty[slot].opcja) {
ilosc++;
}
}
}
return ilosc
},
zajete_sloty: function () {
let ilosc = 0;
for (let grupa in this.dane.grupy) {
for (let slot in this.dane.grupy[grupa].sloty) {
if (this.dane.grupy[grupa].sloty[slot].wpisany !== '') {
ilosc++;
}
}
}
return ilosc
}
},
created: function () {
if (getCookieACC('ips4_delit').length > 0) {
setInterval(() => {
if (this.max_fetches > 0) {
this.xhr();
this.max_fetches = this.max_fetches - 1;
} else {
this.sleeping = true;
this.pokazPrzyciski = false;
}
}, 10000);
this.xhr();
} else {
this.xhr();
this.pokazPrzyciski = false;
}
},
watch: {
wpisany: function () {
this.xhr();
},
},
methods: {
xhr: function (u_id, typ) {
u_id = u_id || '';
typ = typ || '';
let url_base = 'https://stats.armacoopcorps.pl/zapisy/3244/';
let url = url_base + '?json=1';
let http_type = 'GET';
if (typ === 'wypisz') {
url = url_base + 'wypisz/' + u_id;
http_type = 'DELETE';
} else if (typ === 'zapisz') {
url = url_base + 'zapisz/' + u_id;
http_type = 'POST';
this.pokazPrzyciski = false;
} else if (typ === 'dopisz') {
url = url_base + 'dopisz/' + u_id;
http_type = 'POST';
this.pokazPrzyciski = false;
}
$.ajax({
url: url,
method: http_type,
ifModified: true,
headers: {'X-IPBS': getCookieACC('ips4_delit')},
xhrFields: {
withCredentials: true
},
error: (ret) => {
if ([406, 409].includes(ret.status)) {
this.errormessage = ret.responseJSON.errormessage;
this.data = {}
} else {
this.errormessage = "Połączenie z bazą slotów nie bangla. Jeśli widzisz ten komunikat notorycznie zgłoś do Domana.";
this.data = {}
}
},
})
.done((data, status) => {
if (status === 'success') {
if (typ === '') {
this.dane = data;
} else {
this.wpisany = data;
}
this.errormessage = '';
}
this.pokazPrzyciski = true;
this.firstLoading = false;
});
},
togglelog: function () {
this.showlog = !this.showlog;
},
notsleeping: function () {
this.sleeping = false;
this.max_fetches = 12;
this.xhr();
this.pokazPrzyciski = true;
},
getSlotClass: function (slot) {
return {
"opcja": slot.opcja,
"wazny": slot.wazny,
"opis": !slot.opcja && !slot.wazny
}
},
getSlotTitle: function (slot) {
if (slot.wazny) {
return "Slot wymagany do ukończenia misji"
}
if (slot.opcja) {
return "Slot do obsadzenia na końcu"
}
return null
}
}
});
function getCookieACC(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) === ' ') {
c = c.substring(1);
}
if (c.indexOf(name) === 0) {
return c.substring(name.length, c.length);
}
}
return "";
}