User:Theleekycauldron/Scripts/PSHAW/dependencies/Hook.js: Difference between revisions
Content deleted Content added
should be done |
def capitalize |
||
(30 intermediate revisions by the same user not shown) | |||
Line 12:
copies or substantial portions of the Software.
*/
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
class Hook {
constructor(id,content,credits){
Line 18 ⟶ 20:
this.content = content;
this.articles = []
for (let m of this.content.matchAll(/'''[^']*?\[\[(
this.articles.push(capitalize(m[1]))
}
this.credits = credits
Line 37 ⟶ 39:
}
async subpage(){ //returns as Nomination object
if (this.credits.length>0){
let nomination = await Nomination.create(`Template:Did you know nominations/${this.credits[0].subpage}`);
return nomination;
}▼
return null
}▼
give_credit(credit){
let res;
|article=${credit.article}
|optional=
|nompage=Template:Did you know nominations/${credit.subpage}
|hook=${this.
}} ~~~~`
|article=${credit.article}
|optional=
|nompage=Template:Did you know nominations/${
}} ~~~~`
}
var params = {
action: 'edit',
title:
summary: `Giving credit for ${credit.article}`+tag,
section: 'new',
sectiontitle: `DYK for ${credit.article}`,
Line 64 ⟶ 73:
format: 'json'
}
return api.postWithToken( 'csrf', params );
}
tag_talk(article,file){
let res;
let today = new Date()
today = `${today.getUTCDate()} ${["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][today.getUTCMonth()]} ${today.getUTCFullYear()}`
▲ res = `{{DYK talk|${today}|entry=${this.hook}|${file}}}`
console.log(talk)
▲ get_section([`Talk:${credit.article}`],"user|content",null,"older",0).then((talktext) => {
console.log(talktext)
title: `Talk:${article}`,
summary: `Article appeared on [[WP:DYK|DYK]] on ${today}, adding {{[[Template:DYK talk|DYK talk]]}}`+tag, ▲ }
}
}
// </nowiki>
|