From ef61e162799411535a48664948b57a2a8ff5dc21 Mon Sep 17 00:00:00 2001 From: cyfraeviolae Date: Thu, 18 Jan 2024 19:36:06 -0500 Subject: optimize --- static/script.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'static') diff --git a/static/script.js b/static/script.js index 198bd72..a4c5d09 100644 --- a/static/script.js +++ b/static/script.js @@ -224,17 +224,6 @@ document.getElementById('give-up').addEventListener('click', function(evt) { giveUp(); }); - -window.onload = function() { - var urlParams = new URLSearchParams(window.location.search); - var q = urlParams.get('q') - if (q) { - startBoard(deserializeBoard(q)); - return; - } - startBoard(newBoard()); -} - // Source: https://stackoverflow.com/a/19270021 function randomSelect(arr, n) { var result = new Array(n), @@ -268,3 +257,11 @@ function shuffle(array) { return array; } + +var urlParams = new URLSearchParams(window.location.search); +var q = urlParams.get('q') +if (q) { + startBoard(deserializeBoard(q)); +} else { + startBoard(newBoard()); +} -- cgit v1.2.3