-
Notifications
You must be signed in to change notification settings - Fork 0
/
voicerecordertest.js
263 lines (237 loc) · 23.6 KB
/
voicerecordertest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// This is an external script, included here, and in one line, for performance.
/* PluginDetect v0.6.1 [ onWindowLoaded isMinVersion Java(OTF) Flash ] by Eric Gerds www.pinlady.net/PluginDetect */
if(!PluginDetect){var PluginDetect={getNum:function(b,c){if(!this.num(b)){return null}var a;if(typeof c=="undefined"){a=/[\d][\d\.\_,-]*/.exec(b)}else{a=(new RegExp(c)).exec(b)}return a?a[0].replace(/[\.\_-]/g,","):null},hasMimeType:function(c){if(PluginDetect.isIE){return null}var b,a,d,e=c.constructor==String?[c]:c;for(d=0;d<e.length;d++){b=navigator.mimeTypes[e[d]];if(b&&b.enabledPlugin){a=b.enabledPlugin;if(a.name||a.description){return b}}}return null},findNavPlugin:function(g,d){var a=g.constructor==String?g:g.join(".*"),e=d===false?"":"\\d",b,c=new RegExp(a+".*"+e+"|"+e+".*"+a,"i"),f=navigator.plugins;for(b=0;b<f.length;b++){if(c.test(f[b].description)||c.test(f[b].name)){return f[b]}}return null},AXO:window.ActiveXObject,getAXO:function(b,a){var f=null,d,c=false;try{f=new this.AXO(b);c=true}catch(d){}if(typeof a!="undefined"){delete f;return c}return f},num:function(a){return(typeof a!="string"?false:(/\d/).test(a))},compareNums:function(g,e){var d=this,c,b,a,f=window.parseInt;if(!d.num(g)||!d.num(e)){return 0}if(d.plugin&&d.plugin.compareNums){return d.plugin.compareNums(g,e)}c=g.split(",");b=e.split(",");for(a=0;a<Math.min(c.length,b.length);a++){if(f(c[a],10)>f(b[a],10)){return 1}if(f(c[a],10)<f(b[a],10)){return -1}}return 0},formatNum:function(b){if(!this.num(b)){return null}var a,c=b.replace(/\s/g,"").replace(/[\.\_]/g,",").split(",").concat(["0","0","0","0"]);for(a=0;a<4;a++){if(/^(0+)(.+)$/.test(c[a])){c[a]=RegExp.$2}}if(!/\d/.test(c[0])){c[0]="0"}return c[0]+","+c[1]+","+c[2]+","+c[3]},initScript:function(){var $=this,userAgent=navigator.userAgent;$.isIE=/*@cc_on!@*/false;$.IEver=$.isIE&&((/MSIE\s*(\d\.?\d*)/i).exec(userAgent))?parseFloat(RegExp.$1,10):-1;$.ActiveXEnabled=false;if($.isIE){var x,progid=["Msxml2.XMLHTTP","Msxml2.DOMDocument","Microsoft.XMLDOM","ShockwaveFlash.ShockwaveFlash","TDCCtl.TDCCtl","Shell.UIHelper","Scripting.Dictionary","wmplayer.ocx"];for(x=0;x<progid.length;x++){if($.getAXO(progid[x],1)){$.ActiveXEnabled=true;break}}$.head=typeof document.getElementsByTagName!="undefined"?document.getElementsByTagName("head")[0]:null}$.isGecko=!$.isIE&&typeof navigator.product=="string"&&(/Gecko/i).test(navigator.product)&&(/Gecko\s*\/\s*\d/i).test(userAgent)?true:false;$.GeckoRV=$.isGecko?$.formatNum((/rv\s*\:\s*([\.\,\d]+)/i).test(userAgent)?RegExp.$1:"0.9"):null;$.isSafari=!$.isIE&&(/Safari\s*\/\s*\d/i).test(userAgent)?true:false;$.onWindowLoaded(0)},init:function(c,a){if(typeof c!="string"){return -3}c=c.toLowerCase().replace(/\s/g,"");var b=this,d;if(typeof b[c]=="undefined"){return -3}d=b[c];b.plugin=d;if(typeof d.installed=="undefined"||a==true){d.installed=null;d.version=null;d.version0=null;d.getVersionDone=null;d.$=b}b.garbage=false;if(b.isIE&&!b.ActiveXEnabled){if(b.plugin!=b.java){return -2}}return 1},isMinVersion:function(g,e,c,b){var f=PluginDetect,d=f.init(g);if(d<0){return d}if(typeof e=="number"){e=e.toString()}if(typeof e!="string"){e="0"}if(!f.num(e)){return -3}e=f.formatNum(e);var a=-1,h=f.plugin;if(h.getVersionDone!=1){h.getVersion(c,b);if(h.getVersionDone==null){h.getVersionDone=1}}if(h.version!=null||h.installed!=null){if(h.installed<=0.5){a=h.installed}else{a=(h.version==null?0:(f.compareNums(h.version,e)>=0?1:-1))}}f.cleanup();return a;return -3},getVersion:function(e,b,a){return null},getInfo:function(f,c,b){var a={};return a},cleanup:function(){var a=this;if(a.garbage&&typeof window.CollectGarbage!="undefined"){window.CollectGarbage()}},isActiveXObject:function(b){},codebaseSearch:function(c){var e=this;if(!e.ActiveXEnabled){return null}if(typeof c!="undefined"){return e.isActiveXObject(c)}},dummy1:0}}PluginDetect.onDetectionDone=function(g,e,d,a){return -1};PluginDetect.onWindowLoaded=function(c){var b=PluginDetect,a=window;if(b.EventWinLoad===true){}else{b.winLoaded=false;b.EventWinLoad=true;if(typeof a.addEventListener!="undefined"){a.addEventListener("load",b.runFuncs,false)}else{if(typeof a.attachEvent!="undefined"){a.attachEvent("onload",b.runFuncs)}else{if(typeof a.onload=="function"){b.funcs[b.funcs.length]=a.onload}a.onload=b.runFuncs}}}if(typeof c=="function"){b.funcs[b.funcs.length]=c}};PluginDetect.funcs=[0];PluginDetect.runFuncs=function(){var b=PluginDetect,a;b.winLoaded=true;for(a=0;a<b.funcs.length;a++){if(typeof b.funcs[a]=="function"){b.funcs[a](b);b.funcs[a]=null}}};PluginDetect.java={mimeType:"application/x-java-applet",classID:"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93",DTKclassID:"clsid:CAFEEFAC-DEC7-0000-0000-ABCDEFFEDCBA",DTKmimeType:"application/npruntime-scriptable-plugin;DeploymentToolkit",JavaVersions:[[1,9,2,25],[1,8,2,25],[1,7,2,25],[1,6,2,25],[1,5,2,25],[1,4,2,25],[1,3,1,25]],searchJavaPluginAXO:function(){var i=null,a=this,c=a.$,h=[],g,k=[1,5,0,14],j=[1,6,0,2],f=[1,3,1,0],e=[1,4,2,0],d=[1,5,0,7],b=false;if(!c.ActiveXEnabled){return null};if(c.IEver>=a.minIEver){h=a.searchJavaAXO(j,j,b);if(h.length>0&&b){h=a.searchJavaAXO(k,k,b)}}else{if(h.length==0){h=a.searchJavaAXO(f,e,false)}}if(h.length>0){i=h[0]}a.JavaPlugin_versions=[].concat(h);return i},searchJavaAXO:function(l,i,m){var n,f,h=this.$,p,k,a,e,g,j,b,q=[];if(h.compareNums(l.join(","),i.join(","))>0){i=l}i=h.formatNum(i.join(","));var o,d="1,4,2,0",c="JavaPlugin."+l[0]+""+l[1]+""+l[2]+""+(l[3]>0?("_"+(l[3]<10?"0":"")+l[3]):"");for(n=0;n<this.JavaVersions.length;n++){f=this.JavaVersions[n];p="JavaPlugin."+f[0]+""+f[1];g=f[0]+"."+f[1]+".";for(a=f[2];a>=0;a--){b="JavaWebStart.isInstalled."+g+a+".0";if(h.compareNums(f[0]+","+f[1]+","+a+",0",i)>=0&&!h.getAXO(b,1)){continue}o=h.compareNums(f[0]+","+f[1]+","+a+",0",d)<0?true:false;for(e=f[3];e>=0;e--){k=a+"_"+(e<10?"0"+e:e);j=p+k;if(h.getAXO(j,1)&&(o||h.getAXO(b,1))){q[q.length]=g+k;if(!m){return q}}if(j==c){return q}}if(h.getAXO(p+a,1)&&(o||h.getAXO(b,1))){q[q.length]=g+a;if(!m){return q}}if(p+a==c){return q}}}return q},minIEver:7,getFromMimeType:function(a){var h,f,c=this.$,j=new RegExp(a),d,k,i={},e=0,b,g=[""];for(h=0;h<navigator.mimeTypes.length;h++){k=navigator.mimeTypes[h];if(j.test(k.type)&&k.enabledPlugin){k=k.type.substring(k.type.indexOf("=")+1,k.type.length);d="a"+c.formatNum(k);if(typeof i[d]=="undefined"){i[d]=k;e++}}}for(f=0;f<e;f++){b="0,0,0,0";for(h in i){if(i[h]){d=h.substring(1,h.length);if(c.compareNums(d,b)>0){b=d}}}g[f]=i["a"+b];i["a"+b]=null}if(!/windows|macintosh/i.test(navigator.userAgent)){g=[g[0]]}return g},queryJavaHandler:function(){var b=PluginDetect.java,a=window.java,c;b.hasRun=true;try{if(typeof a.lang!="undefined"&&typeof a.lang.System!="undefined"){b.value=[a.lang.System.getProperty("java.version")+" ",a.lang.System.getProperty("java.vendor")+" "]}}catch(c){}},queryJava:function(){var c=this,d=c.$,b=navigator.userAgent,f;if(typeof window.java!="undefined"&&navigator.javaEnabled()&&!c.hasRun){if(d.isGecko){if(d.hasMimeType("application/x-java-vm")){try{var g=document.createElement("div"),a=document.createEvent("HTMLEvents");a.initEvent("focus",false,true);g.addEventListener("focus",c.queryJavaHandler,false);g.dispatchEvent(a)}catch(f){}if(!c.hasRun){c.queryJavaHandler()}}}else{if(/opera.9\.(0|1)/i.test(b)&&/mac/i.test(b)){}else{if(!c.hasRun){c.queryJavaHandler()}}}}return c.value},VENDORS:["Sun Microsystems Inc.","Apple Computer, Inc."],init:function(){var a=this,b=a.$;if(typeof a.app!="undefined"){a.delJavaApplets(b)}a.hasRun=false;a.value=[null,null];a.useTag=[2,2,2];a.app=[0,0,0,0,0,0];a.appi=3;a.queryDTKresult=null;a.OTF=0;a.BridgeResult=[[null,null],[null,null],[null,null]];a.JavaActive=[0,0,0];a.All_versions=[];a.DeployTK_versions=[];a.MimeType_versions=[];a.JavaPlugin_versions=[];a.funcs=[];var c=a.NOTF;if(c){c.$=b;if(c.javaInterval){clearInterval(c.javaInterval)}c.EventJavaReady=null;c.javaInterval=null;c.count=0;c.intervalLength=250;c.countMax=40}a.lateDetection=b.winLoaded;if(!a.lateDetection){b.onWindowLoaded(a.delJavaApplets)}},getVersion:function(f,l){var h,d=this,g=d.$,j=null,n=null,e=null,c=navigator.javaEnabled();if(d.getVersionDone==null){d.init()}var k;if(typeof l!="undefined"&&l.constructor==Array){for(k=0;k<d.useTag.length;k++){if(typeof l[k]=="number"){d.useTag[k]=l[k]}}}if(d.getVersionDone==0){if(!d.version||d.useAnyTag()){h=d.queryExternalApplet(f);if(h[0]){e=h[0];n=h[1]}}d.EndGetVersion(e,n);return}var i=d.queryDeploymentToolKit();if(typeof i=="string"&&i.length>0){j=i;n=d.VENDORS[0]}if(!g.isIE){var q,m,b,o,a;a=g.hasMimeType(d.mimeType);o=(a&&c)?true:false;if(d.MimeType_versions.length==0&&a){h=d.getFromMimeType("application/x-java-applet.*jpi-version.*=");if(h[0]!=""){if(!j){j=h[0]}d.MimeType_versions=h}}if(!j&&a){h="Java[^\\d]*Plug-in";b=g.findNavPlugin(h);if(b){h=new RegExp(h,"i");q=h.test(b.description)?g.getNum(b.description):null;m=h.test(b.name)?g.getNum(b.name):null;if(q&&m){j=(g.compareNums(g.formatNum(q),g.formatNum(m))>=0)?q:m}else{j=q||m}}}if(!j&&a&&/macintosh.*safari/i.test(navigator.userAgent)){b=g.findNavPlugin("Java.*\\d.*Plug-in.*Cocoa",false);if(b){q=g.getNum(b.description);if(q){j=q}}}if(j){d.version0=j;if(c){e=j}}if(!e||d.useAnyTag()){b=d.queryExternalApplet(f);if(b[0]){e=b[0];n=b[1]}}if(!e){b=d.queryJava();if(b[0]){d.version0=b[0];e=b[0];n=b[1];if(d.installed==-0.5){d.installed=0.5}}}if(d.installed==null&&!e&&o&&!/macintosh.*ppc/i.test(navigator.userAgent)){h=d.getFromMimeType("application/x-java-applet.*version.*=");if(h[0]!=""){e=h[0]}}if(!e&&o){if(/macintosh.*safari/i.test(navigator.userAgent)){if(d.installed==null){d.installed=0}else{if(d.installed==-0.5){d.installed=0.5}}}}}else{if(!j&&i!=-1){j=d.searchJavaPluginAXO();if(j){n=d.VENDORS[0]}}if(!j){d.JavaFix()}if(j){d.version0=j;if(c&&g.ActiveXEnabled){e=j}}if(!e||d.useAnyTag()){h=d.queryExternalApplet(f);if(h[0]){e=h[0];n=h[1]}}}if(d.installed==null){d.installed=e?1:(j?-0.2:-1)}d.EndGetVersion(e,n)},EndGetVersion:function(b,d){var a=this,c=a.$;if(a.version0){a.version0=c.formatNum(c.getNum(a.version0))}if(b){a.version=c.formatNum(c.getNum(b));a.vendor=(typeof d=="string"?d:"")}if(a.getVersionDone!=1){a.getVersionDone=0}},queryDeploymentToolKit:function(){var d=this,f=d.$,h,b,g=null,a=null;if((f.isGecko&&f.compareNums(f.GeckoRV,f.formatNum("1.6"))<=0)||f.isSafari||(f.isIE&&!f.ActiveXEnabled)){d.queryDTKresult=0}if(d.queryDTKresult!=null){return d.queryDTKresult}if(f.isIE&&f.IEver>=6){d.app[0]=f.instantiate("object",[],[]);g=f.getObject(d.app[0])}else{if(!f.isIE&&f.hasMimeType(d.DTKmimeType)){d.app[0]=f.instantiate("object",["type",d.DTKmimeType],[]);g=f.getObject(d.app[0])}}if(g){if(f.isIE&&f.IEver>=6){try{g.classid=d.DTKclassID}catch(h){}}try{a=g.jvms.getLength();if(a!=null&&a>0){var c;for(b=0;b<a;b++){c=g.jvms.get(a-1-b).version;if(!f.getNum(c)){continue}d.DeployTK_versions[b]=c}}}catch(h){}try{if(g.object&&g.readyState!=4){f.garbage=true;f.uninstantiate(d.app[0])}}catch(h){}}f.hideObject(g);d.queryDTKresult=d.DeployTK_versions.length>0?d.DeployTK_versions[0]:(a==0?-1:0);return d.queryDTKresult},queryExternalApplet:function(d){var c=this,e=c.$,h=c.BridgeResult,b=c.app,g=c.appi,a=" ";if(typeof d!="string"||!(/\.jar\s*$/).test(d)){return[null,null]}if(c.OTF<1){c.OTF=1}if(!e.isIE){if(e.isGecko&&!e.hasMimeType(c.mimeType)&&!c.queryJava()[0]){return[null,null]}}if(c.OTF<2){c.OTF=2}if(!b[g]&&c.canUseObjectTag()&&c.canUseThisTag(0)){b[1]=e.instantiate("object",[],[],a);b[g]=e.isIE?e.instantiate("object",["archive",d,"code","A.class","type",c.mimeType],["archive",d,"code","A.class","mayscript","true","scriptable","true"],a):e.instantiate("object",["archive",d,"classid","java:A.class","type",c.mimeType],["archive",d,"mayscript","true","scriptable","true"],a);h[0]=[0,0];c.query1Applet(g)}if(!b[g+1]&&c.canUseAppletTag()&&c.canUseThisTag(1)){b[g+1]=e.instantiate("applet",["archive",d,"code","A.class","alt",a,"mayscript","true"],["mayscript","true"],a);h[1]=[0,0];c.query1Applet(g+1)}if(e.isIE&&!b[g+2]&&c.canUseObjectTag()&&c.canUseThisTag(2)){b[g+2]=e.instantiate("object",["classid",c.classID],["archive",d,"code","A.class","mayscript","true","scriptable","true"],a);h[2]=[0,0];c.query1Applet(g+2)};var j,f=0;for(j=0;j<h.length;j++){if(b[g+j]||c.canUseThisTag(j)){f++}else{break}}if(f==h.length){c.getVersionDone=1}return c.getBR()},canUseAppletTag:function(){return((!this.$.isIE||navigator.javaEnabled())?true:false)},canUseObjectTag:function(){return((!this.$.isIE||this.$.ActiveXEnabled)?true:false)},useAnyTag:function(){var b=this,a;for(a=0;a<b.useTag.length;a++){if(b.canUseThisTag(a)){return true}}return false},canUseThisTag:function(c){var a=this,b=a.$;if(a.useTag[c]==3){return true}if(!a.version0||!navigator.javaEnabled()||(b.isIE&&!b.ActiveXEnabled)){if(a.useTag[c]==2){return true}if(a.useTag[c]==1&&!a.getBR()[0]){return true}}return false},getBR:function(){var b=this.BridgeResult,a;for(a=0;a<b.length;a++){if(b[a][0]){return[b[a][0],b[a][1]]}}return[b[0][0],b[0][1]]},delJavaApplets:function(b){var c=b.java.app,a;for(a=c.length-1;a>=0;a--){b.uninstantiate(c[a])}},query1Applet:function(g){var f,c=this,d=c.$,a=null,h=null,b=d.getObject(c.app[g]);try{if(b){a=b.getVersion()+" ";h=b.getVendor()+" ";if(a){c.BridgeResult[g-c.appi]=[a,h];d.hideObject(c.app[g])}if(d.isIE&&a&&b.readyState!=4){d.garbage=true;d.uninstantiate(c.app[g])}}}catch(f){}},NOTF:{isJavaActive:function(){}},append:function(e,d){for(var c=0;c<d.length;c++){e[e.length]=d[c]}},getInfo:function(){var o={};return o},JavaFix:function(){}};PluginDetect.flash={mimeType:["application/x-shockwave-flash","application/futuresplash"],progID:"ShockwaveFlash.ShockwaveFlash",classID:"clsid:D27CDB6E-AE6D-11CF-96B8-444553540000",getVersion:function(){var c=function(i){if(!i){return null}var e=/[\d][\d\,\.\s]*[rRdD]{0,1}[\d\,]*/.exec(i);return e?e[0].replace(/[rRdD\.]/g,",").replace(/\s/g,""):null};var j,g=this.$,h,f,b=null,a=null,d=null;if(!g.isIE){j=g.findNavPlugin("Flash");if(j&&j.description&&g.hasMimeType(this.mimeType)){b=c(j.description)}}else{for(f=15;f>2;f--){a=g.getAXO(this.progID+"."+f);if(a){d=f.toString();break}}if(d=="6"){try{a.AllowScriptAccess="always"}catch(h){return"6,0,21,0"}}try{b=c(a.GetVariable("$version"))}catch(h){}if(!b&&d){b=d}}this.installed=b?1:-1;this.version=g.formatNum(b);return true}};PluginDetect.div=null;PluginDetect.DOMbody=null;PluginDetect.uninstantiate=function(a){var c,d,b=this;if(!a){return}try{if(a[0]&&a[0].firstChild){a[0].removeChild(a[0].firstChild)}if(a[0]&&b.div){b.div.removeChild(a[0])}if(b.div&&b.div.childNodes.length==0){b.div.parentNode.removeChild(b.div);b.div=null;if(b.DOMbody&&b.DOMbody.parentNode){b.DOMbody.parentNode.removeChild(b.DOMbody)}b.DOMbody=null}a[0]=null}catch(c){}};PluginDetect.getObject=function(a){var b;try{if(a[0]&&a[0].firstChild){return a[0].firstChild}}catch(b){}return null};PluginDetect.hideObject=function(a){var b=this.getObject(a);if(b&&b.style){b.style.height="0"}};PluginDetect.instantiate=function(h,b,c,a){var q=function(d){var e=d.style;if(!e){return}e.border="0px";e.padding="0px";e.margin="0px";e.fontSize="5px";e.height="5px";if(d.tagName&&d.tagName.toLowerCase()=="div"){e.width="100%";e.display="block"}else{if(d.tagName&&d.tagName.toLowerCase()=="span"){e.width="1px";e.display="inline"}}};var j,k=document,g=this,p,m,f,i=(k.getElementsByTagName("body")[0]||k.body),o=k.createElement("span"),n,l="/";if(typeof a=="undefined"){a=""}p="<"+h+' width="1" height="1" ';for(n=0;n<b.length;n=n+2){p+=b[n]+'="'+b[n+1]+'" '}p+=">";for(n=0;n<c.length;n=n+2){p+='<param name="'+c[n]+'" value="'+c[n+1]+'" />'}p+=a+"<"+l+h+">";if(!g.div){g.div=k.createElement("div");if(i){try{if(i.firstChild&&typeof i.insertBefore!="undefined"){i.insertBefore(g.div,i.firstChild)}else{i.appendChild(g.div)}}catch(j){}}else{try{k.write("<div>o<"+l+"div>");i=(k.getElementsByTagName("body")[0]||k.body);i.appendChild(g.div);i.removeChild(i.firstChild)}catch(j){try{g.DOMbody=k.createElement("body");k.getElementsByTagName("html")[0].appendChild(g.DOMbody);g.DOMbody.appendChild(g.div)}catch(j){}}}q(g.div)}if(g.div&&g.div.parentNode&&g.div.parentNode.parentNode){g.div.appendChild(o);try{o.innerHTML=p}catch(j){}q(o);return[o]}return[null]};PluginDetect.initScript();
M.vr = {
pix : null,
init : function(Y, page, str, pix) {
voicerecorder_str = str;
this.pix = pix;
// Prepare onload
Y.on('load', voicerecorderOnLoad, window);
// Init java
Y.all('div.voice-recorder-applet').each(function(node, index, nodelist) {
var type = node.get('type'), params = node.get('params');
if (type === 'java') {
voicerecorderShowJava(node.get('id'), params.java, params.width, params.height,
params.appletclass, params.javavars);
}
});
// Does nothing
// Any new code should be added in here and should use YUI3. The old
// code should also be moved to YUI3 and in here.
}
}
var voicerecorder_str;
var voicerecorderJavaInstalled = -99;
var voicerecorderNextAppletId = 1;
var voicerecorderLoadedApplets = 0;
var voicerecorderDoneIE6Focus = 0, voicerecorderDoneIE6FocusApplets = 0;
function voicerecorderForceIERepaint() {
// IE needs a forced repaint
if(navigator.appName == 'Microsoft Internet Explorer') {
var mc=document.getElementById('middle-column');
if (!mc) {
// Used on other pages
return;
}
if(mc.className.indexOf('evilfrog')==-1)
mc.className+=" evilfrog";
else
mc.className=mc.className.replace(' evilfrog','');
}
}
function voicerecorderOnLoad() {
// Check for reload - certain dynamic content requires that pages are
// reloaded if you go Back or Forward to them
var reload = document.getElementById('voicerecorder_require_reload');
if(reload)
{
if(reload.value == 1)
{
reload.value = 0;
window.location.reload();
return;
}
else
{
reload.value = 1;
}
}
// Find referenced anchor tag and its parents
var hash=document.location.hash;
var hashParents=new Array();
if(hash) {
var hashEl=document.getElementById(hash.substring(1));
if(hashEl) {
for(;hashEl;hashEl=hashEl.parentNode) {
hashParents.push(hashEl);
}
}
}
}
// This function is not used
function voicerecorderTranscript(url) {
window.open(url,'transcript','width=450,height=550,location=yes,status=yes,resizable=yes,scrollbars=yes');
return false;
}
// Note: This method is also called from mod/audiorecorder
function voicerecorderShowJava(id,java,width,height,appletclass,javavars) {
if (voicerecorderJavaInstalled == -99 ) {
voicerecorderJavaInstalled = PluginDetect.isMinVersion(
'Java', 1.5, 'plugindetect.getjavainfo.jar', [0, 2, 0]) == 1;
}
if (!voicerecorderJavaInstalled) {
return;
}
var newApplet=document.createElement("applet");
newApplet.code=appletclass;
newApplet.archive=java;
newApplet.width=width;
newApplet.height=height;
newApplet.tabIndex = -1; // Not directly tabbable
newApplet.mayScript = true;
newApplet.id = "voicerecorderJava" + (voicerecorderNextAppletId++);
// In case applet supports the focushack system, we
// pass in its id as a parameter.
javavars[javavars.length] = 'focushackid';
javavars[javavars.length] = newApplet.id;
for (var i=0;i<javavars.length;i+=2) {
var param=document.createElement('param');
param.name=javavars[i];
param.value=javavars[i+1];
newApplet.appendChild(param);
}
var warningDiv = document.getElementById(id);
warningDiv.style.display="none";
newApplet.warningDiv = warningDiv;
newApplet.warningDiv.parentNode.insertBefore(newApplet, warningDiv);
if(document.body.className.indexOf('ie6')!=-1 && !voicerecorderDoneIE6Focus) {
var fixFocus = function()
{
if(document.activeElement &&
document.activeElement.nodeName.toLowerCase()=='applet')
{
setTimeout(fixFocus, 100);
voicerecorderDoneIE6Focus = 1;
voicerecorderDoneIE6FocusApplets ++;
window.focus();
}
else
{
voicerecorderDoneIE6Focus++;
if(voicerecorderDoneIE6Focus == 2 && voicerecorderDoneIE6FocusApplets > 0)
{
// Focus one extra time after applet gets it
window.focus();
}
if(voicerecorderDoneIE6Focus < 50)
{
setTimeout(fixFocus, 100);
}
}
};
window.arghApplets = 0;
setTimeout(fixFocus, 100);
voicerecorderDoneIE6Focus=1;
}
}
// Called by Java applets when loaded - only if the Java version/applet supports
// the focushack system.
function appletLoaded(id) {
var applet = document.getElementById(id);
// These autofocus divs before and after the applet allow focus
// to be correctly moved to the front/back end of the applet's
// controls when the user tabs.
var beforeFocus = document.createElement('div');
beforeFocus.tabIndex = 0;
beforeFocus.className = 'voicerecorderJavaAutofocusBefore';
beforeFocus.onfocus = function() { voicerecorderScrollIntoView(applet); applet.initFocus(false); }
applet.parentNode.insertBefore(beforeFocus, applet);
var afterFocus = document.createElement('div');
afterFocus.tabIndex = 0;
afterFocus.className = 'voicerecorderJavaAutofocusAfter';
afterFocus.onfocus = function() { voicerecorderScrollIntoView(applet); applet.initFocus(true); }
applet.parentNode.insertBefore(afterFocus, applet.warningDiv);
// After all applets are loaded, focus the window to deal with bug
voicerecorderLoadedApplets++;
if(voicerecorderLoadedApplets == voicerecorderNextAppletId-1) {
voicerecorderLoadedApplets = -1;
setTimeout(function() { window.focus(); }, 100);
}
}
// If the element is not fully in view, scroll so that it is
function voicerecorderScrollIntoView(target) {
var region = YAHOO.util.Dom.getRegion(target);
var y = YAHOO.util.Dom.getDocumentScrollTop();
var height = YAHOO.util.Dom.getViewportHeight();
if (y + height < region.bottom) {
window.scroll(0, region.bottom - height);
} else if (y > region.top) {
window.scroll(0, region.top);
}
}
// Called by Java applets when they want to lose focus
function appletDitchFocus(id, forward) {
// Get the applet
var applet = document.getElementById(id);
// Get list of everything that can be focused
var allFocusable = [];
voicerecorderBuildFocusableList(allFocusable, document.documentElement);
// Find applet on list
var found = -1;
for (var i=0; i<allFocusable.length; i++) {
if (allFocusable[i]==applet) {
found=i;
break;
}
}
if (found==-1)
{
return;
}
// Move to next/previous thing
if (forward)
{
found+=2; // Including skipping the special autofocus div
if (found==allFocusable.length)
{
found = 0;
}
}
else
{
found-=2; // Again skip the 'before' focus div
if (found<0)
{
found = allFocusable.length-1;
}
}
var x = allFocusable[found];
setTimeout(function(){x.focus()},0);
}
function voicerecorderBuildFocusableList(list, element)
{
// Exclude items that are invisible or disabled
if (element.style.visibility.toLowerCase() == 'hidden' ||
element.style.display.toLowerCase() == 'none' ||
(typeof element.disabled != 'undefined' && element.disabled)) {
return;
}
// Tabindex check: see
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
var attr = element.getAttributeNode("tabindex");
var specifiedTabIndex = attr ? attr.specified : false;
// Include elements with manually specified tabindex; links; form controls
if(specifiedTabIndex ||
(element.nodeName.toLowerCase()=='a' && typeof element.href!='undefined' && element.href) ||
(element.nodeName.toLowerCase()=='input' && element.type.toLowerCase()!='hidden') ||
(element.nodeName.toLowerCase()=='textarea')) {
list[list.length] = element;
}
// Do children
for (var child = element.firstChild; child!=null; child=child.nextSibling) {
if (child.nodeType==1) {
voicerecorderBuildFocusableList(list, child);
}
}
}