forked from Haimantika/GitHub-roast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Haimantika#7 from jagdishpatil02/main
added new save functionality to save generated roast
- Loading branch information
Showing
3 changed files
with
43 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
async function getRoast() { | ||
const username = document.getElementById('username').value; | ||
if (!username) { | ||
alert('Please enter a GitHub username.'); | ||
return; | ||
} | ||
|
||
try { | ||
const response = await fetch(`/roast/${username}`); | ||
const data = await response.json(); | ||
document.getElementById('roastOutput').textContent = data.roast || 'No roast available.'; | ||
} catch (error) { | ||
console.error('Failed to fetch roast:', error); | ||
document.getElementById('roastOutput').textContent = 'Failed to fetch roast. Please try again.'; | ||
} | ||
const username = document.getElementById("username").value; | ||
if (!username) { | ||
alert("Please enter a GitHub username."); | ||
return; | ||
} | ||
|
||
|
||
|
||
try { | ||
const response = await fetch(`/roast/${username}`); | ||
const data = await response.json(); | ||
document.getElementById("roastOutput").textContent = | ||
data.roast || "No roast available."; | ||
} catch (error) { | ||
console.error("Failed to fetch roast:", error); | ||
document.getElementById("roastOutput").textContent = | ||
"Failed to fetch roast. Please try again."; | ||
} | ||
} | ||
|
||
function saveRoast() { | ||
html2canvas(document.getElementById("roastWrapper")).then(function (canvas) { | ||
var link = document.createElement("a"); | ||
link.href = canvas.toDataURL("image/png"); | ||
link.download = "roast.png"; | ||
link.click(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters