Skip to content

Commit

Permalink
Merge pull request #82 from fred913/main
Browse files Browse the repository at this point in the history
feat: credits
  • Loading branch information
fred913 authored Jul 3, 2023
2 parents 7d33399 + c502c72 commit 60fcf9e
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The counter has paused, awaiting additional remediation measures, as a result of
[![Chat on Discord](https://img.shields.io/badge/chat-discord-blue?style=flat&logo=discord)](https://discord.gg/yzkEz6xxdM)

# Herta Kuru | 黑塔转圈圈 | ヘルタクルへ
[Home Page | 主页 | ホーム ページ](https://duiqt.github.io/herta_kuru)
[Home Page | 主页 | ホーム ページ (Netlify)](https://herta.ft2.ltd/)

Herta GIF and art made by | 黑塔 GIF 绘画者 : [@Seseren_kr](https://twitter.com/Seseren_kr)

Expand Down
7 changes: 4 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<title id="doc-title">Kuru Kuru~</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<link rel="stylesheet" href="static/css/style.css" type="text/css" />
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/ionicons/4.6.1/css/ionicons.min.css">
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/mdui/1.0.2/css/mdui.min.css" />
<link rel="stylesheet" href="https://unpkg.com/ionicons@4.5.10-0/dist/css/ionicons.min.css">
<!-- <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/fontawesome.min.css"> -->
<link rel="stylesheet" href="https://unpkg.com/mdui@1.0.2/dist/css/mdui.min.css" />
<link href="static/img/favicon.ico" rel="shortcut icon">
</head>

Expand Down Expand Up @@ -75,7 +76,7 @@ <h3 id="counter-descriptions">The kuru~ has been squished</h3>
</div>
</div>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/mdui/1.0.2/js/mdui.min.js"></script>
<script src="https://unpkg.com/mdui@1.0.2/dist/js/mdui.min.js"></script>
<script src="static/js/script.js" async></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-T303QPC9L9"></script>
Expand Down
11 changes: 10 additions & 1 deletion static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ h2 {
}

#counter-button {
visibility: hidden;
background-color: #574f84;
border: none;
border-radius: 16px;
Expand Down Expand Up @@ -358,4 +359,12 @@ h2 {
/* position: absolute; */
top: 0px;
left: 0px;
}
}

/* .bili-icon {
background: url('https://www.bilibili.com/favicon.ico');
display: block;
width: 32px;
height: 32px;
float: right;
} */
55 changes: 55 additions & 0 deletions static/js/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
async function convertMp3FilesToBase64(dict) {
const promises = [];
for (const lang in dict) {
if (dict.hasOwnProperty(lang)) {
const audioList = dict[lang].audioList;
if (Array.isArray(audioList)) {
for (let i = 0; i < audioList.length; i++) {
const url = audioList[i];
if (typeof url === "string" && url.endsWith(".mp3")) {
promises.push(loadAndEncode("static/" + url).then(result => dict[lang].audioList[i] = result));
}
}
}
}
}
await Promise.all(promises);
return dict;
}

function loadAndEncode(url) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = "arraybuffer";
xhr.onload = function () {
if (xhr.status === 200) {
const buffer = xhr.response;
const blob = new Blob([buffer], { type: "audio/mpeg" });
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function () {
const base64data = reader.result;
resolve(base64data);
}
} else {
reject(xhr.statusText);
}
};
xhr.onerror = function () {
reject(xhr.statusText);
};
xhr.send();
});
}

window.onload = function () {
// Calling method
convertMp3FilesToBase64(LANGUAGES).then(() => {
// show counter-button
document.getElementById('counter-button').style.visibility = 'visible';
// Other operations on dict or passed to other functions for processing
}).catch(error => {
console.error(error);
});
}
8 changes: 5 additions & 3 deletions static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,14 @@ const progress = [0, 1];
});
};

// NOTE the deployment on Github pages is stopped and deprecated. This tip is not useful anymore.

// NOTE the deployment on Github pages is stopped and deprecated.
// TODO Waiting for decision as the final production website
// if (location.hostname.endsWith("duiqt.github.io")) {
// window.location.href = "https://herta.onrender.com";
// window.location.href = "https://herta.ft2.ltd";
// }

// This function create bilibili icon in 2 cases: activated & inactivated
// A fun manual implementation for integration between MDUI and Font-Awesome
function bilibiliIcon(color) {
return `<i class="mdui-list-item-icon mdui-icon">
<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512" style="fill: ${color};">
Expand Down

0 comments on commit 60fcf9e

Please sign in to comment.