[X] Cleanup the javascript codes so it makes more sense
[X] Fixed the bug where site redirects itself 2 times
[X] Added code so the url is properly constructed and pushed to broswer history
[X] Added code so that clicking "back" button in browser will trigger datasheets/gallery page number to change.
Testing this PR.
Go to site page
Go to a site with a lot of datasheet and gallery data (might need to manually add them)
Click on the page number for both datasheet and gallery, and check the url in the browser. Make sure the change according to the page number clicked.
Important: The url parameter should be: "..../site_name/?datasheet={1}&gallery={2}" where {1} is the datasheet page number, and {2} is gallery page number. For each parameter in the url (datasheet/gallery), if the page number is 1, it should not appear.
Click "back" or "forward" button on browser repeatedly, make sure the page number you clicked are stored in history.
Manually input a test url to that specific site into browser, with different page numbers for each parameter (Make sure to test page numbers that are out of range). If the page number is out of range in url, the datasheet/gallery table page should load page number 1.
Make sure the rest of the page's functionality are not affected.
Expected Output.
The url changes according to the page number clicked.
Clicking "back" "forward" button in browser, the page number are stored and works properly.
Manually inputting url with invalid page number, and the page numbers are not affected and page number 1 is highlighted.
fixes issue #656 Tested on: Chrome, Firefox, Safari (desktop & iphone), Edge
Changes in this PR.
Testing this PR.
Go to site page
Go to a site with a lot of datasheet and gallery data (might need to manually add them)
Click on the page number for both datasheet and gallery, and check the url in the browser. Make sure the change according to the page number clicked. Important: The url parameter should be: "..../site_name/?datasheet={1}&gallery={2}" where {1} is the datasheet page number, and {2} is gallery page number. For each parameter in the url (datasheet/gallery), if the page number is 1, it should not appear.
Click "back" or "forward" button on browser repeatedly, make sure the page number you clicked are stored in history.
Manually input a test url to that specific site into browser, with different page numbers for each parameter (Make sure to test page numbers that are out of range). If the page number is out of range in url, the datasheet/gallery table page should load page number 1.
Make sure the rest of the page's functionality are not affected.
Expected Output.
@osuosl/devs