Something went wrong. Try again later

billyboy

This user has not updated recently.

7 0 8 0
Forum Posts Wiki Points Following Followers

billyboy's forum posts

Avatar image for billyboy
billyboy

7

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@billyboy: I'm not too sure what exactly it is you're trying to accomplish with your code. Do you have a link to the jsfiddle?

First off, doing something like this is unnecessary:

("[data-ref-id|='3010']").attr('href', function (idx, href) { return href; });

You're just setting the href attribute equal to its current value. Second, I'm a bit curious where this comes from:

var giant = "http://giantbomb.com";

I'm assuming that's just a test value for your code here, but where do you actually intend to pull that value from? Isn't that just going to be pulled from the href attribute itself? In which case, why not just do this:

$("[data-ref-id|='3045']").not("[href*='giantbomb.com']").attr('href', function (idx, href) {

return 'http://giantbomb.com' + href;

});

That should only select elements with that particular data-ref-id attribute which do not contain 'giantbomb.com' in their href attribute.

your awesome thanks ,this is what i wanted. im not a professional and javascript is not my strong side :D

Avatar image for billyboy
billyboy

7

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#2  Edited By billyboy

@chaser324: my bad, even with out typos i cant get it to work. i must have spent a few hours trying various ways with String.prototype.indexOf on my page and with jsfiddle

so for the time being until someone can answer this or post a legit way of working with this i just did a str.replace to remove the url and then added it back in with javascript...

Avatar image for billyboy
billyboy

7

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#3  Edited By billyboy

I cant for the life of me get it to work with

String.prototype.indexOf

been trying something like this

var giant = "http://giantbomb.com";

if (giant.indexOf("http://giantbomb.com") !=-1)

("[data-ref-id|='3010']").attr('href', function (idx, href) {

return href;

});

else

("[data-ref-id|='3010']").attr('href', function (idx, href) {

return 'http://giantbomb.com' + href;

});

if (giant.indexOf("http://giantbomb.com") !=-1)

("[data-ref-id|='3045']").attr('href', function (idx, href) {

return href;

});

else

("[data-ref-id|='3045']").attr('href', function (idx, href) {

return 'http://giantbomb.com' + href;

});

but is a no go

Avatar image for billyboy
billyboy

7

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@laika: most overviews of games either have it, dont or are a mix.

doesn't have it - http://www.giantbomb.com/api/game/3030-44217/?api_key=xxxxx&filter=name:minecraft&format=json

doesn'thave it - http://www.giantbomb.com/api/game/3030-30475/?api_key=xxxxx&filter=name:minecraft&format=json

is a mix - http://www.giantbomb.com/api/game/3030-31709/?api_key=xxxxx&filter=name:minecraft&format=json

is a mix - http://www.giantbomb.com/api/game/3030-41484/?api_key=xxxxx&filter=name:minecraft&format=json

is a mix - http://www.giantbomb.com/api/game/3030-41518/?api_key=xxxxx&filter=name:minecraft&format=json

like this for a lot of games, haven't yet looked over any of the others but it appears to only be in the descriptions.

at first i thought the urls were partial so the links could go to your own site but then i noticed a mix and thought something must be wrong.

Avatar image for billyboy
billyboy

7

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#5  Edited By billyboy

So looking at the description in games there is a problem. In some the entire url to giant bomb is supplied

ie: http://www.giantbomb.com/third-person-perspective/3015-464/

in others only partial

ie: /third-person-perspective/3015-464/

and in some a mix of both. I write some jquery to fill the void of the partial but for those that supply the giantbomb.com url I end up having

ie: http://giantbomb.com//www.giantbomb.com/assassins-creed-iii/3030-37494/

So what is the way around this, does anyone have a code snippet to work around this?

Currently I have this

[code]

$("[data-ref-id|='3030']").attr('href', function (idx, href) {

return 'http://giantbomb.com' + href;

});

[/code]

Where I just supply the first 4 numbers of the ref id to the url.