vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[ ---------------------------------------------------------------
2 Enchanter Ad Shrinker
3 ---------------------------------------------------------------
4  
5 @Author: Sacha Beharry
6 @DateCreated:
7 @LastUpdate:
8 @Release: BETA 2
9 @Version: 0.3.1800
10 @Note:
11 ]]
12  
13 EAS_RELEASEVERSION = "BETA 2";
14 EAS_NOTE = {
15 "Enchanter Ad Shrinker - Beta 2",
16 "Thank you for using EAS - Hope you find it useful :)",
17 "Sacha"
18 };
19  
20 --[[ ---------------------------------------------------------------
21  
22 Web:
23  
24 Filename: EnchanterAdShrinker.lua
25  
26 Project Name: Pandora
27  
28 Description: Main Program
29  
30 Purpose:
31 ]]
32  
33  
34 local lastName = nil;
35  
36 function EnchanterAdShrinker_OnLoad()
37 SlashCmdList["EnchanterAdShrinkerCOMMAND"] = EnchanterAdShrinker_SlashHandler;
38 SLASH_EnchanterAdShrinkerCOMMAND1 = "/enchanteradshrinker";
39 SLASH_EnchanterAdShrinkerCOMMAND2 = "/eas";
40  
41 this:RegisterEvent("CHAT_MSG_CHANNEL");
42  
43 --[[
44 local xhList = {};
45 xhList[ "enchantmsg" ] = { tag = "Long Enchant Message", trigger = enchTrigger, function = doEnchMsg, block = 1 };
46 ]]
47  
48 local old_SetItemRef = SetItemRef;
49 function SetItemRef(link, text, button)
50 for name, msg in string.gfind( link, "xhmsg:(%w+)<XH>(.+)" ) do
51  
52 if( ItemRefTooltip:IsVisible() and lastName and lastName == name ) then
53  
54 HideUIPanel(ItemRefTooltip);
55 --ItemRefTooltip:Hide();
56 lastName = nil;
57  
58 else
59 lastName = name;
60  
61 ShowUIPanel(ItemRefTooltip);
62 if ( not ItemRefTooltip:IsVisible() ) then
63 ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE");
64 end
65  
66 ItemRefTooltip:ClearLines();
67 --ItemRefTooltip:ClearAllPoints();
68  
69 if( name == "eas" and msg == "eas" ) then
70  
71 ItemRefTooltip:AddLine( EAS_NOTE[1], 1, 0.5, 0 );
72 ItemRefTooltip:AddLine( EAS_NOTE[2], 1, 1, 1, 1, 1 );
73 ItemRefTooltip:AddLine( EAS_NOTE[3] );
74  
75 else
76 ItemRefTooltip:AddLine( "Message", 0.5, 0.5, 1 );
77 ItemRefTooltip:AddLine( name );
78 ItemRefTooltip:AddLine( msg, 1, 1, 1, 1, 1 );
79 end
80 ItemRefTooltip:Show();
81  
82 --[[
83 ShowUIPanel(ItemRefTooltip);
84 if ( not ItemRefTooltip:IsVisible() ) then
85 ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE");
86 end
87 ]]
88 end
89  
90 return;
91 end
92  
93 lastName = nil;
94 old_SetItemRef(link, text, button);
95 end
96  
97  
98 local old_ChatFrame_OnEvent = ChatFrame_OnEvent;
99 function ChatFrame_OnEvent(event)
100 --if( string.find( event, "CHAT_MSG" ) and arg1 and arg2 and string.len(arg1) > 16 ) then
101 if( event == "CHAT_MSG_CHANNEL" and arg1 and arg2 and string.len(arg1) > 16 ) then
102 local argl = string.lower(arg1);
103 local start; --, _ = string.find( argl, "enchanting");
104 local score = 100;
105 if( not start ) then
106 score = Sacha_LightSearch( arg1, "bracer chest boots weapon armor fiery demon slaying beast crusader" );
107 if( score > 0 and ( string.find( argl, "chant") or string.find( argl, "ench") ) ) then
108 start = 1;
109 end
110 end
111  
112 if( start and Sacha_LightSearch( arg1, "trainer thorium item:" ) == 0 ) then
113 --[[
114 Thanks to Subatai-Garona for this fix posted in curse-gaming.com
115 --]]
116 if string.find( arg1, "|") then arg1 = string.gsub(arg1, "|", "/"); end;
117  
118 arg1 = "|cff8888ff|Hxhmsg:"..arg2.."<XH>"..arg1.."|h[Enchantments]|h|r";
119 if( string.find(argl, "wts") ) then
120 arg1 = "WTS "..arg1;
121 elseif( string.find(argl, "wtb") ) then
122 arg1 = "WTB "..arg1;
123 else
124 arg1 = "Regarding "..arg1;
125 end
126 end
127 end
128 old_ChatFrame_OnEvent(event);
129 end
130  
131 --ChatPrintln( "|cffff8800|Hxhmsg:eas<XH>eas|h[Enchanter Ad Shrinker]|h|r loaded." );
132  
133 end
134  
135 function EnchanterAdShrinker_SlashHandler( com )
136  
137 end
138  
139 function Sacha_LightSearch( source, search )
140 local ad = string.lower( source );
141 local query = string.lower( search );
142  
143 if( string.find( ad, query ) ) then
144 return 100;
145 else
146 local sourceWords = {};
147 for word in string.gfind( ad, "%w+" ) do
148 sourceWords[word] = 1;
149 end
150  
151 local highlighted = source;
152  
153 local score = 0;
154 local total = 0;
155 for word in string.gfind(query, "%w+") do
156 total = total + 1;
157 if( sourceWords[word] ) then
158 score = score + 1;
159 elseif( string.find( ad, word ) ) then
160 score = score + 0.9;
161 end
162 end
163  
164 if( score > 0 ) then
165 score = floor(99*score/total);
166 end
167  
168 return score;
169 end
170 end
171  
172 function ChatPrintln( string )
173 DEFAULT_CHAT_FRAME:AddMessage(string, 0.95, 0.95, 0.5);
174 end