-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
95 lines (86 loc) · 3.48 KB
/
scripts.js
File metadata and controls
95 lines (86 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
$(function() {
//random background
// let imgNames = ['tarn','rooftop','vents','visions', 'shot', 'empty', 'seething', 'ascension', 'pyretic', 'desperate', 'past', 'gifts', 'baral', 'electromancer', 'confusion', 'probe', 'brain'];
let imgNames = ['tarn', 'visions', 'seething', 'ascension', 'pyretic', 'past', 'electromancer', 'probe', 'brain'];
$('body').css('background-image', 'url("img/' + imgNames[Math.floor(Math.random()*imgNames.length)] + '.jpg")');
$('.btn-minus').on('click', function() {
let input = $(this).parent().parent().children('input[type=number]');
if(input.val()>0 || input.hasClass('life-input') )
input.val(parseInt(input.val() )-1 );
});
$('.btn-plus').on('click', function() {
let input = $(this).parent().parent().children('input[type=number]');
input.val(parseInt(input.val() )+1 );
});
//easy solution to dealing with inputs, increment, decrement, and clear buttons
//as well as checkboxes for drawing
$('body').on('click', function() {
drawMana();
drawStorm();
});
$('body').on('keyup', function() {
drawMana();
drawStorm();
});
//mana checkboxes
$('#whiteCheckbox').on('change', function() {
$('#whiteMana').css('display',$(this).prop('checked')?'':'none');
});
$('#blueCheckbox').on('change', function() {
$('#blueMana').css('display',$(this).prop('checked')?'':'none');
});
$('#blackCheckbox').on('change', function() {
$('#blackMana').css('display',$(this).prop('checked')?'':'none');
});
$('#redCheckbox').on('change', function() {
$('#redMana').css('display',$(this).prop('checked')?'':'none');
});
$('#greenCheckbox').on('change', function() {
$('#greenMana').css('display',$(this).prop('checked')?'':'none');
});
$('#colorlessCheckbox').on('change', function() {
$('#colorlessMana').css('display',$(this).prop('checked')?'':'none');
});
});
function drawMana() {
$('#manaDiv').html('');
if(! $('#manaCheckbox').prop('checked') ) {
return;
}
let colorNames = 'white blue black red green colorless'.split(' ');
for(let i=0; i<colorNames.length; i++) {
for(let j=0; j<Math.min($('#'+colorNames[i]+'Input').val(),100); j++) {
$('#manaDiv').append('<img width="32px" src="img/'+colorNames[i]+'.svg">');
}
}
}
function drawStorm() {
$('#stormDiv').html('');
if(! $('#stormCheckbox').prop('checked') ) {
return;
}
for(let i=0; i<Math.min($('#stormInput').val(),100); i++) {
$('#stormDiv').append('<img width="32px" src="img/tempest.png">');
}
}
//https://stackoverflow.com/questions/3900701/onclick-go-full-screen?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
function toggleFullscreen() {
if ((document.fullScreenElement && document.fullScreenElement !== null) ||
(!document.mozFullScreen && !document.webkitIsFullScreen)) {
if (document.documentElement.requestFullScreen) {
document.documentElement.requestFullScreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullScreen) {
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
}