Repos / gorts / e8a3593318
commit e8a3593318420527ee84ea29dd69fce3f8b7725a
Author: Nhân <hi@imnhan.com>
Date: Fri Jun 16 21:53:53 2023 +0700
country magic
diff --git a/web/index.js b/web/index.js
index ab93e09..6f3ed00 100644
--- a/web/index.js
+++ b/web/index.js
@@ -20,6 +20,16 @@ const getDiff = (newState, oldState) => {
return diff;
};
+// Thanks internets:
+// https://dev.to/jorik/country-code-to-flag-emoji-a21
+function getFlagEmoji(countryCode) {
+ const codePoints = countryCode
+ .toUpperCase()
+ .split("")
+ .map((char) => 127397 + char.charCodeAt());
+ return String.fromCodePoint(...codePoints);
+}
+
const drawDiffToDom = (diff) => {
Object.keys(diff).forEach((key) => {
const element = document.querySelector(`#${key}`);
@@ -35,6 +45,13 @@ const drawDiffToDom = (diff) => {
element.innerHTML = newValue;
};
+ // Country needs to be converted from code to flag emoji
+ if (key === "p1country" || key === "p2country") {
+ updateFunc = () => {
+ element.innerHTML = getFlagEmoji(newValue);
+ };
+ }
+
fadeUpdate(element, newValue, updateFunc);
});
};
diff --git a/web/state.json b/web/state.json
index b66d8f0..6358e75 100644
--- a/web/state.json
+++ b/web/state.json
@@ -1,11 +1,11 @@
{
- "description": "asdfasdf",
- "p1name": "CYG BST | | Fuudo",
- "p1country": "🇯🇵",
- "p1team": "",
+ "description": "Saigon Cup 2023",
+ "p1name": "BST CYG Diego Umejuarez",
+ "p1country": "jp",
+ "p1team": "Team Japan",
"p1score": 6,
- "p2name": "B.O.B | Xiaobao",
- "p2country": "🇯🇵",
+ "p2name": "Jiyuner",
+ "p2country": "us",
"p2score": 1,
- "p2team": ""
+ "p2team": "Team Japan2"
}