User:Theleekycauldron/Scripts/PSHAW/dependencies/Prep.js: Difference between revisions

Content deleted Content added
bugfixen
Restored revision 1303816471 by Theleekycauldron (talk): Test over
 
(8 intermediate revisions by the same user not shown)
Line 26:
prep.loadHooks();
prep.loadFiles();
prep.loadDYKbotdo();
}
return prep
Line 38 ⟶ 39:
for (let c in creditstext){
creditstext[c] = new Credit(creditstext[c]);
creditstext[c].used = creditstext[c].articleuser == "ExampleEditor";
}
for (var h=0; h<hooktext.length; h++){
Line 44 ⟶ 45:
this.hooks.push(hook)
if (hook.articles.length > 0){
console.log(hook)
for (let credit of 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){
Line 71 ⟶ 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 87 ⟶ 108:
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 - 12)
}
Line 105 ⟶ 126:
assemble(){
let res = []
res.push(`${this.title.includes("Queue")?"{{DYKbotdo|~~~"+this.botdo+"}}":""}
<noinclude>{{Did you know/Clear/header}}
==Hooks==
Line 139 ⟶ 160:
res.push(credit.content)
}
}
for (let credit of this.lost_credits){
res.push(credit.content)
}
res.push(`</div>