-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswisstxt-lib.min.js
1 lines (1 loc) · 5.67 KB
/
swisstxt-lib.min.js
1
document.addEventListener("DOMContentLoaded",(function(){console.log("swisstxt-lib Script loaded successfully. Version 1.0.11");var e=function(){var e=document.getElementsByTagName("script"),t=Array.prototype.find.call(e,(function(e){return"swisstxt-lib"===e.getAttribute("data-identifier")}));if(!t)return console.error("Error: No matching script tag found."),null;var o=t.getAttribute("data-site"),r=t.getAttribute("data-url"),l=t.getAttribute("data-room-id"),s=t.getAttribute("data-button-text")||"Transcripts",i=t.getAttribute("data-color")||"2",n=t.getAttribute("data-height")||"200",a={};return t.hasAttribute("data-pre")&&(a.PRE="pre"),t.hasAttribute("data-en")&&(a.EN="en"),t.hasAttribute("data-fr")&&(a.FR="fr"),t.hasAttribute("data-it")&&(a.IT="it"),t.hasAttribute("data-de")&&(a.DE="de"),o||console.error("Error: Missing data-site attribute."),r?r=r.replace(/\/$/,""):(console.error("Error: Missing data-url attribute."),console.log("fullUrl",r)),l||console.error("Error: Missing data-room-id attribute."),i&&!["1","2","3","4","5","6"].includes(i)?(console.error("Error: Invalid value for data-color. Only values 1-6 are allowed."),null):isNaN(n)||n<200?(console.error("Error: Invalid value for data-height. Height must be a number >= 200."),null):{site:o,fullUrl:r,roomId:l,buttonText:s,color:i,overlayHeight:parseInt(n,10),languages:a}}();if(e&&e.site&&e.fullUrl&&e.roomId){var t;if("1"===e.site)t="https://www.liveaccess.online";else{if("2"!==e.site)return void console.error("Error: Invalid value for data-site.");t="https://stage.liveaccess.online"}var o=e.fullUrl,r=e.roomId,l=e.buttonText,s=e.color,i=e.overlayHeight,n=e.languages;if(window.location.href.replace(/\/$/,"")===o?console.log("URL matches the provided full URL, starting swisstxt-lib script."):(console.log("URL does not match the provided full URL, exiting swisstxt-lib script."),console.log("Current URL: "+window.location.href.replace(/\/$/,"")),console.log("Full URL: "+o)),window.location.href.replace(/\/$/,"")===o){function a(e,o){var l=document.createElement("button");return l.id=`liveaccess-lang-btn-${e.toLowerCase()}`,l.innerText=e,l.style.fontSize="12px",l.style.fontFamily="Arial",l.style.width="38px",l.style.height="38px",l.style.marginRight="6px",l.style.backgroundColor="var(--background-color, #1e1e1e)",l.style.color="var(--text-color, #b6b6be)",l.style.border="1px solid var(--border-color, #b6b6be)",l.style.borderRadius="4px",l.style.cursor="pointer",l.style.display="flex",l.style.justifyContent="center",l.style.alignItems="center",l.style.zIndex="1002",l.addEventListener("mouseover",(function(){l.style.color="#68d0fe"})),l.addEventListener("mouseout",(function(){l.style.color="var(--text-color, #b6b6be)"})),l.addEventListener("click",(function(){m(`${t}/p/${r}?view=3&color=${s}&language=${o}&fontsize=18`)})),l}var d=document.createElement("button");d.id="liveaccess-transcript-btn",d.innerText=l,d.style.fontSize="1rem",d.style.fontFamily="Arial, sans-serif",d.style.height="40px",d.style.borderRadius="4px",d.style.fontWeight="500",d.style.padding="0 1.2rem",d.style.color="var(--text-color, #b6b6be)",d.style.backgroundColor="var(--background-color, #1e1e1e)",d.style.border="1px solid var(--border-color, #b6b6be)",d.style.cursor="pointer",d.style.display="flex",d.style.justifyContent="center",d.style.alignItems="center",d.style.minWidth="100px",d.style.position="fixed",d.style.bottom="20px",d.style.left="50%",d.style.transform="translateX(-50%)",d.style.zIndex="1002",document.body.appendChild(d),d.addEventListener("mouseover",(function(){d.style.color="#68d0fe"})),d.addEventListener("mouseout",(function(){d.style.color="var(--text-color, #b6b6be)"}));var c=document.createElement("div");c.id="liveaccess-overlay",c.style.position="fixed",c.style.bottom=`-${i}px`,c.style.left="0",c.style.width="100%",c.style.height=`${i}px`,c.style.backgroundColor="#333",c.style.color="white",c.style.zIndex="1001",c.style.transition="bottom 0.3s ease",c.style.display="flex",c.style.flexDirection="row",document.body.appendChild(c);var y=document.createElement("div");y.id="liveaccess-iframe-container",y.style.flexGrow="1",y.style.height="100%",c.appendChild(y);var u=document.createElement("iframe");u.id="liveaccess-iframe-popup",u.style.width="100%",u.style.height="100%",u.style.border="none",y.appendChild(u);var b=document.createElement("div");b.id="liveaccess-button-bar",b.style.position="fixed",b.style.bottom=`${i}px`,b.style.right="20px",b.style.display="flex",b.style.alignItems="center",b.style.zIndex="1002",b.style.transition="bottom 0.3s ease",b.style.opacity="0",document.body.appendChild(b),Object.keys(n).forEach((function(e){var t=a(e,n[e]);b.appendChild(t)}));var p=a("LIVE","main");b.appendChild(p);var f=document.createElement("button");function m(e){document.getElementById("liveaccess-iframe-popup").src=e}function v(){"0px"===c.style.bottom?(c.style.bottom=`-${i}px`,d.style.display="block",b.style.opacity="0"):(c.style.bottom="0px",d.style.display="none",b.style.opacity="1",b.style.bottom=`${i}px`,m(`${t}/p/${r}?view=3&color=${s}&language=main&fontsize=18`))}f.id="liveaccess-close-btn",f.innerHTML="×",f.style.width="38px",f.style.height="38px",f.style.backgroundColor="var(--background-color, #1e1e1e)",f.style.color="var(--text-color, #b6b6be)",f.style.border="1px solid var(--border-color, #b6b6be)",f.style.borderRadius="4px",f.style.cursor="pointer",f.style.marginLeft="6px",f.style.display="flex",f.style.justifyContent="center",f.style.alignItems="center",f.style.zIndex="1002",f.addEventListener("mouseover",(function(){f.style.color="#68d0fe"})),f.addEventListener("mouseout",(function(){f.style.color="var(--text-color, #b6b6be)"})),b.appendChild(f),d.addEventListener("click",(function(){v()})),f.addEventListener("click",(function(){v()}))}}}));