-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.js
35 lines (32 loc) · 1.57 KB
/
create.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
document.getElementById('generateBtn').addEventListener('click', function () {
var badgeType = document.getElementById('badgeType').value;
var username = document.getElementById('username').value;
var repository = document.getElementById('repository').value;
var markdownCode = '';
switch (badgeType) {
case 'stars':
markdownCode = `![Stars](https://img.shields.io/github/stars/${username}/${repository})`;
break;
case 'forks':
markdownCode = `![Forks](https://img.shields.io/github/forks/${username}/${repository})`;
break;
case 'watchers':
markdownCode = `![Watchers](https://img.shields.io/github/watchers/${username}/${repository})`
break
case 'license':
markdownCode = `[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/${username}/${repository}?tab=MIT-1-ov-file#readme)`
break
case 'release':
markdownCode = `![GitHub Release](https://img.shields.io/github/v/release/${username}/${repository})`
break
}
document.getElementById('markdownCode').textContent = markdownCode;
});
document.getElementById('copyBtn').addEventListener('click', function () {
var markdownCode = document.getElementById('markdownCode').textContent;
navigator.clipboard.writeText(markdownCode).then(function () {
alert('Markdown code copied to clipboard!');
}, function (err) {
console.error('Could not copy text: ', err);
});
});