Forums

RS-Linkify Thread is sticky

Quick find code: 261-262-33-65181208

AoDude

AoDude

Posts: 1,694 Mithril Posts by user Forum Profile RuneMetrics Profile
Tbh, your explanation brings up more questions to me:

Why are you using an array there? Why not an object? Why not an object of arrays?

[code] creditList = { 'indecent act' : ['Caffeine Powered!', 'I'], 'lil indecent' : ['Caffeine Powered!', 'I'], 'keighlea' : ['Zaros Powered!', ''], 'rowley' : ['Over Powered!', 'R'], 'morgan' : ['Warm Javascripts', 'M'], 'blasty' : ['Blue Powered!', 'B'], 'ryan m' : ['Binary Powered!', ''], 'lust' : ['Potato Powered!', ''], 'baraxil' : ['Purple Powered!', ''], 'lifer' : ['Never Underpowered!', ''], 'vigilant foe' : ['script powered!', ''], 'michaeisword' : ['2H Sword Powered!', ''], 'charles' : ['Hugely Empowered!', ''], 'amaethwr' : ['Flower Powered!', 'A'], 'maxq' : ['PhotoShop Powered!', ''], 'bodyy' : ['Body Powered!', ''], 'aodude' : ['Dorito Powered!', 'D'] } --- var element = null; if (!creditList.hasOwnProperty(aName)) { return; } --- element.addClass('rsLinkify-side2').attr('title', creditList[aName][0]).attr('title', creditList[aName][0]]).before('<img class="rsLinkify-side1 rsLinkify-badgeGlowOff linkyfybadge' + creditList[aName][1] + '" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />'); ele.next('div').find('img').wrapAll('<div class="rsLinkify-flip" title="' + creditList[aName][0] + '"><div class="rsLinkify-rotate"></div><img class="rsLinkify-star" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"></div>'); [/code]
AO
Deputy-Owner :
The Nexus CC

14-Aug-2016 00:01:56 - Last edited on 14-Aug-2016 00:11:50 by AoDude

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Hiya AoDude :)

You can probably tell or may have guessed that this has changed over time. It was originally an object however I was pulling my hair out regarding an issue with names.

Names in my objects sometimes wouldn't match names on the page. I was having so much difficulty, as a part of my trouble shooting I dismantled the object and built an array (did this to a few things not just this object). I wanted the use of indexOf for troubleshooting.

I went on a convoluted journey trying solve the problem and in the end it wasn't the objects at all. However I never changed it back, tbh I didn't want to look at it again after what I went through.


See white space issue here, they still exist.

My Noob...
http://i.imgur.com/y7Zu3MY.png

and this account...
http://i.imgur.com/uV0wVnR.png

Four different kinds of white space, and some used rather badly. &nbsp does not belong in URLs and URL encoding does not belong in plain text. And the plus sign....that takes me back.

All that time I was unaware of 4 white space issue. Thinking my objects were wrong, and then arrays. Basically using the process of elimination until I noticed something odd (see pics).

Since then I just have never put it back to how it was. Didn't have the energy and even though not as elegant, the array worked and I'd already refactored code around it. It was one of those things where I finally got it working and just wanted to publish it before anyone else noticed (happens more than I care to admit).

The === operator is really mean on these pages. But I'm not sure == would have flagged a match and it may cause bigger issues.

I will go back to objects again for the badges, and there a few other places where I'll do something similar. Nice that these things come up because in this case objects are the right thing for the job, more so than a single array.

Really like it that people read those posts and that people don't miss a thing. Keeps me on my toes :)

14-Aug-2016 04:07:31 - Last edited on 14-Aug-2016 04:14:01 by Indecent Act

AoDude

AoDude

Posts: 1,694 Mithril Posts by user Forum Profile RuneMetrics Profile
Indecent Act said :
In the end it wasn't the object at all. I just have never put it back to how it was. Didn't have the energy at the time and even though not as elegant, the array worked and I'd had enough lol. It was one of those things where I finally got it working and just wanted to publish it before anyone else noticed (that happens more than I care to admit).

I will go back to objects again for the badges, and there a few other places where I'll do something similar. Nice that these things come up because in this case objects are the right thing for the job, more so than a single array.


I probably have more quick-hacked solutions in my stuff than I care to admit too! :) But I get why you did it now. Believe me I have done some weird/convoluted stuff to try and figure out strange bugs. And to be honest, so long as it doesn't cause a problem, and you have a good reason to do it a certain way, there is no wrong way to do something. Which is why I started out asking why you did it your certain way, because as I had anticipated, you had a good reason for doing it that way at the time you wrote it.

I probably wouldn't have anticipated the 4 space issue. So I can't say that the solution I provided above will even work! Admittedly I prefer thinking about how the world works in a vacuum, and often forget that the world is a messy unorganized place.

---

I saw a reddit thread earlier this week that reminded me of you: https://www.reddit.com/r/ProgrammerHumor/comments/4x7uc8/remove_html_tags_with_regex/ Knowing it was posted in ProgramerHumor, and how everyone was trying, and quickly being proven incorrect with atrocious html. It looked like a fun puzzle to me, so I came up with a solution for fun. But it was the regex battling the inconsistency of html that reminded me of your battle against the inconsistency here on the forums. :)

https://media.giphy.com/media/FVRmYYRaIlYgo/giphy.gif
AO
Deputy-Owner :
The Nexus CC

14-Aug-2016 04:58:33

AoDude

AoDude

Posts: 1,694 Mithril Posts by user Forum Profile RuneMetrics Profile
Morgan said :
Warm Javascripts now support the "**" operator that I (think) replaces Math.pow

Looks good!


Neat! I don't even see that up on W3 Schools yet, but it seems to work in the version of chrome I am currently using:

http://puu.sh/qAC1e/854f43e8dd.png

Thanks for the info!
AO
Deputy-Owner :
The Nexus CC

14-Aug-2016 05:05:42

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Morgan said :
Warm Javascripts now support the "**" operator that I (think) replaces Math.pow

Looks good!

Aren't you the up to date lil warm javascripter!

I didn't know about the double asterisk operator for power of. But I believe it's in this years spec or maybe next years. Not sure tbh as its new to me :)


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

Hiya AoDude,

I really appreciate the questions. It either reminds me to finish stuff, or gives me new tools/methods to improve my code. My reply was almost as convoluted as the issue I was tracking, but giving the big picture and seemly crazy last resort approaches is something most of can appreciate.

As for regex and HTML tags, oh that's a huge can of worms. If you know the structure of pages and the structure is consistent across those pages, then its not so bad. But a generic approach for any page not much fun. A regex guru once posted a detailed method on SO. I mean this guy was insanely hard core. His code worked (it seemed) but his closing comments were don't do it. If you do use my code, then don't credit me.

He didn't even endorse his own code, and tbh this guy talks regex in his sleep.

Ripping out what's between tags isn't too bad, or the opposite. But what about attributes?

When I see that post, I have to ask why? I mean what do they want? If they just want plain text from within the HTML tags, then let the DOM do it for you.

[code]<p id="id">foo</p>

var theText = $('#id').text();
/* or */
var theText = document.getElementById('id').innerText;

[/code]

Without understanding what they want I don't see the need for regex at all. I get that its humour, but tbh I'm not sure what's humour and what's not. I feel I'm taking the question too seriously and missing the point.

Recursively traversing through nested tags gets tricky, no one attempted that for some reason, I guess they don't like fun!

14-Aug-2016 06:17:40 - Last edited on 14-Aug-2016 07:53:13 by Indecent Act

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Indecent Act said :
Recursively traversing through nested tags gets tricky, no one attempted that for some reason, I guess they don't like fun!

A lil something I was working on ages ago, just to show what I mean :)

Figure I should put my money where my mouth is in regard to recursion in nested structures.

Try using correctly and incorrectly nested tags to see the result. I was hoping to provide error correction for badly/broken nested posts. Keep in mind this was never finished but the logic seems pretty sound (for the most part).

http://www.indecentcode.com/parser/parser.html

Edit: Must be BB tags, but the same code could be modified for html tags.

This is the first thing that's needed when stripping out HTML tags, handle nesting!

That is after all what the box model is all about. Even though this doesn't strip tags, it does more in some ways, by identifying and understanding nest structures and then provides solutions for errors.

I keep reminding myself that reddit post is humour. But I can't help myself. Also I don't see a clever punchline anywhere and that makes me take it more seriously than perhaps I should.

14-Aug-2016 08:08:14 - Last edited on 14-Aug-2016 08:42:46 by Indecent Act

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