Diferencia entre revisiones de «Usuario:Stargazer/common.js»

m
Looks good
m (Okay, how about that)
m (Looks good)
Etiqueta: Deshacer
 
(No se muestran 16 ediciones intermedias del mismo usuario)
// TestCopy makingof the "marktag asstatus reviewed buttonchange" gadget that is case insensitive (i.e. makeworks itfor work{{t|Stub}}, for{{t|Partial}}, and {{t|Complete}}) and excludes non-articles
mw.hook('wikipage.diff').add(function tag_status_change() {
 
// 2021-02-22 exclude pages outside ns 0
if (mw.config.get('wgNamespaceNumber') != 0) return
 
// 2018-11-06 add status-change tags to pages with diffs that change the status
const diff = document.querySelector('.diff')
if (!diff) return;
 
diff.querySelectorAll('.diff-addedline').forEach(function find_status_change(el) {
if (!/\{\{([sS]tub|[pP]artial|[cC]omplete)\}\}/.test(el.innerText)) return
const row = el.parentElement
const rem = row.querySelector('.diff-deletedline')
const add = row.querySelector('.diff-addedline')
const msg = rem.innerText.trim() +' => '+ add.innerText.trim()
 
// guard against tagging latest revision in multi-change diffs
if (diff.querySelector('.diff-multi')) {
// TODO: determine which of the revisions to tag?
console.warn('gadget:', 'tag-status-change', 'ignored on combination diff')
mw.notify('theses revisions contain a potential status-change ('+ msg +') which has been ignored')
return;
}
 
console.warn('gadget:', 'tag-status-change')
 
// send the notification
;(new mw.Api).postWithToken('csrf', {
action: 'tag',
revid: mw.config.get('wgRevisionId'),
add: 'status-change',
reason: msg,
}).then(function notify_success() {
mw.notify('revision tagged with '+ msg)
})
 
 
})
 
})
 
 
// Copy of the "mark as reviewed" button gadget that is case insensitive (i.e. works for {{t|Complete}})
mw.hook('wikipage.content').add(function tag_complete_button() {
 
return {
// find {{t|complete}} and replace with {{t|complete|~x4}}
text: revision.content.replace( /\u007b{complete\{[cC]omplete}}/i, '{'+'{complete|~~'+'~~}}' ),
summary: 'mark as complete',
}
*/
 
/*
/* Claim button for objectives */
// Claim button for objectives
// I'm pretty sure I didn't quite get this to work; objective-related stuff isn't really a priority right now, but I'm leaving it here commented out to maybe look at later
mw.hook('wikipage.content').add(function objective_claim_button() {
 
})
}
*/
 
/*
 
//PlayingTweaks around withto editing toolbar
var customizeToolbar = function() {
/*/ Your code goes here */
// Add category button
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
"category": {
label: 'Category',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/2/2d/Button_clipboard_category.png',
action: {
type: 'encapsulate',
options: {
pre: "[[Category: ",
post: "]]"
}
}
}
}
});
 
//Remove references button
'tool': 'reference'
});
*/
 
//Add new references dropdown
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
groups: {
list: {
tools: {
references: {
label: 'References',
type: 'select',
list: {
'book-button': {
label: '{' + '{book ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{book ref|',
post: '}}'
}
}
},
'wob-button': {
label: '{' + '{wob ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{wob ref|',
post: '}}'
}
}
},
'ref-button': {
label: '{' + '{ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{ref|',
post: '}}'
}
}
},
'epigraph-button': {
label: '{' + '{epigraph ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{epigraph ref|',
post: '}}'
}
}
},
'au-button': {
label: '{' + '{au ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{au ref|',
post: '}}'
}
}
},
'msh-button': {
label: '{' + '{msh ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{msh ref|',
post: '}}'
}
}
},
'file-button': {
label: '{' + '{file ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{file ref|',
post: '}}'
}
}
},
'url-button': {
label: '{' + '{url ref}}',
action: {
type: 'encapsulate',
options: {
pre: '{' + '{url ref|',
post: '}}'
}
}
}
}
}
}
}
}
} );
};
 
/*
* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar...
* Don't touch below this line!
 
*/
if (['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1) {
mw.loader.using('user.options').then(function() {
});
}
*/