<!doctype html>
<html prefix="og: http://ogp.me/ns#">
    <head>
    <% include ./partials/header.ejs %>
    <% include ./partials/nav.ejs %>
    <link rel="stylesheet"
      href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script>
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.css">
            <link rel="icon" type="image/jpg" href="https://media.discordapp.net/attachments/506425178822279168/507496898823847936/dbr.png">
            <title><%=bot.users.get(id).username%> comments - Discord Bot Reviews</title>
    </head>
    <body>
        <center><h2><%=bot.users.get(id).username%> comments page <%=page%></h2>
        <br><br>
        <%if(bot.botinfo.get(id, "allowcomments") && bot.botinfo.get(id, "allowcomments")) {%>
Comments are disabled on this bot.
<br><br>
          <% } else {%>
        <%if(req.user) { %>
          <script>var id = <%= id %></script>
            <form class="bg-dark-submit" action="/api/form/postcomment?redirect=<%=id%>&page=<%=page%>" method="POST" id="comment-form" enctype="application/x-www-form-urlencoded">
            <img class="rounded-circle badge-img fluid-img" style="heigth:100px;width:100px;margin-bottom:1rem" src="<%=bot.users.get(req.user.id).avatarURL || bot.users.get(req.user.id).defaultAvatarURL%>">
            <textarea class="txtarea" class="d-flex-lg" style="width:50%;height:10rem;font-size: 15px;display:inline-block;margin-bottom:1rem" rows="3" id="comment" name="comment" maxlength="600" placeholder="Write a quick comment as <%=req.user.username%>... (600 characters maximum)" required="required"></textarea><br>
            <input type="hidden" name="bot" value="<%= id%>">
        
            <input type="submit" style="position:static;right:9rem" value="Comment" class="btn btn-primary" id="commentclick" disabled>
            <br>
          </form><br><br>
          <script>
            var commentBox = document.getElementById("comment")
            var commentSubmit = document.getElementById("commentclick")
            document.getElementById("comment").addEventListener("keydown", (event) => {
              if (commentBox.value.replace(/ /g, "").replace(/\n/g, "").length == 0) {
                commentSubmit.setAttribute("disabled", "")
              } else {
                commentSubmit.removeAttribute("disabled")
              }});
            document.getElementById("comment").addEventListener("keyup", (event) => {
              if (commentBox.value.replace(/ /g, "").replace(/\n/g, "").length == 0)  {
                commentSubmit.setAttribute("disabled", "")
              } else {
                commentSubmit.removeAttribute("disabled")
              }});
        </script>
          <% } else {%>
          <br><a href="/auth">Login</a> to comment.<br><br>
          <% } %>
        </center>
<hr>
<center>
<h2>Total showing comments: <%if(req.user) { if(bot.guilds.get("500658335217876997").members.get(req.user.id).roles.has("500662148561764352") || bot.guilds.get("500658335217876997").members.get(req.user.id).roles.has("500658928602841099")) {%> <%=bot.comments.filter(r=> r.bot === id).size%> <%} else {%> <%=bot.comments.filter(r=> r.bot === id && !banned.has(r.author)).size%><% }} else {%><%=bot.comments.filter(r=> r.bot === id && !banned.has(r.author)).size%><% }%></h2>
<%if(bot.comments.filter(r=> r.bot === id && r.author && banned.has(r.author)).size >0) {%>
<p style="color: red;">NOTE: this bot contains comments whose author is banned, which are hidden</p>
<% }%>
<br>
</center>
<% if(bot.comments.filter(r=> r.bot === id).size <1) {%> 
<center>No one has commented yet</center>
  <% } else { var showbans = false%>
    <%if(req.user) { if(bot.guilds.get("500658335217876997").members.get(req.user.id)) { if(bot.guilds.get("500658335217876997").members.get(req.user.id).roles.has("500662148561764352") || bot.guilds.get("500658335217876997").members.get(req.user.id).roles.has("500658928602841099")) { showbans = true }}}%>
<% var count = 0; bots = comments.filter(r=> showbans ? r.bot === id : r.bot == id && !banned.has(r.author)).map(r=> r); while(bots[count]) { %>
  <br>
                          <div class="card" style="margin: 0 auto;<%if(bot.userinfo.has(bots[count].author) && bot.userinfo.get(bots[count].author, "commentbubble") && bot.userinfo.get(bots[count].author, "commentbubble").length >0) {%><%if(bot.userinfo.get(bots[count].author, "commentbubble").startsWith("http")) {%>background-size: contain;background-repeat:no-repeat;     -webkit-background-size: cover;-moz-background-size: cover;-o-background-size: cover;background-size: cover;background-image: url(<%=bot.userinfo.get(bots[count].author, "commentbubble")%>)<%} else {%>background-color: rgb(<%=bot.userinfo.get(bots[count].author, "commentbubble")%>)<%}} else {%>background-color: #2f2f2f<% }%>;width:75%;border-radius:25px;padding:1rem;margin-bottom:1rem">
                          
                            <p style="display: inline-block;font-size: 18px;">&nbsp<img class="rounded-circle"style="height:50px;" src="<%=bot.users.get(bots[count].author).avatarURL || bot.users.get(bots[count].author).defaultAvatarURL%>"> <a style="color: <%if(bot.userinfo.has(bots[count].author) && bot.userinfo.get(bots[count].author, "nametag") && bot.userinfo.get(bots[count].author, "nametag") && bot.userinfo.get(bots[count].author, "nametag").length >1) {%>rgb(<%=bot.userinfo.get(bots[count].author, "nametag")%>) <%} else {%>white<%}%>;"href="/user/<%=bot.users.get(bots[count].author).id%>"><%=bot.users.get(bots[count].author).tag%></a><%if(bot.botinfo.get(id, "submitter") === bots[count].author) {%> <img title="Author is the owner of the bot"style="height: 25px;"src="https://cdn.discordapp.com/emojis/515950426181468163.png"> <% };if(bot.guilds.get("500658335217876997").members.get(bots[count].author)) { if (bot.guilds.get("500658335217876997").members.get(bots[count].author).roles.has("500658928602841099")) {%> <img title="Author is an administrator of the website" src="https://cdn.discordapp.com/emojis/507680644416012299.png" height="25px"> <%}if(bot.guilds.get("500658335217876997").members.get(bots[count].author)) { if (bot.guilds.get("500658335217876997").members.get(bots[count].author).roles.has("500662148561764352")) {%> <img title="Author is a website moderator" src="https://cdn.discordapp.com/emojis/507668351368036382.png" height="25px"> <%}if(bot.guilds.get("500658335217876997").members.get(bots[count].author)) { if (bot.guilds.get("500658335217876997").members.get(bots[count].author).roles.has("507628349707911178")) {%> <img title="Author is certified" src="https://cdn.discordapp.com/emojis/507958292790902795.png" height="25px"> <%}}}}; %><%if(bot.guilds.get("500658335217876997").members.get(bots[count].author)) { if (bot.guilds.get("500658335217876997").members.get(bots[count].author).roles.has("637796644552835083")) {%> <img title="Author is a library creator" src="https://cdn.discordapp.com/emojis/637971528792670218.png" height="25px"><%}}%> 
                              <%if(req.user) { if(req.user.id === bots[count].author || bot.guilds.get("500658335217876997").members.get(req.user.id) && bot.guilds.get("500658335217876997").members.get(req.user.id).roles.has("500662148561764352") || bot.guilds.get("500658335217876997").members.get(req.user.id) && bot.guilds.get("500658335217876997").members.get(req.user.id).roles.has("500658928602841099")) {%> 
                            <form action="/api/form/deletecomment?redirect=<%=id%>&page=<%=page%>" style="display:inline-block;position:absolute;right:1rem;" method="POST" id="form" enctype="application/x-www-form-urlencoded">&nbsp&nbsp&nbsp 
                            <input type="hidden" name="commentID" value="<%= bots[count].id %>">
                            <input type="hidden" name="bot" value="<%= bots[count].bot %>">
                              <input style="border-radius: 25px;display:inline-block;" type="submit" value="Delete comment" class="btn btn-danger" id="asshole" name="asshole"><% }} %></form></p>
                           <p style="display: inline-block; font-size: 18px; word-wrap:break-word"><%=bots[count].comment%> </p>
                           <i id="<%=bots[count].id%>" style="font-size:13px;color: white;"></i>
                           <% if(showbans && banned.has(bots[count].author)) {%>
                            <br>
                            <i style="color:red;font-size:13px;">This user is banned from the server/website, only moderators can see it.</i>
                            <% }%>
                           <script>
                            var asy = new Date("<%=bots[count].time%>")
                            var weekday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
                            var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
                          var datetoday = "th"
                    if(asy.getDate() == 1 || asy.getDate() == 21 || asy.getDate() == 31) datetoday = "st" 
                    if(asy.getDate() == 22 || asy.getDate() == 2) datetoday = "nd"
                    if(asy.getDate() == 3 || asy.getDate() == 23) datetoday = "rd"
var h = asy.getHours() > 12 ? asy.getHours() - 12 : asy.getHours()
var m = asy.getMinutes()
var s = asy.getSeconds()
var ap = asy.getHours() / 12 < 1 ? "AM" : "PM"
var totalanswer = h + ":" + m + " " + ap
document.getElementById("<%=bots[count].id%>").innerText = "Posted at " +  weekday[asy.getDay()] + ", " + asy.getDate() + datetoday + " " + months[asy.getMonth()] + " " + asy.getFullYear() + " at " + totalanswer
                            </script>
                          </div>
                        <br>
                          <% count++ }%>
                          <% }%>
                          <div>
                            <br><br>
                            <center>
             <%if(req.params.page == 1 || req.params.page == 0) {%>
          
              <a class="btn btn-grey">Previous page</a>
               <a class="btn btn-primary" href="<%=Number(req.params.page) + 1%>">Next page</a></li>
              <% } else {%>
             <a class="btn btn-primary" href="<%=Number(req.params.page) - 1%>">PREVIOUS page</a>
             <%if(req.params.page >= Math.ceil(bot.comments.filter(r=> r.id === id).size) / 15) {%>
            <a class="btn btn-grey" style="background-color: grey;">Next page</a>
         <% } else {%>
           <a class="btn btn-primary" href="<%=Number(req.params.page) + 1%>">Next page</a>
         <% } }%>  
        </center>
         <br><br>
         </div> 
         <% } %>
        <br><br>
        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
        </body>
</html>
