Created
October 3, 2016 09:06
-
-
Save Neceros/3c7d6bcb064c850a4f66b00ebe264e0b to your computer and use it in GitHub Desktop.
This file contains 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
<script> | |
{% block js %} | |
$(document).ready(function (e) { | |
var subjects = {{ subjects|safe }}; | |
var whats = {{ whats|safe }}; | |
var wheres = {{ wheres|safe }}; | |
var extras = {{ extras|safe }}; | |
function generateEvents() { | |
var events_html = ''; | |
for (var i = 0; i < 10; i++) { | |
events_html += '<div class="event">'; | |
var choice = subjects[Math.floor(Math.random() * subjects.length)] + " "; | |
choice += whats[Math.floor(Math.random() * whats.length)] + " "; | |
choice += wheres[Math.floor(Math.random() * wheres.length)]; | |
if (Math.random() >= 0.5) { | |
choice += ", " + extras[Math.floor(Math.random() * extras.length)]; | |
} | |
events_html += choice + "</div>"; | |
} | |
$(".events").html(events_html); | |
} | |
generateEvents(); | |
$("#more-events").click(function (e) { | |
generateEvents(); | |
}); | |
}); | |
{% endblock js %} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment