Skip to content

Commit

Permalink
feat: bpt_idcard\html\assets\js\init.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed May 18, 2024
1 parent 88e9b45 commit a06ba95
Showing 1 changed file with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
$(document).ready(function () {
// LUA listener
window.addEventListener('message', function (event) {
if (event.data.action == 'open') {
var type = event.data.type;
var userData = event.data.array['user'][0];
var licenseData = event.data.array['licenses'];
var sex = userData.sex;

if (type == 'driver' || type == null) {
$('img').show();
$('#name').css('color', '#282828');

if (sex.toLowerCase() == 'm') {
$('img').attr('src', 'assets/images/male.png');
$('#sex').text('male');
} else {
$('img').attr('src', 'assets/images/female.png');
$('#sex').text('female');
}

$('#name').text(userData.firstname + ' ' + userData.lastname);
$('#dob').text(userData.dateofbirth);
$('#height').text(userData.height);
$('#signature').text(userData.firstname + ' ' + userData.lastname);

if (type == 'driver') {
if (licenseData != null) {
Object.keys(licenseData).forEach(function (key) {
var type = licenseData[key].type;

if (type == 'drive_bike') {
type = 'bike';
} else if (type == 'drive_truck') {
type = 'truck';
} else if (type == 'drive') {
type = 'car';
}

if (type == 'bike') {
$('#licenses').append('<p>' + 'Bike' + '</p>');
} else if (type == 'truck') {
$('#licenses').append('<p>' + 'Truck' + '</p>');
} else if (type == 'car') {
$('#licenses').append('<p>' + 'Car' + '</p>');
}
});
}

$('#id-card').css('background', 'url(assets/images/license.png)');
} else {
$('#id-card').css('background', 'url(assets/images/idcard.png)');
}
} else if (type == 'weapon') {
$('img').hide();
$('#name').css('color', '#d9d9d9');
$('#name').text(userData.firstname + ' ' + userData.lastname);
$('#dob').text(userData.dateofbirth);
$('#signature').text(userData.firstname + ' ' + userData.lastname);

$('#id-card').css('background', 'url(assets/images/firearm.png)');
}

$('#id-card').show();
} else if (event.data.action == 'close') {
$('#name').text('');
$('#dob').text('');
$('#height').text('');
$('#signature').text('');
$('#sex').text('');
$('#id-card').hide();
$('#licenses').html('');
}
});
});

0 comments on commit a06ba95

Please sign in to comment.