-
Notifications
You must be signed in to change notification settings - Fork 0
/
decoder.js
36 lines (31 loc) · 817 Bytes
/
decoder.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
function decoder() {
var found = false;
// console.log( window.location );
//window.location.
var search = window.location.search;
if( '?' == search[0] ) {
var items = search.substr( 1 ).split( "&" );
for( var i = 0; i < items.length; i++ ) {
var tuple = items[i].split( "=" );
if( "comic" == tuple[0] ) {
try {
var json = atob( tuple[1] );
var scenes = JSON.parse( json );
console.log( "JSON", json );
var yume = new Yume();
yume.load( scenes );
yume.setup();
yume.bindProgressionButtons( "next", "back" );
found = true;
}
catch ( error ) {
console.log( "Error", error );
}
}
}
}
if( !found ) {
document.write( "<h1>Player needs a ?comic=base64encoded... in the URL</h1>" );
}
}
decoder();