MediaWiki:Gadget-find-archived-section.js: Difference between revisions
Content deleted Content added
unbreak for AN/ANI |
proper fix for section headers with double quotes in title, without breaking other stuff |
||
Line 39:
+ '?title=Special:Search'
+ '&search=' + encodeURIComponent(searchString)
+ '&prefix=' + encodeURIComponent(prefix)
+ '&sort=create_timestamp_desc';
// Fetch and parse search results page
$.ajax(searchLink).then(function(html) {
var divHtml;
if ($(html).find('.mw-search-nonefound').length) {
} else {
var discussionLink = $(html).find('ul.mw-search-results .searchalttitle a').attr('href');
if (discussionLink) {
divHtml += '<b><a href="' + discussionLink + '">Click to see archived discussion</a></b> ';▼
// escape double quotes in link, so that they aren't treated as end of href
// encodeURI() doesn't work here as it tends to escape characters such as the single quote which
// have already been escaped by mediawiki, resulting in a doubly-escaped malformed url
▲ divHtml += '<b><a href="' + discussionLink.replace(/"/g, '%22') + '">Click to see archived discussion</a></b> ';
divHtml += '<small><a href="' + searchLink + '">(or search in archives)</a></small>. ';
} else {
divHtml += '<a href="' + searchLink + '">Click to search in archives</a>. ';
|