Lankide:WOSlinker/common.js

Wikipedia, Entziklopedia askea

Oharra: Gorde ondoren zure nabigatzailearen katxea ekidin beharko duzu aldaketak ikusteko. Mozilla / Firefox / Safari: Shift tekla sakatu birkargatzeko momentuan, edo Ctrl-Shift-R sakatu (Cmd-Shift-R Apple Mac baten); IE: Ctrl tekla sakatu birkargatzeko momentuan, edo Ctrl-F5 sakatu; Konqueror:: Birkargatzeko klik egin, edo F5 sakatu, besterik ez; Opera erabiltzaileek Tresnak-Hobespenak atalera jo eta katxea garbitzeko aukera hautatu.

function font_queryString(p) {
    var re = RegExp('[&?]' + p + '=([^&]*)');
    var matches;
    if (matches = re.exec(document.location)) {
        try { 
            return decodeURI(matches[1]);
        } catch (e) { }
    }
    return null;
}

//Add a 'font edit' tab
if(mw.config.get('wgArticleId') != 0 ) { 
    $( function fontEditButton() {
        mw.util.addPortletLink('p-cactions', 
                       mw.util.getUrl(null,{action:'edit',font:true}),
                       'font',
                       'p-font',
                       'font edit');
    }
)}

if(mw.config.get('wgAction') == 'edit' && font_queryString('font') == 'true') {
    $(function font() {
        var myContent = document.getElementById('wpTextbox1').value;

        myContent = myContent.replace(/\<font color\=(\w*)\>\[\[(.*?)\|(.*?)\]\]\<\/font\>/g,'[[$2|<font color=$1>$3</font>]]');
        myContent = myContent.replace(/\<font color\=(\w*)\>\[\[(.*?)\]\]\<\/font\>/g,'[[$2|<font color=$1>$2</font>]]');

        myContent = myContent.replace(/\<FONT COLOR\=\"\#([\d\w]*)\"\>\[\[(.*?)\|(.*?)\]\]\<\/FONT\>/g,'[[$2|<FONT COLOR="#$1">$3</FONT>]]');
        myContent = myContent.replace(/\<FONT COLOR\=\"\#([\d\w]*)\"\>\[\[(.*?)\]\]\<\/FONT\>/g,'[[$2|<FONT COLOR="#$1">$2</FONT>]]');

        myContent = myContent.replace(/\<font size\=2 color\=\"(\w*)\"\>\<noinclude\>\[\[(.*?)\|(.*?)\]\]\<\/noinclude\>\<\/font\>/g,'<noinclude>[[$2|<font size=2 color="$1">$3</font>]]</noinclude>');
        myContent = myContent.replace(/\<font size\=2 color\=\"(\w*)\"\>\<noinclude\>\{\{(.*?)\|(.*?)\}\}\<\/noinclude\>\<\/font\>/g,'<noinclude><font size=2 color="$1">{{$2|$3}}</font></noinclude>');

        if(document.getElementById('wpTextbox1').value != myContent) {
           document.getElementById('wpTextbox1').value=myContent;
           document.getElementById('wpSummary').value='fix [[Berezi:LintErrors/tidy-font-bug|lint]]';
           document.getElementById('wpMinoredit').checked = true;
        }



    }
)}