1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <title>Api Proxy Test
</title>
6 <script type=
"text/javascript" src=
"../mv_embed.js"></script>
8 <script type=
"text/javascript" >
9 //HARD coded local test:
10 var remote_wiki_host = 'http://test.wikipedia.org';
11 var remote_script_path = '/w';
13 js2AddOnloadHook( function(){
14 $j('#hostName').text( remote_wiki_host );
15 //run the api-proxy setup:
19 'server_frame': remote_wiki_host + remote_script_path + '/index.php/MediaWiki:ApiProxy',
20 'client_frame_path' : '/wiki_trunk/js2/mwEmbed/libMwApi/NestedCallbackIframe.html',
23 //callback function here:
24 $j('#setupDone').show('slow');
25 $j('#doHello').click( doHello );
26 $j('#doAppend').click(doAppend);
31 js_log('to a hello user');
32 $j('#helloTarget').html( mv_get_loading_img() );
33 //first get the user name:
34 getUserName(function( user_name ){
35 $j('#helloTarget').hide().text( user_name ).fadeIn('slow');
39 function getUserName( callback ){
44 //we use normal do_api_req with keywork 'proxy' for the url
45 $mw.proxy.doRequest( rObj,
47 //now we get the data back for that domain
48 if( !data.query || !data.query.userinfo ){
49 js_log(
"Error no query.userinfo ");
52 callback( data.query.userinfo.name );
57 //simple
"hello from api proxy" append on talk page
59 $j('#appendTarget').html( mv_get_loading_img() );
61 getUserName(function(userName){
62 var eTitle = 'User_talk:' + userName;
64 get_mw_token(eTitle, 'proxy', function( token ){
65 js_log(
"got token: " + token) ;
69 'summary':
"Api proxy test edit",
70 'appendtext':
"\n\n==== Hello from Api proxy At: " + Date() +
" ====",
77 if(result.edit && result.edit.newrevid){
78 $j('#appendTarget').html(
"success: " + JSON.stringify ( result) );
79 url = remote_wiki_host + remote_script_path + '/index.php/';
80 url+= result.edit.title.replace(' ', '_');
81 $j('#appendTarget').append( '
<br><a target=
"_new" href=
"' + url + '">visit page
</a>' );
83 $j('#appendTarget').html(
"falied: " + JSON.stringify ( result) );
94 <h3> Simple API proxy testing system
</h3>
96 <div id=
"setupProxy">Proxy for:
<span id=
"hostName"></span> <br><span style=
"font-size:small">( be sure to enable the mwEmbed gadget or add importScriptURI( 'path_to_local_mw_install' + /js2/remoteMwEmbed.js ) to your User skin .js page
</span></div>
97 <div id=
"setupDone" style=
"display:none;">
98 <br> <a href=
"#" id=
"doHello" >Hello User:
</a> <span id=
"helloTarget"></span>
99 <br><br><br> <a href=
"#" id=
"doAppend">Append Msg to Talk page:
</a>
100 <div id=
"appendTarget"></div>