I recently realised an issue with my webrings (made using garlic.garden's amazing
onionring :]), when i clicked the random button on the sites with my webring it would sometimes work and sometimes link to completely random places ',:'
After some digging i found the issue and a simple solution :)!
The issue lies in the widget code in the randomText variable: onclick='randomSite()'
I believe when a site has many onionrings or other scripts with a function named randomSite(), it will do likely
that randomSite() rather than your webrings, so it will link to other sites that arent part of it! (thats why it works fine on the index page, there no other randoms :P)
So how do you fix it?Simply naming your randomSite() to something unique to your webring should do the trick! e.g. i have randomApertureSite() for my aperture webring ^_^
Original code:
...
function randomSite() {
otherSites = sites.slice(); //create a copy of the sites list
otherSites.splice(thisIndex, 1); //remove the current site so we don't just land on it again
randomIndex = Math.floor(Math.random() * otherSites.length);
location.href = otherSites[randomIndex];
}
...
if (useRandom) {
randomText = `<a href='javascript:void(0)' onclick='randomSite()'>random</a> | `;
}
...
Fixed code:
...
function randomYourWebringSite() {
otherSites = sites.slice(); //create a copy of the sites list
otherSites.splice(thisIndex, 1); //remove the current site so we don't just land on it again
randomIndex = Math.floor(Math.random() * otherSites.length);
location.href = otherSites[randomIndex];
}
...
if (useRandom) {
randomText = `<a href='javascript:void(0)' onclick='randomYourWebringSite()'>random</a> | `;
}
...
Hope this can help someone else out :D!