From 2915b7ed3b945d5b3c03e3598f6d90d3c9ba673a Mon Sep 17 00:00:00 2001 From: ayan-b Date: Fri, 29 Jun 2018 02:31:31 +0530 Subject: [PATCH] Minor fixes --- js/main.js | 57 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/js/main.js b/js/main.js index 1236544..044ebca 100644 --- a/js/main.js +++ b/js/main.js @@ -30,40 +30,46 @@ $(document).ready(function(){ let show = event_type; switch (event_type) { case "CommitCommentEvent": + show = user + ' commented on ' + activity.comment.commit_id.substring(0,10) + + ' at ' + repo + '
' + activity.comment.body; break; case "CreateEvent": break; case "DeleteEvent": - break; - case "DownloadEvent": - break; - case "FollowEvent": - show = user + ' started following ' + activity.payload.target.login + "
"; + var ref = activity.payload.ref, + ref_type = activity.payload.ref_type; + show = user + " deleted " + ref_type + " " + ref + " at " + repo + "
"; break; case "ForkEvent": - show = " forked " + repo + ' into  ' + activity.payload.forkee.full_name + " 
"; - break; - case "ForkApplyEvent": - break; - case "GistEvent": + show = user + "forked" + repo + 'into ' + activity.payload.forkee.full_name + "
"; 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 + ' / ' + + activity.payload.issue.title + "
" + body + "
"; 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 + " " + action + " issue " + repo + ' / ' + activity.payload.issue.title + "
" + body + "
", action + show = user + " " + action + " issue at " + repo + '' + ': ' + activity.payload.issue.title + + "
" + body + "
"; break; case "MemberEvent": break; case "PublicEvent": + show = user + ' made ' + repo + ' public'; break; case "PullRequestEvent": - show = user + " " + activity.payload.action + '  a pull request: ' + activity.repo.name + "/#" + activity.payload.number + '
' + activity.payload.pull_request.head.sha.substring(0, 10) + " " + activity.payload.pull_request.title + "
"; + show = user + " " + activity.payload.action + ' a pull request:' + activity.repo.name + "/#" + activity.payload.number + '
' + activity.payload.pull_request.head.sha.substring(0, 10) + " " + activity.payload.pull_request.title + "
"; break; case "PullRequestReviewCommentEvent": break; @@ -83,18 +89,18 @@ $(document).ready(function(){ for (; count >= ii;) body += '
' + activity.payload.commits[ii - 1].sha.substring(0, 10) + " " + (activity.payload.commits[ii - 1].message.length > 250 ? activity.payload.commits[ii - 1].message.substring(0, 249) + "..." : activity.payload.commits[ii - 1].message) + "
", ii++; body += 'compare these commits »' } - show = user +" pushed " + count + " " + commit + ' to  ' + ref + "  at " + repo + "
" + body; + show = user +" pushed " + count + " " + commit + ' to ' + ref + " at " + repo + "
" + body; break; case "ReleaseEvent": - show = user + ' released   ' + activity.payload.release.name + - " at " + repo + "
"; + " at " + repo + "
"; break; case "TeamAddEvent": break; case "WatchEvent": - show = "
" + user + " started watching " + repo + "
" + "
" + show = "
" + user + " starred " + repo + "
" + "
" break; } @@ -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": @@ -152,7 +161,7 @@ $(document).ready(function(){
${repo.name}arrow_drop_down_circle -

${repo.description}

+

${desc}

@@ -218,4 +227,12 @@ $(document).ready(function() { } }); -}); \ No newline at end of file +}); + +function truncate (str, len){ + + if (str.length > len){ + return (str.substring(0, len-1) + "..."); + } +return str; +} \ No newline at end of file