includes/clientside/static/ajax.js
changeset 527 21e11f564463
parent 526 b2fb50d572c7
child 537 547b7ba6d535
equal deleted inserted replaced
526:b2fb50d572c7 527:21e11f564463
  1566         }
  1566         }
  1567       });
  1567       });
  1568     return true;
  1568     return true;
  1569   }
  1569   }
  1570   action = action.replace(/_confirm$/, '');
  1570   action = action.replace(/_confirm$/, '');
       
  1571   // white-out the plugin info box
       
  1572   if ( btnobj )
       
  1573   {
       
  1574     var td = btnobj.parentNode.parentNode.parentNode.parentNode;
       
  1575     var blackbox = whiteOutElement(td);
       
  1576   }
  1571   var request = toJSONString({
  1577   var request = toJSONString({
  1572       mode: action,
  1578       mode: action,
  1573       plugin: plugin_filename
  1579       plugin: plugin_filename
  1574     });
  1580     });
  1575   ajaxPost(makeUrlNS('Admin', 'PluginManager/action.json'), 'r=' + ajaxEscape(request), function()
  1581   ajaxPost(makeUrlNS('Admin', 'PluginManager/action.json'), 'r=' + ajaxEscape(request), function()
  1576     {
  1582     {
  1577       if ( ajax.readyState == 4 && ajax.status == 200 )
  1583       if ( ajax.readyState == 4 && ajax.status == 200 )
  1578       {
  1584       {
  1579         if ( ajax.responseText == 'good' )
  1585         var response = String(ajax.responseText + '');
  1580         {
  1586         if ( response.substr(0, 1) != '{' )
       
  1587         {
       
  1588           handle_invalid_json(response);
       
  1589           return false;
       
  1590         }
       
  1591         response = parseJSON(response);
       
  1592         if ( response.success )
       
  1593         {
       
  1594           if ( blackbox )
       
  1595           {
       
  1596             blackbox.parentNode.removeChild(blackbox);
       
  1597           }
  1581           ajaxPage( namespace_list['Admin'] + 'PluginManager' );
  1598           ajaxPage( namespace_list['Admin'] + 'PluginManager' );
  1582         }
  1599           return true;
  1583         else
  1600         } 
  1584         {
  1601         // wait for fade effect to finish its run
  1585           var response = String(ajax.responseText + '');
  1602         setTimeout(function()
  1586           if ( response.substr(0, 1) != '{' )
       
  1587           {
  1603           {
  1588             handle_invalid_json(response);
  1604             miniPrompt(function(div)
  1589             return false;
  1605               {
  1590           }
  1606                 if ( blackbox )
  1591           response = parseJSON(response);
       
  1592           if ( response.mode != 'error' )
       
  1593           {
       
  1594             console.debug(response);
       
  1595             return false;
       
  1596           }
       
  1597           // wait for fade effect to finish its run
       
  1598           setTimeout(function()
       
  1599             {
       
  1600               miniPrompt(function(div)
       
  1601                 {
  1607                 {
  1602                   var txtholder = document.createElement('div');
  1608                   blackbox.parentNode.removeChild(blackbox);
  1603                   txtholder.style.textAlign = 'center';
  1609                 }
  1604                   txtholder.appendChild(document.createTextNode(response.error));
  1610                 var txtholder = document.createElement('div');
  1605                   txtholder.appendChild(document.createElement('br'));
  1611                 txtholder.style.textAlign = 'center';
  1606                   txtholder.appendChild(document.createElement('br'));
  1612                 txtholder.appendChild(document.createTextNode(response.error));
  1607                   
  1613                 txtholder.appendChild(document.createElement('br'));
  1608                   // close button
  1614                 txtholder.appendChild(document.createElement('br'));
  1609                   var btn_cancel = document.createElement('a');
  1615                 
  1610                   btn_cancel.className = 'abutton abutton_red';
  1616                 // close button
  1611                   btn_cancel.href = '#';
  1617                 var btn_cancel = document.createElement('a');
  1612                   btn_cancel.appendChild(document.createTextNode($lang.get('etc_ok')));
  1618                 btn_cancel.className = 'abutton abutton_red';
  1613                   
  1619                 btn_cancel.href = '#';
  1614                   txtholder.appendChild(btn_cancel);
  1620                 btn_cancel.appendChild(document.createTextNode($lang.get('etc_ok')));
  1615                   div.appendChild(txtholder);
  1621                 
  1616                   
  1622                 txtholder.appendChild(btn_cancel);
  1617                   btn_cancel.onclick = function()
  1623                 div.appendChild(txtholder);
  1618                   {
  1624                 
  1619                     miniPromptDestroy(this);
  1625                 btn_cancel.onclick = function()
  1620                     return false;
  1626                 {
  1621                   }
  1627                   miniPromptDestroy(this);
  1622                 });
  1628                   return false;
  1623             }, 750);
  1629                 }
  1624         }
  1630               });
       
  1631           }, 750);
  1625       }
  1632       }
  1626     });
  1633     });
  1627 }
  1634 }