-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.html
621 lines (518 loc) · 23 KB
/
create.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Blend — Free HTML5 Bootstrap Website Template by FreeHTML5.co</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Free HTML5 Website Template by FreeHTML5.co" />
<meta name="keywords" content="free html5, free template, free bootstrap, free website template, html5, css3, mobile first, responsive" />
<meta name="author" content="FreeHTML5.co" />
<!--
//////////////////////////////////////////////////////
FREE HTML5 TEMPLATE
DESIGNED & DEVELOPED by FreeHTML5.co
Website: http://freehtml5.co/
Email: [email protected]
Twitter: http://twitter.com/fh5co
Facebook: https://www.facebook.com/fh5co
//////////////////////////////////////////////////////
-->
<!-- Facebook and Twitter integration -->
<meta property="og:title" content="" />
<meta property="og:image" content="" />
<meta property="og:url" content="" />
<meta property="og:site_name" content="" />
<meta property="og:description" content="" />
<meta name="twitter:title" content="" />
<meta name="twitter:image" content="" />
<meta name="twitter:url" content="" />
<meta name="twitter:card" content="" />
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="shortcut icon" href="favicon.ico">
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,600,400italic,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<!-- Animate.css -->
<link rel="stylesheet" href="css/animate.css">
<!-- Icomoon Icon Fonts-->
<link rel="stylesheet" href="css/icomoon.css">
<!-- Bootstrap -->
<link rel="stylesheet" href="css/bootstrap.css">
<!-- Owl Carousel -->
<link rel="stylesheet" href="css/owl.carousel.min.css">
<link rel="stylesheet" href="css/owl.theme.default.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="css/style.css">
<!-- Modernizr JS -->
<script src="js/modernizr-2.6.2.min.js"></script>
<!-- FOR IE9 below -->
<!--[if lt IE 9]>
<script src="js/respond.min.js"></script>
<![endif]-->
<link href="css/bootstrap.fd.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div id="fh5co-page">
<a href="#" class="js-fh5co-nav-toggle fh5co-nav-toggle"><i></i></a>
<aside id="fh5co-aside" role="complementary" class="border js-fullheight" style="width:300px" >
<h1 id="fh5co-logo"><a href="index.html"><img src="images/am.png" alt="Free HTML5 Bootstrap Website Template" width="120" height="140"></a></h1>
<nav id="fh5co-main-menu" role="navigation">
<ul>
<li><a href="index.html">Home</a></li>
<li class="fh5co-active"><a href="create.html">Create</a></li>
<li><a href="about.html">About</a></li>
<li><a id="uploadImage">Upload an image</a></li>
<li><a id="uploadSong">Upload a song</a></li>
</ul>
<div id="signIn">
<div>
<input id="email" type="text" placeholder="Email...">
</div>
<div>
<input id="password" type="password" placeholder="Password...">
</div>
<div class="w3-padding w3-xlarge w3 container">
<button id="sign-up" onclick="signUp();" class="btn">Sign up</button>
<button id="sign-in" onclick="signIn();" class="btn">Sign In</button>
</div>
</div>
<div id="logged-in" value="hide" class="w3-padding w3-xlarge w3 container">
<div id="hello"></div>
<button id="sign-out" onclick="signOut();" class="btn">Sign Out</button>
</div>
</nav>
<div class="fh5co-footer">
<p>
<small>
© 2016 Blend Free HTML5. All Rights Reserved.
<span>Designed by <a href="http://freehtml5.co/" target="_blank">FreeHTML5.co</a> </span>
<span>Demo Images: <a href="http://pexels.com/" target="_blank">Pexels</a></span>
</small>
</p>
<ul>
<li><a href="#"><i class="icon-facebook"></i></a></li>
<li><a href="#"><i class="icon-twitter"></i></a></li>
<li><a href="#"><i class="icon-instagram"></i></a></li>
<li><a href="#"><i class="icon-linkedin"></i></a></li>
</ul>
</div>
</aside>
<div id="fh5co-main">
<div id="gallery">
<h1 class="container fh5co-heading animate-box" data-animate-effect="fadeInLeft">step 1: choose photos</h1>
<div class="fh5co-gallery"></div>
<div class="w3-padding w3-xlarge w3 container">
<button class="fa fa-trash btn" onclick="Delete()"></button>
<button onclick="showNext()" class="btn">Next</button>
</div>
</div>
<div id="create" class="container" hidden>
<h1 class="fh5co-heading animate-box" data-animate-effect="fadeInLeft">Step 2: choose a song file</h1>
<div class="fh5co-gallery2"></div>
<div class="w3-padding w3-xlarge w3 container">
<button onclick="showPrev()" class="btn">Back</button>
<button class="fa fa-trash btn" onclick="Delete2()"></button>
<button onclick="Create()" class="btn">Create your video</button>
</div>
</div>
<div id="result" class="container" hidden>
<h1 class="fh5co-heading animate-box" data-animate-effect="fadeInLeft">Your video is ready</h1>
<div id="video"></div>
<button onclick="showPrev2()" class="btn">Back</button>
</div>
<!--https://en.code-bude.net/2013/04/17/how-to-create-video-files-in-c-from-single-images/-->
</div>
</div>
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- jQuery Easing -->
<script src="js/jquery.easing.1.3.js"></script>
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap.fd.js"></script>
<!-- Carousel -->
<script src="js/owl.carousel.min.js"></script>
<!-- Stellar -->
<script src="js/jquery.stellar.min.js"></script>
<!-- Waypoints -->
<script src="js/jquery.waypoints.min.js"></script>
<!-- Counters -->
<script src="js/jquery.countTo.js"></script>
<!-- MAIN JS -->
<script src="js/main.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.9.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyDSeclpoQTYGOqTZB_QuEvMhpBe4bzXiIk",
authDomain: "myalbum-c8507.firebaseapp.com",
databaseURL: "https://myalbum-c8507.firebaseio.com",
projectId: "myalbum-c8507",
storageBucket: "myalbum-c8507.appspot.com",
messagingSenderId: "1011314042913"
};
firebase.initializeApp(config);
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
function loadList() {
$(".fh5co-gallery").html('');
let imagesRef = firebase.database().ref().child(firebase.auth().currentUser.uid).child("images");
let i = 0;
imagesRef.once('value', function (snapshot) {
snapshot.forEach(function (childSnapshot) {
let childData = childSnapshot.val();
let imageRef = firebase.storage().ref().child(childData.fileName);
imageRef.getDownloadURL().then(function (url) {
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function (event) {
var blob = xhr.response;
};
xhr.open('GET', url);
xhr.send();
let index = "img" + i;
let a = '<a class="gallery-item" id="' + index + '"">' +
'<img src="' + url + '" alt="' + url + '" data-url="' + url + '" style="width: 100%;height:100%;">' + '<span class="overlay">' +
'<h2></h2>' +
'<span></span>' + ' </span>' + '</a>';
$(".fh5co-gallery").append(a);
$("#img" + i).fadeOut(0);
console.log("parent data" + childData);
$("#img" + i).attr("parentOf", childSnapshot.key);
let j = i;
setTimeout(function () { $("#img" + j).fadeIn(3000); }, i * 750);
i++;
}).catch(function (error) {
// Handle any errors
});
});
});
}
function loadList2() {
$(".fh5co-gallery2").html('');
let imagesRef = firebase.database().ref().child(firebase.auth().currentUser.uid).child("songs");
let i = 0;
imagesRef.once('value', function (snapshot) {
snapshot.forEach(function (childSnapshot) {
let childData = childSnapshot.val();
let imageRef = firebase.storage().ref().child(childData.fileName);
imageRef.getDownloadURL().then(function (url) {
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function (event) {
var blob = xhr.response;
};
xhr.open('GET', url);
xhr.send();
let index = "song" + i;
var arrayOfStrings = url.split('_');
var songName = arrayOfStrings[1].split('.')[0];
let b = '<div>'+songName+'<video id="'+index+ '" class="item" controls><source src="'+url+'" type="video/mp4"></video></div>';
$(".fh5co-gallery2").append(b);
$("#song" + i).fadeOut(0);
$("#song" + i).attr("parentOf", childSnapshot.key);
let j = i;
setTimeout(function () { $("#song" + j).fadeIn(3000); }, i * 750);
i++;
}).catch(function (error) {
// Handle any errors
});
});
});
}
$(document).ready(function () {
$("#uploadSong").click(function () {
$.FileDialog({
accept: ".mp3",
cancelButton: "Cancel",
dragMessage: "Drop songs here or click to choose manually.",
dropheight: 400,
errorMessage: "An error occured while loading file",
multiple: true,
okButton: "Upload",
readAs: "DataURL",
removeMessage: "Remove file",
title: "Load songs"
});
$("input[type='file']").addClass("hidden");
$(".bfd-dropfield-inner").html("Drop songs here<br /><b>or</b><br />click here.");
$(".bfd-dropfield-inner").css('padding-top', '110px');
$(".modal-body").css('background-color', '#f0f0f0');
});
$("#uploadImage").click(function () {
$.FileDialog({
accept: "image/*",
cancelButton: "Cancel",
dragMessage: "Drop images here or click to choose manually.",
dropheight: 400,
errorMessage: "An error occured while loading file",
multiple: true,
okButton: "Upload",
readAs: "DataURL",
removeMessage: "Remove file",
title: "Load images"
});
$("input[type='file']").addClass("hidden");
$(".bfd-dropfield-inner").html("Drop images here<br /><b>or</b><br />click here.");
$(".bfd-dropfield-inner").css('padding-top', '110px');
$(".modal-body").css('background-color', '#f0f0f0');
});
// handle files choice when done
$(document).on('files.bs.filedialog', function (ev) {
let files_list = ev.files;
let rootRef = firebase.database().ref();
let storageRef = firebase.storage().ref();
for (i = 0; i < files_list.length; i++) {
let file = files_list[i];
let fileName = guid() + "_" + file.name;
let imageRef = storageRef
.child(fileName)
.put(file);
console.log(file.type);
if (file.type != "audio/mp3") {
let imageObjectRef = rootRef.child(firebase.auth().currentUser.uid).child("images").push();
imageObjectRef.set({
fileName: fileName
});
} else {
let imageObjectRef = rootRef.child(firebase.auth().currentUser.uid).child("songs").push();
imageObjectRef.set({
fileName: fileName
});
}
}
loadList();
loadList2();
});
// handle dialog cancelling
$(document).on('cancel.bs.filedialog', function (ev) {
// DO SOMETHING when user cancelled
});
$(document).on('click', ".gallery-item", function () {
if ($(this).hasClass("checked")) {
$(this).removeClass("checked");
} else {
$(this).addClass("checked");
}
});
$(document).on('click', ".item", function () {
if ($(this).hasClass("checked2")) {
$(this).removeClass("checked2");
} else {
$(this).addClass("checked2");
}
});
});
function signUp() {
var email = $("#email").val();
var password = $("#password").val();
console.log(email);
console.log(password);
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function (error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
}
function signIn() {
var email = $("#email").val();
var password = $("#password").val();
console.log(email);
console.log(password);
firebase.auth().signInWithEmailAndPassword(email, password).catch(function (error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
}
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
// User is signed in.
var displayName = user.displayName;
var email = user.email;
var emailVerified = user.emailVerified;
var photoURL = user.photoURL;
var isAnonymous = user.isAnonymous;
var uid = user.uid;
var providerData = user.providerData;
console.log("signed in");
console.log(password);
document.getElementById("hello").innerHTML = "Hello " + email;
$("#signIn").hide();
$("#logged-in").show();
$("#fh5co-gallery").show();
$("#gallery").show();
$("#uploadImage").show();
loadList();
loadList2();
// ...
} else {
$("#fh5co-gallery").hide();
$("#gallery").hide();
$("#signIn").show();
$("#logged-in").hide();
$("#uploadImage").hide();
}
});
function signOut() {
firebase.auth().signOut().then(function () {
// Sign-out successful.
}).catch(function (error) {
// An error happened.
});
}
function Delete() {
var result = confirm("Want to delete?");
if (result) {
let rootRef = firebase.database().ref();
$.each($(".checked"), function () {
imageParent = $(this).attr("parentOf");
rootRef.child(firebase.auth().currentUser.uid).child("images").child(imageParent).set(null).then(function () {
console.log("Document successfully deleted!");
}).catch(function (error) {
console.error("Error removing document: ", error);
});
});
}
}
function Delete2() {
var result = confirm("Want to delete?");
if (result) {
let rootRef = firebase.database().ref();
$.each($(".checked2"), function () {
songParent = $(this).attr("parentOf");
rootRef.child(firebase.auth().currentUser.uid).child("songs").child(songParent).set(null).then(function () {
console.log("Document successfully deleted!");
}).catch(function (error) {
console.error("Error removing document: ", error);
});
});
}
}
function showPrev() {
$("#fh5co-gallery").show();
$("#gallery").show();
$(document).ready(function () {
$("#create").hide();
});
}
function showPrev2() {
$("#video").html="";
$("#result").hide();
$("#create").show();
}
function showNext() {
var list = document.getElementsByClassName("checked");
if (list.length) {
$("#fh5co-gallery").hide();
$("#gallery").hide();
$(document).ready(function () {
loadList2();
$("#fh5co-gallery2").show();
$("#create").show();
});
} else {
alert("No images selected");
}
}
function loading(list,song) {
$("body").append("<div id='loadingDiv' style='position:fixed;left:0px;top:0px;z-index:999999;width:100%;height:100%;text-align:center;background-color:rgba(0,0,0,0.7);font-size:55px;'><div style='position:fixed; top:40%; width:100%;color:white;' id='tempLink'>Loading...</div></div>");
$.ajax({
url: "http://imagestovideo.eirandanan.com//api/imagesToVideo",
type: "post",
data: {
imageUrls: list,
audioUrl: song
},
//contentType: "application/json",
//processData: false,
success: function (videoUrl) {
let url = videoUrl;
let b = '<video controls><source src="'+url+'" type="video/mp4"></video>';
$("#video").append(b);
$("#create").hide();
$("#result").show();
$("#loadingDiv").remove();
},
error: function (err) {
console.log(err);
}
});
}
function Create() {
var list = document.getElementsByClassName("checked2");
if (list.length == 1) {
var list2 = [];
$.each($(".checked"), function () {
list2.push($(this).find("img:first").attr('src'));
});
var url = list[0].currentSrc;
loading(list2, url);
} else if (list.length == 0) {
alert("No song selected");
} else if (list.length > 0) {
alert("Too many songs selected");
}
}
function CreatePrev() {
if (file.length) {
file = document.querySelector("[name=file]").files[0];
let rootRef = firebase.database().ref();
let storageRef = firebase.storage().ref();
let fileName = guid() + "_" + file.name;
let imageRef = storageRef
.child(fileName)
.put(file);
let imageRef2 = firebase.storage().ref().child(fileName);
let imageObjectRef = rootRef.child(firebase.auth().currentUser.uid).child("songs").push();
imageObjectRef.set({
fileName: fileName
})
//new!!
imageRef.on(firebase.storage.TaskEvent.STATE_CHANGED, // or 'state_changed'
function(snapshot) {
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
if(progress == 100){
imageRef2.getDownloadURL().then(function (url) {
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function (event) {
var blob = xhr.response;
};
xhr.open('GET', url);
xhr.send();
var list2 = [];
$.each($(".checked"), function () {
list2.push($(this).find("img:first").attr('src'));
});
loading(list2, url);
//url is here
}).catch(function (error) {
// Handle any errors
});
}
},
function(error) {
},
function() {
});
//end new!!
} else {
alert("No song selected");
}
}
</script>
</body>
</html>