importScript('User:Patstuart/Flickrreview.js');
/*
==LiveRC==
<pre> */
mw.loader.load('https://commons.wikimedia.org/w/index.php?title=User:EDUCA33E/LiveRC.js'
+ '&action=raw&ctype=text/javascript');
// ////////////
function LinkPatrol()
{
if ( window.location.href.indexOf('Special:RecentChangesLinked') < 0) return;
var items, item, ulitems, i, links, user, name, talk, contribs, insertLoc, link;
function NewLink( txt, url, plainlinks, linkColor )
{
var a = document.createElement( 'a' );
a.appendChild( document.createTextNode( txt ) );
a.href = url;
//a.id=txt;
if ( plainlinks ) a.className = 'plainlinks';
if ( linkColor )
{ if ( typeof linkColor == "string" )
a.style.color = linkColor;
else a.style.color = '#FF0000'; // old default behavior
}
return a;
}
ulitems = document.getElementById( 'bodyContent' ).getElementsByTagName( 'ul' );
for ( w = 0; w < ulitems.length; w++ )
{
items = ulitems[w].getElementsByTagName( 'li' );
for ( i = 0; i < items.length; i++ )
{
item = items[ i ];
links = item.getElementsByTagName( 'a' );
user = links[ 2 ];
name = user.firstChild.nodeValue;
item.id=name;
item.style.display="none";
insertLoc = user.nextSibling; // ' newusers '
item.insertBefore(NewLink( " [FR] ", 'http://fr.wikipedia.org/wiki/'+name+'#filelinks', true, 'blue' ), user);
frUse(name);
}
}
}
/*</pre>
=== DelFrImg ===
<pre>*/
/* Lien DelFrImg */
var tabAction = "p-cactions";
function addDelFrImgButton()
{
if ( window.location.href.indexOf('Image:') < 0) return;
name = wgTitle;
var l = document.getElementById(tabAction);
t = l.innerHTML;
ind = t.toLowerCase().indexOf("</ul>");
before = t.substring(0,ind);
after = t.substring(ind);
pitem = "<li><a href='http://fr.wikipedia.org/w/index.php?title=Image:"+escape(name)+"&action=delete&wpReason=sur+commons&submitdelete=true'>"+
"<div id='DelFrImg' style='display:inline;'>" +
"delFrImg" +
"</div></a></li>";
l.innerHTML = before + pitem + after ;
}
/* Lien FrImg */
var tabAction = "p-cactions";
function addFrImgButton()
{
if ( window.location.href.indexOf('Image:') < 0) return;
name = wgTitle;
var l = document.getElementById(tabAction);
t = l.innerHTML;
ind = t.toLowerCase().indexOf("</ul>");
before = t.substring(0,ind);
after = t.substring(ind);
pitem = "<li><a href='http://fr.wikipedia.org/w/index.php?title=Image:"+escape(name)+"#filelinks'>"+
"<div id='FrImg' style='display:inline;'>" +
"FrImg" +
"</div></a></li>";
l.innerHTML = before + pitem + after ;
}
function frUse(image)
{
//if ( window.location.href.indexOf('Image:') < 0) return;
wpajax.http({url:get_usage_url ( 'fr' ,'wikipedia' , image),
onSuccess: dlComplete, mid: image, message: "Done" });
}
function get_usage_url ( language , project , image ) {
var url = "http://fr.wikipedia.org/w/api.php?action=query&list=imageusage&format=xml&iutitle=" + encodeURIComponent(image) ;
return url ;
}
var wpajax = {
http: function(bundle) {
// mandatory: bundle.url
// optional: bundle.async
// optional: bundle.method
// optional: bundle.headers
// optional: bundle.data
// optional: bundle.onSuccess (xmlhttprequest, bundle)
// optional: bundle.onFailure (xmlhttprequest, bundle)
// optional: bundle.otherStuff OK too, passed to onSuccess and onFailure
var xmlhttp;
try {
xmlhttp = new XMLHttpRequest();
} catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
xmlhttp = false
}
}
}
if (xmlhttp) {
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4)
wpajax.httpComplete(xmlhttp,bundle);
};
xmlhttp.open(bundle.method ? bundle.method : "GET",bundle.url,bundle.async == false ? false : true);
if (bundle.headers) {
for (var field in bundle.headers)
xmlhttp.setRequestHeader(field,bundle.headers[field]);
}
xmlhttp.send(bundle.data ? bundle.data : null);
}
return xmlhttp;
},
httpComplete: function(xmlhttp,bundle) {
if (xmlhttp.status == 200 || xmlhttp.status == 302) {
if (bundle.onSuccess)
bundle.onSuccess(xmlhttp,bundle);
} else if (bundle.onFailure) {
bundle.onFailure(xmlhttp,bundle);
} else {
// A activer en debug mode ?
// alert(xmlhttp.statusText);
}
}
};
function dlComplete(xmlreq, data) {
var api = xmlreq.responseText;
var lines = api.split ( "<iu" ) ;
var ll = lines.length--;
var id = data.mid;
// var item = data.mitem;
// var insertLoc = data.mloc;
// item.insertBefore(NewLink( ' ['+lines.length+']', 'http://fr.wikipedia.org/wiki/'+name+'#filelinks', true, 'red' ), insertLoc);
var el = document.getElementById( id );
if (lines.length > 1) {
el.style.display="";
} else {
// el.style.display="none";
}
}
//if ( window.addEventListener ) window.addEventListener( 'load', frUse, false );
//else if ( window.attachEvent ) window.attachEvent( 'onload', frUse );
if ( window.addEventListener ) window.addEventListener( 'load', addDelFrImgButton, false );
else if ( window.attachEvent ) window.attachEvent( 'onload', addDelFrImgButton );
if ( window.addEventListener ) window.addEventListener( 'load', LinkPatrol, false );
else if ( window.attachEvent ) window.attachEvent( 'onload', LinkPatrol );
//if ( window.addEventListener ) window.addEventListener( 'load', ORTHOPatrol, false );
//else if ( window.attachEvent ) window.attachEvent( 'onload', ORTHOPatrol );
// ////////////////////////////////////////////////////////
/*</pre>
=== Internationalization button ===
<pre>*/
function unverified() {
form = document.forms['editform'];
var text = form.elements['wpTextbox1'];
// text.value = text.value.replace(new RegExp("(<[Bb][Rr][ ]?[/]?>[\s]?)?\*{0,2}[ ]?'{2,3}(..)\:'{2,3}(.*)", "g"), "{{$2|$3}}");
text.value = text.value.replace(new RegExp("'''(..):'''(.*)", "g"), "{{$1|$2}}");
text.value = text.value.replace(new RegExp("\{\{[Cc]zech\}\}(.*)", "g"), "{{cs|$1}}");
text.value = text.value.replace(new RegExp("\{\{[Dd]ansk\}\}(.*)", "g"), "{{da|$1}}");
text.value = text.value.replace(new RegExp("\{\{([Gg]erman|[Dd]eutsch)\}\}(.*)", "g"), "{{de|$2}}");
text.value = text.value.replace(new RegExp("\{\{[Ee]nglish\}\}(.*)", "g"), "{{en|$1}}");
text.value = text.value.replace(new RegExp("\{\{([Ss]panish|[Ee]spañol)\}\}(.*)", "g"), "{{es|$2}}");
text.value = text.value.replace(new RegExp("\{\{[Ss]uomi\}\}(.*)", "g"), "{{fi|$1}}");
text.value = text.value.replace(new RegExp("\{\{[Ff](rench|ran[cç]ais)\}\}(.*)", "g"), "{{fr|$2}}");
text.value = text.value.replace(new RegExp("\{\{[Ii]talian[o]?\}\}(.*)", "g"), "{{it|$1}}");
text.value = text.value.replace(new RegExp("\{\{[Jj]apanese\}\}(.*)", "g"), "{{ja|$1}}");
text.value = text.value.replace(new RegExp("\{\{([Nn]ederlands|[Dd]utch)\}\}(.*)", "g"), "{{nl|$2}}");
text.value = text.value.replace(new RegExp("\{\{([Pp]olish|[Pp]olski)\}\}(.*)", "g"), "{{pl|$2}}");
text.value = text.value.replace(new RegExp("\{\{([Pp]ortuguês|[Pp]ortuguese)\}\}(.*)", "g"), "{{pt|$2}}");
text.value = text.value.replace(new RegExp("\{\{([Rr]omanian)\}\}(.*)", "g"), "{{ro|$2}}");
text.value = text.value.replace(new RegExp("\{\{([Рp]усский|[Rr]ussian)\}\}(.*)", "g"), "{{ru|$2}}");
text.value = text.value.replace(new RegExp("\{\{[Ss]lovensko\}\}(.*)", "g"), "{{sl|$1}}");
text.value = text.value.replace(new RegExp("\{\{([Ss]venska|[Ss]wedish)\}\}(.*)", "g"), "{{sv|$2}}");
text.value = text.value.replace(new RegExp("\{\{[Tt]ürkçe\}\}(.*)", "g"), "{{tr|$1}}");
text.value = text.value.replace(new RegExp("\{\{[Cc]hinese\}\}(.*)", "g"), "{{zh|$1}}");
form.elements['wpSummary'].value = 'internationalization';
form.elements['wpDiff'].click();
}
// add link
function addLink(where, url, name, id, title, key, after) {
// addLink() accepts either an id or a DOM node, mw.util.addPortletLink() only takes a node
if (after && !after.cloneNode)
after = document.getElementById(after);
return mw.util.addPortletLink(where, url, name, id, title, key, after);
}
// ////////////////////////////////////////////////////////
function internationalization() {
form = document.forms['editform'];
var text = form.elements['wpTextbox1'];
text.value = text.value.replace(new RegExp("[\*]?[ ]?\{\{(..)\}\}(.*)", "g"), "WwW |{{subst:lc:$1}}=$2wWw");
text.value = text.value.replace(new RegExp(/WwW([\s\S]*)wWw/g), "{{Translation table|inline=o|hidetitle=o|width=100%\n$1\n}}\n");
text.value = text.value.replace(new RegExp("WwW|wWw", "g"), "");
form.elements['wpSummary'].value = 'internationalization';
form.elements['wpDiff'].click();
}
// Create a tab that calls this function when pressed
$(function () {
if(document.title.indexOf("Modification") == 0) {
addLink('p-cactions', 'javascript:unverified()', 'tag', 'ca-unverified', 'Adds a tag to an unverified image', '', '');
addLink('p-cactions', 'javascript:internationalization()', 'TT', 'ca-internationalization', 'internationalization', '', '');
}
});
/*</pre>
Fin
*/