';
button += '';
$('div.EeWPwe').append(button);
// Missing CSS.
var css = '';
css += '.ZkkK1e.ZkkK1e {line-height: normal; font-family: arial,sans-serif;}';
css += '.ZkkK1e {-moz-box-sizing: border-box; box-sizing: border-box; border-radius: 18px; cursor: pointer; display: inline-block; height: 36px; min-width: 36px; position: relative; background: #fff; border: 1px solid #dadce0; color: #3c4043;}';
css += '.POUQwd.WN4Zxc {padding: 7px 0 7px 11px;}';
css += '.xlY4q, .POUQwd, .XqKfz {-moz-box-sizing: border-box; box-sizing: border-box; display: inline-block; height: 34px; vertical-align: bottom;}';
css += '.xlY4q.VIZLse {padding-right: 11px;}';
css += '.xlY4q {font-size: 14px; line-height: 34px; padding: 0 8px; padding-right: 8px;}';
css += '.VDgVie {text-align: center;}';
appendCssStyle(css);
// Example: "Nil"
} else if ($('div.V1GY4c img')[0]) {
if ($('div.V1GY4c img')[0].closest('a[href]:not([href=""]):not([href=" "])')) return;
var map = $('div.V1GY4c')[0];
var link = document.createElement('a');
link.href = mapsUrl;
map.parentNode.insertBefore(link, map);
link.appendChild(map);
}
}
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', setGMapsLinks);
else setGMapsLinks();
}
} catch(e) {gclh_error("mainGSearch",e);}
};
////////////////////////////////
// 3. Project GC ($$cap)
// 3.1 Project GC - Main ($$cap)
////////////////////////////////
var mainPGC = function() {
try {
// Tables with PQ definitions are available.
if ($('.row table').length > 0 && settings_show_create_pq_from_pq_splitter) {
// No errors available for month name related functions.
global_error = false;
// Get user language of the page.
var lang = getLanguage();
// Build output boxes for both tables with the PQ definitions.
$('.row table').each(function(table_index) {
buildOutputBox(this, table_index);
});
// Build css.
buildCss();
}
} catch(e) {gclh_error("mainPGC",e);}
/////////////////////////////////////
// 3.2 Project GC - Functions ($$cap)
/////////////////////////////////////
// Build output box.
function buildOutputBox(side, table_index) {
var html = '';
html += '
';
html += '
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 += '
';
html += '
';
html += '
Output to email: ';
html += 'The secondary email will only work if you have two or more email addresses in your profile.
';
html += '';
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. How to change pop up blocker settings in browser Mozilla Firefox, Google Chrome.
';
html += '
This is a feature of GC little helper II.
';
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('.not_ignored')[0].addEventListener("click", function() {
setValue('settings_pq_splitter_not_ignored', $(this).prop('checked'));
});
$(side).find('.is_enabled')[0].addEventListener("click", function() {
setValue('settings_pq_splitter_is_enabled', $(this).prop('checked'));
});
$(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);
});
$(side).find('.include_pq_name')[0].addEventListener("click", function() {
setValue('settings_pq_splitter_include_pq_name', $(this).prop('checked'));
});
}
}
// 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 not_ignored = $(current_table).find('.not_ignored').prop('checked') ? 1 : 0;
var is_enabled = $(current_table).find('.is_enabled').prop('checked') ? 1 : 0;
var email = $(current_table).find('.output_email').val();
var include_pq_name = $(current_table).find('.include_pq_name').prop('checked') ? 1 : 0;
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, ni: not_ignored, ie: is_enabled, in: include_pq_name};
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,.hide) select, #filtertoggle2div > div:not(.row,.hide) input:not(.btn)').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. Certitude ($$cap)
///////////////////////
// URLs for testing:
// https://www.certitudes.org/certitude?wp=GC8J1H9
// https://www.certitudes.org/certitude?wp=GC71TFG (with fileurl and filename)
// Certitude: GCLH
var mainCertitudes = function() {
// Certitude stay anonymous.
if (document.location.href.match(/^https:\/\/www\.certitudes\.org\/certitude\?wp=[A-Z0-9]{1,15}/) && settings_anonymous_on_certitude && document.getElementsByName('anonymous')[0]) {
try {
document.getElementsByName('anonymous')[0].checked = true;
} catch(e) {gclh_error("Certitude stay anonymous.",e);}
}
// Certitude compact information and copy to clipboard button.
if (document.location.href.match(/^https:\/\/www\.certitudes\.org\/certify/) && settings_show_compact_certitude_information && $('.user-input .embossed.success')[0] && $('.user-input .embossed.success')[0].innerHTML) {
try {
function copyElementByIdToClipboard(element) {
try {
var range = document.createRange();
range.selectNode(document.getElementById(element));
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand("copy");
window.getSelection().removeAllRanges();
} catch(e) {gclh_error("Certitude copy to clipboard",e);}
}
function addCompactCertitude() {
var output = ' ';
if ($('form.card')[0]) {
$('form.card:first').after(output);
var copyBtn = document.querySelector('.gclh_copy_btn');
copyBtn.addEventListener('click', function(event) {
copyElementByIdToClipboard('gclh_solution');
})
}
}
addCompactCertitude();
var css = '';
css += '.certifys-container {grid-template-columns: 300px auto 200px;}';
css += '.header {grid-template-columns: 300px auto;}';
appendCssStyle(css);
} catch(e) {gclh_error("mainCertitudes",e);}
}
}; // End of mainCertitudes.
///////////////////////////
// 5. 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' }, 'STAMEN_TERRAIN': { maxZoom: 20, displayName: 'Stamen Terrain' }, 'HUMANITARIAN': { maxZoom: 20, displayName: 'Humanitarian' }, 'ARCGIS_WORLDIMAGERY': { maxZoom: 20, displayName: 'World Imagery' }, 'ARCGIS_WORLDIMAGERY_OVERLAY': { maxZoom: 20, displayName: 'World Imagery + Overlay' }},
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);}
}
}
// Add link to admin tools to right sidebar.
if (is_page("cache_listing") && document.getElementById("ctl00_ContentBody_GeoNav_adminTools")) {
try {
if (document.getElementById('ctl00_ContentBody_GeoNav_uxArchivedLogType').children[0].href) {
var maintenance_link = document.getElementById('ctl00_ContentBody_GeoNav_uxArchivedLogType').children[0].href.replace('LogType=5', 'LogType=46')
$("#ctl00_ContentBody_GeoNav_adminTools").append('
";
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 (settings_adapt_height_cache_notes) {
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/)) {
function checkBuildSendIcons(waitCount, username, guid) {
if (!$('.gclh_send')[0]) {
var side = $('.hidden-by a')[0];
buildSendIcons(side, username, "per guid", guid);
}
waitCount++;
if (waitCount <= 50) setTimeout(function(){checkBuildSendIcons(waitCount, username, guid);}, 200);
}
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) {
checkBuildSendIcons(0, username, guid);
}
}
}
});
}
// Log form, log edit, log view redesigned new log page:
// "side" als Objekt geht verloren, wenn zwischenzeitlich ein Refresh der Seitendaten stattfindet, deshalb immer neu ermitteln.
} else if (document.location.pathname.match(/\/live\/(?:log\/(?:gl|tl)|(?:geocache|trackable)\/(?:gc|tb))[a-z0-9]+/i)) {
let hiddenUsername = '';
let hiddenGuid = '';
let loggedUsername = '';
let loggedGuid = '';
function checkBuildSendIcons(waitCount, username, guid, sideX) {
side = $(sideX)[0];
if (!$('.gclh_send')[0] && side && username && guid) {
buildSendIcons(side, username, "per guid", guid);
}
waitCount++;
if (waitCount <= 50) setTimeout(function(){checkBuildSendIcons(waitCount, username, guid, sideX);}, 200);
}
function getUserGuid(sideX) {
side = $(sideX)[0];
var userParts = side.href.match(/\.com\/p(\?|\/\?)(id=|code=|u=)(.+)/);
if (userParts && userParts[3]) {
var userLink = "/p/default.aspx?" + userParts[2] + userParts[3] + "&tab=geocaches";
GM_xmlhttpRequest({
method: "GET",
url: userLink,
onload: function(response) {
if (response.responseText) {
var [username, guid] = getUserGuidFromProfile(response.responseText);
if (sideX.match(/hidden/)) {
hiddenUsername = username;
hiddenGuid = guid;
} else {
loggedUsername = username;
loggedGuid = guid;
}
if (username && guid) {
checkBuildSendIcons(0, username, guid, sideX);
}
}
}
});
}
}
let url = '';
const config = { childList: true, subtree: true };
const logviewSendIconsObserver = new MutationObserver(function(_, observer) {
observer.disconnect();
if (url !== document.location.pathname) {
if (is_page('logform') && $('.hidden-by a')[0]) {
if (hiddenUsername == '') getUserGuid('.hidden-by a');
else checkBuildSendIcons(0, hiddenUsername, hiddenGuid, '.hidden-by a');
url = document.location.pathname;
} else if (document.location.pathname.match(/\/live\/log\/(?:gl|tl)[a-z0-9]+/i) && $('.log-sub-header a')[0]) {
if (loggedUsername == '') getUserGuid('.log-sub-header a');
else checkBuildSendIcons(0, loggedUsername, loggedGuid, '.log-sub-header a');
url = document.location.pathname;
}
}
observer.observe(document.body, config);
});
logviewSendIconsObserver.observe(document.body, config);
// 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);}
// Remove banners (blue banners).
if (settings_remove_banner) {
try {
// To activate the (x) button for a new banner, just change the following jq selector (use a comma and a new banner selector)
$('div.blue-banner-content,div.banner').each(function( index ) {
const bannerEl = $(this);
const bannerTextSum = bannerEl.text().checksum();
if (settings_remove_banner_text_ids.find(link => link === bannerTextSum)) {
$(bannerEl)[0].style.display = 'none';
} else {
const closeElId = 'closeBanner' + index; // hack for bind event
bannerEl.prepend('✖');
bannerEl.find('#' + closeElId).bind({
click: function() {
settings_remove_banner_text_ids.push(bannerTextSum);
setValue("settings_remove_banner_text_ids", JSON.stringify(settings_remove_banner_text_ids));
$(bannerEl)[0].style.display = 'none';
}
});
}
});
} 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 {
var 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/)) {
console.error("GClh_ERROR (no header alert) - addElevationToWaypoints_GeonamesElevation() - " + document.location.href + ": Service Unavailable.");
console.log(responseDetails);
} else {
console.error("GClh_ERROR (no header alert) - addElevationToWaypoints_GeonamesElevation() - " + document.location.href + ": Unknown error, see details.");
console.log(responseDetails);
}
getElevations(context.retries+1,context.locations);
} else {
var json = JSON.parse(responseDetails.responseText);
if (!json.geonames) {
console.error("GClh_ERROR (no header alert) - addElevationToWaypoints_GeonamesElevation() - " + document.location.href + ": json.geonames is undefined.");
console.log(responseDetails);
getElevations(context.retries+1,context.locations);
} else {
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|guid|ID|wp|LUID|PLogGuid|code)\=/) && 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 = '';
// Old logging page.
if (document.location.href.match(/\.com\/seek\/log\.aspx\?(id|guid|ID|wp|LUID|PLogGuid|code)\=/)) var mt = '1px'
// New logging page.
else var mt = '4px'
css += '#aci {margin-left: 4px; margin-right: 2px; margin-top: ' + mt + '; 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){
// Add cache type icon and limit cachetitle
var type = $(text).find('.cacheDetailsTitle a')[0].getAttribute("title");
var typeIcon = $(text).find('.activity-type-icon svg')[0];
var linkHeader = document.getElementsByClassName('subheader')[0];
if (type && typeIcon && linkHeader) {
var cacheName = $('.subheader')[0].innerHTML;
typeIcon.setAttribute("style", "vertical-align: sub; height: 19px; width: 19px;");
var typeIconSpan = document.createElement("span");
typeIconSpan.setAttribute("class", "gclh_TypeIcon");
typeIconSpan.setAttribute("style", "margin-right: 4px; margin-top: 3px; float: left;");
typeIconSpan.setAttribute("title", type);
linkHeader.setAttribute("style", "white-space: nowrap; overflow: hidden; text-overflow: ellipsis;");
linkHeader.setAttribute("title", cacheName);
linkHeader.parentNode.insertBefore(typeIconSpan, linkHeader);
document.getElementsByClassName('gclh_TypeIcon')[0].appendChild(typeIcon);
}
// Favorite points and favorite percent.
var aci = '';
var favoritePoints = $(text).find('.favorite-value').html();
if (favoritePoints) {
favoritePoints = favoritePoints.replace('.','').replace(',','');
favoritePoints = parseInt(favoritePoints);
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 += '';
}
// Difficulty and Terrain
var difficulty = $(text).find('#ctl00_ContentBody_uxLegendScale img');
var terrain = $(text).find('#ctl00_ContentBody_Localize12 img')
if ((difficulty[0]) && (terrain[0])) {
difficulty = difficulty[0].getAttribute("alt").split(" ")[0];
terrain = terrain[0].getAttribute("alt").split(" ")[0];
aci += separator(aci);
aci += '';
aci += '';
aci += ' ' + difficulty + ' ';
aci += '';
aci += '';
aci += '';
aci += ' ' + terrain + '';
aci += '';
}
// Output and further load.
if (aci != '') {
$('#aci')[0].innerHTML = aci;
let gccode;
// Old logging page.
// Beim Ändern eines Logs steht der GC Code nicht zur Verfügung, deshalb gibt es dort auch keinen Prozentsatz für die Favoriten.
if (document.location.href.match(/\.com\/seek\/log\.aspx\?(id|guid|ID|wp|LUID|PLogGuid|code)\=/) && $('#uxNewLoggingBannerLink')[0]) {
gccode = $('#uxNewLoggingBannerLink').attr('href').split('/').at(-2);
// New logging page.
} else if (document.location.href.match(/\.com\/play\/geocache\/gc\w+\/log/)) {
gccode = window.location.href.split('/').at(-2);
}
if (favoritePoints && !gccode == '') getFavoriteScore(gccode, function(score) {
$('.favorite_percent')[0].innerHTML = ' ' + score + '%';
});
// Variable length of cache name on new logging page.
if (document.location.href.match(/\.com\/play\/geocache\/gc\w+\/log/)) {
function setMaxwidthOfCacheName(waitCount) {
var width = 621 - parseInt(window.getComputedStyle($('#aci')[0]).width);
$('.subheader')[0].style.maxWidth = width+"px";
waitCount++;
if (waitCount <= 100) setTimeout(function(){setMaxwidthOfCacheName(waitCount);}, 100);
}
setMaxwidthOfCacheName(0);
}
}
});
}
// Add copy to clipboard links to geocaches and trackables old log page for Log ID and Logtext.
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)\=/))) {
try {
if ($('.CoordInfoLink')[0] && $('#ctl00_ContentBody_LogBookPanel1_CoordInfoLinkControl1_uxCoordInfoCode')[0]) {
addCopyToClipboardLink($('#ctl00_ContentBody_LogBookPanel1_CoordInfoLinkControl1_uxCoordInfoCode')[0], $('.CoordInfoLink')[0], "Log ID");
}
if ($('.LogEdit')[0] && $('#ctl00_ContentBody_LogBookPanel1_LogText')[0]) {
addCopyToClipboardLink(document.getElementById('ctl00_ContentBody_LogBookPanel1_LogText').innerText, $('.LogEdit')[0], "Logtext", 'padding: 4px 14px; position: relative; bottom: 5px;');
}
} catch(e) {gclh_error("Copy to Clipboard on log page",e);}
}
// 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(/(.*)( p1 ? finds - p1 : finds);";
code += " finds++;";
code += " inhalt = inhalt.replace(/#found-?(\\d+)?#/ig, (_match, p1) => p1 ? finds - p1 : finds);";
code += " }";
code += " if (aDate) inhalt = inhalt.replace(/#Date#/ig, aDate);";
code += " if (aTime) inhalt = inhalt.replace(/#Time#/ig, aTime);";
code += " if (aDateTime) inhalt = inhalt.replace(/#DateTime#/ig, aDateTime);";
code += " if (me) inhalt = inhalt.replace(/#me#/ig, me);";
code += " if (aGCTBName) inhalt = inhalt.replace(/#GCTBName#/ig, aGCTBName);";
code += " if (aGCTBLink) inhalt = inhalt.replace(/#GCTBLink#/ig, aGCTBLink);";
code += " if (aGCTBNameLink) inhalt = inhalt.replace(/#GCTBNameLink#/ig, aGCTBNameLink);";
code += " if (aLogDate) inhalt = inhalt.replace(/#LogDate#/ig, aLogDate);";
if (!newLogPage || settings_show_pseudo_as_owner) {
code += " if (owner) inhalt = inhalt.replace(/#owner#/ig, owner);";
}
code += " if (id.match(/last_logtext/) && settings_replace_log_by_last_log) {";
code += " input.value = inhalt;";
code += " } else {";
code += " if (typeof input.selectionStart != 'undefined' && inhalt) {";
code += " var start = input.selectionStart;";
code += " var end = input.selectionEnd;";
code += " var insText = input.value.substring(start, end);";
code += " input.value = input.value.substr(0, start) + inhalt + input.value.substr(end);";
code += " var pos = start + inhalt.length;";
code += " input.selectionStart = input.selectionEnd = pos;";
code += " }";
code += " }";
code += " input.focus();";
// Auch im Log Preview zur Anzeige bringen.
code += " input.dispatchEvent(new KeyboardEvent('keyup', {'keyCode': 32}));";
code += "}";
injectPageScript(code, 'body');
}
// Smilies aufbauen.
function build_smilies(newLogPage) {
var o = "
');
$('#trackablesPanel').before(log_preview_wrapper);
var $mdEditor = $("textarea.log-text").MarkdownDeep({
SafeMode :true,
AllowInlineImages: false,
ExtraMode: false,
RequireHeaderClosingTag: true,
disableShortCutKeys: true,
DisabledBlockTypes: [
BLOCKTYPE_CONST.h4,
BLOCKTYPE_CONST.h5,
BLOCKTYPE_CONST.h6
],
help_location: "/guide/markdown.aspx",
active_modal_class: "modal-open",
active_modal_selector: "html",
additionalPreviewFilter: SmileyConvert()
});
$('#log-preview-button').click(function(){
$('#log-preview-content').toggle();
$('#log-previewPanel button').toggleClass('handle-open');
});
} catch(e) {gclh_error("Logpage Log Preview",e);}
}
// Replicate TB-Header to bottom
if (document.location.href.match(/\.com\/play\/geocache\/gc\w+\/log/)) {
try {
var checkExistTBHeader = setInterval(function() {
if ($('#tbHeader .trackables-header').length) {
var visit_link = document.createElement("a");
visit_link.setAttribute("href", "javascript:void(0);");
visit_link.appendChild(document.createTextNode('Visit all'));
visit_link.addEventListener("click", function(){
$('#tbHeader .btn-visit').trigger( "click" );
});
var drop_link = document.createElement("a");
drop_link.setAttribute("href", "javascript:void(0);");
drop_link.appendChild(document.createTextNode('Drop all'));
drop_link.addEventListener("click", function(){
$('#tbHeader .btn-drop').trigger( "click" );
});
var clear_link = document.createElement("a");
clear_link.setAttribute("href", "javascript:void(0);");
clear_link.appendChild(document.createTextNode('Clear all'));
clear_link.addEventListener("click", function(){
$('#tbHeader .btn-clear').trigger( "click" );
});
var li = document.createElement("li");
li.classList.add('tb_action_buttons');
li.appendChild(clear_link);
li.appendChild(visit_link);
li.appendChild(drop_link);
$(".trackables-list").append(li);
var css =
".tb_action_buttons{text-align:right;} " +
".tb_action_buttons a{margin-right: 12px; text-decoration:underline;}" +
".tb_action_buttons a:last-child{margin-right:0px;}"
appendCssStyle(css);
clearInterval(checkExistTBHeader);
}
}, 500);
} catch(e) {gclh_error("Logpage Replicate TB-Header",e);}
}
// Maxlength of logtext and unsaved warning.
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]) ||
document.location.href.match(/\.com\/play\/geocache\/gc\w+\/log/)) {
try {
var newLogpage = document.location.href.match(/\.com\/play\/geocache\/gc\w+\/log/);
var changed = false;
// Meldung bei ungespeichertem Log.
window.onbeforeunload = function(e) {
if (changed && settings_unsaved_log_message) {
var mess = "You have changed a log and haven't saved it yet. Do you want to leave this page and lose your changes?";
e.returnValue = mess;
return mess;
}
};
if ($('#ctl00_ContentBody_LogBookPanel1_btnSubmitLog')[0]) $('#ctl00_ContentBody_LogBookPanel1_btnSubmitLog')[0].addEventListener("click", function() {changed = false;}, false); // Keine Meldung beim Submit.
if ($('#submitLog')[0]) $('#submitLog')[0].addEventListener("click", function() {changed = false;}, false); // Keine Meldung beim Submit.
var counterelement = document.createElement('span');
function waitForLoadingLoggingPage(waitCount) {
if (!document.getElementsByClassName('loading')[0]) {
if (!newLogpage || (newLogpage && settings_improve_character_counter)) {
var logfield = (!newLogpage ? $('#ctl00_ContentBody_LogBookPanel1_uxLogInfo')[0] : $('#LogText')[0]);
var counterspan = document.createElement('p');
counterspan.id = "logtextcounter";
var wordsArr = $(logfield).val().replace(/\n/g, ' ').split(' ');
var words = 0;
for (let i=0; i");
counterelement.innerHTML = '' + $(logfield).val().replace(/\n/g, "\r\n").length + '/4000 (' + words + ' words)';
counterspan.appendChild(counterelement);
if (!newLogpage) document.getElementById('litDescrCharCount').parentNode.appendChild(counterspan);
else {
document.querySelector('.btn-group-grow').insertBefore(counterspan, (document.querySelector('.btn-favorite') ? document.querySelector('.btn-favorite') : document.querySelector('.btn-problem')));
var observerNewLog = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (!document.querySelector('#logtextcounter')) document.querySelector('.btn-group-grow').insertBefore(counterspan, (document.querySelector('.btn-favorite') ? document.querySelector('.btn-favorite') : document.querySelector('.btn-problem')));
});
});
var target = document.querySelector('body');
var config = {attributes: true, childList: true, characterData: true, subtree: true};
observerNewLog.observe(target, config);
}
logfield.addEventListener("keyup", function() {limitedField(logfield, document.querySelector('#logtextcounter span'), 4000, true);}, false);
logfield.addEventListener("change", function() {limitedField(logfield, document.querySelector('#logtextcounter span'), 4000, true);}, false);
}
} else {waitCount++; if (waitCount <= 200) setTimeout(function(){waitForLoadingLoggingPage(waitCount);}, 50);}
}
waitForLoadingLoggingPage(0);
var css = '#logtextcounter {font-weight: normal !important;}';
if (newLogpage && settings_improve_character_counter) {
css += 'span.character-counter {display: none !important;}';
css += '#logtextcounter {margin: 0 !important;}'
css += '.btn-group-grow {flex: unset !important; display: flex; justify-content: space-between; width: 100%; align-items: center;}';
css += '.btn-problem {float: unset !important; margin-left: 0 !important;}'
}
appendCssStyle(css);
} catch(e) {gclh_error("Maxlength of logtext and unsaved warning",e);}
}
// Autovisit Old Log Page.
if (settings_autovisit && document.location.href.match(/\.com\/seek\/log\.aspx/) && !document.location.href.match(/\.com\/seek\/log\.aspx\?LUID=/) && !document.getElementById('ctl00_ContentBody_LogBookPanel1_CoordInfoLinkControl1_uxCoordInfoCode')) {
try {
var tbs = getTbsO();
if (tbs.length != 0) {
for (var i = 0; i < tbs.length; i++) {
var [tbC, tbN] = getTbO(tbs[i].parentNode);
if (!tbC || !tbN) continue;
var auto = document.createElement("input");
auto.setAttribute("type", "checkbox");
auto.setAttribute("id", "gclh_"+tbC);
auto.setAttribute("value", tbN);
auto.addEventListener("click", setAutoO, false);
tbs[i].appendChild(auto);
tbs[i].appendChild(document.createTextNode(" AutoVisit"));
}
$('#ctl00_ContentBody_LogBookPanel1_ddLogType')[0].addEventListener("input", buildAutosO, false);
buildAutosO(true);
window.addEventListener("load", function(){buildAutosO(true);}, false);
}
function buildAutosO(start) {
var type = getTypeO();
var tbs = getTbsO();
for (var i = 0; i < tbs.length; i++) {
var [tbC, tbN] = getTbO(tbs[i].parentNode);
setAutoO(tbC, tbN, type, start, true);
}
if (unsafeWindow.setSelectedActions) unsafeWindow.setSelectedActions();
}
function setAutoO(tbC, tbN, type, start, allTbs) {
if (!type) var type = getTypeO();
if (!tbC || !tbN) var [tbC, tbN] = getTbO(this.parentNode.parentNode);
var options = $('#gclh_'+tbC)[0].parentNode.getElementsByTagName('option');
var select = $('#gclh_'+tbC)[0].parentNode.getElementsByTagName('select');
var autos = $('#gclh_'+tbC)[0];
if (!type || !tbC || !tbN || !select[0] || options.length < 2 || !autos) return;
if (start) {
if (getValue("autovisit_"+tbC, settings_autovisit_default)) autos.checked = true;
else autos.checked = false;
}
if (options.length == 2 || (options.length == 3 && select[0].selectedIndex != 1)) {
if (autos.checked == true) {
if (type == 2 || type == 10 || type == 11) select[0].selectedIndex = options.length - 1;
else select[0].selectedIndex = 0;
} else {
if (allTbs != true && (type == 2 || type == 10 || type == 11)) select[0].selectedIndex = 0;
}
}
setValue("autovisit_"+tbC, (autos.checked ? true:false));
}
function getTypeO() {return $('#ctl00_ContentBody_LogBookPanel1_ddLogType')[0].value;}
function getTbsO() {return $('#tblTravelBugs tbody tr td select').closest('td');}
function getTbO(tb) {return [$(tb).find('td a')[0].innerHTML, $(tb).find('td select option')[0].value];}
} catch(e) {gclh_error("Autovisit Old",e);}
}
// Autovisit New Log Page.
if (settings_autovisit && document.location.href.match(/\.com\/play\/geocache\/gc\w+\/log/i)) {
try {
function getTbs() {return $('#tbList .trackables-list li:not(.tb_action_buttons)');}
function getType() {return $('.log-types').val();} // returns the log type.
function getTb(tb) {return $(tb).find('.stats dd')[1].innerHTML;}; // returns the tb code.
function getTbType(tb) {
let r = $(tb).find('input[type="radio"]');
for (let i=0; i<3; i++) {
if (r[i].checked) return r[i].value;
}
}
function buildAutos() {
let tbs = getTbs();
if (tbs.length > 0) {
for (let i=0; i 1) {
var tbs = getTbs();
if (tbs.length > 0) {
for (let i=0; i
');
$(tbs[i]).find('.actions.radio-toggle-group').appendTo('#gclh_action_list_'+tbC+'');
let html = '
'
+ ' '
+ ' '
+ '
';
$('#gclh_action_list_'+tbC).append(html);
}
// Save TB in autovisit if it new.
if (getValue("autovisit_"+tbC, "new") === "new") {
setValue("autovisit_"+tbC, settings_autovisit_default);
}
// Save autovisit status onchange
$(tbs[i]).find('.gclh_autovisit input').each(function() {
this.addEventListener('change', function(evt) {
setValue(evt.target.name, (evt.target.value==1 ? true : false));
buildAutos();
})
});
}
// Set Autovisit.
buildAutos();
// Change autovisit if the logtype changed
$('select.log-types').bind('change', buildAutos);
waitCount++; if (waitCount <= 100) setTimeout(function(){waitForContent(waitCount);}, 100);
}
} else {waitCount++; if (waitCount <= 100) setTimeout(function(){waitForContent(waitCount);}, 100);}
}
waitForContent(0);
} catch(e) {gclh_error("Autovisit New",e);}
}
// Default Log Type and Log Signature Old Log Page.
// Cache:
if (document.location.href.match(/\.com\/seek\/log\.aspx\?(id|guid|ID|PLogGuid|wp)\=/) && $('#ctl00_ContentBody_LogBookPanel1_ddLogType')[0] && $('#ctl00_ContentBody_LogBookPanel1_lbConfirm').length == 0) {
try {
// Logtype.
if (!document.location.href.match(/\&LogType\=/) && !document.location.href.match(/PLogGuid/)) {
var cache_type = document.getElementById("ctl00_ContentBody_LogBookPanel1_WaypointLink").nextSibling.childNodes[0].title;
var select_val = "-1";
if (cache_type.match(/event/i)) {
select_val = settings_default_logtype_event;
} else if ($('.PostLogList').find('a[href*="https://www.geocaching.com/profile/?guid="], a[href*="https://www.geocaching.com/p/?guid="]').text().trim() == global_me.trim()) {
select_val = settings_default_logtype_owner;
} else select_val = settings_default_logtype;
var select = document.getElementById('ctl00_ContentBody_LogBookPanel1_ddLogType');
var childs = select.children;
if (select.value == "-1") {
for (var i = 0; i < childs.length; i++) {
if (childs[i].value == select_val) select.selectedIndex = i;
}
}
// Bei Events wird nach dem Event Datum von GS automatisch der Logtype "Attended" gesetzt, sofern ein "Attended" noch nicht vorhanden ist.
// Das Log Datum steht dann auf dem aktuellen Datum und nicht auf dem Event Datum, was richtig wäre. Das Log Datum ist nicht eingabebereit.
// Unsere Default Einstellung settings_default_logtype_event zieht für diesen Fall nie. Der Fehler tritt auch ohne den GClh auf. Es handelt
// sich hier also um einen Bug auf der Webseite, der aber wohl kaum noch berichtigt wird.
if (select.value == "10") {
var logdate = $("#uxDateVisited");
var logdate_format = logdate.attr("userdateformat");
var logdate_date = new Date($("#ctl00_ContentBody_LogBookPanel1_EventDate").val());
var logdate_text = $.datepicker.formatDate(logdate_format, logdate_date);
logdate.attr("value", logdate_text);
}
}
// Signature.
var logtext = document.getElementById('ctl00_ContentBody_LogBookPanel1_uxLogInfo').value;
var signature = getValue("settings_log_signature", "");
// Cursorposition gegebenenfalls hinter Draft ermitteln.
document.getElementById('ctl00_ContentBody_LogBookPanel1_uxLogInfo').innerHTML += "";
var initial_cursor_position = document.getElementById('ctl00_ContentBody_LogBookPanel1_uxLogInfo').selectionEnd;
// Draft.
if (document.location.href.match(/\.com\/seek\/log\.aspx\?PLogGuid\=/)) {
if (settings_log_signature_on_fieldnotes && !logtext.includes(signature.replace(/^\s*/, ''))) {
document.getElementById('ctl00_ContentBody_LogBookPanel1_uxLogInfo').innerHTML += signature;
}
// Kein Draft.
} else {
if (!logtext.includes(signature)) {
document.getElementById('ctl00_ContentBody_LogBookPanel1_uxLogInfo').innerHTML += signature;
}
}
replacePlaceholder();
document.getElementById('ctl00_ContentBody_LogBookPanel1_uxLogInfo').selectionEnd = initial_cursor_position;
// Auch im Log Preview zur Anzeige bringen.
document.getElementById('ctl00_ContentBody_LogBookPanel1_uxLogInfo').dispatchEvent(new KeyboardEvent('keyup', {'keyCode': 32}));
} catch(e) {gclh_error("Default Log-Type and Signature Old Log Page (CACHE)",e);}
}
// TB:
if (document.location.href.match(/\.com\/track\/log\.aspx/) && $('#ctl00_ContentBody_LogBookPanel1_ddLogType')[0]) {
try {
// Logtype.
if (settings_default_tb_logtype != "-1" && !document.location.href.match(/\&LogType\=/)) {
var select = document.getElementById('ctl00_ContentBody_LogBookPanel1_ddLogType');
var childs = select.children;
for (var i = 0; i < childs.length; i++) {
if (childs[i].value == settings_default_tb_logtype) select.selectedIndex = i;
}
}
// Signature.
if ($('#ctl00_ContentBody_LogBookPanel1_uxLogInfo')[0] && $('#ctl00_ContentBody_LogBookPanel1_uxLogInfo')[0].innerHTML == "") $('#ctl00_ContentBody_LogBookPanel1_uxLogInfo')[0].innerHTML = getValue("settings_tb_signature", "");
replacePlaceholder();
document.getElementById('ctl00_ContentBody_LogBookPanel1_uxLogInfo').selectionEnd = 0;
// Auch im Log Preview zur Anzeige bringen.
document.getElementById('ctl00_ContentBody_LogBookPanel1_uxLogInfo').dispatchEvent(new KeyboardEvent('keyup', {'keyCode': 32}));
} catch(e) {gclh_error("Default Log-Type and Signature (TB)",e);}
}
// Log Signature New Log Page.
if (document.location.href.match(/\.com\/play\/geocache\/gc\w+\/log/)) {
try {
checkLogType(0);
function checkLogType(waitCount) {
// Drafts ohne Signatur.
if (document.location.href.match(/log\?d\=/) && document.getElementById('LogText').value != "" && !settings_log_signature_on_fieldnotes) {
// Auch im Log Preview zur Anzeige bringen.
document.getElementById('LogText').dispatchEvent(new KeyboardEvent('keyup', {'keyCode': 32}));
}
// Kein Draft oder Draft mit Signatur.
if ((!document.location.href.match(/log\?d\=/)) || // Kein Draft
(document.location.href.match(/log\?d\=/) && document.getElementById('LogText').value != "" && settings_log_signature_on_fieldnotes)) { // Draft
var initial_cursor_position = document.getElementById('LogText').selectionEnd;
var logtext = document.getElementById('LogText').value;
var signature = getValue("settings_log_signature", "");
if (!logtext.includes(signature.replace(/^\s*/, ''))) {
document.getElementById('LogText').innerHTML = signature;
}
replacePlaceholder(true);
if (document.location.href.match(/log\?d\=/)) { // Draft
// 2 Zeilen sinngemäß von DieBatzen ausgeliehen, um "<" und ">" richtig darzustellen.
var textarea = document.createElement('textarea');
var value = $('