Skip to content

Commit

Permalink
style: rename function name
Browse files Browse the repository at this point in the history
  • Loading branch information
52funny authored and 52funny committed Jul 22, 2024
1 parent 1b8d8cb commit 7c0e5af
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,6 @@ let $userBtn;
*/
let $userName;

// Parsing base64 strings with Unicode characters
function decodeBase64WithUnicode(base64String) {
const binString = atob(base64String);
const len = binString.length;
const bytes = new Uint8Array(len);
const arr = new Uint32Array(bytes.buffer, 0, Math.floor(len / 4));
let i = 0;
for (; i < arr.length; i++) {
arr[i] = binString.charCodeAt(i * 4) |
(binString.charCodeAt(i * 4 + 1) << 8) |
(binString.charCodeAt(i * 4 + 2) << 16) |
(binString.charCodeAt(i * 4 + 3) << 24);
}
for (i = i * 4; i < len; i++) {
bytes[i] = binString.charCodeAt(i);
}
return new TextDecoder().decode(bytes);
}

// Produce table when window loads
window.addEventListener("DOMContentLoaded", async () => {
const $indexData = document.getElementById('index-data');
Expand All @@ -127,7 +108,7 @@ window.addEventListener("DOMContentLoaded", async () => {
return;
}

DATA = JSON.parse(decodeBase64WithUnicode($indexData.innerHTML));
DATA = JSON.parse(decodeBase64($indexData.innerHTML));
DIR_EMPTY_NOTE = PARAMS.q ? 'No results' : DATA.dir_exists ? 'Empty folder' : 'Folder will be created when a file is uploaded';

await ready();
Expand Down Expand Up @@ -929,3 +910,22 @@ function getEncoding(contentType) {
}
return 'utf-8';
}

// Parsing base64 strings with Unicode characters
function decodeBase64(base64String) {
const binString = atob(base64String);
const len = binString.length;
const bytes = new Uint8Array(len);
const arr = new Uint32Array(bytes.buffer, 0, Math.floor(len / 4));
let i = 0;
for (; i < arr.length; i++) {
arr[i] = binString.charCodeAt(i * 4) |
(binString.charCodeAt(i * 4 + 1) << 8) |
(binString.charCodeAt(i * 4 + 2) << 16) |
(binString.charCodeAt(i * 4 + 3) << 24);
}
for (i = i * 4; i < len; i++) {
bytes[i] = binString.charCodeAt(i);
}
return new TextDecoder().decode(bytes);
}

0 comments on commit 7c0e5af

Please sign in to comment.