get local api url function abstraction
authorMichael Dale <dale@users.mediawiki.org>
Fri, 31 Jul 2009 05:23:31 +0000 (05:23 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Fri, 31 Jul 2009 05:23:31 +0000 (05:23 +0000)
js2/mwEmbed/mv_embed.js

index 530b27e..f1d96bb 100644 (file)
@@ -1080,11 +1080,9 @@ function do_api_req( options, callback ){
        if( typeof options.url == 'undefined' ||  options.url === false){
                if(!wgServer || ! wgScriptPath){                        
                        return js_error('Error: no api url for api request');;
-               }               
-               if (wgServer && wgScript)
-                       options.url = wgServer + wgScript;
+               }                               
                //update to api.php (if index.php was in the wgScript path): 
-                options.url =  options.url.replace(/index.php/, 'api.php');            
+                options.url =  mwGetLocalApiUrl();             
        }                       
        if( typeof options.data == 'undefined' )
                options.data = {};      
@@ -1131,6 +1129,13 @@ function do_api_req( options, callback ){
                loadExternalJs( req_url );                              
        }       
 }
+function mwGetLocalApiUrl(url){
+       if (wgServer && wgScript){
+                       url = wgServer + wgScript;
+               return url.replace(/index.php/, 'api.php');
+       }
+       return false;
+}
 //grab wiki form error for wiki html page proccessing (should be depricated)
 function grabWikiFormError ( result_page ){
                var res = {};