-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.js
executable file
·59 lines (44 loc) · 1.68 KB
/
image.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
// ----------------------------------------------------------------------------
// Assets Helper, a Javascript Assets Helper library
// Licensed under the MIT license.
// ----------------------------------------------------------------------------
// Copyright (C) Iftekher Sunny < [email protected] >
// ----------------------------------------------------------------------------
(function (_) {
/////////////////////////////////////////////////////////
//
// instance of global object
//
/////////////////////////////////////////////////////////
var root = this;
/////////////////////////////////////////////////////////
//
// instance of assets object
//
/////////////////////////////////////////////////////////
var Assets = root.Assets || {
name: "assets-helper",
version: "0.0.0"
};
/////////////////////////////////////////////////////////
//
// getting image url
//
/////////////////////////////////////////////////////////
Assets.image = function(path) {
var hostname = root.location.hostname,
port = root.location.port == 80 ? "" : ":" + root.location.port,
protocol = root.location.protocol,
protocols = ['http', 'https', '//'];
for(key in protocols) {
if (path.indexOf(protocols[key]) != -1) return path;
}
return protocol + "//" + hostname + port + "/" + path;
}
/////////////////////////////////////////////////////////
//
// assigning Assets object to the Global object
//
/////////////////////////////////////////////////////////
return root.Assets = Assets;
}())