<commit_before>/*!
 *  opentok-whiteboard (http://github.com/aullman/opentok-whiteboard)
 *  
 *  Shared Whiteboard that works with OpenTok
 *
 *  @Author: <NAME> (http://github.com/aullman)
 *  @Copyright (c) 2014 <NAME>
 *  @License: Released under the MIT license (http://opensource.org/licenses/MIT)
**/
var OpenTokWhiteboard=angular.module("opentok-whiteboard",["opentok"]).directive("otWhiteboard",["OTSession","$window",function(o,e){return{restrict:"E",template:'<canvas></canvas><div class="OT_panel"><input type="button" ng-class="{OT_color: true, OT_selected: c[\'background-color\'] === color}" ng-repeat="c in colors" ng-style="c" ng-click="changeColor(c)"></input><input type="button" ng-click="erase()" ng-class="{OT_erase: true, OT_selected: erasing}" value="Eraser"></input><input type="button" ng-click="capture()" class="OT_capture" value="{{captureText}}"></input><input type="button" ng-click="undo()" class="OT_capture" value="Undo"></input><input type="button" ng-click="redo()" class="OT_capture" value="Redo"></input><input type="button" ng-click="clear()" class="OT_clear" value="Clear"></input>',link:function(t,n,a){var i,r=n.context.querySelector("canvas"),c=(n.context.querySelector("select"),n.context.querySelector("input"),{dragging:!1}),s=0,u=0,p=[],d=[],l=[],h=[],g=/(iPad|iPhone|iPod)/g.test(navigator.userAgent);e.paper.setup(r),t.colors=[{"background-color":"black"},{"background-color":"blue"},{"background-color":"red"},{"background-color":"green"},{"background-color":"orange"},{"background-color":"purple"},{"background-color":"brown"}],t.captureText=g?"Email":"Capture",t.strokeCap="round",t.strokeJoin="round",r.width=a.width||n.width(),r.height=a.height||n.height();var f=function(){e.paper.project.clear(),e.paper.view.update()};t.changeColor=function(o){t.color=o["background-color"],t.lineWidth=2,t.erasing=!1},t.changeColor(t.colors[Math.floor(Math.random()*t.colors.length)]),t.clear=function(){f(),o.session&&o.session.signal({type:"otWhiteboard_clear"})},t.erase=function(){t.lineWidth=50,t.erasing=!0},t.capture=function(){g?window.location.href="mailto:?subject=Whiteboard&Body=<img src='"+r.toDataURL("image/png")+"'>":window.open(r.toDataURL("image/png"))},t.undo=function(){if(p.length){var o=p.pop();m(o),d.push(o),W("otWhiteboard_undo",o)}};var m=function(o){o.visible=!1,e.paper.view.update()};t.redo=function(){if(d.length){var o=d.pop();b(o),p.push(o),W("otWhiteboard_redo",o)}};var v,b=function(o){o.visible=!0,e.paper.view.update()},w=function(o,n){console.log(o,n),void 0!==typeof n&&(window.path=new e.paper.Path,path.strokeColor=o.color,path.strokeWidth=t.lineWidth,path.strokeCap=t.strokeCap,path.strokeJoin=t.strokeJoin,mode=t.erasing?"pen":"eraser","pen"==mode&&(path.blendMode="destination-out"),s=new e.paper.Point(o.fromX,o.fromY),path.moveTo(s)),window.path.add(o.toX,o.toY),l.push(o),void 0!==typeof n&&(window.path.smooth(),c.dragging=!1,u&&(s=l.length,p.push(window.path),u=0))},k=function(o){o.forEach(function(o){w(o,!0),l.push(o)})},y=function(e,t,n){for(var a=t.slice(),i=function(o){o&&TB.error(o)};a.length;){var r=a.splice(0,Math.min(a.length,32)),c={type:e,data:JSON.stringify(r)};n&&(c.to=n),o.session.signal(c,i)}},W=function(e,t){o.session&&(h.push(t),v||(v=setTimeout(function(){y(e,h),h=[],v=null},100)))};angular.element(document).on("keyup",function(o){o.ctrlKey&&(90===o.keyCode&&t.undo(),89===o.keyCode&&t.redo())}),angular.element(r).on("mousedown mousemove mouseup mouseout touchstart touchmove touchend touchcancel",function(a){if("mousemove"!==a.type&&"touchmove"!==a.type&&"mouseout"!==a.type||c.dragging){a.preventDefault();var i,s=angular.element(r).offset(),h=r.width/n.width(),g=r.height/n.height(),f=a.offsetX||a.originalEvent.pageX-s.left||a.originalEvent.touches[0].pageX-s.left,m=a.offsetY||a.originalEvent.pageY-s.top||a.originalEvent.touches[0].pageY-s.top,v=f*h,b=m*g,k=t.erasing?"pen":"eraser";switch(a.type){case"mousedown":case"touchstart":c.dragging=!0,c.lastX=v,c.lastY=b,window.path&&(window.path.selected=!1),window.path=new e.paper.Path,path.strokeColor=t.color,path.strokeWidth=t.lineWidth,path.strokeCap=t.strokeCap,path.strokeJoin=t.strokeJoin,"pen"==k&&(path.blendMode="destination-out"),i=new e.paper.Point(v,b),path.moveTo(i);break;case"mousemove":case"touchmove":if(f=a.offsetX||a.originalEvent.pageX-s.left||a.originalEvent.touches[0].pageX-s.left,m=a.offsetY||a.originalEvent.pageY-s.top||a.originalEvent.touches[0].pageY-s.top,v=f*h,b=m*g,c.dragging){var y={id:o.session&&o.session.connection&&o.session.connection.connectionId,fromX:c.lastX,fromY:c.lastY,toX:v,toY:b,mode:k,color:t.color,lineWidth:t.lineWidth,show:1};u++,d=[],w(y),l.push(y),c.lastX=v,c.lastY=b,W("otWhiteboard_update",y)}break;case"touchcancel":case"mouseup":case"touchend":case"mouseout":window.path.smooth(),c.dragging=!1,u&&(i=l.length,p.push(window.path),u=0)}}}),o.session&&o.session.on({"signal:otWhiteboard_update":function(e){e.from.connectionId!==o.session.connection.connectionId&&(k(JSON.parse(e.data)),t.$emit("otWhiteboardUpdate"))},"signal:otWhiteboard_undo":function(e){e.from.connectionId!==o.session.connection.connectionId&&(JSON.parse(e.data).forEach(function(o){m(o)}),t.$emit("otWhiteboardUpdate"))},"signal:otWhiteboard_redo":function(e){e.from.connectionId!==o.session.connection.connectionId&&(JSON.parse(e.data).forEach(function(o){b(o)}),t.$emit("otWhiteboardUpdate"))},"signal:otWhiteboard_history":function(o){i&&i!==o.from.connectionId||(i=o.from.connectionId,k(JSON.parse(o.data)),t.$emit("otWhiteboardUpdate"))},"signal:otWhiteboard_clear":function(e){e.from.connectionId!==o.session.connection.connectionId&&f()},connectionCreated:function(e){l.length>0&&e.connection.connectionId!==o.session.connection.connectionId&&y("otWhiteboard_history",l,e.connection)}})}}}]);<commit_msg>Generate minified<commit_after>/*!
 *  opentok-whiteboard (http://github.com/aullman/opentok-whiteboard)
 *  
 *  Shared Whiteboard that works with OpenTok
 *
 *  @Author: <NAME> (http://github.com/aullman)
 *  @Copyright (c) 2014 <NAME>
 *  @License: Released under the MIT license (http://opensource.org/licenses/MIT)
**/
var OpenTokWhiteboard=angular.module("opentok-whiteboard",["opentok"]).directive("otWhiteboard",["OTSession","$window","$timeout",function(o,e,t){return{restrict:"E",template:'<canvas></canvas><div class="OT_panel"><input type="button" ng-class="{OT_color: true, OT_selected: c[\'background-color\'] === color}" ng-repeat="c in colors" ng-style="c" ng-click="changeColor(c)"></input><input type="button" ng-click="erase()" ng-class="{OT_erase: true, OT_selected: erasing}" value="Eraser"></input><input type="button" ng-click="capture()" class="OT_capture" value="{{captureText}}"></input><input type="button" ng-click="undo()" class="OT_capture" value="Undo"></input><input type="button" ng-click="redo()" class="OT_capture" value="Redo"></input><input type="button" ng-click="clear()" class="OT_clear" value="Clear"></input>',link:function(n,a,i){var c,r=a.context.querySelector("canvas"),s=(a.context.querySelector("select"),a.context.querySelector("input"),{dragging:!1}),u=0,p=0,l=[],d=[],h=[],g=[],f=/(iPad|iPhone|iPod)/g.test(navigator.userAgent);e.paper.setup(r),n.colors=[{"background-color":"black"},{"background-color":"blue"},{"background-color":"red"},{"background-color":"green"},{"background-color":"orange"},{"background-color":"purple"},{"background-color":"brown"}],n.captureText=f?"Email":"Capture",n.strokeCap="round",n.strokeJoin="round",n.lineWidth=2,r.width=i.width||a.width(),r.height=i.height||a.height();var m=function(){e.paper.project.clear(),e.paper.view.update(),h=[],l=[],d=[],u=0,p=0};n.changeColor=function(o){n.color=o["background-color"],n.erasing=!1},n.changeColor(n.colors[Math.floor(Math.random()*n.colors.length)]),n.clear=function(){m(),o.session&&o.session.signal({type:"otWhiteboard_clear"})},n.erase=function(){n.erasing=!0},n.capture=function(){f?e.location.href="mailto:?subject=Whiteboard&Body=<img src='"+r.toDataURL("image/png")+"'>":e.open(r.toDataURL("image/png"))},n.undo=function(){if(l.length){var o=l[l.length-1];v(o),_("otWhiteboard_undo",o)}};var v=function(o){o=l.pop(),d.push(o),o.visible=!1,e.paper.view.update()};n.redo=function(){if(d.length){var o=d[d.length-1];k(o),_("otWhiteboard_redo",o)}};var b,k=function(o){o=d.pop(),l.push(o),o.visible=!0,e.paper.view.update()},W=function(o,a){o.end&&n.path?(u=h.length,h.push(n.path),l.push(n.path),p=0,n.path.smooth({type:"continuous"}),s.dragging=!1,t(function(){n.path=null},50)):(a&&!n.path&&(n.path=new e.paper.Path,n.path.strokeColor=o.color,n.path.strokeWidth=o.lineWidth,n.path.strokeCap=n.strokeCap,n.path.strokeJoin=n.strokeJoin,"eraser"===o.mode&&(n.path.blendMode="destination-out"),u=new e.paper.Point(o.fromX,o.fromY),n.path.moveTo(u)),n.path.add(o.toX,o.toY))},y=function(o){o.forEach(function(o){W(o,!0)})},w=function(e,t,n){for(var a=t.slice(),i=function(o){o&&TB.error(o)};a.length;){var c=a.splice(0,Math.min(a.length,32)),r={type:e,data:JSON.stringify(c)};n&&(r.to=n),o.session.signal(r,i)}},_=function(e,t){o.session&&(g.push(t),b||(b=setTimeout(function(){w(e,g),g=[],b=null},100)))};angular.element(document).on("keyup",function(o){o.ctrlKey&&(90===o.keyCode&&n.undo(),89===o.keyCode&&n.redo())}),angular.element(r).on("mousedown mousemove mouseup mouseout touchstart touchmove touchend touchcancel",function(t){if("mousemove"!==t.type&&"touchmove"!==t.type&&"mouseout"!==t.type||s.dragging){t.preventDefault();var i,c=angular.element(r).offset(),u=r.width/a.width(),l=r.height/a.height(),h=t.offsetX||t.originalEvent.pageX-c.left||t.originalEvent.touches[0].pageX-c.left,g=t.offsetY||t.originalEvent.pageY-c.top||t.originalEvent.touches[0].pageY-c.top,f=h*u,m=g*l,v=n.erasing?"eraser":"pen";switch(t.type){case"mousedown":case"touchstart":s.dragging=!0,s.lastX=f,s.lastY=m,n.path&&(n.path.selected=!1),n.path=new e.paper.Path,n.path.strokeColor=n.color,n.path.strokeWidth=n.lineWidth,n.path.strokeCap=n.strokeCap,n.path.strokeJoin=n.strokeJoin,"eraser"===v&&(n.path.strokeWidth=50,n.path.blendMode="destination-out"),i=new e.paper.Point(f,m),n.path.moveTo(i);break;case"mousemove":case"touchmove":if(h=t.offsetX||t.originalEvent.pageX-c.left||t.originalEvent.touches[0].pageX-c.left,g=t.offsetY||t.originalEvent.pageY-c.top||t.originalEvent.touches[0].pageY-c.top,f=h*u,m=g*l,s.dragging){var b={id:o.session&&o.session.connection&&o.session.connection.connectionId,fromX:s.lastX,fromY:s.lastY,toX:f,toY:m,mode:v,color:n.color,lineWidth:"pen"===v?n.lineWidth:50,show:1};p++,d=[],W(b),s.lastX=f,s.lastY=m,_("otWhiteboard_update",b)}break;case"touchcancel":case"mouseup":case"touchend":case"mouseout":if(p){var b={id:o.session&&o.session.connection&&o.session.connection.connectionId,end:!0};W(b),_("otWhiteboard_update",b)}}}}),o.session&&o.session.on({"signal:otWhiteboard_update":function(e){e.from.connectionId!==o.session.connection.connectionId&&(y(JSON.parse(e.data)),n.$emit("otWhiteboardUpdate"))},"signal:otWhiteboard_undo":function(e){e.from.connectionId!==o.session.connection.connectionId&&(JSON.parse(e.data).forEach(function(o){v(o[1])}),n.$emit("otWhiteboardUpdate"))},"signal:otWhiteboard_redo":function(e){e.from.connectionId!==o.session.connection.connectionId&&(JSON.parse(e.data).forEach(function(o){k(o[1])}),n.$emit("otWhiteboardUpdate"))},"signal:otWhiteboard_history":function(o){c&&c!==o.from.connectionId||(c=o.from.connectionId,y(JSON.parse(o.data)),n.$emit("otWhiteboardUpdate"))},"signal:otWhiteboard_clear":function(e){e.from.connectionId!==o.session.connection.connectionId&&m()},connectionCreated:function(e){h.length>0&&e.connection.connectionId!==o.session.connection.connectionId&&w("otWhiteboard_history",h,e.connection)}})}}}]);
{'fraction_non_alphanumeric': 0.25904128283862166, 'fraction_numerical': 0.007250085295121119, 'mean_word_length': 12.508064516129032, 'pattern_counts': {'":': 47, '<': 39, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '325800', 'n_tokens_mistral': 4592, 'n_tokens_neox': 4549, 'n_words': 169}