Widget:ProjectLabel: Difference between revisions
From Makerpedia
No edit summary |
No edit summary |
||
| Line 36: | Line 36: | ||
window.widgets.push(appStart); | window.widgets.push(appStart); | ||
</script> | </script> | ||
<style> | |||
#projectLabel { | |||
position: relative; | |||
width:525px; | |||
height: 400px; | |||
} | |||
#projectLabel img{ | |||
position: absolute; | |||
left: 0; | |||
top: 0; | |||
width:525px; | |||
height: 400px; | |||
} | |||
#projectTitle{ | |||
position: absolute; | |||
left: 18px; | |||
top: 18px; | |||
width: calc(525px - 36px); | |||
height: 78px; | |||
text-align: center; | |||
line-height: 78px; | |||
font-family: serif; | |||
font-size:24px; | |||
} | |||
</style> | |||
<div id="projectLabel"> | <div id="projectLabel"> | ||
<img src="images/frames/projectLabelFrame.png"></img> | <img src="images/frames/projectLabelFrame.png"></img> | ||
<div id="projectTitle">Test</div> | |||
</div> | </div> | ||
Revision as of 19:57, 21 March 2025
<script> function appStart(){
if(pageParams["page"]){
mw.loader.using(['mediawiki.api', 'jquery']).then(()=>{
new mw.Api().get({
action: 'query',
prop: 'revisions',
rvprop: 'content',
titles: pageParams["page"],
format: 'json'
}).done(function (pageData) {
var pageId = Object.keys(pageData.query.pages)[0];
var content = pageData.query.pages[pageId].revisions[0]['*'];
var pageUrl = mw.util.getUrl(pageParams["page"]);
var badges = [];
const regex = /\[\[Category:(.*?)\]\]/gi;
let cats = content.match(regex);
cats = cats.map(match => /\[\[Category:(.*?)\]\]/i.exec(match)[1]);
console.log(cats);
cats.forEach(cat=>{
makerSkills.forEach(skill=>{
if(cat == skill.name) badges.push(skill.image);
});
});
console.log(badges);
});
});
}
}
if(!window.widgets) window.widgets = [];
window.widgets.push(appStart);
</script>
<style>
- projectLabel {
position: relative; width:525px; height: 400px;
}
- projectLabel img{
position: absolute; left: 0; top: 0; width:525px; height: 400px;
}
- projectTitle{
position: absolute; left: 18px; top: 18px; width: calc(525px - 36px); height: 78px; text-align: center; line-height: 78px; font-family: serif; font-size:24px;
} </style>
<img src="images/frames/projectLabelFrame.png"></img>
Test