Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
auxves authored and shanalikhan committed Jul 2, 2019
1 parent df83913 commit c8523b9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions ui/gist-selection/gist-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ document
const selectionTemplate = `
<button type="button" onclick="saveGistId('@id')" class="list-group-item list-group-item-action">@description (@id) – Updated @timestamp ago</button>`;

gists.forEach(gist => {
const html = selectionTemplate
.replace(new RegExp("@description", "g"), gist.description)
.replace(new RegExp("@id", "g"), gist.id)
.replace(
new RegExp("@timestamp", "g"),
timeSince(new Date(gist.updated_at))
);
appendHTML(selectionContainer, html);
});
gists
.sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at))
.forEach(gist => {
const html = selectionTemplate
.replace(new RegExp("@description", "g"), gist.description)
.replace(new RegExp("@id", "g"), gist.id)
.replace(
new RegExp("@timestamp", "g"),
timeSince(new Date(gist.updated_at))
);
appendHTML(selectionContainer, html);
});

0 comments on commit c8523b9

Please sign in to comment.