PageSourceSearch

https://accounts.adafruit.com/assets/controllers/add_credential_controller-04cdbbb1.js

js adafruit.com collected 2026-10-01 07:50:22 UTC 1,314 bytes, 44 lines download raw bytes

1import { Controller } from "@hotwired/stimulus";
2import * as Credential from "components/credential";
3import { post } from "@rails/request.js";
4
5export default class extends Controller {
6  static targets = ["nickname"];
7
8  async submit(event) {
9    event.preventDefault();
10    this.resetErrorAlert();
11
12    if (this.nicknameTarget.value.length < 3) {
13      this.showErrorAlert(
14        "Invalid Nickname. Must be at least three characters in length.",
15      );
16      return;
17    }
18
19    const form = event.target;
20    const response = await post(form.action, {
21      body: new FormData(form),
22      responseKind: "json",
23    });
24
25    if (response.ok) {
26      const credentialOptions = await response.json;
27      const callback_url = `/credentials/callback?credential_nickname=${this.nicknameTarget.value}`;
28      Credential.create(encodeURI(callback_url), credentialOptions);
29    }
30  }
31
32  resetErrorAlert() {
33    const alertElement = document.querySelector(".alert-js");
34    alertElement.style.display = "none";
35  }
36
37  showErrorAlert(message) {
38    const alertElement = document.querySelector(".alert-js");
39    alertElement.querySelector(".message").innerHTML = message;
40    alertElement.classList.add("alert-danger");
41    alertElement.classList.remove("alert-info");
42    alertElement.style.display = "block";
43  }
44}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.