Théo Marchal
3a490aa173
* Remove Backstretch plugin (not working well on mobile) * Update all plugins * Made Hisui a different region
112 lines
4.2 KiB
JavaScript
112 lines
4.2 KiB
JavaScript
$(document).ready(function() {
|
||
|
||
function random(min, max) {
|
||
return Math.floor(Math.random()*(max-min+1)+min);
|
||
}
|
||
|
||
// have a nice little background
|
||
//$.backstretch("artwork/artwork"+random(1, 10)+".jpg");
|
||
|
||
// splice url arguments
|
||
function gup(name, url) {
|
||
if (!url) url = location.href;
|
||
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
|
||
var regexS = "[\\?&]"+name+"=([^&#]*)";
|
||
var regex = new RegExp( regexS );
|
||
var results = regex.exec( url );
|
||
return results == null ? null : results[1];
|
||
}
|
||
|
||
// read url
|
||
local_gen = gup('gen', window.location.href);
|
||
if (local_gen != null) {
|
||
if (local_gen == "all")
|
||
$('article #container #game #configuration input#all').attr('checked', true);
|
||
else {
|
||
$('article #container #game #configuration input#select').attr('checked', true);
|
||
for (i = 0; i < local_gen.length; i++) {
|
||
if (local_gen.charAt(i)) {
|
||
if (local_gen.charAt(i) == "m")
|
||
$('article #container #game #configuration #selected_options input#mega').attr('checked', true);
|
||
else if (local_gen.charAt(i) == "r")
|
||
$('article #container #game #configuration #selected_options input#regional').attr('checked', true);
|
||
else if (local_gen.charAt(i) == "g")
|
||
$('article #container #game #configuration #selected_options input#gigantamax').attr('checked', true);
|
||
else
|
||
$('article #container #game #configuration #selected_options input#' + local_gen.charAt(i) + 'g').attr('checked', true);
|
||
}
|
||
}
|
||
$('#selected_options').slideDown();
|
||
}
|
||
$('article #container #game #configuration select.lang').val(gup('lang', window.location.href));
|
||
if (gup('silhouette', window.location.href) == "true")
|
||
$('article #container #game #configuration input#silhouette').attr('checked', true);
|
||
else
|
||
$('article #container #game #configuration input#full').attr('checked', true);
|
||
$('article #container #game #configuration select.questions').val(gup('questions', window.location.href));
|
||
$('article #container #game #configuration select.time').val(gup('time', window.location.href));
|
||
}
|
||
else { // if we did not come from a personalized URL, we read localstorage
|
||
|
||
if (localStorage.getItem('generation') != null) {
|
||
if (localStorage.getItem('generation') != 'all') {
|
||
gen_list = localStorage.getItem('generation');
|
||
|
||
$('article #container #game #configuration input#select').attr('checked', true);
|
||
for (i = 0; i < gen_list.length; i++) {
|
||
if (gen_list.charAt(i)) {
|
||
|
||
if (gen_list.charAt(i) == "m")
|
||
$('article #container #game #configuration #selected_options input#mega').attr('checked', true);
|
||
else if (gen_list.charAt(i) == "r")
|
||
$('article #container #game #configuration #selected_options input#regional').attr('checked', true);
|
||
else if (gen_list.charAt(i) == "g")
|
||
$('article #container #game #configuration #selected_options input#gigantamax').attr('checked', true);
|
||
else
|
||
$('article #container #game #configuration #selected_options input#' + gen_list.charAt(i) + 'g').attr('checked', true);
|
||
}
|
||
}
|
||
$('#selected_options').slideDown();
|
||
} else
|
||
$('article #container #game #configuration input#all').attr('checked', true);
|
||
}
|
||
if (localStorage.getItem('lang') != null)
|
||
$('article #game #configuration select.lang').val(localStorage.getItem('lang'));
|
||
if (localStorage.getItem('silhouette') != null)
|
||
$('article #game #configuration input:radio[name=silhouette]#'+localStorage.getItem('silhouette')).attr('checked', true);
|
||
if (localStorage.getItem('questions') != null)
|
||
$('article #game #configuration select.questions').val(localStorage.getItem('questions'));
|
||
if (localStorage.getItem('time') != null)
|
||
$('article #game #configuration select.time').val(localStorage.getItem('time'));
|
||
}
|
||
|
||
|
||
// select generation toggle
|
||
$('#configuration input#all').click(function() {
|
||
$('#selected_options').slideUp();
|
||
});
|
||
|
||
$('#configuration input#select').click(function() {
|
||
$('#selected_options').slideDown();
|
||
});
|
||
|
||
|
||
|
||
// hamburger mobile
|
||
$("#hamburger .container").click(function()
|
||
{
|
||
if ($("nav").hasClass("active"))
|
||
{
|
||
$("ul").slideUp(200, function()
|
||
{
|
||
$("nav").removeClass("active");
|
||
});
|
||
}
|
||
else
|
||
{
|
||
$("nav").addClass("active");
|
||
$("ul").slideDown(200);
|
||
}
|
||
});
|
||
});
|