/* JWConfZoomHand 2020.08.04 Based on JWConf Signal 2018.04.29 (c) 2018 - Simon Lorenz - werbung@lorenzweb.net */ (function() { // used locale var requestedLocale = "de"; // switch enabled var signalEnabled = true; // remember testActive var testActive = false; // remember if zoom hand raised var ZoomHandRaised = false; var JWConfRaisings = 0; // loop through table of attendees and call for observer subscription function subscribeNewAttendees() { if (signalEnabled === false) { return; } var tableAttendees = document.getElementById("confroom"); if (typeof(tableAttendees) !== "undefined" && tableAttendees !== null) { for (var i = 0, row; row = tableAttendees.rows[i]; i++) { if (row.parentNode.localName !== "thead") addObserver(row); } } } function updateJWConfRaisings() { JWConfRaisings = document.evaluate('count(//table[@class="monitorTbl"]//tr[@class="detected meldung-blue" or @class="detected meldungActive"])', document, null, XPathResult.ANY_TYPE, null ).numberValue; } function subscribeAttList() { var x = new MutationObserver(function (e) { if (e[0].removedNodes) { updateJWConfRaisings(); decideZoomHand(false); } }); x.observe(document.getElementById('confroom'), { childList: true, subtree: true}); } // add observer for any new attendee function addObserver(addToElement) { if (!addToElement.classList.contains('detected')) { addToElement.classList.add('detected'); var observer = new MutationObserver(function(mutations) { if (signalEnabled === false) { return; } mutations.forEach(function(mutation) { if (mutation.attributeName === "class") { var attributeValue = $(mutation.target).prop(mutation.attributeName); console.log("Class attribute", addToElement.children[0].innerText, "changed to:", attributeValue); if (attributeValue === "detected meldung-blue") { decideZoomHand(true); } else if (attributeValue === "detected") { updateJWConfRaisings(); decideZoomHand(false); } } }); }); observer.observe(addToElement, { attributes: true }); } } // send message to background script to raise hand in zoom if raised hand is active, else send message to lower hand function decideZoomHand(actionRaise) { contentElement = document.getElementById("content"); if (typeof(contentElement) !== "undefined" && contentElement !== null) { if (actionRaise === true) { if (ZoomHandRaised === false) { //send message to background script which opens the ZoomRaiseHand Script chrome.runtime.sendMessage({greeting: "raise"}); ZoomHandRaised = true; } } else { // check if any other is still raising else all good, lower hand if (JWConfRaisings > 0) { console.log("There are some other raisings") return; } if (ZoomHandRaised === true ) { chrome.runtime.sendMessage({greeting: "raise"}); ZoomHandRaised = false; } } } } // add on/off selector to "Live Monitor" headline function addSelectorToMonitorHeadline() { var headlineToFind = getMessage("headlineToAttach"); var h4Elements = document.getElementsByTagName("h4"); if (typeof(h4Elements) !== "undefined" && h4Elements !== null) { for (var i=0, h4Element; h4Element = h4Elements[i]; i++) { if (typeof(h4Element.childNodes) !== "undefined" && h4Element.childNodes !== null) { for (var ii=0, childNode; childNode = h4Element.childNodes[ii]; ii++) { if (typeof(childNode.nodeValue) !== "undefined" && childNode.nodeValue !== null) { if (childNode.nodeValue.startsWith(headlineToFind) || childNode.nodeValue.startsWith("Live") || childNode.nodeValue.startsWith("Interface Live")) { // add selector var selectorElem = document.createElement("div"); selectorElem.style = "display: inline-block; margin-left: 10px;height: 22px;background-color: #c60f13;width: 49px;"; selectorElem.innerHTML = '
' selectorElem.id = 'signalSelector'; selectorElem.addEventListener("click", function( e ) { toggleSelectorSignal(); }); selectorElem.addEventListener("contextmenu", function( e ) { openTestMenu(); e.preventDefault(); }, false); h4Element.insertBefore(selectorElem, h4Element.childNodes[ii+1]); // add test menu (originally color picker) var testMenuElem = document.createElement("div"); testMenuElem.style = "position: absolute; top: 100px; left: 50px; display: none; background-color: #0a0a0a; color: #dadada; padding: 10px; font-size: 1rem; min-width:250px; min-height:170px; border: 2px solid #cacaca; -webkit-box-shadow: 10px 10px 20px 0px rgba(0,0,0,0.75); -moz-box-shadow: 10px 10px 20px 0px rgba(0,0,0,0.75); box-shadow: 10px 10px 20px 0px rgba(0,0,0,0.75); z-index: 1;"; testMenuElem.innerHTML = /*getMessage("configMenu_Language") + '