Skip to content

Commit

Permalink
Merge pull request #1 from IsaacLean/qpcr-crush
Browse files Browse the repository at this point in the history
qPCR Crush
  • Loading branch information
mattlean committed Jan 9, 2016
2 parents 3afbd97 + 1cec5e2 commit 058a88f
Show file tree
Hide file tree
Showing 48 changed files with 2,774 additions and 51 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
npm-debug.log
examples/*/adamengine-dev.js
examples/qpcr-crush/*.pyc
examples/qpcr-crush/node_modules
examples/qpcr-crush/static/game.min.html
examples/qpcr-crush/static/qpcrcrush.min.js
examples/qpcr-crush/static/bower_components
28 changes: 28 additions & 0 deletions examples/qpcr-crush/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = function(grunt) {

grunt.initConfig({
uglify: {
files: {
src: ['static/adamengine-dev.js', 'static/qpcrcrush.js'],
dest: 'static/qpcrcrush.min.js'
}
},
htmlmin: {
dist: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: {
'static/game.min.html': 'static/game.html'
}
}
}
});

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-htmlmin');

grunt.registerTask('default', ['uglify', 'htmlmin']);

};
26 changes: 26 additions & 0 deletions examples/qpcr-crush/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
application: qpcrcrush
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico

- url: /static
static_dir: static

- url: .*
script: main.app

libraries:
- name: webapp2
version: "2.5.2"

- name: jinja2
version: "2.6"

skip_files:
- node_modules
103 changes: 103 additions & 0 deletions examples/qpcr-crush/badges.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>qPCR Crush Badges</title>
<link href="/static/bower_components/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
<style>
h1 {
margin: 30px 0;
}

td {
transition: background-color 1s ease-out;
}
</style>
</head>
<body>
<div class="container">
<h1>Badges</h1>
<table class="table table-bordered">
<thead>
<tr>
<th>Badge ID</th>
<th>Score Submits</th>
<th>Created</th>
<th>Latest Submission</th>
<th>Prize Collected</th>
</tr>
</thead>
<tbody>
{% for participant in participants %}
<tr>
<td>{{participant.key().name()}}</td>
<td>{{participant.submitted}}</td>
<td class="datetime">{{participant.created}}</td>
<td class="datetime">{{participant.modified}}</td>
<td>
{% if participant.prizeWon %}
<input type="checkbox" data-badgeId={{participant.key().name()}} data-prizeWon checked="checked">
{% else %}
<input type="checkbox" data-badgeId={{participant.key().name()}} data-prizeWon>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<script src="/static/bower_components/jquery/dist/jquery.js"></script>
<script src="/static/bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="/static/bower_components/moment/moment.js"></script>
<script>
$(function() {
function checkPrizeWon() {
$('[data-prizeWon]').each(function() {
var checkbox = $(this);
if(checkbox.is(':checked')) {
$(this).parent().parent().addClass('success');
} else {
$(this).parent().parent().removeClass('success');
}
});
}

$('.datetime').each(function() {
var rawDatetime = $(this).text();
var formDatetime = moment(rawDatetime + ' Z').format('M/D: h:mm A');
$(this).text(formDatetime);
});

checkPrizeWon();

$('[data-prizeWon]').click(function(e) {
e.preventDefault();
var checkbox = $(this);
var badgeId = $(this).attr('data-badgeId');

$.ajax({
url: '/tp',
type: 'POST',
data: {badgeId: badgeId},
success: function(response) {
if(response === 'True') {
checkbox.prop('checked', true);
} else {
checkbox.prop('checked', false);
}

alert('SUCCESS\n\nYou have successfully toggled ' + checkbox.attr('data-badgeId') +'\'s prize win state to ' + response +'.');

checkPrizeWon();
},
error: function() {
alert('ERROR\n\nSomething went wrong with the toggle. Is there something wrong with the internet?\n\nPlease try again.')
}
});
});
});
</script>
</body>
</html>
Binary file added examples/qpcr-crush/favicon.ico
Binary file not shown.
154 changes: 154 additions & 0 deletions examples/qpcr-crush/highscorers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>qPCR Crush High Scorers</title>
<link href="/static/bower_components/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
<style>
h1 {
margin: 30px 0;
}

.btn {
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container">
<h1>High Scorers</h1>
<h2>Leaderboard</h2>
<table class="table table-bordered">
<thead>
<tr>
<th>Badge ID</th>
<th>Alias</th>
<th>Score</th>
<th>Date/Time</th>
<th>Add to Winners</th>
</tr>
</thead>
<tbody>
{% for lbEntry in lbEntries %}
<tr>
<td>{{lbEntry.badgeId}}
<td>{{lbEntry.alias}}</td>
<td>{{lbEntry.score}}</td>
<td class="datetime">{{lbEntry.created}}</td>
<td><button data-addWinner data-badgeId={{lbEntry.badgeId}} data-alias="{{lbEntry.alias}}" class="btn btn-success">Add Winner</button></td>
</tr>
{% endfor %}
</tbody>
</table>
<button id="delete-leaderboard" class="btn btn-danger">DELETE LEADERBOARD</button>
<h2>Winner Table</h2>
<table class="table table-bordered">
<thead>
<tr>
<th>Winner Badge ID</th>
<th>Winner Alias</th>
<th>Added onto Winner Table</th>
<th>Remove from Winners</th>
</tr>
</thead>
<tbody>
{% for winner in winners %}
<tr>
<td>{{winner.key().name()}}</td>
<td>{{winner.alias}}</td>
<td class="datetime">{{winner.created}}</td>
<td><button data-removeWinner data-badgeId={{winner.key().name()}} data-alias="{{winner.alias}}" class="btn btn-danger">Remove Winner</button></td>
</tr>
{% endfor %}
</tbody>
</table>
<button id="delete-winners-table" class="btn btn-danger">DELETE WINNERS TABLE</button>
</div>
<script src="/static/bower_components/jquery/dist/jquery.js"></script>
<script src="/static/bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="/static/bower_components/moment/moment.js"></script>
<script>
$(function() {
$('.datetime').each(function() {
var rawDatetime = $(this).text();
var formDatetime = moment(rawDatetime + ' Z').format('M/D: h:mm A');
$(this).text(formDatetime);
});

$('[data-addWinner]').click(function() {
$.ajax({
url: '/sw',
type: 'POST',
data: {
sw: 'hisnameisjohncena',
badgeId: $(this).attr('data-badgeId'),
alias: $(this).attr('data-alias')
},
success: function(response) {
if(response === 'Winner already exists') {
alert('ERROR\n\nWinner already exists in the winner table! Did you refresh?');
} else {
alert('SUCCESS\n\nNew winner of the hour added. Please refresh the page.');
}
},
error: function() {
alert('ERROR\n\nSomething went wrong with toggling a winner for this hour. Is there something wrong with the internet?\n\nPlease try again.');
}
});
});

$('[data-removeWinner]').click(function() {
$.ajax({
url: '/rw',
type: 'POST',
data: {
rw: 'hisnameisjohncena',
badgeId: $(this).attr('data-badgeId'),
alias: $(this).attr('data-alias')
},
success: function(response) {
alert('SUCCESS\n\nWinner of the hour removed. Please refresh the page.');
},
error: function() {
alert('ERROR\n\nSomething went wrong with toggling a winner for this hour. Is there something wrong with the internet?\n\nPlease try again.');
}
});
});

$('#delete-leaderboard').click(function() {
if(window.confirm('Are you sure you want to delete the leaderboard?\n\nThis cannot be reverted!')) {
$.ajax({
url: '/dl',
type: 'POST',
data: {dl: 'hisnameisjohncena'},
success: function(response) {
alert('SUCCESS\n\nLeaderboard deleted. Please refresh the page.');
},
error: function() {
alert('ERROR\n\nSomething went wrong with the leaderboard deletion. Is there something wrong with the internet?\n\nPlease try again.');
}
});
}
});

$('#delete-winners-table').click(function(e) {
if(window.confirm('Are you sure you want to delete the winners table?\n\nThis cannot be reverted!')) {
$.ajax({
url: '/dw',
type: 'POST',
data: {dw: 'hisnameisjohncena'},
success: function(response) {
alert('SUCCESS\n\nWinners table deleted. Please refresh the page.');
},
error: function() {
alert('ERROR\n\nSomething went wrong with the winners table deletion. Is there something wrong with the internet?\n\nPlease try again.');
}
});
}
});
});
</script>
</body>
</html>
11 changes: 11 additions & 0 deletions examples/qpcr-crush/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
indexes:

# AUTOGENERATED

# This index.yaml is automatically updated whenever the dev_appserver
# detects that a new type of query is run. If you want to manage the
# index.yaml file manually, remove the above marker line (the line
# saying "# AUTOGENERATED"). If you want to manage some indexes
# manually, move them above the marker line. The index.yaml file is
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.
Loading

0 comments on commit 058a88f

Please sign in to comment.