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
Yep I do something similar but the parent is a class [msgcontents] and I can't determine the index from that.

What I'll likely end up doing is parsing the button index into the function and then use that to determine the msgcontents index.

It's no trouble finding parent classname or parent id. But I don't know of any native function that returns the index from a class. I notice you use bubblefooter, that's still the same issue because I need the index. There is 10 elements that share that name, I need to know what one it is.

04-Sep-2013 04:07:21 - Last edited on 04-Sep-2013 04:08:51 by Indecent Act

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Not exactly, as I said I'd use the button to submit an index, The index would come from the number of iterations from a loop that I use to grab all the posts.

Edit: Blasty here's my solution, I assigned numeric ID's to the message and quote elements, now I just match numeric values of the ID's. This is much simpler, tbh I thought I was overcomplicating things and when I took a break it came to me.

­
//e = element parsed from quote button
//sel = selected text


//function to determine parent no matter how deeply nested.
function isDescendant(parent, child) {
var node = child.parentNode;
while (node != null) {
if (node.className == parent) {
return node.id;
}
node = node.parentNode;
}
return false;
}
//determine if text comes from msgcontents and if so get ID.
var parentEl = null;
if (window.getSelection) {
if (sel.rangeCount) {
parentEl = sel.getRangeAt(0).commonAncestorContainer;
if (parentEl.nodeType != 1) {
parentEl = parentEl.parentNode;
}
}
} else if ( (sel = document.selection) && sel.type != "Control&quot ;) {
parentEl = sel.createRange().parentElement();
}
//This bit verifies the match from ID's (ID's represent the class index)
if (sel != '' && sel != 'undefined') {
var mDec = isDescendant('msgcontents', parentEl);
if(mDec){
if(mDec.slice(-1) == e.id.slice(-1)){
message = sel;
}
}
}

04-Sep-2013 04:20:53 - Last edited on 05-Sep-2013 20:39:10 by Indecent Act

Oldduffer
Apr Member 2006

Oldduffer

Posts: 94 Iron Posts by user Forum Profile RuneMetrics Profile
Original message details are unavailable.
@Huge Charlie, wow very nice editing skills. Thanks for that, I don't think I'd have even attempted it tbh.

Oldduffer: [qfc id=259-260-166-64977831 page=10180][/qfc]
http://www.indecentcode.com/rslinkify_images/10180.png


Thanks again for the awesome work!

04-Sep-2013 05:41:36

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Original message details are unavailable.
I think in the Miscellanous Rs Linkify Settings it should be 'Format date to DD/MM/YYYY'?

Actually I need to change the wording to 'toggle date format', because it's seems to vary from user to user depending on local settings.

04-Sep-2013 12:14:02

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