User talk:Dschwen/highlightredirects.js
From Wikipedia, the free encyclopedia
- You might look at querying api.php instead of loading the whole page with action=raw.
- #REDIRECT is not enough. there can be whitespace between # and REDIRECT which does not have to be uppercase.
Nifty though! — Hippietrail 01:26, 23 January 2007 (UTC)
- api.php is a great suggestion, I just implemented it. Drastically reduces the request volume, and creates a appealingly absurd third layer of JavaScript interpretation (to eval the returned JSON string) :-). --Dschwen(A) 23:36, 14 February 2007 (UTC)
[edit] Suggested changes
G'day, very impressive! I respectfully suggest a couple of changes, though:
- it currently doesn't go past any anchors that are targets (i.e. have a name but no href). Fixed by testing
links[key].href
when you testlinks[key].pathname
:
if( links[key].href && links[key].pathname && links[key].pathname.substr(0,6) == '/wiki/' && !( links[key].href.substr(0,local.length) == local ) )
- it currently only picks up the uppercase form of redirect, and as stated above, ignores the permissible form with a space between the # and the redirect. Fixed by changing the test to a regex:
'if(/\#.?redirect/i.test(me.xhr.responseText)) {' +
cheers, Webaware talk 14:08, 14 February 2007 (UTC)
- Thanks a lot for your suggestions, and especially for providing the code snippets along with them! The whole thing was created as a proof of concept. If you have further ideas or suggestions please don't hold back. I appreciate any kind of input. --Dschwen(A) 22:44, 14 February 2007 (UTC)
-
- Thanks a lot for coming up with this. Not only is it very useful, it's also quite instructive - I must get my head around AJAX sometime, and now I have somewhere I can play with it without it being too boring!
- I've just noticed a couple of other instances where it stops short of getting all links, so I'll investigate and post back the fix(es). cheers, Webaware talk 23:18, 14 February 2007 (UTC)
- Ok, I've noticed failing XHRs too, but I just cannot get my finger on them. And I just switched to requesting api.php (see above). --Dschwen(A) 23:36, 14 February 2007 (UTC)
- This looks interesting, and the script now picks up all links on the pages where I found it wasn't getting them before. However, you currently have it hard-coded for en.wikipedia.org pages; it would be handy if you truncate that to just
/w/api.php?...
, so that the script can still be used from other Wiki projects (like Wikibooks, *.wikipedia.org, etc.) Webaware talk 02:19, 15 February 2007 (UTC)
- This looks interesting, and the script now picks up all links on the pages where I found it wasn't getting them before. However, you currently have it hard-coded for en.wikipedia.org pages; it would be handy if you truncate that to just
- Ok, I've noticed failing XHRs too, but I just cannot get my finger on them. And I just switched to requesting api.php (see above). --Dschwen(A) 23:36, 14 February 2007 (UTC)