includes/clientside/static/ajax.js
changeset 481 07bf15b066bc
parent 436 242353360e37
child 522 fd46b1bf708e
equal deleted inserted replaced
480:d5376271f96b 481:07bf15b066bc
   214   document.getElementById('protbtn_2').style.textDecoration = 'none';
   214   document.getElementById('protbtn_2').style.textDecoration = 'none';
   215   document.getElementById('protbtn_'+l).style.textDecoration = 'underline';
   215   document.getElementById('protbtn_'+l).style.textDecoration = 'underline';
   216   ajaxPost(stdAjaxPrefix+'&_mode=protect', 'reason='+ajaxEscape(r)+'&level='+l, function() {
   216   ajaxPost(stdAjaxPrefix+'&_mode=protect', 'reason='+ajaxEscape(r)+'&level='+l, function() {
   217     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   217     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   218       unsetAjaxLoading();
   218       unsetAjaxLoading();
   219       if(ajax.responseText != 'good')
   219       if(ajax.responseText == 'good')
   220         alert(ajax.responseText);
   220         return true;
       
   221       // check for JSON error response
       
   222       var response = String(ajax.responseText + '');
       
   223       if ( response.substr(0, 1) == '{' )
       
   224       {
       
   225         response = parseJSON(response);
       
   226         if ( response.mode == 'error' )
       
   227         {
       
   228           alert(response.error);
       
   229           return true;
       
   230         }
       
   231       }
       
   232       alert(ajax.responseText);
   221     }
   233     }
   222   }, true);
   234   }, true);
   223 }
   235 }
   224 
   236 
   225 function ajaxRename()
   237 function ajaxRename()
   401       buildDiffList();
   413       buildDiffList();
   402     }
   414     }
   403   });
   415   });
   404 }
   416 }
   405 
   417 
   406 function ajaxHistView(oldid, tit) {
   418 function ajaxHistView(oldid, ttl) {
   407   // IE <6 pseudo-compatibility
   419   // IE <6 pseudo-compatibility
   408   if ( KILL_SWITCH )
   420   if ( KILL_SWITCH )
   409     return true;
   421     return true;
   410   if(!tit) tit=title;
   422   if(!ttl) ttl=title;
   411   setAjaxLoading();
   423   setAjaxLoading();
   412   ajaxGet(append_sid(scriptPath+'/ajax.php?title='+tit+'&_mode=getpage&oldid='+oldid), function() {
   424   ajaxGet(append_sid(scriptPath+'/ajax.php?title='+ttl+'&_mode=getpage&oldid='+oldid), function() {
   413     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   425     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   414       unsetAjaxLoading();
   426       unsetAjaxLoading();
   415       edit_open = false;
   427       edit_open = false;
   416       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   428       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   417     }
   429     }
   424     return true;
   436     return true;
   425   setAjaxLoading();
   437   setAjaxLoading();
   426   ajaxGet(stdAjaxPrefix+'&_mode=rollback&id='+id, function() {
   438   ajaxGet(stdAjaxPrefix+'&_mode=rollback&id='+id, function() {
   427     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   439     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   428       unsetAjaxLoading();
   440       unsetAjaxLoading();
   429       alert(ajax.responseText);
   441       
       
   442       var response = String(ajax.responseText + '');
       
   443       if ( response.substr(0, 1) != '{' )
       
   444       {
       
   445         handle_invalid_json(response);
       
   446         return false;
       
   447       }
       
   448       
       
   449       response = parseJSON(response);
       
   450       if ( response.success )
       
   451       {
       
   452         alert( $lang.get('page_msg_rb_success_' + response.action, { dateline: response.dateline }) )
       
   453       }
       
   454       else
       
   455       {
       
   456         if ( response.action )
       
   457         {
       
   458           alert( $lang.get('page_err_' + response.error, { action: response.action }) );
       
   459         }
       
   460         else
       
   461         {
       
   462           alert( $lang.get('page_err_' + response.error) );
       
   463         }
       
   464       }
   430     }
   465     }
   431   });
   466   });
   432 }
   467 }
   433 
   468 
   434 function ajaxClearLogs()
   469 function ajaxClearLogs()