octo front

This commit is contained in:
Galen Wolfe-Pauly 2015-05-19 16:54:32 -07:00
parent ef6731c5f4
commit 2563c63d51
3 changed files with 29 additions and 9 deletions

View File

@ -21,9 +21,9 @@
== ==
;div#vs: vs ;div#vs: vs
;div#user ;div#user
;div.as;
;div.sig: ~ ;div.sig: ~
;div.ship; ;div.ship;
;div.as;
== ==
== ==
;div#bord; ;div#bord;

View File

@ -9,12 +9,13 @@
#what { #what {
height: 36px; height: 36px;
top: 18px;
} }
#bord { #bord {
height: 600px; height: 600px;
position: absolute; position: absolute;
top: 72px; top: 111px;
opacity: .6; opacity: .6;
} }
@ -36,15 +37,21 @@
text-transform: uppercase; text-transform: uppercase;
} }
#what #ship, .turn #what #ship,
#what #user { #what #user {
border: 2px solid #fff; border: 2px solid #fff;
} }
#what #ship,
.turn #what #user { .turn #what #user {
border: 2px solid red; border: 2px solid red;
} }
#what #ship,
#what #user {
padding: .6rem;
}
#what .as { #what .as {
width: 1.6rem; width: 1.6rem;
} }

View File

@ -2,6 +2,7 @@ $(function() {
$bord = $('#bord') $bord = $('#bord')
$whom = $('#whom') $whom = $('#whom')
lett = ["x","o"]
symb = [" ","✕","◯"] symb = [" ","✕","◯"]
draw = function(state) { draw = function(state) {
space = function(_state,y,x) { space = function(_state,y,x) {
@ -21,19 +22,31 @@ $(function() {
} }
} }
$bord.html(s) $bord.html(s)
$whom.html((state.who == 'x' ? symb[1] : symb[2])) turn(state.who)
} }
which = null
turn = function(who) {
$('body').toggleClass('turn',(who == which))
}
assign = function(who) {
which = who
turn(who)
$('#ship .as').text(symb[Number(!lett.indexOf(who))+1])
$('#user .as').text(symb[lett.indexOf(who)+1])
}
urb.appl = 'octo' urb.appl = 'octo'
urb.bind('/web', function(err,res) { urb.bind('/octo/web', function(err,res) {
if(which == null) { assign(res.data.who) }
draw(res.data) draw(res.data)
}) })
draw({ // draw({
box:[false,false,false,false,false,false,false,false,false], // box:[false,false,false,false,false,false,false,false,false],
boo:[false,false,false,false,false,false,false,false,false] // boo:[false,false,false,false,false,false,false,false,false]
}) // })
$bord.on('click', function(e) { $bord.on('click', function(e) {
if(!$('body').hasClass('turn')) { return false } if(!$('body').hasClass('turn')) { return false }