Git Product home page Git Product logo

autokana2-vanilla's Introduction

autoKana2-vanilla

自動フリガナ入力をするVanilla JSライブラリ


Vanilla JS リメイク版 "jquery.autoKana2.js".

概要

このJavascriptは、Very Pinchさんが作成した、autoKana2 1.0.31 を、Vanilla JS (ライブラリに依存しない素のJavascript)にリメイクしたものです。

jQueryがなくても動作し、他のライブラリやテンプレートと競合しません。

入力欄Aに対して入力された文字のカナを自動的に取り出して入力欄Bに反映します。

Download

ダウンロードしたdist/autoKana2-vanilla.min.jsを自身の使用したいディレクトリに配置して使用して下さい。

CDNを利用すると、jsファイルの設置は不要になります。

Usage

  • local
<script src="autoKana2-vanilla.min.js"></script>
  • CDN
<script src="//cdn.jsdelivr.net/gh/GakutoMatsumura/autoKana2-vanilla@main/dist/autoKana2-vanilla.min.js"></script>
<input id="kanji_input_id" name="kanji" type="text">
<input id="kana_input_id" name="kana" type="text">
<script>
document.addEventListener("DOMContentLoaded", function(e) {
	autoKana("#kanji_input_id","#kana_input_id", {
		katakana: true,
		notSupportAlert: false,
		emptyInputCallback: function () { return true; }//戻り値にtrueを指定すると、空欄時にカナ欄をリセット。falseを指定するとそのまま過去のカナが残る
	});
});
</script>

Settings

Option Type Default Description
katakana bool true カタカナにする。falseでひらがなに。
notSupportAlert bool false ルビ変換がサポート外の場合にアラートを出す。
emptyInputCallback function return true trueを返す場合に、入力欄が空の場合カナ欄も空にリセットする。

autoKana2からの変更点

  • jQuery不要
  • emptyInputCallbackの戻り値がtrueの場合、バックスペースやデリート時に、入力欄が空の場合カナ欄も空にリセットする
  • かな入力における、濁点半濁点がカナ欄に適用されるように修正
  • かな入力における、全角の濁点半濁点文字「゛゜」があると変換がストップしてしまう問題の修正
  • サポート外の際、アラートを出すかどうかのオプションを追加

Demonstration

demo.html sample page (en.thilmera.com)

demo.html source

demo.cdn.html source

Author

Vanilla JS リメイクバージョン

  • Gakuto Matsumura

project site : t7GithubJS (en.thilmera.com)

Origin

  • Very.Pinch

origin repository link

thank you.

LICENSE

MIT License

autokana2-vanilla's People

Contributors

gakutomatsumura avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.