From 77b2724a4d6888f50981e2c35fe72408e439cfb6 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Fri, 31 Jul 2009 05:23:31 +0000 Subject: [PATCH] get local api url function abstraction --- js2/mwEmbed/mv_embed.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 = {}; -- 2.20.1