-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscript.js
73 lines (65 loc) · 2.16 KB
/
script.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Generated by CoffeeScript 1.9.0
(function() {
var GitHubMentionHighlighter;
GitHubMentionHighlighter = (function() {
GitHubMentionHighlighter.prototype.userMentions = function() {
var $mention, mention, mentions, _i, _len, _ref;
mentions = [];
_ref = $(".user-mention, .member-mention");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
mention = _ref[_i];
$mention = $(mention);
if ($mention.text() === ("@" + this.username)) {
mentions.push($mention);
}
}
return mentions;
};
GitHubMentionHighlighter.prototype.teamMentions = function() {
var $mention, members, mention, mentions, _i, _len, _ref;
mentions = [];
members = [];
_ref = $(".team-mention");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
mention = _ref[_i];
$mention = $(mention);
if ($mention.attr("aria-label")) {
members = $mention.attr("aria-label").replace(" and ", " ").split(", ");
} else if ($mention.data("url")) {
$.ajax({
url: $mention.data("url"),
async: false,
dataType: 'json',
cache: true,
success: (function(_this) {
return function(data) {
return members = data["members"];
};
})(this)
});
}
if ($.inArray(this.username, members) !== -1) {
mentions.push($mention);
}
}
return mentions;
};
GitHubMentionHighlighter.prototype.mentions = function() {
return $.merge(this.userMentions(), this.teamMentions());
};
function GitHubMentionHighlighter() {
var $mention, _i, _len, _ref;
this.username = $(".supportocat a, #user-links .name").text().trim();
_ref = this.mentions();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
$mention = _ref[_i];
$mention.addClass("highlight");
$mention.parents(".timeline-comment, .timeline-entry").addClass("highlight");
}
}
return GitHubMentionHighlighter;
})();
$(function() {
return new GitHubMentionHighlighter();
});
}).call(this);