Last active
April 12, 2022 18:57
-
-
Save duplaja/a03149387c1789838ee3fea1344cc6a3 to your computer and use it in GitHub Desktop.
Rate LibraryThing Works
This file contains hidden or 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
window.addEventListener("load", function(event) { | |
const ratingtd = document.getElementById("ratingstdtitle"); | |
const orig_rating = document.getElementById("form_rating").value; | |
const button = document.createElement('a'); | |
button.setAttribute("id", "rate-button"); | |
button.innerHTML = "<h3>Rate Book (Current Rating: "+orig_rating+")</h3>" | |
ratingtd.insertBefore(button, ratingtd.firstChild) | |
var userratingbutton = document.getElementById("rate-button"); | |
userratingbutton.setAttribute("role", "button"); | |
userratingbutton.setAttribute("tabindex",0); | |
userratingbutton.addEventListener("click", setmyrating, false); | |
}); | |
function setmyrating() { | |
var ratings = document.getElementsByClassName("rating")[0]; | |
var rating_id = ratings.id; | |
var rating = prompt('Rate this book, 1-10: '); | |
var modrating = parseInt(rating,10) | |
setRating(rating_id, bookID, modrating, 1, 0); | |
var userratingbutton = document.getElementById("rate-button"); | |
userratingbutton.innerHTML = "<h3>Rate Book (Current Rating: "+rating+")</h3>" | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment