Sha256: 8cbdbfdc60db7023f3655c60995fe37eaffb9ced4a009b6d660ae506186e24ed

Contents?: true

Size: 1.65 KB

Versions: 6

Compression:

Stored size: 1.65 KB

Contents

/* eslint-disable require-jsdoc, no-alert, func-style */
// = require decidim/bulletin_board/decidim-bulletin_board

window.Decidim = window.Decidim || {};

$(() => {
  const { IdentificationKeys } = window.decidimBulletinBoard;

  function identificationKeys() {
    const $form = $(".trustee_zone form");
    const $trusteeUniqueId = $("#trustee_unique_id", $form);
    const $trusteePublicKey = $("#trustee_public_key", $form);

    window.trusteeIdentificationKeys = new IdentificationKeys($trusteeUniqueId.val(), $trusteePublicKey.val());
    if (!window.trusteeIdentificationKeys.browserSupport) {
      $("#not_supported_browser").addClass("visible");
      return;
    }

    const $submit = $("#submit_identification_keys");
    const $generate = $("#generate_identification_keys");
    const $upload = $("#upload_identification_keys");

    $("button", $generate).click(() => {
      window.trusteeIdentificationKeys.generate().then(() => {
        $trusteePublicKey.val(JSON.stringify(window.trusteeIdentificationKeys.publicKey));
        $submit.addClass("visible");
      }).catch(() => {
        alert($generate.data("error"))
      });
    });

    $("button.hollow", $submit).click(() => {
      $trusteePublicKey.val("");
      $submit.removeClass("visible");
    });

    $("button", $upload).click(() => {
      window.trusteeIdentificationKeys.upload().then(() => {
        $upload.addClass("hide");
      }).catch((errorMessage) => {
        alert($upload.data(errorMessage));
      });
    })

    window.trusteeIdentificationKeys.present((result) => {
      $upload.toggleClass("hide", result);
    });
  }

  $(document).ready(() => {
    identificationKeys()
  })
})

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-elections-0.24.3 app/assets/javascripts/decidim/elections/trustee_zone.js.es6
decidim-elections-0.24.2 app/assets/javascripts/decidim/elections/trustee_zone.js.es6
decidim-elections-0.24.1 app/assets/javascripts/decidim/elections/trustee_zone.js.es6
decidim-elections-0.24.0 app/assets/javascripts/decidim/elections/trustee_zone.js.es6
decidim-elections-0.24.0.rc2 app/assets/javascripts/decidim/elections/trustee_zone.js.es6
decidim-elections-0.24.0.rc1 app/assets/javascripts/decidim/elections/trustee_zone.js.es6