-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.html
189 lines (142 loc) · 4.77 KB
/
main.html
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<html>
<head>
<title>ASoIaF Character Generator</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="names.js"></script>
<script src="character.js"></script>
<script type="text/javascript">
var generated = false;
var selectedGender = "Random";
var selectedRegion = "Random";
var selectedHouse = "Random";
$(document).ready(function() {
disableSelection(document.getElementById('generate-button'));
disableSelection(document.getElementById('footer'));
$('#generate-button').mousedown(function() {
$('#generate-button').addClass('black');
});
$('#generate-button').mouseup(function() {
$(this).removeClass("black");
var $all = $('#main');
var $both = $('#charName, #charDesc');
if (generated) {
$all.fadeOut('fast', generateCharacter);
}
else {
generated = true;
$all.fadeOut(0, generateCharacter);
}
$all.fadeIn('fast');
});
$('#generate-button').mouseleave(function() {
$(this).removeClass("black");
});
$('.drawer-tab').click(function() {
$(this).next().slideToggle();
});
$('.gender').click(function() {
if ($(this).html() != selectedGender){
$('.gender').removeClass('selected');
$(this).addClass('selected');
selectedGender = $(this).html();
}
});
$('.region').click(function() {
if ($(this).html() != selectedRegion){
$('.region').removeClass('selected');
$(this).addClass('selected');
selectedRegion = $(this).html();
selectedHouse = 'Random';
setHouseOptions();
}
});
$('#house-table').on('click', '.house', function() {
if ($(this).html() != selectedRegion){
$('.house').removeClass('selected');
$(this).addClass('selected');
selectedHouse = $(this).html();
}
});
});
function setHouseOptions(){
if (selectedRegion === 'Random') {
$('#house-table').html('<tr><td></td></tr>');
} else {
var houses = houseNames[selectedRegion]();
var table = '';
for (var i = 0; i < houses.length; i++) {
if (i % 3 == 0){table += '<tr>';}
table += '<td class=\'house\'>' + houses[i] + '</td>';
if (i % 3 == 2){table += '</tr>';}
}
table += '<td class=\'house selected\'>Random</td></tr>';
$('#house-table').html(table);
}
}
function generateCharacter(){
var character = new Character(selectedGender, selectedRegion, selectedHouse);
$('#charName').html(character.getName());
$('#charDesc').html(character.getDesc());
}
/***********************************************
* Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
target.style.MozUserSelect="none"
else //All other route (ie: Opera)
target.onmousedown=function(){return false}
target.style.cursor = "default"
}
</script>
</head>
<body>
<div id="title">
A Song of Ice and Fire</br>Character Generator
</div>
<div id="main">
<div id='centered'>
<div id="char">
<div id="charName"></div>
<div id="charDesc"></div>
</div>
<div id="generate-button">Generate!</div>
</div>
</div>
<div id='footer'>
<div class='drawer'>
<div class='drawer-tab'>Options</div>
<div class='drawer-body'>
<div class='category' id='gender-drawer'>
<table class='drawer-table' style='width:120px'>
<tr><td class='gender'>Male</td></tr>
<tr><td class='gender'>Female</td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td class='gender selected'>Random</td></tr>
</table>
</div>
<div class='category' id='region-drawer'>
<table class='drawer-table' style='width:240px'>
<tr><td class='region'>North</td><td class='region'>Riverlands</td></tr>
<tr><td class='region'>Iron Islands</td><td class='region'>Vale</td></tr>
<tr><td class='region'>Westerlands</td><td class='region'>Crownlands</td></tr>
<tr><td class='region'>Reach</td><td class='region'>Stormlands</td></tr>
<tr><td class='region'>Dorne</td><td class='region selected'>Random</td></tr>
</table>
</div>
<div class='category' id='house-drawer'>
<table class='drawer-table' id='house-table' style='width:360px; border-right-style: solid;'>
<tr><td></td></tr>
</table>
</div>
</div>
</div>
</div>
</body>
</html>