website/_site/js/main.js

73 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-08-14 16:22:22 +02:00
$(document).ready(function() {
var sjs = SimpleJekyllSearch({
searchInput: document.getElementById('search-input'),
resultsContainer: document.getElementById('results-container'),
json: '/search.json',
searchResultTemplate: '<a class="dropdown-item" href="{url}">{title}</a>',
noResultsText: '<a class="dropdown-item" href="#">Nessun risultato</a>',
exclude: ["https://blog.unitoo.it", "https://blog.unitoo.pw"]
});
$(".morphext-bounce-in").Morphext({
animation: "bounceIn",
speed: 2500
});
$(".morphext-bounce-left").Morphext({
animation: "zoomInLeft",
speed: 4500
});
$(".morphext-bounce-up").Morphext({
animation: "bounceInUp",
speed: 6500
});
var startMusic = function() {
var radio_player = document.getElementById("radio-player");
if (radio_player.paused) {
radio_player.play();
}
}
var askForRadio = function() {
$("body").overhang({
custom: true,
type: "confirm",
primary: "#f39200",
accent: "#ffc56e",
yesColor: "white",
yesMessage: "<i class='fas fa-heart text-danger'></i> Adoro!",
noMessage: "<i class='fas fa-times-circle'></i> Magari un'altra volta!",
noColor: "white",
message: "Ti piacerebbe ascoltare la radio mentre navighi sul sito?",
callback: function (value) {
console.log(value);
if (value) {
createCookie("radio-autoplay", "true", 31);
startMusic();
} else {
createCookie("radio-autoplay", "false", 31);
}
}
});
};
var radio_autoplay = readCookie("radio-autoplay");
if (radio_autoplay == null) {
setTimeout(askForRadio, 8000);
} else if (radio_autoplay == 'true') {
var radio_player = document.getElementById("radio-player");
$("#radio-autoplay-button").prop("checked", true);
2020-02-20 15:27:24 +01:00
radio_player.autoplay = radio_autoplay;
}
$("#radio-autoplay-button").on("change", function(e) {
eraseCookie("radio-autoplay");
createCookie("radio-autoplay", $(e.currentTarget).is(":checked"), 31);
});
2019-08-14 16:22:22 +02:00
});