PageSourceSearch

https://www.kiis1011.com.au/wp-content/client-mu-plugins/megaphone/megaphone-audio-picker-script.js?ver=7.1.2

js kiis1011.com.au collected 2026-10-02 11:32:13 UTC 3,522 bytes, 106 lines download raw bytes

1jQuery($ => {
2  const megaphoneButton = document.querySelector('#insert-megaphone-audio');
3  const blocker = document.querySelector('#hide-megaphone-picker');
4  const cancelButton = document.querySelector('#close-megaphone-modal');
5  const modal = document.querySelector('#megaphone-picker');
6
7  if (megaphoneButton) {
8    document.addEventListener('click', event => {
9      if (event.target.id !== 'insert-megaphone-audio') return;
10      modal.classList.toggle('visible');
11      blocker.classList.add('visible');
12    });
13  }
14
15  if (blocker) {
16    blocker.addEventListener('click', event => {
17      event.preventDefault();
18      modal.classList.remove('visible');
19      blocker.classList.remove('visible');
20    });
21  }
22
23  if (cancelButton) {
24    cancelButton.addEventListener('click', event => {
25      event.preventDefault();
26      modal.classList.remove('visible');
27      blocker.classList.remove('visible');
28    });
29  }
30
31  const podcastTitles = document.getElementsByClassName('podcast-title');
32  for (let i = 0; i < podcastTitles.length; i++) {
33    podcastTitles[i].addEventListener('click', ajaxRequest);
34  }
35
36  function ajaxRequest() {
37    console.log('ajax function');
38    for (let i = 0; i < podcastTitles.length; i++) {
39      podcastTitles[i].classList.remove('selected');
40    }
41    this.classList.add('selected');
42    const podcastResults = document.getElementsByClassName('podcast-results');
43    for (let i = 0; i < podcastResults.length; i++) {
44      podcastResults[i].classList.remove('visible');
45    }
46    const loadingSpinner = document.getElementById('loading-spinner');
47    loadingSpinner.classList.add('visible');
48    $.ajax({
49      type: 'GET', // request type,
50      dataType: 'json',
51      async: true,
52      url: myAjax.ajax_url,
53      data: {
54        action: 'megaphone_fetch',
55        feed_url: this.title,
56        security: myAjax.ajax_nonce,
57      },
58      success(result, statusText, xhr) {
59        console.log(result, xhr.status);
60        $('.audio-results-container').append(result.data);
61        const episodes = document.getElementsByClassName('episode');
62        for (let i = 0; i < episodes.length; i++) {
63          episodes[i].addEventListener('click', insertShortcode);
64        }
65      },
66      error(xhr, textStatus, errorThrown) {
67        console.log(errorThrown, xhr);
68        $('.audio-results-container').append(xhr.responseJSON.data);
69      },
70      complete() {
71        loadingSpinner.classList.remove('visible');
72      },
73      timeout: 5000,
74    });
75  }
76
77  function insertShortcode() {
78    modal.classList.remove('visible');
79    blocker.classList.remove('visible');
80    let textEditorActive = false;
81    const textEditor = document.querySelector('.wp-editor-area');
82    if (textEditor.offsetParent !== null) {
83      textEditorActive = true;
84    }
85
86    const iframeShortcode = `[megaphone_embed id="${this.id}"]`;
87    if (textEditorActive) {
88      const textareaField = document.querySelector('.wp-editor-area');
89      if (
90        textareaField.selectionStart ||
91        textareaField.selectionStart === '0'
92      ) {
93        const startPos = textareaField.selectionStart;
94        const endPos = textareaField.selectionEnd;
95        textareaField.value =
96          textareaField.value.substring(0, startPos) +
97          iframeShortcode +
98          textareaField.value.substring(endPos, textareaField.value.length);
99      } else {
100        textareaField.value += iframeShortcode;
101      }
102    } else {
103      tinyMCE.execCommand('mceInsertContent', 0, iframeShortcode);
104    }
105  }
106});

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.