mirror of
https://github.com/webodf/WebODF.git
synced 2026-11-30 16:47:58 +01:00
Dependencies between classes are listed in the manifest.json files.
These files list what classes are required to load other classes. Yet, each eval
of a class can trigger loading of a required class. This means that the request
for a particular class is only sent out when the class that needs it is loaded.
This patch adds a new function:
runtime.loadClasses(classNames, callback);
This function creates a list of all required classes before doing any loading.
If the environment is the browser and a callback is provided, the list of files
is added as <script/> tags to the DOM. This means the browser can request all
files at once. The callback is attached to the onload trigger of the last
<script/> tag.
If no callback is provided, the files are still loaded synchronously.
runtime.loadClass is still present but redundant, since the runtime already
knows what classes are needed for other classes.
odf.html is adapted to use the new class.
43 lines
1.2 KiB
HTML
43 lines
1.2 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<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;
|
|
}
|
|
</style>
|
|
<script src="lib/runtime.js" type="text/javascript" charset="utf-8"></script>
|
|
<script type="text/javascript" charset="utf-8">
|
|
function init() {
|
|
// if the url has a fragment (#...), try to load the file it represents
|
|
var location = String(document.location),
|
|
pos = location.indexOf('#'),
|
|
odfelement = document.getElementById("odf");
|
|
document.odfcanvas = new odf.OdfCanvas(odfelement);
|
|
if (pos === -1 || !window) {
|
|
return;
|
|
}
|
|
location = location.substr(pos + 1);
|
|
document.odfcanvas.load(location);
|
|
}
|
|
runtime.loadClass("odf.OdfCanvas", init);
|
|
</script>
|
|
<title></title>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="odf"/>
|
|
</body>
|
|
</html>
|