DOMjudge / domjudge

DOMjudge programming contest jury system
https://www.domjudge.org
GNU General Public License v2.0
718 stars 254 forks source link

Favourite hearts on downloaded static scoreboard have no effect when opened as local file #2724

Open mpsijm opened 15 hours ago

mpsijm commented 15 hours ago

Description of the problem

When I download the "Public static scoreboard ZIP", it includes the favourite hearts. It appears that a cookie is used to store which teams are favourited, and the pinned teams are rendered client-side on page load. However, when opening the scoreboard's index.html as file in my browser, it does not work.

Your environment

DemoWeb

Steps to reproduce

  1. Download static scoreboard from https://www.domjudge.org/demoweb/jury/contests/7/public-scoreboard.zip
  2. Unzip it
  3. Open file:///home/[user]/Downloads/scoreboard/index.html in your browser
  4. Click a heart

Expected behaviour

The team is favourited and pinned to the top.

Actual behaviour

No visual change, and an error in the console: image

Any other information that you want to share?

Since everything is managed on the client and there is no server involved anymore, I expect that it is not necessary to make an XMLHttpRequest. Instead, the page should simply window.reload() after updating the cookie.

Note that this does work when serving the unzipped scoreboard folder using python3 -m http.server and accessing http://localhost:8000.

I'm also wondering why cookies are used instead of the browser's localStorage.

meisterT commented 15 hours ago

I'm also wondering why cookies are used instead of the browser's localStorage

No particular reason, I just didn't know any better