Skip to content

Commit

Permalink
Merge pull request #2 from robmoffat/explained-semgrep-fix
Browse files Browse the repository at this point in the history
Explained semgrep fix
  • Loading branch information
robmoffat authored Feb 10, 2023
2 parents 8175aa9 + 62acc4b commit 6a8a1a4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
11 changes: 8 additions & 3 deletions toolbox/fdc3-explained/1.0/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,23 @@ const broadcastText = document.getElementById("broadcastText")
function enablePage() {
console.log('FDC3 is available');

// NOTE: conceptually replaced with fdc3.getInfo
if (window.FSBL) {
window.FSBL.getFSBLInfo().then(info => providerDetails.innerHTML = 'Available - Finsemble ' + info.FSBLVersion);
window.FSBL.getFSBLInfo().then(info => updateProviderDetails('Available - Finsemble ' + info.FSBLVersion));
} else if (window.fin) {
providerDetails.innerHTML = 'Available - OpenFin ' + fin.desktop.getVersion();
updateProviderDetails('Available - OpenFin ' + fin.desktop.getVersion());
} else {
providerDetails.innerHTML = 'Available - Unknown';
updateProviderDetails('Available - Unknown');
}

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

function updateProviderDetails(details){
providerDetails.innerText = details;
}

function broadcastFDC3Context() {
var context = JSON.parse(broadcastText.value);
fdc3.broadcast(context);
Expand Down
15 changes: 10 additions & 5 deletions toolbox/fdc3-explained/1.1/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,23 @@ function displayFDC3Support() {
}

function getPlatform() {
const providerDetails = document.getElementById('providerDetails');


// TODO: add G42 and FDC3 Desktop Agent to vendors
// NOTE: conceptually replaced with fdc3.getInfo
if (window.FSBL) {
window.FSBL.getFSBLInfo().then(info => (providerDetails.innerHTML = 'Finsemble ' + info.FSBLVersion));
window.FSBL.getFSBLInfo().then(info => updateProviderDetails('Available - Finsemble ' + info.FSBLVersion));
} else if (window.fin) {
providerDetails.innerHTML = 'OpenFin ' + fin.desktop.getVersion();
updateProviderDetails('Available - OpenFin ' + fin.desktop.getVersion());
} else {
providerDetails.innerHTML = 'Unknown';
updateProviderDetails('Available - Unknown');
}
}

function updateProviderDetails(details){
const providerDetails = document.getElementById('providerDetails');
providerDetails.innerText = details;
}

async function populateHTML() {
try {
//populate available channels list with system channels
Expand Down
4 changes: 2 additions & 2 deletions toolbox/fdc3-explained/1.2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@

<tr>
<td>
<div id="context-result">
<i>Context result will appear here.</i>
<div>
<pre id="context-result"><i>Context result will appear here.</i></pre>
</div>
</td>
</tr>
Expand Down
19 changes: 14 additions & 5 deletions toolbox/fdc3-explained/1.2/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,16 @@ function displayFDC3Support() {
}

function getPlatform() {
const providerDetails = document.getElementById('providerDetails');
const fdc3Info = window.fdc3.getInfo();
console.log('FDC3 info', fdc3Info);

providerDetails.innerHTML = `${fdc3Info.provider} ${fdc3Info.providerVersion}`;
//providerDetails.innerHTML = `${fdc3Info.provider} ${fdc3Info.providerVersion}`;
updateProviderDetails(`${fdc3Info.provider} ${fdc3Info.providerVersion}`);
}

function updateProviderDetails(details){
const providerDetails = document.getElementById('providerDetails');
providerDetails.innerText = details;
}

async function populateHTML() {
Expand Down Expand Up @@ -147,25 +152,29 @@ async function broadcastFDC3Context() {

async function getContext(contextType) {
try {
let contextResultBox = document.getElementById('context-result');
if (contextListener) contextListener.unsubscribe();

// if context type is passed in then only listen on that specific context
if (contextType) {
contextListener = fdc3.addContextListener(
contextType,
context => (contextResultBox.innerHTML = "<pre>" + JSON.stringify(context, null, 2)) + "</pre>"
context => displayContext(JSON.stringify(context, null, 2))
);
} else {
contextListener = fdc3.addContextListener(
context => (contextResultBox.innerHTML= "<pre>" + JSON.stringify(context, null, 2)) + "</pre>"
context => displayContext(JSON.stringify(context, null, 2))
);
}
} catch (error) {
console.error('Unable to add a context listener', error);
}
}

function displayContext(text){
let contextResultBox = document.getElementById('context-result');
contextResultBox.innerText = text;
}

async function addAppChannel() {
try {
let appChannelName = document.getElementById('app-channel').value;
Expand Down

0 comments on commit 6a8a1a4

Please sign in to comment.