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