-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
87 lines (70 loc) · 2.08 KB
/
main.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
var datetime = null,
date = null;
var update = function () {
date = moment(new Date())
datetime.html(date.format('dddd, MMMM Do YYYY, h:mm:ss a'));
};
$(document).ready(function(){
datetime = $('.show-time')
update();
setInterval(update, 1000);
});
$('.pdf_form').submit(function(e){
e.preventDefault();
formdata=new FormData()
var fileSelect = document.getElementById('file-select');
file=fileSelect.files
formdata.append('file', file[0], file.name);
//ajax_it(formdata);
convert_it(formdata);
$('.convertbtn').text('Converting ...')
})
function convert_it(formdata){
$.ajax({
url: 'https://v2.convertapi.com/convert/docx/to/pdf?Secret=OzUJvmJf1jVlhO6Y',
data: formdata,
processData: false,
contentType: false,
method: 'POST',
success: function(data) {
console.log(data);
files=data.Files
file=files[0]
data=file.FileData;
let url='data:application/pdf;base64, ' + data;
$('#sec-download-link').attr('href',url);
$('#sec-download-link').attr('download', file.FileName )
$('#sec-download-link').css('display','block');
//window.open(url,"_blank");
$('.convertbtn').text('Convert Another File')
}
})
}
$('.doc_form').submit(function(e){
e.preventDefault();
formdata=new FormData()
var fileSelect = document.getElementById('pdf-file-select');
file=fileSelect.files
formdata.append('file', file[0], file.name);
ajax_it(formdata);
$('.convertbtn').text('Converting ...')
})
function ajax_it(formdata){
$.ajax({
url: 'https://journals.projecttopics.org/convert',
data: formdata,
processData: false,
contentType: false,
method: 'POST',
success: function(data) {
console.log(data);
$('#download-link').attr('href',data.data);
$('#download-link').attr('download', file.FileName )
$('#download-link').css('display','block');
//window.open(url,"_blank");
$('.convertbtn').text('Convert Another File')
}
}).fail(function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
})
}