Compare commits

...

8 Commits

Author SHA1 Message Date
Michael Green
59173d8ae5 Merge branch 'main' into branch-v1.7.0 2024-04-16 11:51:21 +10:00
Michael Green
178f70cb98 Performance improvements to infinite scrolling (#347) 2024-04-16 11:39:58 +10:00
Michael Green
080a823cda Merge 1.7.3 into main (#331) 2024-04-15 14:38:17 +10:00
Michael Green
60dbaf85a4 Merge branch 'main' into branch-v1.7.0 2024-04-15 14:35:32 +10:00
Michael Green
8a80274030 Integrate EJS 4.0.12 - Adds a new Master System core, and a new DS core (#344)
Closes #340
2024-04-15 14:23:11 +10:00
Michael Green
7e8679151b Integrate EJS 4.0.12 - Adds a new Master System core, and a new DS core (#343)
Closes #340
2024-04-15 13:05:18 +10:00
Michael Green
123239cf58 Merge branch 'main' into branch-v1.7.0 2024-03-12 00:48:56 +11:00
Michael Green
111c501911 Fix for broken first run on fresh installs
* Fix for broken first run on fresh installs
2024-02-11 00:47:41 +11:00
7 changed files with 1937 additions and 3871 deletions

View File

@@ -17,8 +17,8 @@ RUN dotnet publish "gaseous-server/gaseous-server.csproj" --use-current-runtime
# download and unzip EmulatorJS from CDN # download and unzip EmulatorJS from CDN
RUN apt-get update && apt-get install -y p7zip-full RUN apt-get update && apt-get install -y p7zip-full
RUN mkdir -p out/wwwroot/emulators/EmulatorJS RUN mkdir -p out/wwwroot/emulators/EmulatorJS
RUN wget https://cdn.emulatorjs.org/releases/4.0.11.7z RUN wget https://cdn.emulatorjs.org/releases/4.0.12.7z
RUN 7z x -y -oout/wwwroot/emulators/EmulatorJS 4.0.11.7z RUN 7z x -y -oout/wwwroot/emulators/EmulatorJS 4.0.12.7z
# Build runtime image # Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 FROM mcr.microsoft.com/dotnet/aspnet:8.0

View File

@@ -43,7 +43,7 @@ namespace gaseous_server.Controllers
[MapToApiVersion("1.0")] [MapToApiVersion("1.0")]
[HttpGet] [HttpGet]
[ProducesResponseType(typeof(List<Game>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<Game>), StatusCodes.Status200OK)]
public ActionResult Game( public async Task<ActionResult> Game(
string name = "", string name = "",
string platform = "", string platform = "",
string genre = "", string genre = "",
@@ -303,7 +303,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(Game), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Game), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "5Minute")] [ResponseCache(CacheProfileName = "5Minute")]
public ActionResult Game(long GameId) public async Task<ActionResult> Game(long GameId)
{ {
try try
{ {
@@ -331,7 +331,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(List<AlternativeName>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<AlternativeName>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameAlternativeNames(long GameId) public async Task<ActionResult> GameAlternativeNames(long GameId)
{ {
try try
{ {
@@ -364,7 +364,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(List<AgeRatings.GameAgeRating>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<AgeRatings.GameAgeRating>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameAgeClassification(long GameId) public async Task<ActionResult> GameAgeClassification(long GameId)
{ {
try try
{ {
@@ -397,7 +397,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(List<Artwork>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<Artwork>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameArtwork(long GameId) public async Task<ActionResult> GameArtwork(long GameId)
{ {
try try
{ {
@@ -428,7 +428,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(Artwork), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Artwork), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameArtwork(long GameId, long ArtworkId) public async Task<ActionResult> GameArtwork(long GameId, long ArtworkId)
{ {
try try
{ {
@@ -464,7 +464,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/artwork/{ArtworkId}/image/{size}/{ImageName}")] [Route("{GameId}/artwork/{ArtworkId}/image/{size}/{ImageName}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameCoverImage(long GameId, long ArtworkId, Communications.IGDBAPI_ImageSize size, string ImageName) public async Task<ActionResult> GameCoverImage(long GameId, long ArtworkId, Communications.IGDBAPI_ImageSize size, string ImageName)
{ {
try try
{ {
@@ -531,7 +531,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(Cover), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Cover), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameCover(long GameId) public async Task<ActionResult> GameCover(long GameId)
{ {
try try
{ {
@@ -566,7 +566,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/cover/image/{size}/{imagename}")] [Route("{GameId}/cover/image/{size}/{imagename}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameCoverImage(long GameId, Communications.IGDBAPI_ImageSize size, string imagename = "") public async Task<ActionResult> GameCoverImage(long GameId, Communications.IGDBAPI_ImageSize size, string imagename = "")
{ {
try try
{ {
@@ -693,7 +693,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(List<Genre>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<Genre>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameGenre(long GameId) public async Task<ActionResult> GameGenre(long GameId)
{ {
try try
{ {
@@ -731,7 +731,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(List<Dictionary<string, object>>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<Dictionary<string, object>>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameInvolvedCompanies(long GameId) public async Task<ActionResult> GameInvolvedCompanies(long GameId)
{ {
try try
{ {
@@ -776,7 +776,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(Dictionary<string, object>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Dictionary<string, object>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameInvolvedCompanies(long GameId, long CompanyId) public async Task<ActionResult> GameInvolvedCompanies(long GameId, long CompanyId)
{ {
try try
{ {
@@ -818,7 +818,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/companies/{CompanyId}/image")] [Route("{GameId}/companies/{CompanyId}/image")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameCompanyImage(long GameId, long CompanyId) public async Task<ActionResult> GameCompanyImage(long GameId, long CompanyId)
{ {
try try
{ {
@@ -863,7 +863,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/platforms")] [Route("{GameId}/platforms")]
[ProducesResponseType(typeof(List<KeyValuePair<long, string>>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<KeyValuePair<long, string>>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GamePlatforms(long GameId) public async Task<ActionResult> GamePlatforms(long GameId)
{ {
try try
{ {
@@ -882,7 +882,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(List<ReleaseDate>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<ReleaseDate>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameReleaseDates(long GameId) public async Task<ActionResult> GameReleaseDates(long GameId)
{ {
try try
{ {
@@ -943,7 +943,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(Classes.Roms.GameRomItem), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Classes.Roms.GameRomItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
//[ResponseCache(CacheProfileName = "5Minute")] //[ResponseCache(CacheProfileName = "5Minute")]
public ActionResult GameRom(long GameId, long RomId) public async Task<ActionResult> GameRom(long GameId, long RomId)
{ {
try try
{ {
@@ -972,7 +972,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/roms/{RomId}")] [Route("{GameId}/roms/{RomId}")]
[ProducesResponseType(typeof(Classes.Roms.GameRomItem), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Classes.Roms.GameRomItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameRomRename(long GameId, long RomId, long NewPlatformId, long NewGameId) public async Task<ActionResult> GameRomRename(long GameId, long RomId, long NewPlatformId, long NewGameId)
{ {
try try
{ {
@@ -1002,7 +1002,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/roms/{RomId}")] [Route("{GameId}/roms/{RomId}")]
[ProducesResponseType(typeof(Classes.Roms.GameRomItem), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Classes.Roms.GameRomItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameRomDelete(long GameId, long RomId) public async Task<ActionResult> GameRomDelete(long GameId, long RomId)
{ {
try try
{ {
@@ -1034,7 +1034,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/roms/{RomId}/file")] [Route("{GameId}/roms/{RomId}/file")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameRomFile(long GameId, long RomId) public async Task<ActionResult> GameRomFile(long GameId, long RomId)
{ {
try try
{ {
@@ -1073,7 +1073,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/roms/{RomId}/{FileName}")] [Route("{GameId}/roms/{RomId}/{FileName}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameRomFile(long GameId, long RomId, string FileName) public async Task<ActionResult> GameRomFile(long GameId, long RomId, string FileName)
{ {
try try
{ {
@@ -1172,7 +1172,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/romgroup")] [Route("{GameId}/romgroup")]
[ProducesResponseType(typeof(Classes.RomMediaGroup.GameRomMediaGroupItem), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Classes.RomMediaGroup.GameRomMediaGroupItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult NewGameRomGroup(long GameId, long PlatformId, [FromBody] List<long> RomIds) public async Task<ActionResult> NewGameRomGroup(long GameId, long PlatformId, [FromBody] List<long> RomIds)
{ {
try try
{ {
@@ -1233,7 +1233,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/romgroup/{RomGroupId}")] [Route("{GameId}/romgroup/{RomGroupId}")]
[ProducesResponseType(typeof(Classes.RomMediaGroup.GameRomMediaGroupItem), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Classes.RomMediaGroup.GameRomMediaGroupItem), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameRomGroupDelete(long GameId, long RomGroupId) public async Task<ActionResult> GameRomGroupDelete(long GameId, long RomGroupId)
{ {
try try
{ {
@@ -1266,7 +1266,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/romgroup/{RomGroupId}/{filename}")] [Route("{GameId}/romgroup/{RomGroupId}/{filename}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameRomGroupFile(long GameId, long RomGroupId, string filename = "") public async Task<ActionResult> GameRomGroupFile(long GameId, long RomGroupId, string filename = "")
{ {
try try
{ {
@@ -1311,7 +1311,7 @@ namespace gaseous_server.Controllers
[Route("search")] [Route("search")]
[ProducesResponseType(typeof(List<Game>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<Game>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameSearch(long RomId = 0, string SearchString = "") public async Task<ActionResult> GameSearch(long RomId = 0, string SearchString = "")
{ {
try try
{ {
@@ -1352,7 +1352,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(List<Screenshot>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<Screenshot>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameScreenshot(long GameId) public async Task<ActionResult> GameScreenshot(long GameId)
{ {
try try
{ {
@@ -1383,7 +1383,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(Screenshot), StatusCodes.Status200OK)] [ProducesResponseType(typeof(Screenshot), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameScreenshot(long GameId, long ScreenshotId) public async Task<ActionResult> GameScreenshot(long GameId, long ScreenshotId)
{ {
try try
{ {
@@ -1417,7 +1417,7 @@ namespace gaseous_server.Controllers
[Route("{GameId}/screenshots/{ScreenshotId}/image/{size}/{ImageName}")] [Route("{GameId}/screenshots/{ScreenshotId}/image/{size}/{ImageName}")]
[ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)] [ProducesResponseType(typeof(FileStreamResult), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult GameScreenshotImage(long GameId, long ScreenshotId, Communications.IGDBAPI_ImageSize Size, string ImageName) public async Task<ActionResult> GameScreenshotImage(long GameId, long ScreenshotId, Communications.IGDBAPI_ImageSize Size, string ImageName)
{ {
try try
{ {
@@ -1468,7 +1468,7 @@ namespace gaseous_server.Controllers
[ProducesResponseType(typeof(List<GameVideo>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(List<GameVideo>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
[ResponseCache(CacheProfileName = "7Days")] [ResponseCache(CacheProfileName = "7Days")]
public ActionResult GameVideo(long GameId) public async Task<ActionResult> GameVideo(long GameId)
{ {
try try
{ {

View File

@@ -593,23 +593,29 @@ FROM
// build alpha list // build alpha list
Dictionary<string, int> AlphaList = new Dictionary<string, int>(); Dictionary<string, int> AlphaList = new Dictionary<string, int>();
int CurrentPage = 0; int CurrentPage = 1;
int NextPageIndex = 0; int NextPageIndex = pageSize;
for (int i = 0; i < dbResponse.Rows.Count; i++) for (int i = 0; i < dbResponse.Rows.Count; i++)
{ {
string firstChar = dbResponse.Rows[i]["NameThe"].ToString().Substring(0, 1).ToUpperInvariant(); string firstChar = dbResponse.Rows[i]["NameThe"].ToString().Substring(0, 1).ToUpperInvariant();
if (!"ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(firstChar)) if (!"ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(firstChar))
{ {
firstChar = "#"; if (!AlphaList.ContainsKey("#"))
{
AlphaList.Add("#", 1);
}
} }
if (!AlphaList.ContainsKey(firstChar)) else
{ {
AlphaList.Add(firstChar, CurrentPage); if (!AlphaList.ContainsKey(firstChar))
} {
if (NextPageIndex == i) AlphaList.Add(firstChar, CurrentPage);
{ }
NextPageIndex += pageSize; if (NextPageIndex == i + 1)
CurrentPage += 1; {
NextPageIndex += pageSize;
CurrentPage += 1;
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -72,6 +72,11 @@
</table> </table>
</td> </td>
</tr> </tr>
<tr>
<td>
<strong>Note</strong>: The page will need to be reloaded for changes to take effect.
</td>
</tr>
<tr> <tr>
<td style="text-align: right;"> <td style="text-align: right;">
<button id="profile_pref_ok" value="OK" onclick="SavePrefs();">OK</button> <button id="profile_pref_ok" value="OK" onclick="SavePrefs();">OK</button>
@@ -221,7 +226,7 @@
if (getQueryString('page', 'string') == 'home' || getQueryString('page', 'string') == undefined) { if (getQueryString('page', 'string') == 'home' || getQueryString('page', 'string') == undefined) {
setCookie('games_library_last_page', 1); setCookie('games_library_last_page', 1);
location.reload(); //location.reload();
} }
closeDialog(); closeDialog();

View File

@@ -405,7 +405,7 @@ function executeFilter1_1(pageNumber, pageSize) {
if (!pageSize) { if (!pageSize) {
switch (pageMode) { switch (pageMode) {
case "infinite": case "infinite":
pageSize = 5; pageSize = 30;
break; break;
case "paged": case "paged":
default: default:

View File

@@ -77,52 +77,54 @@ function formatGamesPanel(targetElement, result, pageNumber, pageSize, forceScro
break; break;
case 'infinite': case 'infinite':
var gamePlaceholders = document.getElementsByName('GamePlaceholder'); var gamePlaceholders = document.getElementsByName('GamePlaceholder');
let currentPageValue = 0;
let nextPageThreshold = -1;
for (var i = 0; i < result.count; i++) {
if (i >= nextPageThreshold) {
// new page
currentPageValue ++;
nextPageThreshold = i + pageSize;
if (currentPageValue > 0) { let currentPage = 1;
if (!document.getElementById('pageFooterAnchor' + (currentPageValue - 1))) { let totalPages = Math.ceil(result.count / pageSize);
let newFooterPageAnchor = document.createElement('a'); let startIndex = 0;
newFooterPageAnchor.id = 'pageFooterAnchor' + (currentPageValue - 1); let endIndex = pageSize;
newFooterPageAnchor.setAttribute('name', 'pageAnchor' + (currentPageValue - 1)); for (let p = currentPage; p < totalPages + 1; p++) {
newFooterPageAnchor.className = 'pageFooterAnchor'; //console.log("Page: " + p + " - StartIndex: " + startIndex + " - EndIndex: " + endIndex);
newFooterPageAnchor.setAttribute('data-page', (currentPageValue - 1));
newFooterPageAnchor.setAttribute('data-loaded', "0"); let newPageAnchor = document.getElementById('pageAnchor' + p);
targetElement.appendChild(newFooterPageAnchor); if (!newPageAnchor) {
newPageAnchor = document.createElement('span');
newPageAnchor.id = 'pageAnchor' + p;
newPageAnchor.setAttribute('name', 'pageAnchor' + p);
newPageAnchor.className = 'pageAnchor';
newPageAnchor.setAttribute('data-page', p);
newPageAnchor.setAttribute('data-loaded', "0");
targetElement.appendChild(newPageAnchor);
}
if (endIndex > result.count) {
endIndex = result.count;
}
for (let i = startIndex; i < endIndex; i++) {
var placeHolderpresent = false;
for (var x = 0; x < gamePlaceholders.length; x++) {
if (gamePlaceholders[x].getAttribute('data-index') == i) {
placeHolderpresent = true;
} }
} }
if (placeHolderpresent == false) {
if (!document.getElementById('pageAnchor' + currentPageValue)) { var gamePlaceholder = document.createElement('div');
let newPageAnchor = document.createElement('a'); gamePlaceholder.setAttribute('name', 'GamePlaceholder');
newPageAnchor.id = 'pageAnchor' + currentPageValue; gamePlaceholder.id = 'GamePlaceholder' + i;
newPageAnchor.setAttribute('name', 'pageAnchor' + currentPageValue); gamePlaceholder.setAttribute('data-index', i);
newPageAnchor.className = 'pageAnchor'; gamePlaceholder.className = 'game_tile';
newPageAnchor.setAttribute('data-page', currentPageValue); newPageAnchor.appendChild(gamePlaceholder);
newPageAnchor.setAttribute('data-loaded', "0");
targetElement.appendChild(newPageAnchor);
} }
} }
var placeHolderpresent = false; startIndex = endIndex;
for (var x = 0; x < gamePlaceholders.length; x++) { endIndex = startIndex + pageSize;
if (gamePlaceholders[x].getAttribute('data-index') == i) {
placeHolderpresent = true; if (startIndex > result.count) {
} break;
}
if (placeHolderpresent == false) {
var gamePlaceholder = document.createElement('div');
gamePlaceholder.setAttribute('name', 'GamePlaceholder');
gamePlaceholder.id = 'GamePlaceholder' + i;
gamePlaceholder.setAttribute('data-index', i);
gamePlaceholder.className = 'game_tile';
targetElement.appendChild(gamePlaceholder);
} }
} }
break; break;
} }
@@ -160,6 +162,8 @@ function formatGamesPanel(targetElement, result, pageNumber, pageSize, forceScro
break; break;
} }
$(game).fadeIn(500);
} }
var pager = document.getElementById('games_pager'); var pager = document.getElementById('games_pager');
@@ -173,7 +177,7 @@ function formatGamesPanel(targetElement, result, pageNumber, pageSize, forceScro
for (const [key, value] of Object.entries(result.alphaList)) { for (const [key, value] of Object.entries(result.alphaList)) {
var letterPager = document.createElement('span'); var letterPager = document.createElement('span');
letterPager.className = 'games_library_alpha_pager_letter'; letterPager.className = 'games_library_alpha_pager_letter';
letterPager.setAttribute('onclick', 'document.location.hash = "#pageAnchor' + value + '"; executeFilter1_1(' + value + ');'); letterPager.setAttribute('onclick', 'document.location.hash = "#pageAnchor' + (value) + '"; executeFilter1_1(' + (value) + ');');
letterPager.innerHTML = key; letterPager.innerHTML = key;
alphaPager.appendChild(letterPager); alphaPager.appendChild(letterPager);
} }
@@ -289,8 +293,13 @@ function formatGamesPanel(targetElement, result, pageNumber, pageSize, forceScro
$('.lazy').Lazy({ $('.lazy').Lazy({
effect: 'show', effect: 'show',
effectTime: 100, effectTime: 500,
visibleOnly: true visibleOnly: true,
defaultImage: '/images/unknowngame.png',
delay: 250,
afterLoad: function(element) {
//console.log(element[0].getAttribute('data-id'));
}
}); });
} }
@@ -306,13 +315,24 @@ function isScrolledIntoView(elem) {
} }
} }
const elementIsVisibleInViewport = (el, partiallyVisible = false) => {
const { top, left, bottom, right } = el.getBoundingClientRect();
const { innerHeight, innerWidth } = window;
return partiallyVisible
? ((top > 0 && top < innerHeight) ||
(bottom > 0 && bottom < innerHeight)) &&
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
: top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
};
function IsInView() { function IsInView() {
var pageMode = GetPreference('LibraryPagination', 'paged'); var pageMode = GetPreference('LibraryPagination', 'paged');
switch (pageMode) { switch (pageMode) {
case "paged": case "paged":
var loadElement = document.getElementById('games_library_loadmore'); var loadElement = document.getElementById('games_library_loadmore');
if (loadElement) { if (loadElement) {
if (isScrolledIntoView(loadElement)) { //if (isScrolledIntoView(loadElement)) {
if (elementIsVisibleInViewport(loadElement, true)) {
var pageNumber = Number(document.getElementById('games_library_loadmore').getAttribute('data-pagenumber')); var pageNumber = Number(document.getElementById('games_library_loadmore').getAttribute('data-pagenumber'));
var pageSize = document.getElementById('games_library_loadmore').getAttribute('data-pagesize'); var pageSize = document.getElementById('games_library_loadmore').getAttribute('data-pagesize');
executeFilter1_1(pageNumber); executeFilter1_1(pageNumber);
@@ -326,17 +346,14 @@ function IsInView() {
// load page // load page
let anchors = document.getElementsByClassName('pageAnchor'); let anchors = document.getElementsByClassName('pageAnchor');
let footAnchors = document.getElementsByClassName('pageFooterAnchor');
for (let i = 0; i < anchors.length; i++) { for (let i = 0; i < anchors.length; i++) {
if (isScrolledIntoView(anchors[i]) && anchors[i].getAttribute('data-loaded') == "0") { //if (isScrolledIntoView(anchors[i])) {
document.getElementById(anchors[i].id).setAttribute('data-loaded', "1"); if (elementIsVisibleInViewport(anchors[i], true)) {
executeFilter1_1(Number(anchors[i].getAttribute('data-page'))); if (anchors[i].getAttribute('data-loaded') == "0") {
} console.log("Loading page: " + anchors[i].getAttribute('data-page'));
} document.getElementById(anchors[i].id).setAttribute('data-loaded', "1");
for (let i = 0; i < footAnchors.length; i++) { executeFilter1_1(Number(anchors[i].getAttribute('data-page')));
if (isScrolledIntoView(footAnchors[i]) && footAnchors[i].getAttribute('data-loaded') == "0") { }
document.getElementById(footAnchors[i].id).setAttribute('data-loaded', "1");
executeFilter1_1(Number(footAnchors[i].getAttribute('data-page')));
} }
} }
break; break;
@@ -360,12 +377,14 @@ function renderGameIcon(gameObject, showTitle, showRatings, showClassification,
gameBox.classList.add(...classes['game_tile']); gameBox.classList.add(...classes['game_tile']);
} }
gameBox.setAttribute('onclick', 'window.location.href = "/index.html?page=game&id=' + gameObject.id + '";'); gameBox.setAttribute('onclick', 'window.location.href = "/index.html?page=game&id=' + gameObject.id + '";');
gameBox.style.display = 'none';
var gameImageBox = document.createElement('div'); var gameImageBox = document.createElement('div');
gameImageBox.classList.add(...classes['game_tile_box']); gameImageBox.classList.add(...classes['game_tile_box']);
var gameImage = document.createElement('img'); var gameImage = document.createElement('img');
gameImage.id = 'game_tile_cover_' + gameObject.id; gameImage.id = 'game_tile_cover_' + gameObject.id;
gameImage.setAttribute('data-id', gameObject.id);
if (useSmallCover == true) { if (useSmallCover == true) {
gameImage.classList.add(...classes['game_tile_image game_tile_image_small lazy']); gameImage.classList.add(...classes['game_tile_image game_tile_image_small lazy']);
} else { } else {