-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmaterial-freebox-os.js
150 lines (134 loc) · 4.97 KB
/
material-freebox-os.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/**
* Material-Freebox-OS
* Shared scripts
*/
(function() {
window.MaterialFreeboxOS = {
/**
* Returns true if page title begins with Freebox OS
* @param pageTitle
* @returns {boolean}
*/
matches: function(pageTitle) {
return pageTitle.indexOf('Freebox OS') == 0;
},
getDepURI: function(relative) {
var prefix = relative.substring(0, 'http'.length);
return prefix == 'http' || prefix == 'file'
? relative
: chrome.extension.getURL(relative);
},
materialColors: {
colors: [
'#F44336', // red
'#E91E63', // pink
'#9C27B0', // purple
'#673AB7', // deep-purple
'#3F51B5', // indigo
'#2196F3', // blue
'#03A9F4', // light-blue
'#00BCD4', // cyan
'#009688', // teal
'#4CAF50', // green
'#8BC34A', // light-green
'#CDDC39', // lime
'#FFEB3B', // yellow
'#FFC107', // amber
'#FF9800', // orange
'#FF5722', // deep-orange
'#795548', // brown
'#9E9E9E', // grey
'#607D8B' // blue-grey
],
get defaultPrimary() {
return this.colors[5];
},
get defaultAccent() {
return this.colors[9];
}
},
/**
* Wallpaper-related methods
*/
wallpaper: {
findWallpaperInfos: function (uri) {
var wallpaper = null;
this.wallpapers.forEach(function (w) {
if (w.image == uri)
wallpaper = w;
});
return wallpaper;
},
wallpapers: [
{
name: 'Earth 064',
credits: 'Google Maps / DigitalGlobe',
image: 'data/img/wallpaper1.jpg'
},
{
name: 'Earth 152',
credits: 'Google Maps / Aerometrex',
image: 'data/img/wallpaper2.jpg'
},
{
name: 'Off The Road',
credits: 'Trey Ratcliff',
source: 'http://www.stuckincustoms.com/',
image: 'data/img/wallpaper3.jpg'
},
{
name: 'The Remarkables',
credits: 'Trey Ratcliff',
source: 'http://www.stuckincustoms.com/',
image: 'data/img/wallpaper4.jpg'
},
{
name: 'Blue Sky',
credits: 'Henry Lien',
source: 'https://plus.google.com/u/1/+HenryLien/about',
image: 'data/img/wallpaper5.jpg'
},
{
name: 'Golden Gate Afternoon',
credits: 'Romain Guy',
source: 'http://www.curious-creature.org/',
image: 'data/img/wallpaper6.jpg'
}
],
get defaultWallpaper() {
return this.wallpapers[0];
},
updateWallpaperCredits: function (element, wallpaperInfos) {
element.style.display = wallpaperInfos !== null ? 'block' : 'none';
if (wallpaperInfos === null)
return;
if (wallpaperInfos['source'] !== undefined) {
element.href = wallpaperInfos['source'];
element.target = '_blank';
} else {
element.removeAttribute('href');
element.removeAttribute('target');
}
// Equivalent for element.innerHTML = "Fond d'écran : <b>" + wallpaperInfos['name'] + "</b> par <b>" + wallpaperInfos['credits'] + "</b>";
// but Firefox validation process will complain about creating DOM nodes from HTML string
element.innerHTML = '';
element.appendChild(document.createTextNode("Fond d'écran : "));
element.appendChild(
document.createElement('b').appendChild(document.createTextNode(wallpaperInfos['name'])).parentNode
);
element.appendChild(document.createTextNode(" par "));
element.appendChild(
document.createElement('b').appendChild(document.createTextNode(wallpaperInfos['credits'])).parentNode
);
}
},
environment: {
isFirefox: function() {
return /firefox/i.test(navigator.userAgent);
},
getBrowserHandle: function() {
return this.isFirefox() ? browser : chrome;
}
}
};
})();