Module:ElementAchievementBadges: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| (6 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
--[[ | --[[ | ||
* Name: ElementAchievementBadges | |||
* Author: Mark W. Datysgeld | |||
* Description: Element module that renders achievement badges for Person templates and handles all badge-type achievements | |||
* Notes: Creates blocks for Blueprint framework; loads achievement data using AchievementSystem; filters for badge-type achievements; renders badges as HTML spans with CSS classes; includes category links; protected execution with error handling | |||
]] | |||
local p = {} | local p = {} | ||
| Line 36: | Line 35: | ||
end | end | ||
-- CRITICAL: | -- CRITICAL: WE MUST PRE-LOAD THE JSON DATA WITH THE FRAME BEFORE GETTING ANY ACHIEVEMENTS | ||
pcall(function() | pcall(function() | ||
Achievements.loadData(frame) | Achievements.loadData(frame) | ||
| Line 43: | Line 41: | ||
end) | end) | ||
-- Get all | -- Get all badge-type achievements using the centralized function | ||
local badgeAchievements = Achievements.getBadgeAchievements(pageId, frame) | |||
local badgeAchievements | |||
-- Minimal debug info for troubleshooting | -- Minimal debug info for troubleshooting | ||
| Line 113: | Line 89: | ||
end | end | ||
end | end | ||
-- Get category links from the centralized function | |||
local categoryLinksString = Achievements.getCategoryLinks(badgeAchievements, frame) | |||
-- Return the complete HTML with debug info | -- Return the complete HTML with debug info and category links | ||
return table.concat(badgesHtml) .. debugInfo | return table.concat(badgesHtml) .. categoryLinksString .. debugInfo | ||
end | end | ||