MediaWiki:Gadget-twinkleimage.js: Difference between revisions

Localise
m (1 revision)
 
(Localise)
 
(6 intermediate revisions by 2 users not shown)
Line 24: Line 24:


Twinkle.image.callback = function twinkleimageCallback() {
Twinkle.image.callback = function twinkleimageCallback() {
var Window = new Morebits.simpleWindow( 600, 300 );
var Window = new Morebits.simpleWindow( 600, 330 );
Window.setTitle( "File for dated speedy deletion" );
Window.setTitle( "File for dated speedy deletion" );
Window.setScriptName( "Twinkle" );
Window.setScriptName( "Twinkle" );
Line 72: Line 72:
label: 'Orphaned fair use (CSD F5)',
label: 'Orphaned fair use (CSD F5)',
value: 'orphaned fair use',
value: 'orphaned fair use',
tooltip: 'Image or media is unlicensed for use on Wikipedia and allowed only under a claim of fair use per Wikipedia:Non-free content, but it is not used in any articles'
tooltip: 'Image or media is unlicensed for use on Wikipedia and allowed only under a claim of fair use per Sarkarverse:Non-free content, but it is not used in any articles'
},
},
{
{
Line 130: Line 130:
{
{
label: 'Non-free',
label: 'Non-free',
tooltip: 'Image is licensed under a fair use claim'
tooltip: 'File is licensed under a fair use claim'
}
]
} );
/* falls through */
case 'no license':
work_area.append( {
type: 'checkbox',
name: 'derivative',
list: [
{
label: 'Derivative work which lacks a source for incorporated works',
tooltip: 'File is a derivative of one or more other works whose source is not specified'
}
}
]
]
Line 158: Line 170:
case 'replaceable fair use':
case 'replaceable fair use':
work_area.append( {
work_area.append( {
type: 'checkbox',
type: 'textarea',
name: 'old_image',
name: 'reason',
list: [
label: 'Reason: '
{
label: 'Old image',
tooltip: 'Image was uploaded before 2006-07-13'
}
]
} );
} );
break;
break;
Line 176: Line 183:


Twinkle.image.callback.evaluate = function twinkleimageCallbackEvaluate(event) {
Twinkle.image.callback.evaluate = function twinkleimageCallbackEvaluate(event) {
var type, non_free, source, reason, replacement, old_image;
var type, non_free, source, reason, replacement, derivative;


var notify = event.target.notify.checked;
var notify = event.target.notify.checked;
Line 198: Line 205:
replacement = event.target.replacement.value;
replacement = event.target.replacement.value;
}
}
if( event.target.old_image ) {
if( event.target.derivative ) {
old_image = event.target.old_image.checked;
derivative = event.target.derivative.checked;
}
}


Line 227: Line 234:


var lognomination = Twinkle.getPref('logSpeedyNominations') && Twinkle.getPref('noLogOnSpeedyNomination').indexOf(csdcrit.toLowerCase()) === -1;
var lognomination = Twinkle.getPref('logSpeedyNominations') && Twinkle.getPref('noLogOnSpeedyNomination').indexOf(csdcrit.toLowerCase()) === -1;
var templatename = (derivative ? ('dw ' + type) : type);


var params = {
var params = {
'type': type,
'type': type,
'templatename': templatename,
'normalized': csdcrit,
'normalized': csdcrit,
'non_free': non_free,
'non_free': non_free,
Line 235: Line 244:
'reason': reason,
'reason': reason,
'replacement': replacement,
'replacement': replacement,
'old_image': old_image,
'lognomination': lognomination
'lognomination': lognomination
};
};
Line 260: Line 268:
// No auto-notification, display what was going to be added.
// No auto-notification, display what was going to be added.
var noteData = document.createElement( 'pre' );
var noteData = document.createElement( 'pre' );
noteData.appendChild( document.createTextNode( "{{subst:di-" + type + "-notice|1=" + mw.config.get('wgTitle') + "}} ~~~~" ) );
noteData.appendChild( document.createTextNode( "{{subst:di-" + templatename + "-notice|1=" + mw.config.get('wgTitle') + "}} ~~~~" ) );
Morebits.status.info( 'Notification', [ 'Following/similar data should be posted to the original uploader:', document.createElement( 'br' ),  noteData ] );
Morebits.status.info( 'Notification', [ 'Following/similar data should be posted to the original uploader:', document.createElement( 'br' ),  noteData ] );
}
}
Line 273: Line 281:
text = text.replace(/\{\{(mtc|(copy |move )?to ?commons|move to wikimedia commons|copy to wikimedia commons)[^}]*\}\}/gi, "");
text = text.replace(/\{\{(mtc|(copy |move )?to ?commons|move to wikimedia commons|copy to wikimedia commons)[^}]*\}\}/gi, "");


var tag = "{{di-" + params.type + "|date={{subst:#time:j F Y}}";
var tag = "{{di-" + params.templatename + "|date={{subst:#time:j F Y}}";
switch( params.type ) {
switch( params.type ) {
case 'no source no license':
case 'no source no license':
Line 289: Line 297:
break;
break;
case 'replaceable fair use':
case 'replaceable fair use':
tag += params.old_image ? "|old image=yes" : "";
tag += params.reason ? "|1=" + params.reason : "";
break;
break;
default:
default:
break;  // doesn't matter
break;  // doesn't matter
}
}
tag += "}}\n";
tag += "|help=off}}\n";


pageobj.setPageText(tag + text);
pageobj.setPageText(tag + text);
Line 315: Line 323:
var params = pageobj.getCallbackParameters();
var params = pageobj.getCallbackParameters();
var initialContrib = pageobj.getCreator();
var initialContrib = pageobj.getCreator();
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
 
var notifytext = "\n{{subst:di-" + params.type + "-notice|1=" + mw.config.get('wgTitle');
// disallow warning yourself
if (params.type === 'no permission') {
if (initialContrib === mw.config.get('wgUserName')) {
notifytext += params.source ? "|source=" + params.source : "";
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification");
}
} else {
notifytext += "}} ~~~~";
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
usertalkpage.setAppendText(notifytext);
var notifytext = "\n{{subst:di-" + params.templatename + "-notice|1=" + mw.config.get('wgTitle');
usertalkpage.setEditSummary("Notification: tagging for deletion of [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
if (params.type === 'no permission') {
usertalkpage.setCreateOption('recreate');
notifytext += params.source ? "|source=" + params.source : "";
switch (Twinkle.getPref('deliWatchUser')) {
}
case 'yes':
notifytext += "}} ~~~~";
usertalkpage.setWatchlist(true);
usertalkpage.setAppendText(notifytext);
break;
usertalkpage.setEditSummary("Notification: tagging for deletion of [[:" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
case 'no':
usertalkpage.setCreateOption('recreate');
usertalkpage.setWatchlistFromPreferences(false);
switch (Twinkle.getPref('deliWatchUser')) {
break;
case 'yes':
default:
usertalkpage.setWatchlist(true);
usertalkpage.setWatchlistFromPreferences(true);
break;
break;
case 'no':
usertalkpage.setWatchlistFromPreferences(false);
break;
default:
usertalkpage.setWatchlistFromPreferences(true);
break;
}
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
}
}
usertalkpage.setFollowRedirect(true);
usertalkpage.append();


// add this nomination to the user's userspace log, if the user has enabled it
// add this nomination to the user's userspace log, if the user has enabled it
14,061

edits