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..274bd29f2 100644 --- a/js/web/infoboard/js/infoboard.js +++ b/js/web/infoboard/js/infoboard.js @@ -36,17 +36,17 @@ FoEproxy.addHandler('ConversationService', 'getOverview', (data, postData) => { }); // when a great building where the player has invested has been levelled -FoEproxy.addHandler('BlueprintService','newReward', (data, postData) => { +FoEproxy.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 +63,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 +118,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 +139,7 @@ let Infoboard = { } else { return HTML.CloseOpenBox('BackgroundInfo'); - } + } let div = $('#BackgroundInfo'), h = []; @@ -150,6 +157,7 @@ let Infoboard = { h.push('
  • '); h.push('
  • '); h.push('
  • '); + h.push('
  • '); h.push(''); h.push(''); @@ -178,7 +186,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 +244,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 +278,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 +316,7 @@ let Infoboard = { * */ ResetBox: () => { - $('#BackgroundInfo').on('click', '.btn-reset-box', function() { + $('#BackgroundInfo').on('click', '.btn-reset-box', function () { $('#BackgroundInfoTable tbody').html(''); }); } @@ -433,8 +446,8 @@ let Info = { */ GuildBattlegroundService_getProvinces: (d) => { - GildFights.PrepareColors(); - + GildFights.PrepareColors(); + let data = d[0]; let bP = GildFights.MapData['battlegroundParticipants'], @@ -462,12 +475,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 +510,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 +550,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 +570,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 +595,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 +624,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']) + } ) }; }