diff --git a/examples/script-tag/public/create-sign.js b/examples/script-tag/public/create-sign.js index db33cb2..8e220c4 100644 --- a/examples/script-tag/public/create-sign.js +++ b/examples/script-tag/public/create-sign.js @@ -18,16 +18,16 @@ $createSignature.addEventListener('submit', function (event) { var thumbprint = $certificate.value, - message = $message.value, - hashingAlgorithm = document.querySelector('input[name="hashingAlgorithm"]:checked').value; + message = $message.value; event.preventDefault(); $hash.placeholder = 'Вычисляется...'; $hash.value = ''; - window.cryptoPro.createHash(message, hashingAlgorithm).then(function (hash) { - var detachedSignature = document.querySelector('input[name="signatureType"]:checked').value; + window.cryptoPro.createHash(message).then(function (hash) { + var detachedSignature = document.querySelector('input[name="signatureType"]:checked').value, + signaturePromise; detachedSignature = Boolean(Number(detachedSignature)); @@ -36,7 +36,13 @@ $signature.placeholder = 'Создается...'; $signature.value = ''; - window.cryptoPro.createSignature(thumbprint, hash, detachedSignature).then(function (signature) { + if (detachedSignature) { + signaturePromise = window.cryptoPro.createDetachedSignature(thumbprint, hash); + } else { + signaturePromise = window.cryptoPro.createAttachedSignature(thumbprint, message); + } + + signaturePromise.then(function (signature) { $signature.value = signature; }, function (error) { $signature.placeholder = 'Не создана'; diff --git a/examples/script-tag/public/index.html b/examples/script-tag/public/index.html index 24a7bb6..4f0e8fc 100755 --- a/examples/script-tag/public/index.html +++ b/examples/script-tag/public/index.html @@ -8,9 +8,9 @@