mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 05:07:52 +00:00
7890fcae69
* [API] use new-style objects consistently * rewrite todo tutorial in test-api.html * [API] Add API doc, update object API * [Tutorials] Rename tutorials, remove old * Fix Links * updates * initial * hope this works * Object Utils always return new objects instead of mutating existing objects * keep domain object model in-sync when listening Keep the domain object model in sync with the latest version when listening for mutation events. * Remove old-style plugins * Update views to use new API * Tidy Code * Update API Docs * Add Plugin API and Example
51 lines
1.2 KiB
HTML
51 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
<title>Implementing a basic plugin</title>
|
|
<script src="dist/main.js"></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
|
|
function WebPlugin(websites) {
|
|
this.websites = websites;
|
|
|
|
var ROOTS = websites.reduce(function (rootMap, website) {
|
|
rootMap[website] = {
|
|
namespace: website,
|
|
identifier: 'page'
|
|
};
|
|
return rootMap;
|
|
}, {});
|
|
|
|
function installPlugin(MCT) {
|
|
Object.keys(ROOTS).forEach(function (rootUrl) {
|
|
MCT.Objects.addRoot(ROOTS[rootUrl]);
|
|
MCT.Objects.addProvider(rootUrl, {
|
|
get: function () {
|
|
return Promise.resolve({
|
|
type: 'example.page',
|
|
url: rootUrl,
|
|
name: rootUrl
|
|
});
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
return installPlugin;
|
|
}
|
|
|
|
var myWebPlugin = WebPlugin([
|
|
'http://www.wikipedia.org/',
|
|
'http://nasa.github.io/openmct'
|
|
]);
|
|
|
|
MCT.install(myWebPlugin);
|
|
|
|
MCT.run();
|
|
</script>
|
|
</body>
|
|
</html>
|