<commit_before>/*!
mPainter v0.1.0 
Author: <NAME> 
Date: 2013-08-16 
License: MIT 
*/
!function(a,b){"use strict";function c(a){var b=l().push(a);b>2&&0===b%2&&h(z.config)}function d(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)b.hasOwnProperty(d)&&c.setAttribute(d,b[d]);return c}function e(a){return z.canvasStack.elements[a]={config:{element_index:a,tool:z.config.tool,painter_radius:z.config.painter_radius,opacity:z.config.opacity,color:z.config.color},points:[],is_delelted:!1},z.canvasStack.elements[a]}function f(){z.is_mousedown=!1;var a=z.config.element_index,b=t(x.options.element_prefix+a);b&&b.setAttribute("opacity",z.config.opacity);for(var c in z.redo)if(z.redo.hasOwnProperty(c)){var d=(z.redo[c],"d"===z.redo[c].value?"a":"d");z.undo.push({id:z.redo[c].id,value:d}),z.undo.push({id:z.redo[c].id,value:z.redo[c].value})}z.undo.push({id:a,value:"d"}),z.redo=[],z.canvasStack.head=z.config.element_index++}function g(a){z.EVENTS[a.type]&&"function"==typeof z.EVENTS[a.type]&&z.EVENTS[a.type].call(x,a)}function h(a){switch(a.tool){case z.TOOLS.PAINT:i(a);break;case z.TOOLS.LINE:k(a)}}function i(a){var b=x.options.element_prefix+a.element_index,c=t(b);c?c.setAttribute("d",j(a.element_index)):(c=d("path",{id:b,d:j(a.element_index),fill:"none",stroke:a.color,"stroke-linecap":"round","stroke-width":2*a.painter_radius,opacity:a.opacity/2}),z.el.appendChild(c))}function j(a){var b=l(a),c=b.length,d=0===c%2?c-1:c-2,e="M"+b[0].x+","+b[0].y+" Q";b.length;for(var f=1;d>f;f++)e+=b[f].x+","+b[f].y+" ";return e+="T"+b[d].x+","+b[d].y}function k(a){var b=x.options.element_prefix+a.element_index,c=t(b);if(c){var e=m(a.element_index);c.setAttribute("x2",e.x),c.setAttribute("y2",e.y)}else{var f=m(a.element_index,0),g=m(a.element_index);c=d("line",{id:b,x1:f.x,y1:f.y,x2:g.x,y2:g.y,"stroke-linecap":"round","stroke-width":2*a.painter_radius,stroke:a.color,opacity:a.opacity/2}),z.el.appendChild(c)}}function l(a){var c=a===b?z.config.element_index:a;return z.canvasStack.elements[c]===b?c===z.config.element_index?e(c).points:b:z.canvasStack.elements[c].points}function m(a,c){var d=l(a);return c===b?d[d.length-1]:d[c]}function n(a){switch(z.config.tool){case z.TOOLS.PAINT:o(a);break;case z.TOOLS.LINE:p(a)}}function o(a){var b=d("circle",{id:x.options.cursor_id,cx:a.offsetX,cy:a.offsetY,r:z.config.painter_radius,stroke:z.config.color,fill:z.config.color});z.el.appendChild(b)}function p(){var a="";z.el.getAttribute("style")&&(a=z.el.getAttribute("class")),z.el.setAttribute("style",a+"cursor:crosshair;")}function q(a){var b=t(x.options.cursor_id);b&&(b.setAttribute("cx",a.offsetX),b.setAttribute("cy",a.offsetY))}function r(){var a=t(x.options.cursor_id),b=z.el.getAttribute("style");a&&a.parentNode.removeChild(a),b&&z.el.setAttribute("style",b.replace(/cursor:crosshair;/,""))}function s(a){return{x:a.offsetX,y:a.offsetY}}function t(a){return document.getElementById(a)}function u(){for(var a={},b=0,c=arguments.length;c>b;b++)for(var d in arguments[b])arguments[b].hasOwnProperty(d)&&(a[d]=arguments[b][d]);return a}function v(a,b){for(var c=a.relatedTarget||a.toElement||a.fromElement;c&&c!==b;)c=c.parentNode;return c!==b?!0:!1}function w(a){x.options.debug===!0&&console.log(a)}var x,y=a.mPainter||{},z={};y=function(a){x=this,this._init(a)},y.prototype={_init:function(a){var b={debug:!1,id:"mysvg",cursor_id:"cursor",element_prefix:"element_",tool:"PAINT"};this.options=u({},b,a),z={el:t(this.options.id),undo:[],redo:[],is_mousedown:!1,canvasStack:{head:-1,elements:[]},config:{element_index:0,tool:this.options.tool,painter_radius:3,opacity:1,color:"#FF0000"},EVENTS:{mousedown:this._mouseDown,mousemove:this._mouseMove,mouseup:this._mouseUp,mouseover:this._mouseOver,mouseout:this._mouseOut},TOOLS:{PAINT:"PAINT",LINE:"LINE"}},this._initEvents()},_initEvents:function(){z.el.addEventListener("mousedown",g,!1),z.el.addEventListener("mousemove",g,!1),z.el.addEventListener("mouseup",g,!1),z.el.addEventListener("mouseover",g,!1),z.el.addEventListener("mouseout",g,!1)},_mouseDown:function(a){w("Mouse down: "+a.offsetX+","+a.offsetY),a.preventDefault(),c(s(a)),z.is_mousedown=!0},_mouseMove:function(a){z.is_mousedown===!0&&(w("Mouse move to: "+a.offsetX+","+a.offsetY),c(s(a))),q(a)},_mouseUp:function(a){z.is_mousedown===!0&&(w("Mouse up: "+a.offsetX+","+a.offsetY),c(s(a)),f())},_mouseOver:function(a){v(a,z.el)&&(w("Mouse enter",a),n(a))},_mouseOut:function(a){var b=a.toElement?a.toElement:a.relatedTarget;(null===b||"svg"!==b.nodeName&&"svg"!==b.parentNode.nodeName&&b.id!==this.options.cursor_id)&&(z.is_mousedown===!0&&(w("Mouse out: "+a.offsetX+","+a.offsetY),f()),r())},setColor:function(a){z.config.color=a},setPainterSize:function(a){z.config.painter_radius=a},setOpacity:function(a){z.config.opacity=a},setTool:function(a){if(!z.TOOLS[a])throw"TOOL: "+a+" is not available.";z.config.tool=z.TOOLS[a]},undo:function(){if(z.undo.length){var a=z.undo.pop(),b=a.id,c=a.value,d="d"===c?"a":"d";if(z.redo.push({id:b,value:d}),"d"===c){var e=t(this.options.element_prefix+b);z.canvasStack.elements[b].is_delelted=!0,e&&e.parentNode.removeChild(e)}else{var f=z.canvasStack.elements[b].config;f.opacity=2*f.opacity,h(f)}}},redo:function(){if(z.redo.length){var a=z.redo.pop(),b=a.id,c=a.value,d="d"===c?"a":"d";if(z.undo.push({id:b,value:d}),"d"===c){var e=t(this.options.element_prefix+b);z.canvasStack.elements[b].is_delelted=!0,e&&e.parentNode.removeChild(e)}else{var f=z.canvasStack.elements[b].config;f.opacity=2*f.opacity,h(f)}}},getInternal:function(){return z},reset:function(){for(z.config.element_index=0,z.canvasStack={head:-1,elements:[]},z.is_mousedown=!1;z.el.lastChild;)z.el.removeChild(z.el.lastChild)}},a.mPainter=y}(window);<commit_msg>[UPDATE] update mPainter.min.js<commit_after>/*!
mPainter v0.1.2 
Author: <NAME> 
Date: 2013-09-28 
License: MIT 
*/
!function(a,b){"use strict";function c(){D(G.options.startTrigger,function(a){E(I.el,a,d)}),D(G.options.moveTrigger,function(a){E(I.el,a,e)}),D(G.options.stopTrigger,function(a){E(I.el,a,f)}),E(I.el,"mouseover",g),E(I.el,"mouseout",h)}function d(a){B("Mouse down: "+a.offsetX+","+a.offsetY),a.preventDefault(),i(y(a)),I.is_mousedown=!0}function e(a){I.is_mousedown===!0&&(B("Mouse move to: "+a.offsetX+","+a.offsetY),i(y(a))),w(a)}function f(a){I.is_mousedown===!0&&(B("Mouse up: "+a.offsetX+","+a.offsetY),i(y(a)),l())}function g(a){z(a,I.el)&&(B("Mouse enter",a),t(a))}function h(a){var b=a.toElement?a.toElement:a.relatedTarget;(null===b||"svg"!==b.nodeName&&"svg"!==b.parentNode.nodeName&&b.id!==G.options.cursor_id)&&(I.is_mousedown===!0&&(B("Mouse out: "+a.offsetX+","+a.offsetY),l()),x())}function i(a){r(I.config.element_index).push(a),n(I.config)}function j(a){return I.canvasStack.elements[a]={config:{element_index:a,tool:I.config.tool,painter_radius:I.config.painter_radius,opacity:I.config.opacity,color:I.config.color},points:[],is_delelted:!1},I.canvasStack.elements[a]}function k(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)b.hasOwnProperty(d)&&c.setAttribute(d,b[d]);return c}function l(){I.is_mousedown=!1;var a=I.config.element_index,b=F(G.options.element_prefix+a);b&&b.setAttribute("opacity",I.config.opacity);for(var c=I.redo.length-1;c>=0;c--)I.undo.push({id:I.redo[c].id,value:A(I.redo[c].value)});for(var d=0,e=I.redo.length;e>d;d++)I.undo.push({id:I.redo[d].id,value:I.redo[d].value});I.undo.push({id:a,value:"d"}),I.redo=[],I.canvasStack.head=I.config.element_index++}function m(a){var b=F(G.options.element_prefix+a);b&&b.parentNode.removeChild(b)}function n(a){switch(a.tool){case I.TOOLS.PAINT:o(a);break;case I.TOOLS.LINE:q(a)}}function o(a){var b=G.options.element_prefix+a.element_index,c=F(b);c?c.setAttribute("d",p(a.element_index)):(c=k("path",{id:b,d:p(a.element_index),fill:"none",stroke:a.color,"stroke-linecap":"round","stroke-width":2*a.painter_radius,opacity:a.opacity/2}),I.el.appendChild(c))}function p(a){var b=r(a),c=b.length,d=0===c%2?c-1:c-2,e="M"+b[0].x+","+b[0].y;if(1===c)return e;if(2===c||3===c)return e+"T"+b[c-1].x+","+b[c-1].y;e+="Q";for(var f=1;d>f;f++)e+=b[f].x+","+b[f].y+" ";return e+="T"+b[d].x+","+b[d].y}function q(a){var b=G.options.element_prefix+a.element_index,c=F(b);if(c){var d=s(a.element_index);c.setAttribute("x2",d.x),c.setAttribute("y2",d.y)}else{var e=s(a.element_index,0),f=s(a.element_index);c=k("line",{id:b,x1:e.x,y1:e.y,x2:f.x,y2:f.y,"stroke-linecap":"round","stroke-width":2*a.painter_radius,stroke:a.color,opacity:a.opacity/2}),I.el.appendChild(c)}}function r(a){return I.canvasStack.elements[a]===b?j(a).points:I.canvasStack.elements[a].points}function s(a,c){var d=r(a);return c===b?d[d.length-1]:d[c]}function t(a){switch(I.config.tool){case I.TOOLS.PAINT:u(a);break;case I.TOOLS.LINE:v(a)}}function u(a){var b=k("circle",{id:G.options.cursor_id,cx:a.offsetX,cy:a.offsetY,r:I.config.painter_radius,stroke:I.config.color,fill:I.config.color});I.el.appendChild(b)}function v(){var a="";I.el.getAttribute("style")&&(a=I.el.getAttribute("style")),I.el.setAttribute("style",a+"cursor:crosshair;")}function w(a){var b=F(G.options.cursor_id);b&&(b.setAttribute("cx",a.offsetX),b.setAttribute("cy",a.offsetY))}function x(){var a=F(G.options.cursor_id),b=I.el.getAttribute("style");a&&a.parentNode.removeChild(a),b&&I.el.setAttribute("style",b.replace(/cursor:crosshair;/,""))}function y(a){return{x:a.offsetX,y:a.offsetY}}function z(a,b){for(var c=a.relatedTarget||a.toElement||a.fromElement;c&&c!==b;)c=c.parentNode;return c!==b?!0:!1}function A(a){return"d"===a?"a":"a"===a?"d":"redo"===a?"undo":"undo"===a?"redo":a}function B(a){G.options.debug===!0&&console.log(a)}function C(){for(var a={},b=0,c=arguments.length;c>b;b++)for(var d in arguments[b])arguments[b].hasOwnProperty(d)&&(a[d]=arguments[b][d]);return a}function D(a,b,c){for(var d=0,e=a.length;e>d;d++)b.call(c||null,a[d],d,a)}function E(b,c,d){if(a.addEventListener)b.addEventListener(c,d,!1);else{if(!a.attachEvent)throw"Event type: "+c+" is not supported";b.attachEvent("on"+c,d)}}function F(a){return document.getElementById(a)}var G,H=a.mPainter||{},I={};H=function(a){var b={debug:!1,id:"mysvg",cursor_id:"cursor",element_prefix:"element_",tool:"PAINT",startTrigger:["mousedown","touchstart","MSPointerDown"],moveTrigger:["mousemove","touchmove","MSPointerMove"],stopTrigger:["mouseup","touchend","touchcancel","MSPointerUp"]};this.options=C(b,a),G=this,I={el:F(this.options.id),undo:[],redo:[],is_mousedown:!1,canvasStack:{head:-1,elements:[]},config:{element_index:0,tool:this.options.tool,painter_radius:3,opacity:1,color:"#FF0000"},TOOLS:{PAINT:"PAINT",LINE:"LINE"}},c()},H.prototype={setColor:function(a){I.config.color=a},setSize:function(a){I.config.painter_radius=a},setOpacity:function(a){I.config.opacity=a},setTool:function(a){if(!I.TOOLS[a])throw"TOOL: "+a+" is not available.";I.config.tool=I.TOOLS[a]},undo:function(){this.exec("undo")},redo:function(){this.exec("redo")},saveImage:function(){var b=F("mycanvas"),c=b.getContext("2d"),d=(new XMLSerializer).serializeToString(I.el),e=a.URL||a.webkitURL||a,f=document.createElement("img"),g=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),h=e.createObjectURL(g);f.onload=function(){c.drawImage(f,0,0,b.width,b.height);var a=b.toDataURL("image/png");console.log(a)},f.crossOrigin="anonymous",f.src=h},exec:function(a){if(I[a].length){var b=I[a].pop(),c=b.id,d=b.value;switch(I[A(a)].push({id:c,value:A(d)}),d){case"a":I.canvasStack.elements[c].is_delelted=!1;var e=I.canvasStack.elements[c].config;e.opacity*=2,n(e);break;case"d":I.canvasStack.elements[c].is_delelted=!0,m(c)}}},getInternal:function(){return I},reset:function(){for(I.undo=[],I.redo=[],I.config.element_index=0,I.canvasStack={head:-1,elements:[]},I.is_mousedown=!1;I.el.lastChild;)I.el.removeChild(I.el.lastChild)}},a.mPainter=H}(window);
{'fraction_non_alphanumeric': 0.27735865050436553, 'fraction_numerical': 0.012291260489955073, 'mean_word_length': 13.619578686493185, 'pattern_counts': {'":': 17, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 1}, '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': '5283950', 'n_tokens_mistral': 5150, 'n_tokens_neox': 5093, 'n_words': 209}