Initial commit

This commit is contained in:
2023-02-15 10:38:53 +05:30
commit bfc107e7e1
5 changed files with 206 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
const { createApp } = Vue;
const fontsMap = {
ambili: "FML-TTambili",
charaka: "FML-TTRevathi",
haritha: "haritha",
indulekha: "FML-TTindulekha",
karthika: "FML-TTkarthika",
manorama: "manorama",
matweb: "matweb",
nandini: "FML-TTnandini",
panchari: "panchari",
revathi: "FML-TTrevathi",
uma: "FML-TTkaumudi",
};
createApp({
data() {
return {
form: {
text: `ചെണ്ടമേളം
കുഞ്ചൻ നമ്പ്യാർ
മഞ്ഞൾ പ്രസാദം
തിങ്കളാഴ്ച
`,
font: "karthika",
},
allFonts: Object.keys(fontsMap),
asciiTxt: "",
asciiFont: "",
};
},
methods: {
async onSubmit() {
const res = await fetch("/api/a2u", {
method: "post",
body: JSON.stringify(this.form),
headers: {
"Content-type": "application/json",
},
});
const data = await res.json();
this.asciiTxt = data.ascii;
this.asciiFont = fontsMap[this.form.font];
},
correctOldChillu(e) {
return (e = e
.replace("ൺ", "ണ്‍")
.replace("ൻ", "ന്‍")
.replace("ർ", "ര്‍")
.replace("ൽ", "ല്‍")
.replace("ൾ", "ള്‍")
.replace("ോ", "ോ")
.replace("ൊ", "ൊ"));
},
correctNewChillu(e) {
return (e = e
.replaceAll("ണ്‍", "ൺ")
.replaceAll("ന്‍", "ൻ")
.replaceAll("ര്‍", "ർ")
.replaceAll("ല്‍", "ൽ")
.replaceAll("ള്‍", "ൾ")
.replaceAll("ോ", "ോ")
.replaceAll("ൊ", "ൊ")
.replaceAll("", "0")
.replaceAll("൧", "1")
.replaceAll("൨", "2")
.replaceAll("൩", "3")
.replaceAll("൪", "4")
.replaceAll("൫", "5")
.replaceAll("൬", "6")
.replaceAll("", "7")
.replaceAll("൮", "8")
.replaceAll("൯", "9"));
},
},
}).mount("#app");
+29
View File
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Ascii to unicode converter</title>
<link rel="stylesheet" href="https://unpkg.com/mvp.css@1.12/mvp.css" />
<style type="text/css" media="screen">
</style>
</head>
<body>
<main id="app">
<hr />
<form accept-charset="utf-8" v-on:submit.prevent="onSubmit">
<select v-model="form.font">
<option v-for="font in allFonts" :value="font">{{font}}</option>
</select>
<textarea v-model="form.text" rows="4">
</textarea>
<button type="submit">Submit</button>
<textarea rows="8" :style="{'font-family': asciiFont}" v-model="asciiTxt" ></textarea>
</form>
</main>
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<script src="./app.js" charset="utf-8"></script>
</body>
</html>