User:Theleekycauldron/Scripts/PSHAW/dependencies/Prep.js: Difference between revisions
Content deleted Content added
Undid revision 1236155257 by Theleekycauldron (talk) |
Restored revision 1303816471 by Theleekycauldron (talk): Test over |
||
(15 intermediate revisions by the same user not shown) | |||
Line 23:
let page = await get_pages(title,"user|content",null,"older");
let prep = new Prep(title,page)
if (!(title.includes("/Queue/") && prep.content.length<200)){
prep.loadHooks();▼
prep.
prep.loadDYKbotdo();
}
return prep
}
Line 34 ⟶ 37:
let creditstext = splittext.slice(ip[2],ip[3]);
this.hooks = []
creditstext[c] = new Credit(creditstext[c]);
creditstext[c].used = creditstext[c].user == "Editor";
}
for (var h=0; h<hooktext.length; h++){
let hook = new Hook(h,hooktext[h].slice(2),[])
this.hooks.push(hook)
if (hook.articles.length > 0){
console.log(hook)
▲ for (let c in creditstext){
if (credit.used){
continue;
}
console.log(credit)
console.log(hook.articles.includes(credit.article))
if (hook.articles.includes(credit.article)){
console.log("match!")
hook.credits.push(credit)
if (!credit.make){
credit.subpage = hook.credits[0].subpage
}
credit.used = true;
}
}
Line 53 ⟶ 66:
hook.credits.push(new Credit("nullnom"))
}
}
}
this.lost_credits = []
for (let credit of creditstext){
if (!credit.used){
this.lost_credits.push(credit)
}
}
Line 60 ⟶ 79:
let filetext = this.content.match(/\{\{main page image\/DYK.*?}}/g);
this.file = new File(filetext[0])
}
loadDYKbotdo(){
let botdotext = this.content.match(/\{\{DYKbotdo\|(.*)\}\}/)
if (botdotext != null) {
this.botdo = botdotext[1]
} else {
if (this.title.includes("/Queue/")){
this.botdo = "~~~"
} else {
this.botdo = null
}
}
}
Line 71 ⟶ 103:
}
return res
}
lostcredits(){
let res = ''
for (let credit of this.lost_credits){
res += ' <b>Warning</b>: Credit for \"[[' + credit.article + ']]\" in prep set unrecognized. That usually means the article or hook has been moved. The credit <b>will be removed</b> if it is not cured.\n\n';
}
return res.substring(0, res.length - 2)
}
Line 86 ⟶ 126:
assemble(){
let res = []
res.push(`${this.title.includes("Queue")?"{{DYKbotdo|
<noinclude>{{Did you know/Clear/header}}
==Hooks==
Line 120 ⟶ 160:
res.push(credit.content)
}
}
for (let credit of this.lost_credits){
res.push(credit.content)
}
res.push(`</div>
|