User:Jean-Frédéric/flickrLinks.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Jean-Frédéric/flickrLinks. |
- Report page listing warnings and errors.
if(mw.config.get('wgNamespaceNumber')==6) addOnloadHook(addFlickrLinks);
function addFlickrLinks(){
mw.util.addPortletLink('p-cactions', 'javascript:switchDisplay()', 'Flickr links', 'ca-myLinks', 'Links to get Flickr messages');
}
var isDisplayed = false;
//Affiche ou masque la liste des liens.
function switchDisplay(){
if(isDisplayed)
{
document.getElementById('LinksDiv').style.display = 'none';
isDisplayed = false;
}
else
{
createLinks();
isDisplayed = true;
document.getElementById('LinksDiv').style.display = '';
}
}
function createLinks(){
var div = document.getElementById('bodyContent')
LinksDiv = document.getElementById('LinksDiv');
if(!LinksDiv)
{
LinksDiv= document.createElement('div');
LinksDiv.id = "LinksDiv";
LinksDiv.align="center";
div.parentNode.insertBefore(LinksDiv, div);
initLinks();
var tablinks = document.createElement("table")
var line = tablinks.insertRow(-1)
for (var j = 0, len = linksArray.length; j < len ; j++ )
{
var cell = line.insertCell(-1)
cell.appendChild(linksArray[j]);
}
LinksDiv.appendChild(tablinks);
}
}//createLinks
function initLinks()
{
var pageTitle = encodeURIComponent (mw.config.get('wgTitle').split (" ").join ("_"));
linksArray=new Array();
flickrLink1 = document.createElement('a');
with(flickrLink1 ) {
innerHTML='Message Flickr 1';
title='Message de remerciement Flickr sans CheckUsage';
setAttribute("value", "Thanks for licensing this image as CC-BY-SA! Your choice of a free license has allowed us to use your image in <a href=\"http://commons.wikimedia.org/wiki/File:"+ pageTitle + ">Wikimedia Commons</a>.\n<a href=\"http://commons.wikimedia.org/\"><img src=\"http://farm4.static.flickr.com/3560/3312955411_23201ab4ed_o.jpg\" title=\"Wikimedia Commons\" /></a>");
setAttribute("onclick", "window.prompt("
+ "'Message : ', this.getAttribute('value'));"
);
setAttribute("href", "javascript:;");
}
linksArray.push(flickrLink1)
flickrLink2 = document.createElement('a');
with(flickrLink2 ) {
innerHTML='Message Flickr 2';
title='Message de remerciement Flickr avec CheckUsage';
setAttribute("value", "Thanks for licensing this image as CC-BY-SA! Your choice of a free license has allowed us to use your image in <b><a href=\"http://commons.wikimedia.org/wiki/File:"+pageTitle+">Wikimedia Commons</a></b>. The image is now used to illustrate <a href=\"http://tools.wikimedia.de/~daniel/WikiSense/CheckUsage.php?i="+pageTitle+"&w=_100000\">one or more pages</a> on Wikipedia or other free knowledge projects.\n<a href=\"http://commons.wikimedia.org/\"><img src=\"http://farm4.static.flickr.com/3560/3312955411_23201ab4ed_o.jpg\" title=\"Wikimedia Commons\" /></a>");
setAttribute("onclick", "window.prompt("
+ "'Message : ', this.getAttribute('value'));"
);
setAttribute("href", "javascript:;");
}
linksArray.push(flickrLink2)
}//initLinks