node-webodf
Version:
WebODF - JavaScript Document Engine http://webodf.org/
118 lines (115 loc) • 3.45 kB
Plain Text
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<style type="text/css" media="screen, print">
body, html, div {
padding: 0px;
margin: 0px;
border: 0px;
}
body, html {
height: 100%;
text-align: center;
}
html > body {
background: black;
}
div#toolbar {
background: white;
padding: 7px;
border-bottom: 1px solid black;
}
div#toolbar > span.button {
border: 1px solid black;
padding: 2px;
cursor: default;
}
div#toolbar > span.button:hover {
background: #CCCCCC;
}
</style>
<script type="text/javascript">
////<![CDATA[
@WEBODF_JS@
//]]>
</script>
<script type="text/javascript">
var WEBODF_MESSAGE_EVENT_ID = 'webodf.message';
var FirefoxCom = (function FirefoxComClosure() {
return {
/**
* Creates an event that the extension is listening for and will
* asynchronously respond by calling the callback.
* @param {String} action The action to trigger.
* @param {String} data Optional data to send.
* @param {Function} callback Optional response callback that will be called
* with one data argument.
*/
request: function(action, data, callback) {
var event,
eventDetail = {
"action" : action,
"data": data
};
event = new CustomEvent(WEBODF_MESSAGE_EVENT_ID, {"bubbles":true, "detail":eventDetail});
return document.dispatchEvent(event);
}
};
})();
var webodffirefox = {
url: undefined,
data: undefined,
odfcanvas: undefined
};
function loadODF() {
runtime.loadClass("odf.OdfCanvas");
var wf = webodffirefox,
odfelement = document.getElementById("odf");
wf.url = document.location.href;
wf.odfcanvas = new odf.OdfCanvas(odfelement);
wf.odfcanvas.load(wf.url);
}
function addButton(parent, label, onclick) {
var doc = parent.ownerDocument,
button = doc.createElement("span");
button.className = "button";
button.appendChild(doc.createTextNode(label));
button.onclick = onclick;
parent.appendChild(button);
}
function addSpacer(parent) {
var doc = parent.ownerDocument,
spacer = doc.createElement("span");
spacer.appendChild(doc.createTextNode(" "));
parent.appendChild(spacer);
}
function init() {
runtime.loadClass("core.Base64");
var toolbar = document.getElementById("toolbar");
addButton(toolbar, "download this document", function onclick() {
FirefoxCom.request('download', { originalUrl: webodffirefox.url });
});
addSpacer(toolbar);
addButton(toolbar, "about WebODF", function onclick() {
document.location.href = "http://webodf.org/about/";
});
addSpacer(toolbar);
addButton(toolbar, "get the source code", function onclick() {
document.location.href = "https://github.com/kogmbh/WebODF/";
});
loadODF();
}
window.setTimeout(function () {
init();
}, 1);
//--></script>
<title></title>
</head>
<body>
<div id="toolbar">
</div>
<div id="odf"/>
</body>
</html>