DEPRECATED - LacunaWebPKI: calling checkInstalled with custom action on notInstalled (jQuery)

by Lacuna Software

HTML

<script src="https://webpki.lacunasoftware.com/Scripts/LacunaWebPKI/lacuna-web-pki-1.3.1.js"></script>
<button id="startButton" type="button">Start</button>
<div id="notInstalledPanel">
    <p id="notInstalledMessage"></p>
    <p>Click OK to install/update the component.</p>
    <button type="button">OK</button>
</div>
<div id="logPanel"></div>

CSS

#notInstalledPanel {
    display: none;
    border: 1px solid #000;
    background-color: #eee;
    padding: 0.5em;
}

JavaScript

// ### DEPRECATED ###
// ------------------------------------------------------------------------------------------
// LacunaWebPKI: calling checkInstalled with custom action on notInstalled (jQuery)

var pki = new LacunaWebPKI({
    license: 'ASYAanNmaWRkbGUubmV0LHdlYnBraS5sYWN1bmFzb2Z0d2FyZS5jb20AAAABClKvO1J22vAD+YmfANiKQLbcLE1lNraPKCel6tRM+ZxR+h6M/crtJYRRVGGz7hrdbM0Y0mfTu15RMYGqQMi1QNZS6GrT4vNzIayv552Fl0EFWQA7jWlctUwfYoHRHVEnCNx9YGXDiA9+yDoGlVwgTR7fjzNeS3Fen1MVIyKBF464gN0JvdiCRJMI47JGVDkPmKjcrYIvJs6y5Lg25RW4ZnBKVruS+HR2s3k8ZrV4y4RCQE4UYMKbukF9vsF+JqAEifRlPq2xLcrNdxBveVDSXS/LRHAcrZrMM+Iw4A79jl0ngWPcy+CwinAhT+3dxVo5ZWMRQFpmTkylEMDvTjV9wQ==',
    defaultError: function (message, error, origin) {
        log('Web PKI error originated at ' + origin + ': ' + error);
        alert('Web PKI error: ' + message);
    }
});

function start() {
    log('Checking component installation ...');
    pki.checkInstalled({
        installed: onWebPkiDetected,
        notInstalled: onWebPkiNotInstalled
    });
}

function onWebPkiNotInstalled (status, statusMsg) {
    log('Component not installed or outdated');
    $('#notInstalledMessage').html(statusMsg);
    $('#notInstalledPanel button').click(function() {
        pki.redirectToInstallPage();
    });
    $('#notInstalledPanel').show();
}

function onWebPkiDetected () {
    log('Component detected');
    alert('We are good to go!');
}

function log(message) {
    $('#logPanel').append('<p>' + message + '</p>');
    if (window.console) {
        window.console.log(message);
    }
}

$(function() {
    $('#startButton').click(start);
});