-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
117 lines (105 loc) · 4.82 KB
/
index.html
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My GitHub Widgets</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="styles.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cinzel:wght@400..900&display=swap" rel="stylesheet">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1059149013243103"
crossorigin="anonymous"></script>
</head>
<body>
<div class="head">
<h1>My GitHub Widgets</h1>
</div>
<p>Include this script tag in your webpage</p>
<textarea name="" id="script-frame" readonly rows="4" cols="80"></textarea>
<section>
<div class="profile-details">
<h2>Profile Widget</h2>
<input type="text" id="username-input" placeholder="Enter GitHub Username"><br>
<button type="submit" onclick="generatePIframe()">Create Profile Widget</button><br>
<p id="error-message" style="color: red;"></p>
</div>
<div>
<h3>Embed Code:</h3>
<textarea id="iframe-code-p" readonly rows="4" cols="80"></textarea>
</div>
<div id="iframe-container-p">
<h3>Preview:</h3>
<iframe id="profile-iframe"></iframe>
</div>
</section>
<hr>
<section>
<div class="repo-details">
<h2>Repository Widget</h2>
<input id="repo-input" type="text" placeholder="Username/Repo-name"><br>
<button id="generate-button" type="button" onclick="generateIframe()">Generate Repository
Widget</button><br>
<p id="error-message1" style="color: red;"></p>
</div>
<div>
<h3>Embed Code:</h3>
<textarea id="iframe-code" readonly rows="4" cols="80"></textarea>
</div>
<div id="iframe-container">
<h3>Preview:</h3>
<iframe id="repo-iframe" src=""></iframe>
</div>
</section>
<footer>
<h3>Created by: <a href="https://github.com/notquitelikeme">Dennis Magaki(notquitelikeme)</a></h3>
<h4>Notes: </h4>
<p>Watching Value in Repository Widgets may not be correct, might resemble value in Stars : looking into problem
</p>
<p>Errors in console resulting from usage of widgets can be ignored unless it is necessary : looking to rectify
</p>
</footer>
<script src="script.js"></script>
<script src="script1.js"></script>
<script>
function generateIframe() {
const input = document.getElementById('repo-input').value.trim();
const [owner, repo] = input.split('/');
if (!owner || !repo) {
document.getElementById('error-message').innerText = 'Both fields are required!';
return;
}
const iframeSrc = `https://git-hub-widgets.vercel.app/repo.html?owner=${encodeURIComponent(owner)}&repo=${encodeURIComponent(repo)}`;
const iframeTag = `<iframe class="Frame" title="repo-frame" src="${iframeSrc}"></iframe>`;
document.getElementById('repo-iframe').src = iframeSrc;
document.getElementById('iframe-code').value = iframeTag;
document.getElementById('error-message').innerText = '';
}
</script>
<script>
function generatePIframe() {
const username = document.getElementById('username-input').value;
if (!username) {
document.getElementById('error-message').textContent = 'Please enter a GitHub username';
return;
}
const PiframeSrc = `https://git-hub-widgets.vercel.app/profile.html?username=${encodeURIComponent(username)}`;
const PiframeTag = `<iframe class="PFrame" title="profile-frame" src="${PiframeSrc}"></iframe>`;
document.getElementById('profile-iframe').src = PiframeSrc;
document.getElementById('iframe-code-p').value = PiframeTag;
document.getElementById('error-message').innerText = '';
}
</script>
<script>
function displayScriptTag() {
const scriptSrc = `https://git-hub-widgets.vercel.app/framescript.js`;
const scriptTag = `<script src="${scriptSrc}"><\/script>`;
document.getElementById('script-frame').value = scriptTag;
}
window.onload = displayScriptTag;
</script>
</body>
</html>