Sha256: fe0c872e28deaae72d5d79e0203e3aec8c17fb15fd1806d266f266469a7e92e2

Contents?: true

Size: 1.71 KB

Versions: 7

Compression:

Stored size: 1.71 KB

Contents

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

import { IdentificationKeys } from "@decidim/decidim-bulletin_board";

$(() => {
  function identificationKeys() {
    const $form = $("#trustee_zone form");
    const $trusteeSlug = $("#trustee_slug", $form);
    const $trusteePublicKey = $("#trustee_public_key", $form);

    window.trusteeIdentificationKeys = new IdentificationKeys(
      $trusteeSlug.val(),
      $trusteePublicKey.val()
    );

    if (!window.trusteeIdentificationKeys.browserSupport) {
      $("#not_supported_browser").attr("hidden", false);
      return;
    }

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

    $("button", $generate).on("click", () => {
      window.trusteeIdentificationKeys.
        generate().
        then(() => {
          $trusteePublicKey.val(
            JSON.stringify(window.trusteeIdentificationKeys.publicKey)
          );
          $submit.attr("hidden", false);
          $generate.attr("hidden", true);
        }).
        catch(() => {
          alert($generate.data("error"));
        });
    });

    $("button", $submit).click(() => {
      $trusteePublicKey.val("");
      $submit.attr("hidden", true);
    });

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-elections-0.28.4 app/packs/src/decidim/elections/trustee/trustee_zone.js
decidim-elections-0.28.3 app/packs/src/decidim/elections/trustee/trustee_zone.js
decidim-elections-0.28.2 app/packs/src/decidim/elections/trustee/trustee_zone.js
decidim-elections-0.28.1 app/packs/src/decidim/elections/trustee/trustee_zone.js
decidim-elections-0.28.0 app/packs/src/decidim/elections/trustee/trustee_zone.js
decidim-elections-0.28.0.rc5 app/packs/src/decidim/elections/trustee/trustee_zone.js
decidim-elections-0.28.0.rc4 app/packs/src/decidim/elections/trustee/trustee_zone.js