-
Notifications
You must be signed in to change notification settings - Fork 90
/
localstorage.html
executable file
·144 lines (132 loc) · 9.95 KB
/
localstorage.html
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<html>
<title>Draw.io Embedded</title>
<head>
<style type="text/css">
html, body, #wrapper {
height:100%;
width:100%;
margin:0;
padding:0;
border:0;
}
table#wrapper {
height:75%;
}
#wrapper td {
vertical-align:middle;
text-align:center;
}
iframe {
border:0;
position:fixed;
top:0;
left:0;
right:0;
bottom:0;
width:100%;
height:100%
}
</style>
<script type="text/javascript">
var editor = 'https://embed.diagrams.net/?embed=1&ui=atlas&spin=1&proto=json';
var initial = null;
var name = null;
function edit(image)
{
var iframe = document.createElement('iframe');
iframe.setAttribute('frameborder', '0');
var close = function()
{
window.removeEventListener('message', receive);
document.body.removeChild(iframe);
};
var draft = localStorage.getItem('.draft-' + name);
if (draft != null)
{
draft = JSON.parse(draft);
if (!confirm("A version of this page from " + new Date(draft.lastModified) + " is available. Would you like to continue editing?"))
{
draft = null;
}
}
var receive = function(evt)
{
if (evt.data.length > 0)
{
var msg = JSON.parse(evt.data);
if (msg.event == 'init')
{
if (draft != null)
{
iframe.contentWindow.postMessage(JSON.stringify({action: 'load',
autosave: 1, xml: draft.xml}), '*');
iframe.contentWindow.postMessage(JSON.stringify({action: 'status',
modified: true}), '*');
}
else
{
iframe.contentWindow.postMessage(JSON.stringify({action: 'load',
autosave: 1, xmlpng: image.getAttribute('src')}), '*');
}
}
else if (msg.event == 'export')
{
image.setAttribute('src', msg.data);
localStorage.setItem(name, JSON.stringify({lastModified: new Date(), data: msg.data}));
localStorage.removeItem('.draft-' + name);
draft = null;
close();
}
else if (msg.event == 'autosave')
{
localStorage.setItem('.draft-' + name, JSON.stringify({lastModified: new Date(), xml: msg.xml}));
}
else if (msg.event == 'save')
{
iframe.contentWindow.postMessage(JSON.stringify({action: 'export',
format: 'xmlpng', xml: msg.xml, spin: 'Updating page'}), '*');
localStorage.setItem('.draft-' + name, JSON.stringify({lastModified: new Date(), xml: msg.xml}));
}
else if (msg.event == 'exit')
{
localStorage.removeItem('.draft-' + name);
draft = null;
close();
}
}
};
window.addEventListener('message', receive);
iframe.setAttribute('src', editor);
document.body.appendChild(iframe);
};
function load()
{
initial = document.getElementById('image').getAttribute('src');
start();
};
function start()
{
name = (window.location.hash.length > 1) ? window.location.hash.substring(1) : 'default';
var current = localStorage.getItem(name);
if (current != null)
{
var entry = JSON.parse(current);
document.getElementById('image').setAttribute('src', entry.data);
}
else
{
document.getElementById('image').setAttribute('src', initial);
}
};
window.addEventListener('hashchange', start);
</script>
</head>
<body onload="load();">
<table id="wrapper">
<tr>
<td><img id="image" style="max-width:100%;cursor:pointer;" onclick="edit(this);" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMwAAABBCAYAAACdDEv0AAAACXBIWXMAAAsTAAALEwEAmpwYAAABY3pUWHRteEdyYXBoTW9kZWwAAIVTwXKDIBD9Gk9OZxTaNLnGNsmlpxx6prAqExQH0Zh+fQGX6jidKRf3vX0syz5MaNFMZ8O6+kMLUKmYEvqWEJLnh1f3ScVjxgfy7GFlpEBBhFf5DUhlgRukgH4lslorK7s1xXXbArcrptRqXbhjFWzglTO15T6lsPXM7ckusheQVR2L57uD578Yv1VGDy2ekhBahuWTvX3E0gJKNij7FCjikw2LR/jrJfQ9oYXR2s5RMxWgVBqnEiTk9GcOuzbQ2v/FNAvjH5kasLNCSX5LazCwafleSwvXjnGP787KhB5r2yiHcheWurUn1kjlnby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fcX3ZuImKBCQoGAvestbUVve8XWG3/SEKmmBcWqJE0iqmGL6HL0cnIKvL1dxdfSpbS0NBwXDeslAkLBoJAwN69exFCYHb9AOPQA8yxNKp0R7U4ijOOI2BAWPS54C++HbfuhrLzmqZhGAarV68+Zgd/LE5IMEMcOHCAVCqFEIJQ51bM7u+hiyxJLU/C1Igq8ShOEzkf0r5kQEQQehx33ifwFnx6VD7DMEgkEscMHR+LkxIMwMDAAO3t7fi+j5QSLbefUO+PMY/+HOl0k7QsdD9NSNcwNco2hWIieBI8AR7B0teelAg9zoDjQngefs0G3DkfKs6ULEXTNEzTZNGiRRX3V8bipAUzxJEjR+jo6EDTNERhVXnN60cf3I6e34eRa0VzOsA9ivRSGGYVnt1xHKsKRYAZXojvDaKFqsCsRoYX4UeW4YdXIJLriqu7jETTtOJAyrlz5550PSZNMEN0d3fT09NTbHEUijPBUD+lrq6O2traybM72YIZwrZt+vr6GBgYKP62hhBqNqfi1GAYBkIILMsimUxSU1NTNlNysjhlginF8zzS6TS5XA7btnFdF8/z8H0fwzBwHDVOTVEZlmUV7xvTNLEsC8uyiMVixOPx4uoup4rTIhiFYrrw/1vRo9r+4Wx4AAAAAElFTkSuQmCC" /></td>
</tr>
</table>
<div style="position:fixed;font-family:Arial,Helvetica;font-size:10pt;color:#cccccc;bottom:0px;right:0px;margin-right:10px;margin-bottom:10px;">Powered by <a href="https://www.diagrams.net" target="_blank"/>diagrams.net</a></div>
</body>
</html>