Skip to content

Instantly share code, notes, and snippets.

@contolini
Created February 10, 2013 00:26
Show Gist options
  • Save contolini/4747728 to your computer and use it in GitHub Desktop.
Save contolini/4747728 to your computer and use it in GitHub Desktop.
<html>
<head>
<style type="text/css">
td {
font-size: 30px;
padding: 20px;
border: 1px solid gray;
text-align: center;
}
.chosen {
background-color: blue;
color: white;
}
.null {
background-color: gray;
color: white;
}
.star {
background-color: red;
color: white;
}
</style>
</head>
<body>
<table>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
var cities = new Array('LA', 'Chicago', 'Dallas', 'NYC', 'Spokane', 'Baltimore', 'Albany', 'Austin', 'New Orleans');
function getCity() {
return cities.pop();
}
function getRand(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function dollarize(n) {
return '$' + n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
$('td').each(function(){
if (!getRand(0, 8)) {
$(this).addClass('star');
$(this).html(getCity());
} else {
$(this).html(dollarize(getRand(50000, 500000)));
}
});
$('td').on('click', function(){
var p = prompt('Player name'),
v = $(this).html();
if (p === 'null') {
$(this).html('X').addClass('null');
} else {
$(this).html(v + '<br />' + p).addClass('chosen');
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment