Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
a Summer day - @474.10 (what is this?)
Activity rating: Four Stars Posts & Arts: 51/1k.beats Random | Recent Posts | Guild Recents
News: inconvenience is counterculture :eyes: Guild Events: HOMESTUCK ART-APALOOZA

+  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 862 times)
jack_dawlia
Jr. Member ⚓︎
**
View Profile WWWArt


catgirl irl
⛺︎ My Room

Guild Memberships:
Artifacts:
GLaDOS' Test Chamber VeteranJoined 2024!
« on: a Winter night » 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)
PurpleHello98
Sr. Member ⚓︎
****
View Profile WWW


'Cause I'm your girl, hold me baby <3
⛺︎ My Room
StatusCafe: purplehello98

Artifacts:
First 1000 Members!Joined 2022!
« Reply #1 on: a Summer day » Embed

THANK YOU SO MUCH!!!! I had been wondering about this for ages for my K-pop webring and now it looks to be working perfectly. :) <3
Logged

"...And we are not angels, to be comforted by seeing the means for which everything is sent."
-Elizabeth Gaskell, Wives and Daughters


https://purplehello98.neocities.org/graphics/userbars/46535.png
https://purplehello98.neocities.org/graphics/buttons/purplehello98.gifhttps://purplehello98.neocities.org/graphics/buttons/neocities-pink.gifhttps://purplehello98.neocities.org/graphics/buttons/vrvr-purple.gif
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

Minecraft: Online
Join: craft.melonking.net