mirror of
https://github.com/Xevion/power-math.git
synced 2025-12-05 23:15:46 -06:00
2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
(function(t){function e(e){for(var i,a,r=e[0],c=e[1],u=e[2],d=0,m=[];d<r.length;d++)a=r[d],Object.prototype.hasOwnProperty.call(s,a)&&s[a]&&m.push(s[a][0]),s[a]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(t[i]=c[i]);l&&l(e);while(m.length)m.shift()();return o.push.apply(o,u||[]),n()}function n(){for(var t,e=0;e<o.length;e++){for(var n=o[e],i=!0,r=1;r<n.length;r++){var c=n[r];0!==s[c]&&(i=!1)}i&&(o.splice(e--,1),t=a(a.s=n[0]))}return t}var i={},s={app:0},o=[];function a(e){if(i[e])return i[e].exports;var n=i[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=t,a.c=i,a.d=function(t,e,n){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},a.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)a.d(n,i,function(e){return t[e]}.bind(null,i));return n},a.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="/power-math/";var r=window["webpackJsonp"]=window["webpackJsonp"]||[],c=r.push.bind(r);r.push=e,r=r.slice();for(var u=0;u<r.length;u++)e(r[u]);var l=c;o.push([0,"chunk-vendors"]),n()})({0:function(t,e,n){t.exports=n("56d7")},"432b":function(t,e,n){},"56d7":function(t,e,n){"use strict";n.r(e);n("e260"),n("e6cf"),n("cca6"),n("a79d");var i=n("2b0e"),s=n("bfc7"),o=n("7f82"),a=n("10bd"),r=n("77b4"),c=n("c0ac"),u=n("61b7"),l=n("d410"),d=n("289d"),m=n("ecee"),h=n("c074"),p=n("ad3d"),f=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{attrs:{id:"app"}},[n("div",{staticClass:"columns is-justify-content-flex-end pt-2"},[n("div",{staticClass:"column is-1 mr-2"},[n("b-icon",{staticClass:"is-clickable is-pulled-right",attrs:{pack:"fas",icon:"cog","custom-size":"3x"},nativeOn:{click:function(e){t.isSettingsMenuActive=!0}}}),n("b-modal",{attrs:{"has-modal-card":"","trap-focus":"","destroy-on-hide":!1,"aria-role":"dialog","aria-modal":""},scopedSlots:t._u([{key:"default",fn:function(e){return[n("SettingsMenu",{attrs:{problems:t.problems},on:{close:e.close}})]}}]),model:{value:t.isSettingsMenuActive,callback:function(e){t.isSettingsMenuActive=e},expression:"isSettingsMenuActive"}})],1)]),n("div",{directives:[{name:"katex",rawName:"v-katex",value:t.expression,expression:"expression"}],staticClass:"animate__animated animate__faster",class:t.currentAnimation,attrs:{id:"expression"}}),n("div",{staticClass:"container"},[n("div",{staticClass:"columns is-centered"},[n("div",{staticClass:"column is-three-fifths"},[n("b-field",{attrs:{id:"input"},nativeOn:{keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.checkAnswer()}}},[n("b-input",{attrs:{"custom-class":t.inputClass},model:{value:t.answer,callback:function(e){t.answer=e},expression:"answer"}})],1)],1)])])])},b=[],g=(n("a9e3"),n("25eb"),n("4de4"),n("99af"),{methods:{getRandomInt:function(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t)+t)}}}),w={methods:{addition:function(t){var e=g.methods.getRandomInt(t.low,t.high),n=g.methods.getRandomInt(t.low,t.high);return{text:"".concat(e," + ").concat(n),answer:e+n}},subtraction:function(t){var e=g.methods.getRandomInt(t.low,t.high),n=g.methods.getRandomInt(t.low,t.high);return Math.random()>.5?{text:"".concat(e," - ").concat(n),answer:e-n}:{text:"-".concat(e," + ").concat(n),answer:-e+n}},multiplication:function(t){var e=g.methods.getRandomInt(t.low,t.high),n=g.methods.getRandomInt(t.low,t.high);return{text:"".concat(e," \\times ").concat(n),answer:e*n}},division:function(t){var e=g.methods.getRandomInt(t.low,t.high),n=g.methods.getRandomInt(t.low,t.high);return{text:"".concat(e*n," \\div ").concat(n),answer:e}},square_root:function(t){var e=g.methods.getRandomInt(t.low,t.high);return{text:"\\sqrt{".concat(e*e,"}"),answer:e}}},data:function(){var t=this;return{problems:[{name:"Addition",id:"addition",description:"Find the sum of two integers",difficulties:[{id:"easy",name:"Easy",options:{low:7,high:50},style:"is-success"},{id:"medium",name:"Medium",options:{low:30,high:100},style:"is-warning"},{id:"hard",name:"Hard",options:{low:50,high:200},style:"is-danger"}],method:t.methods.addition,enabled:!0,current:0},{name:"Subtraction",id:"subtraction",description:"Evaluate the difference between two integers.",difficulties:[{id:"easy",name:"Easy",options:{low:7,high:50},style:"is-success"},{id:"medium",name:"Medium",options:{low:20,high:80},style:"is-warning"},{id:"hard",name:"Hard",options:{low:40,high:110},style:"is-danger"}],method:t.methods.subtraction,enabled:!0,current:0},{name:"Multiplication",id:"multiplication",description:"Evaluate the product of two integers.",difficulties:[{id:"easy",name:"Easy",options:{low:5,high:35},style:"is-success"},{id:"medium",name:"Medium",options:{low:8,high:50},style:"is-warning"},{id:"hard",name:"Hard",options:{low:15,high:95},style:"is-danger"}],method:t.methods.multiplication,enabled:!0,current:0},{name:"Division",id:"division",description:"Divide one integer by another to get a third integer.",difficulties:[{id:"easy",name:"Easy",options:{low:5,high:35},style:"is-success"},{id:"medium",name:"Medium",options:{low:8,high:50},style:"is-warning"},{id:"hard",name:"Hard",options:{low:15,high:95},style:"is-danger"}],method:t.methods.division,enabled:!0,current:0},{name:"Square Root",id:"square_root",description:"Find the square root of a given integer.",difficulties:[{id:"easy",name:"Easy",options:{low:4,high:20},style:"is-success"},{id:"medium",name:"Medium",options:{low:13,high:30},style:"is-warning"},{id:"hard",name:"Hard",options:{low:19,high:60},style:"is-danger"}],method:t.methods.square_root,enabled:!0,current:0}]}}},v={computed:{availableProblems:function(){return this.problems.filter((function(t){return t.enabled}))}},methods:{getProblem:function(){for(var t=this.availableProblems[g.methods.getRandomInt(0,this.availableProblems.length)],e=null,n=0;n<5;n++)if(e=t.method(t.difficulties[t.current].options),null==this.previousProblem||e.text!==this.previousProblem.text)break;return this.previousProblem=e,e}},data:function(){return{previousProblem:null,problems:w.data().problems}}},y=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"modal-card"},[n("header",{staticClass:"modal-card-head"},[n("p",{staticClass:"modal-card-title"},[t._v("Settings")]),n("b-icon",{staticClass:"is-clickable",attrs:{pack:"fas",icon:"times"},nativeOn:{click:function(e){return t.$parent.close()}}})],1),n("section",{staticClass:"modal-card-body"},t._l(t.problems,(function(e,i){return n("b-field",{key:e.id,staticClass:"is-flex mb-1",attrs:{addons:""}},[n("p",{staticClass:"control is-flex-grow-0",staticStyle:{"min-width":"150px"}},[n("b-button",{staticClass:"button-unhoverable is-block darker w-100",staticStyle:{cursor:"default"},attrs:{hovered:!1}},[t._v(" "+t._s(e.name)+" ")])],1),n("p",{staticClass:"control is-flex-grow-2"},[n("b-button",{staticClass:"w-100",attrs:{type:e.enabled?"":"is-info",selected:!e.enabled},on:{click:function(e){return t.disableProblem(i)}}},[t._v(" Off ")])],1),t._l(e.difficulties,(function(s,o){return n("p",{key:s.id,staticClass:"control is-flex-grow-2"},[n("b-tooltip",{staticClass:"w-100",attrs:{type:"is-dark",animated:!1},scopedSlots:t._u([{key:"content",fn:function(){return[n("katex-element",{attrs:{expression:t.getExample(i,o)}})]},proxy:!0}],null,!0)},[n("b-button",{staticClass:"w-100",attrs:{type:e.enabled&&e.current===o?s.style||"is-info":"",selected:e.enabled&&e.current===o},nativeOn:{click:function(e){return t.selectProblemDifficulty(i,o)}}},[t._v(" "+t._s(s.name)+" ")])],1)],1)}))],2)})),1)])},x=[],k={name:"SettingsMenu",props:{problems:v},methods:{selectProblemDifficulty:function(t,e){this.problems[t].enabled=!0,this.problems[t].current=e},disableProblem:function(t){this.problems[t].enabled=!1},getExample:function(t,e){var n=this.problems[t];return n.method(n.difficulties[e].options).text}}},_=k,C=n("2877"),I=Object(C["a"])(_,y,x,!1,null,null,null),S=I.exports,M={name:"App",mixins:[v],components:{SettingsMenu:S},data:function(){return{answer:null,currentQuestion:null,correctTimeout:!1,inputClass:"",allowInputSubmit:!0,currentAnimation:"",chances:3,isSettingsMenuActive:!1}},computed:{expression:function(){return null!=this.currentQuestion?this.currentQuestion.text:"error"}},created:function(){var t=this;window.addEventListener("keyup",(function(e){38===e.keyCode?t.nextQuestion():39===e.keyCode&&t.checkAnswer(!0)}))},mounted:function(){var t=this;this.$nextTick((function(){t.nextQuestion()}))},methods:{nextQuestion:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=this.getProblem();null==this.currentQuestion?this.currentQuestion=n:(this.currentAnimation=e?"animate__fadeOutRight":"animate__fadeOutUp",setTimeout((function(){t.currentQuestion=n,t.currentAnimation="animate__fadeInDown",setTimeout((function(){t.currentAnimation=""}),500)}),200))},checkAnswer:function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(this.allowInputSubmit||e)&&(t="number"===typeof this.currentQuestion.answer?this.currentQuestion.answer===Number.parseInt(this.answer):this.currentQuestion.answer===this.answer,t||e?(this.inputClass="correct",setTimeout(this.clearInputClass,500),this.nextQuestion(),this.answer=""):(0===--this.chances&&(this.nextQuestion(!0),this.chances=3),this.inputClass="incorrect",setTimeout(this.clearInputClass,500),this.allowInputSubmit=!1,setTimeout(this.unlockInput,500)))},clearInputClass:function(){this.inputClass=""},unlockInput:function(){this.allowInputSubmit=!0}}},O=M,P=(n("5c0b"),Object(C["a"])(O,f,b,!1,null,null,null)),A=P.exports;n("be0f"),n("432b"),n("4b3c");i["a"].config.productionTip=!1,m["c"].add(h["a"],h["b"]),i["a"].component("vue-fontawesome",p["a"]),i["a"].use(o["a"]),i["a"].use(a["a"]),i["a"].use(r["a"]),i["a"].use(c["a"]),i["a"].use(u["a"]),i["a"].use(l["a"]),d["a"].setOptions({defaultIconComponent:"vue-fontawesome",defaultIconPack:"fas"}),i["a"].use(s["a"]),new i["a"]({render:function(t){return t(A)}}).$mount("#app")},"5c0b":function(t,e,n){"use strict";var i=n("9c0c"),s=n.n(i);s.a},"9c0c":function(t,e,n){}});
|
|
//# sourceMappingURL=app.aa8bf807.js.map
|