Skip to content

Commit 32da13b

Browse files
committed
fix jshint and code clean up
1 parent 02939f5 commit 32da13b

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

js/directives/updateBackground.js

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
11
define(
22
[
3-
'jQuery',
4-
'underscore',
5-
'color-thief'
3+
'jQuery',
4+
'underscore',
5+
'color-thief'
66
],
77
function($, _, ColorThief) { 'use strict';
88

99
var myUpdateBackgroundFactory = function(appSettings, $http) {
10-
var thief = new ColorThief();
10+
var thief = new ColorThief();
1111

12-
var updateThumbnail = function(element, backgrounds){
12+
var updateThumbnail = function(element, backgrounds){
1313

14-
var color = null;
15-
try {
16-
color = thief.getColor(element.get(0));
17-
} catch(e) {}
14+
var color = null;
15+
try {
16+
color = thief.getColor(element.get(0));
17+
} catch(e) {}
1818

19-
backgrounds.push(color ? 'rgb(' + color.join(',') + ')' : 'white');
19+
backgrounds.push(color ? 'rgb(' + color.join(',') + ')' : 'white');
2020

21-
var thumbnail = $('.thumbnail-loading', element.parent().parent().parent());
22-
thumbnail
23-
.removeClass('thumbnail-loading')
24-
.addClass('thumbnail')
25-
.css('background', backgrounds.join(', '));
26-
};
21+
var thumbnail = $('.thumbnail-loading', element.parent().parent().parent());
22+
thumbnail
23+
.removeClass('thumbnail-loading')
24+
.addClass('thumbnail')
25+
.css('background', backgrounds.join(', '));
26+
};
2727

28-
return function(scope, element, attrs) {
29-
scope.$watch(attrs.dLoad, function(value) {
30-
element.on('load', function() {
28+
return function(scope, element, attrs) {
29+
scope.$watch(attrs.dLoad, function(value) {
30+
element.on('load', function() {
3131

32-
var backgrounds = [];
33-
if (appSettings.showThumbnails) {
32+
var backgrounds = [];
33+
if (appSettings.showThumbnails) {
3434

35-
$http({
36-
url: 'http://api.page2images.com/restfullink?p2i_url=' +
37-
encodeURIComponent(scope.bookmark.url) +
38-
'&p2i_device=6&p2i_screen=1024x768&p2i_imageformat=jpg&p2i_wait=0&p2i_key=7cd903b37d087238',
39-
method: "POST",
40-
headers: {
41-
'Content-Type': 'application/json; charset=utf-8'
42-
}
43-
}).success(function(responseData) {
35+
$http({
36+
url: 'http://api.page2images.com/restfullink?p2i_url=' +
37+
encodeURIComponent(scope.bookmark.url) +
38+
'&p2i_device=6&p2i_screen=1024x768&p2i_imageformat=jpg&p2i_wait=0&p2i_key=7cd903b37d087238',
39+
method: "POST",
40+
headers: {
41+
'Content-Type': 'application/json; charset=utf-8'
42+
}
43+
}).success(function(responseData) {
4444

45-
if(!_.isUndefined(responseData.image_url)){
46-
backgrounds.push('url(' + responseData.image_url + ')');
45+
if(!_.isUndefined(responseData.image_url)){
46+
backgrounds.push('url(' + responseData.image_url + ')');
47+
}
48+
updateThumbnail(element, backgrounds);
49+
}).error(function(data, status, header, config) {
50+
updateThumbnail(element, backgrounds);
51+
});
52+
}
53+
else{
54+
updateThumbnail(element, backgrounds);
4755
}
48-
updateThumbnail(element, backgrounds);
49-
}).error(function(data, status, header, config) {
50-
updateThumbnail(element, backgrounds);
5156
});
52-
}
53-
else{
54-
updateThumbnail(element, backgrounds);
55-
}
56-
});
57-
});
58-
};
57+
});
58+
};
5959
};
6060

6161
return [
62-
'appSettings',
63-
'$http',
64-
myUpdateBackgroundFactory
62+
'appSettings',
63+
'$http',
64+
myUpdateBackgroundFactory
6565
];
6666

6767
});

0 commit comments

Comments
 (0)