I made a wordlegolf game that tracks your scores and one user can have multiple scoreboards. I am trying to have arrows that lets you rotate through your scoreboards. image of arrows
So I need to be able to track which scoreboard the user is currently on and rotate through each scoreboard
I've tried a bunch of things and was able to get it to work but now that I have implemented UUIDs I am getting a bunch of errors with my javascript. I tried adding this UUIDEncoder class which I saw online but that hasnt helped.
views.py
newlink = []
links = list(CreatedScoreboardUnique.objects.filter(players=request.user))
for link in links:
newlink.append(link.pk)
newlink = json.dumps(newlink, cls=UUIDEncoder)
class UUIDEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, UUID):
# if the obj is uuid, we simply return the value of uuid
return obj.hex
return json.JSONEncoder.default(self, obj)
html
<svg width="37" height="37" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" onclick="nextScoreboard()">
<path d="M15.0378 6.34317L13.6269 7.76069L16.8972 11.0157L3.29211 11.0293L3.29413 13.0293L16.8619 13.0157L13.6467 16.2459L15.0643 17.6568L20.7079 11.9868L15.0378 6.34317Z" fill="currentColor"/>
</svg>
javascript
function nextScoreboard(){
console.log('next clicked')
var links = JSON.parse("{{links|safe}}")
var currId = "{{scoreboard.id}}"
var nextlink = false
for(i = 0; i < links.length; i++){
if(links[i] == currId){
window.location.href = "http://127.0.0.1:8000/scoreboard/" + links[i+1]
}
}
}
This is the error I keep getting and cant figure out
Is there an easier way to do this or can you help with the error?