Skip to content

Commit

Permalink
Add some events #6
Browse files Browse the repository at this point in the history
  • Loading branch information
ayan-b committed Jun 28, 2018
1 parent 857319d commit 1e726d0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
8 changes: 5 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
<br> <br>
<div id="profile"></div>
<div class="fixed-action-btn left-button">
<a class="btn-floating btn-large purple hoverable modal-trigger tooltipped" data-delay="20" data-position="right" data-tooltip="Send a message" href="#modal1">
<a class="btn-floating btn-large purple hoverable modal-trigger tooltipped"
data-delay="20" data-position="right" data-tooltip="Send a message" href="#modal1">
<i class="large material-icons">comment</i>
</a>
</div>
Expand All @@ -73,7 +74,8 @@

<div class="row">
<div class="input-field col s12">
<textarea id="message" class="materialize-textarea" name="message" required></textarea>
<textarea id="message" class="materialize-textarea" name="message" required>
</textarea>
<label for="message">Message</label>
</div>
</div>
Expand Down Expand Up @@ -111,7 +113,7 @@ <h2 class=""> Thanks for submitting your response!<i class="material-icons mediu
<script type="text/javascript" src="static/materialize/js/materialize.min.js"></script>
<script src = "js/main.js"></script>
<script data-cfasync="false" type="text/javascript" src="js/form-handler.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.8.6/showdown.min.js"></script>
<script type="text/javascript" src="static/showdown/dist/showdown.min.js"></script>
<script>
$(document).ready(function(){
$('.modal').modal();
Expand Down
57 changes: 37 additions & 20 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,46 @@ $(document).ready(function(){
let show = event_type;
switch (event_type) {
case "CommitCommentEvent":
show = user + ' <a target = "_blank" href=' +
activity.comment.html_url + '>commented on ' + activity.comment.commit_id.substring(0,10) +
' at ' + repo + '<blockquote>' + activity.comment.body;
break;
case "CreateEvent":
break;
case "DeleteEvent":
break;
case "DownloadEvent":
break;
case "FollowEvent":
show = user + '&nbsp;started following&nbsp;<a href="' + activity.payload.target.html_url + '">' + activity.payload.target.login + "</a><br>";
var ref = activity.payload.ref,
ref_type = activity.payload.ref_type;
show = user + " deleted " + ref_type + " " + ref + " at " + repo + "<br>";
break;
case "ForkEvent":
show = "&nbsp;forked&nbsp;" + repo + '&nbsp;into&nbsp;&nbsp;<a href="https://github.com/' + activity.payload.forkee.full_name + '">' + activity.payload.forkee.full_name + "</a>&nbsp;<br>";
break;
case "ForkApplyEvent":
break;
case "GistEvent":
show = user + "forked" + repo + 'into <a href="https://github.com/' +
activity.payload.forkee.full_name + '">' + activity.payload.forkee.full_name + "</a><br>";
break;
case "GollumEvent":
break;
case "IssueCommentEvent":
var converter = new showdown.Converter();
var body = truncate (activity.payload.issue.body, 250);
body = converter.makeHtml(body);
show = user + " commented on issue: " + repo + ' / <a href="' + activity.payload.issue.html_url + '">' +
activity.payload.issue.title + "</a><br/><blockquote>" + body + "</blockquote>";
break;
case "IssuesEvent":
var converter = new showdown.Converter(),
action = activity.payload.action,
body = activity.payload.issue.body.length > 250 ? activity.payload.issue.body.substring(0, 249) + "..." : activity.payload.issue.body;
body = truncate(activity.payload.issue.body, 250);
body = converter.makeHtml(body);
show = user + "&nbsp;" + action + "&nbsp;issue&nbsp;" + repo + '&nbsp;/&nbsp;<a target="_blank" href="' + activity.payload.issue.html_url + '">' + activity.payload.issue.title + "</a><blockquote>" + body + "</blockquote>", action
show = user + " " + action + " issue at " + repo + '<a target="_blank" href="' +
activity.payload.issue.html_url + '">' + ': ' + activity.payload.issue.title +
"</a><blockquote>" + body + "</blockquote>";
break;
case "MemberEvent":
break;
case "PublicEvent":
show = user + ' made ' + repo + ' public';
break;
case "PullRequestEvent":
show = user + "&nbsp;" + activity.payload.action + '&nbsp; a pull request:&nbsp;<a href="' + activity.payload.pull_request.html_url + '">' + activity.repo.name + "/#" + activity.payload.number + '</a><br/><blockquote><a href="' + activity.payload.pull_request.head.repo.html_url + "/commit/" + activity.payload.pull_request.head.sha + '">' + activity.payload.pull_request.head.sha.substring(0, 10) + "</a>&nbsp;" + activity.payload.pull_request.title + "</blockquote>";
show = user + " " + activity.payload.action + ' a pull request:<a href="' + activity.payload.pull_request.html_url + '">' + activity.repo.name + "/#" + activity.payload.number + '</a><br/><blockquote><a href="' + activity.payload.pull_request.head.repo.html_url + "/commit/" + activity.payload.pull_request.head.sha + '">' + activity.payload.pull_request.head.sha.substring(0, 10) + "</a>&nbsp;" + activity.payload.pull_request.title + "</blockquote>";
break;
case "PullRequestReviewCommentEvent":
break;
Expand All @@ -83,18 +89,18 @@ $(document).ready(function(){
for (; count >= ii;) body += '<blockquote><a href="https://github.com/' + activity.repo.name + "/commit/" + activity.payload.commits[ii - 1].sha + '">' + activity.payload.commits[ii - 1].sha.substring(0, 10) + "</a>&nbsp;" + (activity.payload.commits[ii - 1].message.length > 250 ? activity.payload.commits[ii - 1].message.substring(0, 249) + "..." : activity.payload.commits[ii - 1].message) + "</blockquote>", ii++;
body += '<a target="_blank" href="https://github.com/' + activity.repo.name + "/compare/" + first + "..." + last + '">compare these commits &raquo;</a>'
}
show = user +"&nbsp;pushed&nbsp;" + count + "&nbsp;" + commit + ' to&nbsp;<span class="well"><span class="octicon octicon-git-branch"></span>&nbsp;<a href="https://github.com/' + activity.repo.name + "/tree/" + ref + '">' + ref + "</a>&nbsp;</span>&nbsp;at&nbsp;" + repo + "<br/>" + body;
show = user +" pushed " + count + " " + commit + ' to <a href="https://github.com/' + activity.repo.name + "/tree/" + ref + '">' + ref + "</a> at " + repo + "<br>" + body;
break;
case "ReleaseEvent":
show = user + '&nbsp;released&nbsp;<a target="_blank" href="' + activity.payload.release.zipball_url +
'"></span></a>&nbsp;<a target="_blank" href="' +
show = user + ' released <a target="_blank" href="' + activity.payload.release.zipball_url +
'"></a> <a target="_blank" href="' +
activity.payload.release.html_url + '">' + activity.payload.release.name +
"</a></span>&nbsp;at&nbsp;" + repo + "<br/>";
"</a> at " + repo + "<br/>";
break;
case "TeamAddEvent":
break;
case "WatchEvent":
show = "<div>" + user + "&nbsp;started watching&nbsp;" + repo + "<br>" + "</div>"
show = "<div>" + user + " starred " + repo + "<br>" + "</div>"
break;

}
Expand Down Expand Up @@ -123,6 +129,9 @@ $(document).ready(function(){
}).done(function(repos){
//console.log(repos);
$.each(repos, function(index, repo){
let desc = repo.desciption;
if (desc==null)
desc = "";
let lang = repo.language.toLowerCase();
switch (lang){
case "html":
Expand Down Expand Up @@ -153,7 +162,7 @@ $(document).ready(function(){
</div>
<div class="card-reveal">
<span class="card-title grey-text text-darken-4">${repo.name}<i class="material-icons right blue-grey-text darken-1 small">arrow_drop_down_circle</i></span>
<p>${repo.description}</p>
<p>${desc}</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -220,4 +229,12 @@ $(document).ready(function() {
}
});

});
});

function truncate (str, len){

if (str.length > len){
return (str.substring(0, len-1) + "...");
}
return str;
}

0 comments on commit 1e726d0

Please sign in to comment.