මාධ්යවිකි:Upload.js
සටහන: සුරැකීමෙන් පසුව, වෙනස් කම් දැකගැනුමට ඔබගේ බ්රවුසරයෙහි කෑෂය මගහැරයෑමට ඔබට සිදුවිය හැක. ගූගල් ක්රෝම්, ෆයර්ෆොක්ස්, මයික්රොසොෆ්ට් එජ් සහ සෆාරි: Reload ඔබන අතරතුර ⇧ Shift ඔබන්න. සවිස්තරාත්ම උපදෙස් සහ වෙනත් බ්රව්සර වලට අදාළ තොරතුරු සඳහා, විකිපීඩියා:කෑෂය මගහැරයෑම වෙතට යොමු වන්න.
//<source lang="javascript">
// LicenseChecker
//
// checks whether the selected license on Special:Upload is valid and provides feedback
//
// Maintainer: [[User:Dschwen]]
//
var licenseChecker = {
//
// List of invalid licenses
//
invalid: ["subst:nld", "subst:template 2|cc-by-nc-sa-2.0|flickrreview", "subst:template 2|flickrreview|subst:nld"],
//
// Translations of the warning message
//
i18n: {
'de': 'Die ausgewählte <b>Lizenz ist nicht akzeptabel für Wikimedia Commons</b>. Dein <b>Upload wird gelöscht</b> werden!',
'en': 'The selected licensing is <b>unacceptable on Wikimedia Commons</b> and will lead to the <b>deletion</b> of your upload!',
'hr': 'Odabrana licencija je <b>neprihvatljiva za Zajednički poslužitelj</b> i vjerojatno će biti <b>obrisana</b> nakon postavljanja!',
'ru': 'Выбранная лицензия <b>не разрешена на Викискладе</b> и приведёт к <b>удалению</b> загруженного файла!'
},
// Event handler for the license selector
check: function () {
this.$warnbanner.empty();
for (var i = 0; i < this.invalid.length; i++) {
if (this.$licensemenu.val() == this.invalid[i]) {
this.$warnbanner.append(this.message);
return;
}
}
},
install: function () {
if (typeof(UFUI) != 'undefined' && typeof( i18n ) != 'undefined' && typeof(i18n[UFUI.userLanguage]) == 'string') {
// From UploadForm.js, wgUserLanguage with uselang-hacks removed
this.message = i18n[UFUI.userLanguage];
} else {
this.message = (this.i18n[wgUserLanguage] || this.i18n.en);
}
this.$uploadtext = $('#uploadtext');
this.$licensemenu = $('#wpLicense');
// Some forms may not have a license selector (e.g. "fromwikimedia", or reupload forms)
if (!this.$licensemenu.length) return;
this.$warnbanner = $('<div class="center"></div>');
this.$warnbanner.css({
color: 'red',
background: '#eeeeee'
});
this.$uploadtext.append(this.$warnbanner);
$(this.$licensemenu).change(function () {
licenseChecker.check();
});
}
};
$(document).ready(function() {licenseChecker.install();});
/***** loadAutoInformationTemplate ********
* Adds a link to subpages of current page
*
* Maintainers: [[User:Yonidebest]], [[User:Dschwen]]
****/
function loadAutoInformationTemplate() {
//Don't show when reuploading
if (getParamValue('wpDestFile') !== null) return;
//Honor user configuration
if (window.JSconfig && typeof (window.JSconfig.keys) != 'undefined'
&& typeof (window.JSconfig.keys['loadAutoInformationTemplate']) != 'undefined'
&& !window.JSconfig.keys['loadAutoInformationTemplate']) {
return;
}
uploadDescription = document.getElementById('wpUploadDescription');
// ignore fromflickr, as people should use flinfo tool
// ignore fromwikimedia, as people should use commons helper tool
if (uploadDescription != null && wgUserLanguage != 'fromflickr' && wgUserLanguage != 'fromwikimedia' && uploadDescription.value == '') {
switch (wgUserLanguage) {
case "ownwork":
case "deownwork":
case "elownwork":
case "esownwork":
case "faownwork":
case "frownwork":
case "itownwork":
case "mkownwork":
case "nlownwork":
case "noownwork":
case "plownwork":
case "ruownwork":
case "svownwork":
uploadDescription.value = '{{Information\n|Description=\n|Source={{own}}\n|Date=\n|Author= [[User:' + mw.config.get('wgUserName') + '|' + mw.config.get('wgUserName') + ']]\n|Permission=\n|other_versions=\n}}\n';
break;
case "fromgov":
uploadDescription.value = '{{Information\n|Description=\n|Source=\n|Date=\n|Author=\n|Permission=\n|other_versions=\n}}\n';
break;
case "icommons":
uploadDescription.value = '{{Information\n|Description=\n|Source=\n|Date=\n|Author=\n|Permission=\n|other_versions=\n}} \n[[category:iCommons iHeritage]]\n [[category:South Africa]]\n';
break;
default:
uploadDescription.value = '{{Information\n|Description=\n|Source=\n|Date=\n|Author=\n|Permission=\n|other_versions=\n}}\n';
break;
}
/// Hide copy & paste template information, if we just prefilled it automatically
$('#Uploadtext-template-box').hide();
}
}
$(document).ready(loadAutoInformationTemplate);
/*
* Hide on the list of allowed types in the upload form that PDFs can be uploaded.
* Most pdfs shouldn't have been uploaded. Written at the wiki on the best case.
* Discourage its use by hiding that it can be uploaded.
*/
$(document).ready(function () {
$("#mw-upload-permitted p").contents().eq(1).each(function () {
this.data = this.data.replace(/pdf[,،、] /, "");
});
});
//</source>