PhotoSphereStudio/public/assets/drag-and-drop.js

64 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2023-05-22 22:44:08 +07:00
function convertDMSToDD([degrees, minutes, seconds], ref) {
2023-06-27 22:39:15 +07:00
decimal_degrees = degrees + minutes / 60 + seconds / 3600;
if (ref == 'S' || ref == 'W') {
decimal_degrees = -decimal_degrees;
}
return decimal_degrees;
}
2023-04-08 10:34:31 +07:00
function readURL(input) {
2023-06-27 22:39:15 +07:00
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('.image-upload-wrap').hide();
$('.file-upload-image').attr('src', e.target.result);
$('.file-upload-content').show();
$('.image-title').html(input.files[0].name);
var img = document.createElement('img');
img.src = e.target.result;
// Render thumbnail.
img.onload = function () {
EXIF.getData(img, function () {
var allMetaData = EXIF.getAllTags(this);
var allMetaDataSpan = document.getElementById('allMetaDataSpan');
// allMetaDataSpan.innerHTML = JSON.stringify(allMetaData, null, '\t');
var lat = convertDMSToDD(
EXIF.getTag(this, 'GPSLatitude'),
EXIF.getTag(this, 'GPSLatitudeRef')
);
var long = convertDMSToDD(
EXIF.getTag(this, 'GPSLongitude'),
EXIF.getTag(this, 'GPSLongitudeRef')
);
$('#lat').val(lat);
$('#long').val(long);
console.log(`lat: ${lat}, long: ${long}`);
});
};
};
reader.readAsDataURL(input.files[0]);
} else {
removeUpload();
}
2023-04-08 10:34:31 +07:00
}
function removeUpload() {
2023-06-27 22:39:15 +07:00
$('.file-upload-input').replaceWith($('.file-upload-input').clone());
$('.file-upload-content').hide();
$('.image-upload-wrap').show();
2023-04-08 10:34:31 +07:00
}
$('.image-upload-wrap').bind('dragover', function () {
2023-06-27 22:39:15 +07:00
$('.image-upload-wrap').addClass('image-dropping');
2023-04-08 10:34:31 +07:00
});
$('.image-upload-wrap').bind('dragleave', function () {
2023-06-27 22:39:15 +07:00
$('.image-upload-wrap').removeClass('image-dropping');
});