PageSourceSearch

https://cdnp.4imprint.com/proteus/production/US/bundles/videodialog-M_CNFpVV.js

js 4imprint.com collected 2026-10-02 06:45:08 UTC 7,965 bytes, 178 lines download raw bytes

1import { D as u } from "./dialog4i2022-BWnxNKrI.js";
2import { e as p } from "./details-zBEfhWMh.js";
3class v {
4  constructor() {
5    this.theVideoDialog = new u(), this.techVideoTitle = "tech trend", this.mugVideoTitle = "mug imprints", this.bitmovinScriptUrl = "//cdn.jsdelivr.net/npm/bitmovin-player@8/bitmovinplayer.js", this.videoPlayer = null, this.productName = null, this.productID = null, this.productAlias = null, this.videoID = null, this.previousvideoId = null, this.previousProductID = null, this.previousProductAlias = null, this.isinitialvideo = !1, this._isClosed = !1, this._playerToken = 0, this.vidHTML = `<a href="" class="transcriptLink inlineMiddle marginBtm10 text16">View Transcript</a>
6            <div id="videoContainer" class="dialogContent videoContent marginBtm15 player-wrapper">${p}</div>`, this.setUpVideo = this.setUpVideo.bind(this), this.updateContent = this.updateContent.bind(this);
7  }
8  init() {
9    this.theVideoDialog.init({
10      dialogClass: "videoDialog xLDialog",
11      title: "Video Highlights",
12      content: this.vidHTML,
13      onOpen: this.setUpVideo,
14      update: this.updateContent,
15      onClose: async () => {
16        if (this._isClosed = !0, this.videoPlayer) {
17          try {
18            this.videoPlayer.pause(), this.videoPlayer.unload?.(), await this.videoPlayer.destroy();
19          } catch {
20          }
21          this.videoPlayer = null;
22        }
23        document.querySelectorAll("video, iframe").forEach((e) => {
24          try {
25            e.pause?.(), e.src = "", e.load?.();
26          } catch {
27          }
28        });
29      }
30    });
31  }
32  open(e, t) {
33    this.theVideoDialog.open(e, t);
34  }
35  async setUpVideo(e) {
36    this._isClosed = !1, this.setVariables(e);
37    let t = e.id.startsWith("hypVideoLink");
38    this.productID != "" && this.productID != null || t ? this.isinitialvideo = !0 : this.isinitialvideo = !1;
39    const i = this.getURL();
40    try {
41      const o = await fetch(i, {
42        method: "GET",
43        headers: { "Content-Type": "application/json", "X-Requested-With": "fetch" }
44      });
45      if (!o.ok) throw new Error(`Error processing video request: ${o.statusText}`);
46      const r = await o.text();
47      if (this._isClosed) return;
48      if (/^\s*<!DOCTYPE html/i.test(r)) {
49        document.querySelector(".dialogContent").innerHTML = "<p>Unable to load video, please try again later.</p>";
50        return;
51      }
52      const s = JSON.parse(r);
53      if (this._isClosed) return;
54      if (s) {
55        if (this.isinitialvideo && (this.previousProductID = this.productID, this.previousvideoId = s.wv.VideoID, this.previousProductAlias = this.productAlias), await this.updateContent(s), this._isClosed) return;
56        typeof bitmovin == "function" ? this.initPlayer(s) : this.loadScript(s);
57      }
58    } catch (o) {
59      console.error(o);
60    }
61  }
62  setVariables(e) {
63    this.videoID = e.getAttribute("data-videoid"), this.productID = e.getAttribute("data-productid"), this.productAlias = e.hasAttribute("data-productalias") ? e.getAttribute("data-productalias") : "", this.productName = e.hasAttribute("aria-label") ? e.getAttribute("aria-label").replace("Video for ", "") : "", this.productName == "" && e.querySelector("svg") && (this.productName = e.querySelector("svg").getAttribute("aria-label").replace("Video for ", ""));
64  }
65  getURL() {
66    let e = "/video/";
67    return this.productID == null && this.videoID != null ? e += "VideoDetailsByID/" + this.videoID : this.videoID == null && this.productID != null ? e += "VideoDetails/" + this.productID : e += "VideoDetailsByVideoAndProductId/" + this.videoID + "/" + this.productID, e;
68  }
69  async updateContent(e) {
70    const t = document.querySelector(".videoDialog");
71    if (!t) return;
72    const i = t.querySelector("h2");
73    if (i) {
74      if (t.querySelector(".vidProdInfo") && t.querySelector(".vidProdInfo").remove(), e.wv.VideoTitle && e.wv.VideoTitle.toLowerCase() == this.mugVideoTitle)
75        i.textContent = "Mug Imprint Options";
76      else if (e.wv.VideoTitle && e.wv.VideoTitle.toLowerCase() == this.techVideoTitle)
77        i.textContent = "Trending Technology Items";
78      else {
79        const o = `<div class="vidProdInfo">
80                <h3 class="textSemiBold text18 marginBtm5">${this.productName}</h3>
81                <p class="text16">Item # ${this.productAlias}</p>
82            </div>`;
83        t.querySelector(".transcriptLink")?.insertAdjacentHTML("beforebegin", o);
84      }
85      this.showTranscriptLink(e), this.isinitialvideo || this.addPreviousVideoLink(), e.videos && e.videos.length > 1 && this.addMoreVideoLinks(e);
86    }
87  }
88  loadScript(e) {
89    const t = document.createElement("script");
90    t.src = this.bitmovinScriptUrl, t.onload = () => {
91      this._isClosed || this.initPlayer(e);
92    }, document.head.appendChild(t);
93  }
94  initPlayer = (e) => {
95    const t = ++this._playerToken;
96    if (this._isClosed) return;
97    if (this.videoPlayer) {
98      try {
99        this.videoPlayer.pause(), this.videoPlayer.unload?.(), this.videoPlayer.destroy();
100      } catch {
101      }
102      this.videoPlayer = null;
103    }
104    const i = e.wv.VideoID, o = e.wv.AssetUrl, r = e.wv.EnglishSubtitleUrl, s = e.wv.VideoTitle, n = this.getAnalyticsTitle(s), a = this.getVideoTitle(s), h = this.getConfig(n, i), c = this.getSource(i, o, r, a), d = document.getElementById("videoContainer");
105    d && (d.innerHTML = '<div id="player"></div>');
106    const l = document.getElementById("player");
107    if (!(!l || this._isClosed)) {
108      if (this.videoPlayer = new bitmovin.player.Player(l, h), this._isClosed) {
109        try {
110          this.videoPlayer.destroy();
111        } catch {
112        }
113        return;
114      }
115      this.videoPlayer.load(c).then(() => {
116        this._isClosed || this._playerToken;
117      }).catch(() => {
118        this._isClosed || this._playerToken;
119      });
120    }
121  };
122  addMoreVideoLinks(e) {
123    const t = document.getElementsByClassName("otherVidContainer");
124    t.length > 0 && t[0].remove();
125    let i = '<div class="otherVidContainer displayFlex flexSpaceBetween flexAlignItemsCenter">';
126    for (let o of e.videos)
127      o.VideoID != e.wv.VideoID && (i += `<button class="videoLink" data-productid="${this.productID}" data-videoid="${o.VideoID}" data-productalias="${this.productAlias}">
128                    Watch ${this.productName}
129                </button>`);
130    i += "</div>", document.getElementById("videoContainer")?.insertAdjacentHTML("afterend", i);
131  }
132  showTranscriptLink(e) {
133    const t = document.querySelector(".transcriptLink");
134    t && (e.wv.VideoTitle && e.wv.VideoTitle.toLowerCase() == this.mugVideoTitle ? t.setAttribute("href", "/video#mugimprints") : e.wv.VideoTitle ? t.setAttribute("href", "/video/id/" + e.wv.VideoID + "#transcript") : this.productAlias !== "" ? t.setAttribute("href", "/video/product/" + this.productAlias + "#transcript") : t.classList.add("hide"));
135  }
136  getAnalyticsTitle(e) {
137    return e && e.length > 0 ? e : this.productAlias;
138  }
139  getVideoTitle(e) {
140    let t = this.productName;
141    return e && e.length > 0 && (t = e, e.toLowerCase() == this.mugVideoTitle && (t = "Video for Mug Imprint Options"), e.toLowerCase() == this.techVideoTitle && (t = "Video for Technology Trends")), t;
142  }
143  getConfig(e, t) {
144    return {
145      key: "a8072f85-5072-454b-b8f2-09087b192aa7",
146      analytics: {
147        key: "26a9da30-39dd-4906-bf18-2b222b809d92",
148        title: e,
149        videoId: t
150      },
151      playback: {
152        autoplay: !0,
153        muted: !1
154      }
155    };
156  }
157  getSource(e, t, i, o) {
158    return {
159      title: o,
160      dash: t + e + "/stream.mpd",
161      hls: t + e + "/index.m3u8",
162      subtitleTracks: [{
163        url: i,
164        id: "track-0",
165        label: "English",
166        lang: "en"
167      }],
168      thumbnailTrack: {
169        url: t + e + "/sprites/low/sprite.vtt"
170      }
171    };
172  }
173}
174const g = new v();
175export {
176  g as default
177};
178//# sourceMappingURL=videodialog-M_CNFpVV.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.