Fix the control panel scripts.

This commit is contained in:
Azareal 2019-04-20 12:22:57 +10:00
parent b3c4cc4bfc
commit 114afe0b13
2 changed files with 18 additions and 14 deletions

View File

@ -218,20 +218,24 @@ function fetchPhrases(plist) {
runInitHook("pre_iife"); runInitHook("pre_iife");
let loggedIn = document.head.querySelector("[property='x-loggedin']").content == "true"; let loggedIn = document.head.querySelector("[property='x-loggedin']").content == "true";
let toLoad = 2; if(!window.location.pathname.startsWith("/panel/")) {
// TODO: Shunt this into loggedIn if there aren't any search and filter widgets? let toLoad = 2;
let q = (f) => { // TODO: Shunt this into loggedIn if there aren't any search and filter widgets?
toLoad--; let q = (f) => {
if(toLoad===0) initPhrases(loggedIn); toLoad--;
if(f) throw("template function not found"); if(toLoad===0) initPhrases(loggedIn);
}; if(f) throw("template function not found");
if(loggedIn) { };
toLoad += 2; if(loggedIn) {
notifyOnScriptW("template_topic_c_edit_post", () => q(!Template_topic_c_edit_post)); toLoad += 2;
notifyOnScriptW("template_topic_c_attach_item", () => q(!Template_topic_c_attach_item)); notifyOnScriptW("template_topic_c_edit_post", () => q(!Template_topic_c_edit_post));
notifyOnScriptW("template_topic_c_attach_item", () => q(!Template_topic_c_attach_item));
}
notifyOnScriptW("template_topics_topic", () => q(!Template_topics_topic));
notifyOnScriptW("template_paginator", () => q(!Template_paginator));
} else {
initPhrases(false);
} }
notifyOnScriptW("template_topics_topic", () => q(!Template_topics_topic));
notifyOnScriptW("template_paginator", () => q(!Template_paginator));
if(loggedIn) { if(loggedIn) {
fetch("/api/me/") fetch("/api/me/")

View File

@ -7,7 +7,7 @@
{{range .Header.PreScriptsAsync}} {{range .Header.PreScriptsAsync}}
<script async type="text/javascript" src="/static/{{.}}"></script>{{end}} <script async type="text/javascript" src="/static/{{.}}"></script>{{end}}
<meta property="x-loggedin" content="{{.CurrentUser.Loggedin}}" /> <meta property="x-loggedin" content="{{.CurrentUser.Loggedin}}" />
<script type="text/javascript" src="/static/init.js?i=1"></script> <script type="text/javascript" src="/static/init.js?i=2"></script>
{{range .Header.ScriptsAsync}} {{range .Header.ScriptsAsync}}
<script async type="text/javascript" src="/static/{{.}}"></script>{{end}} <script async type="text/javascript" src="/static/{{.}}"></script>{{end}}
<script type="text/javascript" src="/static/jquery-3.1.1.min.js"></script> <script type="text/javascript" src="/static/jquery-3.1.1.min.js"></script>