From 5dbd6e8ecdb3047376f7237460ae7cafab3b3053 Mon Sep 17 00:00:00 2001 From: Th3C0D3R Date: Fri, 11 Dec 2020 09:08:51 +0100 Subject: [PATCH 1/2] Infoboard filter custom text --- js/web/infoboard/css/infoboard.css | 7 ++ js/web/infoboard/js/infoboard.js | 114 ++++++++++++++++------------- 2 files changed, 70 insertions(+), 51 deletions(-) diff --git a/js/web/infoboard/css/infoboard.css b/js/web/infoboard/css/infoboard.css index dfc4e4b48..cdc4c3f0d 100644 --- a/js/web/infoboard/css/infoboard.css +++ b/js/web/infoboard/css/infoboard.css @@ -182,3 +182,10 @@ table.info-table tr td { #BackgroundInfoTable .gbg-undefined td:first-child { background-image: url(../images/gbg-undefined.png); } + +input.textfilter{ + width: 100%; + width: -moz-available; /* WebKit-based browsers will ignore this. */ + width: -webkit-fill-available; /* Mozilla-based browsers will ignore this. */ + width: fill-available; +} \ No newline at end of file diff --git a/js/web/infoboard/js/infoboard.js b/js/web/infoboard/js/infoboard.js index 6278bcb17..33f7e2ee3 100644 --- a/js/web/infoboard/js/infoboard.js +++ b/js/web/infoboard/js/infoboard.js @@ -35,18 +35,17 @@ FoEproxy.addHandler('ConversationService', 'getOverview', (data, postData) => { MainParser.setConversations(data.responseData); }); -// when a great building where the player has invested has been levelled -FoEproxy.addHandler('BlueprintService','newReward', (data, postData) => { +// when a great building where the player has invested has been levelledFoEproxy.addHandler('BlueprintService', 'newReward', (data, postData) => { - if ( data && data['responseData'] && data['responseData'] ) { + if (data && data['responseData'] && data['responseData']) { // save the number of returned FPs to show in the infoboard message - Info.ReturnFPPoints = ( data['responseData']['strategy_point_amount'] ) ? data.responseData.strategy_point_amount : 0; + Info.ReturnFPPoints = (data['responseData']['strategy_point_amount']) ? data.responseData.strategy_point_amount : 0; // If the Info.OtherPlayerService_newEventgreat_building_contribution ran earlier than this // the ReturnFPPoints was 0 so no message was posted. Therefore recreate the message using // the stored data (and the correct value of Info.ReturnFPPoints) and post it - if ( Info.ReturnFPMessageData ){ - let bd = Info.OtherPlayerService_newEventgreat_building_contribution( Info.ReturnFPMessageData ); + if (Info.ReturnFPMessageData) { + let bd = Info.OtherPlayerService_newEventgreat_building_contribution(Info.ReturnFPMessageData); Info.ReturnFPMessageData = null; Infoboard.PostMessage(bd); } @@ -63,7 +62,8 @@ let Infoboard = { InjectionLoaded: false, PlayInfoSound: true, SoundFile: new Audio(extUrl + 'vendor/sounds/ping.mp3'), - SavedFilter: ["auction", "gex", "gbg", "trade", "level", "msg"], + SavedFilter: ["auction", "gex", "gbg", "trade", "level", "msg", "text"], + SavedTextFilter: "", DebugWebSocket: false, @@ -117,6 +117,12 @@ let Infoboard = { else Infoboard.SavedFilter = JSON.parse(localStorage.getItem("infoboxSavedFilter")); + if (localStorage.getItem("infoboxTextFilter") === null) + localStorage.setItem("infoboxTextFilter", Infoboard.SavedTextFilter); + else + Infoboard.SavedTextFilter = localStorage.getItem("infoboxTextFilter"); + + HTML.Box({ 'id': 'BackgroundInfo', 'title': i18n('Boxes.Infobox.Title'), @@ -132,7 +138,7 @@ let Infoboard = { } else { return HTML.CloseOpenBox('BackgroundInfo'); - } + } let div = $('#BackgroundInfo'), h = []; @@ -150,6 +156,7 @@ let Infoboard = { h.push('
  • '); h.push('
  • '); h.push('
  • '); + h.push('
  • '); h.push(''); h.push(''); @@ -178,7 +185,7 @@ let Infoboard = { msg: i18n('Boxes.Infobox.Messages.Welcome'), }); - $('#BackgroundInfo').on('click', '#infoboxTone', function() { + $('#BackgroundInfo').on('click', '#infoboxTone', function () { let disabled = $(this).hasClass('deactivated'); @@ -236,10 +243,11 @@ let Infoboard = { if ($('#BackgroundInfo').length > 0) { let status = $('input[data-type="' + bd['class'] + '"]').prop('checked'), + textfilter = $('input[data-type="text"]').val().split("|"), msg = bd['msg'], img = bd['img'], type = bd['type'], tr = $(''); - - // wenn nicht angezeigt werden soll, direkt verstecken - if (!status && bd.class !== 'welcome') { + + // wenn nicht angezeigt werden soll, direkt verstecken + if ((!status || !(textfilter.some(e => msg.includes(e)))) && bd.class !== 'welcome') { tr.hide(); } @@ -269,26 +277,30 @@ let Infoboard = { * */ FilterInput: () => { - $('#BackgroundInfo').on('change', '.filter-msg', function() { + $('#BackgroundInfo').on('change', '.filter-msg', function () { let active = []; - $('.filter-msg').each(function() { - if ($(this).is(':checked')) { + $('.filter-msg').each(function () { + if ($(this).is(':checked') || ($(this).data("type") === "text" && $(this).val() !== "")) { active.push($(this).data('type')); if (!Infoboard.SavedFilter.includes($(this).data('type'))) Infoboard.SavedFilter.push($(this).data('type')); - } else { + } + else { if (Infoboard.SavedFilter.includes($(this).data('type'))) Infoboard.SavedFilter.splice(Infoboard.SavedFilter.indexOf($(this).data('type')), 1); } }); localStorage.setItem("infoboxSavedFilter", JSON.stringify(Infoboard.SavedFilter)); - - $('#BackgroundInfoTable tbody tr').each(function() { - let tr = $(this), type = tr.attr('class'); - - if (active.some(e => type.startsWith(e)) || tr.hasClass('welcome')) { + localStorage.setItem("infoboxTextFilter", $('input[data-type="text"]').val()); + + $('#BackgroundInfoTable tbody tr').each(function () { + let tr = $(this), + textfilter = $('input[data-type="text"]').val().split("|"), + type = tr.attr('class'); + + if ((active.some(e => type.startsWith(e)) && textfilter.some(e => $(tr.children()[2]).html().includes(e))) || tr.hasClass('welcome')) { tr.show(); } else { tr.hide(); @@ -303,7 +315,7 @@ let Infoboard = { * */ ResetBox: () => { - $('#BackgroundInfo').on('click', '.btn-reset-box', function() { + $('#BackgroundInfo').on('click', '.btn-reset-box', function () { $('#BackgroundInfoTable tbody').html(''); }); } @@ -433,8 +445,8 @@ let Info = { */ GuildBattlegroundService_getProvinces: (d) => { - GildFights.PrepareColors(); - + GildFights.PrepareColors(); + let data = d[0]; let bP = GildFights.MapData['battlegroundParticipants'], @@ -462,12 +474,12 @@ let Info = { type: i18n('Boxes.Infobox.FilterGildFights'), msg: HTML.i18nReplacer( i18n('Boxes.Infobox.Messages.GildFightOccupied'), { - provinceName: prov['name'], - attackerColor: tc, - attackerShadow: ts, - attackerName: p['clan']['name'], - untilOccupied: moment.unix(data['lockedUntil']).format('HH:mm:ss') - }), + provinceName: prov['name'], + attackerColor: tc, + attackerShadow: ts, + attackerName: p['clan']['name'], + untilOccupied: moment.unix(data['lockedUntil']).format('HH:mm:ss') + }), img: 'gbg-lock' }; } @@ -497,14 +509,14 @@ let Info = { if (color) { let tc = colors['highlight'], sc = color['highlight'], ts = colors['shadow'], ss = color['shadow']; - - t += '' + p['clan']['name'] + ' ⚔️ ' + prov['name'] + ' (' + d['progress'] + '/' + d['maxProgress'] + ')
    '; + + t += '' + p['clan']['name'] + ' ⚔️ ' + prov['name'] + ' (' + d['progress'] + '/' + d['maxProgress'] + ')
    '; } else { let tc = colors['highlight'], ts = colors['shadow']; - t += '' + p['clan']['name'] + ' ⚔️ ' + prov['name'] + ' (' + d['progress'] + '/' + d['maxProgress'] + ')
    '; - + t += '' + p['clan']['name'] + ' ⚔️ ' + prov['name'] + ' (' + d['progress'] + '/' + d['maxProgress'] + ')
    '; + } if (image) { image = 'gbg-undefined'; @@ -537,19 +549,19 @@ let Info = { OtherPlayerService_newEventgreat_building_contribution: (d) => { let newFP = Info.ReturnFPPoints; - if ( d['rank'] >= 6 ){ newFP = 0; } + if (d['rank'] >= 6) { newFP = 0; } let data = { class: 'level', type: 'Level-Up', msg: HTML.i18nReplacer( i18n('Boxes.Infobox.Messages.LevelUp'), { - player: d['other_player']['name'], - building: d['great_building_name'], - level: d['level'], - rank: d['rank'], - fps: newFP - } + player: d['other_player']['name'], + building: d['great_building_name'], + level: d['level'], + rank: d['rank'], + fps: newFP + } ) }; @@ -557,7 +569,7 @@ let Info = { // so store the data and post the message from that handler (using the stored data) // ... but only if the rank is 5 and higher (1-5), otherwise, there is no reward // (and BlueprintService.newReward is not triggered) - if ( d['rank'] < 6 && Info.ReturnFPPoints == -1 ){ + if (d['rank'] < 6 && Info.ReturnFPPoints == -1) { Info.ReturnFPMessageData = d; return undefined; } @@ -582,12 +594,12 @@ let Info = { type: i18n('Boxes.Infobox.FilterTrade'), msg: HTML.i18nReplacer( i18n('Boxes.Infobox.Messages.Trade'), { - 'player': d['other_player']['name'], - 'offer': GoodsData[d['offer']['good_id']]['name'], - 'offerValue': d['offer']['value'], - 'need': GoodsData[d['need']['good_id']]['name'], - 'needValue': d['need']['value'] - } + 'player': d['other_player']['name'], + 'offer': GoodsData[d['offer']['good_id']]['name'], + 'offerValue': d['offer']['value'], + 'need': GoodsData[d['need']['good_id']]['name'], + 'needValue': d['need']['value'] + } ) } }, @@ -611,9 +623,9 @@ let Info = { type: 'GEX', msg: HTML.i18nReplacer( i18n('Boxes.Infobox.Messages.GEX'), { - 'player': d['player']['name'], - 'points': HTML.Format(d['expeditionPoints']) - } + 'player': d['player']['name'], + 'points': HTML.Format(d['expeditionPoints']) + } ) }; } From 2642ab9127a3cfb51eb422affd79003c604b9972 Mon Sep 17 00:00:00 2001 From: Th3C0D3R Date: Fri, 11 Dec 2020 09:09:20 +0100 Subject: [PATCH 2/2] upsi --- js/web/infoboard/js/infoboard.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/web/infoboard/js/infoboard.js b/js/web/infoboard/js/infoboard.js index 33f7e2ee3..274bd29f2 100644 --- a/js/web/infoboard/js/infoboard.js +++ b/js/web/infoboard/js/infoboard.js @@ -35,7 +35,8 @@ FoEproxy.addHandler('ConversationService', 'getOverview', (data, postData) => { MainParser.setConversations(data.responseData); }); -// when a great building where the player has invested has been levelledFoEproxy.addHandler('BlueprintService', 'newReward', (data, postData) => { +// when a great building where the player has invested has been levelled +FoEproxy.addHandler('BlueprintService', 'newReward', (data, postData) => { if (data && data['responseData'] && data['responseData']) { // save the number of returned FPs to show in the infoboard message