function getPinyin()
{
var value = document.getElementById('test').value;
var type = document.querySelector('[name="pinyin_type"]:checked').value;
var polyphone = document.querySelector('[name="polyphone"]').checked;
var result = '';
if(value)
{
switch(type)
{
case '0': result = pinyinUtil.getPinyin(value, ' ', true, polyphone); break;
case '1': result = pinyinUtil.getPinyin(value, ' ', false, polyphone); break;
case '2': result = pinyinUtil.getFirstLetter(value, polyphone); break;
default: break;
}
}
var html = result;
if(result instanceof Array)
{
html = '<ol>';
result.forEach(function(val)
{
html += '<li>'+val+'</li>';
});
html += '</ol>';
}
document.getElementById('result').innerHTML = html;
}
document.getElementById('test').addEventListener('input', getPinyin);
document.getElementsByName('polyphone')[0].addEventListener('change', function(e)
{
getPinyin();
});
document.addEventListener('change', function(e)
{
if(e.target.name === 'pinyin_type')
{
getPinyin();
}
});
getPinyin();
// 初始化简单的拼音输入法
SimpleInputMethod.init('.test-input-method');
document.querySelector('.loading-tip').innerHTML = 'JS加载完毕,现在你可以开始打字了!';
*
回帖描述:*
链接类型:*
下载链接:*
描述:*
回帖描述:*
链接类型:*
阅读权限:*
下载链接:



聚优部落技术论坛 © 版权所有 鲁ICP备15007479号-6
Copyright(C)web.com, All Rights Reserved.
