website/js/main.js

79 lines
2.5 KiB
JavaScript
Raw Normal View History

2019-08-13 15:16:48 +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"]
});
2019-08-14 15:57:40 +02:00
$(".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();
}
2020-04-01 18:51:36 +02:00
};
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) {
if (value) {
createCookie("radio-autoplay", "true", 31);
2020-02-20 17:28:30 +01:00
_paq.push(['trackGoal', 2]);
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);
});
2020-04-01 18:51:36 +02:00
$("#play-podcast").off();
$("#play-podcast").on("click", function(e) {
var link = $("#select-podcast").val();
2020-04-01 18:56:05 +02:00
$("#container-podcast").attr("src", link);
2020-04-01 18:51:36 +02:00
});
2019-08-13 15:16:48 +02:00
});