1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
| function() {
var e = window.jQuery;
Discourse.ClickTrack = {
trackClick: function(t) {
if ("" !== Discourse.Utilities.selectedText()) return !1;
var s = e(t.currentTarget);
if (s.hasClass("lightbox")) return !0;
var a = s.attr("href") || s.data("href"),
n = s.closest("article"),
r = n.data("post-id"),
o = e("#topic").data("topic-id"),
i = s.data("user-id");
if (a && 0 !== a.trim().length) {
i || (i = n.data("user-id"));
var u = i && i === Discourse.User.currentProp("id"),
c = Discourse.getURL("/clicks/track?url=" + encodeURIComponent(a));
if (r && !s.data("ignore-post-id") && (c += "&post_id=" + encodeURI(r)), o && (c += "&topic_id=" + encodeURI(o)), !u) {
var l = e("span.badge", s);
if (1 === l.length && 0 === s.closest(".badge-category").length && (0 === s.closest(".onebox-result").length && 0 === s.closest(".onebox-body").length || s.hasClass("track-link"))) {
var h = l.html();
/^\d+$/.test(h) && l.html(parseInt(h, 10) + 1)
}
}
if (3 === t.which) {
var p = Discourse.SiteSettings.track_external_right_clicks ? c : a;
return s.attr("href", p), !0
}
if (t.shiftKey || t.metaKey || t.ctrlKey || 2 === t.which) return Discourse.ajax("/clicks/track", {
data: {
url: a,
post_id: r,
topic_id: o,
redirect: !1
},
dataType: "html"
}), !0;
if (t.preventDefault(), s.hasClass("back") || s.hasClass("quote-other-topic")) return !0;
if (s.data("href") || (s.addClass("no-href"), s.data("href", s.attr("href")), s.attr("href", null), s.data("auto-route", !0)), Discourse.SiteSettings.prevent_anons_from_downloading_files && s.hasClass("attachment") && !Discourse.User.current()) return bootbox.alert(I18n.t("post.errors.attachment_download_requires_login")), !1;
if (Discourse.URL.isInternal(a) && !s.hasClass("attachment")) return Discourse.ajax("/clicks/track", {
data: {
url: a,
post_id: r,
topic_id: o,
redirect: !1
},
dataType: "html"
}), Discourse.URL.routeTo(a), !1;
if (Discourse.User.currentProp("external_links_in_new_tab")) {
var f = window.open(c, "_blank");
f.focus(), setTimeout(function() {
s.removeClass("no-href"), s.attr("href", s.data("href")), s.data("href", null)
}, 50)
} else Discourse.URL.redirectTo(c);
return !1
}
}
}
}(this),
|