forked from eggzilla/RNAInvaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
152 lines (133 loc) · 5.07 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>RNA invaders - the game</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/easeljs-0.8.2.min.js"></script>
<script src="js/preloadjs-0.6.2.min.js"></script>
<script src="js/soundjs-NEXT.min.js"></script>
<script src="js/flashaudioplugin-NEXT.min.js"></script>
<script src="js/flashaudioplugin-0.6.2.min.js"></script>
<script src="js/soundjs-0.6.2.min.js"></script>
<script src="js/rna.js" type="text/javascript"></script>
<script src="js/data.js" type="text/javascript"></script>
<script src="js/rna.js" type="text/javascript"></script>
<script src="js/ViennaRNA.js" type="text/javascript"></script>
<script type='text/javascript' src='js/d3.js'></script>
<script type='text/javascript' src='js/fornac.js'></script>
<script type="text/javascript">
/* lets begin the actual code */
function main(){
$('#Start').click(function(){Start()});
function Start() {
var keys = [37, 38, 39, 40, 32];
function disable_scroll() {
// if (window.addEventListener) {
// window.addEventListener('DOMMouseScroll', wheel, false);
// }
// window.onmousewheel = document.onmousewheel = wheel;
document.onkeydown = keydown;
}
function enable_scroll() {
if (window.removeEventListener) {
window.removeEventListener('DOMMouseScroll', wheel, false);
}
window.onmousewheel = document.onmousewheel = document.onkeydown = null;
}
function preventDefault(e) {
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
function keydown(e) {
for (var i = keys.length; i--;) {
if (e.keyCode === keys[i]) {
preventDefault(e);
return;
}
}
}
function wheel(e) {
preventDefault(e);
}
var seq = $('#sequence').val();
// alert(seq);
// $('#Start').disable=true;
// $("#Start").removeAttr('data-disable-with');
// $("#Start").prop('disabled', true);
// alert('Prepare for Impact');
if (typeof seq == 'string' && seq.length){
// alert('Prepare for hungry RNA');
$('#Start').hide();
disable_scroll();
/* tried to change the canvas background color, does not work
var canvas = document.getElementById('mainCanvas');
var context = canvas.getContext('2d');
context.fillStyle = "#C0C0C0";
context.fill();
// $('#mainCanvas').canvas("background-color","#C0C0C0");
*/
var game = new Game(seq);
game.Init();
}
else{
alert('Coward, insert Sequence to face an enemy!');
$("#Start").prop('disabled', false);
enable_scroll();
}
}
}
/* start the main() function onload */
$(function(){ main();});
//$(function(){ $("#Start").mousedown(main()); });
// thanks to https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode
function toggleFullScreen(id) {
var elem = document.getElementById(id);
if (!document.fullscreenElement && // alternative standard method
!document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) {
elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
exitFullscreen();
}
}
</script>
</head>
<body>
<div id='main' onkeypress="mouseInput()">
<div class="btn-group pull-right" role="group">
<button class="btn btn-default btn-sm" title="Fullscreen" onclick="toggleFullScreen('main'); return false;">
<span class="glyphicon glyphicon-fullscreen"></span>
</button>
</div>
<form name="ChooseYourEnemy" method="post" onsubmit="return fold();">
<label id="labelRNA" style="position:relative; z-index:6;">InvadRNA</label>
<input id="sequence" name="sequence" type="text" style="position:relative; z-index:6;" value="ACGU"><br>
</form>
<div id="maincontainer">
<a style="position:relative; top:50px; left:0%;" id="Start">
<img src="./graphics/logo.png" alt="logo" style="position:absolute; z-index:6;">
</a>
<canvas id="mainCanvas" width="600" height="600">Canvas is not supported</canvas>
<img src="./graphics/uppercanvasdelimiter.png" alt="uppercanvasdelimiter"
style="position:relative; left:-2px; top:16px; z-index:8;">
<img src="./graphics/lowercanvasdelimiter.png" alt="lowercanvasdelimiter"
style="position:relative; left:-4px; top:482px; z-index:8;">
</div>
<span id="printHere"></span>
<!-- hidden area for the fornac container (which is used to draw the structure) -->
<div id='rna_ss' style="display: none;"> </div>
</div> <!-- main>
</body>