Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
94 lines (91 sloc) 4.32 KB
{% macro team_dropdown(name) -%}
<select data-placeholder="{{ name.title() }} team" class="dropdown-select" name="{{ name }}", id="{{ name }}">
<option value=""></option>
{% for division in divisions %}
<optgroup label="{{ division.name }}">
{% for team in division.teams %}
<option value="{{ team.shortcode }}">
{{ team.name }}
</option>
{% endfor %}
</optgroup>
{% endfor %}
</select>
{%- endmacro %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>r/NBA Gamethread Generator</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ url_for('static', filename='css/chosen.min.css') }}" />
<style type="text/css">
textarea {
font-family: menlo, consolas, courier, mono;
}
</style>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/chosen.jquery.min.js') }}"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(function() {
$(".dropdown-select").chosen();
$("#main-form").submit(function() {
var form = $(this);
$.post(form.prop("action"), form.serialize(), function(data) {
if (data["error"]) {
$("#gamethread-text").html('<div '
+ 'class="alert alert-dismissable alert-danger">'
+ '<button class = "close" type="button" '
+ 'data-dismiss="alert" aria-hidden="true">×'
+ '</button>' + data["error"] + '</div>');
$(".alert").alert();
}
else {
$("#gamethread-text").html('<p>Title</p><input '
+ 'class="form-control" id="title_input"'
+ 'value="' + data["title"] + '" /><br /><p>'
+ 'Body</p><textarea rows="15" class='
+ '"form-control" id="body_input">'
+ data["body"] + '</textarea><br /><button '
+ 'class="btn btn-primary btn-lg btn-block"'
+ 'id="submit">Submit Gamethread</button>');
$("#submit").click(function() {
var title = $("#title_input").val();
var body = $("#body_input").val()
window.location.href = ("https://reddit.com/r/"
+ "nba/submit?title="
+ encodeURIComponent(title) + "&text="
+ encodeURIComponent(body));
});
}
})
return false;
})
});
</script>
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>
r/NBA Gamethread Generator
</h1>
<p>
<form action="{{ url_for('generate') }}" method="post" id="main-form">
{{ team_dropdown('away') }}
{{ team_dropdown('home') }}
<input type="submit" class="btn primary" value="Generate Gamethread" />
</form>
</p>
<hr />
<div id="gamethread-text"></div>
</div>
<footer>
<p>
Created by Alex Gaynor. For feedback, <a href="https://www.reddit.com/message/compose/?to=kingkilr&subject=Gamethread%20Generator">send a reddit message to kingkilr</a>. <a href="https://github.com/alex/nba-gamethread">Code is open source</a>.
</p>
</footer>
</div>
</body>
</html>