6 lines
1022 B
JavaScript
6 lines
1022 B
JavaScript
|
(function(a){a.fn.speech=function(b){var c={speech:true,lang:"zh",speed:3,sWidth:16,sHeight:13,https:true,bg:"./image/speech.png",content:"这是一段测试内容"};var b=a.extend(c,b);
|
||
|
return this.each(function(){var j=a(this),i=j.find(".speech_iframe"),d=b.https?"https":"http",f=j.text();f=(!f||f===undefined||f===null)?b.content:f;var h=d+"://tts.baidu.com/text2audio?lan="+b.lang+"&ie=UTF-8&text="+f+"&spd="+b.speed;
|
||
|
if(b.speech){var g="<a href='javascript:void(0);' class='speech'></a>";j.append(g);var e=j.find(".speech");e.css({width:b.sWidth,height:b.sHeight,display:"inline-block",background:"url("+b.bg+") no-repeat"});
|
||
|
e.on("click",function(){i.length>0?i.attr("src",h):(function(){var k="<iframe height='0' width='0' class='speech_iframe' scrolling='no' frameborder='0' src='"+h+"' ></iframe>";
|
||
|
j.append(k);})();});}else{i.length>0?i.attr("src",h):(function(){var k="<iframe height='0' width='0' class='speech_iframe' scrolling='no' frameborder='0' src='"+h+"' ></iframe>";
|
||
|
j.append(k);})();}});};})(jQuery);
|