User:Tomia/monobook.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.
The accompanying .css page for this skin is at User:Tomia/monobook.css. |
- Report page listing warnings and errors.
//<nowiki>
function myInsert(area, yht) {
if(area) {
document.editform.wpTextbox1.value = area + '\n' +
document.editform.wpTextbox1.value;
}
document.editform.wpSummary.value = yht;
// document.editform.wpWatchthis.checked=false;
}
function myAppend(area, yht) {
if(area) {
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value +
'\n' + area;
}
document.editform.wpSummary.value = yht;
// document.editform.wpWatchthis.checked=false;
}
function global_get_tidy_title()
{
// get the article link from the label 'ca-edit' out of the document text.
var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
// If a page is write protected (for that user, a sysop will always have 'ca-edit')
// we need 'ca-viewsource' as 'ca-edit' does not exist there.
if (editlk == null)
{
var editlk = document.getElementById('ca-viewsource').getElementsByTagName('a')[0].href;
}
// Cut everything up to "title=" from the start and everything past "&action=edit"
// from the end.
editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.indexOf('&'));
editlk = editlk.replace(/\/.*$/, ''); //removing subpages from the link
return editlk;
}
function loadHook() {
var div = document.getElementById('specialchars');
if(div) {
// extract the namespace
var namespace = global_get_tidy_title();
if (namespace.indexOf('Image:') == 0) {
div.innerHTML +=
"<div><a href=\"javascript:insertTags('{{Information|\\n|Description =\\n','|Source = self-made\\n|Date = 2006-07-\\n|Author = [[User:Tomia]]\\n|Permission =\\n}}\\n','')\">[[test]]</a>" +
" · <a href=\"javascript:myInsert('{{subst:nld}}','{{no license}}')\">{{nolicense}}</a>" +
" · <a href=\"javascript:myInsert('{{subst:nsd}}','{{no source}}')\">{{nosource}}</a>" +
" · <a href=\"javascript:myInsert('{{copyvio}}','{{copyvio}}')\">{{copyvio}}</a>" +
" · <a href=\"javascript:myInsert('{{Albumcover}}','{{Albumcover}}')\">{{album}}</a>" +
" · <a href=\"javascript:myInsert('{{Bookcover}}','{{Bookcover}}')\">{{book}}</a>" +
" · <a href=\"javascript:myInsert('{{Logo}}','{{Logo}}')\">{{logo}}</a>" +
"</div>";
}
else if (namespace.indexOf('User_talk:') == 0) {
div.innerHTML +=
"<div><a href=\"javascript:insertTags('== [[:Image:',']] ==','')\">==[[:Image:]]==</a>" +
" · <a href=\"javascript:insertTags('{{subst:Welcome}}\\n --~~~~','', '')\">{{Welcome}}</a>" +
" · <a href=\"javascript:myAppend('{{subst:Please tag images}} --~~~~', '{{Please tag images}}')\">{{Tageja puuttuu}}</a>" +
" · <a href=\"javascript:myAppend('{{subst:Please link images}} --~~~~', '{{Please link images}}')\">{{Luokat puuttuu}}</a>" +
"</div>";
}
}
}
// Copied from [[MediaWiki:Quick-delete.js]]
// Configuration
// Should the edits be saved automatically?
mnx_autosave = false;
mns_text = "Mark as no source";
mns_tooltip = "Mark this image as missing required source information";
mnl_text = "Mark as no license";
mnl_tooltip = "Mark this image as missing required licensing information";
mnp_text = "Mark as no permission";
mnp_tooltip = "Mark this image as missing permission info";
mco_text = "Mark as copyvio";
mco_tooltip = "Mark this image as copyvio";
// Site info
mnx_path = "/w/index.php";
mnx_prettypath = "/wiki/";
mnx_hostname = "commons.wikimedia.org"
// From [[en:Wikipedia:WikiProject User scripts/Scripts/Get Page Name]]
function getPname() {
z=document.getElementById("content").childNodes;
for (var n=0;n<z.length;n++) {
if (z[n].className=="firstHeading") return z[n].textContent;
};
}
// From [[en:Wikipedia:WikiProject User scripts/Scripts/addLink]]
function addLink(where, url, name, id, title, key, after){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
if(after) {
tabs.insertBefore(li,document.getElementById(after));
} else {
tabs.appendChild(li);
}
if(id) {
if(key && title) { ta[id] = [key, title]; }
else if(key) { ta[id] = [key, '']; }
else if(title) { ta[id] = ['', title];}
}
// re-render the title and accesskeys from existing code in wikibits.js
akeytt();
return li;
}
// From [[en:User:Lupin/autoedit.js]]
function getParamValue(paramName) {
var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
var h=document.location;
var m=cmdRe.exec(h);
if (m) {
try {
return decodeURIComponent(m[1]);
} catch (someError) {}
}
return null;
}
function mnx_openWindow(url) {
var res = window.open(url, '_blank');
if (!res) alert("mnx_openWindow: window.open() returned null");
}
function mnx_getUploader() {
// Get uploader from first point in the list under "File history"
// Uploader is stored in second A tag in UL tag under "File history"
// Returns title of user page (without name space) in URL form
var el = document.getElementById('filehistory')
if (!el) {
alert("mnx_getUploader: Cannot find filehistory ... exiting");
return null;
}
while (el.nextSibling) {
el = el.nextSibling;
if (el.tagName && el.tagName.toLowerCase() == 'table')
break;
}
if (!el) {
alert("mnx_getUploader: Cannot find table tag ... exiting");
return null;
}
var as = el.getElementsByTagName('a');
var re1 = new RegExp('http://' + (mnx_hostname + mnx_prettypath).replace(/\./g, '\\.') + 'User:(.*)$');
var re2 = new RegExp('http://' + (mnx_hostname + mnx_path).replace(/\./g, '\\.') + '\\?title=User:([^&]*)');
var m;
for (var k=0; k<as.length; k++) {
m = re1.exec(as[k].href);
if (m) return m[1];
m = re2.exec(as[k].href);
if (m) return m[1];
}
alert("mnx_getUploader: Cannot find uploader ... exiting");
return null;
}
function mnx_markNo(action) {
var pagename = encodeURIComponent(getPname());
var uploader = mnx_getUploader();
if (!uploader) return;
if(action == 'mco_mco') {
useraction = 'mco_warn';
}
else if (action == 'mnp_mnp') {
useraction = 'mnp_warn';
}
else {
useraction = 'mnx_warn';
}
mnx_openWindow(mnx_path + '?title=User_talk:' + uploader
+ '&action=edit&fakeaction=' + useraction + '&target=' + pagename);
var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
document.location = editlk + '&fakeaction=' + action ;
}
function mnx_addTemplate(template, sorl) {
var txt = '{{subst:' + template + '}}';
// this MUST be subst since templates are NSD, NLD
document.editform.wpTextbox1.value = txt + '\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'marking image as missing essential ' + sorl + ' information. If this is not fixed this image might be deleted after 7 days.';
// this is the edit summary for when you mark the image. you can change it if you want.
// sorl = "source" or "license"
if (mnx_autosave) document.editform.wpSave.click();
}
function mnx_addUserWarningTemplate(imagetarget) {
var txt = '{{subst:image source|' + imagetarget + '}}';
document.editform.wpTextbox1.value += '\n' + txt + '~~~~\n';
document.editform.wpSummary.value = "Warning: image missing source or licensing information.";
if (mnx_autosave) document.editform.wpSave.click();
}
function mnp_addUserWarningTemplate(imagetarget) {
var txt = '{{subst:image permission|'+ imagetarget + '}}';
document.editform.wpTextbox1.value += '\n' + txt + '~~~~\n';
document.editform.wpSummary.value = "Warning: image missing permission info.";
if (mnx_autosave) document.editform.wpSave.click();
}
function mco_addTemplate() {
var txt = '{{copyvio}}';
document.editform.wpTextbox1.value = txt + '\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = 'Marking as copyvio';
if (mnx_autosave) document.editform.wpSave.click();
}
function mco_addUserWarningTemplate(imagetarget) {
var txt = '{{subst:copyvionote|' + imagetarget + '}}';
document.editform.wpTextbox1.value += '\n' + txt + '~~~~\n';
document.editform.wpSummary.value = "Warning: copyvio or against policy.";
if (mnx_autosave) document.editform.wpSave.click();
}
function mnx_onload() {
if (getPname().indexOf('Image:') == 0) {
addLink('p-tb', 'javascript:mnx_markNo(\'mns_mns\')', mns_text, 'mark-no-source', mns_tooltip);
addLink('p-tb', 'javascript:mnx_markNo(\'mnp_mnp\')', mnp_text, 'mark-no-permission', mnp_tooltip);
addLink('p-tb', 'javascript:mnx_markNo(\'mnl_mnl\')', mnl_text, 'mark-no-license', mnl_tooltip);
addLink('p-tb', 'javascript:mnx_markNo(\'mco_mco\')', mco_text, 'mark-copyvio', mco_tooltip);
}
else {
var fakeaction = getParamValue('fakeaction');
if (fakeaction == 'mns_mns'){
mnx_addTemplate('nsd','source');
}
else if (fakeaction == 'mnl_mnl'){
mnx_addTemplate('nld','license');
}
else if (fakeaction == 'mnp_mnp'){
mnx_addTemplate('npd','permission');
}
else if (fakeaction == 'mco_mco'){
mco_addTemplate();
}
else if (fakeaction == 'mnp_warn'){
mnp_addUserWarningTemplate(getParamValue('target'));
}
else if (fakeaction == 'mnx_warn'){
mnx_addUserWarningTemplate(getParamValue('target'));
}
else if (fakeaction == 'mco_warn'){
mco_addUserWarningTemplate(getParamValue('target'));
}
}
}
// Copy ends
$(mnx_onload);
$(loadHook);
// </nowiki>