-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
72 lines (62 loc) · 1.57 KB
/
app.js
File metadata and controls
72 lines (62 loc) · 1.57 KB
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
Colorhythm.onerror = function(e) {
$('.error-msg')
.show()
.html(e.message);
};
$('.screen').each(function(i, el) {
var canvas = $(el);
var scene = null;
$(window).keyup(function(e) {
if (e.keyCode == 27) {
canvas.removeAttr('id');
$('body').css('overflow', 'auto');
}
});
var fullscreen = $('<a class="button light">enter fullscreen</a>');
var onoff = $('<a class="button light">visualization off</a>');
canvas.parent().after(fullscreen);
fullscreen.after(onoff);
fullscreen.after(' ');
fullscreen.click(function() {
$('body').css('overflow', 'hidden');
canvas.attr('id', 'fullscreen');
});
function loadScene() {
var name = window.location.hash && window.location.hash.slice(1) || canvas.data('visualization');
$.getJSON(name, jsonLoaded)
.fail(function(err){
var reason = (err.status!=404)?': invalid file':': not found';
Colorhythm.error('', 'unable load visualization '+name+reason);
console.log(err);
});
}
function jsonLoaded(data) {
var promise = new Colorhythm.Scene(data);
promise.done(sceneCreated);
}
function sceneCreated(s) {
if (scene) {
scene.powerOff();
}
s.screen.canvas(el);
s.powerOn();
scene = s;
}
$(window).on('hashchange', function() {
loadScene();
});
loadScene();
// onoff.click(function() {
// if (scr._active) {
// scr.off();
// onoff.html('visualization on');
// onoff.toggleClass('light');
// onoff.toggleClass('dark');
// } else {
// scr.on();
// onoff.html('visualization off');
// onoff.toggleClass('light');
// onoff.toggleClass('dark');
// }
// });
});