Skip to content

Commit

Permalink
View who favorited the cache in the logs of cache listing
Browse files Browse the repository at this point in the history
Build back - Upload js
#1054
  • Loading branch information
2Abendsegler committed Sep 11, 2020
2 parents 8dd47a5 + a4322f4 commit 88cb22b
Showing 1 changed file with 1 addition and 169 deletions.
170 changes: 1 addition & 169 deletions gc_little_helper_II.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @name GC little helper II
// @namespace http://www.amshove.net
//--> $$000
// @version 0.10.7.3
// @version 0.10.7
//<-- $$000
// @include https://www.geocaching.com/*
// @include https://maps.google.tld/*
Expand Down Expand Up @@ -610,12 +610,6 @@ var variablesInit = function(c) {
c.settings_show_edit_links_for_logs = getValue("settings_show_edit_links_for_logs", true);
c.settings_show_copydata_plus = getValue("settings_show_copydata_plus", false);
c.settings_show_copydata_separator = getValue("settings_show_copydata_separator", "\n");
c.settings_show_who_favorited_but = getValue("settings_show_who_favorited_but", true);
c.settings_show_who_favorited_loading_time = getValue("settings_show_who_favorited_loading_time", 120);
//xxxx
c.settings_show_who_favorited_back = getValue("settings_show_who_favorited_back", true);
c.settings_show_who_favorited_visible = getValue("settings_show_who_favorited_visible", false);
c.settings_show_who_favorited_delay = getValue("settings_show_who_favorited_delay", '');

try {
if (c.userToken === null) {
Expand Down Expand Up @@ -1264,42 +1258,6 @@ var mainGC = function() {
if (window.confirm(mess)) document.location.href = "/my/default.aspx";
else document.location.href = document.location.href.replace("?#"+splitter[1]+"#"+splitter[2], "");

// Get who favorited a cache on page "Users Who Favorited This Cache".
} else if (postbackValue == "whoFavorited") {
if (splitter[3] && splitter[3] != "") {
// Process marked page "Users Who Favorited This Cache".
whoFavoritedIframe($('#ctl00_ContentBody_pnlUsers').closest('form').prop('action'), 'whoFavorited', splitter[3], function(processId) {
// Save guids who favorited a cache.
var whoAll = GM_getValue('whoFavorited', []);
var who = $.grep(whoAll, function(e){return e.processId == processId;});
if (!who[0]) {
whoAll.push({processId: processId, guids: []});
var who = $.grep(whoAll, function(e){return e.processId == processId;});
}
$('#ctl00_ContentBody_pnlUsers table.Table tbody tr td:nth-child(1) > a:nth-child(2)').each(function() {
who[0].guids[who[0].guids.length] = getGuid($(this)[0].href);
});
GM_setValue('whoFavorited', whoAll);
// Get the next page.
var buttons = $('#ctl00_ContentBody_pnlUsers table.NoBottomSpacing tbody tr')[0];
var buttonNext = buttons.children[1].children[2];
if ($(buttonNext).hasClass('aspNetDisabled') == false) {
$('#ctl00_ContentBody_pnlUsers').closest('form').prop('action', $('#ctl00_ContentBody_pnlUsers').closest('form').prop('action') + '#gclhpb#whoFavorited#' + processId);
//xxxx
if (settings_show_who_favorited_delay == '') {
buttonNext.click();
} else {
setTimeout(function(){
buttonNext.click();
}, settings_show_who_favorited_delay);
}
} else {
return;
}
});
return;
}

// Jump to profile tab.
} else if (postbackValue.match(/_ContentBody_ProfilePanel1_/)) {
if (is_page("publicProfile")) {
Expand Down Expand Up @@ -7064,7 +7022,6 @@ var mainGC = function() {
unsafeWindow.$('a.tb_images').fancybox({'type': 'image', 'titlePosition': 'inside'});
gclh_add_vip_icon();
setLinesColorInCacheListing();
markLogsWhoFavorited();
if(isUpvoteActive){
unsafeWindow.appendUpvotesToLogs(log_ids);
updateUpvoteEvents(logs);
Expand Down Expand Up @@ -7096,7 +7053,6 @@ var mainGC = function() {
unsafeWindow.$('a.tb_images').fancybox({'type': 'image', 'titlePosition': 'inside'});
gclh_add_vip_icon();
setLinesColorInCacheListing();
markLogsWhoFavorited();
setMarkerDisableDynamicLogLoad();
if (document.getElementById("gclh_show_log_counter")) document.getElementById("gclh_show_log_counter").style.visibility = "";
}
Expand All @@ -7109,7 +7065,6 @@ var mainGC = function() {
if (settings_show_all_logs_but) addButtonOverLogs(gclh_load_all_logs, "gclh_load_all_logs", false, "Show all logs", "");
if (settings_show_bigger_avatars_but && !settings_hide_avatar && !isMemberInPmoCache() && settings_show_thumbnails) showBiggerAvatarsLink();
if (settings_show_log_counter_but) showLogCounterLink();
if (settings_show_who_favorited_but && $('#uxFavContainerLink .favorite-value')[0] && $('#uxFavContainerLink .favorite-value')[0].innerHTML.replace(/(\s*)/g,'') != "0") addButtonOverLogs(markWhoFavorited, "gclh_show_whoFavorited", true, "Show who favorited", "Mark user logs who favorited the cache");
if(isUpvoteActive){
$('#new_sort_element_upvote').prop( "disabled", false );
$('#new_sort_element_upvote').removeClass("isDisabled");
Expand Down Expand Up @@ -7155,7 +7110,6 @@ var mainGC = function() {
unsafeWindow.$('a.tb_images').fancybox({'type': 'image', 'titlePosition': 'inside'});
gclh_add_vip_icon();
setLinesColorInCacheListing();
markLogsWhoFavorited();
setMarkerDisableDynamicLogLoad();
if (document.getElementById("gclh_show_log_counter")) document.getElementById("gclh_show_log_counter").style.visibility = "hidden";
}
Expand Down Expand Up @@ -7255,7 +7209,6 @@ var mainGC = function() {
unsafeWindow.$('a.tb_images').fancybox({'type': 'image', 'titlePosition': 'inside'});
gclh_add_vip_icon();
setLinesColorInCacheListing();
markLogsWhoFavorited();
setMarkerDisableDynamicLogLoad();

// Highlight the searchs.
Expand Down Expand Up @@ -11802,102 +11755,6 @@ var mainGC = function() {
}, 100);
}

// Mark user logs who favorited the cache.
function markWhoFavorited() {
if ($('#gclh_show_whoFavorited.working')[0]) return;
$('#gclh_show_whoFavorited input')[0].removeAttribute('style');
$('#gclh_show_whoFavorited input')[0].removeAttribute('title');
$('#gclh_show_whoFavorited').addClass('loadstatus');
$('#gclh_show_whoFavorited').addClass('working');
$('#gclh_show_whoFavorited input')[0].setAttribute('disabled', '');
whoFavoritedIframe($('#hlViewWhoFavorited')[0].href, 'whoFavorited_cacheListing', new Date().getTime(), function(processId) {
function waitForWhoFavoritedGuids(waitCount, processId) {
var whoAll = GM_getValue('whoFavorited', []);
var who = $.grep(whoAll, function(e){return e.processId == processId;});
var favoritedCount = $('#uxFavContainerLink .favorite-value')[0].innerHTML.replace(/(\s*)/g,'');
var maxWaitCount = settings_show_who_favorited_loading_time * 1000 / 500;
if ((who && who[0] && favoritedCount == who[0].guids.length) || waitCount >= maxWaitCount) {
global_whoFavoritedGuids = who[0].guids;
whoFavoritedSavedRemove(processId);
$('#gclh_show_whoFavorited input')[0].removeAttribute('style');
$('#gclh_show_whoFavorited').removeClass('loadstatus');
$('#gclh_show_whoFavorited').removeClass('working');
$('#gclh_show_whoFavorited input')[0].removeAttribute('disabled');
if ($('#whoFavorited_cacheListing')[0]) $('#whoFavorited_cacheListing')[0].remove();
if (waitCount >= maxWaitCount) {
$('#gclh_show_whoFavorited input')[0].setAttribute('title', 'Error by loading user who favorited the cache.\n(Timeout: Probably too much user.)')
$('#gclh_show_whoFavorited').addClass('gclhError');
} else {
markLogsWhoFavorited();
}
} else {
if (who && who[0] && who[0].guids && who[0].guids.length > 0) {
var loadstatus = roundTO( (who[0].guids.length * 100 / favoritedCount), 0);
$('#gclh_show_whoFavorited input')[0].setAttribute('style', 'background-size: '+loadstatus+'% 2px;');
}
waitCount++; if (waitCount <= maxWaitCount) setTimeout(function() {waitForWhoFavoritedGuids(waitCount, processId);}, 500);
}
}
waitForWhoFavoritedGuids(0, processId);
});
}
// Assign guids who favorited to logs.
var global_whoFavoritedGuids = {};
function markLogsWhoFavorited() {
if (!global_whoFavoritedGuids || global_whoFavoritedGuids.length == 0) return;
$('#cache_logs_table2 tbody tr').each(function() {
if ($(this).find('.logOwnerProfileName a')[0] && $(this).find('.logOwnerProfileName a')[0].href && $(this).find('.LogType img')[0]) {
if (!$(this).find('.LogFavorite')[0]) {
if (in_array(getGuid($(this).find('.logOwnerProfileName a')[0].href), global_whoFavoritedGuids)) {
$(this).find('.LogType img').after('<img class="LogFavorite" title="Favorite" src="/images/icons/fave_fill_16.svg" style="padding-left: 1px;">');
}
}
}
});
}
// Process Iframe for page "Users Who Favorited This Cache".
function whoFavoritedIframe(iframeUrl, iframeId, processId, functionDone) {
try {
// Nur iframe fürs cache_listing aufbauen. Bei Anderen wird die Verarbeitung quasi durch den Click auf next angestossen.
if (iframeId == 'whoFavorited_cacheListing') {
iframeUrl += '#gclhpb#whoFavorited#' + processId;
iframe = document.createElement('iframe');
iframe.id = iframeId;
iframe.src = iframeUrl;
//xxxx
if (settings_show_who_favorited_visible == true) {
// iframe.style = 'width: 99%; height: 250px;'; // letzter Versuch
iframe.style = 'width: 800px; height: 250px;'; // Testdata
} else {
iframe.style = 'display: none; visibility: hidden; width: 100%; position: fixed;';
}
//xxxx
if (settings_show_who_favorited_back == true) {
$('body')[0].appendChild(iframe);
} else {
$('body')[0].before(iframe); // Testdata
}
$('table.Table tbody tr td a img').each(function() {this.src = "";});
}
function waitForIframeContent(waitCount, iframeId, processId) {
// Merke: Mit "$('#ctl00_ContentBody_pnlUsers')[0]" wird die Verarbeitung an die durch den Click auf next erzeugten Screen zurückgegeben.
// Merke: Mit "$('#'+iframeId)[0]" wird die Verarbeitung ans Cache Listing zurückgegeben.
//xxxx
if ($('#ctl00_ContentBody_pnlUsers')[0] || $('#'+iframeId)[0]) {
// if (($('#ctl00_ContentBody_pnlUsers')[0] && $('#ctl00_ContentBody_pnlUsers td.PageBuilderWidget').length >= 4) || $('#'+iframeId)[0]) { // letzter Versuch
functionDone(processId);
} else {waitCount++; if (waitCount <= 1000) setTimeout(function() {waitForIframeContent(waitCount, iframeId, processId);}, 10);}
}
waitForIframeContent(0, iframeId, processId);
} catch(e) {gclh_error('Function whoFavoritedIframe',e);}
}
// Remove saved process id.
function whoFavoritedSavedRemove(processId) {
var whoAll = GM_getValue('whoFavorited', []);
var whoRest = $.grep(whoAll, function(e){return e.processId != processId;});
GM_setValue('whoFavorited', whoRest);
}

// Add button over logs in cache listing.
function addButtonOverLogs(func, id, right, txt, title) {
if (!$('#ctl00_ContentBody_uxLogbookLink')[0]) return;
Expand Down Expand Up @@ -13249,15 +13106,6 @@ var mainGC = function() {
html += newParameterVersionSetzen(0.9) + newParameterOff;
html += newParameterOn1;
html += checkboxy('settings_show_compact_logbook_but', 'Show button \"Show compact logs\" above the logs') + "<br>";
html += checkboxy('settings_show_who_favorited_but', 'Show button \"Show who favorited\" above the logs') + "<br>";
html += ' &nbsp; &nbsp;' + "Maximum loading time for the favorites data: <input class='gclh_form' type='text' size='4' id='settings_show_who_favorited_loading_time' value='" + getValue("settings_show_who_favorited_loading_time", 120) + "'>";
html += "<img src=" + global_restore_icon + " id='restore_settings_show_who_favorited_loading_time' title='back to default' style='width: 12px; cursor: pointer;'>";
html += " seconds" + show_help3("With this option you can set the maximum time for the loading of the favorites data. The loading of this data takes a comparatively long time, because we can only read data for 10 favorites with one load, and only one 10 after the other. Default is \"120\" seconds (2 minutes).<br><br>This option requires \'Show button \"Show who favorited\" above the logs\'.") + "<br>";
//xxxx
html += "&nbsp;&nbsp;" + checkboxy('settings_show_who_favorited_back', 'Build internal screen at the end') + "<br>";
html += "&nbsp;&nbsp;" + checkboxy('settings_show_who_favorited_visible', 'Show internal screen') + "<br>";
html += ' &nbsp; &nbsp;' + "Delay for clicking to button \"next\" in milliseconds: <input class='gclh_form' type='text' size='4' id='settings_show_who_favorited_delay' value='" + getValue("settings_show_who_favorited_delay", '') + "'><br>";

html += checkboxy('settings_hide_found_count', 'Hide found count') + "<br>";
html += checkboxy('settings_cache_type_icon_visible', 'Set cache type icon always visible') + show_help("With this option, the cache type icon is always displayed complete, even if the cache is deactivated or archived.") + "<br>";
html += checkboxy('settings_log_status_icon_visible', 'Set log status icon always visible') + show_help("With this option, the log status icon is always displayed complete, even if the cache is deactivated or archived. The log status icon is located above the cache type icons and indicates for example if a cache was found, if there is a personal note or if there are corrected coordinates.") + "<br>";
Expand Down Expand Up @@ -13811,7 +13659,6 @@ var mainGC = function() {
$('#restore_settings_show_copydata_own_stuff_name')[0].addEventListener("click", restoreField, false);
$('#restore_settings_show_copydata_own_stuff_value')[0].addEventListener("click", restoreField, false);
$('#restore_settings_show_copydata_separator')[0].addEventListener("click", restoreField, false);
$('#restore_settings_show_who_favorited_loading_time')[0].addEventListener("click", restoreField, false);

// Events setzen für Parameter, die im GClh Config mehrfach ausgegeben wurden, weil sie zu mehreren Themen gehören. Es handelt sich hier um den Parameter selbst.
// In der Function werden Events für den Parameter selbst (ZB: "settings_show_mail_in_viplist") und dessen Clone gesetzt, die hinten mit "X" und Nummerierung
Expand Down Expand Up @@ -13972,12 +13819,6 @@ var mainGC = function() {
setEvForDepPara("settings_show_copydata_own_stuff_show","restore_settings_show_copydata_own_stuff_name");
setEvForDepPara("settings_show_copydata_own_stuff_show","settings_show_copydata_own_stuff_value");
setEvForDepPara("settings_show_copydata_own_stuff_show","restore_settings_show_copydata_own_stuff_value");
setEvForDepPara("settings_show_who_favorited_but","settings_show_who_favorited_loading_time");
setEvForDepPara("settings_show_who_favorited_but","restore_settings_show_who_favorited_loading_time");
//xxxx
setEvForDepPara("settings_show_who_favorited_but","settings_show_who_favorited_back");
setEvForDepPara("settings_show_who_favorited_but","settings_show_who_favorited_visible");
setEvForDepPara("settings_show_who_favorited_but","settings_show_who_favorited_delay");

// Abhängigkeiten der Linklist Parameter.
for (var i = 0; i < 100; i++) {
Expand Down Expand Up @@ -14139,9 +13980,6 @@ var mainGC = function() {
setValue("settings_show_copydata_own_stuff_name", document.getElementById('settings_show_copydata_own_stuff_name').value);
setValue("settings_show_copydata_own_stuff_value", document.getElementById('settings_show_copydata_own_stuff_value').value);
setValue("settings_show_copydata_separator", document.getElementById('settings_show_copydata_separator').value);
setValue("settings_show_who_favorited_loading_time", document.getElementById('settings_show_who_favorited_loading_time').value);
//xxxx
setValue("settings_show_who_favorited_delay", document.getElementById('settings_show_who_favorited_delay').value);

// Map Layers in vorgegebener Reihenfolge übernehmen.
var new_map_layers_available = document.getElementById('settings_maplayers_available');
Expand Down Expand Up @@ -14401,10 +14239,6 @@ var mainGC = function() {
'settings_relocate_other_map_buttons',
'settings_show_radius_on_flopps',
'settings_show_edit_links_for_logs',
'settings_show_who_favorited_but',
//xxxx
'settings_show_who_favorited_back',
'settings_show_who_favorited_visible',
);

for (var i = 0; i < checkboxes.length; i++) {
Expand Down Expand Up @@ -14806,7 +14640,6 @@ var mainGC = function() {
case "settings_show_copydata_own_stuff_name": field.value = "Photo file name"; break;
case "settings_show_copydata_own_stuff_value": field.value = "#yyyy#.#mm#.#dd# - #GCName# - #GCCode# - 01"; break;
case "settings_show_copydata_separator": field.value = "\n"; break;
case "settings_show_who_favorited_loading_time": field.value = "120"; break;
}
$(field)[0].focus();
}
Expand Down Expand Up @@ -15272,7 +15105,6 @@ var mainGC = function() {
[changed, changedData] = rcNoConfigDataDel('clipboard', false, changed, changedData);
[changed, changedData] = rcNoConfigDataDel('urlLogs', [], changed, changedData);
[changed, changedData] = rcNoConfigDataDel('headerReplacement', false, changed, changedData);
[changed, changedData] = rcNoConfigDataDel('whoFavorited', [], changed, changedData);
//<-- $$007
document.getElementById('rc_configData').innerText = changedData;
CONFIG = config_tmp;
Expand Down

0 comments on commit 88cb22b

Please sign in to comment.