{"version":3,"file":"YoutubeVideo.min.js","sources":["EncompassWebServices/includes/DashboardItemTypes/YoutubeVideo.js"],"sourcesContent":["\"use strict\";\r\n\r\n(async function () {\r\n let YouTubeVideoID = \"\";\r\n const videoType = {\r\n showEditButton: true,\r\n itemFields: [\"YouTubeVideoID\"],\r\n addItem(createNewItemCallback) {\r\n Show_Dashboard_YouTubeDialog({\r\n callback(control, id, title) {\r\n createNewItemCallback(title, {\r\n YouTubeVideoID: id\r\n });\r\n }\r\n });\r\n },\r\n editItem(title, itemFields, dashboardItem, editItemCallback) {\r\n Show_Dashboard_YouTubeDialog({\r\n callback(control, id, widgetTitle) {\r\n editItemCallback(widgetTitle, {\r\n YouTubeVideoID: id\r\n });\r\n },\r\n id: itemFields.YouTubeVideoID,\r\n widgetTitle: title\r\n });\r\n },\r\n async onLoaded(dashboardItem, itemFields) {\r\n const content = `
`;\r\n dashboardItem.querySelector(\".content\").innerHTML = content;\r\n }\r\n };\r\n EWS.DashboardItemTypesManager.add(\"YoutubeVideo\", videoType);\r\n EWS.DashboardItemTypesManager.add(\"YouTube Video\", videoType);\r\n\r\n const pattern = /[\\\\?&]v=([^]*)/;\r\n\r\n const ParseYouTubeAddress = function (dialog, url) {\r\n let results = pattern.exec(url);\r\n let isNotNewFormat = true;\r\n\r\n if (results == null) {\r\n if (url.indexOf(\"https://youtu.be/\") > -1) {\r\n results = url.replace(\"https://youtu.be/\", \"\").trim();\r\n isNotNewFormat = false;\r\n }\r\n }\r\n\r\n if (results != null) {\r\n dialog.querySelector(\".tips\").classList.add(\"hidden\");\r\n dialog.querySelector(\"#ews-youtube-preview\").classList.remove(\"hidden\");\r\n if (isNotNewFormat) {\r\n results = decodeURIComponent(results[1].replace(/\\+/g, \" \"));\r\n }\r\n\r\n if (results !== YouTubeVideoID) {\r\n YouTubeVideoID = results;\r\n\r\n dialog.querySelector(\"#ews-youtube-preview\").src = `//www.youtube.com/embed/${YouTubeVideoID}?wmode=transparent`;\r\n if (!dialog.querySelector(\"#ews-youtube-title\").value) {\r\n dialog.querySelector(\"#ews-youtube-title\").value = \"YouTube Video\";\r\n }\r\n }\r\n } else {\r\n dialog.querySelector(\".tips\").classList.remove(\"hidden\");\r\n dialog.querySelector(\"#ews-youtube-preview\").classList.add(\"hidden\");\r\n dialog.querySelector(\"#ews-youtube-preview\").src = \"about:blank\";\r\n YouTubeVideoID = \"\";\r\n }\r\n };\r\n\r\n function Show_Dashboard_YouTubeDialog(insertArgs) {\r\n EWS.VerifySession(() => {\r\n // Task 1146755: Optimize Dashboard Widget-YouTube Video Implementation\r\n const content = `