-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.js
90 lines (76 loc) · 2.33 KB
/
home.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
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
$(document).ready(function() {
// Submit Login
$('form').submit(function(event) {
event.preventDefault();
if ($('#tag').val() == 'Tag' || $('#monat').val() == 'Monat' || $('#jahr').val() == 'Jahr') {
$('#tag').focus();
return
}
$(".submit-btn").prop("disabled", true);
$(".error").prop("disabled", true);
$(".submit-btn").text('Sendet...');
$(".error").attr("hidden", true);
$(".errordetails").attr("hidden", true);
// prepare form Data
// text
var form = $('form')[0];
var formData = new FormData(form);
// Birthday
var geburtstag = $('#tag').val() + "." + $('#monat').val() + "." + $('#jahr').val();
formData.append('geburtstag', geburtstag);
// Img
var image2 = $('#kinderfoto').prop('files')[0];
formData.append('file', image2);
// Verify data
$.ajax({
type: 'POST',
url: 'send.php',
processData: false,
contentType: false,
dataType: 'json',
timeout: 300000,
data: formData,
success: function(data) {
if (data.status == 'successful') {
$(".container-vote").remove();
$(".alert-success").attr("hidden", false);
} else {
$(".error").attr("hidden", false);
$(".errordetails").attr("hidden", false);
$(".errordetails").text("Error: " + data.error.category + ": " + data.error.description);
$(".submit-btn").prop("disabled",false);
$(".submit-btn").text('Absenden');
$("html, body").animate({ scrollTop: $(document).height() }, 400);
}
},
error: function(jqXHR, textStatus, errorThrown) {
$(".error").attr("hidden", false);
$(".errordetails").attr("hidden", false);
$(".errordetails").text("Error: " + textStatus + ", " + errorThrown);
$(".submit-btn").prop("disabled", false);
$(".submit-btn").text('Absenden');
$("html, body").animate({ scrollTop: $(document).height() }, 400);
}
});
});
});
// Live image preview
function readURL2(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#kinderfoto--prev').removeAttr('hidden');
$('#kinderfoto--prev').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#kinderfoto").change(function(){
readURL2(this);
});
//
$(".unten").click(function() {
$([document.documentElement, document.body]).animate({
scrollTop: $(".vote").offset().top
}, 500);
});