PageSourceSearch

https://autoarmia.pl/wp-content/themes/kingc/layouts/js/submit.min.js?ver=1.0.8

js autoarmia.pl collected 2026-10-10 02:45:01 UTC 9,241 bytes, 267 lines download raw bytes

1(function ($) {
2  $(document).ready(function () {
3
4    document.querySelectorAll('input[name="publish_option"]').forEach((radio) => {
5        radio.addEventListener("change", function () {
6            document.getElementById("schedule_date_wrapper").style.display = 
7                this.value === "later" ? "block" : "none";
8        });
9    });
10    
11    function b(c) {
12      if (c.files && c.files[0]) {
13        var b = new FileReader();
14        b.onload = function (b) {
15          $(".inputprev").attr("src", b.target.result);
16        };
17        b.readAsDataURL(c.files[0]);
18      }
19    }
20    $("#featured-image").change(function () {
21      b(this);
22    });
23tinyMCE.init({
24  selector: "div.tinymce",
25  theme: "inlite",
26  insert_toolbar: "quicktable blockquote",
27  selection_toolbar: "bold italic | quicklink h2 h3 blockquote",
28  inline: true,
29  paste_data_images: false,
30  setup: function (editor) {
31    const maxChars = 2000;
32
33    // Helper: get visible plain text only
34    function getPlainText() {
35      return (editor.getContent({ format: 'text' }) || '').trim();
36    }
37
38    // Prevent typing beyond max
39    editor.on('keydown', function (e) {
40      const text = getPlainText();
41      if (text.length >= maxChars && e.keyCode !== 8 && e.keyCode !== 46 && !e.ctrlKey && !e.metaKey) {
42        e.preventDefault();
43      }
44    });
45
46    // Paste: make plain text, count, cut, replace content
47    editor.on('paste', function (e) {
48      e.preventDefault();
49
50      // 1) Get plain clipboard text
51      let pasted = (e.clipboardData || window.clipboardData).getData('text/plain') || '';
52
53      // 2) Remove any HTML leftover, normalize whitespace
54      pasted = pasted.replace(/<\/?[^>]+(>|$)/g, '').replace(/\s+/g, ' ').trim();
55
56      // 3) Combine existing visible text + pasted
57      const existing = getPlainText();
58      let combined = existing ? (existing + ' ' + pasted) : pasted; // add separator if needed
59      combined = combined.trim();
60
61      // 4) Trim to maxChars if necessary
62      if (combined.length > maxChars) {
63        combined = combined.substring(0, maxChars);
64      }
65
66      // 5) Safely encode & convert newlines to <br> for rendering
67      const safeHtml = editor.dom.encode(combined).replace(/\r?\n/g, '<br>');
68
69      // 6) Replace editor content with the clean plain text (rendered as HTML)
70      editor.setContent(safeHtml);
71    });
72
73    // Optional live counter
74    editor.on('keyup paste change', function () {
75      const count = getPlainText().length;
76      console.log(`Characters: ${count}/${maxChars}`);
77    });
78  }
79});
80
81    $("#king_post_tags").tagsInput({
82      defaultText: "wpisz tag",
83      height: "auto",
84      width: "100%",
85      maxChars: 100,
86      placeholderColor: "#a8b6c0",
87      onAddTag: function () {
88        var input = $("#king_post_tags_tagsinput");
89        var maxLen = 8; // e.g.
90        if (input.children('span.tag').length >= maxLen) {
91          input.children('div').hide();
92        } else {
93          input.children('div').show();
94        }
95      },
96      onRemoveTag: function () {
97        var input = $("#king_post_tags_tagsinput");
98        var maxLen = 8; // e.g.
99        if (input.children('span.tag').length < maxLen) {
100          input.children('div').show();
101        }
102      }
103    });
104    $("#king_posts_form").on("submit", function () {
105      var b = $(this).find("#submit-loading");
106      var c = $(this).find("#submit-loading2");
107      b.button("loading");
108      c.button("loading");
109    });
110    $(document).on("change", ".poll-radio input[type=radio]", function () {
111      $(this).parents().eq(5).attr("id", this.value);
112    });
113    $(document).on(
114      "change",
115      '[data-key="field_60afcaf36c797"] .acf-input input',
116      function (e) {
117        e.preventDefault();
118        var target = $(this);
119        var checked = target.prop("checked");
120        if (!checked) {
121          return;
122        }
123        var parent = target.parents().eq(6);
124        var id = target.prop("id");
125        var key = target.closest(".acf-field").attr("data-key");
126        var list = parent
127          .find('[data-key="' + key + '"] .acf-input input')
128          .not('[data-key="' + key + '"] input[type="hidden"]')
129          .not('.acf-clone [data-key="' + key + '"] input');
130        if (list.length == 1) {
131          return;
132        }
133        for (var i = 0; i < list.length; i++) {
134          var item_id = list[i].getAttribute("id");
135          if (id != item_id) {
136            list[i].checked = false;
137          }
138        }
139      }
140    );
141    const aipost = document.getElementById("aipost");
142    $("#ai-submit").on("click", (event) => {
143      event.preventDefault();
144      const input = document.getElementById("ai-box");
145      const { value } = input;
146      const { value: selectElement } = document.getElementById("ai-select");
147      const results = document.getElementById("ai-results");
148      if (!value.trim()) {
149        return;
150      }
151      const submit = event.currentTarget;
152      submit.disabled = true;
153      input.disabled = true;
154      submit.classList.add("loading");
155      var radioBut = $("input:radio[name=aisize]:checked").val();
156      $.ajax({
157        type: "POST",
158        url: mainscript.ajaxurl,
159        dataType: "json",
160        data: {
161          action: "king_ai_writer",
162          input: value,
163          select: selectElement,
164          radio: radioBut,
165        },
166        success: (response) => {
167          if (response.success) {
168            const sresult = response.data;
169            if (selectElement === "image") {
170              const images = sresult.map(
171                ({ url }) =>
172                  `<div class="ai-imgs"><img src="${url}"width="200"height="200"/><div id="king-aimg"data-aimg="${url}"></div></div>`
173              );
174              results.style.display = "flex";
175              let html = '<div class="ai-result">';
176              html += images.join("");
177              html += "</div>";
178              results.insertAdjacentHTML("afterbegin", html);
179              input.disabled = false;
180              submit.disabled = false;
181              submit.classList.remove("loading");
182              const kingAimgs = document.querySelectorAll("#king-aimg");
183              kingAimgs.forEach((img) => {
184                img.click();
185              });
186            } else {
187              const chatBox = document.querySelector("#king_post_content p");
188              let index = 0;
189              const typingInterval = setInterval(() => {
190                const char = sresult.charAt(index);
191                const element = char === "\n" ? "<br>" : char;
192                chatBox.insertAdjacentHTML("beforebegin", element);
193                index++;
194                if (index >= sresult.length) {
195                  clearInterval(typingInterval);
196                  input.disabled = false;
197                  submit.disabled = false;
198                  submit.classList.remove("loading");
199                }
200              }, 20);
201            }
202          } else {
203            console.log(response.data);
204            results.innerHTML += response.data;
205            input.disabled = false;
206            submit.disabled = false;
207            submit.classList.remove("loading");
208          }
209        },
210      });
211    });
212    $(document).on("click", "#king-aimg", (event) => {
213      const iurl = event.target.dataset.aimg;
214      if (!iurl) {
215        return;
216      }
217      event.target.classList.add("loading");
218      $.ajax({
219        type: "POST",
220        url: mainscript.ajaxurl,
221        data: { action: "king_ai_upload", iurl: iurl },
222        success: (response) => {
223          event.target.classList.add("ldone");
224          event.target.classList.remove("loading");
225          delete event.target.dataset.aimg;
226          if (aipost) {
227            var inp = document.createElement("INPUT");
228            inp.setAttribute("type", "hidden");
229            inp.setAttribute("name", "acf[field_60ae46d02f589][]");
230            inp.setAttribute("value", response);
231            event.target.appendChild(inp);
232          }
233          var rdiv = document.createElement("div");
234          rdiv.setAttribute("id", "king-rimg");
235          rdiv.setAttribute("data-rid", response);
236          event.target.parentElement.appendChild(rdiv);
237        },
238        error: (xhr, status, error) => {
239          console.error(error);
240        },
241      });
242    });
243    $(document).on("click", "#king-rimg", (event) => {
244      const rid = event.target.dataset.rid;
245      if (!rid) {
246        return;
247      }
248      event.target.classList.add("loading");
249      $.ajax({
250        type: "POST",
251        url: mainscript.ajaxurl,
252        data: { action: "king_ai_remove", rid: rid },
253        success: (response) => {
254          console.log("done");
255          const parentDiv = event.target.parentElement;
256          parentDiv.remove();
257        },
258        error: (xhr, status, error) => {
259          console.error(error);
260        },
261      });
262    });
263    $(".ailabel").click(function (d) {
264      d.stopPropagation();
265    });
266  });
267})(jQuery);

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.