From 1d222f95987f01aaee4b88a57515cc3823751005 Mon Sep 17 00:00:00 2001 From: Tailszefox Date: Sun, 12 Apr 2020 06:16:28 +0200 Subject: [PATCH] Moved inline javascript to own file --- index.php | 224 +---------------------------------------------------- js/base.js | 218 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 219 insertions(+), 223 deletions(-) create mode 100644 js/base.js diff --git a/index.php b/index.php index 8e92a3b..65e1f02 100644 --- a/index.php +++ b/index.php @@ -150,228 +150,6 @@ else - + \ No newline at end of file diff --git a/js/base.js b/js/base.js new file mode 100644 index 0000000..64b1c6e --- /dev/null +++ b/js/base.js @@ -0,0 +1,218 @@ +$(function () +{ + var merpRunning = false; + + var merp = new Konami(function(){ + if(!merpRunning) + { + $("#audio audio")[0].play(); + $("#resultImage").addClass("animateImage"); + merpRunning = true; + } + else + { + $("#audio audio")[0].pause(); + $("#audio audio")[0].currentTime = 0; + $("#resultImage").removeClass("animateImage"); + merpRunning = false; + } + }); + + var twilicane = new Konami(function(){ + var current = $("#from").val(); + + if(current == "twilight_p") + { + if($("#twilicane").length == 0) + { + var twilicaneDiv = $('
'); + $("#resultDiv").prepend(twilicaneDiv); + $(' - http://fav.me/d6vlrbm').insertAfter(".sourceLink"); + } + else + { + $("#twilicane").remove(); + $("#sourceLinkTwilicane").remove(); + $("#sourceLinkTwilicaneSpan").remove(); + } + } + + }, "848773767367657869"); + + function getNewFusion() + { + $("#to").find("option").removeAttr("disabled"); + $("#from").find("option").removeAttr("disabled"); + + var from = $("#from").val(); + var to = $("#to").val(); + var fromSelected = $("#from")[0].selectedIndex; + var toSelected = $("#to")[0].selectedIndex; + + //$("#to")[0].options[fromSelected].disabled = true; + + //$("#from")[0].options[toSelected].disabled = true; + + jQuery.get('fusion_ajax.php', {from: from, to: to}, function(data, textStatus, xhr) { + $("#resultDivContent").html(data); + }); + + } + + function randomizePonies(which) + { + $("#to").find("option").removeAttr("disabled"); + $("#from").find("option").removeAttr("disabled"); + + var nbPonies = $("#from option").size(); + + if(which == 0) + { + $("#from")[0].selectedIndex = Math.floor(Math.random() * nbPonies); + $("#to")[0].selectedIndex = Math.floor(Math.random() * nbPonies); + + if($("#from")[0].selectedIndex == $("#to")[0].selectedIndex) + { + if($("#from")[0].selectedIndex == nbPonies - 1) + $("#to")[0].selectedIndex = $("#from")[0].selectedIndex - 1 + else + $("#to")[0].selectedIndex = $("#from")[0].selectedIndex + 1 + } + } + else if(which == 1) + { + $("#from")[0].selectedIndex = Math.floor(Math.random() * nbPonies); + + if($("#from")[0].selectedIndex == $("#to")[0].selectedIndex) + { + if($("#to")[0].selectedIndex == nbPonies - 1) + $("#from")[0].selectedIndex = $("#to")[0].selectedIndex - 1 + else + $("#from")[0].selectedIndex = $("#to")[0].selectedIndex + 1 + } + } + else if(which == 2) + { + $("#to")[0].selectedIndex = Math.floor(Math.random() * nbPonies); + + if($("#from")[0].selectedIndex == $("#to")[0].selectedIndex) + { + if($("#from")[0].selectedIndex == nbPonies - 1) + $("#to")[0].selectedIndex = $("#from")[0].selectedIndex - 1 + else + $("#to")[0].selectedIndex = $("#from")[0].selectedIndex + 1 + } + } + + getNewFusion(); + } + + $("select.fusionChoice").change(function (e) { + getNewFusion(); + }); + + $("#buttonSwap").click(function (e) { + $("#to").find("option").removeAttr("disabled"); + $("#from").find("option").removeAttr("disabled"); + + var from = $("#from").val(); + var to = $("#to").val(); + + $("#from").val(to); + $("#to").val(from); + + getNewFusion(); + + e.preventDefault(); + }); + + $("#buttonRandomize").click(function (e) { + randomizePonies(0); + + e.preventDefault(); + }); + + $("#buttonRandomizeFrom").click(function (e) { + randomizePonies(1); + + e.preventDefault(); + }); + + $("#buttonRandomizeTo").click(function (e) { + randomizePonies(2); + + e.preventDefault(); + }); + + $("#faqClose").click(function (e) { + $("#faqWrapper").hide(); + }); + + $("#faqWrapper").click(function (e) { + $("#faqWrapper").hide(); + }) + + $("#faqWrapper").children().click(function(e) { + return false; + }); + + $("#faqLink").click(function (e) { + $("#faqWrapper").show(); + + e.preventDefault(); + }); + + $(document).on('click', "#resultImage", function(event) { + var current = $("#from").val(); + + if(current == "vinyl" || current == "vinyl2") + { + var posX = event.pageX - $(this).offset().left + var posY = event.pageY - $(this).offset().top; + + if(posX >= 85 && posX <= 310 && posY >= 150 && posY <= 310) + { + if(current == "vinyl") + { + $("#from option[value='vinyl']").val("vinyl2"); + $("#to option[value='vinyl']").val("vinyl2"); + } + else + { + $("#from option[value='vinyl2']").val("vinyl"); + $("#to option[value='vinyl2']").val("vinyl"); + } + + getNewFusion(); + event.preventDefault(); + } + } + + if(current == "starlight" || current == "starlight2") + { + var posX = event.pageX - $(this).offset().left + var posY = event.pageY - $(this).offset().top; + + if(posX >= 190 && posX <= 230 && posY >= 380 && posY <= 460) + { + if(current == "starlight") + { + $("#from option[value='starlight']").val("starlight2"); + $("#to option[value='starlight']").val("starlight2"); + } + else + { + $("#from option[value='starlight2']").val("starlight"); + $("#to option[value='starlight2']").val("starlight"); + } + + getNewFusion(); + event.preventDefault(); + } + } + }); + + var urlQuery = new URLSearchParams(window.location.search); + if(urlQuery.get("from") == null || urlQuery.get("to") == null) + randomizePonies(0); +}); \ No newline at end of file