This zone is sleeping right now! ZzzZZzzz

Better not distrub it! ~You go to the petrol station and buy a slushy instead, everything is cool!~

This area will open again in 000.beats!

(Learn about Swatch Time)

Some other zones are awake :^]


Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
May 25, 2026 - @590.74 (what is this?)
Activity rating: Three Stars Posts & Arts: 39/1k.beats Random | Recent Posts | Guild Recents
News: Love is not possession  :4u: Guild Events: Spring Themed Projects

+  MelonLand Forum
|-+  Materials & Info
| |-+  ☮︎ ∙ Communities & Webrings
| | |-+  A fix for random site for onionrings!


« previous next »
Pages: [1] Print Embed
Author Topic: A fix for random site for onionrings!  (Read 666 times)
jack_dawlia
Jr. Member ⚓︎
**
View Profile WWWArt


catgirl irl
⛺︎ My Room

Guild Memberships:
Artifacts:
GLaDOS' Test Chamber VeteranJoined 2024!
« on: February 10, 2026 @897.86 » Embed

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:
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:
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!
Logged

- the silly (xe/xir)
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
MelonLand @000

Want to Login or Join ?

Minecraft: Online
Join: craft.melonking.net