Last active
August 29, 2015 14:05
-
-
Save greenlikeorange/d88eff260dc1fddaf9c7 to your computer and use it in GitHub Desktop.
Myanmar Blacklist words
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang='my'> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
body { | |
font-family: Padauk; | |
} | |
#blacklist { | |
width: 100%; | |
resize: none; | |
font-family: Padauk; | |
} | |
button { | |
font-family: Padauk; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>ဗမာ "ပယ်" စာလုံးများ</h1> | |
<ul> | |
<li>ယူနီကုတ်ဖြင့်သာ ဖြစ်သည်</li> | |
<li>Javascript RegExp ကိုအသုံးပြုထားသည်</li> | |
<li>code အားလွတ်လပ်စာ ကူယူနိုင်သည်</li> | |
<li>ကျေးဇူးပြု၍ ထပ်ထည့်လိုသော စာလုံးများရှိပါက myanmarltt@gmail.com ပေးပို့ပါရန်</li> | |
</ul> | |
<textarea name="blacklisttest" id="blacklist" cols="30" rows="10"></textarea> | |
<button id="getfullist">စာလုံးအားလုံး ကြည့်ရန်</button> | |
<div id='fullist'></div> | |
<script id="jsbin-javascript"> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
font-family: Padauk; | |
} | |
#blacklist { | |
width: 100%; | |
resize: none; | |
font-family: Padauk; | |
} | |
button { | |
font-family: Padauk; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var single = "လီး|လိုး|စောက်|မသာ".split("|"); | |
// Bind is depended wods, they didn't match without pre | |
var pre = "လီး|လိုး|စောက်|ခွေး".split("|"); | |
var bind = "%1မသား".split("|"); | |
var listSingle = single; | |
var listBinded = []; | |
// Populate bind list | |
for(var i = 0; i < bind.length; i++ ) { | |
for(var j = 0; j < pre.length; j++){ | |
listBinded.push(bind[i].replace("%1", pre[j])); | |
} | |
} | |
// Genereate list to regexp | |
var rexBinded = new RegExp(listBinded.join("|")); | |
var rexSingle = new RegExp(listSingle.join("|")); | |
// DOM work flow | |
var txt = document.getElementById("blacklist"); | |
var fullist = document.getElementById("fullist"); | |
var getfullist = document.getElementById("getfullist"); | |
txt.addEventListener("keyup", | |
function(eve){ | |
var match; | |
console.log(txt.value); | |
while( (match = txt.value.match(rexBinded)) ) { | |
txt.value = txt.value.replace(match[0], "**"); | |
} | |
while( (match = txt.value.match(rexSingle)) ) { | |
txt.value = txt.value.replace(match[0], "**"); | |
} | |
}, | |
false); | |
getfullist.addEventListener("click", | |
function(eve){ | |
console.log("get"); | |
fullist.innerHTML = "<h2>စာလုံးများ</h2>"; | |
var ul = document.createElement('div'); | |
ul.setAttribute('class', 'the-list'); | |
listSingle.forEach(function(w,i){ | |
ul.innerHTML += "<div class='word'>"+w+"</div>"; | |
}); | |
listBinded.forEach(function(w,i){ | |
ul.innerHTML += "<div class='word'>"+w+"</div>"; | |
}); | |
fullist.appendChild(ul); | |
}, | |
false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment