Created
July 15, 2014 00:38
-
-
Save noahpryor/8947b2ee369766b4f977 to your computer and use it in GitHub Desktop.
minesweeper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= num_rows = 10 %> | |
| <%= num_cols = 10 %> | |
| <%= [[[""]][false]] | |
| <table> | |
| <thead></thead> | |
| <tbody> | |
| <% (0...num_row).each do |row| %> | |
| <tr> | |
| <% (0...num_cols).each do |col| %> | |
| <td data-col="<%=col%>" data-row="<%=row%>"> <button class="btn" data-kind="flag">Flag</button><button class="btn" data-kind="check">Check</button></td> | |
| <% end %> | |
| </tr> | |
| <% end %> | |
| </tbody> | |
| </table> | |
| <script> | |
| var railsEndpoint = "/positions/query.json"; | |
| var handleCellResponse = function(response) { | |
| var data = JSON.parse(response.data); | |
| console.log(data) | |
| if(data.status == "mine") { | |
| cell.text = "mine" | |
| } | |
| else if(data.status == "count") { | |
| cell.text "blah" //you get the idea | |
| } | |
| } | |
| $(".flat-button").on('click',function(item) { | |
| var cell = $(item).parent('td'); | |
| var queryData = cell.data(); | |
| queryData.kind = $(item).data().kind; | |
| $.get((railsEndpoint, cellPosition),handleCellResponse) | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment