includes/clientside/static/ajax.js
changeset 407 35d94240a197
parent 343 eefe9ab7fe7c
child 413 6607cd646d6d
equal deleted inserted replaced
406:7468a663315f 407:35d94240a197
   183   if ( ns_id[1] == 'Special' || ns_id[1] == 'Admin' )
   183   if ( ns_id[1] == 'Special' || ns_id[1] == 'Admin' )
   184     return false;
   184     return false;
   185   enableUnload();
   185   enableUnload();
   186   setAjaxLoading();
   186   setAjaxLoading();
   187   ajaxGet(stdAjaxPrefix+'&_mode=getpage&noheaders', function() {
   187   ajaxGet(stdAjaxPrefix+'&_mode=getpage&noheaders', function() {
   188     if(ajax.readyState == 4) {
   188     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   189       unsetAjaxLoading();
   189       unsetAjaxLoading();
   190       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   190       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   191       selectButtonMajor('article');
   191       selectButtonMajor('article');
   192       unselectAllButtonsMinor();
   192       unselectAllButtonsMinor();
   193     }
   193     }
   210   document.getElementById('protbtn_0').style.textDecoration = 'none';
   210   document.getElementById('protbtn_0').style.textDecoration = 'none';
   211   document.getElementById('protbtn_1').style.textDecoration = 'none';
   211   document.getElementById('protbtn_1').style.textDecoration = 'none';
   212   document.getElementById('protbtn_2').style.textDecoration = 'none';
   212   document.getElementById('protbtn_2').style.textDecoration = 'none';
   213   document.getElementById('protbtn_'+l).style.textDecoration = 'underline';
   213   document.getElementById('protbtn_'+l).style.textDecoration = 'underline';
   214   ajaxPost(stdAjaxPrefix+'&_mode=protect', 'reason='+ajaxEscape(r)+'&level='+l, function() {
   214   ajaxPost(stdAjaxPrefix+'&_mode=protect', 'reason='+ajaxEscape(r)+'&level='+l, function() {
   215     if(ajax.readyState == 4) {
   215     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   216       unsetAjaxLoading();
   216       unsetAjaxLoading();
   217       if(ajax.responseText != 'good')
   217       if(ajax.responseText != 'good')
   218         alert(ajax.responseText);
   218         alert(ajax.responseText);
   219     }
   219     }
   220   }, true);
   220   }, true);
   227     return true;
   227     return true;
   228   r = prompt($lang.get('ajax_rename_prompt'));
   228   r = prompt($lang.get('ajax_rename_prompt'));
   229   if(!r || r=='') return;
   229   if(!r || r=='') return;
   230   setAjaxLoading();
   230   setAjaxLoading();
   231   ajaxPost(stdAjaxPrefix+'&_mode=rename', 'newtitle='+ajaxEscape(r), function() {
   231   ajaxPost(stdAjaxPrefix+'&_mode=rename', 'newtitle='+ajaxEscape(r), function() {
   232     if(ajax.readyState == 4) {
   232     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   233       unsetAjaxLoading();
   233       unsetAjaxLoading();
   234       alert(ajax.responseText);
   234       alert(ajax.responseText);
   235     }
   235     }
   236   }, true);
   236   }, true);
   237 }
   237 }
   241   // IE <6 pseudo-compatibility
   241   // IE <6 pseudo-compatibility
   242   if ( KILL_SWITCH )
   242   if ( KILL_SWITCH )
   243     return true;
   243     return true;
   244   setAjaxLoading();
   244   setAjaxLoading();
   245   ajaxPost(ENANO_SPECIAL_CREATEPAGE, ENANO_CREATEPAGE_PARAMS, function() {
   245   ajaxPost(ENANO_SPECIAL_CREATEPAGE, ENANO_CREATEPAGE_PARAMS, function() {
   246     if(ajax.readyState == 4) {
   246     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   247       unsetAjaxLoading();
   247       unsetAjaxLoading();
   248       window.location.reload();
   248       window.location.reload();
   249     }
   249     }
   250   });
   250   });
   251 }
   251 }
   265   {
   265   {
   266     return;
   266     return;
   267   }
   267   }
   268   setAjaxLoading();
   268   setAjaxLoading();
   269   ajaxPost(stdAjaxPrefix+'&_mode=deletepage', 'reason=' + ajaxEscape(reason), function() {
   269   ajaxPost(stdAjaxPrefix+'&_mode=deletepage', 'reason=' + ajaxEscape(reason), function() {
   270     if(ajax.readyState == 4) {
   270     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   271       unsetAjaxLoading();
   271       unsetAjaxLoading();
   272       alert(ajax.responseText);
   272       alert(ajax.responseText);
   273       window.location.reload();                                                                           
   273       window.location.reload();                                                                           
   274     }
   274     }
   275   });
   275   });
   282     return true;
   282     return true;
   283   c = confirm($lang.get('ajax_delvote_confirm'));
   283   c = confirm($lang.get('ajax_delvote_confirm'));
   284   if(!c) return;
   284   if(!c) return;
   285   setAjaxLoading();
   285   setAjaxLoading();
   286   ajaxGet(stdAjaxPrefix+'&_mode=delvote', function() {
   286   ajaxGet(stdAjaxPrefix+'&_mode=delvote', function() {
   287     if(ajax.readyState == 4) {
   287     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   288       unsetAjaxLoading();
   288       unsetAjaxLoading();
   289       alert(ajax.responseText);
   289       alert(ajax.responseText);
   290     }
   290     }
   291   }, true);
   291   }, true);
   292 }
   292 }
   298     return true;
   298     return true;
   299   c = confirm($lang.get('ajax_delvote_reset_confirm'));
   299   c = confirm($lang.get('ajax_delvote_reset_confirm'));
   300   if(!c) return;
   300   if(!c) return;
   301   setAjaxLoading();
   301   setAjaxLoading();
   302   ajaxGet(stdAjaxPrefix+'&_mode=resetdelvotes', function() {
   302   ajaxGet(stdAjaxPrefix+'&_mode=resetdelvotes', function() {
   303     if(ajax.readyState == 4) {
   303     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   304       unsetAjaxLoading();
   304       unsetAjaxLoading();
   305       alert(ajax.responseText);
   305       alert(ajax.responseText);
   306       item = document.getElementById('mdgDeleteVoteNoticeBox');
   306       item = document.getElementById('mdgDeleteVoteNoticeBox');
   307       if(item)
   307       if(item)
   308       {
   308       {
   321   document.getElementById('wikibtn_0').style.textDecoration = 'none';
   321   document.getElementById('wikibtn_0').style.textDecoration = 'none';
   322   document.getElementById('wikibtn_1').style.textDecoration = 'none';
   322   document.getElementById('wikibtn_1').style.textDecoration = 'none';
   323   document.getElementById('wikibtn_2').style.textDecoration = 'none';
   323   document.getElementById('wikibtn_2').style.textDecoration = 'none';
   324   document.getElementById('wikibtn_'+val).style.textDecoration = 'underline';
   324   document.getElementById('wikibtn_'+val).style.textDecoration = 'underline';
   325   ajaxGet(stdAjaxPrefix+'&_mode=setwikimode&mode='+val, function() {
   325   ajaxGet(stdAjaxPrefix+'&_mode=setwikimode&mode='+val, function() {
   326     if(ajax.readyState == 4) {
   326     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   327       unsetAjaxLoading();
   327       unsetAjaxLoading();
   328       if(ajax.responseText!='GOOD')
   328       if(ajax.responseText!='GOOD')
   329       {
   329       {
   330         alert(ajax.responseText);
   330         alert(ajax.responseText);
   331       }
   331       }
   342   // IE <6 pseudo-compatibility
   342   // IE <6 pseudo-compatibility
   343   if ( KILL_SWITCH )
   343   if ( KILL_SWITCH )
   344     return true;
   344     return true;
   345   setAjaxLoading();
   345   setAjaxLoading();
   346   ajaxGet(stdAjaxPrefix+'&_mode=catedit', function() {
   346   ajaxGet(stdAjaxPrefix+'&_mode=catedit', function() {
   347     if(ajax.readyState == 4) {
   347     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   348       unsetAjaxLoading();
   348       unsetAjaxLoading();
   349       edit_open = false;
   349       edit_open = false;
   350       eval(ajax.responseText);
   350       eval(ajax.responseText);
   351     }
   351     }
   352   });
   352   });
   370     if(s) query = query + '&' + catlist[i] + '=true';
   370     if(s) query = query + '&' + catlist[i] + '=true';
   371   }
   371   }
   372   setAjaxLoading();
   372   setAjaxLoading();
   373   query = query.substring(1, query.length);
   373   query = query.substring(1, query.length);
   374   ajaxPost(stdAjaxPrefix+'&_mode=catsave', query, function() {
   374   ajaxPost(stdAjaxPrefix+'&_mode=catsave', query, function() {
   375     if(ajax.readyState == 4) {
   375     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   376       unsetAjaxLoading();
   376       unsetAjaxLoading();
   377       edit_open = false;
   377       edit_open = false;
   378       if(ajax.responseText != 'GOOD') alert(ajax.responseText);
   378       if(ajax.responseText != 'GOOD') alert(ajax.responseText);
   379       ajaxReset();
   379       ajaxReset();
   380     }
   380     }
   388   // IE <6 pseudo-compatibility
   388   // IE <6 pseudo-compatibility
   389   if ( KILL_SWITCH )
   389   if ( KILL_SWITCH )
   390     return true;
   390     return true;
   391   setAjaxLoading();
   391   setAjaxLoading();
   392   ajaxGet(stdAjaxPrefix+'&_mode=histlist', function() {
   392   ajaxGet(stdAjaxPrefix+'&_mode=histlist', function() {
   393     if(ajax.readyState == 4) {
   393     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   394       unsetAjaxLoading();
   394       unsetAjaxLoading();
   395       edit_open = false;
   395       edit_open = false;
   396       selectButtonMajor('article');
   396       selectButtonMajor('article');
   397       selectButtonMinor('history');
   397       selectButtonMinor('history');
   398       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   398       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   406   if ( KILL_SWITCH )
   406   if ( KILL_SWITCH )
   407     return true;
   407     return true;
   408   if(!tit) tit=title;
   408   if(!tit) tit=title;
   409   setAjaxLoading();
   409   setAjaxLoading();
   410   ajaxGet(append_sid(scriptPath+'/ajax.php?title='+tit+'&_mode=getpage&oldid='+oldid), function() {
   410   ajaxGet(append_sid(scriptPath+'/ajax.php?title='+tit+'&_mode=getpage&oldid='+oldid), function() {
   411     if(ajax.readyState == 4) {
   411     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   412       unsetAjaxLoading();
   412       unsetAjaxLoading();
   413       edit_open = false;
   413       edit_open = false;
   414       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   414       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   415     }
   415     }
   416   });
   416   });
   420   // IE <6 pseudo-compatibility
   420   // IE <6 pseudo-compatibility
   421   if ( KILL_SWITCH )
   421   if ( KILL_SWITCH )
   422     return true;
   422     return true;
   423   setAjaxLoading();
   423   setAjaxLoading();
   424   ajaxGet(stdAjaxPrefix+'&_mode=rollback&id='+id, function() {
   424   ajaxGet(stdAjaxPrefix+'&_mode=rollback&id='+id, function() {
   425     if(ajax.readyState == 4) {
   425     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   426       unsetAjaxLoading();
   426       unsetAjaxLoading();
   427       alert(ajax.responseText);
   427       alert(ajax.responseText);
   428     }
   428     }
   429   });
   429   });
   430 }
   430 }
   438   if(!c) return;
   438   if(!c) return;
   439   c = confirm($lang.get('ajax_clearlogs_confirm_nag'));
   439   c = confirm($lang.get('ajax_clearlogs_confirm_nag'));
   440   if(!c) return;
   440   if(!c) return;
   441   setAjaxLoading();
   441   setAjaxLoading();
   442   ajaxGet(stdAjaxPrefix+'&_mode=flushlogs', function() {
   442   ajaxGet(stdAjaxPrefix+'&_mode=flushlogs', function() {
   443     if(ajax.readyState == 4) {
   443     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   444       unsetAjaxLoading();
   444       unsetAjaxLoading();
   445       alert(ajax.responseText);
   445       alert(ajax.responseText);
   446       window.location.reload();
   446       window.location.reload();
   447     }
   447     }
   448   });
   448   });
   522   }
   522   }
   523   if(!id1 || !id2) { alert('BUG: Couldn\'t get checked radiobutton state'); return; }
   523   if(!id1 || !id2) { alert('BUG: Couldn\'t get checked radiobutton state'); return; }
   524   setAjaxLoading();
   524   setAjaxLoading();
   525   ajaxGet(stdAjaxPrefix+'&_mode=pagediff&diff1='+id1+'&diff2='+id2, function()
   525   ajaxGet(stdAjaxPrefix+'&_mode=pagediff&diff1='+id1+'&diff2='+id2, function()
   526     {
   526     {
   527       if(ajax.readyState==4)
   527       if ( ajax.readyState == 4 && ajax.status == 200 )
   528       {
   528       {
   529         unsetAjaxLoading();
   529         unsetAjaxLoading();
   530         document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   530         document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   531       }
   531       }
   532     });
   532     });
   563   if ( id == '_blank' )
   563   if ( id == '_blank' )
   564   {
   564   {
   565     return null;
   565     return null;
   566   }
   566   }
   567   ajaxGet(stdAjaxPrefix + '&_mode=getstyles&id=' + id, function() {
   567   ajaxGet(stdAjaxPrefix + '&_mode=getstyles&id=' + id, function() {
   568       if ( ajax.readyState == 4 )
   568       if ( ajax.readyState == 4 && ajax.status == 200 )
   569       {
   569       {
   570         // IE doesn't like substr() on ajax.responseText
   570         // IE doesn't like substr() on ajax.responseText
   571         var response = String(ajax.responseText + ' ');
   571         var response = String(ajax.responseText + ' ');
   572         response = response.substr(0, response.length - 1);
   572         response = response.substr(0, response.length - 1);
   573         if ( response.substr(0,1) != '[' )
   573         if ( response.substr(0,1) != '[' )
   638     return true;
   638     return true;
   639   }
   639   }
   640   
   640   
   641   ajaxPost(stdAjaxPrefix + '&_mode=change_theme', 'theme_id=' + ajaxEscape(theme_id) + '&style_id=' + ajaxEscape(style_id), function()
   641   ajaxPost(stdAjaxPrefix + '&_mode=change_theme', 'theme_id=' + ajaxEscape(theme_id) + '&style_id=' + ajaxEscape(style_id), function()
   642     {
   642     {
   643       if ( ajax.readyState == 4 )
   643       if ( ajax.readyState == 4 && ajax.status == 200 )
   644       {
   644       {
   645         if ( ajax.responseText == 'GOOD' )
   645         if ( ajax.responseText == 'GOOD' )
   646         {
   646         {
   647           var c = confirm($lang.get('ajax_changestyle_success'));
   647           var c = confirm($lang.get('ajax_changestyle_success'));
   648           if ( c )
   648           if ( c )
   694 }
   694 }
   695 
   695 
   696 function ajaxGetStyles(id) {
   696 function ajaxGetStyles(id) {
   697   setAjaxLoading();
   697   setAjaxLoading();
   698   ajaxGet(stdAjaxPrefix+'&_mode=getstyles&id='+id, function() {
   698   ajaxGet(stdAjaxPrefix+'&_mode=getstyles&id='+id, function() {
   699     if(ajax.readyState == 4) {
   699     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   700       unsetAjaxLoading();
   700       unsetAjaxLoading();
   701       eval(ajax.responseText);
   701       eval(ajax.responseText);
   702       html = '<h3>And a style...</h3><select id="mdgStyleID" name="style">';
   702       html = '<h3>And a style...</h3><select id="mdgStyleID" name="style">';
   703       for(i=0;i<list.length;i++) {
   703       for(i=0;i<list.length;i++) {
   704         lname = list[i].substr(0, 1).toUpperCase() + list[i].substr(1, list[i].length);
   704         lname = list[i].substr(0, 1).toUpperCase() + list[i].substr(1, list[i].length);
   737   pass = hex_sha1(document.getElementById('mdgPassSetField').value);
   737   pass = hex_sha1(document.getElementById('mdgPassSetField').value);
   738   setAjaxLoading();
   738   setAjaxLoading();
   739   ajaxPost(stdAjaxPrefix+'&_mode=setpass', 'password='+pass, function()
   739   ajaxPost(stdAjaxPrefix+'&_mode=setpass', 'password='+pass, function()
   740     {
   740     {
   741       unsetAjaxLoading();
   741       unsetAjaxLoading();
   742       if(ajax.readyState==4)
   742       if ( ajax.readyState == 4 && ajax.status == 200 )
   743       {
   743       {
   744         alert(ajax.responseText);
   744         alert(ajax.responseText);
   745       }
   745       }
   746     }, true);
   746     }, true);
   747 }
   747 }
   861     return false;
   861     return false;
   862   }
   862   }
   863   $killdiv.object.innerHTML = '<img alt="Loading..." src="' + scriptPath + '/images/loading-big.gif" /><br />Making request...';
   863   $killdiv.object.innerHTML = '<img alt="Loading..." src="' + scriptPath + '/images/loading-big.gif" /><br />Making request...';
   864   var url = makeUrlNS('Admin', 'Home', 'src=ajax');
   864   var url = makeUrlNS('Admin', 'Home', 'src=ajax');
   865   ajaxPost(url, 'act=kill_php', function() {
   865   ajaxPost(url, 'act=kill_php', function() {
   866       if ( ajax.readyState == 4 )
   866       if ( ajax.readyState == 4 && ajax.status == 200 )
   867       {
   867       {
   868         if ( ajax.responseText == '1' )
   868         if ( ajax.responseText == '1' )
   869         {
   869         {
   870           var $killdiv = $dynano('php_killer');
   870           var $killdiv = $dynano('php_killer');
   871           //$killdiv.object.innerHTML = '<img alt="Success" src="' + scriptPath + '/images/error.png" /><br />Embedded PHP in pages has been disabled.';
   871           //$killdiv.object.innerHTML = '<img alt="Success" src="' + scriptPath + '/images/error.png" /><br />Embedded PHP in pages has been disabled.';
   893   if ( KILL_SWITCH )
   893   if ( KILL_SWITCH )
   894     return false;
   894     return false;
   895   setAjaxLoading();
   895   setAjaxLoading();
   896   ajaxGet(stdAjaxPrefix + '&_mode=get_tags', function()
   896   ajaxGet(stdAjaxPrefix + '&_mode=get_tags', function()
   897     {
   897     {
   898       if ( ajax.readyState == 4 )
   898       if ( ajax.readyState == 4 && ajax.status == 200 )
   899       {
   899       {
   900         unsetAjaxLoading();
   900         unsetAjaxLoading();
   901         var resptext = String(ajax.responseText + ' ');
   901         var resptext = String(ajax.responseText + ' ');
   902         resptext = resptext.substr(0, resptext.length-1);
   902         resptext = resptext.substr(0, resptext.length-1);
   903         if ( resptext.substr(0, 1) != '{' )
   903         if ( resptext.substr(0, 1) != '{' )
   991   addtag_nukeme = nukeme;
   991   addtag_nukeme = nukeme;
   992   tag = ajaxEscape(tag);
   992   tag = ajaxEscape(tag);
   993   setAjaxLoading();
   993   setAjaxLoading();
   994   ajaxPost(stdAjaxPrefix + '&_mode=addtag', 'tag=' + tag, function()
   994   ajaxPost(stdAjaxPrefix + '&_mode=addtag', 'tag=' + tag, function()
   995     {
   995     {
   996       if ( ajax.readyState == 4 )
   996       if ( ajax.readyState == 4 && ajax.status == 200 )
   997       {
   997       {
   998         unsetAjaxLoading();
   998         unsetAjaxLoading();
   999         var nukeme = addtag_nukeme;
   999         var nukeme = addtag_nukeme;
  1000         addtag_nukeme = false;
  1000         addtag_nukeme = false;
  1001         var resptext = String(ajax.responseText + ' ');
  1001         var resptext = String(ajax.responseText + ' ');
  1063     if ( parentobj.nextSibling.nextSibling.firstChild.nodeValue == $lang.get('tags_btn_add_tag'))
  1063     if ( parentobj.nextSibling.nextSibling.firstChild.nodeValue == $lang.get('tags_btn_add_tag'))
  1064       writeNoTags = true;
  1064       writeNoTags = true;
  1065     
  1065     
  1066   ajaxPost(stdAjaxPrefix + '&_mode=deltag', 'tag_id=' + String(tag_id), function()
  1066   ajaxPost(stdAjaxPrefix + '&_mode=deltag', 'tag_id=' + String(tag_id), function()
  1067     {
  1067     {
  1068       if ( ajax.readyState == 4 )
  1068       if ( ajax.readyState == 4 && ajax.status == 200 )
  1069       {
  1069       {
  1070         if ( ajax.responseText == 'success' )
  1070         if ( ajax.responseText == 'success' )
  1071         {
  1071         {
  1072           for ( var i = 0; i < arrDelete.length; i++ )
  1072           for ( var i = 0; i < arrDelete.length; i++ )
  1073           {
  1073           {
  1203   img.src = scriptPath + '/images/loading.gif';
  1203   img.src = scriptPath + '/images/loading.gif';
  1204   img.alt = 'Loading...';
  1204   img.alt = 'Loading...';
  1205   target.appendChild(img);
  1205   target.appendChild(img);
  1206   ajaxGet(makeUrlNS('Admin', 'Home/updates.xml'), function()
  1206   ajaxGet(makeUrlNS('Admin', 'Home/updates.xml'), function()
  1207     {
  1207     {
  1208       if ( ajax.readyState == 4 )
  1208       if ( ajax.readyState == 4 && ajax.status == 200 )
  1209       {
  1209       {
  1210         var releases = new Array();
  1210         var releases = new Array();
  1211         var update_available = false;
  1211         var update_available = false;
  1212         if ( ajax.responseXML == null )
  1212         if ( ajax.responseXML == null )
  1213         {
  1213         {