website/layouts/partials/hooks/body-end.html

60 lines
2.1 KiB
HTML

{{ if .HasShortcode "kat-button" }}
<div id="katacoda-environment" data-katacoda-ondemand="true" data-katacoda-port="30000" data-katacoda-env="minikube:1.20" data-katacoda-command="start.sh" data-katacoda-ui="panel"></div>
{{ end }}
{{ with .Site.Params.algolia_docsearch }}
<!-- scripts for algolia docsearch -->
{{ end }}
{{/* copy-and-paste helper for codenew shortcode */}}
{{- if or (.HasShortcode "code_sample") (.HasShortcode "code") (.HasShortcode "codenew") -}}
{{- $toastrJs := resources.Get "js/toastr-2.1.4.min.js" | minify | fingerprint -}}
{{- if hugo.IsProduction -}}
<script async src="{{ $toastrJs.RelPermalink }}"></script>
{{- else -}}
<script async src="{{ $toastrJs.RelPermalink }}"></script>
{{- end -}}
<script type="text/javascript">
function copyCode(elem) {
if (document.getElementById(elem)) {
if (navigator.clipboard) {
navigator.clipboard.writeText(document.getElementById(elem).textContent).then(
function () {
toastr.options = {
closeButton: true,
progressBar: true,
positionClass: "toast-bottom-center",
timeOut: 2000,
preventDuplicates: true,
newestOnTop: true
};
toastr.success("{{i18n "toast_success_copycode"}}" + elem, "{{i18n "success_copy_to_clipboard"}}");
},
function () {
toastr.options = {
closeButton: true,
progressBar: true,
positionClass: "toast-bottom-center",
timeOut: 2000,
preventDuplicates: true,
newestOnTop: true
};
toastr.error("{{i18n "toast_failure_copycode"}}" + elem, "{{i18n "error_copy_to_clipboard"}}");
}
);
} else {
toastr.options = {
closeButton: true,
progressBar: true,
positionClass: "toast-bottom-center",
timeOut: 2000,
preventDuplicates: true,
newestOnTop: true
};
toastr.warning("{{i18n "browser_clipboard_support_warning"}}", "{{i18n "warning_copy_to_clipboard"}}");
}
}
}
</script>
{{- end -}}