Skip to content

Commit

Permalink
add Korean support. (no audio yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
duiqt committed May 28, 2023
1 parent e837cd1 commit f23b094
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
Binary file added audio/kr/kuru1.mp3
Binary file not shown.
Binary file added audio/kr/kuru2.mp3
Binary file not shown.
Binary file added audio/kr/kuruto.mp3
Binary file not shown.
Binary file added img/card_kr.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ <h1 id="page-title">Welcome to herta kuru</h1>
<option value="en" selected>English</option>
<option value="cn">中文</option>
<option value="ja">日本語</option>
<option value="kr">한국어</option>
</select>


Expand Down
53 changes: 38 additions & 15 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,34 @@ const LANGUAGES = {
"footer-repository-text-2": "herta_kuru リポジトリ"
},
cardImage: "img/card_ja.jpg"
},
"kr": {
audioList: [
"audio/kr/kuruto.mp3",
"audio/kr/kuru1.mp3",
"audio/kr/kuru2.mp3",
],
texts: {
"page-title": "헤르타빙글 환영합니다~",
"doc-title": "빙글 빙글~",
"page-descriptions": "이 웹사이트는 헤르타를 위해 만들어졌습니다, 붕괴: 스타레일 의 <del>귀찮은</del> 귀여운 천재 ",
// TODO dynamic texts for Korean
"counter-descriptions": "전 세계 빙글 조회수",
"counter-unit": "번",
"counter-button": "빙글 빙글~!",
"credits-gif": "gif의 제작자입니다",
"footer-repository-text": "여기 github 리 포지 토리가 있습니다:",
"footer-repository-text-2": "herta_kuru 리 포지 토리"
},
cardImage: "img/card_kr.jpg"
}
// TODO Korean (text&voice&card) support
};

var current_language = localStorage.getItem("lang") || "en";
if (current_language != "en") {
document.getElementById("language-selector").value = current_language;
}
};

function reload_language() {
let curLang = LANGUAGES[current_language];
let localTexts = curLang.texts;
Expand All @@ -80,7 +101,8 @@ function reload_language() {
});
refreshDynamicTexts()
document.getElementById("herta-card").src = curLang.cardImage;
}
};

reload_language()
document.getElementById("language-selector").addEventListener("change", (ev) => {
current_language = ev.target.value;
Expand All @@ -90,7 +112,7 @@ document.getElementById("language-selector").addEventListener("change", (ev) =>

function getLocalAudioList() {
return LANGUAGES[current_language].audioList;
}
};
//end language support

const getTimestamp = () => Date.parse(new Date());
Expand Down Expand Up @@ -128,7 +150,7 @@ function getGlobalCount(duration = null, callback = null) {
})();
})
.catch((err) => console.error(err));
}
};
// initialize counters
localCounter.textContent = localCount.toLocaleString('en-US');

Expand All @@ -143,7 +165,8 @@ function updateGlobalCount(first = false) {
} else {
setTimeout(updateGlobalCount, 1000); // check it 1sec later
}
}
};

updateGlobalCount(true);

function update(e, resetCount = true) {
Expand All @@ -166,7 +189,7 @@ function update(e, resetCount = true) {
if (resetCount) heldCount = 0;
})
.catch((err) => console.error(err));
}
};

let timer;

Expand Down Expand Up @@ -220,25 +243,25 @@ function tryCachedObject(origUrl) {
});
return origUrl;
}
}
};

function randomChoice(myArr) {
const randomIndex = Math.floor(Math.random() * myArr.length);
const randomItem = myArr[randomIndex];
return randomItem;
}
};

function getRandomAudioUrl() {
var localAudioList = getLocalAudioList()
if (current_language == "en" || current_language == "ja") {
if (current_language == "en" || current_language == "ja" || current_language == "kr") {
const randomIndex = Math.floor(Math.random() * 2) + 1; //kuruto audio only play once at first squish
const randomItem = localAudioList[randomIndex];
return randomItem;
}
const randomIndex = Math.floor(Math.random() * localAudioList.length);
const randomItem = localAudioList[randomIndex];
return randomItem;
}
};

function playKuru() {
let audioUrl;
Expand All @@ -257,7 +280,7 @@ function playKuru() {
audio.addEventListener("ended", function () {
this.remove();
});
}
};

function animateHerta() {
let id = null;
Expand All @@ -283,7 +306,7 @@ function animateHerta() {
elem.style.right = pos + 'px';
}
}, 12);
}
};

function triggerRipple(e) {
let ripple = document.createElement("span");
Expand All @@ -302,7 +325,7 @@ function triggerRipple(e) {
setTimeout(() => {
ripple.remove();
}, 300);
}
};
//end counter button

function refreshDynamicTexts() {
Expand All @@ -312,4 +335,4 @@ function refreshDynamicTexts() {
if (value instanceof Array)
document.getElementById(textId).innerHTML = randomChoice(value);
});
}
};

0 comments on commit f23b094

Please sign in to comment.