Forums

RS-Linkify Thread is sticky

Quick find code: 261-262-33-65181208

Morgan

Morgan

Posts: 36,054 Sapphire Posts by user Forum Profile RuneMetrics Profile
Hey Indsy. I'm a bit more rested today, so I've been exploring the concept of callbacks and all that. I'd seen them in the past but read a guide to refresh my mind today and came up with something you might like :) Tell me what you think.

[code]var lovelyPeople = ["Indsy", "Cory"]; /** * My own lil version of the forEach function. It takes an array and a callback as a parameter. * * @param {array} array * @param {function} callback It's called with the index and the array element as parameters. * @returns {undefined} */ function forEachX(array, callback) { if (typeof callback === "function") { for (var i = 0; i < array.length; i++) { callback(i, array[i]); } } } forEachX(lovelyPeople, function (i, element) { console.log(i + ". You're amazing " + element); });[/code]

08-Apr-2017 18:41:56 - Last edited on 08-Apr-2017 19:00:42 by Morgan

Lil Indecent

Lil Indecent

Posts: 447 Silver Posts by user Forum Profile RuneMetrics Profile
Looks really solid, awesome work :)

One thing I like to do is prove it works by calling on a var that's modified inside the callback.

I'm guessing you already know this, but I'm going to show the power of callbacks by looking at a var inside and outside of callback.

This is where execution of code does not fire sequentially, the last line of code fires before the callback. Since your example is perfect we can toss in some vars and play with them without changing your code, just adding to it :)


[code]var lovelyPeople = ["Indsy", "Cory"]; //var to play with var str = "qwerty"; /** * My own lil version of the forEach function. It takes an array and a callback as a parameter. * * @param {array} array * @param {function} callback It's called with the index and the array element as parameters. * @returns {undefined} */ function forEachX(array, callback) { if (typeof callback === "function") { //simulate work that takes three seconds to complete setTimeout(function () { //clear our var str = ''; for (var i = 0; i < array.length; i++) { //assign new value for var inside callback, using your array elements str = str + array[i]; callback(i, array[i]); } }, 3000); } } forEachX(lovelyPeople, function (i, element) { console.log(i + ". You're amazing " + element); //console.log on last iteration if (i === lovelyPeople.length - 1) { //str outputs: array elements console.log(str); } }); //str outputs: qwerty console.log(str); [/code]

Edit: I worry I'm being too simplistic so please don't think I'm insulting your intelligence. Your callback is perfect, that makes it so good to play around with. I just hope I'm not stating the obvious too much :)

08-Apr-2017 23:52:13 - Last edited on 08-Apr-2017 23:59:03 by Lil Indecent

Morgan

Morgan

Posts: 36,054 Sapphire Posts by user Forum Profile RuneMetrics Profile
Hey Indsy,
I don't think you're insulting my intelligence with your example, if anything, it helped me understand a few concepts that were floating about in my head. There are ways to represent a callback sort of thing in Java, but it's a bit "different" here, so it takes some time to understand. But your example makes perfect sense and was really good :)

I'm going to continue practising this because it can be a bit of a mind twister :P
So thank you and I'm so happy that you found my example 'perfect'. Means a lot coming from you ­<3

09-Apr-2017 01:08:23 - Last edited on 09-Apr-2017 01:09:13 by Morgan

Hevilmystic
Feb Member 2022

Hevilmystic

Posts: 60,012 Emerald Posts by user Forum Profile RuneMetrics Profile
Right

Call me crazy, but why is the area inside the little < on posts with custom borders a different colour to the rest of the posts?

HTTP://puu.sh/vkbfS/a8a85a5c21.png

I've noticed the odd one is the same on every post in this thread, so is it something to do with custom post backgrounds in general?
Unslain Bosses - Clan

14-Apr-2017 19:02:13 - Last edited on 14-Apr-2017 19:02:43 by Hevilmystic

Lil Indecent

Lil Indecent

Posts: 447 Silver Posts by user Forum Profile RuneMetrics Profile
Hiya Crazy Rowley :)

That little triangle (pointy thing) by default is a small image. When applying a custom border colour that default image doesn't work, it gets worse when a custom background is thrown into the mix.

When you see a jmod or fmod post different images are used for the pointy thing. But RS Linkify offers an almost unlimited array of colour options, thus I can't use an image for each possible colour. Also since gradients are used I can't ever match the colour of the pointy thing to the background.

The other thing is, drawing a border around non equiangular quadrilaterals is pretty much not a thing in browsers. Fortunately in chrome, RS Linky can ask the GPU to draw an edge around all non transparent pixels in a png image (the pointy thing). This means we break away from the limitation of borders for only squares and rectangles.

But doing so still comes with issues, we don't want all sides coloured, we only want two sides so it gives a speech bubble effect. The browser doesn't allow for this so it's down to some sneaky positioning trying to hide bits we don't want.

The colour difference you are seeing, is just my crude attempt to make a transition from the new pointy thing to any background no matter what colours (if any) are used.

I might need to tweak it up a bit and give it more transparency on the right edge, in the past it has proved difficult getting it to play nicely with some custom background colors but I'll see what I can do :)

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

Since I'm already here, I saw your post on my other thread just a little while ago.

Not sure what I'll do about that page, I'm in the process of culling content related to my hiscores pages. I'm not sure there is even a need for this stuff anymore since runemetrics, and the hiscores are stagnant for all game modes anyway.

I'll either fix it, redo it or get rid of it. Still deciding atm but I won't leave it too long.

15-Apr-2017 02:09:06 - Last edited on 15-Apr-2017 02:10:16 by Lil Indecent

Hevilmystic
Feb Member 2022

Hevilmystic

Posts: 60,012 Emerald Posts by user Forum Profile RuneMetrics Profile
It still surprises me that whatever I ask, I get an indepth and thorough response - at this point, it shouldn't surprise me, but it does!

I'm surprised I noticed the little < to be honest, but it's interesting to know why it is a thing - it's a shame it's not easy adapt it to 'dynamic' backgrounds.

-

I default to your hiscores because Runemetrics requires me to log in, and even then it's sorta heavy, but I understand that it's just me being lazy. Runemetrics does require a lot of work on Jagex's end before it becomes a product worth paying for, though.

Admittedly, I don't care much about hiscores/skilling any more, that ship has sailed, but your website is the one I've liked using in the past so it's pretty natural for me to go there when I do want to look at my stats, etc.

Anyway, this is exactly what I need, so I'll leave it here:

http://i.imgur.com/pR7LtOK.jpg

­<3
Unslain Bosses - Clan

18-Apr-2017 10:19:59

Lil Indecent

Lil Indecent

Posts: 447 Silver Posts by user Forum Profile RuneMetrics Profile
I was thinking when I was typing out my reply "this should be much more simple than it is" :)

But that little pointy thing ate more time than it I expected when trying to it get it to work with both custom borders and backgrounds.

I've come to love that about your questions, they are like tugging on a little thread that's going to unravel so much more.


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


Still thinking about what to do with my hiscores. I want to tidy up (and fix) things and also support all game modes for RS3 and Old School. I always go through this at least once a year, only this time I might have the time to do something.

So much has changed and I haven't kept up. I guess that makes it easy to not do much, but I'm not happy with my hiscores right now, so I guess that's a sure sign I need to do something :)


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


And perfect timing as always...

* Ahhhh..... sips coffee *

19-Apr-2017 00:27:29

Amaethwr
Aug Member 2008

Amaethwr

Posts: 14,634 Opal Posts by user Forum Profile RuneMetrics Profile
http://www.gamesindustry.biz/articles/2017-04-21-the-third-age-of-jagex

"We have had cool features like extensions to our forums that have been added, just because it was a personal idea from someone, and they chipped away at it over a few Thursdays."

Hehe, thanks, Indy :P

Was acting CEO talking about the TAPP idea - was there much added besides imgur images in posts?
Selective Completionist

24-Apr-2017 19:28:24

Lil Indecent

Lil Indecent

Posts: 447 Silver Posts by user Forum Profile RuneMetrics Profile
Hiya Amaethwr :)


Actually the imgur tag came much later.

After the TAPP thing we lost features more so than gained.

Off the top of my head we lost...

• Refresh

• Back/Up one level

• Thread creation date below thread titles

• Back to top (was returned later)

• Links on profile to last post by user were broken and remain that way

• Page navigation to first and last page were removed, brought back later on though.

• A link tag that doesn't work across Jagex's own domain, even in the last couple of weeks I have seen jmods use it to link to Jagex pages and it rejects the url and reloads the current page. And sadly that was the best new feature that was added.

There was other stuff too, that update kept me quite busy for a while. The main thing that update did was the reskin that made everything bigger but gave us less.

Thanks for the link though, enjoying the read :)


Interestingly they never made the website mobile friendly. Why this is interesting is because Android has just overtaken Windows as the internet’s most used operating system. 3 years ago the same happened with Apple, their mobile platform passed their desktops.

Another thing that's interesting is at some stage (I believe relatively recently) Jagex web guys reduced image and script caching to the point where nothing lives for more than 15 minutes (rather than months or years). Any other website would consider that an act of gross negligence or even sabotage. It makes the site even less mobile friendly and increases the bandwidth used for both Jagex servers and its users. For some strange reason, in the last couple of years, they have actually headed in the complete opposite direction that they should.

Image below shows last few weeks of web traffic by OS. We all saw this comming so what's the deal with Jagex's site?

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

The TAPP thing was great, I'm not bashing it because the forums got much needed attention. Just I'd focus things differently is all.

24-Apr-2017 22:42:14 - Last edited on 24-Apr-2017 22:43:47 by Lil Indecent

Amaethwr
Aug Member 2008

Amaethwr

Posts: 14,634 Opal Posts by user Forum Profile RuneMetrics Profile
Lil Indecent said :
Actually the imgur tag came much later.
Ah, fair enough, my bad :P Had forgotten about the update before

15 minute caching.. Any ideas as to why? Lol

And didn't know that about android overtaking windows bit, but I suppose it makes sense when there's so many phones/tablets, TVs?, probably some cars' features, and other devices using android
Selective Completionist

24-Apr-2017 23:15:51

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