Skip to content

Commit fab8097

Browse files
committed
feat(page work on get attribute, reproducible): use "username" as query parameter to get events, better for testing and future maybe
1 parent 728695c commit fab8097

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

public/index.html

+22-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
}
3333
</style>
3434
<script>
35-
async function fetchEvents() {
36-
const username = document.getElementById("username").value;
35+
async function fetchEvents(username) {
3736
if (!username) {
3837
alert("Please enter a username");
3938
return;
@@ -72,12 +71,32 @@
7271
</div>
7372
`;
7473
}
74+
75+
let username = /\?username=([^&]+)/.exec(window.location.search)[1];
76+
if (username) {
77+
fetchEvents(username);
78+
setTimeout(() => {
79+
document.getElementById("username").value = username;
80+
}, 1000);
81+
}
82+
83+
function redirect() {
84+
const username = document.getElementById("username").value;
85+
86+
if (!username) {
87+
alert("Please enter a username");
88+
return;
89+
}
90+
91+
window.location.href = `/?username=${username}`;
92+
}
93+
7594
</script>
7695
</head>
7796
<body>
7897
<h1>Enter GitHub Username to Fetch Events</h1>
7998
<input type="text" id="username" placeholder="Enter GitHub username" />
80-
<button onclick="fetchEvents()">Fetch Events</button>
99+
<button onclick="redirect()">Fetch Events</button>
81100

82101
<div id="result" style="margin-top: 20px"></div>
83102
</body>

0 commit comments

Comments
 (0)