FlightGear wiki:Instant-Refs: Difference between revisions

Jump to navigation Jump to search
new vid2wiki function
([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))
(new vid2wiki function)
Line 57: Line 57:


== 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 74:
// @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.16
// @version    0.17
// @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 87: Line 86:
// ==/UserScript==
// ==/UserScript==


var jqUI_CssSrc = GM_getResourceText ("jqUI_CSS");
var jqUI_CssSrc = GM_getResourceText("jqUI_CSS");
GM_addStyle (jqUI_CssSrc);
GM_addStyle(jqUI_CssSrc);


var debug = 0;  
var debug = 0;  
Line 132: Line 131:
                         phpBB_code2syntaxhighlight(), // FIXME: could be much better, see below
                         phpBB_code2syntaxhighlight(), // FIXME: could be much better, see below
                         phpBB_quote2cquote(),
                         phpBB_quote2cquote(),
vid2wiki(),
                         escapeEquals(),
                         escapeEquals(),
                         addNewlines()]
                         addNewlines()]
Line 191: Line 191:
function prepend(prefix) {
function prepend(prefix) {
     return function(text) {
     return function(text) {
         return prefix+text;
         return prefix + text;
     };
     };
}
}
Line 218: Line 218:
// Converts HTML <a href="...">...</a> tags to wiki links, internal if possible.
// Converts HTML <a href="...">...</a> tags to wiki links, internal if possible.
function a2wikilink(){
function a2wikilink(){
return function(html)  
return function(html){
// Links to wiki images, because
// Links to wiki images, because
// they need special treatment, or else they get displayed.
// they need special treatment, or else they get displayed.
html = html.replace(/<a.*?href="http:\/\/wiki\.flightgear\.org\/(File:.*?)".*?>(.*?)<\/a>/g, "[[Media:$1|$2]]");
html = html.replace(/<a.*?href="http:\/\/wiki\.flightgear\.org\/File:(.*?)".*?>(.*?)<\/a>/g, "[[Media:$1|$2]]");


// Wiki links without custom text.
// Wiki links without custom text.
Line 251: Line 251:
return html;
return html;
};
};
}
function vid2wiki(){
return function(html){
// YouTube
html = html.replace(/<div.*?><iframe width="(.*?)" height="(.*?)" src="http:\/\/www\.youtube\.com\/embed\/(.*?)".*?><\/iframe><\/div>/g, "{{#ev:youtube|$3|$1x$2}}");
html = html.replace(/\[.*? Watch on Youtube\]/g, "");
// Vimeo: Doesn't currently work (cannot select video viewer on post)
// html = html.replace(/<iframe src="http:\/\/player\.vimeo\.com\/video\/(.*?)\?.*?" width="(.*?)" height="(.*?)".*?>.*?<\/iframe>/g, "{{#ev:vimeo|$3|$1x$2}}");
// html = html.replace(/\[.*? Watch on Vimeo\]/g, "");
return html;
}
}
}
   
   
Line 265: Line 278:
function addNewlines() {
function addNewlines() {
     return function(html) {
     return function(html) {
         html = html.replace(/<br\/?>/g,"<br/>\n");
         html = html.replace(/<br\/?>/g, "<br/>\n");
         html = html.replace(/(<\/?[uo]l>)/g,"$1\n");
         html = html.replace(/(<\/?[uo]l>)/g, "$1\n");
         return html.replace(/<\/li>/g,"</li>\n");
         return html.replace(/<\/li>/g, "</li>\n");
     }
     }
}
}
Line 303: Line 316:
function phpBB_smilies2text() {
function phpBB_smilies2text() {
     return function(bbhtml) {
     return function(bbhtml) {
         return bbhtml.replace(/<img.*?src="\.\/images\/smilies\/icon_.*?\.gif".*?alt="(.*?)".*?>/g,"$1");
         return bbhtml.replace(/<img src="\.\/images\/smilies\/icon_.*?\.gif" alt="(.*?)".*?>/g, "$1");
     }
     }
}
}

Navigation menu