DEPRECATED - LacunaWebPKI.readCertificate example w/ AngularJS

by Lacuna Software

HTML

<script src="https://webpki.lacunasoftware.com/Scripts/LacunaWebPKI/lacuna-web-pki-1.3.1.js"></script>
<div ng-app>
    <div ng-controller="ExampleController">
        <form>
            <button type="button" ng-click="start()">Start</button>
            <div id="signatureControlsPanel" ng-show="showSignatureControls">
                <select ng-model="selectedCertificate" ng-options="getCertificateDisplayName(cert) for cert in certificates">
                    <option value="">Choose a certificate ...</option>
                </select>
                <button type="button" ng-click="readSelectedCertificate()">Read Certificate</button>
            </div>
        </form>
        <p ng-repeat="log in logs">{{log}}</p>
    </div>
</div>

CSS

#signatureControlsPanel {
    margin-top: 1em;
}

JavaScript

// ### DEPRECATED ###
// ------------------------------------------------------------------------------------------
// LacunaWebPKI.readCertificate example w/ AngularJS

function ExampleController($scope) {
    
    $scope.readSelectedCertificate = function () {
        log('Reading certificate ' + $scope.selectedCertificate.thumbprint + ' ...');
        pki.readCertificate($scope.selectedCertificate.thumbprint).success(function (certContent) {
            log('Certificate read: ' + certContent);
        });
    };
    
    // ------------------------------------------------------------------------------------------
    // The code from this point on is necessary for the example to run, but is not the focus of
    // this specific example

    $scope.logs = [];
    $scope.certificates = [];
    $scope.showSignatureControls = false;
    
    var log = function (msg) {
        $scope.logs.push(msg);
    };
    
    var onWebPkiError = function (message, error, origin) {
        log('pki error from ' + origin + ': ' + message);
    };
    
    var myLicense = {
        "format": 1,
        "allowedDomains": [
            "jsfiddle.net",
            "webpki.lacunasoftware.com"
        ],
        "expiration": null,
        "signature": "ClKvO1J22vAD+YmfANiKQLbcLE1lNraPKCel6tRM+ZxR+h6M/crtJYRRVGGz7hrdbM0Y0mfTu15RMYGqQMi1QNZS6GrT4vNzIayv552Fl0EFWQA7jWlctUwfYoHRHVEnCNx9YGXDiA9+yDoGlVwgTR7fjzNeS3Fen1MVIyKBF464gN0JvdiCRJMI47JGVDkPmKjcrYIvJs6y5Lg25RW4ZnBKVruS+HR2s3k8ZrV4y4RCQE4UYMKbukF9vsF+JqAEifRlPq2xLcrNdxBveVDSXS/LRHAcrZrMM+Iw4A79jl0ngWPcy+CwinAhT+3dxVo5ZWMRQFpmTkylEMDvTjV9wQ=="
    };
    
    var pki = new LacunaWebPKI({
        license: myLicense,
        defaultError: onWebPkiError,
        angularScope: $scope // note that we pass our $scope to the LacunaWebPKI object
    });
    
    $scope.start = function () {
        log('Checking component installation ...');
        pki.checkInstalled({
            installed: onWebPkiDetected,
            notInstalled:...