summaryrefslogtreecommitdiffstats
path: root/layouts/partials/scripts.html
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/partials/scripts.html')
-rw-r--r--layouts/partials/scripts.html97
1 files changed, 48 insertions, 49 deletions
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html
index e807e36..2f83c91 100644
--- a/layouts/partials/scripts.html
+++ b/layouts/partials/scripts.html
@@ -1,18 +1,7 @@
-<!-- Comment loading indicator -->
-{{ if and (.IsPage) (.Site.Params.utterancesComment) }}
+{{ if and (.IsPage) (.Site.Params.utterancesRepo) }}
+<!-- comment loading indicator -->
<script>
$(function () {
- var loadingBar = new ProgressBar.Circle('#loading-bar', {
- color: '#8AA2D3',
- strokeWidth: 15,
- trailColor: '#E5E2E4',
- trailWidth: 15,
- fill: '#E5E2E4'
- });
- loadingBar.animate(1.0, {
- duration: 10000
- });
-
var commentStatus;
var commentLoadingTime = 0;
var commentCheckInterval = self.setInterval(checkUtterances, 500);
@@ -25,61 +14,71 @@
clearInterval(commentCheckInterval);
$('#post-comment').hide();
$('#post-loading p').text('{{ i18n "postCommentLoadingFailed" }}');
+ $('#post-loading i').attr("class", "far fa-times-circle");
}
return;
} else {
clearInterval(commentCheckInterval);
- loadingBar.animate(1.0, {
- duration: 500
- }, function () {
- $('#post-loading').hide();
- });
+ $('#post-loading').hide();
}
}
});
</script>
{{ end }}
-<!-- Scroll to top button -->
-{{ if .Site.Params.scrollTop }}
+{{ with .Params.playerURL }}
<script>
$(function () {
- var bar = new ProgressBar.Circle('#progress', {
- color: '#8AA2D3',
- strokeWidth: 12,
- trailColor: '#E5E2E4',
- trailWidth: 12,
- text: {
- value: '{{ partial "fas/fa-angle-up" . }}',
- autoStyleContainer: false,
- style: null
- },
- fill: '#E5E2E4'
+ const postAPlayer = new APlayer({
+ container: document.getElementById("post-aplayer"),
+ theme: "#8F82BC",
+ volume: 0.25,
+ audio: [{
+ name: "{{ $.Params.playerName }}",
+ artist: "{{ $.Params.playerArtist }}",
+ url: "{{ . }}",
+ cover: "{{ $.Params.playerCover }}"
+ }]
});
- var scrolled = ($(window).scrollTop() / ($(document).height() - $(window).height() - 1));
- bar.animate(scrolled);
- $(window).scroll(function () {
- scrolled = ($(window).scrollTop() / ($(document).height() - $(window).height() - 1));
- if (scrolled < 0.0005) {
- scrolled = 0;
- } else if (scrolled > 1) {
- scrolled = 1;
- }
- bar.set(scrolled);
+ });
+</script>
+{{ end }}
+{{ with .Site.Params.playerURL }}
+<script>
+ $(function () {
+ const siteAPlayer = new APlayer({
+ container: document.getElementById("aplayer"),
+ fixed: true,
+ theme: "#8F82BC",
+ volume: 0.25,
+ audio: [{
+ name: "{{ $.Site.Params.playerName }}",
+ artist: "{{ $.Site.Params.playerArtist }}",
+ url: "{{ . }}",
+ cover: "{{ $.Site.Params.playerCover }}"
+ }]
});
});
- $('#container-progress').click(function () {
- $('html, body').animate({
+</script>
+{{ end }}
+{{ if .Site.Params.scrollTop }}
+<!-- scroll to top button -->
+<script>
+ $("#scroll-top").click(function () {
+ $("html, body").animate({
scrollTop: 0
- }, 'slow');
- return false;
+ });
});
</script>
{{ end }}
-<!-- Vanilla LazyLoad -->
+{{ if .Site.Params.webpChecker }}
+<!-- webp checker -->
<script>
$(function () {
- var lazyLoadInstance = new LazyLoad({
- elements_selector: ".lazy"
+ Modernizr.on("webp", function (result) {
+ if (!result) {
+ $('<blockquote><p>{{ i18n "webpCheckerFront" }}<a href="https://caniuse.com/#feat=webp" target="_blank">WebP</a>{{ i18n "webpCheckerEnd" }}</p></blockquote>').replaceAll("#content img");
+ }
});
});
-</script> \ No newline at end of file
+</script>
+{{ end }} \ No newline at end of file