From 58a9329b314015d3b1745180113666e02b407fea Mon Sep 17 00:00:00 2001 From: techgaun Date: Sun, 18 Nov 2018 00:25:02 -0600 Subject: [PATCH] remove unused codes --- js/main.js | 80 ------------------------------------------------------ 1 file changed, 80 deletions(-) diff --git a/js/main.js b/js/main.js index 8e4620d..b99e771 100644 --- a/js/main.js +++ b/js/main.js @@ -118,88 +118,8 @@ function showMsg(msg, type) { `; } -function showData(data) { - if (!Array.isArray(data)) { - showMsg('GitHub repository does not exist', 'danger'); - return; - } - - if (data.length === 0) { - showMsg('No forks exist!'); - return; - } - - const html = []; - const thead = ` - - - Repository - Stargazers - Forks - Last Push - - - `; - - for (const fork of data) { - const item = ` - - ${fork.full_name} - ${fork.stargazers_count} - ${fork.forks_count} - ${timeSince(fork.pushed_at)} ago - - `; - html.push(item); - } - - document.getElementById('data-body').innerHTML = ` -
- - ${thead} - ${html.join('')} -
-
- `; - - document.getElementById('footer').innerHTML = `${data.length} ${data.length == 1 ? 'result' : 'results'}`; -} - function getRepoFromUrl() { const urlRepo = location.hash && location.hash.slice(1); return urlRepo && decodeURIComponent(urlRepo); } - -function timeSince(date_str) { - const date = new Date(date_str); - const seconds = Math.floor((new Date() - date) / 1000); - - let interval = Math.floor(seconds / 31536000); - - if (interval > 1) { - return interval + ' years'; - } - - interval = Math.floor(seconds / 2592000); - if (interval > 1) { - return interval + ' months'; - } - - interval = Math.floor(seconds / 86400); - if (interval > 1) { - return interval + ' days'; - } - - interval = Math.floor(seconds / 3600); - if (interval > 1) { - return interval + ' hours'; - } - - interval = Math.floor(seconds / 60); - if (interval > 1) { - return interval + ' minutes'; - } - - return Math.floor(seconds) + ' seconds'; -}