Skip to content

Commit a876dfc

Browse files
author
Zeno Rocha
committed
Removing unnecessary reference to the original this
1 parent c947cc0 commit a876dfc

File tree

1 file changed

+24
-31
lines changed

1 file changed

+24
-31
lines changed

src/jquery.github.js

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,81 +12,74 @@ function GithubRepo( repo ) {
1212

1313
// Parses HTML template
1414
GithubRepo.prototype.toHTML = function () {
15-
var self = this;
16-
17-
self.pushed_at = self._parsePushedDate( self.pushed_at ),
18-
self.url = self._parseURL( self.url );
15+
this.pushed_at = this._parsePushedDate( this.pushed_at ),
16+
this.url = this._parseURL( this.url );
1917

2018
return $(
2119
"<div class='github-box'>" +
2220
"<div class='github-box-header'>" +
2321
"<h3>" +
24-
"<a href='" + self.url + "'>" + self.name + "</a>" +
22+
"<a href='" + this.url + "'>" + this.name + "</a>" +
2523
"</h3>" +
2624
"<div class='github-stats'>" +
27-
"<a class='repo-stars' title='Stars' data-icon='7' href='" + self.url + "/watchers'>" + self.watchers + "</a>" +
28-
"<a class='repo-forks' title='Forks' data-icon='f' href='" + self.url + "/network'>" + self.forks + "</a>" +
29-
"<a class='repo-issues' title='Issues' data-icon='i' href='" + self.url + "/issues'>" + self.open_issues + "</a>" +
25+
"<a class='repo-stars' title='Stars' data-icon='7' href='" + this.url + "/watchers'>" + this.watchers + "</a>" +
26+
"<a class='repo-forks' title='Forks' data-icon='f' href='" + this.url + "/network'>" + this.forks + "</a>" +
27+
"<a class='repo-issues' title='Issues' data-icon='i' href='" + this.url + "/issues'>" + this.open_issues + "</a>" +
3028
"</div>" +
3129
"</div>" +
3230
"<div class='github-box-content'>" +
33-
"<p>" + self.description + " &mdash; <a href='" + self.url + "#readme'>Read More</a></p>" +
31+
"<p>" + this.description + " &mdash; <a href='" + this.url + "#readme'>Read More</a></p>" +
3432
"</div>" +
3533
"<div class='github-box-download'>" +
36-
"<p class='repo-update'>Latest commit to <strong>master</strong> on " + self.pushed_at + "</p>" +
37-
"<a class='repo-download' title='Download as zip' data-icon='w' href='" + self.url + "/zipball/master'></a>" +
34+
"<p class='repo-update'>Latest commit to <strong>master</strong> on " + this.pushed_at + "</p>" +
35+
"<a class='repo-download' title='Download as zip' data-icon='w' href='" + this.url + "/zipball/master'></a>" +
3836
"</div>" +
3937
"</div>");
4038
};
4139

4240
// Parses pushed_at with date format
4341
GithubRepo.prototype._parsePushedDate = function ( pushed_at ) {
44-
var self = this,
45-
date = new Date( pushed_at );
42+
var date = new Date( pushed_at );
4643

4744
return date.getDate() + "/" + ( date.getMonth() + 1 ) + "/" + date.getFullYear();
4845
};
4946

5047
// Parses URL to be friendly
5148
GithubRepo.prototype._parseURL = function ( url ) {
52-
var self = this;
53-
5449
return url.replace( "api.", "" ).replace( "repos/", "" );
5550
};
5651

5752
// -- Github Plugin ------------------------------------------------------------
5853

5954
function Github( element, options ) {
60-
var self = this,
61-
defaults = {
55+
var defaults = {
6256
iconStars: true,
6357
iconForks: true,
6458
iconIssues: false
6559
};
6660

67-
self.element = element;
68-
self.$container = $( element );
69-
self.repo = self.$container.attr( "data-repo" );
61+
this.element = element;
62+
this.$container = $( element );
63+
this.repo = this.$container.attr( "data-repo" );
7064

71-
self.options = $.extend( {}, defaults, options ) ;
65+
this.options = $.extend( {}, defaults, options ) ;
7266

73-
self._defaults = defaults;
67+
this._defaults = defaults;
7468

75-
self.init();
76-
self.displayIcons();
69+
this.init();
70+
this.displayIcons();
7771
}
7872

7973
// Initializer
8074
Github.prototype.init = function () {
81-
var self = this,
82-
cached = self.getCache();
75+
var cached = this.getCache();
8376

8477
if ( cached !== null ) {
85-
self.applyTemplate( JSON.parse( cached ) );
78+
this.applyTemplate( JSON.parse( cached ) );
8679
return;
8780
}
8881

89-
self.requestData( self.repo );
82+
this.requestData( this.repo );
9083
};
9184

9285
// Display or hide icons
@@ -103,7 +96,7 @@ Github.prototype.displayIcons = function () {
10396

10497
// Request repositories from Github
10598
Github.prototype.requestData = function ( repo ) {
106-
var self = this;
99+
var that = this;
107100

108101
$.ajax({
109102
url: "https://api.github.com/repos/" + repo,
@@ -113,11 +106,11 @@ Github.prototype.requestData = function ( repo ) {
113106
isFailling = results.meta.status >= 400 && result_data.message;
114107

115108
if ( isFailling ) {
116-
self.handleErrorRequest( result_data );
109+
that.handleErrorRequest( result_data );
117110
return;
118111
}
119112

120-
self.handleSuccessfulRequest( result_data );
113+
that.handleSuccessfulRequest( result_data );
121114
}
122115
});
123116
};

0 commit comments

Comments
 (0)