forked from Simnation/Main
752 lines
No EOL
20 KiB
JavaScript
752 lines
No EOL
20 KiB
JavaScript
let locale = 'en';
|
|
let navMenu;
|
|
let isInit = true;
|
|
let userrights;
|
|
let lastjob;
|
|
let lastjobgrade;
|
|
let currentSystem;
|
|
let job_grades = [];
|
|
let sync;
|
|
let useWeaponRegister = true;
|
|
let useMyImpound = true;
|
|
let useMySpeedcam = true;
|
|
let HandleParagraphsAsNumber = false;
|
|
let UseMotDateFromMyMechanicMDT = false;
|
|
let showLastMotDetailFromMyMechanicMDT = false;
|
|
let showPartAcceptanceFromMyMechanicMDT = false;
|
|
let UseMyPrison = false;
|
|
|
|
let globalFileSearcher = new FileSearch()
|
|
|
|
const coreFile = "myMDT_core";
|
|
|
|
|
|
(function(){
|
|
|
|
document.onkeydown = function(e){
|
|
if(e.key.toLowerCase() == "escape"){
|
|
closeWin();
|
|
}
|
|
}
|
|
|
|
|
|
document.getElementById("delete-modal-delete").onclick=function(){
|
|
let id = document.getElementById("delete-modal").getAttribute("data-id");
|
|
let src = document.getElementById("delete-modal").getAttribute("data-delete-destination");
|
|
deleteData(src, id);
|
|
}
|
|
|
|
|
|
window.addEventListener('message', function( event ) {
|
|
if(event.data.message == "show"){
|
|
document.documentElement.setAttribute("data-theme",event.data.theme)
|
|
|
|
useWeaponRegister = event.data.useWeaponRegister
|
|
HandleParagraphsAsNumber = event.data.HandleParagraphsAsNumber
|
|
UseMotDateFromMyMechanicMDT = event.data.UseMotDateFromMyMechanicMDT
|
|
showLastMotDetailFromMyMechanicMDT = event.data.showLastMotDetailFromMyMechanicMDT
|
|
showPartAcceptanceFromMyMechanicMDT = event.data.showPartAcceptanceFromMyMechanicMDT
|
|
useMyImpound = event.data.useMyImpound
|
|
useMySpeedcam = event.data.useMySpeedcam
|
|
UseMyPrison = event.data.UseMyPrison
|
|
|
|
sync=new Sync(event.data.Sync)
|
|
locale = event.data.locale
|
|
document.getElementById("main_navigation_copname").innerHTML = System.buildEmployeeName(event.data.username);
|
|
document.getElementById("main").style.display = "";
|
|
document.getElementById("radiostates").style.display = "none";
|
|
|
|
userrights = new Rights(event.data.rights);
|
|
job_grades = event.data.job_grades;
|
|
|
|
if(lastjob != event.data.job || lastjobgrade != event.data.jobgrade){
|
|
isInit = true;
|
|
lastjob = event.data.job;
|
|
lastjobgrade = event.data.jobgrade;
|
|
}
|
|
|
|
currentSystem = event.data.currentsystem;
|
|
|
|
System.SetColor(event.data.currentsystem);
|
|
|
|
navMenu = new NavMenu(navigation, event.data.currentsystem);
|
|
|
|
Array.from(document.querySelectorAll(".nav-checkrights")).forEach(function(item){
|
|
if(item.getAttribute("data-rightkey") != ""){
|
|
if(userrights.has(item.getAttribute("data-rightkey"))){
|
|
item.style.display = "";
|
|
}
|
|
else{
|
|
item.style.display = "none";
|
|
}
|
|
|
|
if (item.id == "menuItem-li-regweapons" && !useWeaponRegister){
|
|
item.style.display = "none";
|
|
}
|
|
if (item.id == "menuItem-li-prison" && !UseMyPrison){
|
|
item.style.display = "none";
|
|
}
|
|
if (item.id == "menuItem-li-speedcamsmobile" && !useMySpeedcam){
|
|
item.style.display = "none";
|
|
}
|
|
if (item.id == "menuItem-li-speedcamsprofit" && !useMySpeedcam){
|
|
item.style.display = "none";
|
|
}
|
|
if (item.id == "menuItem-li-regvehicleimpounded" && !useMyImpound){
|
|
item.style.display = "none";
|
|
}
|
|
}
|
|
});
|
|
|
|
Array.from(document.querySelectorAll(".nav-checkfor-nextelements")).forEach(function(item){
|
|
let itemsVisible = false;
|
|
|
|
Array.from(document.querySelectorAll(".divier-" + item.getAttribute("data-tkey"))).forEach(function(child){
|
|
if(child.style.display != "none"){
|
|
itemsVisible = true;
|
|
}
|
|
});
|
|
|
|
if(!itemsVisible){
|
|
item.style.display="none";
|
|
}
|
|
else{
|
|
item.style.display="";
|
|
}
|
|
});
|
|
|
|
if(isInit){
|
|
loadPage("dashboard.dataload",-1);
|
|
isInit=false;
|
|
}
|
|
}
|
|
else if(event.data.message == "show-radio-states"){
|
|
locale = event.data.locale
|
|
document.documentElement.setAttribute("data-theme",event.data.theme)
|
|
|
|
document.getElementById("radiostates").style.display = "block";
|
|
document.getElementById("main").style.display = "none";
|
|
|
|
let radioDetails = System.getRadioState(event.data.curstate.vehicle, event.data.curstate.person);
|
|
|
|
let radioHud = new RadioHud();
|
|
|
|
radioHud.SetLocation(event.data.config.Position);
|
|
radioHud.SetExtraMargins(event.data.config.extraMargins);
|
|
radioHud.DrawInfo(radioDetails);
|
|
|
|
radioHud.DrawButtons(event.data.data, radioDetails.radio_id, radioDetails.radio_default);
|
|
|
|
}
|
|
});
|
|
|
|
fetch(`http://${location.host}/NuiReady`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({})
|
|
}).then((response) => {
|
|
response.json().then(function(retobj){});
|
|
});
|
|
|
|
})();
|
|
|
|
|
|
function handleMenuItemClick(item){
|
|
navMenu.setItemActive(item);
|
|
showLoading();
|
|
|
|
loadPage(item.getAttribute("data-destination"), -1, item.getAttribute("data-forceReload"));
|
|
}
|
|
|
|
|
|
function showLoading(){
|
|
document.getElementById("currentpage-content").innerHTML = `
|
|
Loading..
|
|
<progress class="progress progress-accent w-100 "></progress>
|
|
`;
|
|
}
|
|
|
|
|
|
function setCurrentPageHeadLine(text){
|
|
|
|
document.getElementById("current_page_name").innerHTML = text;
|
|
}
|
|
|
|
function changeDestination(input){
|
|
|
|
if(input == "lawbooklaws.dataload"){
|
|
input = "lawbooks.dataload"
|
|
}
|
|
if(input == "evidenceroomarticles.dataload"){
|
|
input = "evidencerooms.dataload"
|
|
}
|
|
|
|
return input;
|
|
}
|
|
|
|
|
|
function loadPage(destination, id, force = "false", staticData={}){
|
|
destination = changeDestination(destination);
|
|
document.body.setAttribute("data-quicksearch","")
|
|
|
|
|
|
if(destination.endsWith(".dataload") || destination.endsWith(".overview")){
|
|
force = "true";
|
|
|
|
if(destination.endsWith(".overview")){
|
|
document.body.setAttribute("data-quicksearch",document.getElementById("global-searchbar") ? document.getElementById("global-searchbar").value.trim() : "")
|
|
}
|
|
}
|
|
|
|
|
|
if(destination != document.body.getAttribute("data-lastdest")){
|
|
resetPageNum();
|
|
document.body.setAttribute("data-quicksearch","");
|
|
}
|
|
else if(id != document.body.getAttribute("data-last-id")){
|
|
resetPageNum();
|
|
}
|
|
|
|
document.body.setAttribute("data-lastdest", destination);
|
|
document.body.setAttribute("data-last-id", id);
|
|
document.body.setAttribute("data-force-load", force);
|
|
|
|
|
|
setActiveItem(destination);
|
|
setCurrentPageHeadLine(getTranslation(destination));
|
|
showLoading();
|
|
|
|
|
|
|
|
if(id == -1 && force == "false" && destination!="trainings.add" && destination!="criminalcomplaint.add" && destination!="evidenceroomarticles.add" && destination!="regvehicle.add" && destination!="regweapons.add"){
|
|
if(destination.endsWith(".view") || destination.endsWith(".edit") || destination.endsWith(".add")){
|
|
let loadtype = destination.replace(".view","").replace(".edit","").replace(".add","");
|
|
ShowDetails(destination, loadtype, staticData);
|
|
}
|
|
}
|
|
else{
|
|
loadData(destination, id, staticData)
|
|
}
|
|
}
|
|
|
|
|
|
function reload(){
|
|
loadPage(document.body.getAttribute("data-lastdest"),document.body.getAttribute("data-last-id"),document.body.getAttribute("data-force-load") )
|
|
}
|
|
|
|
function setActiveItem(destination){
|
|
|
|
let type = destination.replace(".overview","").replace(".dataload","").replace(".add","").replace(".edit","").replace(".view","");
|
|
let item;
|
|
|
|
|
|
if(destination == "trainings.add" || destination == "missionreport.add"){
|
|
type += ".add"
|
|
}
|
|
|
|
if(document.getElementById("menuitem-" + type)){
|
|
item = document.getElementById("menuitem-" + type);
|
|
}
|
|
|
|
|
|
if(item){
|
|
navMenu.setItemActive(item);
|
|
}
|
|
}
|
|
|
|
function ShowCustom(destination, loadtype, retobj){
|
|
let _class = System.getClassByName(loadtype);
|
|
|
|
|
|
if(_class !== null){
|
|
_class.CreateCustom(retobj);
|
|
}
|
|
else{
|
|
console.log("no class defined for " + loadtype);
|
|
}
|
|
}
|
|
|
|
function ShowOverview(loadtype, data){
|
|
let _class = System.getClassByName(loadtype);
|
|
|
|
|
|
if(_class !== null){
|
|
System.CreateOverView(
|
|
_class
|
|
,data
|
|
);
|
|
}
|
|
else{
|
|
console.log("no overview defined for " + loadtype)
|
|
}
|
|
}
|
|
|
|
function ShowDetails(destination, loadtype = "", data = {}){
|
|
|
|
let isViewMode = destination.endsWith(".view");
|
|
loadtype = loadtype.toLocaleLowerCase();
|
|
|
|
let _class = System.getClassByName(loadtype);
|
|
|
|
if(_class !== null){
|
|
let dest = "overview";
|
|
|
|
if (_class.hasOwnProperty("isCustom") && _class.isCustom()) {
|
|
dest = "dataload";
|
|
}
|
|
|
|
System.CreateEdit(
|
|
_class
|
|
,data.data
|
|
,isViewMode
|
|
,destination
|
|
,loadtype + "." + dest
|
|
);
|
|
}
|
|
else{
|
|
console.log("no detailsview defined for " + loadtype)
|
|
}
|
|
}
|
|
|
|
|
|
async function loadData(destination, id, staticData = {}){
|
|
destination = changeDestination(destination);
|
|
|
|
setActiveItem(destination.toLowerCase());
|
|
setCurrentPageHeadLine(getTranslation(destination.toLowerCase()));
|
|
showLoading();
|
|
|
|
|
|
destination = destination.toLowerCase()
|
|
|
|
let loadDest = destination;
|
|
let loadinfo = destination;
|
|
|
|
if(destination.endsWith(".overview")){
|
|
loadDest = "overview";
|
|
loadinfo = destination.replace(".overview","");
|
|
}
|
|
else if(destination.endsWith(".view") || destination.endsWith(".edit") || destination.endsWith(".add")){
|
|
loadDest = "loadDetails";
|
|
loadinfo = destination.replace(".view","");
|
|
loadinfo = loadinfo.replace(".edit","");
|
|
loadinfo = loadinfo.replace(".add","");
|
|
}
|
|
else{
|
|
loadDest = "custom"
|
|
loadinfo = destination.replace(".dataload","");
|
|
}
|
|
|
|
let data;
|
|
try{
|
|
const response = await fetch(`http://${location.host}/${loadDest}`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"pageNum": 1*((document.body.getAttribute("data-cur-pageNum")) ?? 1)-1,
|
|
"id": id,
|
|
"quicksearch": document.body.getAttribute("data-quicksearch"),
|
|
"load_info": loadinfo
|
|
})
|
|
});
|
|
data = await response.json();
|
|
}
|
|
catch(error){
|
|
console.log('Error fetching data:', error);
|
|
|
|
console.log(`--------------------------------------------`)
|
|
console.log(`info : http://${location.host}/${loadDest}`)
|
|
console.log(`pageNum : ${1*((document.body.getAttribute("data-cur-pageNum")) ?? 1)-1}`)
|
|
console.log(`id : ${id}`)
|
|
console.log(`load_info : ${loadinfo}`)
|
|
console.log(`quicksearch : ${quicksearch}`)
|
|
console.log(`--------------------------------------------`)
|
|
}
|
|
|
|
if(data){
|
|
if(loadDest == "overview"){
|
|
ShowOverview(loadinfo, data);
|
|
}
|
|
else if(loadDest == "loadDetails"){
|
|
if(staticData.data !== undefined && staticData.data !== null){
|
|
for (const [key, value] of Object.entries(staticData.data)) {
|
|
if(data.data[key] == undefined){
|
|
data.data[key] = value
|
|
}
|
|
}
|
|
}
|
|
|
|
ShowDetails(destination, loadinfo, data);
|
|
}
|
|
else if(loadDest == "custom"){
|
|
ShowCustom(destination, loadinfo, data);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function sendDataToAPI(source, destination, id, destination_id, formdata){
|
|
fetch(`http://${location.host}/save-data`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"source": source,
|
|
"id": id,
|
|
"formData": formdata,
|
|
"source": source.toLowerCase()
|
|
})
|
|
}).then((response) => {
|
|
response.json().then(function(retobj){
|
|
loadPage(destination.toLowerCase(), destination_id);
|
|
});
|
|
});
|
|
}
|
|
function deleteData(source, id){
|
|
fetch(`http://${location.host}/delete-data`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"id": id,
|
|
"source": source.toLowerCase()
|
|
})
|
|
}).then((response) => {
|
|
response.json().then(function(retobj){
|
|
document.getElementById("delete-modal").checked = false;
|
|
reload();
|
|
});
|
|
});
|
|
}
|
|
|
|
function saveData(source, destination, id, destination_id){
|
|
sendDataToAPI(source, destination, id, destination_id, Form.getFormData())
|
|
}
|
|
function finishManhunt(source, id){
|
|
fetch(`http://${location.host}/finish-manhunt`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"source": source,
|
|
"id": id,
|
|
"source": source.toLowerCase()
|
|
})
|
|
}).then((response) => {
|
|
response.json().then(function(retobj){
|
|
reload();
|
|
});
|
|
});
|
|
}
|
|
async function takeControlCentre(isReset){
|
|
let data;
|
|
try{
|
|
const response = await fetch(`http://${location.host}/takeControlCentre`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"isReset": isReset
|
|
})
|
|
});
|
|
data = await response.json();
|
|
|
|
reload();
|
|
}
|
|
catch(error){
|
|
console.log('Error fetching data:', error);
|
|
console.log(`info : http://${location.host}/takeControlCentre?isReset=${isReset}`)
|
|
}
|
|
}
|
|
|
|
async function SetRadioState(newID, destinationPage){
|
|
let data;
|
|
try{
|
|
const response = await fetch(`http://${location.host}/SetRadioState`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"new_state": newID
|
|
})
|
|
});
|
|
data = await response.json();
|
|
loadPage(destinationPage,-1)
|
|
}
|
|
catch(error){
|
|
console.log('Error fetching data:', error);
|
|
console.log(`info : http://${location.host}/SetRadioState?new_state=${newID}`)
|
|
}
|
|
}
|
|
async function SetRadioStateShortcut(newID){
|
|
let data;
|
|
try{
|
|
const response = await fetch(`http://${location.host}/SetRadioState`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"new_state": newID
|
|
})
|
|
});
|
|
data = await response.json();
|
|
closeWin()
|
|
}
|
|
catch(error){
|
|
console.log('Error fetching data:', error);
|
|
console.log(`info : http://${location.host}/SetRadioState?new_state=${newID}`)
|
|
}
|
|
}
|
|
async function SetVehicle(newID, destinationPage){
|
|
let data;
|
|
try{
|
|
const response = await fetch(`http://${location.host}/SetVehicle`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"new_state": newID
|
|
})
|
|
});
|
|
data = await response.json();
|
|
|
|
loadPage(destinationPage, -1);
|
|
}
|
|
catch(error){
|
|
console.log('Error fetching data:', error);
|
|
console.log(`info : http://${location.host}/SetVehicle?new_state=${newID}`)
|
|
console.log(`destinationpage : ${destinationPage}`)
|
|
}
|
|
}
|
|
|
|
|
|
async function changeDataInColumn(loadType, columnName, id, new_value){
|
|
let formdata = {};
|
|
formdata[columnName] = new_value
|
|
sendDataToAPI(loadType, document.body.getAttribute("data-lastdest") ,id, document.body.getAttribute("data-last-id"), formdata)
|
|
}
|
|
|
|
async function EmployeeSuspend(loadType, employeeid, value){
|
|
let data;
|
|
|
|
try{
|
|
const response = await fetch(`http://${coreFile}/employee_suspend`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"id": employeeid
|
|
,"value": value
|
|
})
|
|
});
|
|
data = await response.json();
|
|
|
|
loadPage(loadType, -1);
|
|
}
|
|
catch(error){
|
|
console.log('Error fetching data:', error);
|
|
console.log(`info : http://${location.host}/employee_suspend?id=${employeeid}&value=${value}`)
|
|
}
|
|
}
|
|
|
|
async function resetVehicle(vehicleId){
|
|
let data;
|
|
|
|
try{
|
|
const response = await fetch(`http://${location.host}/resetVehicle`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"id": vehicleId
|
|
})
|
|
});
|
|
data = await response.json();
|
|
|
|
loadPage("controlcentre.dataload".toLowerCase(), -1);
|
|
}
|
|
catch(error){
|
|
console.log('Error fetching data:', error);
|
|
console.log(`info : http://${location.host}/resetVehicle?id=${vehicleId}`)
|
|
}
|
|
}
|
|
async function resetEmployeeRadio(employeeid){
|
|
let data;
|
|
|
|
try{
|
|
const response = await fetch(`http://${location.host}/resetEmployeeRadio`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
"id": employeeid
|
|
})
|
|
});
|
|
data = await response.json();
|
|
|
|
loadPage("controlcentre.dataload".toLowerCase(), -1);
|
|
}
|
|
catch(error){
|
|
console.log('Error fetching data:', error);
|
|
console.log(`info : http://${location.host}/resetEmployeeRadio?id=${vehicleId}`)
|
|
}
|
|
}
|
|
async function closeWin(){
|
|
let data;
|
|
try{
|
|
const response = await fetch(`http://${location.host}/closeWindow`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({})
|
|
});
|
|
data = await response.json();
|
|
|
|
document.getElementById("main").style.display = "none";
|
|
document.getElementById("radiostates").style.display = "none";
|
|
|
|
}
|
|
catch(error){
|
|
console.log('Error while closing');
|
|
}
|
|
}
|
|
|
|
async function participateForTraining(trainingId, employee_id = null, fromEmployee = false){
|
|
let formdata = {};
|
|
formdata.training_id = trainingId
|
|
formdata.employee_id = employee_id
|
|
|
|
let destination = "trainings.overview";
|
|
let destId = -1;
|
|
if(employee_id !== null){
|
|
destination = "trainings.view";
|
|
destId = trainingId;
|
|
}
|
|
|
|
if(!fromEmployee){
|
|
sendDataToAPI("trainingsemployees", destination,-1, destId, formdata);
|
|
}
|
|
else{
|
|
sendDataToAPI("employeestraining", "employeestraining.dataload",-1, employee_id, formdata)
|
|
}
|
|
}
|
|
async function trainingPassed(passed, employee_id, training_id, fromEmployee = false){
|
|
let formdata = {};
|
|
formdata.training_id = training_id
|
|
formdata.employee_id = employee_id
|
|
formdata.passed = passed
|
|
|
|
if(!fromEmployee){
|
|
sendDataToAPI("trainingsemployees", "trainings.view",-1, training_id, formdata)
|
|
}
|
|
else{
|
|
sendDataToAPI("employeestraining", "employeestraining.dataload",-1, employee_id, formdata)
|
|
}
|
|
}
|
|
|
|
async function addLicenseToFile(file_id){
|
|
let licenseid = document.getElementById("input-files-license").value;
|
|
|
|
let formdata = {};
|
|
formdata.file_id = file_id
|
|
formdata.license_id = licenseid
|
|
|
|
sendDataToAPI("fileslicenses", "files.view",-1, file_id, formdata)
|
|
}
|
|
|
|
async function GenerateRoute(buttonEl, isProperty){
|
|
let data;
|
|
|
|
let coords = buttonEl.getAttribute("data-entering");
|
|
let parsed = JSON.parse(coords);
|
|
let xPos;
|
|
let yPos;
|
|
|
|
if(isProperty){
|
|
let is_my_property = buttonEl.getAttribute("data-is-my-property");
|
|
let is_qs_housing = buttonEl.getAttribute("data-is-qs-housing");
|
|
|
|
if(is_my_property == "1"){
|
|
xPos = parsed.x
|
|
yPos = parsed.y
|
|
}
|
|
else if(is_qs_housing == "1"){
|
|
xPos = parsed.enter.x
|
|
yPos = parsed.enter.y
|
|
}
|
|
else{
|
|
return;
|
|
}
|
|
}
|
|
else{
|
|
xPos = parsed.x
|
|
yPos = parsed.y
|
|
}
|
|
|
|
|
|
try{
|
|
const response = await fetch(`http://${location.host}/GenerateRoute`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
x: xPos,
|
|
y: yPos
|
|
})
|
|
});
|
|
data = await response.json();
|
|
|
|
closeWin();
|
|
}
|
|
catch(error){
|
|
console.log('Error while set route');
|
|
}
|
|
|
|
}
|
|
|
|
async function SearchFiles(htmlEl){
|
|
let data;
|
|
|
|
try{
|
|
const response = await fetch(`http://${location.host}/filterFilesDropdown`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
body: JSON.stringify({
|
|
id: htmlEl.getAttribute("data-parentid"),
|
|
search: htmlEl.value
|
|
})
|
|
});
|
|
data = await response.json();
|
|
|
|
}
|
|
catch(error){
|
|
console.log('Error while set SearchFiles');
|
|
}
|
|
|
|
|
|
Form.refillFilesDropDown(htmlEl, data)
|
|
|
|
}
|
|
|
|
function resetPageNum(){
|
|
document.body.setAttribute("data-cur-pageNum",1);
|
|
} |