ItemRef.lua

ItemRef.lua (8.2.0.31429; unchanged since 8.2.0.30920)
  1. local function FormatLink(linkType, linkDisplayText, ...)
  2. local linkFormatTable = { ("|H%s"):format(linkType), ... };
  3. local returnLink = table.concat(linkFormatTable, ":");
  4. if linkDisplayText then
  5. return returnLink .. ("|h%s|h"):format(linkDisplayText);
  6. else
  7. return returnLink .. "|h";
  8. end
  9. end
  10. function SetItemRef(link, text, button, chatFrame)
  11. -- Going forward, use linkType and linkData instead of strsub and strsplit everywhere
  12. local linkType, linkData = string.match(link, '(.-):(.*)');
  13. if ( strsub(link, 1, 6) == "player" ) then
  14. local namelink, isGMLink, isCommunityLink;
  15. if ( strsub(link, 7, 8) == "GM" ) then
  16. namelink = strsub(link, 10);
  17. isGMLink = true;
  18. elseif ( strsub(link, 7, 15) == "Community") then
  19. namelink = strsub(link, 17);
  20. isCommunityLink = true;
  21. else
  22. namelink = strsub(link, 8);
  23. end
  24. local name, lineID, chatType, chatTarget, communityClubID, communityStreamID, communityEpoch, communityPosition;
  25. if ( isCommunityLink ) then
  26. name, communityClubID, communityStreamID, communityEpoch, communityPosition = strsplit(":", namelink);
  27. else
  28. name, lineID, chatType, chatTarget = strsplit(":", namelink);
  29. end
  30. if ( name and (strlen(name) > 0) ) then
  31. if ( IsModifiedClick("CHATLINK") ) then
  32. local staticPopup;
  33. staticPopup = StaticPopup_Visible("ADD_IGNORE");
  34. if ( staticPopup ) then
  35. -- If add ignore dialog is up then enter the name into the editbox
  36. _G[staticPopup.."EditBox"]:SetText(name);
  37. return;
  38. end
  39. staticPopup = StaticPopup_Visible("ADD_FRIEND");
  40. if ( staticPopup ) then
  41. -- If add ignore dialog is up then enter the name into the editbox
  42. _G[staticPopup.."EditBox"]:SetText(name);
  43. return;
  44. end
  45. staticPopup = StaticPopup_Visible("ADD_GUILDMEMBER");
  46. if ( staticPopup ) then
  47. -- If add ignore dialog is up then enter the name into the editbox
  48. _G[staticPopup.."EditBox"]:SetText(name);
  49. return;
  50. end
  51. staticPopup = StaticPopup_Visible("ADD_RAIDMEMBER");
  52. if ( staticPopup ) then
  53. -- If add ignore dialog is up then enter the name into the editbox
  54. _G[staticPopup.."EditBox"]:SetText(name);
  55. return;
  56. end
  57. staticPopup = StaticPopup_Visible("CHANNEL_INVITE");
  58. if ( staticPopup ) then
  59. _G[staticPopup.."EditBox"]:SetText(name);
  60. return;
  61. end
  62. if ( ChatEdit_GetActiveWindow() ) then
  63. ChatEdit_InsertLink(name);
  64. else
  65. C_FriendList.SendWho(WHO_TAG_EXACT..name);
  66. end
  67. elseif ( button == "RightButton" and (not isGMLink) ) then
  68. FriendsFrame_ShowDropdown(name, 1, lineID, chatType, chatFrame, nil, nil, communityClubID, communityStreamID, communityEpoch, communityPosition);
  69. else
  70. ChatFrame_SendTell(name, chatFrame);
  71. end
  72. end
  73. return;
  74. elseif ( strsub(link, 1, 8) == "BNplayer" ) then
  75. local namelink, isCommunityLink;
  76. if ( strsub(link, 9, 17) == "Community" ) then
  77. namelink = strsub(link, 19);
  78. isCommunityLink = true;
  79. else
  80. namelink = strsub(link, 10);
  81. end
  82. local name, bnetIDAccount, lineID, chatType, chatTarget, communityClubID, communityStreamID, communityEpoch, communityPosition;
  83. if ( isCommunityLink ) then
  84. name, bnetIDAccount, communityClubID, communityStreamID, communityEpoch, communityPosition = strsplit(":", namelink);
  85. else
  86. name, bnetIDAccount, lineID, chatType, chatTarget = strsplit(":", namelink);
  87. end
  88. if ( name and (strlen(name) > 0) ) then
  89. if ( IsModifiedClick("CHATLINK") ) then
  90. --[[
  91. disable SHIFT-CLICK for battlenet friends, so we don't put an encoded bnetIDAccount in chat
  92. local staticPopup;
  93. staticPopup = StaticPopup_Visible("ADD_IGNORE");
  94. if ( staticPopup ) then
  95. -- If add ignore dialog is up then enter the name into the editbox
  96. _G[staticPopup.."EditBox"]:SetText(name);
  97. return;
  98. end
  99. staticPopup = StaticPopup_Visible("ADD_FRIEND");
  100. if ( staticPopup ) then
  101. -- If add ignore dialog is up then enter the name into the editbox
  102. _G[staticPopup.."EditBox"]:SetText(name);
  103. return;
  104. end
  105. staticPopup = StaticPopup_Visible("ADD_GUILDMEMBER");
  106. if ( staticPopup ) then
  107. -- If add ignore dialog is up then enter the name into the editbox
  108. _G[staticPopup.."EditBox"]:SetText(name);
  109. return;
  110. end
  111. staticPopup = StaticPopup_Visible("ADD_RAIDMEMBER");
  112. if ( staticPopup ) then
  113. -- If add ignore dialog is up then enter the name into the editbox
  114. _G[staticPopup.."EditBox"]:SetText(name);
  115. return;
  116. end
  117. staticPopup = StaticPopup_Visible("CHANNEL_INVITE");
  118. if ( staticPopup ) then
  119. _G[staticPopup.."EditBox"]:SetText(name);
  120. return;
  121. end
  122. if ( ChatEdit_GetActiveWindow() ) then
  123. ChatEdit_InsertLink(name);
  124. end
  125. ]]
  126. elseif ( button == "RightButton" ) then
  127. if ( isCommunityLink or not BNIsSelf(bnetIDAccount) ) then
  128. FriendsFrame_ShowBNDropdown(name, 1, nil, chatType, chatFrame, nil, bnetIDAccount, communityClubID, communityStreamID, communityEpoch, communityPosition);
  129. end
  130. else
  131. if ( BNIsFriend(bnetIDAccount)) then
  132. ChatFrame_SendBNetTell(name);
  133. else
  134. local displayName = BNGetDisplayName(bnetIDAccount);
  135. ChatFrame_SendBNetTell(displayName)
  136. end
  137. end
  138. end
  139. return;
  140. elseif ( strsub(link, 1, 7) == "channel" ) then
  141. if ( IsModifiedClick("CHATLINK") ) then
  142. local chanLink = strsub(link, 9);
  143. local chatType, chatTarget = strsplit(":", chanLink);
  144. ChannelFrame:Toggle();
  145. elseif ( button == "LeftButton" ) then
  146. local chanLink = strsub(link, 9);
  147. local chatType, chatTarget = strsplit(":", chanLink);
  148. if ( strupper(chatType) == "CHANNEL" ) then
  149. if ( GetChannelName(tonumber(chatTarget))~=0 ) then
  150. ChatFrame_OpenChat("/"..chatTarget, chatFrame);
  151. end
  152. elseif ( strupper(chatType) == "PET_BATTLE_COMBAT_LOG" or strupper(chatType) == "PET_BATTLE_INFO" ) then
  153. --Don't do anything
  154. else
  155. ChatFrame_OpenChat("/"..chatType, chatFrame);
  156. end
  157. elseif ( button == "RightButton" ) then
  158. local chanLink = strsub(link, 9);
  159. local chatType, chatTarget = strsplit(":", chanLink);
  160. if not ( (strupper(chatType) == "CHANNEL" and GetChannelName(tonumber(chatTarget)) == 0) ) then --Don't show the dropdown if this is a channel we are no longer in.
  161. ChatChannelDropDown_Show(chatFrame, strupper(chatType), chatTarget, Chat_GetColoredChatName(strupper(chatType), chatTarget));
  162. end
  163. end
  164. return;
  165. elseif ( strsub(link, 1, 6) == "GMChat" ) then
  166. GMChatStatusFrame_OnClick();
  167. return;
  168. elseif ( strsub(link, 1, 7) == "levelup" ) then
  169. local _, level, levelUpType, arg1 = strsplit(":", link);
  170. LevelUpDisplay_ShowSideDisplay(tonumber(level), _G[levelUpType], arg1);
  171. return;
  172. elseif ( strsub(link, 1, 6) == "pvpbgs" ) then
  173. TogglePVPUI();
  174. return;
  175. elseif ( strsub(link, 1, 3) == "lfd" ) then
  176. ToggleLFDParentFrame();
  177. return;
  178. elseif ( strsub(link, 1, 8) == "specpane" ) then
  179. ToggleTalentFrame(SPECIALIZATION_TAB);
  180. return;
  181. elseif ( strsub(link, 1, 10) == "talentpane" ) then
  182. ToggleTalentFrame(TALENTS_TAB);
  183. return;
  184. elseif ( strsub(link, 1, 14) == "mountequipment" ) then
  185. ToggleCollectionsJournal(1);
  186. return;
  187. elseif ( strsub(link, 1, 11) == "honortalent" ) then
  188. ToggleTalentFrame(PVP_TALENTS_TAB);
  189. return;
  190. elseif ( strsub(link, 1, 10) == "worldquest" ) then
  191. OpenWorldMap();
  192. return;
  193. elseif ( strsub(link, 1, 7) == "journal" ) then
  194. if ( not HandleModifiedItemClick(GetFixedLink(text)) ) then
  195. if ( not EncounterJournal ) then
  196. EncounterJournal_LoadUI();
  197. end
  198. EncounterJournal_OpenJournalLink(strsplit(":", link));
  199. end
  200. return;
  201. elseif ( strsub(link, 1, 8) == "urlIndex" ) then
  202. local _, index = strsplit(":", link);
  203. LoadURLIndex(tonumber(index));
  204. return;
  205. elseif ( strsub(link, 1, 11) == "lootHistory" ) then
  206. local _, rollID = strsplit(":", link);
  207. LootHistoryFrame_ToggleWithRoll(LootHistoryFrame, tonumber(rollID), chatFrame);
  208. return;
  209. elseif ( strsub(link, 1, 13) == "battlePetAbil" ) then
  210. local _, abilityID, maxHealth, power, speed = strsplit(":", link);
  211. if ( IsModifiedClick() ) then
  212. local fixedLink = GetFixedLink(text);
  213. HandleModifiedItemClick(fixedLink);
  214. else
  215. FloatingPetBattleAbility_Show(tonumber(abilityID), tonumber(maxHealth), tonumber(power), tonumber(speed));
  216. end
  217. return;
  218. elseif ( strsub(link, 1, 9) == "battlepet" ) then
  219. local _, speciesID, level, breedQuality, maxHealth, power, speed, battlePetID = strsplit(":", link);
  220. if ( IsModifiedClick() ) then
  221. local fixedLink = GetFixedLink(text, tonumber(breedQuality));
  222. HandleModifiedItemClick(fixedLink);
  223. else
  224. FloatingBattlePet_Toggle(tonumber(speciesID), tonumber(level), tonumber(breedQuality), tonumber(maxHealth), tonumber(power), tonumber(speed), string.gsub(string.gsub(text, "^(.*)%[", ""), "%](.*)$", ""), battlePetID);
  225. end
  226. return;
  227. elseif ( strsub(link, 1, 19) == "garrfollowerability" ) then
  228. local _, garrFollowerAbilityID = strsplit(":", link);
  229. if ( IsModifiedClick() ) then
  230. local fixedLink = GetFixedLink(text);
  231. HandleModifiedItemClick(fixedLink);
  232. else
  233. FloatingGarrisonFollowerAbility_Toggle(tonumber(garrFollowerAbilityID));
  234. end
  235. return;
  236. elseif ( strsub(link, 1, 12) == "garrfollower" ) then
  237. local _, garrisonFollowerID, quality, level, itemLevel, ability1, ability2, ability3, ability4, trait1, trait2, trait3, trait4, spec1 = strsplit(":", link);
  238. if ( IsModifiedClick() ) then
  239. local fixedLink = GetFixedLink(text, tonumber(quality));
  240. HandleModifiedItemClick(fixedLink);
  241. else
  242. FloatingGarrisonFollower_Toggle(tonumber(garrisonFollowerID), tonumber(quality), tonumber(level), tonumber(itemLevel), tonumber(spec1), tonumber(ability1), tonumber(ability2), tonumber(ability3), tonumber(ability4), tonumber(trait1), tonumber(trait2), tonumber(trait3), tonumber(trait4));
  243. end
  244. return;
  245. elseif ( strsub(link, 1, 11) == "garrmission" ) then
  246. local _, garrMissionID = strsplit(":", link);
  247. local garrMissionID, garrMissionDBID = link:match("garrmission:(%d+):([0-9a-fA-F]+)")
  248. if (garrMissionID and garrMissionDBID and strlen(garrMissionDBID) == 16) then
  249. if ( IsModifiedClick() ) then
  250. local fixedLink = GetFixedLink(text);
  251. HandleModifiedItemClick(fixedLink);
  252. else
  253. FloatingGarrisonMission_Toggle(tonumber(garrMissionID), "0x"..(garrMissionDBID:upper()));
  254. end
  255. end
  256. return;
  257. elseif ( strsub(link, 1, 5) == "death" ) then
  258. local _, id = strsplit(":", link);
  259. OpenDeathRecapUI(id);
  260. return;
  261. elseif ( strsub(link, 1, 7) == "sharess" ) then
  262. local _, index = strsplit(":", link);
  263. SocialFrame_LoadUI();
  264. Social_ShowScreenshot(tonumber(index));
  265. return;
  266. elseif ( strsub(link, 1, 12) == "shareachieve" ) then
  267. local _, achievementID, earned = strsplit(":", link);
  268. SocialFrame_LoadUI();
  269. Social_ShowAchievement(tonumber(achievementID), StringToBoolean(earned));
  270. return;
  271. elseif ( strsub(link, 1, 9) == "shareitem" ) then
  272. local strippedItemLink, earned = link:match("^shareitem:(.-):(%d+)$");
  273. local itemLink = FormatLink("item", nil, strippedItemLink);
  274. SocialFrame_LoadUI();
  275. Social_ShowItem(itemLink, earned);
  276. return;
  277. elseif ( strsub(link, 1, 16) == "transmogillusion" ) then
  278. local fixedLink = GetFixedLink(text);
  279. if ( not HandleModifiedItemClick(fixedLink) ) then
  280. DressUpTransmogLink(link);
  281. end
  282. return;
  283. elseif ( strsub(link, 1, 18) == "transmogappearance" ) then
  284. if ( IsModifiedClick("CHATLINK") ) then
  285. local _, sourceID = strsplit(":", link);
  286. local itemLink = select(6, C_TransmogCollection.GetAppearanceSourceInfo(sourceID));
  287. HandleModifiedItemClick(itemLink);
  288. else
  289. if ( not CollectionsJournal ) then
  290. CollectionsJournal_LoadUI();
  291. end
  292. if ( CollectionsJournal ) then
  293. WardrobeCollectionFrame_OpenTransmogLink(link);
  294. end
  295. end
  296. return;
  297. elseif ( strsub(link, 1, 11) == "transmogset" ) then
  298. if ( not CollectionsJournal ) then
  299. CollectionsJournal_LoadUI();
  300. end
  301. if ( CollectionsJournal ) then
  302. WardrobeCollectionFrame_OpenTransmogLink(link);
  303. end
  304. return;
  305. elseif ( strsub(link, 1, 3) == "api" ) then
  306. APIDocumentation_LoadUI();
  307. local command = APIDocumentation.Commands.Default;
  308. if button == "RightButton" then
  309. command = APIDocumentation.Commands.CopyAPI;
  310. elseif IsModifiedClick("CHATLINK") then
  311. command = APIDocumentation.Commands.OpenDump;
  312. end
  313. APIDocumentation:HandleAPILink(link, command);
  314. return;
  315. elseif ( strsub(link, 1, 13) == "storecategory" ) then
  316. local _, category = strsplit(":", link);
  317. if category == "token" then
  318. StoreFrame_SetTokenCategory();
  319. ToggleStoreUI();
  320. elseif category == "games" then
  321. StoreFrame_OpenGamesCategory();
  322. elseif category == "services" then
  323. StoreFrame_SetServicesCategory();
  324. ToggleStoreUI();
  325. end
  326. elseif ( strsub(link, 1, 4) == "item" ) then
  327. if ( IsModifiedClick("CHATLINK") and button == "LeftButton" ) then
  328. local name, link = GetItemInfo(text);
  329. if ChatEdit_InsertLink(link) then
  330. return;
  331. end
  332. end
  333. elseif ( strsub(link, 1, 10) == "clubTicket" ) then
  334. if ( IsModifiedClick("CHATLINK") and button == "LeftButton" ) then
  335. if ChatEdit_InsertLink(text) then
  336. return;
  337. end
  338. end
  339. local _, ticketId = strsplit(":", link);
  340. if ( CommunitiesFrame_IsEnabled() ) then
  341. Communities_LoadUI();
  342. CommunitiesHyperlink.OnClickLink(ticketId);
  343. end
  344. return;
  345. elseif ( strsub(link, 1, 13) == "calendarEvent" ) then
  346. local _, monthOffset, monthDay, index = strsplit(":", link);
  347. local dayEvent = C_Calendar.GetDayEvent(monthOffset, monthDay, index);
  348. if dayEvent then
  349. Calendar_LoadUI();
  350. if not CalendarFrame:IsShown() then
  351. Calendar_Toggle();
  352. end
  353. C_Calendar.OpenEvent(monthOffset, monthDay, index);
  354. end
  355. return;
  356. elseif ( strsub(link, 1, 9) == "community" ) then
  357. if ( CommunitiesFrame_IsEnabled() ) then
  358. local _, clubId = strsplit(":", link);
  359. clubId = tonumber(clubId);
  360. Communities_LoadUI();
  361. CommunitiesHyperlink.OnClickReference(clubId);
  362. end
  363. return;
  364. elseif ( strsub(link, 1, 9) == "azessence" ) then
  365. if ChatEdit_InsertLink(link) then
  366. return;
  367. end
  368. end
  369. if ( IsModifiedClick() ) then
  370. local fixedLink = GetFixedLink(text);
  371. HandleModifiedItemClick(fixedLink);
  372. else
  373. local itemName, itemLink = ItemRefTooltip:GetItem();
  374. if itemLink == GetFixedLink(text) then
  375. HideUIPanel(ItemRefTooltip);
  376. else
  377. ShowUIPanel(ItemRefTooltip);
  378. if ( not ItemRefTooltip:IsShown() ) then
  379. ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE");
  380. end
  381. ItemRefTooltip:SetHyperlink(link);
  382. end
  383. end
  384. end
  385. function GetFixedLink(text, quality)
  386. local startLink = strfind(text, "|H");
  387. if ( not strfind(text, "|c") ) then
  388. if ( quality ) then
  389. return (gsub(text, "(|H.+|h.+|h)", ITEM_QUALITY_COLORS[quality].hex.."%1|r", 1));
  390. elseif ( strsub(text, startLink + 2, startLink + 6) == "quest" ) then
  391. --We'll always color it yellow. We really need to fix this for Cata. (It will appear the correct color in the chat log)
  392. return (gsub(text, "(|H.+|h.+|h)", "|cffffff00%1|r", 1));
  393. elseif ( strsub(text, startLink + 2, startLink + 12) == "achievement" ) then
  394. return (gsub(text, "(|H.+|h.+|h)", "|cffffff00%1|r", 1));
  395. elseif ( strsub(text, startLink + 2, startLink + 7) == "talent" ) then
  396. return (gsub(text, "(|H.+|h.+|h)", "|cff4e96f7%1|r", 1));
  397. elseif ( strsub(text, startLink + 2, startLink + 6) == "trade" ) then
  398. return (gsub(text, "(|H.+|h.+|h)", "|cffffd000%1|r", 1));
  399. elseif ( strsub(text, startLink + 2, startLink + 8) == "enchant" ) then
  400. return (gsub(text, "(|H.+|h.+|h)", "|cffffd000%1|r", 1));
  401. elseif ( strsub(text, startLink + 2, startLink + 13) == "instancelock" ) then
  402. return (gsub(text, "(|H.+|h.+|h)", "|cffff8000%1|r", 1));
  403. elseif ( strsub(text, startLink + 2, startLink + 8) == "journal" ) then
  404. return (gsub(text, "(|H.+|h.+|h)", "|cff66bbff%1|r", 1));
  405. elseif ( strsub(text, startLink + 2, startLink + 14) == "battlePetAbil" ) then
  406. return (gsub(text, "(|H.+|h.+|h)", "|cff4e96f7%1|r", 1));
  407. elseif ( strsub(text, startLink + 2, startLink + 10) == "battlepet" ) then
  408. return (gsub(text, "(|H.+|h.+|h)", "|cffffd200%1|r", 1)); -- s_defaultColorString (yellow)
  409. elseif ( strsub(text, startLink + 2, startLink + 12) == "garrmission" ) then
  410. return (gsub(text, "(|H.+|h.+|h)", "|cffffff00%1|r", 1));
  411. elseif ( strsub(text, startLink + 2, startLink + 17) == "transmogillusion" ) then
  412. return (gsub(text, "(|H.+|h.+|h)", "|cffff80ff%1|r", 1));
  413. elseif ( strsub(text, startLink + 2, startLink + 19) == "transmogappearance" ) then
  414. return (gsub(text, "(|H.+|h.+|h)", "|cffff80ff%1|r", 1));
  415. elseif ( strsub(text, startLink + 2, startLink + 12) == "transmogset" ) then
  416. return (gsub(text, "(|H.+|h.+|h)", "|cffff80ff%1|r", 1));
  417. end
  418. end
  419. --Nothing to change.
  420. return text;
  421. end
  422. function GetBattlePetAbilityHyperlink(abilityID, maxHealth, power, speed)
  423. local id, name = C_PetBattles.GetAbilityInfoByID(abilityID);
  424. if not name then
  425. GMError("Attempt to link ability when we don't have record.");
  426. return "";
  427. end
  428. return ("|cff4e96f7%s|r"):format(FormatLink("battlePetAbil", name, abilityID, maxHealth or 100, power or 0, speed or 0));
  429. end
  430. function GetPlayerLink(characterName, linkDisplayText, lineID, chatType, chatTarget)
  431. -- Use simplified link if possible
  432. if lineID or chatType or chatTarget then
  433. return FormatLink("player", linkDisplayText, characterName, lineID or 0, chatType or 0, chatTarget or "");
  434. else
  435. return FormatLink("player", linkDisplayText, characterName);
  436. end
  437. end
  438. function GetBNPlayerLink(name, linkDisplayText, bnetIDAccount, lineID, chatType, chatTarget)
  439. return FormatLink("BNplayer", linkDisplayText, name, bnetIDAccount, lineID or 0, chatType, chatTarget);
  440. end
  441. function GetGMLink(gmName, linkDisplayText, lineID)
  442. if lineID then
  443. return FormatLink("playerGM", linkDisplayText, gmName, lineID or 0);
  444. else
  445. return FormatLink("playerGM", linkDisplayText, gmName);
  446. end
  447. end
  448. local function SanitizeCommunityData(clubId, streamId, epoch, position)
  449. if type(clubId) == "number" then
  450. clubId = ("%.f"):format(clubId);
  451. end
  452. if type(streamId) == "number" then
  453. streamId = ("%.f"):format(streamId);
  454. end
  455. epoch = ("%.f"):format(epoch);
  456. position = ("%.f"):format(position);
  457. return clubId, streamId, epoch, position;
  458. end
  459. function GetBNPlayerCommunityLink(playerName, linkDisplayText, bnetIDAccount, clubId, streamId, epoch, position)
  460. clubId, streamId, epoch, position = SanitizeCommunityData(clubId, streamId, epoch, position);
  461. return FormatLink("BNplayerCommunity", linkDisplayText, playerName, bnetIDAccount, clubId, streamId, epoch, position);
  462. end
  463. function GetPlayerCommunityLink(playerName, linkDisplayText, clubId, streamId, epoch, position)
  464. clubId, streamId, epoch, position = SanitizeCommunityData(clubId, streamId, epoch, position);
  465. return FormatLink("playerCommunity", linkDisplayText, playerName, clubId, streamId, epoch, position);
  466. end
  467. function GetClubTicketLink(ticketId, clubName, clubType)
  468. local link = FormatLink("clubTicket", CLUB_INVITE_HYPERLINK_TEXT:format(clubName), ticketId);
  469. if clubType == Enum.ClubType.BattleNet then
  470. return BATTLENET_FONT_COLOR:WrapTextInColorCode(link);
  471. else
  472. return NORMAL_FONT_COLOR:WrapTextInColorCode(link);
  473. end
  474. end
  475. function GetCalendarEventLink(monthOffset, monthDay, index)
  476. local dayEvent = C_Calendar.GetDayEvent(monthOffset, monthDay, index);
  477. if dayEvent then
  478. return FormatLink("calendarEvent", dayEvent.title, monthOffset, monthDay, index);
  479. end
  480. return nil;
  481. end
  482. function GetCommunityLink(clubId)
  483. local clubInfo = C_Club.GetClubInfo(clubId);
  484. if clubInfo then
  485. local link = FormatLink("community", COMMUNITY_REFERENCE_FORMAT:format(clubInfo.name), clubId);
  486. if clubInfo.clubType == Enum.ClubType.BattleNet then
  487. return BATTLENET_FONT_COLOR:WrapTextInColorCode(link);
  488. else
  489. return NORMAL_FONT_COLOR:WrapTextInColorCode(link);
  490. end
  491. end
  492. return nil;
  493. end
  494. function SplitLink(link)
  495. return link:match("^|H(.+)|h(.*)|h$");
  496. end