Only load Chartist when we actually have a chart on the page.

This commit is contained in:
Azareal 2018-08-13 22:37:53 +10:00
parent 4c86c0a042
commit f2b210248a
2 changed files with 2 additions and 4 deletions

View File

@ -71,9 +71,6 @@ func ViewTopic(w http.ResponseWriter, r *http.Request, user common.User, urlBit
} }
header.Title = topic.Title header.Title = topic.Title
header.Zone = "view_topic" header.Zone = "view_topic"
// TODO: Only include these on pages with polls
header.AddSheet("chartist/chartist.min.css")
header.AddScript("chartist/chartist.min.js")
topic.ContentHTML = common.ParseMessage(topic.Content, topic.ParentID, "forums") topic.ContentHTML = common.ParseMessage(topic.Content, topic.ParentID, "forums")
topic.ContentLines = strings.Count(topic.Content, "\n") topic.ContentLines = strings.Count(topic.Content, "\n")
@ -97,6 +94,8 @@ func ViewTopic(w http.ResponseWriter, r *http.Request, user common.User, urlBit
return common.InternalError(err, w, r) return common.InternalError(err, w, r)
} }
poll = pPoll.Copy() poll = pPoll.Copy()
header.AddSheet("chartist/chartist.min.css")
header.AddScript("chartist/chartist.min.js")
} }
if topic.LikeCount > 0 && user.Liked > 0 { if topic.LikeCount > 0 && user.Liked > 0 {

View File

@ -9,7 +9,6 @@
<meta property="x-loggedin" content="{{.CurrentUser.Loggedin}}" /> <meta property="x-loggedin" content="{{.CurrentUser.Loggedin}}" />
<script type="text/javascript" src="/static/init.js"></script> <script type="text/javascript" src="/static/init.js"></script>
<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>
<script type="text/javascript" src="/static/chartist/chartist.min.js"></script>
{{range .Header.Scripts}} {{range .Header.Scripts}}
<script type="text/javascript" src="/static/{{.}}"></script> <script type="text/javascript" src="/static/{{.}}"></script>
{{end}} {{end}}