Original commit (r57)
This commit is contained in:
92
interface.js
Normal file
92
interface.js
Normal file
@ -0,0 +1,92 @@
|
||||
$(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, 9)+".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();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user