/
menus.js
executable file
·69 lines (66 loc) · 1.6 KB
/
menus.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
$(document).ready(function(){
settings = $('#tools #settings'),
chatbutton = $('#chat-button'),
helpbutton = $('#help-button'),
playbutton = $('#play-button'),
editbutton = $('#edit-button'),
buttons = $('.button');
buttons.each(function(vent, obj){
var o = $(obj), txt= o.attr('name');
if(o.hasClass('link')){
o = o.find('a');
}
if(txt === '' || !txt){
txt = o.attr('id');
}
var p = $('<span>').html(txt);
o.append('<img src="/img/empty.png" width="32" height="32" alt="'+$(obj).attr('id')+'"/>').append(p);
p = o.find('span');
p.css({left: 8-(p.width()/2)});
if(txt =='edit'){
editbutton.hide();
}
});
chatbutton.click(function(){
if(chatbutton.hasClass('hidden')){
$('#chat').show();
chatbutton.removeClass('hidden');
}else {
$('#chat').hide();
chatbutton.addClass('hidden');
}
});
helpbutton.click(function(){
if(helpbutton.hasClass('hidden')){
$('#help').show();
helpbutton.removeClass('hidden');
}else {
$('#help').hide();
helpbutton.addClass('hidden');
}
});
playbutton.click(function(){
if($jo.state === 'edit'){
$jo.game.map = $jo.editor.map;
$jo.game.runSetup();
$jo.state = 'play';
console.log('go play');
playbutton.hide();
editbutton.show();
$('#sidebar').fadeOut();
}
});
editbutton.click(function(){
if($jo.state === 'play'){
$jo.editor.run();
$jo.state = 'edit';
console.log('go edit');
editbutton.hide();
playbutton.show();
$('#sidebar').fadeIn();
}
});
$('#canvas').click(function(){
$('input').blur();
});
});