Skip to content

Commit

Permalink
Added setting for enabling/disabling parsing of exif data
Browse files Browse the repository at this point in the history
  • Loading branch information
magma1447 committed Dec 1, 2016
1 parent f8efe64 commit 6faacb7
Showing 1 changed file with 66 additions and 60 deletions.
126 changes: 66 additions & 60 deletions greasemonkey-geocaching-projectgc.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@
removeDisclaimer: {
title: 'Remove disclaimer',
default: false
},
parseExifLocation: {
title: 'Parse Exif location',
default: true
}
};
return items;
Expand Down Expand Up @@ -840,71 +844,73 @@

function Page_Gallery() {
// Find location data in exif tags
$(window).load(function() { // Wait until page is loaded. If the images aren't loaded before this starts it will fail.
$('#ctl00_ContentBody_GalleryItems_DataListGallery img').each(function() {
EXIF.getData($(this)[0], function() {
// console.log(EXIF.pretty(this));
var GPSLatitudeRef = EXIF.getTag(this, "GPSLatitudeRef");
var GPSLatitude = EXIF.getTag(this, "GPSLatitude");
var GPSLongitudeRef = EXIF.getTag(this, "GPSLongitudeRef");
var GPSLongitude = EXIF.getTag(this, "GPSLongitude");

if(typeof(GPSLatitudeRef) != 'undefined') {
var coords = '';

coords += GPSLatitudeRef;
if(GPSLatitude[0] < 10) {
coords += '0' + GPSLatitude[0];
} else {
coords += GPSLatitude[0];
}
coords += ' ';
if(GPSLatitude[1] < 10) {
coords += '0' + GPSLatitude[1];
} else {
coords += GPSLatitude[1];
}
coords += '.';
var decimals = Math.round(GPSLatitude[2]/60*1000);
if(decimals < 10) {
coords += '00' + decimals;
} else if(decimals < 100) {
coords += '0' + decimals;
} else {
coords += decimals;
}
if(IsSettingEnabled('parseExifLocation')) {
$(window).load(function() { // Wait until page is loaded. If the images aren't loaded before this starts it will fail.
$('#ctl00_ContentBody_GalleryItems_DataListGallery img').each(function() {
EXIF.getData($(this)[0], function() {
// console.log(EXIF.pretty(this));
var GPSLatitudeRef = EXIF.getTag(this, "GPSLatitudeRef");
var GPSLatitude = EXIF.getTag(this, "GPSLatitude");
var GPSLongitudeRef = EXIF.getTag(this, "GPSLongitudeRef");
var GPSLongitude = EXIF.getTag(this, "GPSLongitude");

if(typeof(GPSLatitudeRef) != 'undefined') {
var coords = '';

coords += GPSLatitudeRef;
if(GPSLatitude[0] < 10) {
coords += '0' + GPSLatitude[0];
} else {
coords += GPSLatitude[0];
}
coords += ' ';
if(GPSLatitude[1] < 10) {
coords += '0' + GPSLatitude[1];
} else {
coords += GPSLatitude[1];
}
coords += '.';
var decimals = Math.round(GPSLatitude[2]/60*1000);
if(decimals < 10) {
coords += '00' + decimals;
} else if(decimals < 100) {
coords += '0' + decimals;
} else {
coords += decimals;
}

coords += ' ';
coords += ' ';

coords += GPSLongitudeRef;
if(GPSLongitude[0] < 10) {
coords += '00' + GPSLongitude[0];
} else if(GPSLongitude[0] < 100) {
coords += '0' + GPSLongitude[0];
} else {
coords += GPSLongitude[0];
}
coords += ' ';
if(GPSLongitude[1] < 10) {
coords += '0' + GPSLongitude[1];
} else {
coords += GPSLongitude[1];
}
coords += '.';
var decimals = Math.round(GPSLongitude[2]/60*1000);
if(decimals < 10) {
coords += '00' + decimals;
} else if(decimals < 100) {
coords += '0' + decimals;
} else {
coords += decimals;
}
coords += GPSLongitudeRef;
if(GPSLongitude[0] < 10) {
coords += '00' + GPSLongitude[0];
} else if(GPSLongitude[0] < 100) {
coords += '0' + GPSLongitude[0];
} else {
coords += GPSLongitude[0];
}
coords += ' ';
if(GPSLongitude[1] < 10) {
coords += '0' + GPSLongitude[1];
} else {
coords += GPSLongitude[1];
}
coords += '.';
var decimals = Math.round(GPSLongitude[2]/60*1000);
if(decimals < 10) {
coords += '00' + decimals;
} else if(decimals < 100) {
coords += '0' + decimals;
} else {
coords += decimals;
}

$('<span class="OldWarning">EXIF Location<br>' + coords + '</span>').insertAfter(this.parentNode);
}
$('<span class="OldWarning">EXIF Location<br>' + coords + '</span>').insertAfter(this.parentNode);
}
});
});
});
});
}
}

function Page_Bookmarks() {
Expand Down

0 comments on commit 6faacb7

Please sign in to comment.