vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | LINKSNAG_MAX_LINK_LENGTH = 32; |
2 | LINKSNAG_LINK_COLOR = "00FF00"; |
||
3 | LINKSNAG_TIMESTAMP_ON = false; |
||
4 | |||
5 | |||
6 | function linkSnagExportFrame_OnLoad() |
||
7 | linkSnag_old_ChatFrame_OnEvent = ChatFrame_OnEvent; |
||
8 | ChatFrame_OnEvent = linkSnag_new_ChatFrame_OnEvent; |
||
9 | |||
10 | linkSnag_old_SetItemRef = SetItemRef; |
||
11 | SetItemRef = linkSnag_new_SetItemRef; |
||
12 | |||
13 | RegisterForSave("LINKSNAG_TIMESTAMP_ON"); |
||
14 | |||
15 | SlashCmdList["TIMESTAMP_ENABLE"] = linkSnag_timeStampEnable; |
||
16 | SLASH_TIMESTAMP_ENABLE1 = "/lstime"; |
||
17 | end |
||
18 | |||
19 | function linkSnag_timeStampEnable() |
||
20 | if(LINKSNAG_TIMESTAMP_ON == false) then |
||
21 | LINKSNAG_TIMESTAMP_ON = true; |
||
22 | DEFAULT_CHAT_FRAME:AddMessage("linkSnag timestamps are now ENABLED"); |
||
23 | else |
||
24 | LINKSNAG_TIMESTAMP_ON = false; |
||
25 | DEFAULT_CHAT_FRAME:AddMessage("linkSnag timestamps are now DISABLED"); |
||
26 | end |
||
27 | end |
||
28 | |||
29 | function linkSnag_new_ChatFrame_OnEvent(orig_event) |
||
30 | if(not this.Original_AddMessage) then |
||
31 | this.Original_AddMessage = this.AddMessage; |
||
32 | this.AddMessage = linkSnag_ChatTimestamp_AddMessage; |
||
33 | end |
||
34 | |||
35 | local msg = arg1; |
||
36 | |||
37 | if(string.sub(orig_event, 1, 8) == "CHAT_MSG" and msg ~= nil) then |
||
38 | msg = string.gsub(msg, "(%s?)(www%.[%w_/%.%?%%=~-]+)(%s?)", linkSnag_linkGen); -- www.whatever.com/dir/file.ext |
||
39 | msg = string.gsub(msg, "(%s?)(%a+://[%w_/%.%?%%=~-]+)(%s?)", linkSnag_linkGen); -- http://sub.domain.com/dir/file.ext |
||
40 | msg = string.gsub(msg, "(%s?)([_%w-%.~]+@[_%w-]+%.[_%w-%.]+)(%s?)", linkSnag_linkGen);-- 192.168.0.1:12345/dir/file.ext |
||
41 | msg = string.gsub(msg, "(%s?)(%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?[:%d%d?%d?%d?%d?]*[%w_/%.%?%%=~-]*)(%s?)", linkSnag_linkGen);--foo@bar.com |
||
42 | arg1 = msg; |
||
43 | end |
||
44 | |||
45 | linkSnag_old_ChatFrame_OnEvent(orig_event); |
||
46 | end |
||
47 | |||
48 | function linkSnag_new_SetItemRef(link, button) |
||
49 | if (string.sub(link, 1 , 3) == "ref") then |
||
50 | linkSnagURL:SetText(string.sub(link,5)); |
||
51 | linkSnagExportFrame:Show(); |
||
52 | linkSnagURL:HighlightText(); |
||
53 | return; |
||
54 | else |
||
55 | linkSnag_old_SetItemRef(link, button); |
||
56 | end |
||
57 | end |
||
58 | |||
59 | function linkSnag_ChatTimestamp_AddMessage(this, msg, r, g, b, id) |
||
60 | if(msg ~= nil) then |
||
61 | if(LINKSNAG_TIMESTAMP_ON == true) then |
||
62 | msg = linkSnag_timeLink() .. " " .. msg; |
||
63 | end |
||
64 | end |
||
65 | |||
66 | this:Original_AddMessage(msg, r, g, b, id); |
||
67 | return |
||
68 | end |
||
69 | |||
70 | function linkSnag_timeLink(chatMsg) |
||
71 | local hour=string.sub(date(), 10, 11); |
||
72 | local minute=string.sub(date(), 13, 14); |
||
73 | local second =string.sub(date(), 16, 17); |
||
74 | |||
75 | if tonumber(hour) >12 then |
||
76 | hour=hour-12; |
||
77 | else |
||
78 | hour=tonumber(hour) |
||
79 | if hour==0 then |
||
80 | hour=12; |
||
81 | end |
||
82 | end |
||
83 | return "[" .. hour .. ":" .. minute .. ":" .. second .. "]"; |
||
84 | end |
||
85 | |||
86 | function linkSnag_linkGen(begSpace, URL, aftSpace) |
||
87 | return begSpace .. "|cff" .. LINKSNAG_LINK_COLOR .. "|Href:" .. URL .. "|h[".. URL .."]|h|r" .. aftSpace; |
||
88 | end |
||
89 | |||
90 | function linkSnag_HideButton_onClick() |
||
91 | linkSnagExportFrame:Hide(); |
||
92 | end |