-
Notifications
You must be signed in to change notification settings - Fork 6
/
webodf.html
53 lines (50 loc) · 1.54 KB
/
webodf.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
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/webodf.css"/>
<script src="js/require.js"></script>
<script src="extjs/ext-all.js" type="text/javascript" charset="utf-8"></script>
<script src="/lib/runtime.js" type="text/javascript" charset="utf-8"></script>
<script src="js/models/document.js" type="text/javascript" charset="utf-8"></script>
<script src="js/sync.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
function getPad(cb) {
fetchDocumentId(getCurrDocOwner(), getCurrDocLink(), function(id) {
var documents = localGet('documents') || '{}';
if(id && documents[id]) {
documents[id].timestamp = new Date().getTime();
localSet('documents', documents);
cb(documents[id]);
} else {
alert("Could not find document " + getCurrDocLink() + " from " + getCurrDocOwner());
}
});
}
function getCurrDocOwner() {
if(location.hash.length) {
return location.hash.split('/')[0].substring(1);
} else {
window.location.href = 'welcome.html';
}
}
function getCurrDocLink() {
if(location.hash.length) {
return location.hash.substr(location.hash.indexOf('/') + 1);
} else {
window.location.href = 'welcome.html';
}
}
function init() {
runtime.loadClass("odf.OdfCanvas");
var odfelement = document.getElementById("odf"),
odfcanvas = new odf.OdfCanvas(odfelement);
getPad(function(doc) {
odfcanvas.load(doc.data);
});
}
window.setTimeout(init, 0);
</script>
</head>
<body>
<div id="odf"></div>
</body>
</html>