|
@@ -1,11 +1,22 @@
|
1
|
1
|
var d3 = require("d3"),
|
2
|
2
|
$ = require("jquery"),
|
3
|
|
- themes = require("../settings/themes.json"),
|
4
|
3
|
preview = require("./preview.js"),
|
5
|
4
|
video = require("./video.js"),
|
6
|
5
|
audio = require("./audio.js");
|
7
|
6
|
|
8
|
|
-preloadImages();
|
|
7
|
+d3.json("/settings/themes.json", function(err, themes){
|
|
8
|
+
|
|
9
|
+ if (err) {
|
|
10
|
+ throw err;
|
|
11
|
+ }
|
|
12
|
+
|
|
13
|
+ for (var key in themes) {
|
|
14
|
+ themes[key] = $.extend({}, themes.default, themes[key]);
|
|
15
|
+ }
|
|
16
|
+
|
|
17
|
+ preloadImages(themes);
|
|
18
|
+
|
|
19
|
+});
|
9
|
20
|
|
10
|
21
|
function submitted() {
|
11
|
22
|
|
|
@@ -192,11 +203,11 @@ function updateCaption() {
|
192
|
203
|
}
|
193
|
204
|
|
194
|
205
|
function updateTheme() {
|
195
|
|
- var extended = $.extend({}, themes.default, d3.select(this.options[this.selectedIndex]).datum());
|
|
206
|
+ var extended = d3.select(this.options[this.selectedIndex]).datum();
|
196
|
207
|
preview.theme(extended);
|
197
|
208
|
}
|
198
|
209
|
|
199
|
|
-function preloadImages() {
|
|
210
|
+function preloadImages(themes) {
|
200
|
211
|
|
201
|
212
|
|
202
|
213
|
var imageQueue = d3.queue();
|
|
@@ -215,22 +226,22 @@ function preloadImages() {
|
215
|
226
|
|
216
|
227
|
imageQueue.awaitAll(initialize);
|
217
|
228
|
|
218
|
|
- function getImage(theme,cb) {
|
|
229
|
+ function getImage(theme, cb) {
|
219
|
230
|
|
220
|
231
|
if (!theme.backgroundImage) {
|
221
|
|
- return cb(null,theme);
|
|
232
|
+ return cb(null, theme);
|
222
|
233
|
}
|
223
|
234
|
|
224
|
235
|
theme.backgroundImageFile = new Image();
|
225
|
236
|
theme.backgroundImageFile.onload = function(){
|
226
|
|
- return cb(null,theme);
|
|
237
|
+ return cb(null, theme);
|
227
|
238
|
};
|
228
|
239
|
theme.backgroundImageFile.onerror = function(e){
|
229
|
240
|
console.warn(e);
|
230
|
|
- return cb(null,theme);
|
|
241
|
+ return cb(null, theme);
|
231
|
242
|
};
|
232
|
243
|
|
233
|
|
- theme.backgroundImageFile.src = "img/" + theme.backgroundImage;
|
|
244
|
+ theme.backgroundImageFile.src = "/settings/backgrounds/" + theme.backgroundImage;
|
234
|
245
|
|
235
|
246
|
}
|
236
|
247
|
|