appscms-tools-theme 4.0.7 → 4.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_data/about/en/about.json +16 -16
- data/_data/blog/nav.json +13 -13
- data/_data/blog/relatedblogs.json +6932 -6932
- data/_data/download/en/download.json +73 -73
- data/_data/feature/en/3_shop_posters.json +361 -361
- data/_data/feature/en/allele-frequency.json +321 -321
- data/_data/feature/en/batch-conversion.json +153 -153
- data/_data/feature/en/compress-pdf.json +308 -308
- data/_data/feature/en/devtools.json +299 -299
- data/_data/feature/en/face-detection.json +123 -123
- data/_data/feature/en/split-pdf.json +176 -176
- data/_data/feature/en/theframe.json +126 -126
- data/_data/feature/hi/compress-pdf.json +162 -162
- data/_data/feature/tr/compress-pdf.json +161 -161
- data/_data/footer/en/data.json +167 -167
- data/_data/header/en/data.json +174 -174
- data/_data/home/en/en.json +381 -381
- data/_data/home/en/photoeffects.json +97 -97
- data/_data/home/en/posters.json +322 -322
- data/_data/home-1/en/en.json +308 -308
- data/_includes/appscms/customblog/pageRelatedPosts.html +84 -84
- data/_includes/appscms/customblog/recentposts.html +67 -67
- data/_includes/appscms/customblog/relatedBlogs.html +83 -83
- data/_includes/appscms/customblog/relatedposts.html +196 -196
- data/_includes/appscms/extras/appscms-postbox.html +65 -65
- data/_includes/appscms/featurePageAuthors/featurePageAuthors.html +97 -97
- data/_includes/appscms/head/bloghead.html +238 -238
- data/_includes/appscms/infographics/infographics.html +114 -109
- data/_includes/appscms/recent-posts/recent_posts.html +92 -92
- data/_includes/appscms/recent-posts/related_categories_post.html +198 -198
- data/_includes/author_bio.html +41 -41
- data/_includes/authorpagehead/index.html +47 -47
- data/_includes/authors/authors.html +117 -117
- data/_includes/batch-conversion.html +141 -141
- data/_includes/cssfile/links.html +54 -54
- data/_includes/custom-head.html +138 -138
- data/_includes/customCode.html +1 -1
- data/_includes/customScripts.html +1 -1
- data/_includes/customblog/pageRelatedPosts.html +87 -87
- data/_includes/customblog/relatedBlogs.html +86 -86
- data/_includes/dropdown/langdropdown.html +32 -32
- data/_includes/feature.html +39 -39
- data/_includes/featurePageAuthors/featurePageAuthors.html +97 -97
- data/_includes/footer/index.html +538 -538
- data/_includes/google-analytics.html +32 -32
- data/_includes/head/index.html +623 -623
- data/_includes/header/blogHeader.html +34 -34
- data/_includes/header/index.html +192 -192
- data/_includes/infographics/infographics.html +241 -231
- data/_includes/paginationBlogPage.html +70 -70
- data/_includes/script.html +557 -557
- data/_includes/share/socialshare.html +21 -21
- data/_includes/userTracking.html +43 -43
- data/_layouts/aboutUs.html +98 -98
- data/_layouts/allAuthors.html +131 -131
- data/_layouts/appscms-about.html +163 -163
- data/_layouts/appscms-audio.html +33 -33
- data/_layouts/appscms-author.html +408 -408
- data/_layouts/appscms-authors.html +132 -132
- data/_layouts/appscms-calculator.html +93 -93
- data/_layouts/appscms-categories.html +26 -26
- data/_layouts/appscms-contact.html +132 -132
- data/_layouts/appscms-disclaimer.html +124 -124
- data/_layouts/appscms-download.html +289 -289
- data/_layouts/appscms-feature-result.html +94 -94
- data/_layouts/appscms-help.html +25 -25
- data/_layouts/appscms-imagekit.html +113 -113
- data/_layouts/appscms-post.html +243 -243
- data/_layouts/appscms-privacy-policy.html +781 -781
- data/_layouts/appscms-terms-and-conditions.html +646 -646
- data/_layouts/appscms-video.html +33 -33
- data/_layouts/audio.html +33 -33
- data/_layouts/author.html +408 -408
- data/_layouts/batch.html +177 -177
- data/_layouts/blog.html +131 -131
- data/_layouts/calculator.html +99 -99
- data/_layouts/devtools.html +57 -57
- data/_layouts/feature-1.html +406 -406
- data/_layouts/feature.html +435 -434
- data/_layouts/featureResultPage.html +80 -80
- data/_layouts/frame.html +222 -222
- data/_layouts/home.html +300 -300
- data/_layouts/imagekit.html +303 -303
- data/_layouts/photo-effects-home.html +190 -190
- data/_layouts/post.html +233 -233
- data/assets/app.js +75 -75
- data/assets/css/appscms-blog.css +500 -500
- data/assets/css/appscms-home.css +5 -5
- data/assets/css/appscms-imagekit.css +854 -854
- data/assets/css/appscms-variables.css +18 -18
- data/assets/css/blog.css +509 -509
- data/assets/css/calculators.css +46 -46
- data/assets/css/devtools.css +105 -105
- data/assets/css/feature-1.css +293 -293
- data/assets/css/imagekit copy.css +848 -848
- data/assets/css/tools.css +1817 -1817
- data/assets/images/digipaint.svg +6 -6
- data/assets/images/logo.svg +2 -2
- data/assets/images/manthink.svg +3552 -3552
- data/assets/js/batch.js +256 -256
- data/assets/js/devtools.js +81 -81
- data/assets/js/sharePage.js +65 -65
- data/assets/js/usageTracking.js +143 -143
- data/assets/js/usageTrackingEvents.js +6 -6
- metadata +2 -2
data/assets/js/batch.js
CHANGED
@@ -1,256 +1,256 @@
|
|
1
|
-
const getScript = document.currentScript
|
2
|
-
const pageTool = getScript.dataset.tool
|
3
|
-
const lang = getScript.dataset.lang
|
4
|
-
const inputBox = document.querySelector('#Inputbox')
|
5
|
-
const addFiles = document.querySelector('.add-more-files')
|
6
|
-
const gdrive = document.querySelector('#filepicker')
|
7
|
-
const fileDropBox = document.querySelector('.custom-box')
|
8
|
-
const workspace = document.querySelector('.workspace')
|
9
|
-
const selectedFilesList = document.querySelector('.selectedFilesList')
|
10
|
-
const downloadButton = document.querySelector('#download-button')
|
11
|
-
const submitButton = document.querySelector('#submit-button')
|
12
|
-
const showProcessingFiles = document.querySelector('.files-processing-list')
|
13
|
-
let zipFileType = null
|
14
|
-
let renderFileTypes = null
|
15
|
-
let root = document.querySelector(':root')
|
16
|
-
root.style.setProperty('--maincolor', fileDropBox.dataset.color)
|
17
|
-
|
18
|
-
|
19
|
-
const showLoader = () => {
|
20
|
-
showLoading()
|
21
|
-
}
|
22
|
-
const closeLoader = () => { }
|
23
|
-
const mimeTypes = 'image/png,image/jpg,image/jpeg,image/webp'
|
24
|
-
const filemimes = ['.png', '.webp', '.jpg', '.jpeg']
|
25
|
-
gdrive.addEventListener(
|
26
|
-
'click',
|
27
|
-
(getFile, mimeTypes, showLoader, closeLoader) => {
|
28
|
-
const data = loadPicker()
|
29
|
-
}
|
30
|
-
)
|
31
|
-
const dropbox = document.getElementById('dropbox')
|
32
|
-
dropbox.addEventListener(
|
33
|
-
'click',
|
34
|
-
async (getDropBoxFile, showLoader, closeLoader) => {
|
35
|
-
const getFile = chooseFromDropbox()
|
36
|
-
}
|
37
|
-
)
|
38
|
-
|
39
|
-
|
40
|
-
const getFile = (file) => {
|
41
|
-
handleFile(file)
|
42
|
-
}
|
43
|
-
fileDropBox.addEventListener('dragover', (e) => {
|
44
|
-
e.preventDefault()
|
45
|
-
})
|
46
|
-
fileDropBox.addEventListener('drop', (e) => {
|
47
|
-
e.preventDefault()
|
48
|
-
handleFile(e.dataTransfer.files[0])
|
49
|
-
})
|
50
|
-
const fileOnChange = () => {
|
51
|
-
handleFile(file.files)
|
52
|
-
}
|
53
|
-
inputBox.onclick = function () {
|
54
|
-
document.querySelector('#file').click()
|
55
|
-
}
|
56
|
-
const fileOnChange2 = () => {
|
57
|
-
addMoreFiles(document.querySelector('#file2').files)
|
58
|
-
}
|
59
|
-
addFiles.onclick = function () {
|
60
|
-
document.querySelector('#file2').click()
|
61
|
-
}
|
62
|
-
var files = []
|
63
|
-
let fileName = ''
|
64
|
-
let blobList = []
|
65
|
-
const addMoreFiles = (addFiles) => {
|
66
|
-
handleFile(addFiles)
|
67
|
-
}
|
68
|
-
const onSubmit = (files) => {
|
69
|
-
blobList = []
|
70
|
-
Promise.all(
|
71
|
-
files.map((item, index) => {
|
72
|
-
document.querySelector(
|
73
|
-
`#loader-${index}`
|
74
|
-
).innerHTML = `<span class="processing">processing</span>
|
75
|
-
<div class="spinner-border" role="status"><span class="sr-only">Loading...</span></div>`
|
76
|
-
return new Promise((resolve, reject) => {
|
77
|
-
batchConversion(item, index).then(([indexValue, blob, type]) => {
|
78
|
-
blobList.push({ blob: blob, fileName: item })
|
79
|
-
document.querySelector(
|
80
|
-
`#loader-${indexValue}`
|
81
|
-
).innerHTML = `<span class="done">finished</span>`
|
82
|
-
document.querySelector(`#download-${indexValue}`).style.display =
|
83
|
-
'inline-block'
|
84
|
-
resolve()
|
85
|
-
})
|
86
|
-
}).catch((error) => {
|
87
|
-
console.log(error)
|
88
|
-
})
|
89
|
-
})
|
90
|
-
).then(() => {
|
91
|
-
document.querySelector('.bottom-section-container').style.display = 'flex'
|
92
|
-
document.querySelector('.bottom-section-container').style.padding =
|
93
|
-
'20px .75rem'
|
94
|
-
document.querySelector('#download-zip').style.display = 'block'
|
95
|
-
let zip = new JSZip()
|
96
|
-
let zipFiles = zip.folder(`safeimagekit-batch-images`)
|
97
|
-
blobList.map((item) => {
|
98
|
-
zipFiles.file(
|
99
|
-
`safeimagekit-batch-${item.fileName.name.split('.')[0]}.${zipFileType ? zipFileType : 'png'
|
100
|
-
}`,
|
101
|
-
getBase64String(item.blob),
|
102
|
-
{ base64: true }
|
103
|
-
)
|
104
|
-
})
|
105
|
-
|
106
|
-
document.querySelector('#download-zip').addEventListener('click', () => {
|
107
|
-
zip.generateAsync({ type: 'blob' }).then(function (content) {
|
108
|
-
saveAs(content, `safeimagekit-batch-conversion.zip`)
|
109
|
-
if (lang === 'en') {
|
110
|
-
window.location.href = `/download?tool=${pageTool}`
|
111
|
-
} else {
|
112
|
-
window.location.href = `/${lang}/download?tool=${pageTool}`
|
113
|
-
}
|
114
|
-
})
|
115
|
-
})
|
116
|
-
})
|
117
|
-
}
|
118
|
-
let renderFileTypesHtml = ` <option value="png">png</option>
|
119
|
-
<option value="jpg">jpg</option>
|
120
|
-
<option value="jpeg">jpeg</option>
|
121
|
-
<option value="webp">webp</option>
|
122
|
-
`
|
123
|
-
|
124
|
-
const renderFiles = (files) => {
|
125
|
-
if (renderFileTypes !== null) {
|
126
|
-
renderFileTypesHtml = ''
|
127
|
-
renderFileTypes.map((i) => {
|
128
|
-
renderFileTypesHtml += `<option value="${i}">${i}</option>`
|
129
|
-
})
|
130
|
-
}
|
131
|
-
files.map((file, index) => {
|
132
|
-
if (file) {
|
133
|
-
let filename = file.name
|
134
|
-
if (file.name.split(".")[0].length > 10) {
|
135
|
-
let fName = file.name.split(".")[0]
|
136
|
-
let fExtention = file.name.split(".")[1]
|
137
|
-
filename = fName.substr(0, 9) + "..." + fName.substr(-3) + "." + fExtention
|
138
|
-
|
139
|
-
}
|
140
|
-
let loader = 'Ready'
|
141
|
-
showProcessingFiles.innerHTML += `
|
142
|
-
<tr>
|
143
|
-
<th scope="row" class="file-icon-row">
|
144
|
-
<img src="/assets/images/file.png" alt="file" class="file-icon">
|
145
|
-
</th>
|
146
|
-
<td class="fileName">${filename}</td>
|
147
|
-
<td id=loader-${index} class="file-processing"><span class="ready">${loader}</span></td>
|
148
|
-
<td>
|
149
|
-
<div class="download-format ">
|
150
|
-
<select name="image-format" id="image-format">
|
151
|
-
${renderFileTypesHtml}
|
152
|
-
</select>
|
153
|
-
</div>
|
154
|
-
|
155
|
-
</td>
|
156
|
-
<td class="file-download-button text-right">
|
157
|
-
<button style="display:none;" id=download-${index} data-type="image" onclick="handleDownload(this)" class="btn download-file-btn">
|
158
|
-
<svg class="download-icon" width="16px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"
|
159
|
-
fill="currentColor">
|
160
|
-
<path
|
161
|
-
d="M18 20H5V15H6V19H17V15H18V20ZM12 4V15.19L14.3 13L15 13.6667L11.5 17L8 13.6667L8.7 13L11 15.19V4H12Z">
|
162
|
-
</path>
|
163
|
-
</svg> Download
|
164
|
-
</button>
|
165
|
-
</td>
|
166
|
-
</tr>
|
167
|
-
`
|
168
|
-
}
|
169
|
-
})
|
170
|
-
}
|
171
|
-
|
172
|
-
const handleFile = (file) => {
|
173
|
-
showProcessingFiles.innerHTML = ''
|
174
|
-
if (file) {
|
175
|
-
for (let i = 0; i < file.length; i++) {
|
176
|
-
files.push(file[i])
|
177
|
-
stopLoading()
|
178
|
-
workspace.style.display = 'block'
|
179
|
-
document.querySelector('#file').style.display = 'block'
|
180
|
-
let listItem = document.createElement('li')
|
181
|
-
listItem.style.listStyle = 'none'
|
182
|
-
let getFileSize = formatBytes(file[i].size)
|
183
|
-
listItem.innerHTML = `${file[i].name} (${getFileSize})`
|
184
|
-
// selectedFilesList.appendChild(listItem)
|
185
|
-
}
|
186
|
-
}
|
187
|
-
renderFiles(files)
|
188
|
-
submitButton.addEventListener('click', () => onSubmit(files))
|
189
|
-
}
|
190
|
-
function formatBytes(bytes, decimals = 2) {
|
191
|
-
if (bytes === 0) return '0 Bytes'
|
192
|
-
|
193
|
-
const k = 1024
|
194
|
-
const dm = decimals < 0 ? 0 : decimals
|
195
|
-
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
196
|
-
|
197
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
198
|
-
|
199
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
|
200
|
-
}
|
201
|
-
const handleDownload = (e) => {
|
202
|
-
let find = blobList[Number(e.id.replace(/^\D+/g, ''))].blob
|
203
|
-
let fileName = blobList[Number(e.id.replace(/^\D+/g, ''))].fileName.name
|
204
|
-
|
205
|
-
let format = document.querySelector('#image-format').value
|
206
|
-
|
207
|
-
switch (e.dataset.type) {
|
208
|
-
case 'image':
|
209
|
-
let a = document.createElement('a')
|
210
|
-
a.href = find
|
211
|
-
a.download = `safeimagekit-batch-${fileName.split('.')[0]}.${format}`
|
212
|
-
document.body.appendChild(a)
|
213
|
-
a.click()
|
214
|
-
break
|
215
|
-
default:
|
216
|
-
break
|
217
|
-
}
|
218
|
-
}
|
219
|
-
const showLoading = () => {
|
220
|
-
document.querySelector('#file-loader').style.display = 'flex'
|
221
|
-
document.querySelector('.file-input').style.display = 'none'
|
222
|
-
}
|
223
|
-
const stopLoading = () => {
|
224
|
-
fileDropBox.style.display = 'none'
|
225
|
-
}
|
226
|
-
const showDropDown = document.querySelector('.file-pick-dropdown')
|
227
|
-
const icon = document.querySelector('.arrow-sign')
|
228
|
-
const dropDown = document.querySelector('.file-picker-dropdown')
|
229
|
-
showDropDown.addEventListener('click', () => {
|
230
|
-
addScripts()
|
231
|
-
if (dropDown.style.display !== 'none') {
|
232
|
-
dropDown.style.display = 'none'
|
233
|
-
icon.classList.remove('fa-angle-up')
|
234
|
-
icon.classList.add('fa-angle-down')
|
235
|
-
} else {
|
236
|
-
dropDown.style.display = 'block'
|
237
|
-
icon.classList.remove('fa-angle-down')
|
238
|
-
icon.classList.add('fa-angle-up')
|
239
|
-
}
|
240
|
-
})
|
241
|
-
|
242
|
-
const getBase64String = (dataURL) => {
|
243
|
-
const idx = dataURL.indexOf('base64,') + 'base64,'.length
|
244
|
-
return dataURL.substring(idx)
|
245
|
-
}
|
246
|
-
const dataURLtoBlob = (dataurl) => {
|
247
|
-
let arr = dataurl.split(','),
|
248
|
-
mime = arr[0].match(/:(.*?);/)[1],
|
249
|
-
bstr = atob(arr[1]),
|
250
|
-
n = bstr.length,
|
251
|
-
u8arr = new Uint8Array(n)
|
252
|
-
while (n--) {
|
253
|
-
u8arr[n] = bstr.charCodeAt(n)
|
254
|
-
}
|
255
|
-
return new Blob([u8arr], { type: mime })
|
256
|
-
}
|
1
|
+
const getScript = document.currentScript
|
2
|
+
const pageTool = getScript.dataset.tool
|
3
|
+
const lang = getScript.dataset.lang
|
4
|
+
const inputBox = document.querySelector('#Inputbox')
|
5
|
+
const addFiles = document.querySelector('.add-more-files')
|
6
|
+
const gdrive = document.querySelector('#filepicker')
|
7
|
+
const fileDropBox = document.querySelector('.custom-box')
|
8
|
+
const workspace = document.querySelector('.workspace')
|
9
|
+
const selectedFilesList = document.querySelector('.selectedFilesList')
|
10
|
+
const downloadButton = document.querySelector('#download-button')
|
11
|
+
const submitButton = document.querySelector('#submit-button')
|
12
|
+
const showProcessingFiles = document.querySelector('.files-processing-list')
|
13
|
+
let zipFileType = null
|
14
|
+
let renderFileTypes = null
|
15
|
+
let root = document.querySelector(':root')
|
16
|
+
root.style.setProperty('--maincolor', fileDropBox.dataset.color)
|
17
|
+
|
18
|
+
|
19
|
+
const showLoader = () => {
|
20
|
+
showLoading()
|
21
|
+
}
|
22
|
+
const closeLoader = () => { }
|
23
|
+
const mimeTypes = 'image/png,image/jpg,image/jpeg,image/webp'
|
24
|
+
const filemimes = ['.png', '.webp', '.jpg', '.jpeg']
|
25
|
+
gdrive.addEventListener(
|
26
|
+
'click',
|
27
|
+
(getFile, mimeTypes, showLoader, closeLoader) => {
|
28
|
+
const data = loadPicker()
|
29
|
+
}
|
30
|
+
)
|
31
|
+
const dropbox = document.getElementById('dropbox')
|
32
|
+
dropbox.addEventListener(
|
33
|
+
'click',
|
34
|
+
async (getDropBoxFile, showLoader, closeLoader) => {
|
35
|
+
const getFile = chooseFromDropbox()
|
36
|
+
}
|
37
|
+
)
|
38
|
+
|
39
|
+
|
40
|
+
const getFile = (file) => {
|
41
|
+
handleFile(file)
|
42
|
+
}
|
43
|
+
fileDropBox.addEventListener('dragover', (e) => {
|
44
|
+
e.preventDefault()
|
45
|
+
})
|
46
|
+
fileDropBox.addEventListener('drop', (e) => {
|
47
|
+
e.preventDefault()
|
48
|
+
handleFile(e.dataTransfer.files[0])
|
49
|
+
})
|
50
|
+
const fileOnChange = () => {
|
51
|
+
handleFile(file.files)
|
52
|
+
}
|
53
|
+
inputBox.onclick = function () {
|
54
|
+
document.querySelector('#file').click()
|
55
|
+
}
|
56
|
+
const fileOnChange2 = () => {
|
57
|
+
addMoreFiles(document.querySelector('#file2').files)
|
58
|
+
}
|
59
|
+
addFiles.onclick = function () {
|
60
|
+
document.querySelector('#file2').click()
|
61
|
+
}
|
62
|
+
var files = []
|
63
|
+
let fileName = ''
|
64
|
+
let blobList = []
|
65
|
+
const addMoreFiles = (addFiles) => {
|
66
|
+
handleFile(addFiles)
|
67
|
+
}
|
68
|
+
const onSubmit = (files) => {
|
69
|
+
blobList = []
|
70
|
+
Promise.all(
|
71
|
+
files.map((item, index) => {
|
72
|
+
document.querySelector(
|
73
|
+
`#loader-${index}`
|
74
|
+
).innerHTML = `<span class="processing">processing</span>
|
75
|
+
<div class="spinner-border" role="status"><span class="sr-only">Loading...</span></div>`
|
76
|
+
return new Promise((resolve, reject) => {
|
77
|
+
batchConversion(item, index).then(([indexValue, blob, type]) => {
|
78
|
+
blobList.push({ blob: blob, fileName: item })
|
79
|
+
document.querySelector(
|
80
|
+
`#loader-${indexValue}`
|
81
|
+
).innerHTML = `<span class="done">finished</span>`
|
82
|
+
document.querySelector(`#download-${indexValue}`).style.display =
|
83
|
+
'inline-block'
|
84
|
+
resolve()
|
85
|
+
})
|
86
|
+
}).catch((error) => {
|
87
|
+
console.log(error)
|
88
|
+
})
|
89
|
+
})
|
90
|
+
).then(() => {
|
91
|
+
document.querySelector('.bottom-section-container').style.display = 'flex'
|
92
|
+
document.querySelector('.bottom-section-container').style.padding =
|
93
|
+
'20px .75rem'
|
94
|
+
document.querySelector('#download-zip').style.display = 'block'
|
95
|
+
let zip = new JSZip()
|
96
|
+
let zipFiles = zip.folder(`safeimagekit-batch-images`)
|
97
|
+
blobList.map((item) => {
|
98
|
+
zipFiles.file(
|
99
|
+
`safeimagekit-batch-${item.fileName.name.split('.')[0]}.${zipFileType ? zipFileType : 'png'
|
100
|
+
}`,
|
101
|
+
getBase64String(item.blob),
|
102
|
+
{ base64: true }
|
103
|
+
)
|
104
|
+
})
|
105
|
+
|
106
|
+
document.querySelector('#download-zip').addEventListener('click', () => {
|
107
|
+
zip.generateAsync({ type: 'blob' }).then(function (content) {
|
108
|
+
saveAs(content, `safeimagekit-batch-conversion.zip`)
|
109
|
+
if (lang === 'en') {
|
110
|
+
window.location.href = `/download?tool=${pageTool}`
|
111
|
+
} else {
|
112
|
+
window.location.href = `/${lang}/download?tool=${pageTool}`
|
113
|
+
}
|
114
|
+
})
|
115
|
+
})
|
116
|
+
})
|
117
|
+
}
|
118
|
+
let renderFileTypesHtml = ` <option value="png">png</option>
|
119
|
+
<option value="jpg">jpg</option>
|
120
|
+
<option value="jpeg">jpeg</option>
|
121
|
+
<option value="webp">webp</option>
|
122
|
+
`
|
123
|
+
|
124
|
+
const renderFiles = (files) => {
|
125
|
+
if (renderFileTypes !== null) {
|
126
|
+
renderFileTypesHtml = ''
|
127
|
+
renderFileTypes.map((i) => {
|
128
|
+
renderFileTypesHtml += `<option value="${i}">${i}</option>`
|
129
|
+
})
|
130
|
+
}
|
131
|
+
files.map((file, index) => {
|
132
|
+
if (file) {
|
133
|
+
let filename = file.name
|
134
|
+
if (file.name.split(".")[0].length > 10) {
|
135
|
+
let fName = file.name.split(".")[0]
|
136
|
+
let fExtention = file.name.split(".")[1]
|
137
|
+
filename = fName.substr(0, 9) + "..." + fName.substr(-3) + "." + fExtention
|
138
|
+
|
139
|
+
}
|
140
|
+
let loader = 'Ready'
|
141
|
+
showProcessingFiles.innerHTML += `
|
142
|
+
<tr>
|
143
|
+
<th scope="row" class="file-icon-row">
|
144
|
+
<img src="/assets/images/file.png" alt="file" class="file-icon">
|
145
|
+
</th>
|
146
|
+
<td class="fileName">${filename}</td>
|
147
|
+
<td id=loader-${index} class="file-processing"><span class="ready">${loader}</span></td>
|
148
|
+
<td>
|
149
|
+
<div class="download-format ">
|
150
|
+
<select name="image-format" id="image-format">
|
151
|
+
${renderFileTypesHtml}
|
152
|
+
</select>
|
153
|
+
</div>
|
154
|
+
|
155
|
+
</td>
|
156
|
+
<td class="file-download-button text-right">
|
157
|
+
<button style="display:none;" id=download-${index} data-type="image" onclick="handleDownload(this)" class="btn download-file-btn">
|
158
|
+
<svg class="download-icon" width="16px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"
|
159
|
+
fill="currentColor">
|
160
|
+
<path
|
161
|
+
d="M18 20H5V15H6V19H17V15H18V20ZM12 4V15.19L14.3 13L15 13.6667L11.5 17L8 13.6667L8.7 13L11 15.19V4H12Z">
|
162
|
+
</path>
|
163
|
+
</svg> Download
|
164
|
+
</button>
|
165
|
+
</td>
|
166
|
+
</tr>
|
167
|
+
`
|
168
|
+
}
|
169
|
+
})
|
170
|
+
}
|
171
|
+
|
172
|
+
const handleFile = (file) => {
|
173
|
+
showProcessingFiles.innerHTML = ''
|
174
|
+
if (file) {
|
175
|
+
for (let i = 0; i < file.length; i++) {
|
176
|
+
files.push(file[i])
|
177
|
+
stopLoading()
|
178
|
+
workspace.style.display = 'block'
|
179
|
+
document.querySelector('#file').style.display = 'block'
|
180
|
+
let listItem = document.createElement('li')
|
181
|
+
listItem.style.listStyle = 'none'
|
182
|
+
let getFileSize = formatBytes(file[i].size)
|
183
|
+
listItem.innerHTML = `${file[i].name} (${getFileSize})`
|
184
|
+
// selectedFilesList.appendChild(listItem)
|
185
|
+
}
|
186
|
+
}
|
187
|
+
renderFiles(files)
|
188
|
+
submitButton.addEventListener('click', () => onSubmit(files))
|
189
|
+
}
|
190
|
+
function formatBytes(bytes, decimals = 2) {
|
191
|
+
if (bytes === 0) return '0 Bytes'
|
192
|
+
|
193
|
+
const k = 1024
|
194
|
+
const dm = decimals < 0 ? 0 : decimals
|
195
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
196
|
+
|
197
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
198
|
+
|
199
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
|
200
|
+
}
|
201
|
+
const handleDownload = (e) => {
|
202
|
+
let find = blobList[Number(e.id.replace(/^\D+/g, ''))].blob
|
203
|
+
let fileName = blobList[Number(e.id.replace(/^\D+/g, ''))].fileName.name
|
204
|
+
|
205
|
+
let format = document.querySelector('#image-format').value
|
206
|
+
|
207
|
+
switch (e.dataset.type) {
|
208
|
+
case 'image':
|
209
|
+
let a = document.createElement('a')
|
210
|
+
a.href = find
|
211
|
+
a.download = `safeimagekit-batch-${fileName.split('.')[0]}.${format}`
|
212
|
+
document.body.appendChild(a)
|
213
|
+
a.click()
|
214
|
+
break
|
215
|
+
default:
|
216
|
+
break
|
217
|
+
}
|
218
|
+
}
|
219
|
+
const showLoading = () => {
|
220
|
+
document.querySelector('#file-loader').style.display = 'flex'
|
221
|
+
document.querySelector('.file-input').style.display = 'none'
|
222
|
+
}
|
223
|
+
const stopLoading = () => {
|
224
|
+
fileDropBox.style.display = 'none'
|
225
|
+
}
|
226
|
+
const showDropDown = document.querySelector('.file-pick-dropdown')
|
227
|
+
const icon = document.querySelector('.arrow-sign')
|
228
|
+
const dropDown = document.querySelector('.file-picker-dropdown')
|
229
|
+
showDropDown.addEventListener('click', () => {
|
230
|
+
addScripts()
|
231
|
+
if (dropDown.style.display !== 'none') {
|
232
|
+
dropDown.style.display = 'none'
|
233
|
+
icon.classList.remove('fa-angle-up')
|
234
|
+
icon.classList.add('fa-angle-down')
|
235
|
+
} else {
|
236
|
+
dropDown.style.display = 'block'
|
237
|
+
icon.classList.remove('fa-angle-down')
|
238
|
+
icon.classList.add('fa-angle-up')
|
239
|
+
}
|
240
|
+
})
|
241
|
+
|
242
|
+
const getBase64String = (dataURL) => {
|
243
|
+
const idx = dataURL.indexOf('base64,') + 'base64,'.length
|
244
|
+
return dataURL.substring(idx)
|
245
|
+
}
|
246
|
+
const dataURLtoBlob = (dataurl) => {
|
247
|
+
let arr = dataurl.split(','),
|
248
|
+
mime = arr[0].match(/:(.*?);/)[1],
|
249
|
+
bstr = atob(arr[1]),
|
250
|
+
n = bstr.length,
|
251
|
+
u8arr = new Uint8Array(n)
|
252
|
+
while (n--) {
|
253
|
+
u8arr[n] = bstr.charCodeAt(n)
|
254
|
+
}
|
255
|
+
return new Blob([u8arr], { type: mime })
|
256
|
+
}
|