From 14ead343a06977d040e16eda310b4ebbac1c09eb Mon Sep 17 00:00:00 2001 From: Sattva Date: Sat, 30 Dec 2023 01:40:04 +0300 Subject: [PATCH] Weblink #1 - add urlencode function mainly because ruRU gets hyeroglyphs link in output and it never searched right. also make it remove color tags correctly with new urlencode ouput. --- Changelog and Notes.txt | 2 ++ Leatrix_Plus.lua | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Changelog and Notes.txt b/Changelog and Notes.txt index a266de2..8e563c9 100644 --- a/Changelog and Notes.txt +++ b/Changelog and Notes.txt @@ -12,6 +12,8 @@ Tooltip - FIX center popup when closed the leatrix window, its still staying WebLink - Fix ruRU encoding!!! +WebLink - WASD should close the weblink window. + FlightTimers - fix report window editbox Manage Quest Tracker (under minimap) - let user move it. diff --git a/Leatrix_Plus.lua b/Leatrix_Plus.lua index f00790b..b300161 100644 --- a/Leatrix_Plus.lua +++ b/Leatrix_Plus.lua @@ -15958,6 +15958,17 @@ end return elseif str == "id" then + -------------------------------------------------------------------------------- + -- Define urlencode function for Lua 5.3 + -------------------------------------------------------------------------------- + + + local function urlencode(str) + return string.gsub(str, "([^%w%.%- ])", function(c) + return string.format("%%%02X", string.byte(c)) + end):gsub(" ", "+") + end + -- Show web link if not LeaPlusLC.WowheadLock then -- Set Wowhead link prefix @@ -16072,8 +16083,8 @@ local unitFocus if mouseFocus == WorldFrame then unitFocus = "mouseover" else unitFocus = select(2, GameTooltip:GetUnit()) end if not unitFocus or not UnitIsPlayer(unitFocus) then - tipTitle = tipTitle:gsub("|c%x%x%x%x%x%x%x%x", "") -- Remove color tag - LeaPlusLC:ShowSystemEditBox("https://" .. LeaPlusLC.WowheadLock .. "/search?q=" .. tipTitle, false) + tipTitle = tipTitle:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "") + LeaPlusLC:ShowSystemEditBox("https://" .. LeaPlusLC.WowheadLock .. "/search?q=" .. urlencode(tipTitle), false) LeaPlusLC.FactoryEditBox.f:SetText("|cffff0000" .. L["Link will search Wowhead"]) return end