PageSourceSearch

https://wdn-cdn.unl.edu/wdn/templates_6.1/js/lib/unl-utility.js?v=6.1.6

js unl.edu collected 2026-09-24 06:51:48 UTC 4,156 bytes, 123 lines download raw bytes

1var __defProp = Object.defineProperty;
2var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
3import { l, a, s, u } from "../chunks/chunk.dcf-utility.js?v=6.1.6";
4function toAbs(link, baseUrl) {
5  try {
6    return new URL(link, baseUrl).toString();
7  } catch (error) {
8    return console.error(error), null;
9  }
10}
11__name(toAbs, "toAbs");
12function setCookie(name, value, seconds, path, domain, samesite, secure) {
13  let expires = "";
14  if (seconds) {
15    const date = /* @__PURE__ */ new Date();
16    date.setTime(date.getTime() + seconds * 1e3), expires = `;expires=${date.toUTCString()}`;
17  }
18  path ? path.charAt(0) !== "/" && (path = toAbs(path, window.location.pathname)) : path = "/", domain || (domain = ".unl.edu"), samesite || (samesite = "lax");
19  let cookieString = `${name}=${value}${expires};path=${path};domain=${domain};samesite=${samesite}`;
20  (secure || !secure && samesite.toLowerCase() === "none") && (cookieString = `${cookieString};secure`), document.cookie = cookieString;
21}
22__name(setCookie, "setCookie");
23function getCookie(name) {
24  const nameEQ = `${name}=`, allCookies = document.cookie.split(";");
25  for (let index = 0; index < allCookies.length; index++) {
26    const currentCookie = allCookies[index].trimStart();
27    if (currentCookie.indexOf(nameEQ) === 0)
28      return currentCookie.substring(nameEQ.length, currentCookie.length);
29  }
30  return null;
31}
32__name(getCookie, "getCookie");
33function getSessionStorage(key) {
34  return sessionStorage.getItem(key);
35}
36__name(getSessionStorage, "getSessionStorage");
37function setSessionStorage(key, value) {
38  sessionStorage.setItem(key, value);
39}
40__name(setSessionStorage, "setSessionStorage");
41function removeSessionStorage(key) {
42  sessionStorage.removeItem(key);
43}
44__name(removeSessionStorage, "removeSessionStorage");
45function isValidHttpUrl(stringToCheck) {
46  let url;
47  try {
48    url = new URL(stringToCheck);
49  } catch {
50    return !1;
51  }
52  return url.protocol === "http:" || url.protocol === "https:";
53}
54__name(isValidHttpUrl, "isValidHttpUrl");
55function isValidateEmail(email) {
56  return email.match(
57    /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
58  );
59}
60__name(isValidateEmail, "isValidateEmail");
61function loadJS(jsSrc, module = !1) {
62  return new Promise((resolve, reject) => {
63    if (document.querySelector(`script[src="${jsSrc}"]`) !== null) {
64      resolve();
65      return;
66    }
67    const newScript = document.createElement("script");
68    newScript.src = jsSrc, module && newScript.setAttribute("type", "module"), newScript.addEventListener("load", () => {
69      resolve();
70    }), newScript.addEventListener("error", () => {
71      reject(new Error(`Failed to load script: ${jsSrc}`));
72    }), document.head.appendChild(newScript);
73  });
74}
75__name(loadJS, "loadJS");
76function wrapInner(parent, wrapper) {
77  if (typeof wrapper == "string") {
78    const temp = document.createElement("div");
79    temp.innerHTML = wrapper, wrapper = temp.firstElementChild;
80  }
81  for (; parent.firstChild; )
82    wrapper.appendChild(parent.firstChild);
83  parent.appendChild(wrapper);
84}
85__name(wrapInner, "wrapInner");
86function getClassInstance(elementID) {
87  return new Promise((resolve) => {
88    if (elementID in window.UNL.classes) {
89      resolve(window.UNL.classes[elementID]);
90      return;
91    }
92    document.getElementById(elementID).addEventListener("UNLClassReady", () => {
93      resolve(window.UNL.classes[elementID]);
94    });
95  });
96}
97__name(getClassInstance, "getClassInstance");
98function trackablePromise(promise) {
99  const state = { pending: !0, value: null };
100  return promise.then((value) => {
101    state.pending = !1, state.value = value;
102  }), state;
103}
104__name(trackablePromise, "trackablePromise");
105export {
106  getClassInstance,
107  getCookie,
108  getSessionStorage,
109  isValidHttpUrl,
110  isValidateEmail,
111  loadJS,
112  l as loadStyleSheet,
113  a as loadStyleSheets,
114  removeSessionStorage,
115  setCookie,
116  setSessionStorage,
117  s as stringToDom,
118  toAbs,
119  trackablePromise,
120  u as uuidv4,
121  wrapInner
122};
123//# sourceMappingURL=unl-utility.js.map

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.