2,733
edits
Red Leader (talk | contribs) (→Issues/limitations: Update + stumbled on a new problem) |
Red Leader (talk | contribs) ([Long edit summary] 1) Fix bug in date formatting 2) Remove underscores from just wiki text 3) If label contains dots, replace with URL (e.g., http://example.com/path ... file.html → http://example.com/path/to/file.html)) |
||
Line 54: | Line 54: | ||
== Issues/limitations == | == Issues/limitations == | ||
* Taking quotes from the forum '''will not work when the user is logged in'''. | * Taking quotes from the forum '''will not work when the user is logged in'''. | ||
* The JavaScript <code>alert();</code> boxes used are typically restricted to a max size of about 10 KB; other options should be looked at. {{Not done}} | * The JavaScript <code>alert();</code> boxes used are typically restricted to a max size of about 10 KB; other options should be looked at. {{Not done}} | ||
== Feature requests & ideas == | == Feature requests & ideas == | ||
* Convert videos to wiki markup. | |||
* Internet Explorer stuff can be removed. It seems that Internet Explorer plugins are implemented completely differently. {{Not done}} | * Internet Explorer stuff can be removed. It seems that Internet Explorer plugins are implemented completely differently. {{Not done}} | ||
* GET-encoded SID arguments should be stripped from forum URLs. {{Not done}} | * GET-encoded SID arguments should be stripped from forum URLs. {{Not done}} | ||
Line 75: | Line 75: | ||
// @description Automatically converts mailing list and forum quotes into Mediawiki markup. | // @description Automatically converts mailing list and forum quotes into Mediawiki markup. | ||
// @namespace http://wiki.flightgear.org/ | // @namespace http://wiki.flightgear.org/ | ||
// @version 0. | // @version 0.16 | ||
// @icon http://wiki.flightgear.org/images/6/62/FlightGear_logo.png | // @icon http://wiki.flightgear.org/images/6/62/FlightGear_logo.png | ||
// @require http://code.jquery.com/jquery-1.11.1.min.js | // @require http://code.jquery.com/jquery-1.11.1.min.js | ||
Line 216: | Line 216: | ||
} | } | ||
// | // Converts HTML <a href="...">...</a> tags to wiki links, internal if possible. | ||
function a2wikilink() { | function a2wikilink(){ | ||
return function(html) | |||
// Links to wiki images, because | |||
// they need special treatment, or else they get displayed. | |||
html = html.replace(/<a.*?href="http:\/\/wiki\.flightgear\.org\/(File:.*?)".*?>(.*?)<\/a>/g, "[[Media:$1|$2]]"); | |||
// Wiki links without custom text. | |||
html = html.replace(/<a.*?href="http:\/\/wiki\.flightgear\.org\/(.*?)".*?>http:\/\/wiki\.flightgear\.org\/.*?<\/a>/g, "[[$1]]"); | |||
// Links to the wiki with custom text | |||
html = html.replace(/<a.*?href="http:\/\/wiki\.flightgear\.org\/(.*?)".*?>(.*?)<\/a>/g, "[[$1|$2]]"); | |||
// Remove underscores from all wiki links | |||
var list = html.match(/\[\[.*?\]\]/g); | |||
if(list !== null){ | |||
for(var i = 0; i < list.length; i++){ | |||
html = html.replace(list[i], underscore2Space(list[i])); | |||
} | |||
} | |||
// Convert non-wiki links | |||
html = html.replace(/<a.*?href="(.*?)".*?>(.*?)<\/a>/g, "[$1 $2]"); | |||
// Remove triple dots from external links. | |||
// Replace with raw URL (MediaWiki converts it to a link). | |||
list = html.match(/\[.*?(\.\.\.).*?\]/g); | |||
if(list !== null){ | |||
for(var i = 0; i < list.length; i++){ | |||
html = html.replace(list[i], list[i].match(/\[(.*?) .*?\]/)[1]); | |||
} | |||
} | |||
return html; | |||
}; | |||
} | } | ||
Line 395: | Line 415: | ||
//TODO: add template string to profile | //TODO: add template string to profile | ||
var template = "{{FGCquote" + "\n" + | var template = "{{FGCquote" + "\n" + | ||
" | "|" + info.content + "\n" + | ||
" | "|{{cite web" + "\n" + | ||
" | " |url = " + info.url + "\n" + | ||
" | " |title = " + nowiki(info.title) + "\n" + | ||
" | " |author = " + nowiki(info.author) + "\n" + | ||
" | " |date = " + datef(info.date) + "\n" + | ||
" }}" + "\n" + | |||
"}}"; | "}}"; | ||
return template; | return template; | ||
Line 427: | Line 448: | ||
if(date == "11" || date == "12" || date == "13"){ | if(date == "11" || date == "12" || date == "13"){ | ||
return "th"; | return "th"; | ||
}else if(date.substr(1) == "1"){ | }else if(date.substr(1) == "1" || date == "1"){ | ||
return "st"; | return "st"; | ||
}else if(date.substr(1) == "2"){ | }else if(date.substr(1) == "2" || date == "2"){ | ||
return "nd"; | return "nd"; | ||
}else if(date.substr(1) == "3"){ | }else if(date.substr(1) == "3" || date == "3"){ | ||
return "rd"; | return "rd"; | ||
}else{ | }else{ | ||
Line 444: | Line 465: | ||
} | } | ||
function | function underscore2Space(str){ | ||
return str.replace(/_/g, " "); | return str.replace(/_/g, " "); | ||
} | } |