From a5a721b07cd7d8a5fd326de3d5bfd5ca3e311820 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Thu, 27 Aug 2020 21:10:56 +0100 Subject: [PATCH] Fix broken theme button after changing bootstrap version Also fix the theme cookie if it's for the wrong version. --- data/templates/admin.html | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/data/templates/admin.html b/data/templates/admin.html index 5b32df4..31b324e 100644 --- a/data/templates/admin.html +++ b/data/templates/admin.html @@ -35,16 +35,22 @@ {{ else }} const bsVersion = 4; {{ end }} - const cssFile = "{{ .cssFile }}"; + var cssFile = "{{ .cssFile }}"; var css = document.createElement('link'); css.setAttribute('rel', 'stylesheet'); css.setAttribute('type', 'text/css'); var cssCookie = getCookie("css"); if (cssCookie.includes('bs' + bsVersion)) { - css.setAttribute('href', cssCookie); - } else { - css.setAttribute('href', cssFile); - }; + cssFile = cssCookie; + } else if (cssCookie.includes('bs')) { + if (cssCookie.includes('jf')) { + cssFile = 'bs' + bsVersion + '-jf.css'; + } else { + cssFile = 'bs' + bsVersion + '.css'; + } + document.cookie = 'css=' + cssFile; + } + css.setAttribute('href', cssFile); document.head.appendChild(css); {{ if not .bs5 }}