-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinfoBox.js
109 lines (91 loc) · 4.14 KB
/
infoBox.js
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
pc.script.create('infoBox', function (context) {
var InfoBox = function (entity) {
this.entity = entity;
var uri = new pc.URI(window.location.href);
var query = uri.getQuery();
if ('multi' in query) {
return;
}
var button = this.button = document.createElement('div');
button.id = 'infoButton';
button.style.position = 'absolute';
button.style.width = '0px';
button.style.height = '0px';
button.style.top = '16px';
button.style.right = '16px';
button.style.zIndex = 1;
button.style.borderRight = '64px solid #212224';
button.style.borderBottom = '64px solid transparent';
button.style.cursor = 'pointer';
button.style.textAlign = 'right';
var i = document.createElement('div');
i.style.position = 'absolute';
i.style.fontSize = '24px';
i.style.fontFamily = 'Helvetica, sans-serif';
i.style.color = '#5e7578';
i.style.top = '0px';
i.style.right = '0px';
i.style.width = '0px';
i.style.lineHeight = '0px';
i.textContent = 'i';
button.appendChild(i);
button.script = this;
document.body.appendChild(button);
var modal = this.modal = document.createElement('div');
modal.id = 'modal';
modal.style.position = 'fixed';
modal.style.left = '0';
modal.style.top = '0';
modal.style.right = '0';
modal.style.bottom = '0';
modal.style.width = 'auto';
modal.style.height = 'auto';
modal.style.padding = '0 16px 4px 16px';
modal.style.backgroundColor = '#212224';
// modal.style.color = '#2ecc71';
modal.style.display = 'none';
modal.style.zIndex = 2;
modal.style.cursor = 'pointer';
modal.style.textAlign = 'center';
modal.innerHTML = '<img src="img/tanx_green.png" style="padding-top:8px;" />';
modal.innerHTML += '<p>Multiplayer Top-Down Tanks Shooter<p>';
modal.innerHTML += '<p>made during 12 hours hackathon using <a href="https://playcanvas.com/" target="_blank">PlayCanvas</a> and node.js.</p>';
modal.innerHTML += '<p>Use WASD & Mouse to control tank or Touch Joystics on mobile platforms.</p>';
modal.innerHTML += '<p>The game features use of HTML5, WebGL, WebSockets, Canvas, Touch.</p>';
modal.innerHTML += '<br /><p>code: <a href="https://twitter.com/mrmaxm" target="_blank">moka</a></p>';
modal.innerHTML += '<br /><p>media: SashaRX</p>';
modal.innerHTML += '<br /><p>ui: <a href="https://twitter.com/4Roonio" target="_blank">Roonio</a></p>';
document.body.appendChild(modal);
document.body.style.fontWeight = '100';
var logo = document.createElement('img');
logo.src = 'img/tanx.png';
logo.alt = 'logo';
logo.style.position = 'absolute';
logo.style.bottom = '16px';
logo.style.left = '50%';
logo.style.width = '96px';
logo.style.opacity = '0.4';
logo.style.marginLeft = '-48px';
document.body.appendChild(logo);
modal.addEventListener('click', function() {
this.modal.style.display = 'none';
}.bind(this), false);
modal.addEventListener('touchstart', function() {
this.modal.style.display = 'none';
}.bind(this), false);
button.addEventListener('click', function() {
this.modal.style.display = 'block';
}.bind(this), false);
button.addEventListener('touchstart', function() {
this.modal.style.display = 'block';
}.bind(this), false);
};
InfoBox.prototype.setSize = function(size) {
this.button.style.borderRightWidth = size + 'px';
this.button.style.borderBottomWidth = size + 'px';
this.button.childNodes[0].style.top = (size * .33) + 'px';
this.button.childNodes[0].style.right = -Math.floor(size * .66) + 'px';
this.button.childNodes[0].style.fontSize = Math.floor(size / 3) + 'px';
};
return InfoBox;
});