mirror of
https://github.com/TrentSPalmer/fcc-challenges.git
synced 2024-11-24 20:21:30 -08:00
2 lines
38 KiB
JavaScript
2 lines
38 KiB
JavaScript
(this["webpackJsonpcalculator-react"]=this["webpackJsonpcalculator-react"]||[]).push([[0],{24:function(t,n,e){t.exports=e(37)},33:function(t,n,e){},37:function(t,n,e){"use strict";e.r(n);var o=e(0),i=e.n(o),r=e(16),a=e.n(r),u=e(2),c=e(13),s=function(t){return{type:"SETINPUTSTRING",inputString:t}},l=function(t){return{type:"SETOPERATIONSTRING",operationString:t}},d=Object(c.b)({innerWindowWidth:function(t,n){switch(t||(t=window.innerWidth),n.type){case"SETWINDOWINNERWIDTH":return n.windowInnerWidth;default:return t}},innerWindowHeight:function(t,n){switch(t||(t=window.innerHeight),n.type){case"SETWINDOWINNERHEIGHT":return n.windowInnerHeight;default:return t}},inputString:function(t,n){switch(t||(t=""),n.type){case"SETINPUTSTRING":return n.inputString;default:return t}},operationString:function(t,n){switch(t||(t=""),n.type){case"SETOPERATIONSTRING":return n.operationString;default:return t}}}),h=Object(c.c)(d),p=(e(33),e(3)),g=e(4),b=e(1),f=e(6),v=e(5),k=e(7),C=e(8),S=e(12),m="#00293C",E="#1e656d",y="#6d261e",j="#656d1e",O="#261e6d",w="#f1f3ce",M="#f62a00",R=["*","/","-","+"],W=function(t,n,e){var o=t,i=n.includes("=")?n.split("=")[1]:n,r=i;i.length>0&&["*","/","+","-","="].includes(e)&&"."===i.slice(-1)&&(i=i.slice(0,-1));if(["1","2","3","4","5","6","7","8","9"].includes(e))0===t.length?(o=e,r=i+e):1===t.length?"0"===t[0]?(o=e,r=i.slice(0,-1)+e):"-"===t[0]?1===i.length?(o=t+e,r=t+e):(o=t+e,r=i+e):["*","/","+"].includes(t[0])?(o=e,r=i+e):(o=t+e,r=i+e):2===t.length?"-"===t[0]&&"0"===t[1]?(o="-"+e,r=i.slice(0,-1)+e):(o=t+e,r=i+e):t.length>2&&(o=t+e,r=i+e);else if("0"===e)0===t.length?(o=e,r=i+e):1===t.length?"0"!==t[0]&&(["*","/","+"].includes(t[0])?(o=e,r=i+e):(o=t+e,r=i+e)):2===t.length?("-"!==t[0]||"0"!==t[1])&&(o=t+e,r=i+e):t.length>2&&(o=t+e,r=i+e);else if("-"===e)0===i.length?(o=e,r=e):1===i.length&&R.includes(i[0])||(o=e,r=i+e);else if(["*","/","+"].includes(e))1===i.length?R.includes(i.slice(-1))||(r=i+e,o=e):i.length>1&&(o=e,r=i+e);else if("."!==e||t.includes("."))if("="===e&&i.length>0){var a=i.slice(-1);R.includes(a)||"."===a?(o=x(i.slice(0,-1)),r=i.slice(0,-1)+"="+o):r=i+"="+(o=x(i))}else"b"===e&&(1===i.length?(o=t.slice(0,-1),r=i.slice(0,-1)):i.length>1&&(R.includes(i.slice(-1))?R.includes(i.slice(-2,-1))?(o=i.slice(-2,-1),r=i.slice(0,-1)):o=(r=i.slice(0,-1)).split(/[-*/+]/).slice(-1)[0]:R.includes(i.slice(-2,-1))?(o=i.slice(-2,-1),r=i.slice(0,-1)):(o=t.slice(0,-1),r=i.slice(0,-1))));else 0===t.length?(o="0.",r=i+"0."):1===t.length?0===i.length?"-"===t[0]?(o="-0.",r=i+"-0."):(o=t+e,r=i+e):R.includes(t[0])?(o="0.",r=i+"0."):(o=t+e,r=i+e):(o=t+e,r=i+e);return[o,r]},x=function(t){var n=[];for(t.split("").forEach((function(t,e){if(0===e)n.push(t);else if(R.includes(t))n.push(t);else if("-"===n[n.length-1])if(1===e||R.includes(n[n.length-2])){var o=n[n.length-1];n[n.length-1]=o+t}else n.push(t);else if(["*","/","+"].includes(n[n.length-1]))n.push(t);else{var i=n[n.length-1];n[n.length-1]=i+t}}));R.includes(n[n.length-1]);)n.pop();var e=n.filter((function(t,e){return!R.includes(n[e+1])||!R.includes(t)}));return 1===e.length?e[0]:A(e.map((function(t){return R.includes(t)?t:t.includes(".")?parseFloat(t):parseInt(t)})))[0].toString()},A=function t(n){if(1===n.length)return n;if(n.includes("*")){var e=n.indexOf("*");return t([].concat(Object(S.a)(n.slice(0,e-1)),[n[e-1]*n[e+1]],Object(S.a)(n.slice(e+2))))}if(n.includes("/")){var o=n.indexOf("/");return t([].concat(Object(S.a)(n.slice(0,o-1)),[n[o-1]/n[o+1]],Object(S.a)(n.slice(o+2))))}if(n.includes("-")){var i=n.indexOf("-");return t([].concat(Object(S.a)(n.slice(0,i-1)),[n[i-1]-n[i+1]],Object(S.a)(n.slice(i+2))))}if(n.includes("+")){var r=n.indexOf("+");return t([].concat(Object(S.a)(n.slice(0,r-1)),[n[r-1]+n[r+1]],Object(S.a)(n.slice(r+2))))}},T=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"7"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:2,gridColumnEnd:3,gridRowStart:2,gridRowEnd:3,borderBottom:"3px solid black",borderRight:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=3,e.gridRowEnd=4,e.gridColumnStart=1,e.gridColumnEnd=2),i.a.createElement("div",{id:"seven",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"7")}}]),e}(i.a.Component),D=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(T),H=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"8"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:3,gridColumnEnd:4,gridRowStart:2,gridRowEnd:3,borderBottom:"3px solid black",borderRight:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=3,e.gridRowEnd=4,e.gridColumnStart=2,e.gridColumnEnd=3),i.a.createElement("div",{id:"eight",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"8")}}]),e}(i.a.Component),N=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(H),I=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"9"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:4,gridColumnEnd:5,gridRowStart:2,gridRowEnd:3,borderBottom:"3px solid black",borderRight:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=3,e.gridRowEnd=4,e.gridColumnStart=3,e.gridColumnEnd=4),i.a.createElement("div",{id:"nine",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"9")}}]),e}(i.a.Component),B=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(I),U=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"4"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:2,gridColumnEnd:3,gridRowStart:3,gridRowEnd:4,borderBottom:"3px solid black",borderRight:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=4,e.gridRowEnd=5,e.gridColumnStart=1,e.gridColumnEnd=2),i.a.createElement("div",{id:"four",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"4")}}]),e}(i.a.Component),z=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(U),K=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"5"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:3,gridColumnEnd:4,gridRowStart:3,gridRowEnd:4,borderBottom:"3px solid black",borderRight:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=4,e.gridRowEnd=5,e.gridColumnStart=2,e.gridColumnEnd=3),i.a.createElement("div",{id:"five",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"5")}}]),e}(i.a.Component),P=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(K),G=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"6"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:4,gridColumnEnd:5,gridRowStart:3,gridRowEnd:4,borderBottom:"3px solid black",borderRight:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=4,e.gridRowEnd=5,e.gridColumnStart=3,e.gridColumnEnd=4),i.a.createElement("div",{id:"six",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"6")}}]),e}(i.a.Component),L=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(G),F=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"1"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:2,gridColumnEnd:3,gridRowStart:4,gridRowEnd:5,borderRight:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=5,e.gridRowEnd=6,e.borderBottom="3px solid black",e.gridColumnStart=1,e.gridColumnEnd=2),i.a.createElement("div",{id:"one",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"1")}}]),e}(i.a.Component),_=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(F),J=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"2"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:3,gridColumnEnd:4,gridRowStart:4,gridRowEnd:5,borderRight:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=5,e.gridRowEnd=6,e.borderBottom="3px solid black",e.gridColumnStart=2,e.gridColumnEnd=3),i.a.createElement("div",{id:"two",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"2")}}]),e}(i.a.Component),q=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(J),$=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"3"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:4,gridColumnEnd:5,gridRowStart:4,gridRowEnd:5,borderRight:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=5,e.gridRowEnd=6,e.borderBottom="3px solid black",e.gridColumnStart=3,e.gridColumnEnd=4),i.a.createElement("div",{id:"three",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"3")}}]),e}(i.a.Component),Q=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))($),V=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"0"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:1,gridColumnEnd:2,gridRowStart:4,gridRowEnd:5,borderRight:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",borderRadius:"0 0 0 7px",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=6,e.gridRowEnd=7,e.gridColumnStart=1,e.gridColumnEnd=3),i.a.createElement("div",{id:"zero",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"0")}}]),e}(i.a.Component),X=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(V),Y=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:E},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"."),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:E})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:1,gridColumnEnd:2,gridRowStart:3,gridRowEnd:4,borderRight:"3px solid black",borderBottom:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=6,e.gridRowEnd=7,e.gridColumnStart=3,e.gridColumnEnd=4,e.borderBottom="unset"),i.a.createElement("div",{id:"decimal",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},".")}}]),e}(i.a.Component),Z=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(Y),tt=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:O},o}return Object(g.a)(e,[{key:"handleClick",value:function(){this.props.inputStringAction(""),this.props.operationStringAction("")}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:E}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:O})}},{key:"render",value:function(){var t={gridColumnStart:1,gridColumnEnd:2,gridRowStart:2,gridRowEnd:3,borderRight:"3px solid black",borderBottom:"3px solid black",display:"flex",flexDirection:"column",justifyContent:"center",backgroundColor:this.state.backgroundColor};return i.a.createElement("div",{id:"clear",style:t,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"AC")}}]),e}(i.a.Component),nt=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(tt),et=e(10),ot=e(11),it=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:j},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"/"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:j})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:5,gridColumnEnd:6,gridRowStart:2,gridRowEnd:3,borderBottom:"3px solid black",borderRight:"3px solid black",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridColumnStart=3,e.gridColumnEnd=4),i.a.createElement("div",{id:"divide",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},i.a.createElement(et.a,{icon:ot.b}))}}]),e}(i.a.Component),rt=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(it),at=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:j},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"*"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:j})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:6,gridColumnEnd:7,gridRowStart:2,gridRowEnd:3,borderBottom:"3px solid black",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridColumnStart=4,e.gridColumnEnd=5),i.a.createElement("div",{id:"multiply",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},i.a.createElement(et.a,{icon:ot.e}))}}]),e}(i.a.Component),ut=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(at),ct=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:j},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"-"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:j})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:5,gridColumnEnd:6,gridRowStart:3,gridRowEnd:4,borderBottom:"3px solid black",borderRight:"3px solid black",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridColumnStart=4,e.gridColumnEnd=5,e.borderRight="unset"),i.a.createElement("div",{id:"subtract",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},i.a.createElement(et.a,{icon:ot.c}))}}]),e}(i.a.Component),st=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(ct),lt=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:j},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"+"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:j})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:5,gridColumnEnd:6,gridRowStart:4,gridRowEnd:5,borderRight:"3px solid black",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridColumnStart=4,e.gridColumnEnd=5,e.borderRight="unset",e.borderBottom="3px solid black"),i.a.createElement("div",{id:"add",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},i.a.createElement(et.a,{icon:ot.d}))}}]),e}(i.a.Component),dt=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(lt),ht=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:y},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"="),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:y})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:6,gridColumnEnd:7,gridRowStart:4,gridRowEnd:5,display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",backgroundColor:this.state.backgroundColor,borderRadius:"0 0 7px 0",fontSize:88};return t>n&&n<400?e.fontSize=56:n>t&&(e.gridColumnStart=4,e.gridColumnEnd=5,e.gridRowStart=5,e.gridRowEnd=7),i.a.createElement("div",{id:"equals",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},"=")}}]),e}(i.a.Component),pt=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(ht),gt=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(){return Object(p.a)(this,e),n.apply(this,arguments)}return Object(g.a)(e,[{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={display:"flex",flexDirection:"column",justifyContent:"center",textAlign:"right",height:"60%",fontSize:64,lineHeight:"100%"};return(t>n&&n<400||n>t&&n<850)&&(e.fontSize=36),i.a.createElement("div",{id:"display",style:e},0===this.props.inputString.length?0:this.props.inputString)}}]),e}(i.a.Component),bt=Object(u.b)((function(t){return Object(k.a)({},t)}))(gt),ft=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(){return Object(p.a)(this,e),n.apply(this,arguments)}return Object(g.a)(e,[{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={display:"flex",flexDirection:"column",justifyContent:"center",textAlign:"right",height:"40%",fontSize:48,lineHeight:"100%",color:M};return(t>n&&n<400||n>t&&n<850)&&(e.fontSize=27),i.a.createElement("div",{id:"displayOperations",style:e},0===this.props.operationString.length?0:this.props.operationString)}}]),e}(i.a.Component),vt=Object(u.b)((function(t){return Object(k.a)({},t)}))(ft),kt=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(){return Object(p.a)(this,e),n.apply(this,arguments)}return Object(g.a)(e,[{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:1,gridColumnEnd:7,gridRowStart:1,gridRowEnd:2,borderBottom:"3px solid black",backgroundColor:w,borderRadius:"7px 7px 0 0",color:m,textOverflow:"clip",whiteSpace:"nowrap",overflow:"hidden"};return n>t&&(e.gridColumnEnd=5),i.a.createElement("div",{style:e},i.a.createElement(vt,null),i.a.createElement(bt,null))}}]),e}(i.a.Component),Ct=Object(u.b)((function(t){return Object(k.a)({},t)}))(kt),St=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleClick=o.handleClick.bind(Object(b.a)(o)),o.handleMouseEvent=o.handleMouseEvent.bind(Object(b.a)(o)),o.state={backgroundColor:j},o}return Object(g.a)(e,[{key:"handleClick",value:function(){var t=W(this.props.inputString,this.props.operationString,"b"),n=Object(C.a)(t,2),e=n[0],o=n[1];e!==this.props.inputString&&this.props.inputStringAction(e),o!==this.props.operationString&&this.props.operationStringAction(o)}},{key:"handleMouseEvent",value:function(t){"mousedown"===t.type||"touchstart"===t.type?this.setState({backgroundColor:m}):"mouseup"!==t.type&&"touchend"!==t.type||this.setState({backgroundColor:j})}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={gridColumnStart:6,gridColumnEnd:7,gridRowStart:3,gridRowEnd:4,borderBottom:"3px solid black",display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",backgroundColor:this.state.backgroundColor};return n>t&&(e.gridRowStart=2,e.gridRowEnd=3,e.gridColumnStart=2,e.gridColumnEnd=3,e.borderRight="3px solid black"),i.a.createElement("div",{id:"subtract",style:e,className:"clickable",onClick:this.handleClick,onTouchStart:this.handleMouseEvent,onTouchEnd:this.handleMouseEvent,onMouseDown:this.handleMouseEvent,onMouseUp:this.handleMouseEvent},i.a.createElement(et.a,{icon:ot.a}))}}]),e}(i.a.Component),mt=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(St),Et=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(){return Object(p.a)(this,e),n.apply(this,arguments)}return Object(g.a)(e,[{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e={display:"grid",width:"100%",height:"100%",gridTemplateRows:"repeat(4, 1fr)",gridTemplateColumns:"repeat(6, 1fr)",fontSize:64};return t>n&&n<400?e.fontSize=48:n>t&&(e.gridTemplateRows="repeat(6, 1fr)",e.gridTemplateColumns="repeat(4, 1fr)",e.fontSize=48),i.a.createElement("div",{id:"CalculatorGrid",style:e},i.a.createElement(D,null),i.a.createElement(N,null),i.a.createElement(B,null),i.a.createElement(z,null),i.a.createElement(P,null),i.a.createElement(L,null),i.a.createElement(_,null),i.a.createElement(q,null),i.a.createElement(Q,null),i.a.createElement(X,null),i.a.createElement(Z,null),i.a.createElement(nt,null),i.a.createElement(rt,null),i.a.createElement(ut,null),i.a.createElement(st,null),i.a.createElement(dt,null),i.a.createElement(pt,null),i.a.createElement(Ct,null),i.a.createElement(mt,null))}}]),e}(i.a.Component),yt=Object(u.b)((function(t){return Object(k.a)({},t)}))(Et),jt=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleKeyPress=o.handleKeyPress.bind(Object(b.a)(o)),o.handleKey=o.handleKey.bind(Object(b.a)(o)),o}return Object(g.a)(e,[{key:"handleKey",value:function(t){var n=W(this.props.inputString,this.props.operationString,t),e=Object(C.a)(n,2),o=e[0],i=e[1];o!==this.props.inputString&&this.props.inputStringAction(o),i!==this.props.operationString&&this.props.operationStringAction(i)}},{key:"handleKeyPress",value:function(t){8===t.keyCode||46===t.keyCode?this.handleKey("b"):["0","1","2","3","4","5","6","7","8","9",".","*","+","-","="].includes(t.key)?this.handleKey(t.key):"/"===t.key?(t.preventDefault(),this.handleKey(t.key)):13===t.keyCode?this.handleKey("="):27===t.keyCode&&(this.props.inputStringAction(""),this.props.operationStringAction(""))}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyPress,!1)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyPress,!1)}},{key:"render",value:function(){var t=this.props.innerWindowWidth,n=this.props.innerWindowHeight,e=Math.round(.1*n),o=Math.round(.1*t),r={height:"80%",width:"80%",backgroundColor:E,borderRadius:10,marginTop:e,marginBottom:e,marginLeft:o,marginRight:o,overFlow:"hidden",border:"3px solid black",userSelect:"none",MozUserSelect:"none",WebkitUserSelect:"none",zIndex:"1",fontFamily:"Baloo Bhai"};return t>n&&n<400?(r.height="96vh",r.width="80vw",r.marginTop="1vh",r.marginBottom="3vh",r.marginLeft="89px",r.marginRight="89px"):n>t&&(r.height="75vh",r.minHeight=481,r.width="100vw",r.marginTop="12vh",r.marginBottom="unset",r.marginLeft="0px",r.marginRight="0px"),i.a.createElement("div",{id:"Calculator",style:r},i.a.createElement(yt,null))}}]),e}(i.a.Component),Ot=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{inputStringAction:function(n){return t(s(n))},operationStringAction:function(n){return t(l(n))}}}))(jt),wt=function(t){Object(f.a)(e,t);var n=Object(v.a)(e);function e(t){var o;return Object(p.a)(this,e),(o=n.call(this,t)).handleResize=o.handleResize.bind(Object(b.a)(o)),o}return Object(g.a)(e,[{key:"handleResize",value:function(){this.props.innerWindowWidthAction(window.innerWidth),this.props.innerWindowHeightAction(window.innerHeight)}},{key:"componentDidMount",value:function(){window.addEventListener("resize",this.handleResize)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize)}},{key:"render",value:function(){var t=this.props.innerWindowHeight,n=this.props.innerWindowWidth,e={backgroundColor:m,border:"none",width:149,height:0,position:"absolute",right:0},o={position:"absolute",right:0,height:149,width:149},r={textAlign:"center",backgroundColor:m,height:"100vh",width:"100vw",display:"flex",color:w,overFlow:"hidden"};return(n>t&&t<400||t>n)&&(e.width=99,o.width=99,o.height=99),i.a.createElement("div",{style:r},i.a.createElement("a",{href:"https://github.com/TrentSPalmer/fcc-challenges/tree/gh-pages/calculator-react",style:e,target:"_blank",rel:"noopener noreferrer"},i.a.createElement("img",{src:"https://github.blog/wp-content/uploads/2008/12/forkme_right_white_ffffff.png?resize=149%2C149",className:"size-full",style:o,alt:"Fork me on GitHub","data-recalc-dims":"1"})),i.a.createElement(Ot,null))}}]),e}(i.a.Component),Mt=Object(u.b)((function(t){return Object(k.a)({},t)}),(function(t){return{innerWindowWidthAction:function(n){return t(function(t){return{type:"SETWINDOWINNERWIDTH",windowInnerWidth:t}}(n))},innerWindowHeightAction:function(n){return t(function(t){return{type:"SETWINDOWINNERHEIGHT",windowInnerHeight:t}}(n))}}}))(wt);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));a.a.render(i.a.createElement(u.a,{store:h},i.a.createElement(Mt,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(t){t.unregister()})).catch((function(t){console.error(t.message)}))}},[[24,1,2]]]);
|
|
//# sourceMappingURL=main.78f555dc.chunk.js.map
|