X-Git-Url: https://jasonwoof.com/gitweb/?p=peach-cgt.git;a=blobdiff_plain;f=client.coffee;h=177f3b450cb67148cc4d3e029e1e69e57a8b9e8c;hp=6f8d230cdc62c1c2f6e616d6d4c5c2a2f3995f24;hb=e5f404f6eff7f4f3d18438390563b4f43b1b5295;hpb=17254bb57943dda8793cf80c37fb65db472de0ea
diff --git a/client.coffee b/client.coffee
index 6f8d230..177f3b4 100644
--- a/client.coffee
+++ b/client.coffee
@@ -23,27 +23,31 @@ unless Array::shuffle?
new_button = (text) -> $ $ "
#{text}
"
-instantiate_card = (model) ->
- text = model.text
- x = model.x
- y = model.y
- card = $ $ "#{text}
"
+instantiate_card = (card) ->
+ text = card.text
+ x = card.x
+ y = card.y
+ view = $ $ "#{text}
"
button_box = $ $ ''
flip_button = new_button "flip over"
mark_button = new_button "mark"
flip_button.bind 'click', ->
- state.flip state.agent, model.number, ! card.hasClass 'flipped'
+ state.flip state.agent, card.number, ! view.hasClass 'flipped'
mark_button.bind 'click', ->
- state.mark state.agent, model.number, ! card.hasClass 'marked'
+ state.mark state.agent, card.number, ! view.hasClass 'marked'
button_box.append flip_button
button_box.append mark_button
- card.append button_box
- $table.append card
- card.draggable stack: '.card'
- card.bind 'dragstop', (event, ui) ->
- p = card.position()
- state.move state.agent, model.number, p.left, p.top
- model.view = card
+ view.append button_box
+ if card.marked
+ view.addClass 'marked'
+ if card.flipped
+ view.addClass 'flipped'
+ $table.append view
+ view.draggable stack: '.card'
+ view.bind 'dragstop', (event, ui) ->
+ p = view.position()
+ state.move state.agent, card.number, p.left, p.top
+ card.view = view
error_lag = 3