Socket
Socket
Sign inDemoInstall

opentok-annotation

Package Overview
Dependencies
3
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.41 to 1.0.42

4

dist/opentok-annotation.min.js

@@ -1,2 +0,2 @@

(function(){var t,e,n,o={clientVersion:"js-vsol-1.0.0",componentId:"annotationsAccPack",name:"guidAnnotationsKit",actionStartDrawing:"StartDrawing",actionEndDrawing:"EndDrawing",variationSuccess:"Success"},i=function(){var i=window.location.href,a={clientVersion:o.clientVersion,source:i,componentId:o.componentId,name:o.name};e=new t(a);var r={sessionId:n.id,connectionId:n.connection.connectionId,partnerId:n.apiKey};e.addSessionInfo(r)},a=function(t,n){var o={action:t,variation:n};e.logEvent(o)};OTSolution=this.OTSolution||{},console.log("ello"),OTSolution.Annotations=function(n){function r(t,e,n){for(var o=e.split(" "),i=0,a=o.length;i<a;i++)t.addEventListener(o[i],n,!0)}function s(t,e){0===d.width&&(d.width=l.parent.getBoundingClientRect().width),0===d.height&&(d.height=l.parent.getBoundingClientRect().height);var n,i=e?t.canvas.width:l.parent.clientWidth,r=e?t.canvas.height:l.parent.clientHeight,s=e?t.canvas.offsetLeft:d.offsetLeft,c=e?t.canvas.offsetTop:d.offsetTop,h=d.width/i,u=d.height/r,f=t.offsetX||t.pageX-s||t.changedTouches&&t.changedTouches[0].pageX-s,g=t.offsetY||t.pageY-c||t.changedTouches&&t.changedTouches[0].pageY-c,m=f*h,v=g*u,y=e?t.selectedItem:l.selectedItem;if(y)if("OT_pen"===y.id)switch(t.type){case"mousedown":case"touchstart":I.dragging=!0,I.lastX=m,I.lastY=v,l.isStartPoint=!0,!e&&a(o.actionStartDrawing,o.variationSuccess);break;case"mousemove":case"touchmove":I.dragging&&(n={id:l.videoFeed.stream.connection.connectionId,fromId:l.session.connection.connectionId,fromX:I.lastX,fromY:I.lastY,toX:m,toY:v,color:e?t.userColor:l.userColor,lineWidth:l.lineWidth,videoWidth:l.videoFeed.videoElement().clientWidth,videoHeight:l.videoFeed.videoElement().clientHeight,canvasWidth:d.width,canvasHeight:d.height,mirrored:p,startPoint:l.isStartPoint,endPoint:!1,selectedItem:y},E(n,!0),I.lastX=m,I.lastY=v,!e&&j(n),l.isStartPoint=!1);break;case"mouseup":case"touchend":I.dragging=!1,n={id:l.videoFeed.stream.connection.connectionId,fromId:l.session.connection.connectionId,fromX:I.lastX,fromY:I.lastY,toX:m,toY:v,color:e?t.userColor:l.userColor,lineWidth:l.lineWidth,videoWidth:l.videoFeed.videoElement().clientWidth,videoHeight:l.videoFeed.videoElement().clientHeight,canvasWidth:d.width,canvasHeight:d.height,mirrored:p,startPoint:l.isStartPoint,endPoint:!0,selectedItem:y},E(n,!0),I.lastX=m,I.lastY=v,!e&&j(n),l.isStartPoint=!1,!e&&a(o.actionEndDrawing,o.variationSuccess);break;case"mouseout":I.dragging=!1}else if("OT_text"===y.id)n={id:l.videoFeed.stream.connection.connectionId,fromId:l.session.connection.connectionId,fromX:m,fromY:v+t.inputHeight,color:t.userColor,font:t.font,text:t.text,videoWidth:l.videoFeed.videoElement().clientWidth,videoHeight:l.videoFeed.videoElement().clientHeight,canvasWidth:d.width,canvasHeight:d.height,mirrored:p,selectedItem:y},E(n),!e&&j(n);else if(y&&y.points)switch(I.mX=m,I.mY=v,t.type){case"mousedown":case"touchstart":I.isDrawing=!0,I.dragging=!0,I.startX=m,I.startY=v;break;case"mousemove":case"touchmove":I.dragging&&(n={color:e?t.userColor:l.userColor,lineWidth:e?t.lineWidth:l.lineWidth,selectedItem:y},E(n,!0));break;case"mouseup":case"touchend":I.isDrawing=!1;var w=y.points;if(2===w.length)n={id:l.videoFeed.stream.connection.connectionId,fromId:l.session.connection.connectionId,fromX:I.startX,fromY:I.startY,toX:I.mX,toY:I.mY,color:e?t.userColor:l.userColor,lineWidth:e?t.lineWidth:l.lineWidth,videoWidth:l.videoFeed.videoElement().clientWidth,videoHeight:l.videoFeed.videoElement().clientHeight,canvasWidth:d.width,canvasHeight:d.height,mirrored:p,smoothed:!1,startPoint:!0,endPoint:!0,selectedItem:y},b.push(n),!e&&j(n);else{for(var x=A(w),T=0;T<w.length;T++){var k=!1,W=!1,C=I.startX+x.x*w[T][0],M=I.startY+x.y*w[T][1];0===T?(I.lastX=C,I.lastY=M,k=!0):T===w.length-1&&(W=!0),n={id:l.videoFeed.stream.connection.connectionId,fromId:l.session.connection.connectionId,fromX:I.lastX,fromY:I.lastY,toX:C,toY:M,color:e?t.userColor:l.userColor,lineWidth:e?t.lineWidth:l.lineWidth,videoWidth:l.videoFeed.videoElement().clientWidth,videoHeight:l.videoFeed.videoElement().clientHeight,canvasWidth:d.width,canvasHeight:d.height,mirrored:p,smoothed:y.enableSmoothing,startPoint:k,endPoint:W},b.push(n),!e&&j(n),I.lastX=C,I.lastY=M}E(null)}I.dragging=!1}}n=n||{},this.widgetVersion="js-1.0.0-beta",this.parent=n.container,this.videoFeed=n.feed,t=t||n.OTKAnalytics,e||i();var c=n.externalWindow?n.externalWindow.document:window.document,l=this;if(this.parent){var d=document.createElement("canvas");d.setAttribute("id","opentok_canvas"),d.style.position="absolute",this.parent.appendChild(d),d.setAttribute("width",this.parent.clientWidth+"px"),d.style.width=window.getComputedStyle(this.parent).width,d.setAttribute("height",this.parent.clientHeight+"px"),d.style.height=window.getComputedStyle(this.parent).height}var h,u,p,f,g,l=this,m=[],v=[],b=[],y=[],w=[],I={dragging:!1};u=(" "+l.videoFeed.element.className+" ").indexOf(" OT_publisher ")>-1,p=!!u&&(" "+l.videoFeed.element.className+" ").indexOf(" OT_mirrored ")>-1,f=(" "+l.videoFeed.element.className+" ").indexOf(" OT_fit-mode-cover ")>-1,this.canvas=function(){return d},this.link=function(t){this.session=t},this.changeColor=function(t){l.userColor=t,l.lineWidth||(l.lineWidth=2)},this.changeLineWidth=function(t){this.lineWidth=t},this.selectItem=function(t){l.overlay&&(l.overlay.style.display="none",l.overlay=null),"OT_capture"===t.id?(l.selectedItem=t,l.overlay?l.overlay.style="inline":(l.overlay=document.createElement("div"),l.overlay.style.position="absolute",l.overlay.style.top="0px",l.overlay.style.width=l.parent.clientWidth+"px",l.overlay.style.height=l.parent.clientHeight+"px",l.overlay.style.background='rgba(0,0,0,0.4) url("https://assets.tokbox.com/solutions/images/annotation-camera.png") no-repeat center',l.overlay.style.backgroundSize="50px 50px",l.overlay.style.cursor="pointer",l.overlay.style.opacity=0,l.parent.appendChild(l.overlay),l.parent.onmouseover=function(){l.overlay.style.opacity=1,l.overlay.style.zIndex=1010},l.parent.onmouseout=function(){l.overlay.style.opacity=0},l.overlay.onclick=function(){l.captureScreenshot(),l.overlay.style.display="none",l.overlay=null})):t.id.indexOf("OT_line_width")!==-1?t.size&&l.changeLineWidth(t.size):l.selectedItem=t},this.colors=function(t){this.colors=t,this.changeColor(t[0])},this.clear=function(){H(!1,l.session.connection.connectionId),l.session&&l.session.signal({type:"otAnnotation_clear"})},this.captureScreenshot=function(){var t=document.createElement("canvas");t.width=d.width,t.height=d.height;var e=l.videoFeed.videoWidth(),n=l.videoFeed.videoHeight(),o=1,i=0,a=0;f?(e<n?(o=d.width/e,e=d.width,n*=o):(o=d.height/n,n=d.height,e*=o),i=(e-d.width)/2,a=(n-d.height)/2):e>n?(o=d.width/e,e=d.width,n*=o):(o=d.height/n,n=d.height,e*=o);var r=new Image;r.onload=function(){var o=t.getContext("2d");p&&(o.translate(e,0),o.scale(-1,1)),o.drawImage(r,i,a,e,n),p&&(o.translate(e,0),o.scale(-1,1)),o.drawImage(d,0,0),m.forEach(function(e){e.call(l,t.toDataURL())}),t=null},r.src="data:image/png;base64,"+l.videoFeed.getImgData()},this.onScreenCapture=function(t){m.push(t)},this.onResize=function(){b=[],Y(y,!0),w.forEach(function(t){s(t,!0)})},r(d,"mousedown mousemove mouseup mouseout touchstart touchmove touchend",function(t){var e=l.selectedItem&&"OT_text"===l.selectedItem.id,n="mousemove"===t.type&&!I.dragging;e||n||(t.preventDefault(),t.selectedItem=l.selectedItem,t.selectedItem&&(t.canvas={width:d.width,height:d.height,offsetLeft:d.offsetLeft,offsetTop:d.offsetTop},t.userColor=l.userColor,t.lineWidth=l.lineWidth,w.push(t)),s(t))});var x,T="textAnnotation",k=!1,W=function(t){t.preventDefault(),l.selectedItem&&"OT_text"===l.selectedItem.id&&!k&&(k=!0,t.selectedItem=l.selectedItem,_(t))},C=function(t){13===t.which&&O(),27===t.which&&(c.getElementById(T).remove(),x=null),k=!1},M=function(){c.addEventListener("keydown",C)},P=function(){c.removeEventListener("keydown",C)},O=function(){var t=c.getElementById(T);t.clientHeight;return t.value?(t.remove(),P(),x.text=t.value,x.font="16px Arial",x.userColor=l.userColor,x.canvas={width:d.width,height:d.height,offsetLeft:d.offsetLeft,offsetTop:d.offsetTop},w.push(x),void s(x)):void(x=null)},_=function(t){var e=c.createElement("input");e.setAttribute("type","text"),e.style.position="absolute",e.style.top=t.clientY+"px",e.style.left=t.clientX+"px",e.style.background="rgba(255,255,255, .5)",e.style.width="100px",e.style.maxWidth="200px",e.style.border="1px dashed red",e.style.fontSize="16px",e.style.color=l.userColor,e.style.fontFamily="Arial",e.style.zIndex="1001",e.setAttribute("data-canvas-origin",JSON.stringify({x:t.offsetX,y:t.offsetY})),e.id=T,c.body.appendChild(e),e.focus(),x=t,x.inputHeight=e.clientHeight,M()};r(d,"click",W);var E=function(t,e){h||(h=d.getContext("2d"),h.lineCap="round",h.lineJoin="round",h.fillStyle="solid"),h.clearRect(0,0,d.width,d.height),b.forEach(function(t){h.strokeStyle=t.color,h.lineWidth=t.lineWidth,t.smoothed=!!t.smoothed,t.startPoint=!!t.startPoint;var e=!1,n=!!t.selectedItem&&"Text"===t.selectedItem.title&&t.text;n?(h.font=t.font,h.fillStyle=t.color,h.fillText(t.text,t.fromX,t.fromY)):t.smoothed?(t.startPoint?l.isStartPoint=!0:l.isStartPoint&&(e=!0,l.isStartPoint=!1),t.startPoint?(h.closePath(),h.beginPath()):e?h.moveTo((t.fromX+t.toX)/2,(t.fromY+t.toY)/2):(h.quadraticCurveTo(t.fromX,t.fromY,(t.fromX+t.toX)/2,(t.fromY+t.toY)/2),h.stroke())):(h.beginPath(),h.moveTo(t.fromX,t.fromY),h.lineTo(t.toX,t.toY),h.stroke(),h.closePath())});var n=e?t.selectedItem:l.selectedItem;!n||"Pen"!==n.title&&"Text"!==n.title?I.isDrawing&&(t&&(h.strokeStyle=t.color,h.lineWidth=t.lineWidth),n&&n.points&&S(h,l.selectedItem.points)):t&&("Pen"===n.title&&(h.strokeStyle=t.color,h.lineWidth=t.lineWidth,h.beginPath(),h.moveTo(t.fromX,t.fromY),h.lineTo(t.toX,t.toY),h.stroke(),h.closePath()),"Text"===n.title&&(h.font=t.font,h.fillStyle=t.color,h.fillText(t.text,t.fromX,t.fromY)),b.push(t))},S=function(t,e){var n=A(e);if(t.beginPath(),2===e.length)t.moveTo(I.startX,I.startY),t.lineTo(I.mX,I.mY);else for(var o=0;o<e.length;o++){var i=I.startX+n.x*e[o][0],a=I.startY+n.y*e[o][1];l.selectedItem.enableSmoothing?0===o||(1===o?(t.moveTo((i+I.lastX)/2,(a+I.lastY)/2),I.lastX=(i+I.lastX)/2,I.lastX=(a+I.lastY)/2):(t.quadraticCurveTo(I.lastX,I.lastY,(i+I.lastX)/2,(a+I.lastY)/2),I.lastX=(i+I.lastX)/2,I.lastY=(a+I.lastY)/2)):0===o?t.moveTo(i,a):t.lineTo(i,a),I.lastX=i,I.lastY=a}t.stroke(),t.closePath()},A=function(t){for(var e=Number.MAX_VALUE,n=Number.MAX_VALUE,o=0,i=0,a=0;a<t.length;a++)t[a][0]<e?e=t[a][0]:t[a][0]>o&&(o=t[a][0]),t[a][1]<n?n=t[a][1]:t[a][1]>i&&(i=t[a][1]);var r=Math.abs(o-e),s=Math.abs(i-n),c=(I.mX-I.startX)/r,l=(I.mY-I.startY)/s;return{x:c,y:l}},X=function(t,e,n){var o={width:t.canvasWidth,height:t.canvasHeight},i={width:t.videoWidth,height:t.videoHeight},a={width:l.videoFeed.videoElement().clientWidth,height:l.videoFeed.videoElement().clientHeight},r=1,s=d.width/d.height;a.width/a.height,o.width/o.height,i.width/i.height;r=s<0?d.width/o.width:d.height/o.height;var c=d.width/2,h=d.height/2,u=o.width/2,f=o.height/2;t.fromX=c-r*(u-t.fromX),t.fromY=h-r*(f-t.fromY),t.toX=c-r*(u-t.toX),t.toY=h-r*(f-t.toY),t.mirrored=!!t.mirrored,t.mirrored&&(t.fromX=d.width-t.fromX,t.toX=d.width-t.toX),p&&(t.fromX=d.width-t.fromX,t.toX=d.width-t.toX);var g=JSON.parse(JSON.stringify(t));g.canvasWidth=d.width,g.canvasHeight=d.height,g.videoWidth=a.width,g.videoHeight=a.height,e?y[n]=g:y.push(g),b.push(t),E(null)},Y=function(t,e){t.forEach(function(t,n){l.videoFeed.stream&&t.id===l.videoFeed.stream.connection.connectionId&&X(t,e,n)})},H=function(t,e){b=b.filter(function(t){return console.log(t.fromId),t.fromId!==e}),t?y=[]:(l.session&&l.session.signal({type:"otAnnotation_clear"}),w=[]),E()};l.videoFeed.session&&l.videoFeed.session.on({"signal:otAnnotation_pen":function(t){t.from.connectionId!==l.session.connection.connectionId&&Y(JSON.parse(t.data))},"signal:otAnnotation_text":function(t){t.from.connectionId!==l.session.connection.connectionId&&Y(JSON.parse(t.data))},"signal:otAnnotation_history":function(t){g&&g!==t.from.connectionId||(g=t.from.connectionId,Y(JSON.parse(t.data)))},"signal:otAnnotation_clear":function(t){t.from.connectionId!==l.session.connection.connectionId&&H(!0,t.from.connectionId)},connectionCreated:function(t){b.length>0&&t.connection.connectionId!==l.session.connection.connectionId&&z("otWhiteboard_history",b,t.connection)}});var F,z=function(t,e){for(var n=t.slice(),o=function(t){t&&TB.error(t)},i="otAnnotation_pen",a=function(t){if(t&&t[0]&&t[0].selectedItem&&t[0].selectedItem.id){var e=t[0].selectedItem.id;i="OT_text"===e?"otAnnotation_text":"otAnnotation_pen"}};n.length;){var r=n.splice(0,Math.min(n.length,32));a(r);var s={type:i,data:JSON.stringify(r)};e&&(s.to=e),l.session.signal(s,o)}},j=function(t){l.session&&(v.push(t),F||(F=setTimeout(function(){z(v),v=[],F=null},100)))}},OTSolution.Annotations.Toolbar=function(o){var a=this,r=this;if(o||(o={}),!o.session)throw new Error("OpenTok Annotation Widget requires an OpenTok session");if(n=o.session,!t&&!o.OTKAnalytics)throw new Error("OpenTok Annotation Widget requires an OpenTok Solution");t=t||o.OTKAnalytics,e||i(),this.session=o.session,this.parent=o.container,this.externalWindow=o.externalWindow,this.backgroundColor=o.backgroundColor||"rgba(0, 0, 0, 0.7)",this.buttonWidth=o.buttonWidth||"40px",this.buttonHeight=o.buttonHeight||"40px",this.iconWidth=o.iconWidth||"30px",this.iconHeight=o.iconHeight||"30px";var s="https://assets.tokbox.com/solutions/images/",c=[{id:"OT_pen",title:"Pen",icon:[s,"annotation-freehand.png"].join(""),selectedIcon:[s,"annotation-freehand_selected.png"].join("")},{id:"OT_line",title:"Line",icon:[s,"annotation-line.png"].join(""),selectedIcon:[s,"annotation-line_selected.png"].join(""),points:[[0,0],[0,1]]},{id:"OT_shapes",title:"Shapes",icon:[s,"annotation-shapes.png"].join(""),items:[{id:"OT_arrow",title:"Arrow",icon:[s,"annotation-arrow.png"].join(""),points:[[0,1],[3,1],[3,0],[5,2],[3,4],[3,3],[0,3],[0,1]]},{id:"OT_rect",title:"Rectangle",icon:[s,"annotation-rectangle.png"].join(""),points:[[0,0],[1,0],[1,1],[0,1],[0,0]]},{id:"OT_oval",title:"Oval",icon:[s,"annotation-oval.png"].join(""),enableSmoothing:!0,points:[[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)],[.5,0],[.5+.5*Math.cos(7*Math.PI/4),.5+.5*Math.sin(7*Math.PI/4)],[1,.5],[.5+.5*Math.cos(Math.PI/4),.5+.5*Math.sin(Math.PI/4)],[.5,1],[.5+.5*Math.cos(3*Math.PI/4),.5+.5*Math.sin(3*Math.PI/4)],[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)]]},{id:"OT_star",title:"Star",icon:[s,"annotation-star.png"].join(""),points:[[.5+.5*Math.cos(90*(Math.PI/180)),.5+.5*Math.sin(90*(Math.PI/180))],[.5+.25*Math.cos(126*(Math.PI/180)),.5+.25*Math.sin(126*(Math.PI/180))],[.5+.5*Math.cos(162*(Math.PI/180)),.5+.5*Math.sin(162*(Math.PI/180))],[.5+.25*Math.cos(198*(Math.PI/180)),.5+.25*Math.sin(198*(Math.PI/180))],[.5+.5*Math.cos(234*(Math.PI/180)),.5+.5*Math.sin(234*(Math.PI/180))],[.5+.25*Math.cos(270*(Math.PI/180)),.5+.25*Math.sin(270*(Math.PI/180))],[.5+.5*Math.cos(306*(Math.PI/180)),.5+.5*Math.sin(306*(Math.PI/180))],[.5+.25*Math.cos(342*(Math.PI/180)),.5+.25*Math.sin(342*(Math.PI/180))],[.5+.5*Math.cos(18*(Math.PI/180)),.5+.5*Math.sin(18*(Math.PI/180))],[.5+.25*Math.cos(54*(Math.PI/180)),.5+.25*Math.sin(54*(Math.PI/180))],[.5+.5*Math.cos(90*(Math.PI/180)),.5+.5*Math.sin(90*(Math.PI/180))]]}]},{id:"OT_text",title:"Text",icon:[s,"annotation-text.png"].join(""),selectedIcon:[s,"annotation-text.png"].join("")},{id:"OT_colors",title:"Colors",icon:"",items:{}},{id:"OT_line_width",title:"Line Width",icon:[s,"annotation-line_width.png"].join(""),items:{}},{id:"OT_clear",title:"Clear",icon:[s,"annotation-clear.png"].join("")},{id:"OT_capture",title:"Capture",icon:[s,"annotation-camera.png"].join(""),selectedIcon:[s,"annotation-camera_selected.png"].join("")}],l=function(){var t=["pen","line","shapes","text","colors","line-width","clear","capture"],e=function(e,n){var o=t.indexOf(n);return o!==-1&&e.push(c[o]),e};return o.items&&o.items.length?o.items.reduce(e,[]):c};this.items=l(),this.colors=o.colors||["#1abc9c","#2ecc71","#3498db","#9b59b6","#34495e","#16a085","#27ae60","#2980b9","#8e44ad","#2c3e50","#f1c40f","#e67e22","#e74c3c","#ecf0f1","#95a5a6","#f39c12","#d35400","#c0392b","#bdc3c7","#7f8c8d"],this.cbs=[];var d,h=[],u=function(t,e,n){var o=this,i=r.externalWindow?r.externalWindow.document:document;this.getElm=function(t){return"string"==typeof t?i.querySelector(t):t},this.render=function(){var t=this,e="";t.colors.forEach(function(n){e+=t.options.template.replace(/\{color\}/g,n)}),t.elm.innerHTML=e},this.close=function(){this.elm.style.display="none"},this.open=function(){this.elm.style.display=this.options.style.display},this.colorChosen=function(t){this.cbs.push(t)},this.set=function(t,e){var n=this;n.color=t,e!==!1&&n.cbs.forEach(function(e){e.call(n,t)})},n=n||{},n.openEvent=n.openEvent||"click",n.style=Object(n.style),n.style.display=n.style.display||"block",n.template=n.template||'<div class="color-choice" data-col="{color}" style="background-color: {color}"></div>',o.elm=o.getElm(t),o.cbs=[],o.colors=e,o.options=n,o.render(),o.elm.addEventListener("click",function(t){var e=t.target.getAttribute("data-col");e&&(o.set(e),o.close())}),n.autoclose!==!1&&o.close()};this.createPanel=function(t){if(r.parent){var e=t?t.document:document;d=e.createElement("div"),d.setAttribute("id","OT_toolbar"),d.setAttribute("class","OT_panel"),d.style.width="100%",d.style.height="100%",d.style.backgroundColor=this.backgroundColor,this.parent.appendChild(d),this.parent.style.position="relative",this.parent.zIndex=1e3;for(var n=[],o=e.createElement("div"),i=0,s=this.items.length;i<s;i++){var c=this.items[i],l=e.createElement("input");if(l.setAttribute("type","button"),l.setAttribute("id",c.id),l.style.position="relative",l.style.top="50%",l.style.transform="translateY(-50%)","OT_colors"===c.id){l.style.webkitTransform="translateY(-85%)";var f=e.createElement("div");f.setAttribute("class","color-picker"),f.style.backgroundColor=this.backgroundColor,this.parent.appendChild(f);var g=new u(".color-picker",this.colors,{externalWindow:r.externalWindow});g.colorChosen(function(t){var n=e.getElementById("OT_colors");n.style.backgroundColor=t,h.forEach(function(e){e.changeColor(t)})});for(var m=e.querySelectorAll(".color-choice"),v=0;v<m.length;v++)m[v].style.display="inline-block",m[v].style.width="30px",m[v].style.height="30px",m[v].style.margin="5px",m[v].style.cursor="pointer",m[v].style.borderRadius="100%",m[v].style.opacity=.7,m[v].onmouseover=function(){this.style.opacity=1},m[v].onmouseout=function(){this.style.opacity=.7};l.setAttribute("class","OT_color"),l.style.marginLeft="10px",l.style.marginRight="10px",l.style.borderRadius="50%",l.style.backgroundColor=this.colors[0],l.style.width=this.iconWidth,l.style.height=this.iconHeight,l.style.paddingTop=this.buttonHeight.replace("px","")-this.iconHeight.replace("px","")+"px"}else l.style.background='url("'+c.icon+'") no-repeat',l.style.backgroundSize=this.iconWidth+" "+this.iconHeight,l.style.backgroundPosition="center",l.style.width=this.buttonWidth,l.style.height=this.buttonHeight;"Line Width"!==c.title||Array.isArray(c.items)||(c.items=[{id:"OT_line_width_2",title:"Line Width 2",size:2},{id:"OT_line_width_4",title:"Line Width 4",size:4},{id:"OT_line_width_6",title:"Line Width 6",size:6},{id:"OT_line_width_8",title:"Line Width 8",size:8},{id:"OT_line_width_10",title:"Line Width 10",size:10},{id:"OT_line_width_12",title:"Line Width 12",size:12},{id:"OT_line_width_14",title:"Line Width 14",size:14}]),c.items&&l.setAttribute("data-type","group"),l.setAttribute("data-col",c.title),l.style.border="none",l.style.cursor="pointer",n.push(l.outerHTML)}d.innerHTML=n.join(""),d.onclick=function(t){var n="group"===t.target.getAttribute("data-type"),i=t.target.getAttribute("data-col"),r=t.target.getAttribute("id");n?a.items.forEach(function(t){if(t.title===i){if(a.selectedGroup=t,t.items&&(o.setAttribute("class","OT_subpanel"),o.style.backgroundColor=a.backgroundColor,o.style.width="100%",o.style.height="100%",o.style.paddingLeft="15px",o.style.display="none",a.parent.appendChild(o),Array.isArray(t.items))){var n=[];"OT_line_width"===t.id?t.items.forEach(function(t){var o=e.createElement("div");o.setAttribute("data-col",t.title),o.setAttribute("id",t.id),o.style.position="relative",o.style.top="50%",o.style.transform="translateY(-50%)",o.style["float"]="left",o.style.width=a.buttonWidth,o.style.height=a.buttonHeight,o.style.border="none",o.style.cursor="pointer";var i=e.createElement("div");i.style.backgroundColor="#FFFFFF",i.style.width="80%",i.style.height=t.size+"px",i.style.position="relative",i.style.left="50%",i.style.top="50%",i.style.transform="translateX(-50%) translateY(-50%)",i.style.pointerEvents="none",o.appendChild(i),n.push(o.outerHTML)}):t.items.forEach(function(t){var o=e.createElement("input");o.setAttribute("type","button"),o.setAttribute("data-col",t.title),o.setAttribute("id",t.id),o.style.background='url("'+t.icon+'") no-repeat',o.style.position="relative",o.style.top="50%",o.style.transform="translateY(-50%)",o.style.backgroundSize=a.iconWidth+" "+a.iconHeight,o.style.backgroundPosition="center",o.style.width=a.buttonWidth,o.style.height=a.buttonHeight,o.style.border="none",o.style.cursor="pointer",n.push(o.outerHTML)}),o.innerHTML=n.join("")}"OT_shapes"===r||"OT_line_width"===r?(o&&(o.style.display="block"),g.close()):"OT_colors"===r&&(o&&(o.style.display="none"),g.open())}}):(a.items.forEach(function(t){if("Clear"!==t.title&&t.title===i){if(a.selectedItem){var n=e.getElementById(a.selectedItem.id);n&&(n.style.background='url("'+a.selectedItem.icon+'") no-repeat',n.style.backgroundSize=a.iconWidth+" "+a.iconHeight,n.style.backgroundPosition="center")}if(t.selectedIcon){var o=e.getElementById(t.id);o&&(o.style.background='url("'+t.selectedIcon+'") no-repeat',o.style.backgroundSize=a.iconWidth+" "+a.iconHeight,o.style.backgroundPosition="center")}return a.selectedItem=t,p(t),h.forEach(function(t){t.selectItem(a.selectedItem)}),!1}}),o.style.display="none"),a.cbs.forEach(function(t){t.call(a,r)})},o.onclick=function(t){var e="group"===t.target.getAttribute("data-type"),n=(t.target.getAttribute("data-col"),t.target.getAttribute("id"));o.style.display="none",e||a.selectedGroup.items.forEach(function(t){if("OT_clear"!==t.id&&t.id===n){if(a.selectedItem){var e=document.getElementById(a.selectedItem.id);e&&(e.style.background='url("'+a.selectedItem.icon+'") no-repeat',e.style.backgroundSize=a.iconWidth+" "+a.iconHeight,e.style.backgroundPosition="center")}if(t.selectedIcon){var o=document.getElementById(t.id);e&&(o.style.background='url("'+t.selectedIcon+'") no-repeat',o.style.backgroundSize=a.iconWidth+" "+a.iconHeight,o.style.backgroundPosition="center")}return a.selectedItem=t,p(t),h.forEach(function(t){t.selectItem(a.selectedItem)}),!1}}),a.cbs.forEach(function(t){t.call(a,n)})},e.getElementById("OT_clear").onclick=function(){h.forEach(function(t){t.clear()})}}},!this.externalWindow&&this.createPanel();var p=function(t){t.points||("OT_line"===t.id?a.selectedItem.points=[[0,0],[0,1]]:"OT_arrow"===t.id?a.selectedItem.points=[[0,1],[3,1],[3,0],[5,2],[3,4],[3,3],[0,3],[0,1]]:"OT_rect"===t.id?a.selectedItem.points=[[0,0],[1,0],[1,1],[0,1],[0,0]]:"OT_oval"===t.id&&(a.selectedItem.enableSmoothing=!0,a.selectedItem.points=[[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)],[.5,0],[.5+.5*Math.cos(7*Math.PI/4),.5+.5*Math.sin(7*Math.PI/4)],[1,.5],[.5+.5*Math.cos(Math.PI/4),.5+.5*Math.sin(Math.PI/4)],[.5,1],[.5+.5*Math.cos(3*Math.PI/4),.5+.5*Math.sin(3*Math.PI/4)],[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)]]))};this.itemClicked=function(t){this.cbs.push(t)},this.addCanvas=function(t){var e=this;t.link(e.session),t.colors(e.colors),h.push(t)},this.removeCanvas=function(t){h.forEach(function(e){var n=e.canvas();e.videoFeed.stream.connection.connectionId===t&&n.parentNode&&n.parentNode.removeChild(n)}),h=h.filter(function(e){return e.videoFeed.stream.connection.connectionId!==t})},this.remove=function(){try{d.parentNode.removeChild(d)}catch(t){console.log(t)}h.forEach(function(t){var e=t.canvas();e.parentNode&&e.parentNode.removeChild(e)}),h=[]}}}).call(this),function(){var t,e,n;"object"==typeof module&&"object"==typeof module.exports?(t=require("underscore"),e=require("jquery"),n=require("opentok-solutions-logging")):(t=this._,e=this.$,n=this.OTKAnalytics);var o,i,a,r,s,c={},l={clientVersion:"js-vsol-1.0.0",componentId:"annotationsAccPack",name:"guidAnnotationsKit",actionInitialize:"Init",actionStart:"Start",actionEnd:"End",actionFreeHand:"FreeHand",actionPickerColor:"PickerColor",actionText:"Text",actionScreenCapture:"ScreenCapture",actionErase:"Erase",actionUseToolbar:"UseToolbar",variationAttempt:"Attempt",variationError:"Failure",variationSuccess:"Success"},d=function(){var t=window.location.href,e={clientVersion:l.clientVersion,source:t,componentId:l.componentId,name:l.name};s=new n(e);var o={sessionId:a.id,connectionId:a.connection.connectionId,partnerId:a.apiKey};s.addSessionInfo(o)},h=function(t,e){var n={action:t,variation:e};s.logEvent(n)},u=function(t,e){i&&i.triggerEvent(t,e)},p=function(){var t=["startAnnotation","linkAnnotation","resizeCanvas","annotationWindowClosed","endAnnotation"];i.registerEvents(t)},f=function(){var t=['<div id="annotationToolbarContainer" class="ots-annotation-toolbar-container">','<div id="toolbar"></div>',"</div>"].join("\n");e("body").append(t),h(l.actionUseToolbar,l.variationSuccess)},g=["#1abc9c","#2ecc71","#3498db","#9b59b6","#8e44ad","#f1c40f","#e67e22","#e74c3c","#ded5d5"],m=10/6,v=t.throttle(function(){r.onResize()},1e3),b=function(){var t,n;if(c.externalWindow){var o={width:c.externalWindow.innerWidth,height:c.externalWindow.innerHeight},i=o.width/m;i<=o.height?(t=o.width,n=i):(n=o.height,t=n*m)}else{var a=c.absoluteParent||c.canvasContainer;t=e(a).width(),n=e(a).height()}e(c.canvasContainer).css({width:t,height:n}),e(c.canvasContainer).find("canvas").css({width:t,height:n}),e(c.canvasContainer).find("canvas").attr({width:t,height:n}),v(),u("resizeCanvas")},y=function(){e(c.resizeSubject).on("resize",t.throttle(function(){b()},500))},w=function(e,o,i){var a=t.property("toolbarId")(o)||"toolbar",r=t.property("toolbarItems")(o),s=t.property("colors")(o)||g,c=function(){var t=i?i:window;return t.document.getElementById(a)};toolbar=new OTSolution.Annotations.Toolbar({session:e,container:c(),colors:s,items:r&&r.length?o.items:null,externalWindow:i||null,OTKAnalytics:n}),toolbar.itemClicked(function(t){var e={OT_pen:l.actionFreeHand,OT_colors:l.actionPickerColor,OT_text:l.actionText,OT_clear:l.actionErase},n=e[t];n&&h(n,l.variationSuccess)})},I=function(){var t=e.Deferred(),n=.8*screen.width|0,o=n/m,i='<!DOCTYPE html><html lang="en"><head><meta http-equiv="Content-type" content="text/html; charset=utf-8"><title>OpenTok Screen Sharing Solution Annotation</title><style type="text/css" media="screen"> body{margin: 0; background-color: rgba(0, 153, 203, 0.7); box-sizing: border-box; height: 100vh;}canvas{top: 0; z-index: 1000;}.hidden{display: none;}.main-wrap{width: 100%; height: 100%; -ms-box-orient: horizontal; display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -moz-flex; display: -webkit-flex; display: flex; -webkit-justify-content: center; justify-content: center; -webkit-align-items: center; align-items: center;}.inner-wrap{position: relative; border-radius: 8px; overflow: hidden;}.fixed-container{position: fixed; top: 275px; right: 0; width: 40px; z-index: 1001;}.fixed-container .toolbar-wrap{position: absolute; top: 0; left: 0;}.fixed-container .toolbar-wrap input{display: block; top: 0 !important; transform: none !important;}.fixed-container .toolbar-wrap .OT_color{width: 30px; margin-right: 5px !important; margin-left: 5px !important; padding: 0;}.fixed-container .toolbar-wrap .OT_subpanel, .fixed-container .toolbar-wrap .color-picker{position: absolute; top: 0; right: 40px; padding-left: 0 !important; overflow: hidden;}.fixed-container .toolbar-wrap .OT_subpanel> div{top: 0 !important; transform: none !important;}.fixed-container .toolbar-wrap .color-picker{left: -30px;}.fixed-container .toolbar-wrap .color-picker .color-choice{display: block !important; height: 20px !important; width: 20px !important;}.publisherContainer{display: block; background-color: #000000; position: absolute;}.publisher-wrap{height: 100%; width: 100%;}.subscriberContainer{position: absolute; top: 20px; left: 20px; width: 200px; height: 120px; background-color: #000000; border: 2px solid white; border-radius: 6px;}.subscriberContainer .OT_video-poster{width: 100%; height: 100%; opacity: .25; background-repeat: no-repeat; background-image: url(https://static.opentok.com/webrtc/v2.8.2/images/rtc/audioonly-silhouette.svg); background-size: 50%; background-position: center;}.OT_video-element{height: 100%; width: 100%;}.OT_edge-bar-item{display: none;}</style></head><body> <div class="main-wrap"> <div id="annotationContainer" class="inner-wrap"></div></div><div id="toolbarContainer" class="fixed-container"> <div id="toolbar" class="toolbar-wrap"></div></div><div id="subscriberVideo" class="subscriberContainer hidden"></div><script type="text/javascript" charset="utf-8"> /** Must use double-quotes since everything must be converted to a string */ var opener; var canvas; if (!toolbar){alert("Something went wrong: You must pass an OpenTok annotation toolbar object into the window.")}else{opener=window.opener; window.onbeforeunload=window.triggerCloseEvent;}var localScreenProperties={insertMode: "append", width: "100%", height: "100%", videoSource: "window", showControls: false, style:{buttonDisplayMode: "off"}, fitMode: "contain"}; var createContainerElements=function(){var parentDiv=document.getElementById("annotationContainer"); var publisherContainer=document.createElement("div"); publisherContainer.setAttribute("id", "screenshare_publisher"); publisherContainer.classList.add("publisher-wrap"); parentDiv.appendChild(publisherContainer); return{annotation: parentDiv, publisher: publisherContainer};}; var addSubscriberVideo=function(stream){var container=document.getElementById("subscriberVideo"); session.subscribe(stream, container, localScreenProperties, function(error){if (error){console.log("Failed to add subscriber video", error);}container.classList.remove("hidden");});}; if (navigator.userAgent.indexOf("Firefox") !==-1){var ghost=window.open("about:blank"); ghost.focus(); ghost.close();}</script></body></html>',r=["toolbar=no","location=no","directories=no","status=no","menubar=no","scrollbars=no","resizable=no","copyhistory=no",["width=",n].join(""),["height=",o].join(""),["left=",screen.width/2-n/2].join(""),["top=",screen.height/2-o/2].join("")].join(","),s=window.open("about:blank","",r);s.document.write(i),window.onbeforeunload=function(){s.close()},s.toolbar=toolbar,s.OT=OT,s.session=a,s.$=e,s.triggerCloseEvent=function(){u("annotationWindowClosed")},s.onbeforeunload=function(){u("annotationWindowClosed")};var c=function(){s.createContainerElements?e(s.document).ready(function(){t.resolve(s)}):setTimeout(c,100)};return c(),t.promise()},x=function(){e(c.resizeSubject).off("resize",b),toolbar.remove(),c.externalWindow||e("#annotationToolbarContainer").remove()},T=function(n,o){var i=e.Deferred();return t.property("screensharing")(o)?I().then(function(t){w(n,o,t),toolbar.createPanel(t),u("startAnnotation",t),h(l.actionStart,l.variationSuccess),i.resolve(t)}):(w(n,o),u("startAnnotation"),h(l.actionStart,l.variationSuccess),i.resolve()),i.promise()},k=function(n,o,i){c.resizeSubject=t.property("externalWindow")(i)||window,c.externalWindow=t.property("externalWindow")(i)||null,c.absoluteParent=t.property("absoluteParent")(i)||null,c.canvasContainer=o,r=new OTSolution.Annotations({feed:n,container:o,externalWindow:c.externalWindow}),toolbar.addCanvas(r),r.onScreenCapture(function(t){var e=window.open(t,"_blank");
e.focus()});var a=c.externalWindow?c.externalWindow:window;c.canvas=e(t.first(a.document.getElementsByTagName("canvas"))),y(),b(),u("linkAnnotation")},W=function(){b()},C=function(t){c.externalWindow?c.externalWindow.addSubscriberVideo(t):console.log("OT Annotation: External window does not exist. Cannot add subscriber video.")},M=function(){x(),c.canvas=null,c.externalWindow&&(c.externalWindow.close(),c.externalWindow=null,c.resizeSubject=null),u("endAnnotation"),h(l.actionEnd,l.variationSuccess)},P=function(e){if(o=this,o.options=t.omit(e,"accPack","session"),i=t.property("accPack")(e),a=t.property("session")(e),!a)throw new Error("OpenTok Annotation Accelerator Pack requires an OpenTok session");p(),d(),h(l.actionInitialize,l.variationSuccess),f()};P.prototype={constructor:P,start:T,linkCanvas:k,resizeCanvas:W,addSubscriberToExternalWindow:C,end:M},"object"==typeof exports?module.exports=P:"function"==typeof define&&define.amd?define(function(){return P}):this.AnnotationAccPack=P}.call(this);
(function(){var t,e,n,o={clientVersion:"js-vsol-1.0.0",componentId:"annotationsAccPack",name:"guidAnnotationsKit",actionStartDrawing:"StartDrawing",actionEndDrawing:"EndDrawing",variationSuccess:"Success"},i=function(){var i=window.location.href,a={clientVersion:o.clientVersion,source:i,componentId:o.componentId,name:o.name};e=new t(a);var r={sessionId:n.id,connectionId:n.connection.connectionId,partnerId:n.apiKey};e.addSessionInfo(r)},a=function(t,n){var o={action:t,variation:n};e.logEvent(o)};OTSolution=this.OTSolution||{},console.log("ello"),OTSolution.Annotations=function(n){function r(t,e,n){for(var o=e.split(" "),i=0,a=o.length;i<a;i++)t.addEventListener(o[i],n,!0)}function s(t,e){0===d.width&&(d.width=l.parent.getBoundingClientRect().width),0===d.height&&(d.height=l.parent.getBoundingClientRect().height);var n,i=e?t.canvas.width:l.parent.clientWidth,r=e?t.canvas.height:l.parent.clientHeight,s=e?t.canvas.offsetLeft:d.offsetLeft,c=e?t.canvas.offsetTop:d.offsetTop,h=d.width/i,u=d.height/r,f=t.offsetX||t.pageX-s||t.changedTouches&&t.changedTouches[0].pageX-s,g=t.offsetY||t.pageY-c||t.changedTouches&&t.changedTouches[0].pageY-c,m=f*h,v=g*u,y=e?t.selectedItem:l.selectedItem;if(y)if("OT_pen"===y.id)switch(t.type){case"mousedown":case"touchstart":I.dragging=!0,I.lastX=m,I.lastY=v,l.isStartPoint=!0,!e&&a(o.actionStartDrawing,o.variationSuccess);break;case"mousemove":case"touchmove":I.dragging&&(n={id:l.videoFeed.stream.connection.connectionId,fromId:l.session.connection.connectionId,fromX:I.lastX,fromY:I.lastY,toX:m,toY:v,color:e?t.userColor:l.userColor,lineWidth:l.lineWidth,videoWidth:l.videoFeed.videoElement().clientWidth,videoHeight:l.videoFeed.videoElement().clientHeight,canvasWidth:d.width,canvasHeight:d.height,mirrored:p,startPoint:l.isStartPoint,endPoint:!1,selectedItem:y},E(n,!0),I.lastX=m,I.lastY=v,!e&&j(n),l.isStartPoint=!1);break;case"mouseup":case"touchend":I.dragging=!1,n={id:l.videoFeed.stream.connection.connectionId,fromId:l.session.connection.connectionId,fromX:I.lastX,fromY:I.lastY,toX:m,toY:v,color:e?t.userColor:l.userColor,lineWidth:l.lineWidth,videoWidth:l.videoFeed.videoElement().clientWidth,videoHeight:l.videoFeed.videoElement().clientHeight,canvasWidth:d.width,canvasHeight:d.height,mirrored:p,startPoint:l.isStartPoint,endPoint:!0,selectedItem:y},E(n,!0),I.lastX=m,I.lastY=v,!e&&j(n),l.isStartPoint=!1,!e&&a(o.actionEndDrawing,o.variationSuccess);break;case"mouseout":I.dragging=!1}else if("OT_text"===y.id)n={id:l.videoFeed.stream.connection.connectionId,fromId:l.session.connection.connectionId,fromX:m,fromY:v+t.inputHeight,color:t.userColor,font:t.font,text:t.text,videoWidth:l.videoFeed.videoElement().clientWidth,videoHeight:l.videoFeed.videoElement().clientHeight,canvasWidth:d.width,canvasHeight:d.height,mirrored:p,selectedItem:y},E(n),!e&&j(n);else if(y&&y.points)switch(I.mX=m,I.mY=v,t.type){case"mousedown":case"touchstart":I.isDrawing=!0,I.dragging=!0,I.startX=m,I.startY=v;break;case"mousemove":case"touchmove":I.dragging&&(n={color:e?t.userColor:l.userColor,lineWidth:e?t.lineWidth:l.lineWidth,selectedItem:y},E(n,!0));break;case"mouseup":case"touchend":I.isDrawing=!1;var w=y.points;if(2===w.length)n={id:l.videoFeed.stream.connection.connectionId,fromId:l.session.connection.connectionId,fromX:I.startX,fromY:I.startY,toX:I.mX,toY:I.mY,color:e?t.userColor:l.userColor,lineWidth:e?t.lineWidth:l.lineWidth,videoWidth:l.videoFeed.videoElement().clientWidth,videoHeight:l.videoFeed.videoElement().clientHeight,canvasWidth:d.width,canvasHeight:d.height,mirrored:p,smoothed:!1,startPoint:!0,endPoint:!0,selectedItem:y},b.push(n),!e&&j(n);else{for(var x=A(w),T=0;T<w.length;T++){var k=!1,W=!1,C=I.startX+x.x*w[T][0],M=I.startY+x.y*w[T][1];0===T?(I.lastX=C,I.lastY=M,k=!0):T===w.length-1&&(W=!0),n={id:l.videoFeed.stream.connection.connectionId,fromId:l.session.connection.connectionId,fromX:I.lastX,fromY:I.lastY,toX:C,toY:M,color:e?t.userColor:l.userColor,lineWidth:e?t.lineWidth:l.lineWidth,videoWidth:l.videoFeed.videoElement().clientWidth,videoHeight:l.videoFeed.videoElement().clientHeight,canvasWidth:d.width,canvasHeight:d.height,mirrored:p,smoothed:y.enableSmoothing,startPoint:k,endPoint:W},b.push(n),!e&&j(n),I.lastX=C,I.lastY=M}E(null)}I.dragging=!1}}n=n||{},this.widgetVersion="js-1.0.0-beta",this.parent=n.container,this.videoFeed=n.feed,t=t||n.OTKAnalytics,e||i();var c=n.externalWindow?n.externalWindow.document:window.document,l=this;if(this.parent){var d=document.createElement("canvas");d.setAttribute("id","opentok_canvas"),d.style.position="absolute",this.parent.appendChild(d),d.setAttribute("width",this.parent.clientWidth+"px"),d.style.width=window.getComputedStyle(this.parent).width,d.setAttribute("height",this.parent.clientHeight+"px"),d.style.height=window.getComputedStyle(this.parent).height}var h,u,p,f,g,l=this,m=[],v=[],b=[],y=[],w=[],I={dragging:!1};u=(" "+l.videoFeed.element.className+" ").indexOf(" OT_publisher ")>-1,p=!!u&&(" "+l.videoFeed.element.className+" ").indexOf(" OT_mirrored ")>-1,f=(" "+l.videoFeed.element.className+" ").indexOf(" OT_fit-mode-cover ")>-1,this.canvas=function(){return d},this.link=function(t){this.session=t},this.changeColor=function(t){l.userColor=t,l.lineWidth||(l.lineWidth=2)},this.changeLineWidth=function(t){this.lineWidth=t},this.selectItem=function(t){l.overlay&&(l.parent.removeChild(l.overlay),l.overlay=null),"OT_capture"===t.id?(l.selectedItem=t,l.overlay?l.overlay.style="inline":(l.overlay=document.createElement("div"),l.overlay.id="captureOverlay",l.overlay.style.position="absolute",l.overlay.style.top="0px",l.overlay.style.width=l.parent.clientWidth+"px",l.overlay.style.height=l.parent.clientHeight+"px",l.overlay.style.background='rgba(0,0,0,0.4) url("https://assets.tokbox.com/solutions/images/annotation-camera.png") no-repeat center',l.overlay.style.backgroundSize="50px 50px",l.overlay.style.cursor="pointer",l.overlay.style.opacity=0,l.parent.appendChild(l.overlay),l.parent.onmouseover=function(){l.overlay.style.opacity=1,l.overlay.style.zIndex=1010},l.parent.onmouseout=function(){l.overlay.style.opacity=0},l.overlay.onclick=function(){l.captureScreenshot(),l.parent.removeChild(l.overlay),l.overlay=null,l.parent.onmouseover=null,l.parent.onmouseout=null})):t.id.indexOf("OT_line_width")!==-1?t.size&&l.changeLineWidth(t.size):l.selectedItem=t},this.colors=function(t){this.colors=t,this.changeColor(t[0])},this.clear=function(){H(!1,l.session.connection.connectionId),l.session&&l.session.signal({type:"otAnnotation_clear"})},this.captureScreenshot=function(){var t=document.createElement("canvas");t.width=d.width,t.height=d.height;var e=l.videoFeed.videoWidth(),n=l.videoFeed.videoHeight(),o=1,i=0,a=0;f?(e<n?(o=d.width/e,e=d.width,n*=o):(o=d.height/n,n=d.height,e*=o),i=(e-d.width)/2,a=(n-d.height)/2):e>n?(o=d.width/e,e=d.width,n*=o):(o=d.height/n,n=d.height,e*=o);var r=new Image;r.onload=function(){var o=t.getContext("2d");p&&(o.translate(e,0),o.scale(-1,1)),o.drawImage(r,i,a,e,n),p&&(o.translate(e,0),o.scale(-1,1)),o.drawImage(d,0,0),m.forEach(function(e){e.call(l,t.toDataURL())}),t=null},r.src="data:image/png;base64,"+l.videoFeed.getImgData()},this.onScreenCapture=function(t){m.push(t)},this.onResize=function(){b=[],Y(y,!0),w.forEach(function(t){s(t,!0)})},r(d,"mousedown mousemove mouseup mouseout touchstart touchmove touchend",function(t){var e=l.selectedItem&&"OT_text"===l.selectedItem.id,n="mousemove"===t.type&&!I.dragging;e||n||(t.preventDefault(),t.selectedItem=l.selectedItem,t.selectedItem&&(t.canvas={width:d.width,height:d.height,offsetLeft:d.offsetLeft,offsetTop:d.offsetTop},t.userColor=l.userColor,t.lineWidth=l.lineWidth,w.push(t)),s(t))});var x,T="textAnnotation",k=!1,W=function(t){t.preventDefault(),l.selectedItem&&"OT_text"===l.selectedItem.id&&!k&&(k=!0,t.selectedItem=l.selectedItem,_(t))},C=function(t){13===t.which&&O(),27===t.which&&(c.getElementById(T).remove(),x=null),k=!1},M=function(){c.addEventListener("keydown",C)},P=function(){c.removeEventListener("keydown",C)},O=function(){var t=c.getElementById(T);t.clientHeight;return t.value?(t.remove(),P(),x.text=t.value,x.font="16px Arial",x.userColor=l.userColor,x.canvas={width:d.width,height:d.height,offsetLeft:d.offsetLeft,offsetTop:d.offsetTop},w.push(x),void s(x)):void(x=null)},_=function(t){var e=c.createElement("input");e.setAttribute("type","text"),e.style.position="absolute",e.style.top=t.clientY+"px",e.style.left=t.clientX+"px",e.style.background="rgba(255,255,255, .5)",e.style.width="100px",e.style.maxWidth="200px",e.style.border="1px dashed red",e.style.fontSize="16px",e.style.color=l.userColor,e.style.fontFamily="Arial",e.style.zIndex="1001",e.setAttribute("data-canvas-origin",JSON.stringify({x:t.offsetX,y:t.offsetY})),e.id=T,c.body.appendChild(e),e.focus(),x=t,x.inputHeight=e.clientHeight,M()};r(d,"click",W);var E=function(t,e){h||(h=d.getContext("2d"),h.lineCap="round",h.lineJoin="round",h.fillStyle="solid"),h.clearRect(0,0,d.width,d.height),b.forEach(function(t){h.strokeStyle=t.color,h.lineWidth=t.lineWidth,t.smoothed=!!t.smoothed,t.startPoint=!!t.startPoint;var e=!1,n=!!t.selectedItem&&"Text"===t.selectedItem.title&&t.text;n?(h.font=t.font,h.fillStyle=t.color,h.fillText(t.text,t.fromX,t.fromY)):t.smoothed?(t.startPoint?l.isStartPoint=!0:l.isStartPoint&&(e=!0,l.isStartPoint=!1),t.startPoint?(h.closePath(),h.beginPath()):e?h.moveTo((t.fromX+t.toX)/2,(t.fromY+t.toY)/2):(h.quadraticCurveTo(t.fromX,t.fromY,(t.fromX+t.toX)/2,(t.fromY+t.toY)/2),h.stroke())):(h.beginPath(),h.moveTo(t.fromX,t.fromY),h.lineTo(t.toX,t.toY),h.stroke(),h.closePath())});var n=e?t.selectedItem:l.selectedItem;!n||"Pen"!==n.title&&"Text"!==n.title?I.isDrawing&&(t&&(h.strokeStyle=t.color,h.lineWidth=t.lineWidth),n&&n.points&&S(h,l.selectedItem.points)):t&&("Pen"===n.title&&(h.strokeStyle=t.color,h.lineWidth=t.lineWidth,h.beginPath(),h.moveTo(t.fromX,t.fromY),h.lineTo(t.toX,t.toY),h.stroke(),h.closePath()),"Text"===n.title&&(h.font=t.font,h.fillStyle=t.color,h.fillText(t.text,t.fromX,t.fromY)),b.push(t))},S=function(t,e){var n=A(e);if(t.beginPath(),2===e.length)t.moveTo(I.startX,I.startY),t.lineTo(I.mX,I.mY);else for(var o=0;o<e.length;o++){var i=I.startX+n.x*e[o][0],a=I.startY+n.y*e[o][1];l.selectedItem.enableSmoothing?0===o||(1===o?(t.moveTo((i+I.lastX)/2,(a+I.lastY)/2),I.lastX=(i+I.lastX)/2,I.lastX=(a+I.lastY)/2):(t.quadraticCurveTo(I.lastX,I.lastY,(i+I.lastX)/2,(a+I.lastY)/2),I.lastX=(i+I.lastX)/2,I.lastY=(a+I.lastY)/2)):0===o?t.moveTo(i,a):t.lineTo(i,a),I.lastX=i,I.lastY=a}t.stroke(),t.closePath()},A=function(t){for(var e=Number.MAX_VALUE,n=Number.MAX_VALUE,o=0,i=0,a=0;a<t.length;a++)t[a][0]<e?e=t[a][0]:t[a][0]>o&&(o=t[a][0]),t[a][1]<n?n=t[a][1]:t[a][1]>i&&(i=t[a][1]);var r=Math.abs(o-e),s=Math.abs(i-n),c=(I.mX-I.startX)/r,l=(I.mY-I.startY)/s;return{x:c,y:l}},X=function(t,e,n){var o={width:t.canvasWidth,height:t.canvasHeight},i={width:t.videoWidth,height:t.videoHeight},a={width:l.videoFeed.videoElement().clientWidth,height:l.videoFeed.videoElement().clientHeight},r=1,s=d.width/d.height;a.width/a.height,o.width/o.height,i.width/i.height;r=s<0?d.width/o.width:d.height/o.height;var c=d.width/2,h=d.height/2,u=o.width/2,f=o.height/2;t.fromX=c-r*(u-t.fromX),t.fromY=h-r*(f-t.fromY),t.toX=c-r*(u-t.toX),t.toY=h-r*(f-t.toY),t.mirrored=!!t.mirrored,t.mirrored&&(t.fromX=d.width-t.fromX,t.toX=d.width-t.toX),p&&(t.fromX=d.width-t.fromX,t.toX=d.width-t.toX);var g=JSON.parse(JSON.stringify(t));g.canvasWidth=d.width,g.canvasHeight=d.height,g.videoWidth=a.width,g.videoHeight=a.height,e?y[n]=g:y.push(g),b.push(t),E(null)},Y=function(t,e){t.forEach(function(t,n){l.videoFeed.stream&&t.id===l.videoFeed.stream.connection.connectionId&&X(t,e,n)})},H=function(t,e){b=b.filter(function(t){return console.log(t.fromId),t.fromId!==e}),t?y=[]:(l.session&&l.session.signal({type:"otAnnotation_clear"}),w=[]),E()};l.videoFeed.session&&l.videoFeed.session.on({"signal:otAnnotation_pen":function(t){t.from.connectionId!==l.session.connection.connectionId&&Y(JSON.parse(t.data))},"signal:otAnnotation_text":function(t){t.from.connectionId!==l.session.connection.connectionId&&Y(JSON.parse(t.data))},"signal:otAnnotation_history":function(t){g&&g!==t.from.connectionId||(g=t.from.connectionId,Y(JSON.parse(t.data)))},"signal:otAnnotation_clear":function(t){t.from.connectionId!==l.session.connection.connectionId&&H(!0,t.from.connectionId)},connectionCreated:function(t){b.length>0&&t.connection.connectionId!==l.session.connection.connectionId&&z("otWhiteboard_history",b,t.connection)}});var F,z=function(t,e){for(var n=t.slice(),o=function(t){t&&TB.error(t)},i="otAnnotation_pen",a=function(t){if(t&&t[0]&&t[0].selectedItem&&t[0].selectedItem.id){var e=t[0].selectedItem.id;i="OT_text"===e?"otAnnotation_text":"otAnnotation_pen"}};n.length;){var r=n.splice(0,Math.min(n.length,32));a(r);var s={type:i,data:JSON.stringify(r)};e&&(s.to=e),l.session.signal(s,o)}},j=function(t){l.session&&(v.push(t),F||(F=setTimeout(function(){z(v),v=[],F=null},100)))}},OTSolution.Annotations.Toolbar=function(o){var a=this,r=this;if(o||(o={}),!o.session)throw new Error("OpenTok Annotation Widget requires an OpenTok session");if(n=o.session,!t&&!o.OTKAnalytics)throw new Error("OpenTok Annotation Widget requires an OpenTok Solution");t=t||o.OTKAnalytics,e||i(),this.session=o.session,this.parent=o.container,this.externalWindow=o.externalWindow,this.backgroundColor=o.backgroundColor||"rgba(0, 0, 0, 0.7)",this.buttonWidth=o.buttonWidth||"40px",this.buttonHeight=o.buttonHeight||"40px",this.iconWidth=o.iconWidth||"30px",this.iconHeight=o.iconHeight||"30px";var s="https://assets.tokbox.com/solutions/images/",c=[{id:"OT_pen",title:"Pen",icon:[s,"annotation-freehand.png"].join(""),selectedIcon:[s,"annotation-freehand_selected.png"].join("")},{id:"OT_line",title:"Line",icon:[s,"annotation-line.png"].join(""),selectedIcon:[s,"annotation-line_selected.png"].join(""),points:[[0,0],[0,1]]},{id:"OT_shapes",title:"Shapes",icon:[s,"annotation-shapes.png"].join(""),items:[{id:"OT_arrow",title:"Arrow",icon:[s,"annotation-arrow.png"].join(""),points:[[0,1],[3,1],[3,0],[5,2],[3,4],[3,3],[0,3],[0,1]]},{id:"OT_rect",title:"Rectangle",icon:[s,"annotation-rectangle.png"].join(""),points:[[0,0],[1,0],[1,1],[0,1],[0,0]]},{id:"OT_oval",title:"Oval",icon:[s,"annotation-oval.png"].join(""),enableSmoothing:!0,points:[[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)],[.5,0],[.5+.5*Math.cos(7*Math.PI/4),.5+.5*Math.sin(7*Math.PI/4)],[1,.5],[.5+.5*Math.cos(Math.PI/4),.5+.5*Math.sin(Math.PI/4)],[.5,1],[.5+.5*Math.cos(3*Math.PI/4),.5+.5*Math.sin(3*Math.PI/4)],[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)]]},{id:"OT_star",title:"Star",icon:[s,"annotation-star.png"].join(""),points:[[.5+.5*Math.cos(90*(Math.PI/180)),.5+.5*Math.sin(90*(Math.PI/180))],[.5+.25*Math.cos(126*(Math.PI/180)),.5+.25*Math.sin(126*(Math.PI/180))],[.5+.5*Math.cos(162*(Math.PI/180)),.5+.5*Math.sin(162*(Math.PI/180))],[.5+.25*Math.cos(198*(Math.PI/180)),.5+.25*Math.sin(198*(Math.PI/180))],[.5+.5*Math.cos(234*(Math.PI/180)),.5+.5*Math.sin(234*(Math.PI/180))],[.5+.25*Math.cos(270*(Math.PI/180)),.5+.25*Math.sin(270*(Math.PI/180))],[.5+.5*Math.cos(306*(Math.PI/180)),.5+.5*Math.sin(306*(Math.PI/180))],[.5+.25*Math.cos(342*(Math.PI/180)),.5+.25*Math.sin(342*(Math.PI/180))],[.5+.5*Math.cos(18*(Math.PI/180)),.5+.5*Math.sin(18*(Math.PI/180))],[.5+.25*Math.cos(54*(Math.PI/180)),.5+.25*Math.sin(54*(Math.PI/180))],[.5+.5*Math.cos(90*(Math.PI/180)),.5+.5*Math.sin(90*(Math.PI/180))]]}]},{id:"OT_text",title:"Text",icon:[s,"annotation-text.png"].join(""),selectedIcon:[s,"annotation-text.png"].join("")},{id:"OT_colors",title:"Colors",icon:"",items:{}},{id:"OT_line_width",title:"Line Width",icon:[s,"annotation-line_width.png"].join(""),items:{}},{id:"OT_clear",title:"Clear",icon:[s,"annotation-clear.png"].join("")},{id:"OT_capture",title:"Capture",icon:[s,"annotation-camera.png"].join(""),selectedIcon:[s,"annotation-camera_selected.png"].join("")}],l=function(){var t=["pen","line","shapes","text","colors","line-width","clear","capture"],e=function(e,n){var o=t.indexOf(n);return o!==-1&&e.push(c[o]),e};return o.items&&o.items.length?o.items.reduce(e,[]):c};this.items=l(),this.colors=o.colors||["#1abc9c","#2ecc71","#3498db","#9b59b6","#34495e","#16a085","#27ae60","#2980b9","#8e44ad","#2c3e50","#f1c40f","#e67e22","#e74c3c","#ecf0f1","#95a5a6","#f39c12","#d35400","#c0392b","#bdc3c7","#7f8c8d"],this.cbs=[];var d,h=[],u=function(t,e,n){var o=this,i=r.externalWindow?r.externalWindow.document:document;this.getElm=function(t){return"string"==typeof t?i.querySelector(t):t},this.render=function(){var t=this,e="";t.colors.forEach(function(n){e+=t.options.template.replace(/\{color\}/g,n)}),t.elm.innerHTML=e},this.close=function(){this.elm.style.display="none"},this.open=function(){this.elm.style.display=this.options.style.display},this.colorChosen=function(t){this.cbs.push(t)},this.set=function(t,e){var n=this;n.color=t,e!==!1&&n.cbs.forEach(function(e){e.call(n,t)})},n=n||{},n.openEvent=n.openEvent||"click",n.style=Object(n.style),n.style.display=n.style.display||"block",n.template=n.template||'<div class="color-choice" data-col="{color}" style="background-color: {color}"></div>',o.elm=o.getElm(t),o.cbs=[],o.colors=e,o.options=n,o.render(),o.elm.addEventListener("click",function(t){var e=t.target.getAttribute("data-col");e&&(o.set(e),o.close())}),n.autoclose!==!1&&o.close()};this.createPanel=function(t){if(r.parent){var e=t?t.document:document;d=e.createElement("div"),d.setAttribute("id","OT_toolbar"),d.setAttribute("class","OT_panel"),d.style.width="100%",d.style.height="100%",d.style.backgroundColor=this.backgroundColor,this.parent.appendChild(d),this.parent.style.position="relative",this.parent.zIndex=1e3;for(var n=[],o=e.createElement("div"),i=0,s=this.items.length;i<s;i++){var c=this.items[i],l=e.createElement("input");if(l.setAttribute("type","button"),l.setAttribute("id",c.id),l.style.position="relative",l.style.top="50%",l.style.transform="translateY(-50%)","OT_colors"===c.id){l.style.webkitTransform="translateY(-85%)";var f=e.createElement("div");f.setAttribute("class","color-picker"),f.style.backgroundColor=this.backgroundColor,this.parent.appendChild(f);var g=new u(".color-picker",this.colors,{externalWindow:r.externalWindow});g.colorChosen(function(t){var n=e.getElementById("OT_colors");n.style.backgroundColor=t,h.forEach(function(e){e.changeColor(t)})});for(var m=e.querySelectorAll(".color-choice"),v=0;v<m.length;v++)m[v].style.display="inline-block",m[v].style.width="30px",m[v].style.height="30px",m[v].style.margin="5px",m[v].style.cursor="pointer",m[v].style.borderRadius="100%",m[v].style.opacity=.7,m[v].onmouseover=function(){this.style.opacity=1},m[v].onmouseout=function(){this.style.opacity=.7};l.setAttribute("class","OT_color"),l.style.marginLeft="10px",l.style.marginRight="10px",l.style.borderRadius="50%",l.style.backgroundColor=this.colors[0],l.style.width=this.iconWidth,l.style.height=this.iconHeight,l.style.paddingTop=this.buttonHeight.replace("px","")-this.iconHeight.replace("px","")+"px"}else l.style.background='url("'+c.icon+'") no-repeat',l.style.backgroundSize=this.iconWidth+" "+this.iconHeight,l.style.backgroundPosition="center",l.style.width=this.buttonWidth,l.style.height=this.buttonHeight;"Line Width"!==c.title||Array.isArray(c.items)||(c.items=[{id:"OT_line_width_2",title:"Line Width 2",size:2},{id:"OT_line_width_4",title:"Line Width 4",size:4},{id:"OT_line_width_6",title:"Line Width 6",size:6},{id:"OT_line_width_8",title:"Line Width 8",size:8},{id:"OT_line_width_10",title:"Line Width 10",size:10},{id:"OT_line_width_12",title:"Line Width 12",size:12},{id:"OT_line_width_14",title:"Line Width 14",size:14}]),c.items&&l.setAttribute("data-type","group"),l.setAttribute("data-col",c.title),l.style.border="none",l.style.cursor="pointer",n.push(l.outerHTML)}d.innerHTML=n.join(""),d.onclick=function(t){var n="group"===t.target.getAttribute("data-type"),i=t.target.getAttribute("data-col"),r=t.target.getAttribute("id");n?a.items.forEach(function(t){if(t.title===i){if(a.selectedGroup=t,t.items&&(o.setAttribute("class","OT_subpanel"),o.style.backgroundColor=a.backgroundColor,o.style.width="100%",o.style.height="100%",o.style.paddingLeft="15px",o.style.display="none",a.parent.appendChild(o),Array.isArray(t.items))){var n=[];"OT_line_width"===t.id?t.items.forEach(function(t){var o=e.createElement("div");o.setAttribute("data-col",t.title),o.setAttribute("id",t.id),o.style.position="relative",o.style.top="50%",o.style.transform="translateY(-50%)",o.style["float"]="left",o.style.width=a.buttonWidth,o.style.height=a.buttonHeight,o.style.border="none",o.style.cursor="pointer";var i=e.createElement("div");i.style.backgroundColor="#FFFFFF",i.style.width="80%",i.style.height=t.size+"px",i.style.position="relative",i.style.left="50%",i.style.top="50%",i.style.transform="translateX(-50%) translateY(-50%)",i.style.pointerEvents="none",o.appendChild(i),n.push(o.outerHTML)}):t.items.forEach(function(t){var o=e.createElement("input");o.setAttribute("type","button"),o.setAttribute("data-col",t.title),o.setAttribute("id",t.id),o.style.background='url("'+t.icon+'") no-repeat',o.style.position="relative",o.style.top="50%",o.style.transform="translateY(-50%)",o.style.backgroundSize=a.iconWidth+" "+a.iconHeight,o.style.backgroundPosition="center",o.style.width=a.buttonWidth,o.style.height=a.buttonHeight,o.style.border="none",o.style.cursor="pointer",n.push(o.outerHTML)}),o.innerHTML=n.join("")}"OT_shapes"===r||"OT_line_width"===r?(o&&(o.style.display="block"),g.close()):"OT_colors"===r&&(o&&(o.style.display="none"),g.open())}}):(a.items.forEach(function(t){if("Clear"!==t.title&&t.title===i){if(a.selectedItem){var n=e.getElementById(a.selectedItem.id);n&&(n.style.background='url("'+a.selectedItem.icon+'") no-repeat',n.style.backgroundSize=a.iconWidth+" "+a.iconHeight,n.style.backgroundPosition="center")}if(t.selectedIcon){var o=e.getElementById(t.id);o&&(o.style.background='url("'+t.selectedIcon+'") no-repeat',o.style.backgroundSize=a.iconWidth+" "+a.iconHeight,o.style.backgroundPosition="center")}return a.selectedItem=t,p(t),h.forEach(function(t){t.selectItem(a.selectedItem)}),!1}}),o.style.display="none"),a.cbs.forEach(function(t){t.call(a,r)})},o.onclick=function(t){var e="group"===t.target.getAttribute("data-type"),n=(t.target.getAttribute("data-col"),t.target.getAttribute("id"));o.style.display="none",e||a.selectedGroup.items.forEach(function(t){if("OT_clear"!==t.id&&t.id===n){if(a.selectedItem){var e=document.getElementById(a.selectedItem.id);e&&(e.style.background='url("'+a.selectedItem.icon+'") no-repeat',e.style.backgroundSize=a.iconWidth+" "+a.iconHeight,e.style.backgroundPosition="center")}if(t.selectedIcon){var o=document.getElementById(t.id);e&&(o.style.background='url("'+t.selectedIcon+'") no-repeat',o.style.backgroundSize=a.iconWidth+" "+a.iconHeight,o.style.backgroundPosition="center")}return a.selectedItem=t,p(t),h.forEach(function(t){t.selectItem(a.selectedItem)}),!1}}),a.cbs.forEach(function(t){t.call(a,n)})},e.getElementById("OT_clear").onclick=function(){h.forEach(function(t){t.clear()})}}},!this.externalWindow&&this.createPanel();var p=function(t){t.points||("OT_line"===t.id?a.selectedItem.points=[[0,0],[0,1]]:"OT_arrow"===t.id?a.selectedItem.points=[[0,1],[3,1],[3,0],[5,2],[3,4],[3,3],[0,3],[0,1]]:"OT_rect"===t.id?a.selectedItem.points=[[0,0],[1,0],[1,1],[0,1],[0,0]]:"OT_oval"===t.id&&(a.selectedItem.enableSmoothing=!0,a.selectedItem.points=[[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)],[.5,0],[.5+.5*Math.cos(7*Math.PI/4),.5+.5*Math.sin(7*Math.PI/4)],[1,.5],[.5+.5*Math.cos(Math.PI/4),.5+.5*Math.sin(Math.PI/4)],[.5,1],[.5+.5*Math.cos(3*Math.PI/4),.5+.5*Math.sin(3*Math.PI/4)],[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)]]))};this.itemClicked=function(t){this.cbs.push(t)},this.addCanvas=function(t){var e=this;t.link(e.session),t.colors(e.colors),h.push(t)},this.removeCanvas=function(t){h.forEach(function(e){var n=e.canvas();e.videoFeed.stream.connection.connectionId===t&&n.parentNode&&n.parentNode.removeChild(n)}),h=h.filter(function(e){return e.videoFeed.stream.connection.connectionId!==t})},this.remove=function(){try{d.parentNode.removeChild(d)}catch(t){console.log(t)}h.forEach(function(t){var e=t.canvas();e.parentNode&&e.parentNode.removeChild(e)}),h=[]}}}).call(this),function(){var t,e,n;"object"==typeof module&&"object"==typeof module.exports?(t=require("underscore"),e=require("jquery"),n=require("opentok-solutions-logging")):(t=this._,e=this.$,n=this.OTKAnalytics);var o,i,a,r,s,c={},l={clientVersion:"js-vsol-1.0.0",componentId:"annotationsAccPack",name:"guidAnnotationsKit",actionInitialize:"Init",actionStart:"Start",actionEnd:"End",actionFreeHand:"FreeHand",actionPickerColor:"PickerColor",actionText:"Text",actionScreenCapture:"ScreenCapture",actionErase:"Erase",actionUseToolbar:"UseToolbar",variationAttempt:"Attempt",variationError:"Failure",variationSuccess:"Success"},d=function(){var t=window.location.href,e={clientVersion:l.clientVersion,source:t,componentId:l.componentId,name:l.name};s=new n(e);var o={sessionId:a.id,connectionId:a.connection.connectionId,partnerId:a.apiKey};s.addSessionInfo(o)},h=function(t,e){var n={action:t,variation:e};s.logEvent(n)},u=function(t,e){i&&i.triggerEvent(t,e)},p=function(){var t=["startAnnotation","linkAnnotation","resizeCanvas","annotationWindowClosed","endAnnotation"];i.registerEvents(t)},f=function(){var t=['<div id="annotationToolbarContainer" class="ots-annotation-toolbar-container">','<div id="toolbar"></div>',"</div>"].join("\n");e("body").append(t),h(l.actionUseToolbar,l.variationSuccess)},g=["#1abc9c","#2ecc71","#3498db","#9b59b6","#8e44ad","#f1c40f","#e67e22","#e74c3c","#ded5d5"],m=10/6,v=t.throttle(function(){r.onResize()},1e3),b=function(){var t,n;if(c.externalWindow){var o={width:c.externalWindow.innerWidth,height:c.externalWindow.innerHeight},i=o.width/m;i<=o.height?(t=o.width,n=i):(n=o.height,t=n*m)}else{var a=c.absoluteParent||c.canvasContainer;t=e(a).width(),n=e(a).height()}e(c.canvasContainer).css({width:t,height:n}),e(c.canvasContainer).find("canvas").css({width:t,height:n}),e(c.canvasContainer).find("canvas").attr({width:t,height:n}),v(),u("resizeCanvas")},y=function(){e(c.resizeSubject).on("resize",t.throttle(function(){b()},500))},w=function(e,o,i){var a=t.property("toolbarId")(o)||"toolbar",r=t.property("toolbarItems")(o),s=t.property("colors")(o)||g,c=function(){var t=i?i:window;return t.document.getElementById(a)};toolbar=new OTSolution.Annotations.Toolbar({session:e,container:c(),colors:s,items:r&&r.length?o.items:null,externalWindow:i||null,OTKAnalytics:n}),toolbar.itemClicked(function(t){var e={OT_pen:l.actionFreeHand,OT_colors:l.actionPickerColor,OT_text:l.actionText,OT_clear:l.actionErase},n=e[t];n&&h(n,l.variationSuccess)})},I=function(){var t=e.Deferred(),n=.8*screen.width|0,o=n/m,i='<!DOCTYPE html><html lang="en"><head><meta http-equiv="Content-type" content="text/html; charset=utf-8"><title>OpenTok Screen Sharing Solution Annotation</title><style type="text/css" media="screen"> body{margin: 0; background-color: rgba(0, 153, 203, 0.7); box-sizing: border-box; height: 100vh;}canvas{top: 0; z-index: 1000;}.hidden{display: none;}.main-wrap{width: 100%; height: 100%; -ms-box-orient: horizontal; display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -moz-flex; display: -webkit-flex; display: flex; -webkit-justify-content: center; justify-content: center; -webkit-align-items: center; align-items: center;}.inner-wrap{position: relative; border-radius: 8px; overflow: hidden;}.fixed-container{position: fixed; top: 275px; right: 0; width: 40px; z-index: 1001;}.fixed-container .toolbar-wrap{position: absolute; top: 0; left: 0;}.fixed-container .toolbar-wrap input{display: block; top: 0 !important; transform: none !important;}.fixed-container .toolbar-wrap .OT_color{width: 30px; margin-right: 5px !important; margin-left: 5px !important; padding: 0;}.fixed-container .toolbar-wrap .OT_subpanel, .fixed-container .toolbar-wrap .color-picker{position: absolute; top: 0; right: 40px; padding-left: 0 !important; overflow: hidden;}.fixed-container .toolbar-wrap .OT_subpanel> div{top: 0 !important; transform: none !important;}.fixed-container .toolbar-wrap .color-picker{left: -30px;}.fixed-container .toolbar-wrap .color-picker .color-choice{display: block !important; height: 20px !important; width: 20px !important;}.publisherContainer{display: block; background-color: #000000; position: absolute;}.publisher-wrap{height: 100%; width: 100%;}.subscriberContainer{position: absolute; top: 20px; left: 20px; width: 200px; height: 120px; background-color: #000000; border: 2px solid white; border-radius: 6px;}.subscriberContainer .OT_video-poster{width: 100%; height: 100%; opacity: .25; background-repeat: no-repeat; background-image: url(https://static.opentok.com/webrtc/v2.8.2/images/rtc/audioonly-silhouette.svg); background-size: 50%; background-position: center;}.OT_video-element{height: 100%; width: 100%;}.OT_edge-bar-item{display: none;}</style></head><body> <div class="main-wrap"> <div id="annotationContainer" class="inner-wrap"></div></div><div id="toolbarContainer" class="fixed-container"> <div id="toolbar" class="toolbar-wrap"></div></div><div id="subscriberVideo" class="subscriberContainer hidden"></div><script type="text/javascript" charset="utf-8"> /** Must use double-quotes since everything must be converted to a string */ var opener; var canvas; if (!toolbar){alert("Something went wrong: You must pass an OpenTok annotation toolbar object into the window.")}else{opener=window.opener; window.onbeforeunload=window.triggerCloseEvent;}var localScreenProperties={insertMode: "append", width: "100%", height: "100%", videoSource: "window", showControls: false, style:{buttonDisplayMode: "off"}, fitMode: "contain"}; var createContainerElements=function(){var parentDiv=document.getElementById("annotationContainer"); var publisherContainer=document.createElement("div"); publisherContainer.setAttribute("id", "screenshare_publisher"); publisherContainer.classList.add("publisher-wrap"); parentDiv.appendChild(publisherContainer); return{annotation: parentDiv, publisher: publisherContainer};}; var addSubscriberVideo=function(stream){var container=document.getElementById("subscriberVideo"); session.subscribe(stream, container, localScreenProperties, function(error){if (error){console.log("Failed to add subscriber video", error);}container.classList.remove("hidden");});}; if (navigator.userAgent.indexOf("Firefox") !==-1){var ghost=window.open("about:blank"); ghost.focus(); ghost.close();}</script></body></html>',r=["toolbar=no","location=no","directories=no","status=no","menubar=no","scrollbars=no","resizable=no","copyhistory=no",["width=",n].join(""),["height=",o].join(""),["left=",screen.width/2-n/2].join(""),["top=",screen.height/2-o/2].join("")].join(","),s=window.open("about:blank","",r);s.document.write(i),window.onbeforeunload=function(){s.close()},s.toolbar=toolbar,s.OT=OT,s.session=a,s.$=e,s.triggerCloseEvent=function(){u("annotationWindowClosed")},s.onbeforeunload=function(){u("annotationWindowClosed")};var c=function(){s.createContainerElements?e(s.document).ready(function(){t.resolve(s)}):setTimeout(c,100)};return c(),t.promise()},x=function(){e(c.resizeSubject).off("resize",b),toolbar.remove(),c.externalWindow||e("#annotationToolbarContainer").remove()},T=function(n,o){var i=e.Deferred();return t.property("screensharing")(o)?I().then(function(t){w(n,o,t),toolbar.createPanel(t),u("startAnnotation",t),h(l.actionStart,l.variationSuccess),i.resolve(t)}):(w(n,o),u("startAnnotation"),h(l.actionStart,l.variationSuccess),i.resolve()),i.promise()},k=function(n,o,i){c.resizeSubject=t.property("externalWindow")(i)||window,c.externalWindow=t.property("externalWindow")(i)||null,c.absoluteParent=t.property("absoluteParent")(i)||null,c.canvasContainer=o,r=new OTSolution.Annotations({feed:n,container:o,externalWindow:c.externalWindow
}),toolbar.addCanvas(r),r.onScreenCapture(function(t){var e=window.open(t,"_blank");e.focus()});var a=c.externalWindow?c.externalWindow:window;c.canvas=e(t.first(a.document.getElementsByTagName("canvas"))),y(),b(),u("linkAnnotation")},W=function(){b()},C=function(t){c.externalWindow?c.externalWindow.addSubscriberVideo(t):console.log("OT Annotation: External window does not exist. Cannot add subscriber video.")},M=function(){x(),c.canvas=null,c.externalWindow&&(c.externalWindow.close(),c.externalWindow=null,c.resizeSubject=null),u("endAnnotation"),h(l.actionEnd,l.variationSuccess)},P=function(e){if(o=this,o.options=t.omit(e,"accPack","session"),i=t.property("accPack")(e),a=t.property("session")(e),!a)throw new Error("OpenTok Annotation Accelerator Pack requires an OpenTok session");p(),d(),h(l.actionInitialize,l.variationSuccess),f()};P.prototype={constructor:P,start:T,linkCanvas:k,resizeCanvas:W,addSubscriberToExternalWindow:C,end:M},"object"==typeof exports?module.exports=P:"function"==typeof define&&define.amd?define(function(){return P}):this.AnnotationAccPack=P}.call(this);
{
"name": "opentok-annotation",
"version": "1.0.41",
"version": "1.0.42",
"description": "OpenTok annotation accelerator pack",

@@ -5,0 +5,0 @@ "main": "dist/opentok-annotation.js",

@@ -89,11 +89,13 @@ /* global OT OTSolution OTKAnalytics ScreenSharingAccPack define */

var _registerEvents = function () {
var events = [
'startAnnotation',
'linkAnnotation',
'resizeCanvas',
'annotationWindowClosed',
'endAnnotation'
];
if (_accPack) {
var events = [
'startAnnotation',
'linkAnnotation',
'resizeCanvas',
'annotationWindowClosed',
'endAnnotation'
];
_accPack.registerEvents(events);
_accPack.registerEvents(events);
}
};

@@ -100,0 +102,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc