PageSourceSearch

https://muxtly.pages.dev/assets/js/contact.js

js muxtly.pages.dev collected 2026-10-03 05:40:45 UTC 3,203 bytes, 60 lines download raw bytes

1/* Muxtly contact form submission (shared by all languages).
2 * POSTs the form to /api/contact (Cloudflare Pages Function), which forwards
3 * it to the owner's VPS endpoint for storage in PostgreSQL.
4 */
5(function () {
6  var MSG = {
7    en:    { fill: "Please fill in all fields",  fail: "Submission failed, please try again", net: "Network error, please try again", sending: "Sending..." },
8    de:    { fill: "Bitte fülle alle Felder aus", fail: "Übertragung fehlgeschlagen. Bitte erneut versuchen.", net: "Netzwerkfehler. Bitte erneut versuchen.", sending: "Wird gesendet..." },
9    es:    { fill: "Por favor, rellena todos los campos", fail: "El envío falló. Inténtalo de nuevo.", net: "Error de red. Inténtalo de nuevo.", sending: "Enviando..." },
10    fr:    { fill: "Veuillez remplir tous les champs", fail: "L'envoi a échoué. Veuillez réessayer.", net: "Erreur réseau. Veuillez réessayer.", sending: "Envoi en cours..." },
11    ja:    { fill: "すべての項目を入力してください", fail: "送信に失敗しました。もう一度お試しください。", net: "ネットワークエラーです。もう一度お試しください。", sending: "送信中..." },
12    ko:    { fill: "모든 필드를 입력해 주세요", fail: "전송에 실패했습니다. 다시 시도해 주세요.", net: "네트워크 오류입니다. 다시 시도해 주세요.", sending: "보내는 중..." },
13    pt:    { fill: "Preencha todos os campos", fail: "Falha no envio. Tente novamente.", net: "Erro de rede. Tente novamente.", sending: "Enviando..." },
14    "zh-CN": { fill: "请填写所有字段", fail: "提交失败,请重试", net: "网络错误,请重试", sending: "发送中..." },
15    "zh-TW": { fill: "請填寫所有欄位", fail: "提交失敗,請重試", net: "網路錯誤,請重試", sending: "傳送中..." }
16  };
17
18  function t(key) {
19    var lang = (document.documentElement.lang || "en").toLowerCase();
20    var m = MSG[lang] || MSG.en;
21    return m[key];
22  }
23
24  window.sendForm = async function () {
25    var name = (document.getElementById("name").value || "").trim();
26    var email = (document.getElementById("email").value || "").trim();
27    var message = (document.getElementById("message").value || "").trim();
28    var typeEl = document.getElementById("type");
29    var type = typeEl ? typeEl.value : "";
30
31    if (!name || !email || !message) { alert(t("fill")); return; }
32
33    var btn = document.querySelector(".btn");
34    var oldText = btn ? btn.textContent : "";
35    if (btn) { btn.disabled = true; btn.textContent = t("sending"); }
36
37    try {
38      var resp = await fetch("/api/contact", {
39        method: "POST",
40        headers: { "content-type": "application/json" },
41        body: JSON.stringify({
42          name: name,
43          email: email,
44          type: type,
45          message: message,
46          lang: document.documentElement.lang || "en"
47        })
48      });
49      if (resp.ok) {
50        document.getElementById("result").style.display = "block";
51      } else {
52        alert(t("fail"));
53      }
54    } catch (err) {
55      alert(t("net"));
56    } finally {
57      if (btn) { btn.disabled = false; btn.textContent = oldText; }
58    }
59  };
60})();

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.