Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom methods #47

Merged
merged 8 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions example/initialization/1_e_index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<title>Embedded Content Consuming Site</title>
<meta charset="utf-8" />
<script src="http://localhost:8080/xfc.js"></script>
<style>
iframe {
width: 100%;
border: none;
margin: 0;
padding: 0;
}
html[hidden] { display: none; }
.xfc[data-status='mounted'] {
border: 5px dashed #000;
}
.xfc[data-status='launched'] {
border: 5px dashed #00F;
}
.xfc[data-status='authorized'] {
border: 5px dashed #0F0;
}
.grid {
display: flex;
flex-flow: row wrap;
}
.grid div {
padding: 20px;
}
#c1 {
border: 5px dashed #000;
}
#c2 {
border: 5px dashed #00F;
}
#c3 {
border: 5px dashed #0F0;
}
</style>
</head>
<body>
<div>
<h2>The following are XFC's statuses (mounted, launched, authorized).</h2>
</div>
<div class="grid">
<div id="c1">
<h2>mounted app</h2>
</div>
<p></p>
<div id="c2">
<h2>launched app</h2>
</div>
<p></p>
<div id="c3">
<h2>authorized app</h2>
</div>
</div>
<p>This example shows that customMethods are called</p>
<script>
XFC.Consumer.init()
frame = XFC.Consumer.mount(document.body, 'http://localprovider.com:8080/example/initialization/1_e_provider.html');
setTimeout(function(){ frame.invoke('add', [1, 2]).then(result => { console.log('result',result)}); }, 3000);

</script>
</body>
</html>
32 changes: 32 additions & 0 deletions example/initialization/1_e_provider.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<title>HealtheLife Trusted Site</title>
<meta charset="utf-8" />
<style>
body {
padding-bottom: 5px;
}
html[hidden] { display: none; }
</style>
<script src="http://localhost:8080/xfc.js"></script>
</head>
<body>
<div>
<h1>1. Initialization</h1>
</div>
<script type="text/javascript">
const customMethods = {
add(x,y) {
return Promise.resolve(x + y);
},
}
XFC.Provider.init(
{
acls: ['*'],
customMethods,
}
)
</script>
</body>
</html>
Loading