Skip to content

Commit

Permalink
NateWr#6 created a Client-side functionality for the Helpful and Not …
Browse files Browse the repository at this point in the history
…Helpful buttons
  • Loading branch information
Yjohn committed Sep 9, 2017
1 parent d794367 commit 3a1775c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
17 changes: 17 additions & 0 deletions public/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var helpful = 0;
var unhelpful = 0;
var total = 0;
var display = document.getElementById("displayCount");
var totalNumber = document.getElementById("totalNumber")
document.getElementById("Button1").addEventListener("click", function (event) {
//var temp = event.target;
helpful++;
total++;
display.innerHTML = helpful;
totalNumber.innerHTML = total;
});
document.getElementById("Button2").addEventListener("click", function (event) {
unhelpful++;
total++;
totalNumber.innerHTML = total;
});
34 changes: 17 additions & 17 deletions views/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
</button>
</form>
{{#if entries}}
<ul class="entry-list">
{{#each entries}}
<li class="entry">
<h2 class="entry__question">
{{this.question}}
</h2>
<div class="entry__answer">
{{{this.answer}}}
</div>
<div class="entry__help">
{{this.helpful}}/?? people found this helpful. Was this entry helpful?
<button class="button button--small">Yes</button>
<button class="button button--small">No</button>
</div>
</li>
{{/each}}
</ul>
<ul class="entry-list">
{{#each entries}}
<li class="entry">
<h2 class="entry__question">
{{this.question}}
</h2>
<div class="entry__answer">
{{{this.answer}}}
</div>
<div class="entry__help">
<span id="displayCount">{{this.helpful}}</span>/<span id="totalNumber"></span> people found this helpful. Was this entry helpful?
<button id="Button1" class="button button--small">Yes</button>
<button id="Button2" class="button button--small">No</button>
</div>
</li>
{{/each}}
</ul>
{{/if}}
<div class="add">
<p class="add__prompt">Still haven't found your answer? Why not ask a question?</p>
Expand Down
1 change: 1 addition & 0 deletions views/layout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
</header>
{{{body}}}
</div>
<script src="/main.js"></script>
</body>
</html>

0 comments on commit 3a1775c

Please sign in to comment.