X-Git-Url: https://git.mdrn.pl/wl-app.git/blobdiff_plain/48b2fe9f7c2dc3d9aeaaa6dbfb27c7da4f3235ff..269195b3729c1bdc22e9053ee4ebca667ea8549d:/Android/webViewMarker/src/main/assets/jpntext.js diff --git a/Android/webViewMarker/src/main/assets/jpntext.js b/Android/webViewMarker/src/main/assets/jpntext.js new file mode 100755 index 0000000..72c76fe --- /dev/null +++ b/Android/webViewMarker/src/main/assets/jpntext.js @@ -0,0 +1,47 @@ +var jpntext = (function() { + var global = { + KIND: { + 'mix': 0, + 'ascii': 1, + 'hira': 2, + 'kata': 3, + 'cjk': 4 + }, + kind: function(text) { + var result; + if (global.isAscii(text)) { + result = 'ascii'; + } + else if (global.isHiragana(text)) { + result = 'hira'; + } + else if (global.isKatakana(text)) { + result = 'kata'; + } + else if (global.isKanji(text)) { + result = 'cjk'; + } + else { + result = 'mix'; + } + return global.KIND[result]; + }, + isAscii: function(text) { + var re = /^[\u0000-\u00ff]+$/; + return re.test(text); + }, + isKanji: function(text) { + var re = /^([\u4e00-\u9fcf]|[\u3400-\u4dbf]|[\u20000-\u2a6df]|[\uf900-\ufadf])+$/; + return re.test(text); + }, + isHiragana: function(text) { + var re = /^[\u3040-\u309f]+$/; + return re.test(text) + }, + isKatakana: function(text) { + var re = /^[\u30a0-\u30ff]+$/; + return re.test(text); + } + }; + return global; +})();