{"version":3,"file":"video-tracking.js","sources":["../../../../IREP.Web.Content/v7/scripts/modules/videotracking/video-tracking.ts"],"sourcesContent":["import Component from \"irep/modules/component\";\nexport class VideoTracking extends Component {\n constructor(id, options) {\n super(id);\n this.options = $.extend({}, options);\n this.beginLog = false;\n this.endLog = false;\n this.middleLog = false;\n this.emittedEnding = false;\n const media_properties = [\"currentTime\", \"duration\"];\n this._video = document.getElementById(this.options.videoID);\n if (this._video.getElementsByTagName(\"source\").length > 0) {\n this._video.addEventListener(\"durationchange\", (e) => this.capture(e), false);\n this._video.addEventListener(\"timeupdate\", (e) => this.capture(e), false);\n }\n }\n capture(e) {\n if ((this._video.currentTime < 5) && !this.beginLog) {\n this.logVideo(1);\n this.beginLog = true;\n }\n else if ((this._video.currentTime > (this._video.duration / 2)) && !this.middleLog) {\n this.logVideo(3);\n this.middleLog = true;\n }\n else if ((this._video.currentTime > (this._video.duration - 5)) && !this.endLog) {\n this.logVideo(2);\n this.endLog = true;\n }\n else if (this._video.currentTime > (this._video.duration - 1) && !this.emittedEnding) {\n $(this._video).trigger('video-tracking-completion', {});\n this.emittedEnding = true;\n }\n }\n logVideo(ViewType) {\n let vuid;\n if (this._video.getElementsByTagName(\"source\")[0] != null) {\n if (this._video.getElementsByTagName(\"source\")[0].dataset != null) {\n vuid = this._video.getElementsByTagName(\"source\")[0].dataset.videouid;\n }\n else {\n vuid = this._video.getElementsByTagName(\"source\")[0].getAttribute(\"data-videoUID\");\n }\n window.irep.getHtml({\n url: '/api/education/videotracker',\n type: 'POST',\n data: {\n VideoId: this.options.videoUID,\n ActivityCode: vuid,\n ViewType: ViewType,\n Source: \"\"\n }\n });\n }\n }\n}\nexport class NonEduVideoTracking {\n constructor(videoElement) {\n this.beginLog = false;\n this.middleLog = false;\n this.endLog = false;\n if ($(videoElement).parents(\".education-detail7\").length > 0) {\n return;\n }\n this.video = videoElement;\n this.videoURL = this.video.currentSrc;\n this.video.addEventListener('loadedmetadata', () => {\n if (this.videoURL !== this.video.currentSrc) {\n this.videoURL = this.video.currentSrc;\n [this.beginLog, this.middleLog, this.endLog] = [false, false, false];\n }\n });\n if (this.video.getElementsByTagName(\"source\").length > 0) {\n this.video.addEventListener(\"durationchange\", (e) => this.capture(e), false);\n this.video.addEventListener(\"timeupdate\", (e) => this.capture(e), false);\n }\n }\n capture(e) {\n if (this.videoURL) {\n if ((this.video.currentTime < 5) && !this.beginLog) {\n this.logVideo(1);\n this.beginLog = true;\n }\n else if ((this.video.currentTime > (this.video.duration / 2)) && !this.middleLog) {\n this.logVideo(3);\n this.middleLog = true;\n }\n else if ((this.video.currentTime > (this.video.duration - 5)) && !this.endLog) {\n this.logVideo(2);\n this.endLog = true;\n }\n }\n }\n logVideo(ViewType) {\n window.irep.getHtml({\n url: 'api/videotracker',\n type: 'POST',\n data: {\n ViewType: ViewType,\n URL: this.videoURL\n }\n });\n }\n}\n"],"names":["VideoTracking","Component","constructor","id","options","super","this","$","extend","beginLog","endLog","middleLog","emittedEnding","_video","document","getElementById","videoID","getElementsByTagName","length","addEventListener","e","capture","currentTime","logVideo","duration","trigger","ViewType","vuid","dataset","videouid","getAttribute","window","irep","getHtml","url","type","data","VideoId","videoUID","ActivityCode","Source","NonEduVideoTracking","videoElement","parents","video","videoURL","currentSrc","URL"],"mappings":"mCACO,MAAMA,UAAsBC,EAC/B,WAAAC,CAAYC,EAAIC,GACZC,MAAMF,GACNG,KAAKF,QAAUG,EAAEC,OAAO,CAAA,EAAIJ,GAC5BE,KAAKG,UAAW,EAChBH,KAAKI,QAAS,EACdJ,KAAKK,WAAY,EACjBL,KAAKM,eAAgB,EAErBN,KAAKO,OAASC,SAASC,eAAeT,KAAKF,QAAQY,SAC/CV,KAAKO,OAAOI,qBAAqB,UAAUC,OAAS,IACpDZ,KAAKO,OAAOM,iBAAiB,kBAAmBC,GAAMd,KAAKe,QAAQD,KAAI,GACvEd,KAAKO,OAAOM,iBAAiB,cAAeC,GAAMd,KAAKe,QAAQD,KAAI,GAE/E,CACI,O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