Files
tar-valon-ansible/app-configs/rinoa/gitea/public/encode.js
T
Trez.One 0cc4362a23
Gitea Branch PR & Ansible Deployment / Check and Create PR (push) Successful in 19s
Gitea Branch PR & Ansible Deployment / Ansible Dry Run (rikku) (push) Successful in 2m51s
Gitea Branch PR & Ansible Deployment / Ansible Dry Run (benedikta) (push) Successful in 4m8s
Gitea Branch PR & Ansible Deployment / Ansible Dry Run (rinoa) (push) Successful in 4m43s
Gitea Branch PR & Ansible Deployment / PR Merge (push) Successful in 16s
Gitea Branch PR & Ansible Deployment / Ansible Config Deployment (benedikta) (push) Successful in 3m29s
Gitea Branch PR & Ansible Deployment / Ansible Config Deployment (rikku) (push) Successful in 3m1s
Gitea Branch PR & Ansible Deployment / Ansible Config Deployment (rinoa) (push) Successful in 5m29s
Adding CSS for themes and PlantUML integration for Gitea.
2025-10-03 10:26:25 -04:00

52 lines
1.0 KiB
JavaScript
Executable File

/** Functions from https://plantuml.com/code-javascript-synchronous
*/
function encode64(data) {
r = "";
for (i=0; i<data.length; i+=3) {
if (i+2==data.length) {
r +=append3bytes(data.charCodeAt(i), data.charCodeAt(i+1), 0);
} else if (i+1==data.length) {
r += append3bytes(data.charCodeAt(i), 0, 0);
} else {
r += append3bytes(data.charCodeAt(i), data.charCodeAt(i+1),
data.charCodeAt(i+2));
}
}
return r;
}
function append3bytes(b1, b2, b3) {
c1 = b1 >> 2;
c2 = ((b1 & 0x3) << 4) | (b2 >> 4);
c3 = ((b2 & 0xF) << 2) | (b3 >> 6);
c4 = b3 & 0x3F;
r = "";
r += encode6bit(c1 & 0x3F);
r += encode6bit(c2 & 0x3F);
r += encode6bit(c3 & 0x3F);
r += encode6bit(c4 & 0x3F);
return r;
}
function encode6bit(b) {
if (b < 10) {
return String.fromCharCode(48 + b);
}
b -= 10;
if (b < 26) {
return String.fromCharCode(65 + b);
}
b -= 26;
if (b < 26) {
return String.fromCharCode(97 + b);
}
b -= 26;
if (b == 0) {
return '-';
}
if (b == 1) {
return '_';
}
return '?';
}