forked from finos/FDC3
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfdc3_explained.html
217 lines (159 loc) · 5.32 KB
/
fdc3_explained.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<html>
<head>
<title>
FDC3 Explained v.2
</title>
<script language="javascript">
<!-- Various global stuff -->
var channelArray = [];
<!-- Check if FDC3 is avaialable -->
function fdc3Init(callback){
let fdc3Tries = 10; //lets not check forever...
const onFDC3Ready = () => {
if (window.fdc3) {
callback.call(this);
}
else {
if (fdc3Tries > 0){
fdc3Tries--;
window.setTimeout(onFDC3Ready,100);
}
}
};
onFDC3Ready();
}
<!-- Enable application when FDC3 is available -->
document.addEventListener("DOMContentLoaded",() => {
fdc3Init(async () => {
const systemChannels = await fdc3.getSystemChannels();
systemChannels.forEach(channel => {
const thisChannel = channel;
channelArray.push(channel.id);
//alert(channel.id);
//createChannelRow(channel);
//listeners[channel.id] = channel.addContextListener((context) => {updateChannelRow(thisChannel, context);});
});
//populateChannels(channelArray);
enablePage();
});
});
function enablePage(){
console.log('FDC3 is available');
<!-- Special case for Openfin to read App Name -->
if (window.FSBL){
window.FSBL.getFSBLInfo().then((info) => {
document.getElementById('providerDetails').innerHTML = 'Available - Finsemble ' + info.FSBLVersion;
});
} else if (window.fin){
fin.desktop.Application.getCurrent().getInfo((info) => {
document.getElementById('providerDetails').innerHTML = 'Available - ' + info.manifest.startup_app.name});
} else {
document.getElementById('providerDetails').innerHTML = 'Available - Not specified';
}
document.getElementById('directoryDetails').innerHTML = 'TBD';
<!-- enable page obects -->
document.getElementById('btnBroadcast').disabled = false;
document.getElementById('txtBroadcastData').disabled = false;
document.getElementById('selBroadcastChannel').disabled = false;
document.getElementById('btnFetchChannels').disabled = false;
document.getElementById('txtAvailableChannels').disabled = false;
}
<!-- Various poor examples of FDC3 functionality -->
function populateChannels(channelArray){
var i;
var selChannel = document.getElementById('selBroadcastChannel');
var txtChannels = document.getElementById('txtAvailableChannels');
var selOption;
txtChannels.value = channelArray;
for (i = 0; i < channelArray.length; i++) {
selOption = document.createElement("option");
selOption.text = channelArray[i];
selChannel.add(selOption);
}
}
function broadcastFDC3Context(){
var myContextData = document.getElementById('txtBroadcastData');
var ctx = JSON.parse(myContextData.value);
fdc3.broadcast(ctx);
//document.getElementById('txtBroadcastData').value = '';
}
function changeBroadcastChannel(){
alert('Not implemented yet!');
document.getElementById('selBroadcastChannel').selectedIndex = 0;
}
function appLoader(){
var myUrl = document.getElementById('appUrl').value;
if (myUrl.length>0){
window.open(myUrl);
}
}
</script>
<style>
textarea {width:400px;height:100px;}
select {width:238px;height:24px;}
.ctxInput {width:241px;height:24px;}
.urlInput {width:400px;height:24px;}
.header {width:200px;height:40px;font-weight:700;}
</style>
</head>
<body>
<table border="1">
<tr>
<td class="header">FDC3 Provider Service:</td>
<td><span id="providerDetails">FDC3 Not Available</span></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 class="header">Load App Start Url:</td>
<td><input type="text" id="appUrl" class="urlInput" value="demoapps/receive.html"></td>
<td><input type="button" value="Open" onClick="appLoader();"></td>
</tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td class="header">Available Channels:</td>
<td><textarea disabled id="txtAvailableChannels"></textarea></td>
<td><input type="button" value="Fetch" id="btnFetchChannels" disabled onClick="populateChannels(channelArray);"> <input type="button" value="Add" disabled></td>
</tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td class="header" rowspan="2">Broadcast Context:</td>
<td>Channel: <select id="selBroadcastChannel" disabled onChange="changeBroadcastChannel();"></select></td>
<td rowspan="2"><input type="button" value="Send" id="btnBroadcast" disabled onClick="broadcastFDC3Context();"></td>
</tr>
<tr>
<td><textarea id="txtBroadcastData" disabled>{"id":{"ISIN":"US0378331005","SEDOL":"2046251","ticker":"AAPL"},"name":"Apple Inc.","type":"fdc3.instrument"}
</textarea></td>
</tr>
<tr>
<td colspan="3"><hr></td>
</tr>
<tr>
<td class="header" rowspan="3">Get Context:</td>
<td>Channel: <select disabled></td>
<td rowspan="3"><input type="button" value="Fetch" disabled></td>
</tr>
<tr>
<td>Context: <input type="text" class="ctxInput" disabled></td>
</tr>
<tr>
<td><textarea disabled></textarea></td>
</tr>
</table>
</body>
</html>