appscms-tools-theme 4.8.3 → 4.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/_data/.DS_Store +0 -0
  3. data/_data/about/en/about.json +16 -16
  4. data/_data/blog/nav.json +14 -14
  5. data/_data/blog/relatedblogs.json +2816 -2816
  6. data/_data/feature/en/batch-conversion.json +192 -192
  7. data/_data/feature/en/compress-pdf.json +223 -223
  8. data/_data/feature/en/devtools.json +321 -321
  9. data/_data/feature/en/face-detection.json +156 -156
  10. data/_data/feature/en/split-pdf.json +221 -221
  11. data/_data/feature/en/theframe.json +160 -160
  12. data/_data/footer/en/data.json +264 -264
  13. data/_data/header/en/data.json +672 -672
  14. data/_data/home/en/en.json +250 -250
  15. data/_data/home/en/posters.json +322 -322
  16. data/_data/home-1/en/en.json +236 -236
  17. data/_data/noindexURLs.json +23 -0
  18. data/_includes/.DS_Store +0 -0
  19. data/_includes/alternates/alternates.html +64 -89
  20. data/_includes/appscms/customblog/contenttool-recent-posts.html +94 -94
  21. data/_includes/appscms/customblog/pageRelatedPosts.html +68 -68
  22. data/_includes/appscms/customblog/recentposts.html +67 -67
  23. data/_includes/appscms/customblog/relatedBlogs.html +82 -82
  24. data/_includes/appscms/customblog/relatedposts.html +193 -193
  25. data/_includes/appscms/extras/appscms-postbox.html +57 -57
  26. data/_includes/appscms/featurePageAuthors/featurePageAuthors.html +85 -85
  27. data/_includes/appscms/head/bloghead.html +128 -128
  28. data/_includes/appscms/headings/contenttool-headings.html +33 -33
  29. data/_includes/appscms/headings/devtool-headings.html +38 -38
  30. data/_includes/appscms/home/contenttool-feature-boxes.html +19 -19
  31. data/_includes/appscms/home/devtool-feature-boxes.html +70 -70
  32. data/_includes/appscms/infographics/infographics.html +241 -32
  33. data/_includes/appscms/loaders/loader.html +4 -4
  34. data/_includes/appscms/navbars/devtool-navbar.html +50 -50
  35. data/_includes/appscms/navbars/devtool-toolbar.html +100 -100
  36. data/_includes/appscms/navbars/navbar.html +129 -75
  37. data/_includes/appscms/navbars/toolbar.html +326 -139
  38. data/_includes/appscms/recent-posts/recent_posts.html +90 -90
  39. data/_includes/appscms/recent-posts/related_categories_post.html +194 -194
  40. data/_includes/appscms/searchbar/devtool-searchbar.html +63 -63
  41. data/_includes/appscms/usp/usp.html +90 -90
  42. data/_includes/author_bio.html +41 -41
  43. data/_includes/authorpagehead/index.html +47 -47
  44. data/_includes/authors/authors.html +39 -39
  45. data/_includes/batch-conversion.html +141 -141
  46. data/_includes/bookmark.html +6 -6
  47. data/_includes/cssfile/links.html +54 -54
  48. data/_includes/custom-head.html +138 -138
  49. data/_includes/customCode.html +1 -1
  50. data/_includes/customScripts.html +1 -1
  51. data/_includes/customblog/pageRelatedPosts.html +87 -87
  52. data/_includes/customblog/recentposts.html +67 -67
  53. data/_includes/customblog/relatedBlogs.html +86 -86
  54. data/_includes/customblog/relatedposts.html +201 -201
  55. data/_includes/dropdown/langdropdown.html +32 -32
  56. data/_includes/feature.html +39 -39
  57. data/_includes/featurePageAuthors/featurePageAuthors.html +101 -101
  58. data/_includes/footer/index.html +537 -537
  59. data/_includes/google-analytics.html +32 -32
  60. data/_includes/head/index.html +627 -627
  61. data/_includes/header/blogHeader.html +34 -34
  62. data/_includes/header/index.html +152 -152
  63. data/_includes/infographics/infographics.html +244 -244
  64. data/_includes/internationalization-section.html +64 -47
  65. data/_includes/paginationBlogPage.html +70 -70
  66. data/_includes/postbox.html +65 -65
  67. data/_includes/script.html +493 -493
  68. data/_includes/section/count.html +32 -32
  69. data/_includes/section/recent_posts.html +94 -94
  70. data/_includes/section/related_categories_post.html +196 -196
  71. data/_includes/share/socialshare.html +21 -21
  72. data/_includes/userTracking.html +14 -14
  73. data/_layouts/aboutUs.html +175 -175
  74. data/_layouts/allAuthors.html +131 -131
  75. data/_layouts/appscms-about.html +163 -163
  76. data/_layouts/appscms-audio.html +33 -33
  77. data/_layouts/appscms-author.html +436 -436
  78. data/_layouts/appscms-authors.html +145 -145
  79. data/_layouts/appscms-batch.html +141 -141
  80. data/_layouts/appscms-calculator.html +93 -93
  81. data/_layouts/appscms-categories.html +26 -26
  82. data/_layouts/appscms-contact.html +132 -132
  83. data/_layouts/appscms-disclaimer.html +124 -124
  84. data/_layouts/appscms-download.html +289 -289
  85. data/_layouts/appscms-feature-result.html +96 -96
  86. data/_layouts/appscms-help.html +25 -25
  87. data/_layouts/appscms-imagekit.html +96 -96
  88. data/_layouts/appscms-post.html +243 -243
  89. data/_layouts/appscms-privacy-policy.html +781 -781
  90. data/_layouts/appscms-terms-and-conditions.html +646 -646
  91. data/_layouts/appscms-video.html +33 -33
  92. data/_layouts/audio.html +33 -33
  93. data/_layouts/author.html +409 -409
  94. data/_layouts/batch.html +177 -177
  95. data/_layouts/blog-1.html +116 -116
  96. data/_layouts/blog.html +131 -131
  97. data/_layouts/calculator.html +99 -99
  98. data/_layouts/contenttool-feature.html +42 -42
  99. data/_layouts/contenttool-home.html +53 -53
  100. data/_layouts/devtool-blog.html +132 -132
  101. data/_layouts/devtool-feature.html +54 -54
  102. data/_layouts/devtool-home.html +53 -53
  103. data/_layouts/devtools.html +57 -57
  104. data/_layouts/feature-1.html +285 -285
  105. data/_layouts/feature.html +351 -351
  106. data/_layouts/featureResultPage.html +82 -82
  107. data/_layouts/frame.html +222 -222
  108. data/_layouts/home-1.html +186 -186
  109. data/_layouts/home.html +375 -375
  110. data/_layouts/homeResultPage.html +32 -32
  111. data/_layouts/imagekit.html +308 -308
  112. data/_layouts/photo-effects-home.html +190 -190
  113. data/_layouts/post.html +233 -233
  114. data/assets/.DS_Store +0 -0
  115. data/assets/app.js +75 -75
  116. data/assets/css/appscms-blog.css +505 -505
  117. data/assets/css/appscms-contenttool.css +1384 -1384
  118. data/assets/css/appscms-home.css +5 -5
  119. data/assets/css/appscms-imagekit.css +855 -855
  120. data/assets/css/appscms-theme.css +11 -251
  121. data/assets/css/appscms-variables.css +24 -24
  122. data/assets/css/blog.css +510 -510
  123. data/assets/css/calculators.css +46 -46
  124. data/assets/css/common.css +944 -944
  125. data/assets/css/devtool-main.css +1350 -1350
  126. data/assets/css/devtools.css +105 -105
  127. data/assets/css/feature-1.css +293 -293
  128. data/assets/css/home-1.css +188 -188
  129. data/assets/css/imagekit copy.css +848 -848
  130. data/assets/css/imagekit.css +848 -848
  131. data/assets/css/tools.css +1846 -1846
  132. data/assets/images/close-button.svg +31 -31
  133. data/assets/images/digipaint.svg +6 -6
  134. data/assets/images/iconn.svg +12 -12
  135. data/assets/images/logo.svg +2 -2
  136. data/assets/images/manthink.svg +3552 -3552
  137. data/assets/images/search-icon.svg +2 -2
  138. data/assets/js/appscms-infographics.js +49 -49
  139. data/assets/js/batch.js +219 -219
  140. data/assets/js/devtools.js +81 -81
  141. data/assets/js/sharePage.js +65 -65
  142. data/assets/js/usageTracking.js +143 -143
  143. data/assets/js/usageTrackingEvents.js +6 -6
  144. data/assets/js/webvitals.js +4 -4
  145. metadata +5 -3
@@ -1,3 +1,3 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
2
- <path fill-rule="evenodd" clip-rule="evenodd" d="M4 11C4 7.13401 7.13401 4 11 4C14.866 4 18 7.13401 18 11C18 14.866 14.866 18 11 18C7.13401 18 4 14.866 4 11ZM11 2C6.02944 2 2 6.02944 2 11C2 15.9706 6.02944 20 11 20C13.125 20 15.078 19.2635 16.6177 18.0319L20.2929 21.7071C20.6834 22.0976 21.3166 22.0976 21.7071 21.7071C22.0976 21.3166 22.0976 20.6834 21.7071 20.2929L18.0319 16.6177C19.2635 15.078 20 13.125 20 11C20 6.02944 15.9706 2 11 2Z" fill="#000000"/>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M4 11C4 7.13401 7.13401 4 11 4C14.866 4 18 7.13401 18 11C18 14.866 14.866 18 11 18C7.13401 18 4 14.866 4 11ZM11 2C6.02944 2 2 6.02944 2 11C2 15.9706 6.02944 20 11 20C13.125 20 15.078 19.2635 16.6177 18.0319L20.2929 21.7071C20.6834 22.0976 21.3166 22.0976 21.7071 21.7071C22.0976 21.3166 22.0976 20.6834 21.7071 20.2929L18.0319 16.6177C19.2635 15.078 20 13.125 20 11C20 6.02944 15.9706 2 11 2Z" fill="#000000"/>
3
3
  </svg>
@@ -1,49 +1,49 @@
1
- function openModal1(imageSrc) {
2
- var modal1 = document.getElementById("imageModal1");
3
- var modal1Img = document.getElementById("modal1Image");
4
- modal1.style.display = "block";
5
- modal1Img.src = imageSrc;
6
- }
7
- function closeModal1() {
8
- var modal1 = document.getElementById("imageModal1");
9
- modal1.style.display = "none";
10
- }
11
- document.addEventListener("click", function (event) {
12
- var modal1 = document.getElementById("imageModal1");
13
- if (event.target === modal1) {
14
- closeModal1();
15
- }
16
- });
17
- const carousel = document.querySelector(".carousel-inner"),
18
- firstImg = carousel.querySelectorAll("img")[0],
19
- arrowIcons = document.querySelectorAll(".wrapper i");
20
- const numImages = carousel.querySelectorAll("img").length;
21
- const isMobile = window.matchMedia("(max-width: 767px)").matches; // Check if screen width is less than or equal to 767px
22
- if (numImages > 3) {
23
- arrowIcons[1].style.display = "block";
24
- } else {
25
- arrowIcons[0].style.display = "none";
26
- arrowIcons[1].style.display = "none";
27
- }
28
- let isDragStart = false,
29
- isDragging = false,
30
- prevPageX,
31
- prevScrollLeft,
32
- positionDiff;
33
- const showHideIcons = () => {
34
- let scrollWidth = carousel.scrollWidth - carousel.clientWidth; // getting max scrollable width
35
- arrowIcons[0].style.display = carousel.scrollLeft == 0 ? "none" : "block";
36
- arrowIcons[1].style.display =
37
- carousel.scrollLeft == scrollWidth ? "none" : "block";
38
- };
39
- arrowIcons.forEach((icon) => {
40
- icon.addEventListener("click", () => {
41
- let firstImgWidth = firstImg.clientWidth + 40;
42
- const scrollAmount = icon.id === "left" ? -firstImgWidth : firstImgWidth;
43
- carousel.scrollBy({
44
- left: scrollAmount,
45
- behavior: "smooth",
46
- });
47
- setTimeout(() => showHideIcons(), 60); // calling showHideIcons after 60ms
48
- });
49
- });
1
+ function openModal1(imageSrc) {
2
+ var modal1 = document.getElementById("imageModal1");
3
+ var modal1Img = document.getElementById("modal1Image");
4
+ modal1.style.display = "block";
5
+ modal1Img.src = imageSrc;
6
+ }
7
+ function closeModal1() {
8
+ var modal1 = document.getElementById("imageModal1");
9
+ modal1.style.display = "none";
10
+ }
11
+ document.addEventListener("click", function (event) {
12
+ var modal1 = document.getElementById("imageModal1");
13
+ if (event.target === modal1) {
14
+ closeModal1();
15
+ }
16
+ });
17
+ const carousel = document.querySelector(".carousel-inner"),
18
+ firstImg = carousel.querySelectorAll("img")[0],
19
+ arrowIcons = document.querySelectorAll(".wrapper i");
20
+ const numImages = carousel.querySelectorAll("img").length;
21
+ const isMobile = window.matchMedia("(max-width: 767px)").matches; // Check if screen width is less than or equal to 767px
22
+ if (numImages > 3) {
23
+ arrowIcons[1].style.display = "block";
24
+ } else {
25
+ arrowIcons[0].style.display = "none";
26
+ arrowIcons[1].style.display = "none";
27
+ }
28
+ let isDragStart = false,
29
+ isDragging = false,
30
+ prevPageX,
31
+ prevScrollLeft,
32
+ positionDiff;
33
+ const showHideIcons = () => {
34
+ let scrollWidth = carousel.scrollWidth - carousel.clientWidth; // getting max scrollable width
35
+ arrowIcons[0].style.display = carousel.scrollLeft == 0 ? "none" : "block";
36
+ arrowIcons[1].style.display =
37
+ carousel.scrollLeft == scrollWidth ? "none" : "block";
38
+ };
39
+ arrowIcons.forEach((icon) => {
40
+ icon.addEventListener("click", () => {
41
+ let firstImgWidth = firstImg.clientWidth + 40;
42
+ const scrollAmount = icon.id === "left" ? -firstImgWidth : firstImgWidth;
43
+ carousel.scrollBy({
44
+ left: scrollAmount,
45
+ behavior: "smooth",
46
+ });
47
+ setTimeout(() => showHideIcons(), 60); // calling showHideIcons after 60ms
48
+ });
49
+ });
data/assets/js/batch.js CHANGED
@@ -1,219 +1,219 @@
1
- const getScript = document.currentScript;
2
- const pageTool = getScript.dataset.tool;
3
- const lang = getScript.dataset.lang;
4
- const inputBox = document.querySelector(".upload-btn");
5
- const addFiles = document.querySelector(".add-more-files");
6
- const fileDropBox = document.querySelector(".box");
7
- const workspace = document.querySelector(".workspace");
8
- const selectedFilesList = document.querySelector(".selectedFilesList");
9
- const downloadButton = document.querySelector("#download-button");
10
- const submitButton = document.querySelector("#submit-button");
11
- const showProcessingFiles = document.querySelector(".files-processing-list");
12
- let zipFileType = null;
13
- let renderFileTypes = null;
14
-
15
- const showLoader = () => {
16
- showLoading();
17
- };
18
- const closeLoader = () => {};
19
-
20
- fileDropBox.addEventListener("dragover", (e) => {
21
- e.preventDefault();
22
- });
23
- fileDropBox.addEventListener("drop", (e) => {
24
- e.preventDefault();
25
- handleFile(e.dataTransfer.files[0]);
26
- });
27
- const fileOnChange = () => {
28
- handleFile(file.files);
29
- };
30
- inputBox.onclick = function () {
31
- document.querySelector("#file").click();
32
- };
33
- const fileOnChange2 = () => {
34
- addMoreFiles(document.querySelector("#file2").files);
35
- };
36
- addFiles.onclick = function () {
37
- document.querySelector("#file2").click();
38
- };
39
- let files = [];
40
- let fileName = "";
41
- let blobList = [];
42
- const addMoreFiles = (addFiles) => {
43
- handleFile(addFiles);
44
- };
45
- const onSubmit = (files) => {
46
- blobList = [];
47
- Promise.all(
48
- files.map((item, index) => {
49
- document.querySelector(
50
- `#loader-${index}`
51
- ).innerHTML = `<span class="processing">processing</span>
52
- <div class="spinner-border" role="status"><span class="sr-only">Loading...</span></div>`;
53
- return new Promise((resolve, reject) => {
54
- batchConversion(item, index).then(([indexValue, blob, type]) => {
55
- blobList.push({ blob: blob, fileName: item });
56
- document.querySelector(
57
- `#loader-${indexValue}`
58
- ).innerHTML = `<span class="done">finished</span>`;
59
- document.querySelector(`#download-${indexValue}`).style.display =
60
- "inline-block";
61
- resolve();
62
- });
63
- }).catch((error) => {
64
- console.log(error);
65
- });
66
- })
67
- ).then(() => {
68
- document.querySelector(".bottom-section-container").style.display = "flex";
69
- document.querySelector(".bottom-section-container").style.padding =
70
- "20px .75rem";
71
- document.querySelector("#download-zip").style.display = "block";
72
- let zip = new JSZip();
73
- let zipFiles = zip.folder(`safeimagekit-batch-images`);
74
- blobList.map((item) => {
75
- zipFiles.file(
76
- `safeimagekit-batch-${item.fileName.name.split(".")[0]}.${
77
- zipFileType ? zipFileType : "png"
78
- }`,
79
- getBase64String(item.blob),
80
- { base64: true }
81
- );
82
- });
83
-
84
- document.querySelector("#download-zip").addEventListener("click", () => {
85
- zip.generateAsync({ type: "blob" }).then(function (content) {
86
- saveAs(content, `safeimagekit-batch-conversion.zip`);
87
- if (lang === "en") {
88
- window.location.href = `/download?tool=${pageTool}`;
89
- } else {
90
- window.location.href = `/${lang}/download?tool=${pageTool}`;
91
- }
92
- });
93
- });
94
- });
95
- };
96
- let renderFileTypesHtml = ` <option value="png">png</option>
97
- <option value="jpg">jpg</option>
98
- <option value="jpeg">jpeg</option>
99
- <option value="webp">webp</option>
100
- `;
101
-
102
- const renderFiles = (files) => {
103
- if (renderFileTypes !== null) {
104
- renderFileTypesHtml = "";
105
- renderFileTypes.map((i) => {
106
- renderFileTypesHtml += `<option value="${i}">${i}</option>`;
107
- });
108
- }
109
- files.map((file, index) => {
110
- if (file) {
111
- let filename = file.name;
112
- if (file.name.split(".")[0].length > 10) {
113
- let fName = file.name.split(".")[0];
114
- let fExtention = file.name.split(".")[1];
115
- filename =
116
- fName.substr(0, 9) + "..." + fName.substr(-3) + "." + fExtention;
117
- }
118
- let loader = "Ready";
119
- showProcessingFiles.innerHTML += `
120
- <tr>
121
- <th scope="row" class="file-icon-row">
122
- <img src="/assets/images/file.png" alt="file" class="file-icon">
123
- </th>
124
- <td class="fileName">${filename}</td>
125
- <td id=loader-${index} class="file-processing"><span class="ready">${loader}</span></td>
126
- <td>
127
- <div class="download-format ">
128
- <select name="image-format" id="image-format">
129
- ${renderFileTypesHtml}
130
- </select>
131
- </div>
132
-
133
- </td>
134
- <td class="file-download-button text-right">
135
- <button style="display:none;" id=download-${index} data-type="image" onclick="handleDownload(this)" class="btn download-file-btn">
136
- <svg class="download-icon" width="16px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"
137
- fill="currentColor">
138
- <path
139
- d="M18 20H5V15H6V19H17V15H18V20ZM12 4V15.19L14.3 13L15 13.6667L11.5 17L8 13.6667L8.7 13L11 15.19V4H12Z">
140
- </path>
141
- </svg> Download
142
- </button>
143
- </td>
144
- </tr>
145
- `;
146
- }
147
- });
148
- };
149
-
150
- const handleFile = (file) => {
151
- showProcessingFiles.innerHTML = "";
152
- if (file) {
153
- for (let i = 0; i < file.length; i++) {
154
- files.push(file[i]);
155
- stopLoading();
156
- workspace.style.display = "block";
157
- document.querySelector("#file").style.display = "block";
158
- let listItem = document.createElement("li");
159
- listItem.style.listStyle = "none";
160
- let getFileSize = formatBytes(file[i].size);
161
- listItem.innerHTML = `${file[i].name} (${getFileSize})`;
162
- // selectedFilesList.appendChild(listItem)
163
- }
164
- }
165
- renderFiles(files);
166
- submitButton.addEventListener("click", () => onSubmit(files));
167
- };
168
- const formatBytes = (bytes, decimals = 2) => {
169
- if (bytes === 0) return "0 Bytes";
170
-
171
- const k = 1024;
172
- const dm = decimals < 0 ? 0 : decimals;
173
- const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
174
-
175
- const i = Math.floor(Math.log(bytes) / Math.log(k));
176
-
177
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
178
- };
179
- const handleDownload = (e) => {
180
- let find = blobList[Number(e.id.replace(/^\D+/g, ""))].blob;
181
- let fileName = blobList[Number(e.id.replace(/^\D+/g, ""))].fileName.name;
182
-
183
- let format = document.querySelector("#image-format").value;
184
-
185
- switch (e.dataset.type) {
186
- case "image":
187
- let a = document.createElement("a");
188
- a.href = find;
189
- a.download = `safeimagekit-batch-${fileName.split(".")[0]}.${format}`;
190
- document.body.appendChild(a);
191
- a.click();
192
- break;
193
- default:
194
- break;
195
- }
196
- };
197
- const showLoading = () => {
198
- document.querySelector("#file-loader").style.display = "flex";
199
- document.querySelector(".file-input").style.display = "none";
200
- };
201
- const stopLoading = () => {
202
- fileDropBox.style.display = "none";
203
- };
204
-
205
- const getBase64String = (dataURL) => {
206
- const idx = dataURL.indexOf("base64,") + "base64,".length;
207
- return dataURL.substring(idx);
208
- };
209
- const dataURLtoBlob = (dataurl) => {
210
- let arr = dataurl.split(","),
211
- mime = arr[0].match(/:(.*?);/)[1],
212
- bstr = atob(arr[1]),
213
- n = bstr.length,
214
- u8arr = new Uint8Array(n);
215
- while (n--) {
216
- u8arr[n] = bstr.charCodeAt(n);
217
- }
218
- return new Blob([u8arr], { type: mime });
219
- };
1
+ const getScript = document.currentScript;
2
+ const pageTool = getScript.dataset.tool;
3
+ const lang = getScript.dataset.lang;
4
+ const inputBox = document.querySelector(".upload-btn");
5
+ const addFiles = document.querySelector(".add-more-files");
6
+ const fileDropBox = document.querySelector(".box");
7
+ const workspace = document.querySelector(".workspace");
8
+ const selectedFilesList = document.querySelector(".selectedFilesList");
9
+ const downloadButton = document.querySelector("#download-button");
10
+ const submitButton = document.querySelector("#submit-button");
11
+ const showProcessingFiles = document.querySelector(".files-processing-list");
12
+ let zipFileType = null;
13
+ let renderFileTypes = null;
14
+
15
+ const showLoader = () => {
16
+ showLoading();
17
+ };
18
+ const closeLoader = () => {};
19
+
20
+ fileDropBox.addEventListener("dragover", (e) => {
21
+ e.preventDefault();
22
+ });
23
+ fileDropBox.addEventListener("drop", (e) => {
24
+ e.preventDefault();
25
+ handleFile(e.dataTransfer.files[0]);
26
+ });
27
+ const fileOnChange = () => {
28
+ handleFile(file.files);
29
+ };
30
+ inputBox.onclick = function () {
31
+ document.querySelector("#file").click();
32
+ };
33
+ const fileOnChange2 = () => {
34
+ addMoreFiles(document.querySelector("#file2").files);
35
+ };
36
+ addFiles.onclick = function () {
37
+ document.querySelector("#file2").click();
38
+ };
39
+ let files = [];
40
+ let fileName = "";
41
+ let blobList = [];
42
+ const addMoreFiles = (addFiles) => {
43
+ handleFile(addFiles);
44
+ };
45
+ const onSubmit = (files) => {
46
+ blobList = [];
47
+ Promise.all(
48
+ files.map((item, index) => {
49
+ document.querySelector(
50
+ `#loader-${index}`
51
+ ).innerHTML = `<span class="processing">processing</span>
52
+ <div class="spinner-border" role="status"><span class="sr-only">Loading...</span></div>`;
53
+ return new Promise((resolve, reject) => {
54
+ batchConversion(item, index).then(([indexValue, blob, type]) => {
55
+ blobList.push({ blob: blob, fileName: item });
56
+ document.querySelector(
57
+ `#loader-${indexValue}`
58
+ ).innerHTML = `<span class="done">finished</span>`;
59
+ document.querySelector(`#download-${indexValue}`).style.display =
60
+ "inline-block";
61
+ resolve();
62
+ });
63
+ }).catch((error) => {
64
+ console.log(error);
65
+ });
66
+ })
67
+ ).then(() => {
68
+ document.querySelector(".bottom-section-container").style.display = "flex";
69
+ document.querySelector(".bottom-section-container").style.padding =
70
+ "20px .75rem";
71
+ document.querySelector("#download-zip").style.display = "block";
72
+ let zip = new JSZip();
73
+ let zipFiles = zip.folder(`safeimagekit-batch-images`);
74
+ blobList.map((item) => {
75
+ zipFiles.file(
76
+ `safeimagekit-batch-${item.fileName.name.split(".")[0]}.${
77
+ zipFileType ? zipFileType : "png"
78
+ }`,
79
+ getBase64String(item.blob),
80
+ { base64: true }
81
+ );
82
+ });
83
+
84
+ document.querySelector("#download-zip").addEventListener("click", () => {
85
+ zip.generateAsync({ type: "blob" }).then(function (content) {
86
+ saveAs(content, `safeimagekit-batch-conversion.zip`);
87
+ if (lang === "en") {
88
+ window.location.href = `/download?tool=${pageTool}`;
89
+ } else {
90
+ window.location.href = `/${lang}/download?tool=${pageTool}`;
91
+ }
92
+ });
93
+ });
94
+ });
95
+ };
96
+ let renderFileTypesHtml = ` <option value="png">png</option>
97
+ <option value="jpg">jpg</option>
98
+ <option value="jpeg">jpeg</option>
99
+ <option value="webp">webp</option>
100
+ `;
101
+
102
+ const renderFiles = (files) => {
103
+ if (renderFileTypes !== null) {
104
+ renderFileTypesHtml = "";
105
+ renderFileTypes.map((i) => {
106
+ renderFileTypesHtml += `<option value="${i}">${i}</option>`;
107
+ });
108
+ }
109
+ files.map((file, index) => {
110
+ if (file) {
111
+ let filename = file.name;
112
+ if (file.name.split(".")[0].length > 10) {
113
+ let fName = file.name.split(".")[0];
114
+ let fExtention = file.name.split(".")[1];
115
+ filename =
116
+ fName.substr(0, 9) + "..." + fName.substr(-3) + "." + fExtention;
117
+ }
118
+ let loader = "Ready";
119
+ showProcessingFiles.innerHTML += `
120
+ <tr>
121
+ <th scope="row" class="file-icon-row">
122
+ <img src="/assets/images/file.png" alt="file" class="file-icon">
123
+ </th>
124
+ <td class="fileName">${filename}</td>
125
+ <td id=loader-${index} class="file-processing"><span class="ready">${loader}</span></td>
126
+ <td>
127
+ <div class="download-format ">
128
+ <select name="image-format" id="image-format">
129
+ ${renderFileTypesHtml}
130
+ </select>
131
+ </div>
132
+
133
+ </td>
134
+ <td class="file-download-button text-right">
135
+ <button style="display:none;" id=download-${index} data-type="image" onclick="handleDownload(this)" class="btn download-file-btn">
136
+ <svg class="download-icon" width="16px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"
137
+ fill="currentColor">
138
+ <path
139
+ d="M18 20H5V15H6V19H17V15H18V20ZM12 4V15.19L14.3 13L15 13.6667L11.5 17L8 13.6667L8.7 13L11 15.19V4H12Z">
140
+ </path>
141
+ </svg> Download
142
+ </button>
143
+ </td>
144
+ </tr>
145
+ `;
146
+ }
147
+ });
148
+ };
149
+
150
+ const handleFile = (file) => {
151
+ showProcessingFiles.innerHTML = "";
152
+ if (file) {
153
+ for (let i = 0; i < file.length; i++) {
154
+ files.push(file[i]);
155
+ stopLoading();
156
+ workspace.style.display = "block";
157
+ document.querySelector("#file").style.display = "block";
158
+ let listItem = document.createElement("li");
159
+ listItem.style.listStyle = "none";
160
+ let getFileSize = formatBytes(file[i].size);
161
+ listItem.innerHTML = `${file[i].name} (${getFileSize})`;
162
+ // selectedFilesList.appendChild(listItem)
163
+ }
164
+ }
165
+ renderFiles(files);
166
+ submitButton.addEventListener("click", () => onSubmit(files));
167
+ };
168
+ const formatBytes = (bytes, decimals = 2) => {
169
+ if (bytes === 0) return "0 Bytes";
170
+
171
+ const k = 1024;
172
+ const dm = decimals < 0 ? 0 : decimals;
173
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
174
+
175
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
176
+
177
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
178
+ };
179
+ const handleDownload = (e) => {
180
+ let find = blobList[Number(e.id.replace(/^\D+/g, ""))].blob;
181
+ let fileName = blobList[Number(e.id.replace(/^\D+/g, ""))].fileName.name;
182
+
183
+ let format = document.querySelector("#image-format").value;
184
+
185
+ switch (e.dataset.type) {
186
+ case "image":
187
+ let a = document.createElement("a");
188
+ a.href = find;
189
+ a.download = `safeimagekit-batch-${fileName.split(".")[0]}.${format}`;
190
+ document.body.appendChild(a);
191
+ a.click();
192
+ break;
193
+ default:
194
+ break;
195
+ }
196
+ };
197
+ const showLoading = () => {
198
+ document.querySelector("#file-loader").style.display = "flex";
199
+ document.querySelector(".file-input").style.display = "none";
200
+ };
201
+ const stopLoading = () => {
202
+ fileDropBox.style.display = "none";
203
+ };
204
+
205
+ const getBase64String = (dataURL) => {
206
+ const idx = dataURL.indexOf("base64,") + "base64,".length;
207
+ return dataURL.substring(idx);
208
+ };
209
+ const dataURLtoBlob = (dataurl) => {
210
+ let arr = dataurl.split(","),
211
+ mime = arr[0].match(/:(.*?);/)[1],
212
+ bstr = atob(arr[1]),
213
+ n = bstr.length,
214
+ u8arr = new Uint8Array(n);
215
+ while (n--) {
216
+ u8arr[n] = bstr.charCodeAt(n);
217
+ }
218
+ return new Blob([u8arr], { type: mime });
219
+ };