FeXd / puzzle-chess

Find the best move.
http://puzzlechess.ca/
GNU General Public License v3.0
0 stars 0 forks source link

URL Parameters #25

Closed FeXd closed 9 months ago

FeXd commented 9 months ago

It would be nice to be able to load a specific puzzle based on the URL. Also once themes are created, loading a specific theme would be nice too.

This should be pretty easy with URLSearchParams

// Get the full URL (Example: https://puzzlechess.ca/?puzzle=123456&theme=kenny)
const url = new URL(window.location.href);

// Access the URLSearchParams object
const params = new URLSearchParams(url.search);

// Get values of 'puzzle' and 'theme'
const puzzle = params.get('puzzle'); // This would be '123456' for your example URL
const theme = params.get('theme'); // This would be 'kenny' for your example URL