Skip to content

Instantly share code, notes, and snippets.

@Neceros
Created October 3, 2016 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neceros/3c7d6bcb064c850a4f66b00ebe264e0b to your computer and use it in GitHub Desktop.
Save Neceros/3c7d6bcb064c850a4f66b00ebe264e0b to your computer and use it in GitHub Desktop.
<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