(function() { var uriRoot = (window.location.hostname === "localhost") ? "" : "//nyn.be"; var df = {}; window.df = df; document.addEventListener("DOMContentLoaded", function() { var scriptLocation = (window.location.hostname === "localhost") ? "/golf.js" : "//nyn.be"; var leaderboardTitle = "LiveGolfPools.com - Leaderboard"; if (document.title === leaderboardTitle) { var script = $(`.team > span > script[src='${scriptLocation}']`); script.parent().append("ferretti"); } addCss(); addImages(); changePoolName("david's pool"); hideImages(); $(document).on("mousemove", hideImages); $(document).on("click", bleat); window.currentTimer = 180; $("html").addClass("hover"); }); function addCss() { var link = document.createElement("link"); link.rel = "stylesheet"; link.href = uriRoot + "/df.css"; document.head.appendChild(link); } df.addImages = addImages; function addImages() { var images = ["unauthorized.png", "notfound.png"]; for (var i = 0; i < images.length; i++) { var div = document.createElement("div"); div.className = "df-image df-image-"+i; var image = document.createElement("img"); image.src = uriRoot + "/" + images[i]; div.appendChild(image); document.body.appendChild(div); } } var hideHandle = 0; function hideImages() { $(".df-image").css({display:"none"}); if (hideHandle) clearTimeout(hideHandle); hideHandle = setTimeout(showImages, 10 * 1000); } df.showImages = showImages; function showImages() { $(".df-image").css({display:"flex"}); } df.changePoolName = changePoolName; function changePoolName(name, pool) { var tests = [ { regex: /^\/mypools\/(.*)\/pooldetails$/, group: 1 }, { regex: /^\/mypools\/(.*)\/leaderboard$/, group: 1 } ]; if (!pool) { for (var i = 0; i < tests.length; i++) { if (!tests[i].regex.test(window.location.pathname)) continue; pool = tests[i].regex.exec(window.location.pathname)[tests[i].group]; } } var settings = { "async": true, "crossDomain": true, "url": `https://livegolfpools.com/mypools/${pool}/edit`, "method": "POST", "headers": { "Content-Type": "application/x-www-form-urlencoded" }, "data": { "pool_name": name, "submit": "Update Pool" } } $.ajax(settings).done(function() { console.log("updated pool name"); }); } function bleat() { var audio = new Audio("https://nyn.be/bleat.mp3"); audio.volume = 0.1; audio.play(); } })();