clear.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. try
  2. {
  3. function write(text)
  4. {
  5. document.body.appendChild(document.createTextNode(text));
  6. };
  7. function writeln(text)
  8. {
  9. write(text);
  10. document.body.appendChild(document.createElement('br'));
  11. };
  12. write('Clearing Cached version ' + EditorUi.VERSION + '...');
  13. navigator.serviceWorker.getRegistrations().then(function(registrations)
  14. {
  15. if (registrations != null && registrations.length > 0)
  16. {
  17. for (var i = 0; i < registrations.length; i++)
  18. {
  19. registrations[i].unregister();
  20. }
  21. writeln('Done');
  22. }
  23. else
  24. {
  25. writeln('OK');
  26. }
  27. var link = document.createElement('a');
  28. link.style.marginRight = '6px';
  29. link.setAttribute('href', 'javascript:window.location.reload();');
  30. link.appendChild(document.createTextNode('Reload'));
  31. document.body.appendChild(link);
  32. if ((/test\.draw\.io$/.test(window.location.hostname)) ||
  33. (/preprod\.diagrams\.net$/.test(window.location.hostname)) ||
  34. (/app\.diagrams\.net$/.test(window.location.hostname)))
  35. {
  36. link = link.cloneNode(false);
  37. link.setAttribute('href', './');
  38. link.appendChild(document.createTextNode('Start App'));
  39. document.body.appendChild(link);
  40. }
  41. });
  42. // Clears corresponding domain of current domain
  43. var iframe = document.createElement('iframe');
  44. iframe.style.display = 'none';
  45. if (window.location.hostname == 'ac.draw.io')
  46. {
  47. iframe.src = 'https://clear.diagrams.net';
  48. }
  49. else
  50. {
  51. iframe.src = 'https://clear.draw.io';
  52. }
  53. document.body.appendChild(iframe);
  54. }
  55. catch (e)
  56. {
  57. write('Error: ' + e.message);
  58. }