diff options
| author | Aiden Woodruff <aiden.woodruff@gmail.com> | 2018-04-22 13:25:30 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-22 13:25:30 -0500 |
| commit | 0b7110220f9f2a2f886898b6cb95f28d5edacb02 (patch) | |
| tree | af7bc116ec4bf521f58f69a3e71ef73bfcfb816a | |
| parent | 9aa5b06c3404376fd3af2faeffbecbaa1bf6f55a (diff) | |
| download | sweeper-0b7110220f9f2a2f886898b6cb95f28d5edacb02.tar.gz sweeper-0b7110220f9f2a2f886898b6cb95f28d5edacb02.tar.bz2 sweeper-0b7110220f9f2a2f886898b6cb95f28d5edacb02.zip | |
Fixes <td> width issues (#5)
Updated CSS to insure fixed width and height of <td> elements.
Give a nice error when you can't send AJAX.
Give an error when the dimensions are probably too big (it's browser-based, so hard to tell).
Signed-off-by: Aiden Woodruff <aiden.woodruff@gmail.com>
| -rw-r--r-- | flag.png | bin | 224 -> 203 bytes | |||
| -rw-r--r-- | styles.css | 15 | ||||
| -rw-r--r-- | sweeper.js | 15 |
3 files changed, 23 insertions, 7 deletions
| Binary files differ | |||
| @@ -1,13 +1,18 @@ | |||
| 1 | table.board { | 1 | table.board { |
| 2 | border-spacing: 0; | 2 | border-spacing: 0; |
| 3 | border-collapse: collapse; | 3 | outline: 1px solid black; |
| 4 | } | ||
| 5 | |||
| 6 | table.board tr { | ||
| 7 | white-space: nowrap; | ||
| 4 | } | 8 | } |
| 5 | 9 | ||
| 6 | table.board td { | 10 | table.board td { |
| 11 | display: inline-block; | ||
| 7 | text-align: center; | 12 | text-align: center; |
| 8 | width: 20px; | 13 | width: 20px; |
| 9 | height: 20px; | 14 | height: 20px; |
| 10 | border: 2px solid black; | 15 | border: 1px solid black; |
| 11 | } | 16 | } |
| 12 | 17 | ||
| 13 | td.unrevealed { | 18 | td.unrevealed { |
| @@ -20,10 +25,12 @@ td.revealed { | |||
| 20 | background-color: #c6c6c6; | 25 | background-color: #c6c6c6; |
| 21 | } | 26 | } |
| 22 | 27 | ||
| 23 | td.flagged { | 28 | td.flagged, td.correct { |
| 24 | cursor: pointer; | 29 | cursor: pointer; |
| 25 | background-color: #c6c6c6; | 30 | background-color: #c6c6c6; |
| 26 | background-image: url("flag.png"); | 31 | background-image: url("flag.png"); |
| 32 | background-position: center; | ||
| 33 | background-repeat: no-repeat; | ||
| 27 | } | 34 | } |
| 28 | 35 | ||
| 29 | td.wrong { | 36 | td.wrong { |
| @@ -32,8 +39,6 @@ td.wrong { | |||
| 32 | } | 39 | } |
| 33 | 40 | ||
| 34 | td.correct { | 41 | td.correct { |
| 35 | cursor: default; | ||
| 36 | background-image: url("flag.png"); | ||
| 37 | background-color: #00ff00; | 42 | background-color: #00ff00; |
| 38 | } | 43 | } |
| 39 | 44 | ||
| @@ -169,10 +169,16 @@ function flag (e) { | |||
| 169 | function update_leaderboard () { | 169 | function update_leaderboard () { |
| 170 | var xhttp = new XMLHttpRequest(); | 170 | var xhttp = new XMLHttpRequest(); |
| 171 | xhttp.onreadystatechange = function () { | 171 | xhttp.onreadystatechange = function () { |
| 172 | if (this.readyState === 4 && this.status !== 200) { | 172 | if (this.status === 405) { |
| 173 | console.log("Couldn't update leaderboard."); | ||
| 174 | document.getElementById("end").removeChild(document.getElementById("end").getElementsByTagName("input")[0]); | ||
| 175 | var error_msg = document.createElement("p"); | ||
| 176 | error_msg.innerHTML = "Leaderboard doesn't work here."; | ||
| 177 | document.getElementById("end").appendChild(error_msg); | ||
| 178 | } else if (this.readyState === 4 && this.status !== 200) { | ||
| 173 | console.log("There was some error updating the leaderboard."); | 179 | console.log("There was some error updating the leaderboard."); |
| 174 | } else if (this.readyState === 4 && this.status === 200) { | 180 | } else if (this.readyState === 4 && this.status === 200) { |
| 175 | var ld = document.createElement('a'); | 181 | var ld = document.createElement("a"); |
| 176 | ld.href = "leaders.html"; | 182 | ld.href = "leaders.html"; |
| 177 | ld.innerHTML = "Leaderboard"; | 183 | ld.innerHTML = "Leaderboard"; |
| 178 | document.getElementById("end").appendChild(ld); | 184 | document.getElementById("end").appendChild(ld); |
| @@ -332,6 +338,11 @@ for (var y = 0; y < height; y++) { | |||
| 332 | } | 338 | } |
| 333 | 339 | ||
| 334 | window.onload = function () { | 340 | window.onload = function () { |
| 341 | if (width * height > 5000) { | ||
| 342 | document.body.insertBefore(document.createElement("p").appendChild(document.createTextNode("This probably won't work. Try a size where width * height is less than 5000")), document.getElementById("board")); | ||
| 343 | document.body.removeChild(document.getElementById("board")); | ||
| 344 | return; | ||
| 345 | } | ||
| 335 | document.getElementById("board").innerHTML = table; | 346 | document.getElementById("board").innerHTML = table; |
| 336 | timer = window.setInterval( function () { | 347 | timer = window.setInterval( function () { |
| 337 | time++; | 348 | time++; |
