From 28c1306f6d5b8bd5873630fff30fea21771b0243 Mon Sep 17 00:00:00 2001 From: Wotuu Date: Fri, 31 Jan 2025 12:47:26 +0100 Subject: [PATCH 1/6] #2693 Hotfix for GameServerRegions not working properly. --- app/Models/GameServerRegion.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/GameServerRegion.php b/app/Models/GameServerRegion.php index 75a85d11e..78bfdf4a2 100644 --- a/app/Models/GameServerRegion.php +++ b/app/Models/GameServerRegion.php @@ -115,6 +115,6 @@ public function getRegionEpochByDate(Carbon $dateTime): ?Carbon return Carbon::parse(self::EU_EPOCH_CHANGE_DATE); } - return $this->epoch_start; + return Carbon::parse($this->epoch_start); } } From 2c0a1b4595e043b2bdf418bf14267ecc72d0c727 Mon Sep 17 00:00:00 2001 From: Wouter Koppenol Date: Fri, 31 Jan 2025 14:21:10 +0100 Subject: [PATCH 2/6] #2682 Explore embed page can now be controlled through an iframe. --- .../js/custom/inline/base/searchinlinebase.js | 17 ++++++ .../common/maps/heatmapsearchsidebar.js | 10 +++- .../dungeon/explore/gameversion/embed.js | 56 +++++++++++++++++++ .../explore/gameversion/embed.blade.php | 6 +- resources/views/misc/embed.blade.php | 12 +++- resources/views/misc/embedexplore.blade.php | 8 ++- 6 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 resources/assets/js/custom/inline/dungeon/explore/gameversion/embed.js diff --git a/resources/assets/js/custom/inline/base/searchinlinebase.js b/resources/assets/js/custom/inline/base/searchinlinebase.js index 4133b220e..64fa83336 100644 --- a/resources/assets/js/custom/inline/base/searchinlinebase.js +++ b/resources/assets/js/custom/inline/base/searchinlinebase.js @@ -26,6 +26,17 @@ class SearchInlineBase extends InlineCode { let queryParams = getQueryParams(); // Restore URL -> filters values + this._restoreFiltersFromQueryParams(queryParams); + } + + /** + * + * @param queryParams + * @protected + */ + _restoreFiltersFromQueryParams(queryParams) { + console.assert(this instanceof SearchInlineBase, 'this is not a SearchInlineBase!', this); + for (let key in queryParams) { let filtersKey = key.replace('[]', ''); let valueAssigned = false; @@ -58,6 +69,8 @@ class SearchInlineBase extends InlineCode { * @protected */ _updateFilters() { + console.assert(this instanceof SearchInlineBase, 'this is not a SearchInlineBase!', this); + if (typeof this.options.currentFiltersSelector === 'undefined') { return; } @@ -97,6 +110,8 @@ class SearchInlineBase extends InlineCode { * @protected */ _updateUrl(searchParams, blacklist = []) { + console.assert(this instanceof SearchInlineBase, 'this is not a SearchInlineBase!', this); + let urlParams = []; blacklist.push('offset'); @@ -125,6 +140,8 @@ class SearchInlineBase extends InlineCode { * @protected */ _search(options = {}, queryParameters = {}, queryParametersUrlBlacklist = []) { + console.assert(this instanceof SearchInlineBase, 'this is not a SearchInlineBase!', this); + let searchParams = new SearchParams(this.filters, queryParameters); this._updateFilters(); diff --git a/resources/assets/js/custom/inline/common/maps/heatmapsearchsidebar.js b/resources/assets/js/custom/inline/common/maps/heatmapsearchsidebar.js index e1f420d5b..c8ce7d202 100644 --- a/resources/assets/js/custom/inline/common/maps/heatmapsearchsidebar.js +++ b/resources/assets/js/custom/inline/common/maps/heatmapsearchsidebar.js @@ -104,8 +104,6 @@ class CommonMapsHeatmapsearchsidebar extends SearchInlineBase { 'duration': new SearchFilterDuration(this.options.filterDurationSelector, this._search.bind(this), this.options.durationMin, this.options.durationMax), }; - console.log($(this.options.filterWeeklyAffixGroupsSelector).length); - this._setupFilterCollapseCookies(); this._setupLeafletHeatOptions(); } @@ -205,6 +203,12 @@ class CommonMapsHeatmapsearchsidebar extends SearchInlineBase { this._search(); } + searchWithFilters(filters) { + this._restoreFiltersFromQueryParams(filters); + + this._search(); + } + _toggleHeatmap(enabled) { console.assert(this instanceof CommonMapsHeatmapsearchsidebar, 'this is not a CommonMapsHeatmapsearchsidebar', this); this.map.pluginHeat.toggle(enabled); @@ -212,7 +216,7 @@ class CommonMapsHeatmapsearchsidebar extends SearchInlineBase { Cookies.set(this.options.enabledStateCookie, (enabled ? 1 : 0) + '', cookieDefaultAttributes); } - _search(queryParameters, options) { + _search() { console.assert(this instanceof CommonMapsHeatmapsearchsidebar, 'this is not a CommonMapsHeatmapsearchsidebar', this); if (this.initializing) { diff --git a/resources/assets/js/custom/inline/dungeon/explore/gameversion/embed.js b/resources/assets/js/custom/inline/dungeon/explore/gameversion/embed.js new file mode 100644 index 000000000..93c915be9 --- /dev/null +++ b/resources/assets/js/custom/inline/dungeon/explore/gameversion/embed.js @@ -0,0 +1,56 @@ +class DungeonExploreGameversionEmbed extends InlineCode { + + /** + */ + activate() { + super.activate(); + + let validHostnames = [ + 'localhost', + 'keystone.guru', + 'raider.io' + ]; + + window.addEventListener('message', (event) => { + let hostname = (new URL(event.origin)).hostname; + + let isValidHostname = false; + for (let index in validHostnames) { + let validHostname = validHostnames[index]; + if (hostname.endsWith(`.${validHostname}`) || hostname === validHostname) { + isValidHostname = true; + break; + } + } + + if (!isValidHostname) { + console.warn('Invalid hostname - not processing message!'); + return false; + } + + if (typeof event.data.function === 'undefined' || event.data.function === null) { + console.error(`Must pass a function to call!`); + return false; + } + + if (event.data.function === 'setFilters') { + /** @type CommonMapsHeatmapsearchsidebar|false */ + let inlineCode = _inlineManager.getInlineCode('common/maps/heatmapsearchsidebar'); + if (!inlineCode) { + console.error('Unable to find sidebar!'); + return false; + } + + delete event.data.function; + + console.log('Applying filters', event.data); + inlineCode.searchWithFilters(event.data); + } + + return true; + }); + } + + cleanup() { + } +} diff --git a/resources/views/dungeon/explore/gameversion/embed.blade.php b/resources/views/dungeon/explore/gameversion/embed.blade.php index f99710b64..5b9034b4e 100644 --- a/resources/views/dungeon/explore/gameversion/embed.blade.php +++ b/resources/views/dungeon/explore/gameversion/embed.blade.php @@ -35,11 +35,15 @@ 'cookieConsent' => false, ]) +@include('common.general.inline', ['path' => 'dungeon/explore/gameversion/embed', 'options' => [ + 'dependencies' => ['common/maps/map'], +]]) + @include('common.general.inline', ['path' => 'common/maps/embedtopbar', 'options' => [ 'dependencies' => ['common/maps/map'], 'switchDungeonFloorSelect' => '#map_floor_selection_dropdown', 'defaultSelectedFloorId' => $floor->id, - 'mdtStringCopyEnabled' => $dungeon->mdt_supported, + 'mdtStringCopyEnabled' => false, ]]) @section('content') diff --git a/resources/views/misc/embed.blade.php b/resources/views/misc/embed.blade.php index 551ecbfc1..c443cd238 100644 --- a/resources/views/misc/embed.blade.php +++ b/resources/views/misc/embed.blade.php @@ -18,7 +18,9 @@
@if(!empty($parameters)) - @elseif($showStyle === 'compact') - @elseif($showStyle === 'regular') - @elseif($showStyle === 'compact') -