Files
landing_page/qdrant-landing/themes/qdrant/layouts/partials/js.html
T
2023-12-28 11:55:27 +00:00

177 lines
5.3 KiB
HTML

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script src="{{ "js/jquery.js" | absURL }}"></script>
<script src="{{ "js/jquery.mCustomScrollbar.concat.min.js" | absURL }}"></script>
<script src="{{ "js/cookit.js" | absURL }}"></script>
<script src="{{ "js/clipboard.min.js" | absURL }}"></script>
<script src="{{ "js/anchor.min.js" | absURL }}"></script>
<script src="{{ "js/vendor.min.js" | absURL }}"></script>
{{ if or (eq .Section "documentation") (eq .Section "blog") }}
<script src="{{ "js/qdr-search.min.js" | absURL }}"></script>
{{ end }}
<script src="{{ "js/qdr-scroll.min.js" | absURL }}"></script>
<script src="{{ "js/script.js" | absURL }}"></script>
<script>
var clipboard = new ClipboardJS('.copy-btn');
clipboard.on('success', function (e) {
$('#copy-popover').popover('show')
const to = setTimeout(() => {
$('#copy-popover').popover('hide')
$('#modal').modal('show')
clearTimeout(to);
}, 3000);
e.clearSelection();
});
clipboard.on('error', function (e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
$(function () {
$.cookit({
messageText: "{{ .Site.Params.gdpr }}",
linkText: "Learn more",
linkUrl: "/legal/privacy-policy",
buttonText: "I accept",
backgroundColor: '#1c1c1c',
messageColor: '#fff',
linkColor: '#fad04c',
buttonColor: '#fad04c'
});
});
anchors.options.placement = 'left';
anchors.add("article > :is(h1, h2, h3, h4, h5, h6)");
</script>
<script src="{{ "js/lang-switcher.js" | absURL }}"></script>
<script src="{{ "js/copy-code.js" | absURL }}"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
$('[data-toggle="popover"]').popover({
container: 'body'
});
$('.popover-dismiss').popover({
trigger: 'focus'
});
// qdrant-page-search initialization
if (/documentation/.test(window.location?.pathname)) {
window.initQdrantSearch({searchApiUrl: 'https://search.qdrant.tech/api/search', section: "documentation"});
}
if (/blog\/?$/.test(window.location?.pathname)) {
window.initQdrantSearch({searchApiUrl: 'https://search.qdrant.tech/api/search', section: "articles"}); <!-- todo: change to "blog" -->
}
});
</script>
{{ if .IsHome }}
<script>
// Check that current url contains `?token=...` parameter
// And if so, redirec to `/admin?token=...` page
// Get the current URL
const url = window.location.href;
// Use URLSearchParams to parse the query parameters
const params = new URLSearchParams(url.split('#')[1]);
// Check if the 'token' parameter is present
if (params.has('recovery_token')) {
// Get the value of the 'token' parameter
const token = params.get('recovery_token');
// Redirect to the '/admin' page with the same 'token' parameter
window.location.href = '/admin/#recovery_token=' + token;
}
// Check if the 'token' parameter is present
if (params.has('invite_token')) {
// Get the value of the 'token' parameter
const token = params.get('invite_token');
// Redirect to the '/admin' page with the same 'token' parameter
window.location.href = '/admin/#invite_token=' + token;
}
// Check if the 'token' parameter is present
if (params.has('confirmation_token')) {
// Get the value of the 'token' parameter
const token = params.get('confirmation_token');
// Redirect to the '/admin' page with the same 'token' parameter
window.location.href = '/admin/#confirmation_token=' + token;
}
</script>
{{ end }}
{{ if not .IsHome }}
<!-- MathJax support -->
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$','$$'], ['\\[', '\\]']],
processEscapes: true,
processEnvironments: true
},
options: {
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
}
};
window.addEventListener('load', (event) => {
document.querySelectorAll("mjx-container").forEach(function(x){
x.parentElement.classList += 'has-jax'})
});
</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
{{ end }}
{{ if eq .Section "documentation" }}
<script>
$(function() {
// table of contents
document.querySelectorAll('#TOC a').forEach(function(el) {
el.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(el.getAttribute('href'));
if (target) {
target.scrollIntoView({behavior: 'smooth', block: 'start'});
}
});
if (el.innerText) el.setAttribute('title', el.innerText)
});
// sidebar
const moveSearchButton = function() {
if ($(window).width() > 991) {
$('.qdr-search-input-btn').detach().prependTo('#sidebar > #accordion');
} else {
$('.qdr-search-input-btn').detach().prependTo('#sidebar-mobile-header');
}
}
moveSearchButton();
$('#sidebar-toggle').on('click', function () {
$('#sidebar').slideToggle();
$(this).toggleClass('active');
});
$(window).on('resize', function () {
moveSearchButton();
if ($(window).width() > 991) {
$('#sidebar').show();
}
});
})
</script>
{{ end }}