Forums

RS-Linkify Thread is sticky

Quick find code: 261-262-33-65181208

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Weyburns said :
Sweet, thanks for the thorough response as always.

I wasn't expecting anything malicious, I just was wondering what was happening with that. I'm not a huge tinfoil person but shit happens on the internet these days.

Keep up the good work Indy.
Tbh these are really good questions to ask, and should be asked :)


J3 said :
I just took a browse through the options added since I went into hiatus and it's clear you have been a busy bee indy, awesome stuff!

­coffee
Hiya J3 :)

A few little things have crept in and continue to do so. Hopefully there is something new and of use for you. Good to see you're still lurking :)


Hevilmystic said :
So I noticed something funny with the unnamed Jmod posts on the forums (thanks Squallsy), taken from this post .
Damn those unnamed jmods. I'll put a stop to that, cant have 'em ripping off the RS Linkify badge.


Erehk said :
Oooh also, thought I'd mention that there's a new Rules page (here) just in case Linkify's link in the Game Guide drop-down needed to be updated. :)
Sweet thanks for that, I totally forgot I even have a link to the (old) rules. I'll update that in my next update :)

------------------------------------------


Coffee for all :)

https://gfycat.com/EnormousNearChuckwalla

13-Aug-2016 00:03:57

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Hevilmystic said :
I'm curious as to why it defaults to my name! I thought I'd done something wrong... #BlameRowley


Blame Rowley if it doesnt work!



Actually it defaulted to everyone's name. Just the final result was your name.

The names (for badges) are read and written as a collection of names. Even though in the code you're the 4th name, once being made into an array and stored in an object all the values get sorted alphanumerically.

This means nothing comes after Rowley and that's where determining a name for a badge stops.

For me the question wasn't why you. It was why is this even happening? Clearly its something to do with the badges as RS Linkify is trying hard to do something badge related. But not doing any of it particularly well.

The names for badges are hard coded. The criteria for being assigned a badge is you must be in the list of names. Or as is it seems, have no name at all.

Not something I recall seeing before, but it's an easy fix. Since I have way too many characters remaining and even though you didn't ask, I'm going to tell you why it worked or not worked (half a badge) the way it did :)

The player name (in this case missing name) is not only used to determine if a badge is assigned. The element displaying the name also acts as an anchor point or point of reference. This point of reference determines where to place new elements (badge, text, flip side badge) and without it RS Linkify wasn't able to build a new badge into the page, not completely anyway, just some bits.

This version ( 3.1.9.72 ) means no-namers don't get a badge and the Runes of RuleScape link has been updated to the new rules.

13-Aug-2016 07:19:04 - Last edited on 13-Aug-2016 07:20:37 by Indecent Act

Morgan

Morgan

Posts: 36,054 Sapphire Posts by user Forum Profile RuneMetrics Profile
Hey Indsypie,
Perhaps it's not needed (yet), but since Linkify is growing, and I'm seeing it expand overtime, I've been thinking that perhaps something like what Chrome has for settings should be considered.

A search settings box!

http://i.imgur.com/PNEgJIb.png

Again, I don't know if it's doable or needed (yet), but still!

13-Aug-2016 07:52:59

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Hevilmystic said :
How do you mean by this?

Oh that's a major can of worms in javascript, but it is also a good can of worms because I just learnt a few new things while answering your question. I realise now my original answer is lacking, but I'll leave that for now as new stuff is still sinking in :)


From the ECMAScript Specification:

An object is a member of the type Object. It is an unordered collection of properties each of which contains a primitive value, object, or function.


A little code example:
[code]nameList = {
'rowley' : 'Over Powered!',
'morgan' : 'Warm Javascripts'
};[/code]

Think of yours and morgan's names as keys, and the 'Over Powered!' and 'Warm Javascripts' as values.

In the code above 'Over Powered!' is assigned to 'rowley' and 'Warm Javascripts' assigned to morgan. So when I call "rowley" against nameList the returned value is 'Over Powered!'.

What's cool about this is I don't ever need to know where 'rowley' is in the list or even if your name is in the list.

Often things are indexed numerically and that helps finding things. But what if you don't know the index, or the index has changed, or even if the amount of keys has changed. Looking for index #4 in a list of 2 names wont end well and will throw an error, but calling 'rowleyyyy' against the list simply returns nothing and throws no errors. That's the beauty of these kinds of objects, when and where doesn't matter.

There is no specification on the order in which keys and values are stored. There is no guarantee how they will ordered. But most modern browsers make an attempt to preserve order. But when asking the browser for a visual interpretation of nameList, it's alphabetical. In local storage its also alphabetical (appears to be).

How you read from nameList also determines order, map/loop/forEach/obj.keys do different things and do or not preserve order.

13-Aug-2016 16:38:03 - Last edited on 13-Aug-2016 17:08:03 by Indecent Act

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Continued....

Now I have got the basics out of the way, my original theory on why your name was on that rouge J-Mod's badge may not have been because your name is last alphabetically. But it could have been.

You see I made some assumptions. Since I work a lot with chrome local storage, and when reading objects (objects like the nameList code example) from local storage they are always sorted alphabetically by key name. I assumed that's the default nature of how those things are handled.

But if modern browsers do attempt to preserve original order then my conclusions shouldn't ring true (even though they do). Also these names are not pulled from local storage, they are simply coded in, so again I should not assume they behave in the same way as my object from local storage.

Where am I going with this? Good question :)

Looking at it differently and using some of the new info I learned...

Some Linkify code..
http://i.imgur.com/LaA6obg.png
Notice the empty quotes. Now imagine cross-referencing all the text against "rowley", what we get is your title 'over powered' and your badge ID 'R'.

Now lets use the unnamed jmod and cross-reference with that same object....

Ding Ding Ding...

We have a match, right after keighlea's zaros powered there is '' <--- empty quotes because her badge is default and has no ID. But look at what comes after that....your name!

"" <-- Empty quotes = nothing, thus having no name will match ""

The code found a match (nothing or no name) and takes that as the player/mod name, then it looks at the next word and uses that for the title. And that next bit of text is....your name!

13-Aug-2016 16:38:17 - Last edited on 13-Aug-2016 17:10:29 by Indecent Act

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Continued again....

So there you go, I was kind of wrong, but for the right reasons. The same result could have been achieved by my first theory if I were pulling the data from storage and depending how I iterated over that data. But that's not the cause here. I overlooked that nothing is something, but I think in this case we can blame Keighlea, because if she had a custom badge, it wouldn't have happened, not with your name anyway :)


And I have to say it...

You had to ask didn't you!

I even surprised myself with the length of this reply and I'm laughing at myself because I don't even know if I answered your question!

So if you made it this far, this is much deserved...

HTTP://thumbs.ifood.tv/files/image/99/6e/48258-irish-coffee.jpg


Anyway was fun (always is) attempting to give you a reply :)


-----------------------------------------


Morgan said :
Hey Indsypie,
Perhaps it's not needed (yet), but since Linkify is growing, and I'm seeing it expand overtime, I've been thinking that perhaps something like what Chrome has for settings should be considered.

A search settings box!

http://i.imgur.com/PNEgJIb.png

Again, I don't know if it's doable or needed (yet), but still!

Going to look at giving the options a revamp, not sure if I can make a search thing practical for the options but I'll certainly keep it in mind :)

13-Aug-2016 16:43:10 - Last edited on 13-Aug-2016 17:27:41 by Indecent Act

Hevilmystic
Feb Member 2022

Hevilmystic

Posts: 60,012 Emerald Posts by user Forum Profile RuneMetrics Profile
Indecent Act said :
You had to ask didn't you!


Yess I did because I love reading your responses to almost anything asked by here - unparallelled attention to detail. Thank you for taking the time to explain it to someone otherwise oblivious :)

You don't have to blame Keighlea! You're free to blame me (as usual!)

http://i.imgur.com/EVFLFGQ.jpg
Unslain Bosses - Clan

13-Aug-2016 18:09:52 - Last edited on 13-Aug-2016 18:10:29 by Hevilmystic

Quick find code: 261-262-33-65181208 Back to Top