-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.js
215 lines (115 loc) · 4.52 KB
/
ui.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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
var win = window;
if ( !win.setImmediate ) {
win.setImmediate = (function () {
var callbacks = [];
win.addEventListener( 'message', handle, true );
function handle() { callbacks.shift()(); }
return function ( fn ) {
if ( typeof fn !== 'function' ) throw Error('Invalid Argument');
callbacks.push( fn );
win.postMessage( 'setImmediate', '*' );
};
})();
}
var transitionEnd = (function(){
var prefix = {
'WebkitTransition' : 'webkitTransitionEnd',
'MozTransition' : 'transitionend',
'MSTransition' : 'msTransitionEnd',
'OTransition' : 'oTransitionEnd',
'transition' : 'transitionEnd'
},
temp = document.createElement('div'),
keys = Object.keys( prefix ),
i, l; // iterator
for ( i = 0, l = keys.length; i < l; i++ ) {
if ( temp.style[ keys[i] ] !== undefined ) return prefix[ keys[i] ];
}
console.log('TransitionEnd - is not supported');
})();
(function(){
var example = 'pg-catch', //
modes = document.getElementById('modes'),
local = document.getElementById('form-local'),
remote = document.getElementById('form-remote'),
select = ('ontouch' in window) ? 'touchstart' : 'click';
// document.getElementById('form').dispatchEvent( new Event('submit') );
local.addEventListener( 'submit', function ( e ) {
e.preventDefault();
e.stopPropagation();
clear('local');
});
remote.addEventListener( 'submit', function ( e ) {
e.preventDefault();
e.stopPropagation();
var channel = document.getElementById('channel-input');
if ( !channel ) {
// problems - firefox triggers on click, submit isn't accessible and won't be focused...
document.getElementById('pre-remote').innerHTML ='\
<label class="channel-label">Channel ID:</label>\
<input class="channel-input" type="text" autofocus="true"\
placeholder="..." id="channel-input"/>';
return;
}
var value = channel.value;
clear('remote', value );
});
function clear ( type, value ) {
modes.classList.add('fade-out');
modes.addEventListener( transitionEnd, function fade(){
modes.removeEventListener( transitionEnd, fade );
if ( type === 'remote' ) return insertGame();
// local
var time = Date.now();
insertGame( time, 0 );
insertGame( time, 1 );
});
}
function insertGame ( time, no ) {
var main = document.getElementById('main');
main.innerHTML += '\
<div class="js-iframe-wrap">\
<iframe seamless height="0" width="0" frameborder="0" scrolling="no"\
src="games/pg-catch/index.html?' + (time || '') + '"></iframe>\
</div>';
setImmediate(function(){
var wrap = document.querySelectorAll('.js-iframe-wrap')[ no || 0 ].children[0];
if ( !time ) {
wrap.classList.add('frame-center');
return setImmediate(function(){ wrap.classList.add('enlarge-height'); });
}
if ( no === 0 ) wrap.classList.add('frame-right');
if ( no === 1 ) wrap.classList.add('frame-left');
// enlarge also on the iframe !
wrap.classList.add('enlarge-width');
});
}
})();
// zoom-effect: http://lea.verou.me/more-css-secrets/#lightbox
// #504E4E - header & footer
// function close(){
// form.removeEventListener( transitionEnd, close );
// function remove(){ // else still possible to use keys (see FF) + layer above prevent click
// gateRight.removeEventListener( transitionEnd, close );
// header.parentNode.removeChild( header );
// intro.parentNode.removeChild( intro );
// }
// gateRight.addEventListener( transitionEnd, remove );
// gateLeft.classList.add('gate-opened');
// gateRight.classList.add('gate-opened');
// addHandler();
// }
// form.addEventListener( transitionEnd, close );
// form.classList.add('fadeOut');
// header.classList.add('fadeOut');
// container.classList.add('resize-h80');
// barTop.classList.add('bar-enabled');
// barBottom.classList.add('bar-enabled');
// one popup opens - asks for lokal multiplayer or multiple !
// open 2 "split" - for lokal multiplayer || for exchange -
// num: amount of players (can - be setup / default is 2 | just split in half !)
// blocks as openen more than one popup with a click !
// already setup the
// join -> provided via url request ! ( see question mark query ) - use timestamp !
// wiki setup for simple QA + references
// check link + ' list size' // curssor fulfill