`;
if (
value.dispatchCode == "114" ||
value.dispatchCode == "112"
) {
DispatchItem = `
`;
$(".active-calls-list").prepend(
$(DispatchItem).hide().fadeIn("slow")
);
}
});
} else if (eventData.type == "incidents") {
let table = eventData.data;
canSearchForProfiles = true;
$(".incidents-items").empty();
$.each(table, function (index, value) {
$(".incidents-items").append(
`
`
);
});
$(".contextmenu").on("click", ".incidents-delete", function () {
$(".incidents-items")
.find(`[data-id="${$(this).data("info")}"]`)
.remove();
$.post(
`https://${GetParentResourceName()}/deleteIncidents`,
JSON.stringify({
id: $(this).data("info"),
})
);
});
$(".incidents-items").on("contextmenu", ".incidents-item", function (e) {
var args = "";
args = [
{
className: "incidents-delete",
icon: "fas fa-times",
text: "Slet hændelse",
info: $(this).data("id"),
status: "",
},
];
openContextMenu(e, args);
});
} else if (eventData.type == "getPenalCode") {
const titles = eventData.titles;
const penalcode = eventData.penalcode;
$(".offenses-main-container").empty();
$.each(titles, function (index, value) {
$(".offenses-main-container").append(
`
`
);
});
$.each(penalcode, function (index, value) {
$.each(value, function (i, v) {
$(`#penal-${index}`).append(`
${v.id}
${v.months} Months - $${v.fine}
`);
});
});
} else if (eventData.type == "incidentData") {
let table = eventData.data;
$(".incidents-ghost-holder").html("");
$(".associated-incidents-tags-holder").html("");
$(".manage-incidents-editing-title").html(
"You are currently editing incident " + table["id"]
);
$(".manage-incidents-editing-title").data(
"id",
Number(table["id"])
);
$(".manage-incidents-tags-add-btn").css("pointer-events", "auto");
$(".manage-incidents-reports-content").css(
"pointer-events",
"auto"
);
$(".manage-incidents-officers-add-btn").css(
"pointer-events",
"auto"
);
$(".manage-incidents-civilians-add-btn").css(
"pointer-events",
"auto"
);
$(".manage-incidents-evidence-add-btn").css(
"pointer-events",
"auto"
);
$(".associated-incidents-tags-add-btn").css(
"pointer-events",
"auto"
);
$("#manage-incidents-title-input").val(table["title"]);
$(".manage-incidents-reports-content").trumbowyg({
changeActiveDropdownIcon: true,
imageWidthModalEdit: true,
btns: [
['foreColor', 'backColor','fontfamily','fontsize','indent', 'outdent'],
['strong', 'em',], ['insertImage'],
['viewHTML'],
['undo', 'redo'],
['formatting'],
['superscript', 'subscript'],
['link'],
['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
['horizontalRule']
],
});
$(".manage-incidents-reports-content").trumbowyg('html', table["details"]);
$(".manage-incidents-tags-holder").empty();
$.each(table["tags"], function (index, value) {
$(".manage-incidents-tags-holder").append(
`
${value}
`
);
});
$(".manage-incidents-officers-holder").empty();
$.each(table["officersinvolved"], function (index, value) {
$(".manage-incidents-officers-holder").append(
`
${value}
`
);
});
$(".manage-incidents-civilians-holder").empty();
$.each(table["civsinvolved"], function (index, value) {
$(".manage-incidents-civilians-holder").append(
`
${value}
`
);
});
$(".manage-incidents-evidence-holder").empty();
$.each(table["evidence"], function (index, value) {
$(".manage-incidents-evidence-holder").append(
`

`
);
});
$(".manage-incidents-title-holder").empty();
if (PoliceJobs[playerJob] !== undefined || AmbulanceJobs[playerJob] !== undefined) {
$(".manage-incidents-title-holder").prepend(
`
Administrer hændelse
`
);
$(".manage-incidents-title").css("width", "66%");
$(".manage-incidents-create").css("margin-right", "0px");
} else if (DojJobs[playerJob] !== undefined) {
$(".manage-incidents-title-holder").prepend(
`
Administrer hændelse
`
);
$(".manage-incidents-title").css("width", "95%");
}
let associateddata = eventData.convictions;
$.each(associateddata, function (index, value) {
$(".associated-incidents-tags-holder").prepend(
`
${value.name}
`
);
var warrantTag = "red-tag";
var guiltyTag = "red-tag";
var processedTag = "red-tag";
var associatedTag = "red-tag";
if (value.warrant == 1) {
warrantTag = "green-tag";
}
if (value.guilty == 1) {
guiltyTag = "green-tag";
}
if (value.processed == 1) {
processedTag = "green-tag";
}
if (value.associated == 1) {
associatedTag = "green-tag";
}
const cid = value.cid;
// If the associated field is not checked, then populate the recommended fine and sentence fields
const associatedIncidentsContainer = (value.associated != 1) && `
Anbefalet bøde
Anbefalet straf
Bøde
Straf
Fængsel
Bøde
${canSendToCommunityService ? `` : ''}
`;
$(".incidents-ghost-holder").prepend(
`
${value.name} (#${cid})
Højreklik fornede for at tilføje/ændre sigtelser
${associatedIncidentsContainer}
`
);
$(".fine-amount")
.filter("[data-id='" + value.cid + "']")
.val(value.fine);
$(".sentence-amount")
.filter("[data-id='" + value.cid + "']")
.val(value.sentence);
$(".fine-recommended-amount")
.filter("[data-id='" + value.cid + "']")
.val(value.recfine);
$(".sentence-recommended-amount")
.filter("[data-id='" + value.cid + "']")
.val(value.recsentence);
const charges = value["charges"];
for (var i = 0; i < charges.length; i++) {
const randomNum = Math.ceil(
Math.random() * 1000
).toString();
$(`[data-name="${cid}"]`).prepend(
`
${charges[i]}
`
);
}
});
} else if (eventData.type == "incidentSearchPerson") {
let table = eventData.data;
$(".incidents-person-search-holder").empty();
$.each(table, function (index, value) {
let name = value.firstname + " " + value.lastname;
$(".incidents-person-search-holder").prepend(
`
Borger ID
${value.id}
Navn
${name}
`
);
});
} else if (eventData.type == "boloData") {
let table = eventData.data;
$(".manage-bolos-editing-title").html(
"Du redigerer efterlyning " + table["id"]
);
if ($(".badge-logo").attr("src") == "img/ems_badge.webp") {
$(".manage-bolos-editing-title").html(
"Du redigerer intensiv checkin " + table["id"]
);
}
$(".manage-bolos-editing-title").data("id", Number(table["id"]));
$(".manage-bolos-input-title").val(table["title"]);
$(".manage-bolos-input-plate").val(table["plate"]);
$(".manage-bolos-input-owner").val(table["owner"]);
$(".manage-bolos-input-individual").val(table["individual"]);
$(".manage-bolos-reports-content").trumbowyg({
changeActiveDropdownIcon: true,
imageWidthModalEdit: true,
btns: [
['foreColor', 'backColor','fontfamily','fontsize','indent', 'outdent'],
['strong', 'em',], ['insertImage'],
['viewHTML'],
['undo', 'redo'],
['formatting'],
['superscript', 'subscript'],
['link'],
['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
['horizontalRule']
],
});
$(".manage-bolos-reports-content").trumbowyg('html', table["detail"]);
$(".manage-bolos-tags-holder").empty();
$.each(table["tags"], function (index, value) {
$(".manage-bolos-tags-holder").prepend(
`
${value}
`
);
});
$(".bolo-gallery-inner-container").empty();
$.each(table["gallery"], function (index, value) {
let randomNum = Math.ceil(Math.random() * 10).toString();
$(".bolo-gallery-inner-container").prepend(
`

`
);
});
$(".manage-officers-tags-holder").empty();
$.each(table["officersinvolved"], function (index, value) {
$(".manage-officers-tags-holder").prepend(
`
${value}
`
);
});
} else if (eventData.type == "bolos") {
let table = eventData.data;
var reportName = "Generel efterlysning";
canSearchForProfiles = true;
$(".bolos-items").empty();
if ($(".badge-logo").attr("src") == "img/ems_badge.webp") {
reportName = "Intensiv check-in";
}
$.each(table, function (index, value) {
$(".bolos-items").prepend(
`
${value.title}
${reportName}
ID: ${value.id}
${value.author
} - ${timeAgo(Number(value.time))}
`
);
});
} else if (eventData.type == "boloComplete") {
let id = eventData.data;
if (canRefreshBolo == true) {
canRefreshBolo = false;
$(".bolos-search-refresh").empty();
$(".bolos-search-refresh").prepend(
`
`
);
setTimeout(() => {
$(".bolos-search-refresh").empty();
$(".bolos-search-refresh").html("Genindlæs");
canRefreshBolo = true;
$.post(`https://${GetParentResourceName()}/getAllBolos`, JSON.stringify({}));
}, 1500);
}
$(".manage-bolos-editing-title").html(
"Du redigerer efterlysning " + id
);
$(".manage-bolos-editing-title").data("id", Number(id));
} else if (eventData.type == "reportComplete") {
let id = eventData.data;
if (canRefreshReports == true) {
canRefreshReports = false;
$(".reports-search-refresh").empty();
$(".reports-search-refresh").prepend(
`
`
);
setTimeout(() => {
$(".reports-search-refresh").empty();
$(".reports-search-refresh").html("Genindlæs");
canRefreshReports = true;
$.post(`https://${GetParentResourceName()}/getAllReports`, JSON.stringify({}));
}, 1500);
}
$(".manage-reports-editing-title").html(
"Du redigerer rapport " + id
);
$(".manage-reports-editing-title").data("id", Number(id));
} else if (eventData.type == "reports") {
let table = eventData.data;
canSearchForReports = true;
$(".reports-items").empty();
$.each(table, function (index, value) {
$(".reports-items").append(
`
${value.title}
${value.type
} Report
ID: ${value.id}
${value.author
} - ${timeAgo(Number(value.time))}
`
);
});
$(".contextmenu").on("click", ".reports-delete", function () {
$(".reports-items")
.find(`[data-id="${$(this).data("info")}"]`)
.remove();
$.post(
`https://${GetParentResourceName()}/deleteReports`,
JSON.stringify({
id: $(this).data("info"),
})
);
});
$(".reports-items").on("contextmenu", ".reports-item", function (e) {
var args = "";
args = [
{
className: "reports-delete",
icon: "fas fa-times",
text: "Slet rapport",
info: $(this).data("id"),
status: "",
},
];
openContextMenu(e, args);
});
} else if (eventData.type == "reportData") {
let table = eventData.data;
$(".manage-reports-editing-title").html(
"You are currently editing report " + table["id"]
);
$(".manage-reports-editing-title").data("id", Number(table["id"]));
$(".manage-reports-input-title").val(table["title"]);
$(".manage-reports-input-type").val(table["type"]);
$(".manage-reports-reports-content").trumbowyg({
changeActiveDropdownIcon: true,
imageWidthModalEdit: true,
btns: [
['foreColor', 'backColor','fontfamily','fontsize','indent', 'outdent'],
['strong', 'em',], ['insertImage'],
['viewHTML'],
['undo', 'redo'],
['formatting'],
['superscript', 'subscript'],
['link'],
['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
['horizontalRule']
],
});
$(".manage-reports-reports-content").trumbowyg('html', table["details"]);
$(".manage-reports-tags-holder").empty();
$.each(table["tags"], function (index, value) {
$(".manage-reports-tags-holder").append(
`
${value}
`
);
});
$(".reports-gallery-inner-container").empty();
$.each(table["gallery"], function (index, value) {
let randomNum = Math.ceil(Math.random() * 10).toString();
$(".reports-gallery-inner-container").append(
`

`
);
});
$(".reports-officers-tags-holder").empty();
$.each(table["officersinvolved"], function (index, value) {
$(".reports-officers-tags-holder").append(
`
${value}
`
);
});
$(".reports-civilians-tags-holder").empty();
$.each(table["civsinvolved"], function (index, value) {
$(".reports-civilians-tags-holder").append(
`
${value}
`
);
});
} else if (eventData.type == "searchedVehicles") {
} else if (eventData.type == "getVehicleData") {
impoundChanged = false;
let table = eventData.data;
$(".vehicle-information-title-holder").data(
"dbid",
Number(table["dbid"])
);
$(".vehicle-info-plate-input").val(table["plate"]);
$(".vehicle-info-owner-input").val(table["name"]);
$(".vehicle-info-class-input").val(table["class"]);
$(".vehicle-info-model-input").val(table["model"]);
$(".vehicle-info-imageurl-input").val(table["image"]);
let vehiclePoints = table["points"] != null ? table["points"] : 0;
$("#vehiclePointsSlider").val(vehiclePoints);
$("#vehiclePointsSliderValue").html(vehiclePoints);
$(".vehicle-info-content").val(table["information"]);
$(".vehicle-tags").empty();
$(".vehicle-info-image").attr("src", table["image"]);
$(".vehicle-tags").prepend(
`
${table.colorName}
`
);
let impound = "red-tag";
let bolo = "red-tag";
let codefive = "red-tag";
let stolen = "red-tag";
if (table.impound) {
impound = "green-tag";
}
if (table.bolo) {
bolo = "green-tag";
}
if (table.code) {
codefive = "green-tag";
}
if (table.stolen) {
stolen = "green-tag";
}
$(".vehicle-tags").append(`
Beslaglæg
`);
$(".vehicle-tags").append(`
Efterlys
`);
$(".vehicle-tags").append(`
Kode 5
`);
$(".vehicle-tags").append(`
Stjålet
`);
$(".vehicle-info-imageurl-input").val(table["image"]);
} else if (eventData.type == "getWeaponData") {
impoundChanged = false;
let table = eventData.data;
$(".weapon-information-title-holder").data( "dbid", table["id"] );
$(".weapon-info-serial-input").val(table["serial"]);
$(".weapon-info-owner-input").val(table["owner"]);
$(".weapon-info-class-input").val(table["weapClass"]);
$(".weapon-info-model-input").val(table["weapModel"]);
$(".weapon-info-imageurl-input").val(table["image"]);
$(".weapon-info-content").val(table["information"]);
$(".weapon-info-image").attr("src", table["image"]);
$(".weapon-info-imageurl-input").val(table["image"]);
$(".contextmenu").on("click", ".weapons-delete", function () {
$(".weapons-items")
.find(`[data-id="${$(this).data("info")}"]`)
.remove();
$.post(
`https://${GetParentResourceName()}/deleteWeapons`,
JSON.stringify({
id: $(this).data("info"),
})
);
});
$(".weapons-items").on("contextmenu", ".weapons-item", function (e) {
var args = "";
args = [
{
className: "weapons-delete",
icon: "fas fa-times",
text: "Slet våbeninformation",
info: $(this).data("id"),
status: "",
},
];
openContextMenu(e, args);
});
} else if (eventData.type == "updateVehicleDbId") {
$(".vehicle-information-title-holder").data("dbid", Number(eventData.data));
} else if (eventData.type == "updateIncidentDbId") {
$(".manage-incidents-editing-title").data("id", Number(eventData.data));
$(".manage-incidents-tags-add-btn").css("pointer-events", "auto");
$(".manage-incidents-reports-content").css(
"pointer-events",
"auto"
);
$(".manage-incidents-officers-add-btn").css(
"pointer-events",
"auto"
);
$(".manage-incidents-civilians-add-btn").css(
"pointer-events",
"auto"
);
$(".manage-incidents-evidence-add-btn").css(
"pointer-events",
"auto"
);
$(".associated-incidents-tags-add-btn").css(
"pointer-events",
"auto"
);
} else if (eventData.type == "callDetach") {
$(".active-calls-item")
.filter("[data-id='" + eventData.callid + "']")
.children()
.children()
.find(".call-radio")
.html(eventData.data);
} else if (eventData.type == "callAttach") {
$(".active-calls-item")
.filter("[data-id='" + eventData.callid + "']")
.children()
.children()
.find(".call-radio")
.html(eventData.data);
} else if (eventData.type == "getAllLogs") {
let table = eventData.data;
$(".stafflogs-box").empty();
$.each(table, function (index, value) {
$(".stafflogs-box").append(
`
► ${value.text
} (${timeAgo(
Number(value.time)
)})
`
);
});
} else if (eventData.type == "statusImpound") {
const table = eventData.data;
const plate = eventData.plate;
const linkedreport = table["linkedreport"];
const fee = table["fee"];
const time = table["time"] * 1000;
let localDate = new Date(time);
const impoundDate = localDate.toLocaleDateString("en-US", {
timeZone: "UTC",
});
const impoundTime = localDate.toLocaleTimeString("en-US", {
timeZone: "UTC",
});
$(".impound-plate").val(plate).attr("disabled", "disabled");
$(".impound-linkedreport")
.val(linkedreport)
.attr("disabled", "disabled");
$(".impound-fee")
.val("$" + fee)
.attr("disabled", "disabled");
if (table.paid === 1) {
$(".impound-fee").css("color", "green");
} else {
$(".impound-fee").css("color", "red");
}
$(".impound-time")
.val(impoundDate + " - " + impoundTime)
.attr("disabled", "disabled");
$(".impound-cancel").html("Close");
$(".impound-submit").fadeOut(250);
$(".impound-form").slideDown(250);
$(".impound-form").fadeIn(250);
} else if (eventData.type == "greenImpound") {
$(".vehicle-tags")
.find(".impound-tag")
.addClass("green-tag")
.removeClass("red-tag");
} else if (eventData.type == "redImpound") {
$(".vehicle-tags")
.find(".impound-tag")
.removeClass("green-tag")
.addClass("red-tag");
}
});
});
function fidgetSpinner(page) {
$(".close-all").fadeOut(0);
$(".container-load").fadeIn(0);
if (page == ".dashboard-page-container"){
$.post(`https://${GetParentResourceName()}/getAllDashboardData`, JSON.stringify({}));
}
if (page == ".bolos-page-container") {
$.post(`https://${GetParentResourceName()}/getAllBolos`, JSON.stringify({}));
}
if (page == ".reports-page-container") {
$.post(`https://${GetParentResourceName()}/getAllReports`, JSON.stringify({}));
}
if (page == ".stafflogs-page-container") {
$.post(`https://${GetParentResourceName()}/getAllLogs`, JSON.stringify({}));
}
if (page == ".incidents-page-container") {
$.post(`https://${GetParentResourceName()}/getAllIncidents`, JSON.stringify({}));
}
setTimeout(() => {
$(".container-load").fadeOut(0);
$(page).fadeIn(0);
}, 1250);
}
function timeShit() {
let localDate = new Date();
const myTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
date = localDate.toLocaleDateString("en-US", {
timeZone: myTimeZone,
});
time = localDate.toLocaleTimeString("en-US", {
timeZone: myTimeZone,
});
$(".date").html(date);
$(".time").html(time);
}
setInterval(timeShit, 1000);
function addTag(tagInput) {
$(".tags-holder").prepend(`
${tagInput}
`);
$.post(
`https://${GetParentResourceName()}/newTag`,
JSON.stringify({
id: $(".manage-profile-citizenid-input").val(),
tag: tagInput,
})
);
}
// Use the customSentence if defined, otherwise use the recommendedSentence
// This uses the assumption that customSentence will be 0 if not defined
function sendToJail(citizenId, customSentence, recommendedSentence) {
const sentence = Number(customSentence) || Number(recommendedSentence);
$.post(`https://${GetParentResourceName()}/sendToJail`, JSON.stringify({
citizenId,
sentence,
}));
}
// Use the customSentence if defined, otherwise use the recommendedSentence
// This uses the assumption that customSentence will be 0 if not defined
function sendToCommunityService(citizenId, customSentence, recommendedSentence) {
const sentence = Number(customSentence) || Number(recommendedSentence);
$.post(`https://${GetParentResourceName()}/sendToCommunityService`, JSON.stringify({
citizenId,
sentence,
}));
}
// Use the customFine if defined, otherwise use the recommendedFine
// This uses the assumption that customFine will be 0 if not defined
function sendFine(citizenId, customFine, recommendedFine, incidentId) {
const fine = Number(customFine) || Number(recommendedFine);
$.post(`https://${GetParentResourceName()}/sendFine`, JSON.stringify({
citizenId,
fine,
incidentId,
}));
}
// Context menu
var menu = document.querySelector(".contextmenu");
function showMenu(x, y) {
$(".contextmenu").css("left", x + "px");
$(".contextmenu").css("top", y + "px");
$(".contextmenu").addClass("contextmenu-show");
}
function showChargesMenu(x, y) {
$(".ccontextmenu").css("left", x + "px");
$(".ccontextmenu").css("top", y + "px");
$(".ccontextmenu").addClass("ccontextmenu-show");
}
function hideMenu() {
$(".contextmenu").removeClass("contextmenu-show");
}
function hideChargesMenu() {
$(".ccontextmenu").removeClass("ccontextmenu-show");
}
function onMouseDown(e) {
hideMenu();
hideChargesMenu();
document.removeEventListener("mouseup", onMouseDown);
}
function openContextMenu(e, args) {
e.preventDefault();
showMenu(e.pageX, e.pageY);
$(".contextmenu").empty();
$.each(args, function (index, value) {
if (value.status !== "blur(5px)") {
$(".contextmenu").prepend(
`
`
);
}
});
document.addEventListener("mouseup", onMouseDown);
}
function openChargesContextMenu(e, args) {
e.preventDefault();
showChargesMenu(e.pageX, e.pageY);
$(".ccontextmenu").empty();
$.each(args, function (index, value) {
if (value.status !== "blur(5px)") {
$(".ccontextmenu").prepend(
`
`
);
}
});
document.addEventListener("mouseup", onMouseDown);
}
function expandImage(url) {
$(".close-all").css("filter", "brightness(35%)");
$(".gallery-image-enlarged").fadeIn(150);
$(".gallery-image-enlarged").css("display", "block");
$(".gallery-image-enlarged").attr("src", url);
}
function copyImageSource(url) {
const el = document.createElement('textarea');
el.value = url;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
}
function removeImage(url) {
let cid = $(".manage-profile-citizenid-input").val();
$(".gallery-inner-container img")
.filter("[src='" + url + "']")
.remove();
}
function hideIncidentsMenu() {
if (
$(".incidents-person-search-container").css("display") != "none" &&
!mouse_is_inside
) {
$(".incidents-person-search-container").fadeOut(250);
$(".close-all").css("filter", "none");
}
if (
$(".convictions-known-container").css("display") != "none" &&
!mouse_is_inside
) {
$(".convictions-known-container").fadeOut(0);
$(".close-all").css("filter", "none");
}
if (
$(".incidents-known-container").css("display") != "none" &&
!mouse_is_inside
) {
$(".incidents-known-container").fadeOut(0);
$(".close-all").css("filter", "none");
}
}
function onMouseDownIncidents(e) {
hideIncidentsMenu();
document.removeEventListener("mouseup", onMouseDownIncidents);
}
function titleCase(str) {
return str
.split(' ')
.map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase())
.join(' ');
}
function searchProfilesResults(result) {
canSearchForProfiles = true;
$(".profile-items").empty();
if (result.length < 1) {
$(".profile-items").html(
`
`
);
return true;
}
let profileHTML = "";
result.forEach((value) => {
let charinfo = value.charinfo;
let metadata = value.metadata;
if (typeof value.charinfo == "string") {
charinfo = JSON.parse(charinfo);
}
if (typeof value.metadata == "string") {
metadata = JSON.parse(metadata);
}
if (!metadata) {
metadata = {};
}
if (!metadata.licences) {
metadata.licences = {};
}
let name = charinfo.firstname + " " + charinfo.lastname;
let warrant = "red-tag";
let convictions = "red-tag";
let licences = "";
let licArr = Object.entries(metadata.licences);
if (licArr.length == 0 || licArr.length == undefined) {
var licenseTypes = ['business', 'pilot', 'weapon', 'driver'];
licArr = Object.entries(licenseTypes.reduce((licenseType, licenseValue) => (licenseType[licenseValue] = false, licenseType), {}));
}
if (licArr.length > 0 && (PoliceJobs[playerJob] !== undefined || DojJobs[playerJob] !== undefined)) {
for (const [lic, hasLic] of licArr) {
let tagColour =
hasLic == true ? "green-tag" : "red-tag";
licences += `
${titleCase(lic)}`;
}
}
if (value.warrant == true) {
warrant = "green-tag";
}
if (value.convictions < 5) {
convictions = "green-tag";
} else if (
value.convictions > 4 &&
value.convictions < 15
) {
convictions = "orange-tag";
}
if (value.pp == '') {
value.pp = 'img/not-found.webp'
}
profileHTML += `
${name}
${licences}
${value.warrant ? "Aktiv" : "Ingen"} efterlysning
${value.convictions} Convictions
Borger ID: ${value.citizenid}
`;
});
$(".profile-items").html(profileHTML);
}
window.addEventListener("message", (event) => {
if (event.data.action === "updateOfficerData") {
updateOfficerData(event.data.data);
} else if (event.data.action === "updateFingerprintData") {
const { fingerprint } = event.data;
if (fingerprint && fingerprint !== "") {
$(".manage-profile-fingerprint-input").val(fingerprint);
} else {
$(".manage-profile-fingerprint-input").val("");
}
}
});
function updateOfficerData(officerData) {
const leaderboardBox = document.querySelector('.leaderboard-box');
leaderboardBox.innerHTML = '';
const positions = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th', '13th', '14th', '15th', '16th', '17th', '18th', '19th', '20th', '21th', '22th', '23th', '24th', '25th'];
officerData.forEach((officer, index) => {
const position = positions[index];
const officerDiv = document.createElement('div');
officerDiv.className = 'leaderboard-box-test';
officerDiv.style.fontSize = '1.3vh';
officerDiv.style.fontWeight = 'lighter';
officerDiv.style.color = index < 3 ? 'white' : 'grey';
officerDiv.innerHTML = `► ${position}: ${officer.name} (${officer.callsign})
${officer.totalTime}`;
leaderboardBox.appendChild(officerDiv);
});
}
window.addEventListener("load", function () {
document
.getElementById("offenses-search")
.addEventListener("keyup", function () {
var search = this.value.toLowerCase();
if (search.length > 1) {
$.each($(".offense-item"), function (i, d) {
const Name = $(this)
.find(".offense-item-offense")
.html()
.toLowerCase();
const Number = $(this)
.find(".offense-item-id")
.html()
.toLowerCase();
if (Name.includes(search)) {
$(this).show();
} else if (Number.includes(search)) {
$(this).show();
} else {
$(this).hide();
}
});
} else {
$.each($(".offense-item"), function (i, d) {
$(this).show();
});
}
});
});
// Dispatch Map //
customcrs = L.extend({}, L.CRS.Simple, {
projection: L.Projection.LonLat,
scale: function(zoom) {
return Math.pow(2, zoom);
},
zoom: function(sc) {
return Math.log(sc) / 0.6931471805599453;
},
distance: function(pos1, pos2) {
var x_difference = pos2.lng - pos1.lng;
var y_difference = pos2.lat - pos1.lat;
return Math.sqrt(x_difference * x_difference + y_difference * y_difference);
},
transformation: new L.Transformation(0.02072, 117.3, -0.0205, 172.8),
infinite: false
});
var map = L.map("map-item", {
crs: customcrs,
minZoom: 3,
maxZoom: 5,
zoom: 5,
noWrap: true,
continuousWorld: false,
preferCanvas: true,
center: [0, -1024],
maxBoundsViscosity: 1.0
});
var customImageUrl = 'https://i.imgur.com/EdOZjzF.jpg';
var sw = map.unproject([0, 1024], 3 - 1);
var ne = map.unproject([1024, 0], 3 - 1);
var mapbounds = new L.LatLngBounds(sw, ne);
map.setView([-300, -1500], 4);
map.setMaxBounds(mapbounds);
map.attributionControl.setPrefix(false)
L.imageOverlay(customImageUrl, mapbounds).addTo(map);
map.on('dragend', function() {
if (!mapbounds.contains(map.getCenter())) {
map.panTo(mapbounds.getCenter(), { animate: false });
}
});
var Dispatches = {};
var DispatchPing = L.divIcon({
html: '
',
iconSize: [20, 20],
className: 'map-icon map-icon-ping',
offset: [-10, 0]
});
var mapMarkers = L.layerGroup();
function DispatchMAP(DISPATCH) {
var MIN = Math.round(Math.round((new Date() - new Date(DISPATCH.time)) / 1000) / 60);
if (MIN > 10) return;
var COORDS_X = DISPATCH.origin.x
var COORDS_Y = DISPATCH.origin.y
var CODE = DISPATCH.callId
Dispatches[CODE] = L.marker([COORDS_Y, COORDS_X], { icon: DispatchPing });
Dispatches[CODE].addTo(map);
// Automatic deletion after a period of 20 minutes, equivalent to 1200000 milliseconds.
setTimeout(function() {
map.removeLayer(Dispatches[CODE]);
}, 1200000);
Dispatches[CODE].bindTooltip(`
${DISPATCH.dispatchMessage}
`,
{
direction: 'top',
permanent: false,
offset: [0, -10],
opacity: 1,
interactive: true,
className: 'map-tooltip'
});
Dispatches[CODE].addTo(mapMarkers);
Dispatches[CODE].on('click', function() {
const callId = CODE
$.post(
`https://${GetParentResourceName()}/setWaypoint`,
JSON.stringify({
callid: callId,
})
);
});
Dispatches[CODE].on('contextmenu', function() {
map.removeLayer(Dispatches[CODE]);
});
}
function ClearMap() {
$(".leaflet-popup-pane").empty();
$(".leaflet-marker-pane").empty();
}
$(".map-clear").on('click', function() {
$(".map-clear").empty();
$(".map-clear").prepend(
`
`
);
setTimeout(() => {
$(".map-clear").empty();
$(".map-clear").html("Fjern");
ClearMap();
}, 1500);
});