js拼音输入法模型


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>easy-pinyin</title>
<script src="pinyin_dict_notone.js"></script>
<style>
body{ line-height:33px;}
</style>
<script>
/*for(var key in pinyin_dict_notone){  
    document.write("'"+key+"',"); 
}*/


var zimu='abcdefghjklmnopqrstwxyz'.split('');

for(var i=0;i<zimu.length;i++){
    document.write('<button onclick="hhh(\''+zimu[i]+'\')">'+zimu[i]+'</button>');
}

function hhh(x){
    var a=eval('pinyin.'+x+'.split("|")');
    var temp='';
    for(var i=0;i<a.length;i++){
        temp += '<button onclick="fff(\''+a[i]+'\')">'+a[i]+'</button>';
    }
    document.getElementById("pylist").innerHTML=temp;
}

function fff(x){
    var t=eval('pinyin_dict_notone.'+x);
    //alert(0);
    var temp='';
    for(var i=0;i<t.length;i++){
        temp+=('<button onClick="uuu(\''+t[i]+'\')">'+t[i]+'</button> ');
    }
    document.getElementById("wenzi_list").innerHTML=temp;
}
function uuu(x){
    form1.content.value+=x;
}


var pinyin={
  'a':'a|ai|an|ang|ao' 
  
,'b':'ba|bai|ban|bang|bao|bei|ben|beng|bi|bian|biao|bie|bin|bing|bo|bu'
  
,'c':'ca|cai|can|cang|cao|ce|cen|ceng|cha|chai|chan|chang|chao|che|chen|cheng|chi|chong|chou|chu|chuai|chuan|chuang|chui|chun|chuo|ci|cong|cou|cu|cuan|cui|cun|cuo'
  
,'d':'da|dai|dan|dang|dao|de|dei|deng|di|dia|dian|diao|die|ding|diu|dong|dou|du|duan|dui|dun|duo'
  
,'e':'e|ei|en|er'
  
,'f':'fa|fan|fang|fei|fen|feng|fo|fou|fu'
  
,'g':'ga|gai|gan|gang|gao|ge|gei|gen|geng|gong|gou|gu|gua|guai|guan|guang|gui|gun|guo'
  
,'h':'ha|hai|han|hang|hao|he|hei|hen|heng|hong|hou|hu|hua|huai|huan|huang|hui|hun|huo'
  
,'j':'ji|jia|jian|jiang|jiao|jie|jin|jing|jiong|jiu|ju|juan|jue|jun'
  
,'k':'ka|kai|kan|kang|kao|ke|ken|keng|kong|kou|ku|kua|kuai|kuan|kuang|kui|kun|kuo'
  
,'l':'la|lai|lan|lang|lao|le|lei|leng|li|lia|lian|liang|liao|lie|lin|ling|liu|long|lou|lu|luan|lun|luo|lv|lve'
  
,'m':'ma|mai|man|mang|mao|me|mei|men|meng|mi|mian|miao|mie|min|ming|miu|mo|mou|mu'  
  
,'n':'n|na|nai|nan|nang|nao|ne|nei|nen|neng|ni|nian|niang|niao|nie|nin|ning|niu|nong|nou|nu|nuan|nuo|nv|nve'
  
,'o':'o|ou'
  
,'p':'pa|pai|pan|pang|pao|pei|pen|peng|pi|pian|piao|pie|pin|ping|po|pou|pu'
  
,'q':'qi|qia|qian|qiang|qiao|qie|qin|qing|qiong|qiu|qu|quan|que|qun'
  
,'r':'ran|rang|rao|re|ren|reng|ri|rong|rou|ru|ruan|rui|run|ruo'
  
,'s':'sa|sai|san|sang|sao|se|sen|seng|sha|shai|shan|shang|shao|she|shen|sheng|shi|shou|shu|shua|shuai|shuan|shuang|shui|shun|shuo|si|song|sou|su|suan|sui|sun|suo'
  
,'t':'ta|tai|tan|tang|tao|te|teng|ti|tian|tiao|tie|ting|tong|tou|tu|tuan|tui|tun|tuo'
  
,'w':'wa|wai|wan|wang|wei|wen|weng|wo|wu'
  
,'x':'xi|xia|xian|xiang|xiao|xie|xin|xing|xiong|xiu|xu|xuan|xue|xun'
  
,'y':'ya|yan|yang|yao|ye|yi|yin|ying|yo|yong|you|yu|yuan|yue|yun'

,'z':'za|zai|zan|zang|zao|ze|zei|zen|zeng|zha|zhai|zhan|zhang|zhao|zhe|zhei|zhen|zheng|zhi|zhong|zhou|zhu|zhua|zhuai|zhuan|zhuang|zhui|zhun|zhuo|zi|zong|zou|zu|zuan|zui|zun|zuo'

};  
</script>

<div id="pylist" style="margin-top:19px;"></div>

<div id="wenzi_list" style="height:66px;"></div>
<form name="form1">
<textarea name="content" style="width:100%;" rows="5"></textarea>
</form>

程序运行结果如下图所示,点击这里亲自运行看看