Create PQ(s) on geocaching.com';
html += '0 | 0 | 0
';
var error_text = checkSelectErrorAvailable();
if (error_text != '') {
html += '
Error:
';
html += '
' + error_text + '
';
html += '
';
$(side).append(html);
} else {
html += '
PQ name (prefix): ';
html += ' ';
html += '
';
html += '
Configuration:
';
html += '
Choose how often your PQ(s) should run: ';
html += ' ';
html += ' ';
html += '
';
html += '
Output to email: ';
html += 'The secondary email will only work if you have two or more email addresses in your profile.
';
html += '
Instruction:
';
html += '
If you click the "Create PQ(s)" button, the GC little helper II will open as many pop-ups as PQs should be created. The number of simultaneously loaded pop-ups is limited to 5. All PQs will get the name that you entered in the field above and an ongoing digit prefix. The pop-ups close by themselves after the associated PQ has been created. We will display a message if all PQs are created. Please wait until all pop-ups are loaded.
';
html += '
Please make sure you do not have a pop-up blocker enabled. Otherwise this feature will not work as expected.
';
html += '';
$(side).append(html);
$(side).find('.pq_name')[0].addEventListener("change", function() {
if ($(this)[0].value != '') setValue('settings_pq_splitter_pqname', $(this)[0].value);
});
$(side).find('.button_create_pq')[0].addEventListener("click", prepareCreatePQ, false);
$(side).find('#how_often_' + table_index + '_' + settings_pq_splitter_how_often).attr('checked', true);
$(side).find('.how_often').each(function() {
$(this)[0].addEventListener("click", function() {
setValue('settings_pq_splitter_how_often', $(this).attr('index'));
});
});
$(side).find('.output_email')[0].value = settings_pq_splitter_email;
$(side).find('.output_email')[0].addEventListener("change", function() {
setValue('settings_pq_splitter_email', $(this)[0].value);
});
}
}
// Build css.
function buildCss() {
var css = '';
css += 'tfoot {background-color: #d4edda;}';
css += 'tfoot h4 > span {font-size: 14px; font-weight: normal; float: right; margin-top: 2px;}';
css += 'tfoot h5 {margin-top: 18px;}';
css += 'tfoot label {padding-left: 4px; margin-bottom: 0px; font-weight: normal;}';
css += 'tfoot h4, tfoot h5, tfoot p {margin-left: 9px; margin-right: 9px;}';
css += '.working {opacity: 0.6;}';
css += '.gclh_counter.gclh_running {display: block;}';
css += '.gclh_counter {display: none; cursor: default;}';
appendCssStyle(css);
}
// Prepare create PQ(s).
function prepareCreatePQ() {
var urls_for_pqs_to_create = [];
var current_table = $(this).closest('table');
// Determine number of PQs and number of digits for the ongoing digit prefix.
var nPQs = 0;
$(current_table).find('tr').each(function() {
if ($(this).context.rowIndex > 0 && $(this).children().eq(1).text() != "") {
nPQs++;
}
});
var nDigits = parseInt((nPQs + '').length);
// Build urls.
$(current_table).find('tr').each(function() {
if ($(this).context.rowIndex > 0 && $(this).children().eq(1).text() != "") {
var [start_month, start_day, start_year] = getDateParts($(this).children().eq(1).text());
var [end_month, end_day, end_year] = getDateParts($(this).children().eq(2).text());
var cache_count = parseInt($(current_table).find('.pq_name').attr('cache_count'));
var pq_name = $(current_table).find('.pq_name').val() + $(this).context.rowIndex.toString(10).padStart(nDigits, '0');
var how_often = $(current_table).find('.how_often:checked').attr('index');
var email = $(current_table).find('.output_email').val();
var param = {PQSplit: 1, n: pq_name, c: cache_count, ho: how_often, e: email, sm: start_month, sd: start_day, sy: start_year, em: end_month, ed: end_day, ey: end_year};
var sel = getSelection();
var new_url = "https://www.geocaching.com/pocket/gcquery.aspx?" + $.param(param) + '&' + $.param(sel);
urls_for_pqs_to_create.push(new_url);
}
});
// Process error or rather create PQs.
if (checkEndErrorAvailable(urls_for_pqs_to_create)) {
setRunSettings(false);
return false;
} else {
setRunSettings(true);
$(current_table).find('.gclh_counter_total')[0].innerHTML = urls_for_pqs_to_create.length;
$(current_table).find('.gclh_counter').addClass('gclh_running');
create_pqs(urls_for_pqs_to_create, true);
}
}
// Check whether select errors are available.
function checkSelectErrorAvailable() {
// There are restrictions for difficulty and terrain. Not all combinations can be specified on the PQ page.
function checkDT(name) {
var error = '';
var n = 0;
var first = false;
var last = false;
var next = '';
var all = '';
$('#' + name + 'select option[selected=""]').each(function() {
var content = $(this).val();
if (!first || content < first) first = content;
if (!last || content > last) last = content;
if (next == '' || next == parseInt(content.replace(/(\.|,)/, ''))) {
next = parseInt(content.replace(/(\.|,)/, '')) + 5;
} else if (!next) {
} else {
next = false;
}
all += (n == 0 ? '' : '/') + content;
n++;
});
if (n <= 1 || (n > 1 && first == '1.0' && next) || (n > 1 && last == '5.0' && next)) {
} else {
error = "Your " + name + " specifications " + all + " can not be specified on the PQ page. ";
}
return error;
}
return checkDT('difficulty') + checkDT('terrain');
}
// Get selection parameter.
function getSelection() {
var sel = new Object();
$('#filtertoggle2div > div:not(.row) select, #filtertoggle2div > div:not(.row) input').each(function() {
if ($(this).val() != null && $(this).val() != '') {
var name = $(this).attr('name').replace(/(\[|\])/g, '');
if ($(this).attr('multiple')) {
for (var i = 0; i < $(this).val().length; i++) {
sel[name+"["+i+"]"] = $(this).val()[i];
}
} else if ($(this)[0].id.match(/hidden_to(yyyy|mm|dd)/)) {
sel[name] = $(this).val();
} else if ($(this)[0].type == 'checkbox' && $(this)[0].checked) {
sel[name] = $(this).val();
} else if ($(this)[0].type == 'text' && $(this).val() != '') {
sel[name] = $(this).val();
}
}
});
return sel;
}
// Create PQ(s).
function create_pqs(urls_for_pqs_to_create, first_run) {
// Cleanup last run, if there is one.
if (first_run) {
if (typeof global_open_popups !== 'undefined' && global_open_popups != null && Array.isArray(global_open_popups)) {
for (var i = 0; i < global_open_popups.length; i++) {
if (typeof global_open_popups[i] !== 'undefined' && global_open_popups[i] != null && global_open_popups[i] !== false) {
global_open_popups[i].close();
}
}
}
global_open_popups = new Array(urls_for_pqs_to_create.length);
global_open_popup_count = 0;
$('.gclh_running .gclh_counter_total').innerHTML = urls_for_pqs_to_create.length;
}
// Handle pop-ups.
var already_done_count = 0;
for (var i = 0; i < urls_for_pqs_to_create.length; i++) {
if (urls_for_pqs_to_create[i] != '') {
if (global_open_popup_count < 5) {
global_open_popups[i] = window.open(urls_for_pqs_to_create[i], 'PQ_' + i, 'scrollbars=1, menubar=0, resizable=1, width=400, height=250, top=0, left=10000');
$('.gclh_running .gclh_counter_started').innerHTML = $('.gclh_running .gclh_counter_started').innerHTML + 1;
// A pop-up could not be opened in browser, probably because of a pop-up blocker, so we'll stop here and inform the user.
if (global_open_popups[i] == null) {
setRunSettings(false);
alert("A pop-up blocker was detected. Please allow pop-ups for this site, reload the page and try again. Please be aware, that the first two PQs should already be created. So please go to geocaching.com and delete them.");
return false;
}
global_open_popup_count++;
urls_for_pqs_to_create[i] = '';
$('.gclh_running .gclh_counter_started')[0].innerHTML = parseInt($('.gclh_running .gclh_counter_started')[0].innerHTML) + 1;
}
} else {
already_done_count++;
}
if (typeof global_open_popups[i] !== 'undefined' && global_open_popups[i] !== false && global_open_popups[i].closed) {
global_open_popup_count--;
global_open_popups[i] = false;
$('.gclh_running .gclh_counter_completed')[0].innerHTML = parseInt($('.gclh_running .gclh_counter_completed')[0].innerHTML) + 1;
}
}
// Restart creating of PQs until everything is finished.
if (already_done_count < urls_for_pqs_to_create.length || global_open_popup_count > 0) {
setTimeout(function(){create_pqs(urls_for_pqs_to_create, false);}, 250);
} else {
setRunSettings(false);
alert("The GC little helper II is done creating your " + already_done_count + " PQ(s).");
}
}
// Set or stop the running environment.
function setRunSettings(set) {
if (set) {
$('.gclh_running').removeClass('gclh_running');
$('.gclh_counter span').each(function(){this.innerHTML = 0;});
$('.button_create_pq').prop("disabled", true);
$('.button_create_pq').addClass('working');
} else {
$('.button_create_pq').prop("disabled", false);
$('.button_create_pq').removeClass('working');
}
}
// Check whether errors during the identification of the language related month names or the length of the URLs are available.
function checkEndErrorAvailable(urls) {
var err = '';
if (global_error) {
err += "One or more of the determined, month name and language related, start and end dates are failed. Please select another language, such as English or German, at the top right of the page and try again.\n";
}
for (var i = 0; i < urls.length; i++) {
if (urls[i].length > 2000) {
err += "One or more of the determined URLs to calling geocaching.com and creating PQ(s) are too long. You are using too many filters. Please reduce the filters and try again.\n";
break;
}
}
if (err != '') {
alert(err);
return true;
} else return false;
}
// Get user language of the page.
function getLanguage() {
if ($('ul.navbar-right .drowdown-toggle img[src*="country_flags"]')[0]) {
var match = $('ul.navbar-right .drowdown-toggle img[src*="country_flags"]')[0].src.match(/country_flags(2\/png|_manual)\/(.*)\./);
if (match && match[1] && match[2]) {
lang = match[2].replace(/catalonia/, 'es').toUpperCase();
if ($('#menu_locales a[href*="_' + lang + '"]')[0]) {
var match = $('#menu_locales a[href*="_' + lang + '"]')[0].href.match(/#(.{2})/);
if (match && match[1]) {
return match[1];
}
}
}
}
return false;
}
// Break down the date string and return its components.
function getDateParts(str) {
if (str.indexOf("/") == -1) return ['', '', ''];
var arr = str.split('/');
var m = convertMonthNameToNumber(lang, arr[0]);
var d = parseInt(arr[1]);
var y = parseInt(arr[2]);
return [m, d, y];
}
// Convert the name of a month with a given language to the month number.
function convertMonthNameToNumber(lang, name) {
var name_l = name.toLowerCase();
for (var nr = 1; nr <= 12; nr++) {
var [month, month_l] = convertMonthNumberToName(lang, nr);
if (name == month || name_l == month_l) return nr;
}
global_error = true;
return false;
}
// Convert the number of a month to the month name with a given language.
function convertMonthNumberToName(lang, nr) {
if (new Intl.DateTimeFormat(lang, {month:'long'}).format(new Date(nr + '/1/2000'))) {
var month = new Intl.DateTimeFormat(lang, {month:'long'}).format(new Date(nr + '/1/2000'));
} else {
var month = false;
}
var month_l = month.toLowerCase();
return [month, month_l];
}
}; // End of mainPGC.
///////////////////////////
// 4. Openstreetmap ($$cap)
///////////////////////////
var mainOSM = function() {
try {
// Add link to GC Map on Openstreetmap.
function addGCButton(waitCount) {
if (document.location.href.match(/^https?:\/\/www\.openstreetmap\.org\/(.*)#map=/) && $(".control-key").length) {
if (settings_add_link_new_gc_map_on_osm) {
var code = '
';
html = html.replace(/{uniqueServiceId}/g,uniqueServiceId);
// Add map service link to the right sidebar.
var htmlSidebar = html.replace('{linkText}', service_configuration.sidebar.linkText);
htmlSidebar = htmlSidebar.replace('{customclasses}', ( service_configuration.sidebar.icon )?uniqueServiceId+'-sidebar-icon':'');
$('.CacheDetailNavigation ul').first().append('
'+htmlSidebar+'
');
// Add map service link under waypoint table.
var tbl = getWaypointTable();
if (tbl.length > 0) {
var htmlWaypointTable = html.replace('{linkText}', service_configuration.waypointtable.linkText);
htmlWaypointTable = htmlWaypointTable.replace('{customclasses}',( service_configuration.waypointtable.icon )?uniqueServiceId+'-waypointable-icon':'');
tbl.next("p").append(' '+htmlWaypointTable);
}
function check_wpdata_mapservice(waitCount, uniqueServiceId) {
if (check_wpdata_evaluable()) {
$('.mapservice_click-'+uniqueServiceId).removeClass('working');
$('.mapservice_click-'+uniqueServiceId).each(function(){
var parent = $(this)[0].parentNode;
$(parent).find('.GClhdropdown-content').removeClass('working');
});
$('.mapservice_click-'+uniqueServiceId).click(function() {
service_configuration.action( this, service_configuration );
});
} else {waitCount++; if (waitCount <= 100) setTimeout(function(){check_wpdata_mapservice(waitCount, uniqueServiceId);}, 100);}
}
check_wpdata_mapservice(0, uniqueServiceId);
}
function mapservice_open( thisObject, service_configuration ) {
var waypoints = queryListingWaypoints(true);
if (service_configuration.useHomeCoords == true) {
var homeCoords = {
name: 'Home coordinates',
gccode: $('#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoCode')[0].innerHTML,
prefix: "",
source: "GClh II Config",
typeid: '',
latitude: (getValue("home_lat") / 10000000),
longitude: (getValue("home_lng") / 10000000),
prefixedName: $('#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoCode')[0].innerHTML,
};
waypoints.unshift(homeCoords); // Vorne anfügen.
}
if (!service_configuration.runWithOneWaypoint && waypoints.length == 1) {
waypoints.push(waypoints[0]);
}
var map = $(thisObject).data('map');
var data = {
urlTemplate: service_configuration.urlTemplate,
map: map,
maxZoomLevel: service_configuration.layers[map].maxZoom,
waypoints: waypoints,
waypointSeparator: service_configuration.waypointSeparator,
waypointFunction: service_configuration.waypointFunction,
context: service_configuration.context,
mapOffset: service_configuration.mapOffset,
useHomeCoords: service_configuration.useHomeCoords,
runWithOneWaypoint: service_configuration.runWithOneWaypoint
};
var url = data.urlTemplate;
var waypointString = "";
var boundarybox = undefined;
if ( data.context == undefined ) data.context = {};
if ( data.temp == undefined ) data.context.temp = {};
data.context.temp.count = 0;
for (var i=0; i service_configuration.maxUrlLength ) {
alert("Pay attention the URL is very long ("+url.length+" characters). Data loss is possible.");
}
window.open(url);
}
function BoundaryBox( boundarybox, latitude, longitude ) {
boundarybox = boundarybox == undefined ? { Latmax : -90.0, Latmin : 90.0, Lonmax : -180.0, Lonmin : 180.0, center : { latitude : 0.0, longitude : 0.0 } } : boundarybox;
boundarybox.Latmax = Math.max(boundarybox.Latmax, latitude);
boundarybox.Latmin = Math.min(boundarybox.Latmin, latitude);
boundarybox.Lonmax = Math.max(boundarybox.Lonmax, longitude);
boundarybox.Lonmin = Math.min(boundarybox.Lonmin, longitude);
boundarybox.center.latitude = ((boundarybox.Latmax+90.0)+(boundarybox.Latmin+90.0))/2-90.0;
boundarybox.center.longitude = ((boundarybox.Lonmax+180.0)+(boundarybox.Lonmin+180.0))/2-180.0;
return boundarybox;
}
function TileMapZoomLevelForBoundaryBox( boundarybox, widthOffset, heightOffset, maxZoom ) {
var browserZoomLevel = window.devicePixelRatio;
var mapWidth = Math.round(window.innerWidth*browserZoomLevel)+widthOffset;
var mapHeigth = Math.round(window.innerHeight*browserZoomLevel)+heightOffset;
var zoom=-1;
for (zoom=23; zoom>=0; zoom--) {
// Calculate tile boundary box.
var tileY_min = lat2tile(boundarybox.Latmin,zoom);
var tileY_max = lat2tile(boundarybox.Latmax,zoom);
var tiles_Y = Math.abs(tileY_min-tileY_max+1); // boundary box heigth in number of tiles
var tileX_min = long2tile(boundarybox.Lonmin,zoom);
var tileX_max = long2tile(boundarybox.Lonmax,zoom);
var tiles_X = Math.abs(tileX_max-tileX_min+1); // boundary box width in number of tiles
// Calculate width and height of boundary rectangle (in pixel).
var latDelta = Math.abs(tile2lat(tileY_max,zoom)-tile2lat(tileY_min+1,zoom));
var latPixelPerDegree = tiles_Y*256/latDelta;
var boundaryHeight = latPixelPerDegree*Math.abs(boundarybox.Latmax-boundarybox.Latmin);
var longDelta = Math.abs(tile2long(tileX_max+1,zoom)-tile2long(tileX_min,zoom));
var longPixelPerDegree = tiles_X*256/longDelta;
var boundaryWidth = longPixelPerDegree*Math.abs(boundarybox.Lonmax-boundarybox.Lonmin);
if ( ((boundaryHeight < mapHeigth) && (boundaryWidth < mapWidth)) && zoom<=maxZoom ) break;
}
return zoom;
}
function normalizeName( name ) {return name.replace(/[^a-zA-Z0-9_\-]/g,'_');}
function floppsMapWaypoint(waypoint, name, radius, context) {
var id = "";
if (waypoint.source == "waypoint") {
id = String.fromCharCode(65+Math.floor(context.temp.count%26))+Math.floor(context.temp.count/26+1); // create Flopp's Map id: A1, B1, C1, ..., Z1, A2, B2, C3, ..
} else if (waypoint.source == "original" ) {
id = "O";
} else if (waypoint.source == "listing" ) {
id = "L";
}
return id+':'+roundTO(waypoint.latitude,LatLonDigits)+':'+roundTO(waypoint.longitude,LatLonDigits)+':'+radius+':'+name;
}
function gpsvisualizerWaypoint(waypoint, name, radius, context) {
var symbol = ( settings_show_gpsvisualizer_gcsymbols && waypoint.typeid in urlPinIcons ) ? urlPinIcons[waypoint.typeid] : "";
var type = ( settings_show_gpsvisualizer_typedesc && waypoint.typeid in waypointNames ) ? waypointNames[waypoint.typeid] : "";
return name+","+roundTO(waypoint.latitude,LatLonDigits)+','+roundTO(waypoint.longitude,LatLonDigits)+','+radius+"m,"+type+","+symbol;
}
function brouterWaypoint(waypoint, name, radius, context) {
var value = "";
if (waypoint.source == "waypoint" || waypoint.source == "listing") {
value = roundTO(waypoint.longitude,LatLonDigits)+','+roundTO(waypoint.latitude,LatLonDigits);
} else if (waypoint.source == "original" ) {
value = "";
}
return value;
}
function openrouteserviceWaypoint(waypoint, name, radius, context) {
return roundTO(waypoint.latitude,LatLonDigits)+','+roundTO(waypoint.longitude,LatLonDigits);
}
// CSS for BRouter, Flopp's Map, GPSVisualizer, Openrouteservice and Copy Data links.
if ((settings_show_brouter_link || settings_show_flopps_link || settings_show_gpsvisualizer_link || settings_show_openrouteservice_link || settings_show_copydata_menu) && is_page("cache_listing")) {
css += ".GClhdropbtn {";
css += " white-space: nowrap;";
css += " cursor: pointer;}";
css += ".GClhdropdown {";
css += " position: relative;";
css += " display: inline-block;}";
css += ".GClhdropdown-content {";
css += " display: none;";
css += " position: absolute;";
css += " background-color: #f9f9f9;";
css += " min-width: 202px;";
css += " box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);";
css += " z-index: 1001;}";
css += ".GClhdropdown-content-info {";
css += " color: black;";
css += " background-color: #ffffa5;";
css += " padding: 5px 16px 5px 16px;";
css += " text-decoration: none;";
css += " display: none;}";
css += ".GClhdropdown-content-info:hover {";
css += " background-color: #ffffa5;";
css += " cursor: default;}";
css += ".GClhdropdown:hover .GClhdropdown-content.working {";
css += " display: none;}";
css += ".GClhdropdown:hover .GClhdropdown-content {";
css += " display: block;}";
appendCssStyle(css);
// Show links which open Flopp's Map with all waypoints of a cache.
if (settings_show_flopps_link) {
try {
mapservice_link( {
uniqueServiceId: "flopps",
urlTemplate: 'https://flopp.net/?c={center_latitude}:{center_longitude}&z={zoom}&t={map}&d=O:L&m={waypoints}',
layers: {'OSM': { maxZoom: 18, displayName: 'Openstreetmap' }, 'OSM/DE': { maxZoom: 18, displayName: 'OSM German Style' }, 'TOPO': { maxZoom: 15, displayName: 'OpenTopMap' }, 'roadmap':{ maxZoom: 20, displayName: 'Google Maps' }, 'hybrid': { maxZoom: 20, displayName: 'Google Maps Hybrid' }, 'terrain':{ maxZoom: 20, displayName: 'Google Maps Terrain' }, 'satellite':{ maxZoom: 20, displayName: 'Google Maps Satellite' }},
waypointSeparator : '*',
waypointFunction : floppsMapWaypoint,
mapOffset : { width: -280, height: -50 },
defaultMap : 'OSM',
sidebar : { linkText : "Show on Flopp\'s Map", icon : true, icondata : global_flopps_map_icon },
waypointtable : { linkText : "Show waypoints on Flopp\'s Map with …", icon : false },
maxUrlLength: 2000,
action: mapservice_open,
context : {},
useHomeCoords: false,
runWithOneWaypoint: true
});
} catch(e) {gclh_error("Show Flopp's Map links",e);}
}
// Show links which open BRouter with all waypoints of a cache.
if (settings_show_brouter_link) {
try {
mapservice_link( {
uniqueServiceId: "brouter",
urlTemplate: 'https://brouter.de/brouter-web/#map={zoom}/{center_latitude}/{center_longitude}/{map}&lonlats={waypoints}',
layers: {'OpenStreetMap': { maxZoom: 18, displayName: 'OpenStreetMap' }, 'OpenStreetMap.de': { maxZoom: 17, displayName: 'OSM German Style' }, 'OpenTopoMap': { maxZoom: 17, displayName: 'OpenTopoMap' }, 'Esri World Imagery': { maxZoom: 18, displayName: 'Esri World Imagery' }},
waypointSeparator : ';',
waypointFunction : brouterWaypoint,
mapOffset : { width: 0, height: 0 },
defaultMap : 'OpenStreetMap',
sidebar : { linkText : "Show on BRouter", icon : true, icondata : global_brouter_icon },
waypointtable : { linkText : "Show route on BRouter with …", icon : false },
maxUrlLength: 4000,
action: mapservice_open,
context : {},
useHomeCoords: false,
runWithOneWaypoint: true
});
} catch(e) {gclh_error("Show button BRouter and open BRouter",e);}
}
// Show links which open GPSVisualizer with all waypoints of a cache.
if (settings_show_gpsvisualizer_link) {
try {
mapservice_link( {
uniqueServiceId: "gpsvisualizer",
urlTemplate: 'https://www.gpsvisualizer.com/map_input?&width=1244&height=700&trk_list=0&wpt_list=desc_border&bg_map={map}&google_zoom_level=auto&google_street_view=1&google_wpt_labels=1&form:data=name,latitude,longitude,circle_radius,desc,symbol\n{waypoints}',
layers: { 'google_map' : { displayName: 'Google street map', maxZoom: 20 }, 'google_satellite' : { displayName: 'Google satellite', maxZoom: 20 }, 'google_hybrid' : { displayName: 'Google hybrid', maxZoom: 20 }, 'google_physical' : { displayName: 'Google terrain', maxZoom: 20 }, 'google_openstreetmap' : { displayName: 'OpenStreetMap', maxZoom: 20 }, 'google_openstreetmap_tf' : { displayName: 'OSM ThunderForest', maxZoom: 20 }, 'google_openstreetmap_komoot' : { displayName: 'OSM Komoot', maxZoom: 20 }, 'google_opencyclemap' : { displayName: 'OpenCycleMap', maxZoom: 20 }, 'google_opentopomap' : { displayName: 'OpenTopoMap', maxZoom: 20 }, 'google_4umaps' : { displayName: 'World topo maps', maxZoom: 20 }},
waypointSeparator : '\n',
waypointFunction : gpsvisualizerWaypoint,
mapOffset : { width: 0, height: 0 },
defaultMap : 'google_map',
sidebar : { linkText : "Show on GPSVisualizer", icon : true, icondata : global_gpsvisualizer_icon },
waypointtable : { linkText : "Show waypoints on GPSVisualizer with …", icon : false },
maxUrlLength: 4000,
action: mapservice_open,
context : {},
useHomeCoords: false,
runWithOneWaypoint: true
});
} catch(e) {gclh_error("Show button GPSVisualizer and open GPSVisualizer",e);}
}
// Show links which open Openrouteservice with all waypoints of a cache.
if (settings_show_openrouteservice_link) {
try {
mapservice_link( {
uniqueServiceId: "openrouteservice",
urlTemplate: 'https://classic-maps.openrouteservice.org/directions?b='+settings_show_openrouteservice_medium+'&c=0&a={waypoints}',
layers: {'': { maxZoom: '', displayName: ''}},
waypointSeparator: ',',
waypointFunction: openrouteserviceWaypoint,
mapOffset: {width: 0, height: 0},
defaultMap: '',
sidebar: {linkText: "Show on Openrouteservice", icon: true, icondata: global_openrouteservice_icon},
waypointtable: {linkText: "Show route on Openrouteservice", icon: false},
maxUrlLength: 4000,
action: mapservice_open,
context: {},
useHomeCoords: settings_show_openrouteservice_home,
runWithOneWaypoint: false
});
} catch(e) {gclh_error("Show button Openrouteservice and open Openrouteservice",e);}
}
// Create 'Copy Data to Clipboard' menu.
if (settings_show_copydata_menu) {
try {
create_copydata_menu();
} catch(e) {gclh_error("Create 'Copy Data to Clipboard' menu",e);}
}
}
// Build map overview.
if (settings_map_overview_build && is_page("cache_listing") && $('#ctl00_ContentBody_detailWidget')[0]) {
try {
leafletInit();
var css = '';
css += '.mapIcons {position: relative; z-index: 1000; margin-top: 10px; margin-right: 10px; float: right; height: 23px; border-radius: 4px; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65); background-color: #fff;}';
css += '.mapIcon {margin-top: 0px; margin-right: 0px; box-shadow: unset;}';
css += '.mapIconLeft {border-radius: 4px 0px 0px 4px;}';
css += '.mapIconRight {border-radius: 0px 4px 4px 0px; border-left: 1px solid #ccc;}';
css += '.mapIcon:hover {background-color: #f4f4f4;}';
css += '.mapIcons svg {width: 18px; height: 18px; color: #4a4a4a; opacity: 0.85; padding: 2px;}';
css += '.mapIconRight svg {padding: 3px;}';
css += '.search_map_icon {margin-left: 2px !important;}';
if (!settings_map_overview_search_map_icon) css += '.browse_map_icon {margin-top: 1px;}';
appendCssStyle(css);
var html = "";
html += "
";
html += "
";
if (settings_map_overview_search_map_icon || settings_map_overview_browse_map_icon) {
if (settings_map_overview_search_map_icon && settings_map_overview_browse_map_icon) var bothIcons = true;
else var bothIcons = false;
html += "";
if (settings_map_overview_browse_map_icon) {
html += "" + browse_map_icon + "";
}
if (settings_map_overview_search_map_icon) {
html += "" + search_map_icon + "";
}
html += "'>";
}
html += "
";
html += "
";
$(".CacheDetailNavigation").after(html);
$(".mapIcons svg").each(function(){$(this)[0].setAttribute("viewBox", "0 0 25 25");});
function build_map_overview(waitCount) {
if (typeof lat !== "undefined" && typeof lng !== "undefined") {
var previewMap = L.map('gclh_map_overview', {
dragging: true,
zoomControl: true,
}).setView([lat, lng],settings_map_overview_zoom);
var layer = ( settings_map_overview_layer == "" || settings_map_overview_layer == "Geocaching" ) ? all_map_layers['OpenStreetMap Default'] : all_map_layers[settings_map_overview_layer];
var layerObj = L.tileLayer( layer.tileUrl, layer ).addTo(previewMap);
// Delayed load of GS map layer (we need an access token).
if ( settings_map_overview_layer == "Geocaching" ) {
gclh_GetGcAccessToken( function(r) {
all_map_layers["Geocaching"].accessToken = r.access_token;
var layer = all_map_layers['Geocaching'];
L.tileLayer( layer.tileUrl, layer ).addTo(previewMap);
previewMap.eachLayer(function (layer) {
if ( layerObj == layer ) previewMap.removeLayer(layer);
});
});
}
// Make buttons of zoom control smaller only for overview map.
$("#gclh_map_overview .leaflet-bar").attr("style","width: 20px; height: 41px; line-height: 40px;");
$("#gclh_map_overview .leaflet-control-zoom-in").attr("style","width: 20px; height: 20px; line-height: 20px; font-size: 11px; padding-right: 1px;");
$("#gclh_map_overview .leaflet-control-zoom-out").attr("style","width: 20px; height: 20px; line-height: 20px; font-size: 11px; padding-right: 1px;");
// Länge der Kartenbezeichnung ... begrenzen.
$("#gclh_map_overview .leaflet-control-attribution").attr("style","max-width: 238px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;");
function build_map_overview_marker(waitCount) {
if (typeof unsafeWindow.mapLatLng !== "undefined" && unsafeWindow.mapLatLng !== null) {
var marker = L.marker([lat, lng],{icon: L.icon({
iconUrl: 'https://www.geocaching.com/images/wpttypes/pins/' + unsafeWindow.mapLatLng.type + '.png',
iconSize: [20, 23],
iconAnchor: [10, 23],
})}).addTo(previewMap);
} else {waitCount++; if (waitCount <= 100) setTimeout(function(){build_map_overview_marker(waitCount);}, 100);}
}
build_map_overview_marker(0);
} else {waitCount++; if (waitCount <= 100) setTimeout(function(){build_map_overview(waitCount);}, 100);}
}
build_map_overview(0);
} catch(e) {gclh_error("Build map overview",e);}
}
// Personal cache note at cache listing.
if (is_page("cache_listing")) {
var css = '';
// Improve cursor when displaying or editing the personal cache note. It's upside down.
css += '#viewCacheNote {cursor: pointer;} #cacheNoteText {cursor: text;}';
// Adapt height of edit field for personal cache note.
$('h3.h4').append($('#pcn_help').remove().get().reverse());
css += '#viewCacheNote {text-decoration: none !important;}';
// Personal cache note: Adapt height of edit field for personal cache note.
function calcHeightOfCacheNote() {
return ($("#viewCacheNote").parent().height()*1.02+36 > settings_cache_notes_min_size ? $("#viewCacheNote").parent().height()*1.02+36 : settings_cache_notes_min_size);
}
if (settings_adapt_height_cache_notes) {
try {
var note = ($('.Note.PersonalCacheNote')[0] || $('.NotesWidget')[0]);
if (note) $("#cacheNoteText").height(calcHeightOfCacheNote());
} catch(e) {gclh_error("Adapt size of edit field for personal cache note",e);}
}
// Change font to monospace.
if (settings_change_font_cache_notes) $("#viewCacheNote, #cacheNoteText").css("font-family", "monospace");
// Hide complete and Show/Hide Cache Note.
try {
var note = ($('.Note.PersonalCacheNote')[0] || $('.NotesWidget')[0]);
if (settings_hide_cache_notes && note) note.remove();
if (settings_hide_empty_cache_notes && !settings_hide_cache_notes && note) {
var desc = decode_innerHTML(note.getElementsByTagName("label")[0]).replace(":", "");
var noteText = $('#viewCacheNote')[0].innerHTML;
var link = document.createElement("font");
link.setAttribute("style", "font-size: 12px;");
link.innerHTML = "Hide "+desc+"";
note.setAttribute("id", "gclh_note");
note.parentNode.insertBefore(link, note);
if (noteText != null && (noteText == "" || noteText == "Click to enter a note" || noteText == "Klicken zum Eingeben einer Notiz" || noteText == "Pro vložení poznámky klikni sem")) {
note.style.display = "none";
if ($('#gclh_hide_note')[0]) $('#gclh_hide_note')[0].innerHTML = 'Show '+desc;
}
var code =
"function gclhHideNote() {" +
" if (document.getElementById('gclh_note').style.display == 'none') {" +
" document.getElementById('gclh_note').style.display = 'block';" +
" if (document.getElementById('gclh_hide_note')) {" +
" document.getElementById('gclh_hide_note').innerHTML = 'Hide "+desc+"'" +
" }" +
" } else {" +
" document.getElementById('gclh_note').style.display = 'none';" +
" if (document.getElementById('gclh_hide_note')) {" +
" document.getElementById('gclh_hide_note').innerHTML = 'Show "+desc+"'" +
" }" +
" }" +
"}";
injectPageScript(code, 'body');
}
} catch(e) {gclh_error("Hide complete and Show/Hide Cache Note",e);}
// Focus Cachenote-Textarea on Click of the Note (to avoid double click to edit).
try {
var editCacheNote = document.querySelector('#editCacheNote');
if (editCacheNote) {
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type == "attributes") {
if (document.getElementById('editCacheNote').style.display == '') {
document.getElementById('cacheNoteText').focus();
} else {
// Take the parent, because empty lines are not handle by span-element #viewCacheNote.
if ($("#cacheNoteText").height() != calcHeightOfCacheNote()) {
$("#cacheNoteText").height(calcHeightOfCacheNote());
}
}
}
});
});
observer.observe(editCacheNote, {attributes: true});
}
} catch(e) {gclh_error("Focus Cachenote-Textarea on Click of the Note",e);}
appendCssStyle(css);
}
// Show eMail and Message Center Link beside user. (Nicht in Cache Logs im Listing, das erfolgt später bei Log-Template.)
show_mail_and_message_icon:
try {
// Cache, TB, Aktiv User Infos ermitteln.
var [global_gc, global_tb, global_code, global_name, global_link, global_activ_username, global_founds, global_date, global_time, global_dateTime] = getGcTbUserInfo();
// Nicht auf Mail, Message Seite ausführen.
if ($('#ctl00_ContentBody_SendMessagePanel1_SendEmailPanel')[0] || $('#messageArea')[0]) break show_mail_and_message_icon;
if ((settings_show_mail || settings_show_message)) {
// Public Profile:
if (is_page("publicProfile")) {
if ($('#lnkSendMessage')[0] || $('#ctl00_ProfileHead_ProfileHeader_lnkSendMessage')[0]) {
var guid = ($('#lnkSendMessage')[0] || $('#ctl00_ProfileHead_ProfileHeader_lnkSendMessage')[0]).href.match(/https?:\/\/www\.geocaching\.com\/account\/messagecenter\?recipientId=([a-zA-Z0-9-]*)/);
guid = guid[1];
if ($('#ctl00_ContentBody_ProfilePanel1_lblMemberName, #ctl00_ProfileHead_ProfileHeader_lblMemberName')[0]) {
var username = decode_innerHTML($('#ctl00_ContentBody_ProfilePanel1_lblMemberName, #ctl00_ProfileHead_ProfileHeader_lblMemberName')[0]);
var side = $('#ctl00_ContentBody_ProfilePanel1_lblMemberName, #ctl00_ProfileHead_ProfileHeader_lblStatusText')[0];
}
buildSendIcons(side, username, "per guid");
}
// Post Cache new log page:
} else if (document.location.href.match(/\.com\/play\/geocache\/gc\w+\/log/)) {
var id = $('.hidden-by a')[0].href.match(/\/profile\/\?id=(\d+)/);
if (id && id[1]) {
var idLink = "/p/default.aspx?id=" + id[1] + "&tab=geocaches";
GM_xmlhttpRequest({
method: "GET",
url: idLink,
onload: function(response) {
if (response.responseText) {
var [username, guid] = getUserGuidFromProfile(response.responseText);
if (username && guid) {
var side = $('.hidden-by a')[0];
buildSendIcons(side, username, "per guid", guid);
}
}
}
});
}
// Rest:
} else {
if (is_page("cache_listing")) var links = $('#divContentMain .span-17, #divContentMain .sidebar').find('a[href*="/profile/?guid="], a[href*="/p/?guid="]');
else var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
if (links[i].href.match(/https?:\/\/www\.geocaching\.com\/(profile|p)\/\?guid=/)) {
// Avatare haben auch mal guid, hier keine Icons erzeugen.
if (links[i].children[0] && (links[i].children[0].tagName == "IMG" || links[i].children[0].tagName == "img")) continue;
var guid = links[i].href.match(/https?:\/\/www\.geocaching\.com\/(profile|p)\/\?guid=([a-zA-Z0-9-]*)/);
guid = guid[2];
var username = decode_innerHTML(links[i]);
buildSendIcons(links[i], username, "per guid");
}
}
}
}
} catch(e) {gclh_error("Show mail and message icon",e);}
// Banner zu neuen Themen entfernen.
if (settings_remove_banner) {
try {
if (settings_remove_banner_for_garminexpress) $('#Content').find('div.banner').find('#uxSendToGarminBannerLink').closest('div.banner').remove();
if (settings_remove_banner_blue) {
if ($('div.banner').length == 1 && $('div.banner').find('div.wrapper a.btn').length == 1) {
var styles = window.getComputedStyle($('div.banner')[0]);
if (styles && (styles.backgroundColor == "rgb(70, 135, 223)" || styles.backgroundColor == "rgb(61, 118, 197)")) $('div.banner').remove();
}
$('#activationAlert').find('div.container').find('a[href*="/my/lists.aspx"]').closest('#activationAlert').remove();
}
} catch(e) {gclh_error("Remove banner",e);}
}
// Improve cache description.
if (is_page("cache_listing")) {
try {
// Activate fancybox for pictures in the description.
function check_for_fancybox(waitCount) {
if (typeof unsafeWindow.$ !== "undefined" && typeof unsafeWindow.$.fancybox !== "undefined") {
unsafeWindow.$('.CachePageImages a[rel="lightbox"]').fancybox();
} else {waitCount++; if (waitCount <= 50) setTimeout(function(){check_for_fancybox(waitCount);}, 200);}
}
check_for_fancybox(0);
// Deactivate external link warning. (Thanks to mustakorppi for the template: https://greasyfork.org/de/scripts/439287)
if (settings_listing_hide_external_link_warning || settings_listing_links_new_tab) {
$('.UserSuppliedContent a').each(function(){
if (settings_listing_hide_external_link_warning) {
$(this)[0].addEventListener("click", function() {
event.stopImmediatePropagation();
}, true);
}
if (settings_listing_links_new_tab) {
$(this).attr('target', '_blank');
}
});
}
} catch(e) {gclh_error("Activate fancybox",e);}
}
// Link to bigger pictures for owner added images.
if (settings_link_big_listing && is_page("cache_listing")) {
try {
var img = $('#ctl00_ContentBody_LongDescription, .CachePageImages').find('img[src*="geocaching.com/cache/large/"]');
var a = $('#ctl00_ContentBody_LongDescription, .CachePageImages').find('a[href*="geocaching.com/cache/large/"]');
for (var i = 0; i < img.length; i++) {img[i].src = img[i].src.replace("/large/", "/");}
for (var i = 0; i < a.length; i++) {a[i].href = a[i].href.replace("/large/", "/");}
} catch(e) {gclh_error("Link to bigger pictures for owner added images",e);}
}
// Decrypt hints.
if (settings_decrypt_hint && !settings_hide_hint && is_page("cache_listing")) {
try {
if ($('#ctl00_ContentBody_EncryptionKey')[0] && $('#ctl00_ContentBody_lnkDH')[0]) {
decrypt_hints(0);
var decryptKey = $('#dk')[0];
if (decryptKey) decryptKey.parentNode.removeChild(decryptKey);
}
} catch(e) {gclh_error("Decrypt hints",e);}
}
// Hide hints.
if (settings_hide_hint && is_page("cache_listing") && $('#dk')[0]) {
try {
// Replace hints by a link which shows the hints dynamically.
decrypt_hints(0, true);
// Remove hint description.
var decryptKey = $('#dk')[0];
if (decryptKey) decryptKey.parentNode.removeChild(decryptKey);
} catch(e) {gclh_error("Hide hints",e);}
}
function decrypt_hints(waitCount, hideHints) {
$('#ctl00_ContentBody_lnkDH').click();
if ($('#ctl00_ContentBody_lnkDH')[0].getAttribute('title') != 'Decrypt') {
if (hideHints) hide_hints();
} else {waitCount++; if (waitCount <= 50) setTimeout(function(){decrypt_hints(waitCount, hideHints);}, 200);}
}
function hide_hints() {
var hint = $('#div_hint')[0];
var label = $('#ctl00_ContentBody_hints strong')[0];
if (hint && label && trim(hint.innerHTML).length > 0) {
var code =
"function hide_hint() {" +
" var hint = document.getElementById('div_hint');" +
" if (hint.style.display == 'none') {" +
" hint.style.display = 'block';" +
" if (document.getElementById('ctl00_ContentBody_lnkDH')) {" +
" document.getElementById('ctl00_ContentBody_lnkDH').innerHTML = 'Hide'" +
" }" +
" } else {" +
" hint.style.display = 'none';" +
" if (document.getElementById('ctl00_ContentBody_lnkDH')) {" +
" document.getElementById('ctl00_ContentBody_lnkDH').innerHTML = 'Show'" +
" }" +
" }" +
" hint.innerHTML = convertROTStringWithBrackets(hint.innerHTML);" +
" return false;" +
"}";
injectPageScript(code, 'body');
if ($('#ctl00_ContentBody_lnkDH')[0]) {
var link = $('#ctl00_ContentBody_lnkDH')[0];
link.setAttribute('onclick', 'hide_hint();');
link.setAttribute('title', 'Show/Hide ' + decode_innerHTML(label));
link.setAttribute('href', 'javascript:void(0);');
link.setAttribute('style', 'font-size: 12px;');
link.innerHTML = 'Show';
}
hint.style.marginBottom = '1.5em';
hint.style.display = 'none';
}
}
// Improve inventory list in cache listing.
if (is_page("cache_listing")) {
try {
// Trackable Namen kürzen, damit nicht umgebrochen wird, und Title setzen.
var inventory = $('#ctl00_ContentBody_uxTravelBugList_uxInventoryLabel').closest('.CacheDetailNavigationWidget').find('.WidgetBody span');
for (var i = 0; i < inventory.length; i++) {noBreakInLine(inventory[i], 201, inventory[i].innerHTML);}
} catch(e) {gclh_error("Improve inventory list",e);}
}
// Replace link to larger map in preview map in cache listing with the Browse Map.
if (settings_larger_map_as_browse_map && is_page("cache_listing") && $('#uxLatLon')[0]) {
try {
var newstrPROStyle = 'View Larger Browse Map';
document.getElementById('ctl00_ContentBody_uxViewLargerMap').outerHTML = newstrPROStyle;
} catch(e) {gclh_error("Replace link to larger map in preview map in cache listing with the Browse Map",e);}
}
// Show Google-Maps Link on Cache Listing Page.
if (settings_show_google_maps && is_page("cache_listing") && $('#ctl00_ContentBody_uxViewLargerMap')[0] && $('#uxLatLon')[0] && $('#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoCode')[0]) {
try {
var ref_link = $('#ctl00_ContentBody_uxViewLargerMap')[0];
var box = ref_link.parentNode;
box.appendChild(document.createElement("br"));
var link = document.createElement("a");
link.setAttribute("class", "lnk");
link.setAttribute("target", "_blank");
link.setAttribute("title", "Show area on Google Maps");
var coords = toDec($('#uxLatLon')[0].innerHTML);
var latlng = coords[0] + "," + coords[1];
// &ll sorgt für Zentrierung der Seite beim Marker auch wenn linke Sidebar aufklappt. Zoom 18 setzen, weil GC Map eigentlich nicht mehr kann.
link.setAttribute("href", "https://maps.google.de/maps?q=" + latlng + "&ll=" + latlng + "&z=18");
var img = document.createElement("img");
img.setAttribute("src", "/images/silk/map_go.png");
link.appendChild(img);
link.appendChild(document.createTextNode(" "));
var span = document.createElement("span");
span.appendChild(document.createTextNode("Show area on Google Maps"));
link.appendChild(span);
box.appendChild(link);
} catch(e) {gclh_error("Show google maps link",e);}
}
// Hide spoilerwarning above the logs.
if (settings_hide_spoilerwarning && is_page("cache_listing")) {
try {
if ($('.InformationWidget .NoBottomSpacing a[href*="/glossary.aspx#spoiler"]')[0]) {
var sp = $('.InformationWidget .NoBottomSpacing a[href*="/glossary.aspx#spoiler"]')[0].closest('p');
if (sp) {
sp.innerHTML = " ";
sp.style.height = "0";
sp.className += " Clear";
}
}
} catch(e) {gclh_error("Hide spoilerwarning",e);}
}
// Hide warning message.
if (settings_hide_warning_message) {
if ($('.WarningMessage')[0]) {
try {
var content = '"' + $('.WarningMessage')[0].innerHTML + '"';
if (content == getValue("warningMessageContent")) {
warnMessagePrepareMouseEvents();
} else {
// Button in Warnmeldung aufbauen, um Meldung erstes Mal zu verbergen.
var div = document.createElement("div");
div.setAttribute("class", "GoAwayWarningMessage");
div.setAttribute("title", "Go away message");
div.setAttribute("style", "float: right; width: 70px; color: rgb(255, 255, 255); box-sizing: border-box; border: 2px solid rgb(255, 255, 255); opacity: 0.7; cursor: pointer; border-radius: 3px; margin-right: 2px; margin-top: 2px; text-align: center;");
div.appendChild(document.createTextNode("Go away"));
div.addEventListener("click", warnMessageHideAndSave, false);
$('.WarningMessage')[0].parentNode.insertBefore(div, $('.WarningMessage')[0]);
}
} catch(e) {gclh_error("Hide warning message",e);}
}
}
// Warnmeldung verbergen und Inhalt sichern.
function warnMessageHideAndSave() {
$('.WarningMessage').fadeOut(1000, "linear");
var content = '"' + $('.WarningMessage')[0].innerHTML + '"';
setValue("warningMessageContent", content);
$('.GoAwayWarningMessage')[0].style.display = "none";
warnMessagePrepareMouseEvents();
}
// Mouse Events vorbereiten für show/hide Warnmeldung.
function warnMessagePrepareMouseEvents() {
// Balken im rechten Headerbereich zur Aktivierung der Warnmeldung.
var divShow = document.createElement("div");
divShow.setAttribute("class", "ShowWarningMessage");
divShow.setAttribute("style", "z-index: 1004; float: right; right: 0px; width: 6px; background-color: rgb(224, 183, 10); height: 65px; position: absolute;");
$('.WarningMessage')[0].parentNode.insertBefore(divShow, $('.WarningMessage')[0]);
// Bereich für Mouseout Event, um Warnmeldung zu verbergen. Notwendig, weil eigentliche Warnmeldung nicht durchgängig da und zukünftiges Aussehen unklar.
var divHide = document.createElement("div");
divHide.setAttribute("class", "HideWarningMessage");
divHide.setAttribute("style", "z-index: 1004; height: 110px; position: absolute; right: 0px; left: 0px;");
$('.WarningMessage')[0].parentNode.insertBefore(divHide, $('.WarningMessage')[0]);
warnMessageMouseOut();
}
// Show Warnmeldung.
function warnMessageMouseOver() {
$('.ShowWarningMessage')[0].style.display = "none";
$('.WarningMessage')[0].style.display = "";
$('.HideWarningMessage')[0].style.display = "";
$('.HideWarningMessage')[0].addEventListener("mouseout", warnMessageMouseOut, false);
}
// Hide Warnmeldung.
function warnMessageMouseOut() {
$('.WarningMessage')[0].style.display = "none";
$('.HideWarningMessage')[0].style.display = "none";
$('.ShowWarningMessage')[0].style.display = "";
$('.ShowWarningMessage')[0].addEventListener("mouseover", warnMessageMouseOver, false);
}
// Driving direction for every waypoint.
if (settings_driving_direction_link && (is_page("cache_listing") || document.location.href.match(/\.com\/hide\/wptlist.aspx/))) {
try {
var tbl = getWaypointTable();
var length = tbl.find("tbody > tr").length;
for (var i=0; i tr").eq(i*2);
var name = row1st.find("td:eq(4)").text().trim();
var icon = row1st.find("td:eq(1) > img").attr('src');
var cellCoordinates = row1st.find("td:eq(5)");
var tmp_coords = toDec(cellCoordinates.text().trim());
if ((!settings_driving_direction_parking_area || icon.match(/pkg.jpg/g)) && typeof tmp_coords[0] !== 'undefined' && typeof tmp_coords[1] !== 'undefined') {
if (getValue("home_lat", 0) != 0 && getValue("home_lng") != 0) {
var link = "https://maps.google.com/maps?f=d&hl=en&saddr="+getValue("home_lat", 0)/10000000+","+getValue("home_lng", 0)/10000000+"%20(Home%20Location)&daddr=";
row1st.find("td:last").append('');
} else {
var link = document.location + "gclhpb#errhomecoord";
row1st.find("td:last").append('');
}
}
}
} catch(e) {gclh_error("Driving direction for Waypoints",e);}
}
// Added elevation to every additional waypoint with shown coordinates.
if (settings_show_elevation_of_waypoints && ((is_page("cache_listing") && !isMemberInPmoCache()) || is_page("map") || is_page("searchmap") )) {
try {
function formatElevation(elevation) {
return ((elevation>0)?"+":"")+((settings_distance_units != "Imperial")?(Math.round(elevation) + "m"):(Math.round(elevation*3.28084) + "ft"));
}
elevationServicesData[1]['function'] = addElevationToWaypoints_GoogleElevation;
elevationServicesData[2]['function'] = addElevationToWaypoints_OpenElevation;
elevationServicesData[3]['function'] = addElevationToWaypoints_GeonamesElevation;
function addElevationToWaypoints_GoogleElevation(responseDetails) {
try {
context = responseDetails.context;
json = JSON.parse(responseDetails.responseText);
if ( json.status != "OK") {
var mess = "\naddElevationToWaypoints_GoogleElevation():\n- Get elevations: retries: "+context.retries+"\n- json-status: "+json.status+"\n- json.error_message: "+json.error_message;
gclh_log(mess);
getElevations(context.retries+1,context.locations);
return;
}
var elevations = [];
for (var i=0; i/)) {
if (responseDetails.responseText.match(/Service Unavailable/)) {
gclh_log("\naddElevationToWaypoints_GeonamesElevation():\n- Info: Service Unavailable\n- url: "+responseDetails.finalUrl);
} else {
gclh_log("\naddElevationToWaypoints_GeonamesElevation():\n- Error:\n"+responseDetails.responseText+"\n- url: "+responseDetails.finalUrl);
}
getElevations(context.retries+1,context.locations);
return;
} else {
json = JSON.parse(responseDetails.responseText);
var elevations = [];
for (var i=0; i Elevation: ');
// Prepare cache listing - waypoint table.
var tbl = getWaypointTable();
if (tbl.length > 0) {
tbl.find("thead > tr > th:eq(5)").after('
Elevation
');
var length = tbl.find("tbody > tr").length;
for (var i=0; i tr:eq("+(i*2+1)+") > td:eq(1)");
var colspan = cellNote.attr('colspan');
cellNote.attr('colspan',colspan+1);
var row1st = tbl.find("tbody > tr").eq(i*2);
var cellPrefix = row1st.find("td:eq(2)").text().trim();
classAttribute = "waypoint-elevation-na";
idAttribute = "";
for ( var j=0; j');
}
}
return locations;
}
var elevationServices = [];
if (settings_primary_elevation_service > 0) {
elevationServices.push(elevationServicesData[settings_primary_elevation_service]);
}
if (settings_secondary_elevation_service > 0) {
elevationServices.push(elevationServicesData[settings_secondary_elevation_service]);
}
// This function can be re-entered.
function getElevations(serviceIndex,locations) {
if (serviceIndex >= elevationServices.length || elevationServices < 0) {
$('.waypoint-elevation').each(function (index, value) {
$(this).html('???');
});
return;
}
$('.waypoint-elevation').each(function (index, value) {
$(this).html('');
});
$('.waypoint-elevation-na').each(function (index, value) {
$(this).html('n/a');
});
var additionalListingIndex = 0;
if (elevationServices[serviceIndex].name == "Geonames-Elevation") {
var maxLocations = 20;
var countLocations = 0;
var lats = "";
var lngs = "";
for (var i=0; i 0 ) getElevations(0,locations);
} else {waitCount++; if (waitCount <= 100) setTimeout(function(){check_wpdata_elevation(waitCount);}, 100);}
}
check_wpdata_elevation(0);
}
} catch(e) {gclh_error("Add elevation",e);}
}
// Change new links for find caches to the old links.
if (is_page("cache_listing") && settings_listing_old_links) {
try {
var links = $('#ctl00_ContentBody_bottomSection a[href*="/play/search?"]');
for (var i = 0; i < links.length; i++) {
// Other caches hidden by this user.
var match = links[i].href.match(/\/play\/search\?owner\[0\]=(.*?)&.*/);
if (match && match[1]) {links[i].href = "/seek/nearest.aspx?u="+urlencode(urldecode(match[1])); continue;}
// Other caches found by this user.
var match = links[i].href.match(/\/play\/search\?fb=(.*?)&.*/);
if (match && match[1]) {links[i].href = "/seek/nearest.aspx?ul="+urlencode(urldecode(match[1])); continue;}
// Nearby caches of this type, that I haven't found.
var match = links[i].href.match(/\/play\/search\?types=(.*?)&origin=(.*?),(.*?)&f=2&o=2/);
if (match && match[1] && match[2] && match[3]) {links[i].href = "/seek/nearest.aspx?lat="+match[2]+"&lng="+match[3]+"&ex=1"+getCacheTx(match[1]); continue;}
// Nearby caches of this type.
var match = links[i].href.match(/\/play\/search\?types=(.*?)&origin=(.*?),(.*?)(&|$)/);
if (match && match[1] && match[2] && match[3]) {links[i].href = "/seek/nearest.aspx?lat="+match[2]+"&lng="+match[3]+getCacheTx(match[1]); continue;}
// All nearby caches, that I haven't found.
var match = links[i].href.match(/\/play\/search\?origin=(.*?),(.*?)&f=2&o=2/);
if (match && match[1] && match[2]) {links[i].href = "/seek/nearest.aspx?lat="+match[1]+"&lng="+match[2]+"&ex=1"; continue;}
// All nearby caches.
var match = links[i].href.match(/\/play\/search\?origin=(.*?),(.*?)(&|$)/);
if (match && match[1] && match[2]) {links[i].href = "/seek/nearest.aspx?lat="+match[1]+"&lng="+match[2]; continue;}
}
} catch(e) {gclh_error("Change new links for find caches to the old links",e);}
}
// Set language in Driving Directions links for the cache coordinates and the waypoints.
if (is_page("cache_listing") && $('#ctl00_ContentBody_lnkPrintDirectionsSimple')[0]) {
$('#ctl00_ContentBody_lnkPrintDirectionsSimple')[0].href = $('#ctl00_ContentBody_lnkPrintDirectionsSimple')[0].href.replace('http://', 'https://');
$('a[href*="https://maps.google.com/maps?f=d&hl=en&saddr="]').each((_i, elem) => {
elem.href = elem.href.replace('&hl=en', '');
});
}
// Hide greenToTopButton.
if (settings_hide_top_button) $("#topScroll").attr("id", "_topScroll").hide();
// Show additional cache info in old log page.
if (document.location.href.match(/\.com\/seek\/log\.aspx\?(ID|wp|PLogGuid)\=/) && settings_show_add_cache_info_in_log_page && $('.PostLogList > dd:nth-child(2)')[0]) {
try {
$('.PostLogList > dd:nth-child(2)')[0].append(createAreaACI());
buildContentACI($('#ctl00_ContentBody_LogBookPanel1_WaypointLink')[0].nextSibling.href);
buildCssACI();
} catch(e) {gclh_error("Show additional cache info in old log page",e);}
}
// Show additional cache info in new log page.
if (document.location.href.match(/\.com\/play\/geocache\/gc\w+\/log/) && settings_show_add_cache_info_in_log_page) {
try {
function waitForNewLogPageForACI(waitCount) {
if ($('#logType .log-subheading')[0]) {
$('#logType .log-subheading')[0].after(createAreaACI());
buildContentACI($('#logType .log-subheading')[0].href);
buildCssACI();
} else {waitCount++; if (waitCount <= 100) setTimeout(function(){waitForNewLogPageForACI(waitCount);}, 100);}
}
waitForNewLogPageForACI(0);
} catch(e) {gclh_error("Show additional cache info in new log page",e);}
}
function buildCssACI(css) {
if (!css) var css = '';
css += '#aci {margin-left: 20px; margin-right: 2px; cursor: default; float: right;} ';
css += '#aci svg {vertical-align: text-bottom;} ';
css += '#aci img {vertical-align: sub;} ';
appendCssStyle(css);
}
function createAreaACI() {
var span = document.createElement('span');
span.id = 'aci';
return span;
}
function buildContentACI(url) {
$.get(url, null, function(text){
var aci = '';
// Favorite points and favorite percent.
var favoritePoints = $(text).find('.favorite-value').html();
if (favoritePoints) {
favoritePoints = favoritePoints.replace('.','').replace(',','');
favoritePoints = parseInt(favoritePoints);
var from = text.indexOf('userToken', text.indexOf('MapTilesEnvironment')) + 13;
var length = text.indexOf("';", from) - from;
var userTokenACI = text.substr(from, length);
aci += separator(aci) + '';
aci += '';
aci += ' ' + favoritePoints + '';
aci += '';
aci += '';
}
// Watcher.
var watchNumber = $(text).find('#watchlistLinkMount');
if (watchNumber[0]) {
watchNumber = watchNumber[0].getAttribute("data-watchcount");
aci += separator(aci) + '';
aci += '';
aci += ' ' + watchNumber + '';
aci += '';
}
// Output and further load.
if (aci != '') {
$('#aci')[0].innerHTML = aci;
if (favoritePoints) getFavoritePercent(userTokenACI, $('.favorite_percent')[0]);
}
});
}
// Show Smilies und Log Templates old log page.
if ((document.location.href.match(/\.com\/seek\/log\.aspx\?(id|guid|ID|wp|LUID|PLogGuid|code)\=/) || document.location.href.match(/\.com\/track\/log\.aspx\?(id|wid|guid|ID|LUID|PLogGuid|code)\=/)) &&
$('#litDescrCharCount')[0] && $('#ctl00_ContentBody_LogBookPanel1_WaypointLink')[0] && $('#ctl00_ContentBody_LogBookPanel1_uxLogInfo')[0] && $('#uxDateVisited')[0]) {
try {
var [aGCTBName, aGCTBLink, aGCTBNameLink, aLogDate] = getGCTBInfo();
var aOwner = decode_innerHTML($('#ctl00_ContentBody_LogBookPanel1_WaypointLink')[0].nextSibling.nextSibling.nextSibling.nextSibling.nextSibling);
insert_smilie_fkt("ctl00_ContentBody_LogBookPanel1_uxLogInfo");
insert_tpl_fkt();
var liste = "";
if (settings_show_bbcode) build_smilies();
build_tpls();
var box = $('#litDescrCharCount')[0];
box.innerHTML = liste;
} catch(e) {gclh_error("Smilies and Log Templates old log page",e);}
}
// Show Smilies und Log Templates new log page.
if (document.location.href.match(/\.com\/play\/geocache\/gc\w+\/log/) &&
$('#LogDate')[0] && $('#logContent')[0] && $('#LogText')[0] && $('#reportProblemInfo')[0]) {
try {
var [aGCTBName, aGCTBLink, aGCTBNameLink, aLogDate] = getGCTBInfo(true);
var aOwner = decode_innerHTML($('.hidden-by a')[0]);
aOwner = aOwner.match(/(.*)(";
else liste += " " + o;
bs("[:)]", "");
bs("[:D]", "_big");
bs("[8D]", "_cool");
bs("[:I]", "_blush");
bs("[:P]", "_tongue");
if (!newLogPage) liste += "
" + o;
bs("[}:)]", "_evil");
bs("[;)]", "_wink");
bs("[:o)]", "_clown");
bs("[B)]", "_blackeye");
bs("[8]", "_8ball");
if (newLogPage) liste += " ";
else liste += "" + o;
bs("[:(]", "_sad");
bs("[8)]", "_shy");
bs("[:O]", "_shock");
bs("[:(!]", "_angry");
bs("[xx(]", "_dead");
if (!newLogPage) liste += "" + o;
bs("[|)]", "_sleepy");
bs("[:X]", "_kisses");
bs("[^]", "_approve");
bs("[V]", "_dissapprove");
bs("[?]", "_question");
if (newLogPage) liste += "";
else liste += "";
function bs(s, n) {liste += " ";}
}
// Log Templates aufbauen.
function build_tpls(newLogPage) {
var texts = ""; var logicOld = ""; var logicNew = "";
for (var i = 0; i < anzTemplates; i++) {
if (getValue("settings_log_template_name["+i+"]", "") != "") {
texts += "