From 0e566d1883037719c4c8cfbde10cd77c49769b5e Mon Sep 17 00:00:00 2001 From: Tristan Schneider Date: Sun, 28 Nov 2021 10:35:22 +0000 Subject: [PATCH] fix broken admin site when no archives are present --- admin.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/admin.php b/admin.php index 413c547..732d0de 100644 --- a/admin.php +++ b/admin.php @@ -178,7 +178,12 @@ $config_data = json_decode($raw_json_config, false); } function defaultNewArchive() { - lastlink = document.getElementById("archive_links").lastElementChild.getAttribute("href"); + try { + lastlink = document.getElementById("archive_links").lastElementChild.getAttribute("href"); + } catch(err) { + // last link not found, perhaps there is no archive yet + lastlink = "sentences-archive-8-aug-00.txt" + } var re = /(\d+)-(\w\w\w)-(\d+)\.txt/; res = re.exec(lastlink);