summaryrefslogtreecommitdiffstats
path: root/layouts/partials/scripts-end.html
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/partials/scripts-end.html')
-rw-r--r--layouts/partials/scripts-end.html152
1 files changed, 7 insertions, 145 deletions
diff --git a/layouts/partials/scripts-end.html b/layouts/partials/scripts-end.html
index 39b3a00..220ee93 100644
--- a/layouts/partials/scripts-end.html
+++ b/layouts/partials/scripts-end.html
@@ -1,152 +1,14 @@
-<script>
- // toggle theme
- function toggleTheme() {
- $('body').attr('data-theme', (index, attr) => {
- if (attr === 'light') {
- localStorage.setItem('fuji_theme', 'dark');
- return 'dark';
- } else {
- localStorage.setItem('fuji_theme', 'light');
- return 'light';
- }
- });
- }
- // update medium-zoom theme
- // @params fujiTheme, mediumEvent
- function updateMeidumTheme(fujiTheme, mediumEvent) {
- if (fujiTheme && mediumEvent) {
- mediumEvent.detach();
- let mediumTheme;
- if (fujiTheme === 'dark') {
- mediumTheme = '#2f3136';
- } else {
- mediumTheme = '#fffffd';
- }
- mediumEvent = mediumZoom('.img-zoomable', {
- background: mediumTheme
- });
- }
- }
- // update utterances theme
- // @params fujiTheme, utterancesFrame
- function updateUtterancesTheme(fujiTheme, utterancesFrame) {
- if (fujiTheme && utterancesFrame) {
- let ifMessage;
- if (fujiTheme === 'dark') {
- ifMessage = {
- type: 'set-theme',
- theme: 'photon-dark'
- };
- } else {
- ifMessage = {
- type: 'set-theme',
- theme: 'github-light'
- };
- }
- utterancesFrame.contentWindow.postMessage(ifMessage, 'https://utteranc.es');
- }
- }
-</script>
-
-<script>
- // toc anchors & to-top button
- $('.btn .btn-scroll-top').on('click', () => {
- $('html, body').animate({
- scrollTop: 0,
- });
- });
- $('.sidebar-toc a').on('click', (event) => {
- $('html, body').animate({
- scrollTop: $($(event.currentTarget).attr('href')).offset().top
- });
- });
-
- // init medium-zoom
- var mediumTheme;
- if ($('body').attr('data-theme') === 'dark') {
- mediumTheme = '#2f3136';
- } else {
- mediumTheme = '#fffffd';
- }
- var mediumEvent = mediumZoom('.img-zoomable', {
- background: mediumTheme
- });
-
- hljs.initHighlightingOnLoad();
-
- // remove empty ul in toc if article only have ## and ###
- if ($('.sidebar-toc ul ul').length > 0 && $('.sidebar-toc ul ul li').text() === '') {
- $('.sidebar-toc ul ul').hide();
- }
-
- // init highlight.js
- hljs.initHighlighting();
-</script>
-
-{{ if and (and (ne .Params.noComments true) (.IsPage)) (.Site.Params.utterancesRepo) }}
-<script>
- // utterances comment loading indicator
- var commentStatus; // utterence status
- var commentLoadingTime = 0; // loading time passed
- var commentCheckInterval = self.setInterval(checkUtterances, 500);
-
- function checkUtterances() {
- commentStatus = $('.post-comment .utterances').attr('style');
- if (commentStatus) {
- clearInterval(commentCheckInterval);
- updateUtterancesTheme($('body').attr('data-theme'), $('.post-comment iframe')[0])
- $('.post-loading').hide();
- } else {
- if (++commentLoadingTime > 20) {
- clearInterval(commentCheckInterval);
- $('.post-comment').hide();
- $('.post-loading p').text('{{ i18n "postCommentLoadingFailed" }}');
- $('.post-loading i').attr('class', 'far fa-times-circle');
- }
- }
- }
-
- // theme switch button
- $('.btn .btn-toggle-mode').on('click', () => {
- // toggle theme
- toggleTheme();
- // update medium background
- updateMeidumTheme($('body').attr('data-theme'), mediumEvent);
- // update utterances theme if available
- if (commentStatus) {
- updateUtterancesTheme($('body').attr('data-theme'), $('.post-comment iframe')[0]);
- }
- });
-</script>
-{{ else if and (and (ne .Params.noComments true) (.IsPage)) (.Site.Params.disqusShortname) }}
-<script>
- // theme switch button
- $('.btn .btn-toggle-mode').on('click', () => {
- // toggle theme
- toggleTheme();
- // update medium background
- updateMeidumTheme($('body').attr('data-theme'), mediumEvent);
- // update disqus theme if available
- if (DISQUS) {
- DISQUS.reset({
- reload: true
- });
- }
- });
-</script>
+<script src="https://cdn.jsdelivr.net/npm/lazysizes@5.2.2/lazysizes.min.js"></script>
+<script src="https://cdn.jsdelivr.net/npm/medium-zoom@1.0.5/dist/medium-zoom.min.js"></script>
+{{ if .Site.Params.customHighlight }}
+<script src="{{ .Site.Params.customHighlightURL | relURL }}"></script>
{{ else }}
-<script>
- // theme switch button
- $('.btn .btn-toggle-mode').on('click', () => {
- // toggle theme
- toggleTheme();
- // update medium background
- updateMeidumTheme($('body').attr('data-theme'), mediumEvent);
- });
-</script>
+<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.0.3/build/highlight.min.js"></script>
{{ end }}
+<script src="{{ "/assets/js/fuji.dev.js" | relURL }}"></script>
{{ with .Params.playerURL }}
+<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script>
<script>
// in-post aplayer
var aPlayer = new APlayer({