Skip to content

Commit f2648aa

Browse files
authored
Merge pull request #36 from couchbase/ui-bug-fixes
fix lint errors
2 parents a52c494 + 7fa3f25 commit f2648aa

File tree

1 file changed

+77
-77
lines changed

1 file changed

+77
-77
lines changed

src/js/08-contributor-bot.js

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -3,85 +3,85 @@
33
var showData = false
44
var contributors
55
if (document.getElementById('contributorList')) {
6-
var contributorList = document.getElementById('contributorList')
7-
var commitdateTag = document.getElementById('commitdate')
8-
var otherContributor = document.getElementById('otherContributor')
9-
var contributorListBox = document.querySelector('.contributor-list-box')
10-
var apiURL = 'https://api.github.com'
11-
var githubRepo = '/couchbase/docs-ui'
12-
// var url = 'https://api.github.com/repos/couchbase/docs-ui/stats/contributors'
13-
// var contributorEveryDayURL = 'repos/couchbase/docs-ui/stats/contributors'
14-
// Call the fetch function passing the url of the API as a parameter
15-
// eslint-disable-next-line no-undef
16-
fetch(apiURL + '/repos' + githubRepo + '/stats/contributors')
17-
.then(function (resp) {
18-
var data = resp.json()
19-
return data
20-
})
21-
.then(function (data) {
22-
showData = true
23-
contributors = data
24-
var otherContributorData = contributors.length - 5
25-
var maxCommitLength = contributors.length - 1
26-
var maxCommitAuthor = contributors[maxCommitLength]
27-
// get last commit date
28-
var totalWeek = maxCommitAuthor.weeks
29-
var totaltWeekLength = totalWeek.length - 1 // array
30-
var lastCommitWeek = totalWeek[totaltWeekLength]
31-
var lastCommitTimeStamp = lastCommitWeek.w // object
32-
var lastCommitDate = new Date(lastCommitTimeStamp * 1000) // convert timestamp to date
33-
var getDate = lastCommitDate.getDate()
34-
var getYear = lastCommitDate.getFullYear()
35-
// eslint-disable-next-line no-array-constructor
36-
var month = new Array()
37-
month[0] = 'January'
38-
month[1] = 'February'
39-
month[2] = 'March'
40-
month[3] = 'April'
41-
month[4] = 'May'
42-
month[5] = 'June'
43-
month[6] = 'July'
44-
month[7] = 'August'
45-
month[8] = 'September'
46-
month[9] = 'October'
47-
month[10] = 'November'
48-
month[11] = 'December'
49-
var getMonth = month[lastCommitDate.getMonth()]
50-
var latestCommitDate = getMonth + ' ' + getDate + ', ' + getYear
51-
commitdateTag.append(latestCommitDate)
52-
otherContributor.append(otherContributorData)
6+
var contributorList = document.getElementById('contributorList')
7+
var commitdateTag = document.getElementById('commitdate')
8+
var otherContributor = document.getElementById('otherContributor')
9+
var contributorListBox = document.querySelector('.contributor-list-box')
10+
var apiURL = 'https://api.github.com'
11+
var githubRepo = '/couchbase/docs-ui'
12+
// var url = 'https://api.github.com/repos/couchbase/docs-ui/stats/contributors'
13+
// var contributorEveryDayURL = 'repos/couchbase/docs-ui/stats/contributors'
14+
// Call the fetch function passing the url of the API as a parameter
15+
// eslint-disable-next-line no-undef
16+
fetch(apiURL + '/repos' + githubRepo + '/stats/contributors')
17+
.then(function (resp) {
18+
var data = resp.json()
19+
return data
20+
})
21+
.then(function (data) {
22+
showData = true
23+
contributors = data
24+
var otherContributorData = contributors.length - 5
25+
var maxCommitLength = contributors.length - 1
26+
var maxCommitAuthor = contributors[maxCommitLength]
27+
// get last commit date
28+
var totalWeek = maxCommitAuthor.weeks
29+
var totaltWeekLength = totalWeek.length - 1 // array
30+
var lastCommitWeek = totalWeek[totaltWeekLength]
31+
var lastCommitTimeStamp = lastCommitWeek.w // object
32+
var lastCommitDate = new Date(lastCommitTimeStamp * 1000) // convert timestamp to date
33+
var getDate = lastCommitDate.getDate()
34+
var getYear = lastCommitDate.getFullYear()
35+
// eslint-disable-next-line no-array-constructor
36+
var month = new Array()
37+
month[0] = 'January'
38+
month[1] = 'February'
39+
month[2] = 'March'
40+
month[3] = 'April'
41+
month[4] = 'May'
42+
month[5] = 'June'
43+
month[6] = 'July'
44+
month[7] = 'August'
45+
month[8] = 'September'
46+
month[9] = 'October'
47+
month[10] = 'November'
48+
month[11] = 'December'
49+
var getMonth = month[lastCommitDate.getMonth()]
50+
var latestCommitDate = getMonth + ' ' + getDate + ', ' + getYear
51+
commitdateTag.append(latestCommitDate)
52+
otherContributor.append(otherContributorData)
5353

54-
// show html data
55-
if (showData) {
56-
contributorListBox.classList.add('show')
57-
}
58-
// map function
54+
// show html data
55+
if (showData) {
56+
contributorListBox.classList.add('show')
57+
}
58+
// map function
5959

60-
contributors
61-
.slice(0)
62-
.reverse()
63-
.map(function (contributor, index, arrayobj) {
64-
//show only top 5 contributor
65-
if (index <= 4) {
66-
var contributorAvtar = contributor.author.avatar_url
67-
// var contributorTotalCommit = contributor.total
68-
var authorURL = contributor.author.html_url
69-
// append child in ul
70-
var li = document.createElement('li')
71-
var anchor = document.createElement('a')
72-
var image = document.createElement('img')
73-
image.setAttribute('src', contributorAvtar)
74-
image.setAttribute('alt', '')
75-
anchor.setAttribute('href', authorURL)
76-
anchor.setAttribute('target', '_blank')
77-
li.appendChild(anchor)
78-
anchor.appendChild(image)
79-
contributorList.appendChild(li)
80-
}
60+
contributors
61+
.slice(0)
62+
.reverse()
63+
.map(function (contributor, index, arrayobj) {
64+
//show only top 5 contributor
65+
if (index <= 4) {
66+
var contributorAvtar = contributor.author.avatar_url
67+
// var contributorTotalCommit = contributor.total
68+
var authorURL = contributor.author.html_url
69+
// append child in ul
70+
var li = document.createElement('li')
71+
var anchor = document.createElement('a')
72+
var image = document.createElement('img')
73+
image.setAttribute('src', contributorAvtar)
74+
image.setAttribute('alt', '')
75+
anchor.setAttribute('href', authorURL)
76+
anchor.setAttribute('target', '_blank')
77+
li.appendChild(anchor)
78+
anchor.appendChild(image)
79+
contributorList.appendChild(li)
80+
}
81+
})
82+
})
83+
.catch(function (err) {
84+
console.log(err, 13)
8185
})
82-
})
83-
.catch(function (err) {
84-
console.log(err, 13)
85-
})
8686
}
8787
})()

0 commit comments

Comments
 (0)