|
@@ -4,7 +4,8 @@ var d3 = require("d3"),
|
4
|
4
|
minimap = require("./minimap.js"),
|
5
|
5
|
sampleWave = require("./sample-wave.js"),
|
6
|
6
|
getRenderer = require("../renderer/"),
|
7
|
|
- getWaveform = require("./waveform.js");
|
|
7
|
+ getWaveform = require("./waveform.js"),
|
|
8
|
+ $ = require("jquery");
|
8
|
9
|
|
9
|
10
|
var context = d3.select("canvas").node().getContext("2d");
|
10
|
11
|
|
|
@@ -15,6 +16,8 @@ var theme,
|
15
|
16
|
newTheme,
|
16
|
17
|
newCaption,
|
17
|
18
|
subtitle;
|
|
19
|
+ // captionColorPicker,
|
|
20
|
+ // subtitleColorPicker;
|
18
|
21
|
|
19
|
22
|
function _file(_) {
|
20
|
23
|
return arguments.length ? (file = _) : file;
|
|
@@ -113,10 +116,145 @@ function redraw() {
|
113
|
116
|
fontName = fontName.substring(1, fontName.length-1);
|
114
|
117
|
d3.select("#input-font").property("value", fontName);
|
115
|
118
|
}
|
|
119
|
+
|
|
120
|
+ const captionColor = (theme.captionColor === undefined) ? "#000" : theme.captionColor;
|
|
121
|
+ const subtitleColor = (theme.subtitleColor === undefined) ? "#000" : theme.subtitleColor;
|
|
122
|
+
|
|
123
|
+ var container = document.querySelector(".captionColorPicker");
|
|
124
|
+
|
|
125
|
+ if (container.hasChildNodes()) {
|
|
126
|
+ while (container.firstChild) {
|
|
127
|
+ container.removeChild(container.firstChild);
|
|
128
|
+ }
|
|
129
|
+ }
|
|
130
|
+ var newElement = document.createElement('div');
|
|
131
|
+ container.appendChild(newElement);
|
|
132
|
+
|
|
133
|
+ var captionColorPicker = new Pickr({
|
|
134
|
+ el: newElement,
|
|
135
|
+ default: captionColor ? captionColor : '#fff',
|
|
136
|
+ theme: 'nano',
|
|
137
|
+ lockOpacity: true,
|
|
138
|
+
|
|
139
|
+ swatches: [
|
|
140
|
+ 'rgba(244, 67, 54, 1)',
|
|
141
|
+ 'rgba(233, 30, 99, 0.95)',
|
|
142
|
+ 'rgba(156, 39, 176, 0.9)',
|
|
143
|
+ 'rgba(103, 58, 183, 0.85)',
|
|
144
|
+ 'rgba(63, 81, 181, 0.8)',
|
|
145
|
+ 'rgba(33, 150, 243, 0.75)',
|
|
146
|
+ 'rgba(3, 169, 244, 0.7)',
|
|
147
|
+ 'rgba(0, 188, 212, 0.7)',
|
|
148
|
+ 'rgba(0, 150, 136, 0.75)',
|
|
149
|
+ 'rgba(76, 175, 80, 0.8)',
|
|
150
|
+ 'rgba(139, 195, 74, 0.85)',
|
|
151
|
+ 'rgba(205, 220, 57, 0.9)',
|
|
152
|
+ 'rgba(255, 235, 59, 0.95)',
|
|
153
|
+ 'rgba(255, 193, 7, 1)'
|
|
154
|
+ ],
|
|
155
|
+
|
|
156
|
+ components: {
|
|
157
|
+ preview: true,
|
|
158
|
+ opacity: true,
|
|
159
|
+ hue: true,
|
|
160
|
+
|
|
161
|
+ interaction: {
|
|
162
|
+ hex: true,
|
|
163
|
+ rgba: true,
|
|
164
|
+ hsva: true,
|
|
165
|
+ input: true,
|
|
166
|
+ clear: true,
|
|
167
|
+ save: true
|
|
168
|
+ }
|
|
169
|
+ }
|
|
170
|
+ });
|
|
171
|
+
|
|
172
|
+ captionColorPicker.on('save', (color, instance) => {
|
|
173
|
+ if (theme.captionColor) {
|
|
174
|
+ theme.captionColor = color.toHEXA().toString();
|
|
175
|
+ } else {
|
|
176
|
+ theme['captionColor'] = color.toHEXA().toString();
|
|
177
|
+ }
|
|
178
|
+ saveTheme();
|
|
179
|
+ });
|
|
180
|
+
|
|
181
|
+ container = document.querySelector(".subtitleColorPicker");
|
|
182
|
+
|
|
183
|
+ if (container.hasChildNodes()) {
|
|
184
|
+ while (container.firstChild) {
|
|
185
|
+ container.removeChild(container.firstChild);
|
|
186
|
+ }
|
|
187
|
+ }
|
|
188
|
+ newElement = document.createElement('div');
|
|
189
|
+ container.appendChild(newElement);
|
|
190
|
+
|
|
191
|
+ var subtitleColorPicker = new Pickr({
|
|
192
|
+ el: newElement,
|
|
193
|
+ default: subtitleColor ? subtitleColor : '#fff',
|
|
194
|
+ theme: 'nano',
|
|
195
|
+ lockOpacity: true,
|
|
196
|
+
|
|
197
|
+ swatches: [
|
|
198
|
+ 'rgba(244, 67, 54, 1)',
|
|
199
|
+ 'rgba(233, 30, 99, 0.95)',
|
|
200
|
+ 'rgba(156, 39, 176, 0.9)',
|
|
201
|
+ 'rgba(103, 58, 183, 0.85)',
|
|
202
|
+ 'rgba(63, 81, 181, 0.8)',
|
|
203
|
+ 'rgba(33, 150, 243, 0.75)',
|
|
204
|
+ 'rgba(3, 169, 244, 0.7)',
|
|
205
|
+ 'rgba(0, 188, 212, 0.7)',
|
|
206
|
+ 'rgba(0, 150, 136, 0.75)',
|
|
207
|
+ 'rgba(76, 175, 80, 0.8)',
|
|
208
|
+ 'rgba(139, 195, 74, 0.85)',
|
|
209
|
+ 'rgba(205, 220, 57, 0.9)',
|
|
210
|
+ 'rgba(255, 235, 59, 0.95)',
|
|
211
|
+ 'rgba(255, 193, 7, 1)'
|
|
212
|
+ ],
|
|
213
|
+
|
|
214
|
+ components: {
|
|
215
|
+ preview: true,
|
|
216
|
+ opacity: true,
|
|
217
|
+ hue: true,
|
|
218
|
+
|
|
219
|
+ interaction: {
|
|
220
|
+ hex: true,
|
|
221
|
+ rgba: true,
|
|
222
|
+ hsva: true,
|
|
223
|
+ input: true,
|
|
224
|
+ clear: true,
|
|
225
|
+ save: true
|
|
226
|
+ }
|
|
227
|
+ }
|
|
228
|
+ });
|
|
229
|
+
|
|
230
|
+ subtitleColorPicker.on('save', (color, instance) => {
|
|
231
|
+ if (theme.captionColor) {
|
|
232
|
+ theme.subtitleColor = color.toHEXA().toString();
|
|
233
|
+ } else {
|
|
234
|
+ theme['subtitleColor'] = color.toHEXA().toString();
|
|
235
|
+ }
|
|
236
|
+ saveTheme();
|
|
237
|
+ });
|
|
238
|
+
|
116
|
239
|
}
|
117
|
240
|
|
118
|
241
|
}
|
119
|
242
|
|
|
243
|
+function saveTheme() {
|
|
244
|
+ $.ajax({
|
|
245
|
+ url: "/theme/save",
|
|
246
|
+ type: "POST",
|
|
247
|
+ data: JSON.stringify({theme: theme}),
|
|
248
|
+ dataType: "json",
|
|
249
|
+ contentType: "application/json",
|
|
250
|
+ cache: false,
|
|
251
|
+ error: function (error) {
|
|
252
|
+ console.log('error', error);
|
|
253
|
+ }
|
|
254
|
+ });
|
|
255
|
+
|
|
256
|
+}
|
|
257
|
+
|
120
|
258
|
function loadAudio(f, cb) {
|
121
|
259
|
|
122
|
260
|
d3.queue()
|