Skip to content

Commit

Permalink
Cycle through messages in order instead of randomly
Browse files Browse the repository at this point in the history
  • Loading branch information
thewarpaint committed Apr 17, 2017
1 parent 7fb798b commit a03140d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<script type="text/javascript">
var messages;
var currentIndex = 0;
var dataURL = 'https://thewarpaint.github.io/trumpmit/data.json';

document.addEventListener('DOMContentLoaded', function(event) {
Expand All @@ -21,7 +22,7 @@

function init(data) {
messages = data;
renderRandomMessage();
renderNextMessage();
}

function onSuccess() {
Expand All @@ -32,9 +33,9 @@
document.getElementById('console').textContent = getCommitMessage(message);
}

function renderRandomMessage() {
var index = Math.floor(Math.random() * messages.length);
renderMessage(messages[index].text);
function renderNextMessage() {
renderMessage(messages[currentIndex].text);
currentIndex = (currentIndex + 1) % messages.length;
}

function getCommitMessage(message) {
Expand All @@ -49,7 +50,7 @@
<body>
<pre id="console" style="background: #272822; color: #f8f8f2; padding: .5rem; overflow-x: scroll;"></pre>

<button type="button" onclick="renderRandomMessage();"
<button type="button" onclick="renderNextMessage();"
style="padding: .5rem .75rem; font-size: .85rem;">Again!</button>

<p><a href="https://github.com/thewarpaint/trumpmit#how-to">Install it now!</a></p>
Expand Down

0 comments on commit a03140d

Please sign in to comment.