diff --git a/requirements.txt b/requirements.txt index b963363..54df976 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,46 +1,15 @@ -annotated-types==0.6.0 -anyio==4.3.0 -arrow==1.3.0 asgiref==3.7.2 autopep8==2.0.4 -binaryornot==0.4.4 certifi==2024.2.2 -chardet==5.2.0 charset-normalizer==3.3.2 -click==8.1.7 -cookiecutter==2.6.0 -Django==5.0.2 +Django==5.0.3 django-browser-reload==1.12.1 django-tailwind==3.8.0 -fastapi==0.110.0 -h11==0.14.0 -httptools==0.6.1 idna==3.6 -Jinja2==3.1.3 -markdown-it-py==3.0.0 -MarkupSafe==2.1.5 -mdurl==0.1.2 numpy==1.26.4 -pyarrow==15.0.0 +pyarrow==15.0.1 pycodestyle==2.11.1 -pydantic==2.6.3 -pydantic_core==2.16.3 -Pygments==2.17.2 -python-dateutil==2.8.2 -python-dotenv==1.0.1 -python-slugify==8.0.4 -PyYAML==6.0.1 +pylance==0.10.2 requests==2.31.0 -rich==13.7.1 -six==1.16.0 -sniffio==1.3.1 sqlparse==0.4.4 -starlette==0.36.3 -text-unidecode==1.3 -types-python-dateutil==2.8.19.20240106 -typing_extensions==4.10.0 urllib3==2.2.1 -uvicorn==0.27.1 -uvloop==0.19.0 -watchfiles==0.21.0 -websockets==12.0 diff --git a/tunictracker/requirements.txt b/tunictracker/requirements.txt deleted file mode 100644 index 9f836be..0000000 --- a/tunictracker/requirements.txt +++ /dev/null @@ -1,27 +0,0 @@ -annotated-types==0.6.0 -anyio==4.3.0 -asgiref==3.7.2 -autopep8==2.0.4 -click==8.1.7 -Django==5.0.2 -django-browser-reload==1.12.1 -django-tailwind==3.8.0 -fastapi==0.110.0 -h11==0.14.0 -httptools==0.6.1 -idna==3.6 -numpy==1.26.4 -pyarrow==15.0.0 -pycodestyle==2.11.1 -pydantic==2.6.3 -pydantic_core==2.16.3 -python-dotenv==1.0.1 -PyYAML==6.0.1 -sniffio==1.3.1 -sqlparse==0.4.4 -starlette==0.36.3 -typing_extensions==4.10.0 -uvicorn==0.27.1 -uvloop==0.19.0 -watchfiles==0.21.0 -websockets==12.0 diff --git a/tunictracker/tracker/forms.py b/tunictracker/tracker/forms.py new file mode 100644 index 0000000..786103a --- /dev/null +++ b/tunictracker/tracker/forms.py @@ -0,0 +1,14 @@ +from django import forms +from json import loads + + +class ServerAddressForm(forms.Form): + with open('tracker/static/tracker/data/listen_address.json', 'r') as address: + read_address = loads(address.read()) + if (read_address['address']['user'] != ""): + server_address = read_address['address']['user'] + else: + server_address = read_address['address']['default'] + server_address_form = forms.URLField( + max_length=1312, initial=server_address, empty_value="http://localhost:8000/", label="") + server_address_form.widget.attrs["class"] = "w-full text-sm rounded-md border-2 border-bluelight-dark bg-[#242424]/10" diff --git a/tunictracker/tracker/static/tracker/assets/refresh.js b/tunictracker/tracker/static/tracker/assets/refresh.js index b8143da..e147546 100644 --- a/tunictracker/tracker/static/tracker/assets/refresh.js +++ b/tunictracker/tracker/static/tracker/assets/refresh.js @@ -1,7 +1,9 @@ var current_hash = ""; +var server_address = ""; window.onload = () => { - fetch("http://localhost:8080/static/tracker/data/holy_cross_codes.json") + get_updated_server_address(); + fetch(`${document.URL}static/tracker/data/holy_cross_codes.json`) .then((response) => response.json()) .then( (data) => { @@ -19,8 +21,26 @@ window.onload = () => { ); }; +async function get_updated_server_address() { + fetch(`${document.URL}static/tracker/data/listen_address.json`) + .then((response) => response.json()) + .then( + (data) => { + server_address_object = JSON.parse(JSON.stringify(data)); + if (server_address_object.user != "") { + server_address = server_address_object.address.user; + } else { + server_address = server_address_object.address.default; + } + document.getElementById("id_server_address_form").value = + server_address; + }, + (error) => console.log(error) + ); +} + async function refresh_elements(cross_codes) { - fetch("http://localhost:8000/spoiler") + fetch(server_address) .then((response) => response.json()) .then( (data) => { @@ -31,6 +51,7 @@ async function refresh_elements(cross_codes) { return; } else { current_hash = response_object.Debug.Hash; + get_updated_server_address(); } // Parse out data from the back-end into variables. @@ -319,7 +340,7 @@ async function refresh_elements(cross_codes) { scene_entrances_undiscovered <= 0 ) { summary_block.classList.add("hidden"); - breakdown_block.classList.add("hidden"); + // breakdown_block.classList.add("hidden"); } new_summary_list.firstElementChild.appendChild( summary_block.cloneNode(true) @@ -346,6 +367,7 @@ async function refresh_elements(cross_codes) { }, (error) => { document.getElementById("status-block").classList.remove("hidden"); + // get_updated_server_address(); return error; } ); diff --git a/tunictracker/tracker/static/tracker/data/listen_address.json b/tunictracker/tracker/static/tracker/data/listen_address.json new file mode 100644 index 0000000..192b9c2 --- /dev/null +++ b/tunictracker/tracker/static/tracker/data/listen_address.json @@ -0,0 +1 @@ +{"address": {"default": "http://localhost:8000/spoiler", "user": "http://localhost:8000/spoiler"}} \ No newline at end of file diff --git a/tunictracker/tracker/templates/tracker/address/index.html b/tunictracker/tracker/templates/tracker/address/index.html new file mode 100644 index 0000000..398f3e9 --- /dev/null +++ b/tunictracker/tracker/templates/tracker/address/index.html @@ -0,0 +1,13 @@ +
diff --git a/tunictracker/tracker/templates/tracker/index.html b/tunictracker/tracker/templates/tracker/index.html index 71a99f6..48aa444 100644 --- a/tunictracker/tracker/templates/tracker/index.html +++ b/tunictracker/tracker/templates/tracker/index.html @@ -15,6 +15,7 @@ Tunic Transition Tracker