Follow-up r50177: Fix a PHP notice due to typo in arrayname, message key missed too.
[lhc/web/wiklou.git] / js2 / remoteMwEmbed.js
1 /*
2 * this file exposes some of the functionality of mwEmbed to wikis
3 * that are not yet running the new-upload branch
4 */
5
6
7 var urlparts = getRemoteEmbedPath();
8 var mwEmbedHostPath =urlparts[0];
9 var reqAguments =urlparts[1];
10
11 //check if mvEmbed is already loaded (ie the js2 branch is active) in which case do nothing
12 if( typeof MV_EMBED_VERSION == 'undefined' ){
13 doPageSpecificRewrite();
14 }
15
16 function doPageSpecificRewrite(){
17 //add media wizard:
18 if( wgAction == 'edit' || wgAction == 'submit' ){
19 load_mv_embed( function(){
20 importScriptURI(mwEmbedHostPath + '/editPage.js' + reqAguments);
21 });
22 }
23
24 //firefogg integration:
25 if( wgPageName== "Special:Upload" ){
26 load_mv_embed( function(){
27 importScriptURI(mwEmbedHostPath + '/uploadPage.js' +reqAguments);
28 });
29 }
30
31 //oggHandler rewrite:
32 var vidIdList = [];
33 var divs = document.getElementsByTagName('div');
34 for(var i = 0; i < divs.length; i++){
35 if( divs[i].id && divs[i].id.substring(0,11) == 'ogg_player_'){
36 vidIdList.push( divs[i].getAttribute("id") );
37 }
38 }
39 if( vidIdList.length > 0){
40 load_mv_embed( function(){
41 mvJsLoader.embedVideoCheck(function(){
42 //do utilty rewrite of oggHanlder content:
43 rewrite_for_oggHanlder( vidIdList );
44 });
45 });
46 }
47 }
48 function getRemoteEmbedPath(){
49 for(var i=0; i < document.getElementsByTagName('script').length; i++){
50 var s = document.getElementsByTagName('script')[i];
51 if( s.src.indexOf('remoteMwEmbed.js') != -1 ){
52 var reqStr='';
53 var scriptPath='';
54 if( s.src.indexOf('?') != -1){
55 reqStr = s.src.substr( s.src.indexOf('?') );
56 scriptPath = s.src.substr(0, s.src.indexOf('?')).replace('remoteMwEmbed.js', '');
57 }else{
58 scriptPath = s.src.replace('remoteMwEmbed.js', '')
59 }
60 //use the external_media_wizard path:
61 return [scriptPath, reqStr];
62 }
63 }
64 }
65
66 function load_mv_embed( callback ){
67 //inject mv_embed if needed:
68 if( typeof mvEmbed == 'undefined'){
69 importScriptURI(mwEmbedHostPath +'/mwEmbed/mv_embed.js' + reqAguments);
70 check_for_mv_embed( callback );
71 }else{
72 check_for_mv_embed( callback );
73 }
74 }
75 function check_for_mv_embed( callback ){
76 if( typeof MV_EMBED_VERSION == 'undefined'){
77 setTimeout('check_for_mv_embed( ' + callback +');', 25);
78 }else{
79 callback();
80 }
81 }
82