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

165 Add FDC3 Explained to the toolbox folder #535

Merged
merged 11 commits into from
Mar 18, 2022
90 changes: 90 additions & 0 deletions toolbox/fdc3-explained/1.0/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<html>

<head>
<title>FDC3 Explained</title>
<link rel="stylesheet" href="./styles.css">
<script type="module" src="./main.js" defer></script>
</head>

<body>

<table border="1">
<tr>
<td colspan="3" style="text-align:center;">Back to <a href="..">main page</a>.</td>
</tr>

<tr>
<td class="header">FDC3 Provider:</td>
<td><span id="providerDetails">FDC3 Not Available</span></td>
</tr>

<tr>
<td class="header">FDC3 Version:</td>
<td>
<select id="versions" onchange="window.location.href=`../${this.value}`">
<option value="1.0" selected>1.0</option>
<option value="1.1">1.1</option>
<option value="1.2">1.2</option>
</select>
</td>
</tr>

<tr>
<td colspan="3"><hr/></td>
</tr>

<tr>
<td class="header">App Directory:</td>
<td><span id="directoryDetails">No Application Directory Connected</span></td>
<td><input type="button" value="Connect" disabled></td>
</tr>

<tr>
<td class="header">Available Apps:</td>
<td><textarea disabled></textarea></td>
<td><input type="button" value="Fetch" disabled></td>
</tr>

<tr>
<td colspan="3"><hr/></td>
</tr>

<tr>
<td class="header">Broadcast Context:</td>
<td>
<textarea id="broadcastText" disabled>{
"type":"fdc3.instrument",
"id": {
"ISIN":"US0378331005",
"SEDOL":"2046251",
"ticker":"AAPL"
},
"name":"Apple Inc."
}</textarea>
</td>
<td>
<input type="button"
value="Send"
id="broadcastButton"
disabled>
</td>
</tr>

<tr>
<td colspan="3"><hr/></td>
</tr>

<tr>
<td class="header" rowspan="3">Get Context:</td>
<td><textarea disabled>Not implemented</textarea></td>
<td>
<input type="button" value="Subscribe" disabled />
<br />
<input type="button" value="Unsbscribe" disabled />
</td>
</tr>
</table>

</body>

</html>
46 changes: 46 additions & 0 deletions toolbox/fdc3-explained/1.0/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// enable application when FDC3 is available
document.addEventListener('DOMContentLoaded', () => {
fdc3Init(enablePage);
});

// check if FDC3 is available
function fdc3Init(callback) {
let fdc3Tries = 10

const onFDC3Ready = () => {
if (window.fdc3) {
callback.call(this);
} else {
if (fdc3Tries > 0) {
fdc3Tries--;
window.setTimeout(onFDC3Ready, 100);
}
}
}

onFDC3Ready();
}

const providerDetails = document.getElementById("providerDetails")
const broadcastButton = document.getElementById("broadcastButton")
const broadcastText = document.getElementById("broadcastText")

function enablePage() {
console.log('FDC3 is available');

if (window.FSBL) {
window.FSBL.getFSBLInfo().then(info => providerDetails.innerHTML = 'Available - Finsemble ' + info.FSBLVersion);
} else if (window.fin) {
providerDetails.innerHTML = 'Available - OpenFin ' + fin.desktop.getVersion();
} else {
providerDetails.innerHTML = 'Available - Unknown';
}

broadcastButton.disabled = false;
broadcastText.disabled = false;
}

function broadcastFDC3Context() {
var context = JSON.parse(broadcastText.value);
fdc3.broadcast(context);
}
25 changes: 25 additions & 0 deletions toolbox/fdc3-explained/1.0/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
textarea {
width: 400px;
height: 150px;
}

select {
width: 150px;
height: 24px;
}

.ctxInput {
width: 241px;
height: 24px;
}

.urlInput {
width: 400px;
height: 24px;
}

.header {
width: 200px;
height: 40px;
font-weight: 700;
}
156 changes: 156 additions & 0 deletions toolbox/fdc3-explained/1.1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<html>

<head>
<title>FDC3 Explained</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="./styles.css">
<script type="module" src="./main.js" defer></script>
</head>

<body>
<div class="main">
<table border="1">

<tr>
<td colspan="3" style="text-align:center;">Back to <a href="..">main page</a>.</td>
</tr>

<tr>
<td colspan="3"><hr/></td>
</tr>

<tr>
<td class="header">FDC3 Supported </td>
<td><span id="fdc3-support">Checking...</span></td>
</tr>

<tr>
<td class="header">FDC3 Provider:</td>
<td><span id="providerDetails">None</span></td>
</tr>

<tr>
<td class="header">FDC3 Version:</td>
<td>
<select id="versions" onchange="window.location.href=`../${this.value}`">
<option value="1.0">1.0</option>
<option value="1.1" selected>1.1</option>
<option value="1.2">1.2</option>
</select>
</td>
</tr>

<tr>
<td colspan="3"><hr/></td>
</tr>

<tr>
<td class="header">App Directory:</td>
<td><span id="directoryDetails">Not supported yet!</span></td>
<td><input type="button" value="Connect" class="not-supported" disabled></td>
</tr>

<tr>
<td class="header">Available Apps:</td>
<td><textarea disabled></textarea></td>
<td><input type="button" value="Fetch" disabled></td>
</tr>

<tr>
<td colspan="3"><hr/></td>
</tr>

<tr>
<td class="header">Available Channels:</td>
<td>
System Channels:
<ul id="system-channel-list"></ul>
App Channels:
<ul id="app-channel-list"></ul>
</td>
</tr>

<tr>
<td class="header">Add App Channel:</td>
<td><input id="app-channel"></input></td>
<td><Button type="button" id="add-app-channel__btn" disabled>Add</Button></td>
</tr>

<tr>
<td class="header">Join Channel:</td>
<td>Channel: <select class="fdc3-channels" id="join-channel"></select>
<Button type="button" id="join-channel__btn" disabled>Join</Button>
</td>
<td><Button type="button" id="leave-channel__btn" disabled>Leave</Button></td>
</tr>

<tr>
<td colspan="3"><hr/></td>
</tr>

<tr>
<td class="header" rowspan="2">Broadcast Context:</td>
</tr>
<tr>
<td>
<textarea id="txtBroadcastData">{
"type":"fdc3.instrument",
"id": {
"ISIN":"US0378331005",
"SEDOL":"2046251",
"ticker":"AAPL"
},
"name":"Apple Inc."
}</textarea>
</td>
<td rowspan="2">
<Button type="button" id="broadcast__btn" disabled>Send</Button>
</td>
</tr>

<tr>
<td class="header" rowspan="3">Context received:</td>
</tr>

<tr>
<td>Context Type: <input type="text" id="context-type"></td>
<td><Button type="button" id="get_context__btn" disabled>Get context</Button></td>
</tr>

<tr>
<td><textarea id="context-result" disabled></textarea></td>
</tr>

<tr>
<td colspan="3"><hr/></td>
</tr>

<tr>
<td class="header" rowspan="3">Raise Intent:</td>
</tr>

<tr>
<td>Intent: <input type="text" id="intent" value="ViewChart"></td>
</tr>

<tr>
<td><textarea id="intent-context">{
"type":"fdc3.instrument",
"id": {
"ISIN":"US0378331005",
"SEDOL":"2046251",
"ticker":"AAPL"
},
"name":"Apple Inc."
}</textarea>
</td>
<td>
<Button id="raise-intent__btn" disabled>Raise Intent </Button>
</td>
</tr>

</table>
</div>
</body>

</html>
Loading