PageSourceSearch

https://ngongroad.org/wp-content/plugins/ngong-road/assets/js/friends-of-friends-campaigns.js?ver=7.1

js ngongroad.org collected 2026-10-07 22:37:22 UTC 4,746 bytes, 141 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function () {
2  const dropdownSelected = document.querySelector(".dropdown-selected");
3  const dropdownOptions = document.querySelector(".dropdown-options");
4  const options = document.querySelectorAll(".dropdown-option");
5
6  if (dropdownSelected) {
7    // Define the selected text element
8    const selectedTextElement =
9      dropdownSelected.querySelector(".selected-text");
10
11    if (selectedTextElement) {
12      // Set default selection
13      const defaultOption = document.querySelector(
14        '.dropdown-option[data-value="primary"]'
15      );
16      if (defaultOption) {
17        selectedTextElement.textContent = defaultOption.textContent;
18        defaultOption.classList.add("selected");
19      }
20
21      dropdownSelected.addEventListener("click", function () {
22        const isDropdownOpen = dropdownOptions.style.display === "block";
23        dropdownOptions.style.display = isDropdownOpen ? "none" : "block";
24      });
25
26      options.forEach((option) => {
27        option.addEventListener("click", function () {
28          options.forEach((opt) => opt.classList.remove("selected"));
29          this.classList.add("selected");
30          selectedTextElement.textContent = this.textContent;
31          dropdownOptions.style.display = "none";
32          handleDepartmentChange(this.getAttribute("data-value"));
33        });
34
35        option.addEventListener("mouseover", function () {
36          this.classList.add("hover");
37        });
38
39        option.addEventListener("mouseout", function () {
40          this.classList.remove("hover");
41          if (!this.classList.contains("selected")) {
42            const previouslySelected = document.querySelector(
43              ".dropdown-option.selected"
44            );
45            if (previouslySelected) {
46              previouslySelected.classList.add("selected");
47            }
48          }
49        });
50      });
51    }
52
53    // Close dropdown when clicking outside
54    document.addEventListener("click", function (event) {
55      if (
56        !dropdownSelected.contains(event.target) &&
57        !dropdownOptions.contains(event.target)
58      ) {
59        dropdownOptions.style.display = "none";
60      }
61    });
62  }
63
64  function handleDepartmentChange(value) {
65    let galleryContentArea = document.getElementById(
66      "friends-campaign-children"
67    );
68    galleryContentArea.innerHTML = "";
69
70    let galleryId;
71    let galleryHeading;
72
73    switch (value) {
74      case "primary":
75        galleryHeading =
76          "These students are usually new to the program and will enter 4th to 6th grade after sponsorship.";
77        galleryId = childrenGalleryWithCampaignId;
78        break;
79      case "secondary":
80        galleryHeading =
81          "These students need your help in finishing High School and their College journey.";
82        galleryId = secondaryChildrenGalleryWithCampaignId;
83        break;
84      case "post-secondary":
85        galleryHeading =
86          "These students are almost done with their education and need a few years of support.";
87        galleryId = postSecondaryChildrenGalleryWithCampaignId;
88        break;
89      default:
90        galleryHeading = "";
91        galleryId = "";
92    }
93
94    // Append the gallery shortcode output and heading to the gallery content area
95    galleryContentArea.innerHTML +=
96      "<p>" + galleryHeading + "<br>" + galleryId + "</p>";
97  }
98  // Copy Link functionality
99  const copyButton = document.querySelector(".social-copy-link");
100  const copyFeedback = document.getElementById("copy-feedback");
101
102  if (copyButton && copyFeedback) {
103    copyButton.style.cursor = "pointer";
104
105    copyButton.addEventListener("click", function (e) {
106      e.preventDefault();
107
108      // Construct the clean URL (without hash or query parameters)
109      const url = `${window.location.origin}${window.location.pathname}`;
110
111      // Use Clipboard API
112      if (navigator.clipboard) {
113        navigator.clipboard
114          .writeText(url)
115          .then(() => {
116            // Show feedback message
117            copyFeedback.style.display = "inline";
118            setTimeout(() => {
119              copyFeedback.style.display = "none";
120            }, 2000);
121          })
122          .catch((err) => {
123            console.error("Failed to copy text: ", err);
124          });
125      } else {
126        // Fallback for older browsers
127        const tempInput = document.createElement("input");
128        document.body.appendChild(tempInput);
129        tempInput.value = url;
130        tempInput.select();
131        document.execCommand("copy");
132        document.body.removeChild(tempInput);
133
134        copyFeedback.style.display = "inline";
135        setTimeout(() => {
136          copyFeedback.style.display = "none";
137        }, 2000);
138      }
139    });
140  }
141});

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.