-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
161 lines (140 loc) · 4.7 KB
/
index.html
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
151
152
153
154
155
156
157
158
159
160
161
<!doctype html>
<html>
<head>
<title>GifVid</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="https://www.youtube.com/iframe_api" type="text/javascript"></script>
</head>
<body>
<div id="controls">
<h1>GifVid</h1>
<form id="vidform">
<input type="text" placeholder="Background Tag" name="background" />
<input type="text" placeholder="Foreground Tag" name="foreground" />
<input type="text" placeholder="Youtube Link" name="music" />
<input type="text" placeholder="Scene Length (s)" name="timing" />
<button type="submit">Gif Vid!</button>
</form>
<span class="hide">↑</span>
</div>
<div id="player"></div>
<div class="active">
<div class="foreground"></div>
<div class="background"></div>
</div>
<div class="ondeck">
<div class="foreground"></div>
<div class="background"></div>
</div>
<script>
var Scenes = {};
var kutil = (function() {
// DOM class utilities from http://gomakethings.com/ditching-jquery-for-vanilla-js/
var hasClass = function (elem, className) {
return new RegExp(' ' + className + ' ').test(' ' + elem.className + ' ');
};
var addClass = function (elem, className) {
if (!hasClass(elem, className)) {
elem.className += ' ' + className;
}
};
var removeClass = function (elem, className) {
var newClass = ' ' + elem.className.replace( /[\t\r\n]/g, ' ') + ' ';
if (hasClass(elem, className)) {
while (newClass.indexOf(' ' + className + ' ') >= 0 ) {
newClass = newClass.replace(' ' + className + ' ', ' ');
}
elem.className = newClass.replace(/^\s+|\s+$/g, '');
}
};
var parseQS = function() {
var raw_params = window.location.search;
// trim fat
raw_params = raw_params.slice(-1) === "/" ? window.location.search.slice(1,-1) : window.location.search.substr(1);
if (!raw_params) {
return null
}
return raw_params.split('&').reduce(function(prev, param) {
var parts = param.replace(/\+/g, ' ').split('=');
prev[parts[0]] = parts[1] === undefined ? null : decodeURIComponent(parts[1]);
return prev;
}, {});
};
var param = function(obj) {
var res = '';
Object.keys(obj).forEach(function(key) {
res += encodeURIComponent(key) + "=" + encodeURIComponent(obj[key]) + "&";
});
return res.slice(0, -1);
};
var extend = function(){
for(var i=1; i<arguments.length; i++)
for(var key in arguments[i])
if(arguments[i].hasOwnProperty(key))
arguments[0][key] = arguments[i][key];
return arguments[0];
}
var splitMatrix = function(matrix) {
return matrix.split('(')[1].split(')')[0].split(',');
}
return {
hasClass: hasClass,
addClass: addClass,
removeClass: removeClass,
parseQS: parseQS,
param: param,
extend: extend,
splitMatrix: splitMatrix
}
})();
var kjax = (function() {
/*
* XMLHttpRequest with Promises
*/
/*
* Make get request
*
* @method get
*/
function get(url, params) {
var promise = new Promise(function(resolve, reject) {
var req = new XMLHttpRequest();
if (params) url += "?" + kutil.param(params);
req.open('GET', url);
req.onload = function() {
if (req.status >= 200 && req.status < 300) {
resolve(req.response);
} else {
reject(Error(req.statusText));
}
};
req.onerror = function() {
reject(Error("Network error"));
};
req.send();
});
return promise;
}
/*
* Make get request and parse json
*
* @method getJSON
*/
function getJSON(url, params) {
return get(url, params).then(JSON.parse);
}
return {
get: get,
getJSON: getJSON
}
})();
</script>
<script type="text/javascript" src="lib/promise-1.0.0.min.js"></script>
<script type="text/javascript" src="scenes/pan.js"></script>
<script type="text/javascript" src="scenes/giant.js"></script>
<script type="text/javascript" src="scenes/cube.js"></script>
<script type="text/javascript" src="scenes/spotlight.js"></script>
<script type="text/javascript" src="scenes/vortex.js"></script>
<script type="text/javascript" src="gifvid.js"></script>
</body>
</html>