-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
50 lines (43 loc) · 1.68 KB
/
background.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
$(function() {
console.log( 'Starting local bootstrap.' );
//Chrome specific storage for User data. Get()
chrome.storage.local.get('engine_api_url', function(items) {
// If there's nothing in there, default to the default production version.
API_URL = items.engine_api_url || "https://apps.engine.co";
// If there's no protocol specified, use https by default.
if( API_URL.indexOf( "http" ) < 0 )
API_URL = "https://" + API_URL;
// Make a get() request to our API_URL to serve our extension.
$.get( API_URL + '/GMail-Chrome/Injects.json', null,
function( injects, textStatus, jqXHR ) {
// Check to see if injects actually has any background stuff to load.
if(injects.hasOwnProperty( 'background') ) {
// Use async instead of forEach because we want to be certain
// the order of the js files loaded as well as download the files
// without blocking the connection.
async.forEachSeries( injects.background,
function( file, done) {
// Make another get() request to the server to serve up original .css files.
$.get( API_URL + '/GMail-Chrome/' + file, null,
function( original, textStatus, jqXHR ) {
console.log(API_URL + '/GMail-Chrome/' + file);
console.log("loaded successfully");
done();
}
).fail( function() {
console.log( 'Could not load js from ' + API_URL + '/GMail-Chrome/' + file);
done();
});
},
function( error ) {
// Report errors if any
if(error)
console.log(error);
}
);
}
}).fail( function() {
alert( 'Could not load Inject list from ' + API_URL + '/GMail-Chrome/Injects.json');
});
});
});