13 lines
56 KiB
JavaScript
13 lines
56 KiB
JavaScript
|
if(void 0===WebSpeech){var WebSpeech={version:"4.2",server:"http://wa.eguidedog.net/cgi-bin/ekho.pl",serverReturnType:"MP3",voice:"EkhoMandarin",speedDelta:0,pitchDelta:0,volumeDelta:0,sm2ready:!1,speechQueue:[],frameStack:[],state:"NONE",rootNode:null,curNode:null,curPos:0,curText:"",curSpeech:null,foundNewParagraph:!1,headingTags:"H1 H2 H3 H4 H5 H6",foundNewHeading:!1,paragraphTags:"P DIV H1 H2 H3 H4 H5 H6 HR BR",preHighLightNode:null,highLightNode:null,seperators:[".","。",",",",",";",";","(","(",")",")","\n"],cacheNode:null,cachePos:0,cacheCount:0,cacheMaxCount:5,isCtrlKeyDown:!1,isShiftKeyDown:!1,htmlStartId:null,onready:function(){this.sm2ready=!0,WebSpeech.playNextSpeech()},ready:function(f){this.onready=function(){this.sm2ready=!0,f()}},onfinish:function(){},text2url:{},text2audio:{},debug:!0,log:function(msg){var logDiv=document.getElementById("WebSpeechLog");logDiv&&this.debug&&(logDiv.innerHTML+=msg+"<br/>")},getStyle:function(elem,styleName){if(1!==elem.nodeType)return null;try{if(elem.currentStyle)return elem.currentStyle[styleName];if(window.getComputedStyle)return window.getComputedStyle(elem,null).getPropertyValue(styleName)}catch(e){return null}},getUrl:function(cmd,text){return this.server+"?cmd="+cmd+"&voice="+this.voice+"&speedDelta="+this.speedDelta+"&pitchDelta="+this.pitchDelta+"&volumeDelta="+this.volumeDelta+"&text="+encodeURIComponent(text)},playNextSpeech:function(){var text,speechId,url,speechRef;"None"!==this.voice?soundManager.supported()&&(this.sm2ready?0!==this.speechQueue.length?this.text2url[this.speechQueue[0]]&&(speechId=this.speechQueue.shift(),this.text2audio[speechId]||(this.text2audio[speechId]=soundManager.createSound({id:speechId,url:this.text2url[speechId],multiShot:!0})),"NONE"!==this.state&&this.highLightCurText(),speechRef=this,soundManager._writeDebug("play "+speechId),this.text2audio[speechId].play({onfinish:function(){speechRef.playNextSpeech()}}),this.curSpeech=this.text2audio[speechId],this.cacheCount>0&&(this.cacheCount-=1),this.cacheNextSpeech()):"SPEAKHTML"===this.state&&(text=this.getNextClause())?(speechId=this.getSpeechId(text),this.speechQueue.push(speechId),this.text2url[speechId]||(url=this.getUrl("SPEAK",text),"URL"===this.serverReturnType?(speechRef=this,OX.AJAST.call(url,"callback",(function(isSuccess,result){isSuccess&&(speechRef.text2url[speechId]=result,speechRef.playNextSpeech())}))):this.text2url[speechId]=url),this.playNextSpeech()):this.onfinish():soundManager.onready((function(){WebSpeech.playNextSpeech()}))):this.speechQueue=[]},speak:function(text){var speechId,speechRef,url;speechId=this.getSpeechId(text),this.speechQueue.push(speechId),url=this.getUrl("SPEAK",text),this.text2url[speechId]?this.playNextSpeech():"URL"===this.serverReturnType?(speechRef=this,OX.AJAST.call(url,"callback",(function(isSuccess,result){isSuccess&&(speechRef.text2url[speechId]=result,speechRef.playNextSpeech())}))):(this.text2url[speechId]=url,this.playNextSpeech())},getSpeechId:function(text){return"s"+this.voice+"s"+this.speedDelta+"p"+this.pitchDelta+"v"+this.volumeDelta+MD5(text)},disableHighLight:function(){var parentNode;this.highLightNode&&((parentNode=this.highLightNode.parentNode).replaceChild(this.preHighLightNode,this.highLightNode),this.curNode.parentNode===this.highLightNode?(this.curNode.previousSibling&&("SPAN"===this.curNode.previousSibling.tagName?(this.curPos+=this.curNode.previousSibling.firstChild.length,this.curNode.previousSibling.previousSibling&&(this.curPos+=this.curNode.previousSibling.previousSibling.length)):this.curPos+=this.curNode.previousSibling.length),this.curNode=this.preHighLightNode):this.curNode.parentNode&&this.curNode.parentNode.parentNode===this.highLightNode&&(this.curNode=this.preHighLightNode),this.preHighLightNode=null,this.highLightNode=null)},highLightCurText:function(){var part1,part2,part3,parentNode;this.disableHighLight(),this.curNode.nodeValue&&(part1=this.curNode.nodeValue.substr(0,this.curPos-this.curText.length),part2='<span id="WebSpeechHighLight" style="background-color:#ff0; color:#000">'+this.curText+"</s
|
|||
|
/** @license
|
|||
|
*
|
|||
|
* SoundManager 2: JavaScript Sound for the Web
|
|||
|
* ----------------------------------------------
|
|||
|
* http://schillmania.com/projects/soundmanager2/
|
|||
|
*
|
|||
|
* Copyright (c) 2007, Scott Schiller. All rights reserved.
|
|||
|
* Code provided under the BSD License:
|
|||
|
* http://schillmania.com/projects/soundmanager2/license.txt
|
|||
|
*
|
|||
|
* V2.97a.20140901
|
|||
|
*/!function(g,h){function G(F,G){function W(b){return c.preferFlash&&v&&!c.ignoreFlash&&c.flash[b]!==h&&c.flash[b]}function r(b){return function(c){var d=this._s;return d&&d._a?b.call(this,c):null}}this.setupOptions={url:F||null,flashVersion:8,debugMode:!0,debugFlash:!1,useConsole:!0,consoleOnly:!0,waitForWindowLoad:!1,bgColor:"#ffffff",useHighPerformance:!1,flashPollingInterval:null,html5PollingInterval:null,flashLoadTimeout:1e3,wmode:null,allowScriptAccess:"always",useFlashBlock:!1,useHTML5Audio:!0,html5Test:/^(probably|maybe)$/i,preferFlash:!1,noSWFCache:!1,idPrefix:"sound"},this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,usePolicyFile:!1,volume:100},this.flash9Options={isMovieStar:null,usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null,ondataerror:null},this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null},this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a","m4b"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},ogg:{type:["audio/ogg; codecs=vorbis"],required:!1},opus:{type:["audio/ogg; codecs=opus","audio/opus"],required:!1},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave","audio/x-wav"],required:!1}},this.movieID="sm2-container",this.id=G||"sm2movie",this.debugID="soundmanager-debug",this.debugURLParam=/([#?&])debug=1/i,this.versionNumber="V2.97a.20140901",this.altURL=this.movieURL=this.version=null,this.enabled=this.swfLoaded=!1,this.oMC=null,this.sounds={},this.soundIDs=[],this.didFlashBlock=this.muted=!1,this.filePattern=null,this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i},this.features={buffering:!1,peakData:!1,waveformData:!1,eqData:!1,movieStar:!1},this.sandbox={},this.html5={usingFlash:null},this.flash={},this.ignoreFlash=this.html5Only=!1;var Ja,c=this,Ka=null,k=null,X,t=navigator.userAgent,La=g.location.href.toString(),p=document,la,Ma,ma,n,x=[],M=!1,N=!1,m=!1,y=!1,na=!1,O,w,oa,Y,pa,D,H,I,Na,qa,ra,Z,sa,$,ta,E,ua,P,va,aa,J,Oa,wa,Pa,xa,Qa,Q=null,ya=null,R,za,K,ba,ca,q,S=!1,Aa=!1,Ra,Sa,Ta,da=0,T=null,ea,Ua=[],U,u=null,Va,fa,V,z,ga,Ba,Wa,s,fb=Array.prototype.slice,A=!1,Ca,v,Da,Xa,B,ha,Ya=0,ia=t.match(/(ipad|iphone|ipod)/i),Za=t.match(/android/i),C=t.match(/msie/i),gb=t.match(/webkit/i),ja=t.match(/safari/i)&&!t.match(/chrome/i),Ea=t.match(/opera/i),Fa=t.match(/(mobile|pre\/|xoom)/i)||ia||Za,$a=!La.match(/usehtml5audio/i)&&!La.match(/sm2\-ignorebadua/i)&&ja&&!t.match(/silk/i)&&t.match(/OS X 10_6_([3-7])/i),Ga=p.hasFocus!==h?p.hasFocus():null,ka=ja&&(p.hasFocus===h||!p.hasFocus()),ab=!ka,bb=/(mp3|mp4|mpa|m4a|m4b)/i,Ha=p.location?p.location.protocol.match(/http/i):null,cb=Ha?"":"http://",db=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,eb="mpeg4 aac flv mov mp4 m4v f4v m4a m4b mp4v 3gp 3g2".split(" "),hb=RegExp("\\.("+eb.join("|")+")(\\?.*)?$","i"),Ia;this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i,this.useAltURL=!Ha;try{Ia=Audio!==h&&(Ea&&opera!==h&&10>opera.version()?new Audio(null):new Audio).canPlayType!==h}catch(ib){Ia=!1}this.hasHTML5=Ia,this.setup=function(b){var e=!c.url;return b!==h&&m&&u&&c.ok(),oa(b),b&&(e&&P&&b.url!==h&&c.beginDelayedInit(),!P&&b.url!==h&&"complete"===p.readyState&&setTimeout(E,1)),c},this.supported=this.ok=function(){return u?m&&!y:c.useHTML5Audio&&c.hasHTML5},this.getMovie=function(b){return X(b)||p[b]||g[b]},this.createSound=function(b,e){function d(){return a=ba(a),c.sounds[a.id]=new Ja(a),c.soundIDs.push(a.id),c.sounds[a.id]}var a,f=null;if(!m||!c.ok())return!1;if(e!==h&&(b={id:b,url:e}),(a=w(b)).url=ea(a.url),void 0===a.id&&(a.id=c.setupOptions.idPrefix+Ya++),q(a.id,!0))return c.sounds[a.id];if(fa(a))(f=d())._setup_html5(a);else{if(c.htm
|