From: Michael Dale Date: Fri, 31 Jul 2009 05:23:31 +0000 (+0000) Subject: get local api url function abstraction X-Git-Tag: 1.31.0-rc.0~40614 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24ze_article%22%29%20.%20%22?a=commitdiff_plain;h=77b2724a4d6888f50981e2c35fe72408e439cfb6;p=lhc%2Fweb%2Fwiklou.git get local api url function abstraction --- diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index 530b27e86d..f1d96bb9c5 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -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 = {};