You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.6KB

  1. (function () {
  2. var ajax = function (url, settings) {
  3. var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
  4. settings = settings || {};
  5. xhr.open(settings.method || 'GET', url, true);
  6. xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  7. xhr.setRequestHeader('Accept', 'text/html');
  8. xhr.onreadystatechange = function (state) {
  9. if (xhr.readyState == 4) {
  10. if (xhr.status == 200 && settings.success) {
  11. settings.success(xhr);
  12. } else if (xhr.status != 200 && settings.error) {
  13. settings.error(xhr);
  14. }
  15. }
  16. };
  17. xhr.send(settings.data || '');
  18. };
  19. var e = document.getElementById('yii-debug-toolbar');
  20. if (e) {
  21. e.style.display = 'block';
  22. var url = e.getAttribute('data-url');
  23. ajax(url, {
  24. success: function (xhr) {
  25. var div = document.createElement('div');
  26. div.innerHTML = xhr.responseText;
  27. e.parentNode.replaceChild(div, e);
  28. if (window.localStorage) {
  29. var pref = localStorage.getItem('yii-debug-toolbar');
  30. if (pref == 'minimized') {
  31. document.getElementById('yii-debug-toolbar').style.display = 'none';
  32. document.getElementById('yii-debug-toolbar-min').style.display = 'block';
  33. }
  34. }
  35. },
  36. error: function (xhr) {
  37. e.innerHTML = xhr.responseText;
  38. }
  39. });
  40. }
  41. })();