Skip to content

Commit

Permalink
fix: show text incase of html
Browse files Browse the repository at this point in the history
  • Loading branch information
Mussabaheen committed Mar 25, 2024
1 parent ec8c16b commit 25b262f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@
}

function copyToClipboard(element) {
var text = element.textContent.trim();
if(typeof(element)!="string"){
var text = element.textContent.trim();
}
else{
var text = element;
}
var textarea = document.createElement("textarea");
textarea.value = text;
document.body.appendChild(textarea);
Expand All @@ -213,8 +218,8 @@
copyToClipboard(itemText);
}
function expandText(button) {
var itemText = button.previousElementSibling.textContent;
toggleExpand(itemText);
var listItem = button.parentElement; // Get the <li> element containing the button
toggleExpand(listItem);
}
</script>
</head>
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func main() {

http.HandleFunc("/", ShowClipboard)
http.HandleFunc("/updates", UpdatesHandler)
fmt.Println("serving the clipboard UI :", *localPort)
err = http.ListenAndServe(":"+*localPort, nil)
if err != nil {
panic("error occured while running clipboard : " + err.Error())
Expand Down

0 comments on commit 25b262f

Please sign in to comment.