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AaD,MAStCY,EAAEuD,UAAUC,GAAG,4BAA4B,WACvCxD,EAAE,6BAA6ByD,MAAK,SAAUC,GAE1C,IAAI3E,EAAO,CACPI,KAAMF,KACN0E,qBAAsBC,YAAYD,sBAEtC5E,EAAKW,IAAMyD,OAAOU,UAAU5E,KAAKG,IACiC,GAA9DY,EAAEf,MAAM6E,QAAQ,oCAAoCrD,SAEpD7B,EAAOK,KAAKG,IAAM,IAAIP,EAASE,eAKH,IAA7BoE,OAAOY,oBACdZ,OAAOY,kBAAoB,IAE/BZ,OAAOY,kBAA4B,SAAI,SAAUhF,GAC7C,OAAO,IAAIF,EAASE","sources":["webpack://WebComponents/./runestone/showeval/js/showEval.js"],"sourcesContent":["/*\nThis component is based on ...\nShowEval, a JS module for creating visualizations of expression evaluation. Mainly for programming tutorials.\n0.9.1\n\nAl Sweigart\nal@inventwithpython.com\nhttps://github.com/asweigart/\n*/\n\"use strict\";\n\nimport RunestoneBase from \"../../common/js/runestonebase\";\nimport \"../css/showEval.css\";\n\nvar seList = [];\n\nexport class ShowEval extends RunestoneBase {\n constructor(opts) {\n super(opts);\n this.divid = opts.orig.id;\n this.containerDiv = opts.orig;\n this.containerDiv.classList.add(\"showEval\");\n let steps = [];\n for (let s of opts.raw) {\n steps.push(s.replace(/\\\\/g, \"\"));\n }\n this.steps = steps.slice();\n this.currentStep = 0;\n this.createTrace = $(opts.orig).data(\"tracemode\"); // TODO - reset doesn't work for traces\n this.rb = new RunestoneBase(opts);\n // create elements\n this.currentStepDiv = $(\"
\").addClass(\"currentStepDiv\");\n $(this.containerDiv).append(this.currentStepDiv);\n this.currentStepDiv.append($(\"\").addClass(\"pre\"));\n this.currentStepDiv.append($(\"\").addClass(\"eval\"));\n this.currentStepDiv.append($(\"\").addClass(\"post\"));\n this.currentStepDiv.append($(\"
\").addClass(\"anno\"));\n this.setNextButton(`#${this.divid}_nextStep`);\n this.setResetButton(`#${this.divid}_reset`);\n\n // parse steps and turn into a 4-string array: ['pre', 'before eval', 'after eval', 'post']\n for (var i = 0; i < this.steps.length; i++) {\n var s = this.steps[i];\n let endpoint, pItem, comment;\n\n if (s.includes(\"##\")) {\n // If there is an annotation\n endpoint = s.indexOf(\"##\");\n comment = s.substring(endpoint + 2, s.length);\n } else {\n endpoint = s.length;\n comment = false;\n }\n this.steps[i] = [\n s.substring(0, s.indexOf(\"{{\")), // 'pre'\n s.substring(s.indexOf(\"{{\") + 2, s.indexOf(\"}}{{\")), // 'before eval'\n s.substring(\n s.indexOf(\"}}{{\") + 4,\n s.indexOf(\"}}\", s.indexOf(\"}}{{\") + 4)\n ), // 'after eval'\n s.substring(\n s.indexOf(\"}}\", s.indexOf(\"}}{{\") + 4) + 2,\n endpoint\n ),\n ]; // 'post'\n\n this.steps[i].push(comment); // 'anno'\n }\n this.reset();\n this.caption = \"ShowEval\";\n this.addCaption(\"runestone\");\n this.indicate_component_ready();\n }\n\n setNextButton(nextButtonSelector) {\n var thisObj = this; // uhg, javascript\n $(nextButtonSelector).click(function () {\n thisObj.evaluateStep(nextButtonSelector);\n });\n }\n\n setResetButton(resetButtonSelector) {\n var thisObj = this; // uhg, javascript\n $(resetButtonSelector).click(function () {\n thisObj.reset(0);\n });\n }\n\n reset() {\n $(this.containerDiv).find(\".previousStep\").remove();\n this.setStep(0);\n this.rb.logBookEvent({\n event: \"showeval\",\n act: \"reset\",\n div_id: this.containerDiv.id,\n });\n }\n\n setStep(step) {\n this.currentStep = step;\n let newWidth = this.getWidth(this.steps[this.currentStep][1]);\n if (this.steps[step][4]) {\n this.currentStepDiv.children(\".anno\").html(this.steps[step][4]);\n this.currentStepDiv.children(\".anno\").show();\n } else {\n this.currentStepDiv.children(\".anno\").hide();\n }\n this.currentStepDiv.children(\".eval\").width(newWidth);\n this.currentStepDiv.children(\".pre\").html(this.steps[step][0]);\n this.currentStepDiv.children(\".eval\").html(this.steps[step][1]);\n this.currentStepDiv.children(\".post\").html(this.steps[step][3]);\n }\n\n getWidth(text) {\n // TODO - class style must match or else width will be off.\n var newElem = $(\"
\")\n .addClass(\"showEval evalCont\")\n .hide()\n .html(text);\n $(\"body\").append(newElem);\n var newWidth = newElem.width() + 1; // +1 is a hack\n newElem.remove();\n\n return newWidth;\n }\n\n createPreviousStepDiv(step) {\n this.currentStepDiv.before(\n $(\"
\")\n .addClass(\"previousStep\")\n .html(\n this.steps[step][0] +\n this.steps[step][1] +\n this.steps[step][3]\n )\n );\n }\n\n evaluateStep(buttonId, step) {\n this.currentStepDiv.children(\".anno\").hide();\n $(buttonId).attr(\"disabled\", true);\n if (step === undefined) {\n step = this.currentStep;\n }\n if (this.currentStep >= this.steps.length) {\n //this.currentStep = 0;\n //step = 0;\n $(buttonId).attr(\"disabled\", false);\n return; // do nothing if on last step\n }\n //this.setStep(step);\n\n var fadeInSpeed = 0;\n if (this.createTrace) {\n this.createPreviousStepDiv(step);\n this.currentStepDiv.hide();\n fadeInSpeed = 200;\n }\n\n let newWidth = this.getWidth(this.steps[step][2]);\n var evalElem = this.currentStepDiv.children(\".eval\");\n\n var thisShowEval = this;\n\n evalElem.css(\"color\", \"red\");\n\n this.currentStepDiv.fadeTo(fadeInSpeed, 1, function () {\n window.setTimeout(function () {\n evalElem.fadeTo(400, 0, function () {\n //evalElem.css('overflow', 'hidden');\n evalElem.animate(\n { width: newWidth, duration: 400 },\n function () {\n evalElem.html(thisShowEval.steps[step][2]);\n evalElem.fadeTo(400, 1, function () {\n window.setTimeout(function () {\n //evalElem.css('overflow', 'visible');\n evalElem.css(\"color\", \"#333\");\n thisShowEval.currentStep += 1;\n if (\n thisShowEval.currentStep <\n thisShowEval.steps.length\n ) {\n thisShowEval.setStep(\n thisShowEval.currentStep\n );\n }\n $(buttonId).attr(\"disabled\", false);\n }, 600);\n });\n }\n );\n });\n }, 600);\n });\n\n this.rb.logBookEvent({\n event: \"showeval\",\n act: \"next\",\n div_id: this.containerDiv.id,\n });\n }\n}\n\n/*=================================\n== Find the custom HTML tags and ==\n== execute our code on them ==\n=================================*/\n$(document).on(\"runestone:login-complete\", function () {\n $(\"[data-component=showeval]\").each(function (index) {\n // MC\n var opts = {\n orig: this,\n useRunestoneServices: eBookConfig.useRunestoneServices,\n };\n opts.raw = window.raw_steps[this.id];\n if ($(this).closest(\"[data-component=timedAssessment]\").length == 0) {\n // If this element exists within a timed component, don't render it here\n seList[this.id] = new ShowEval(opts);\n }\n });\n});\n\nif (typeof window.component_factory === \"undefined\") {\n window.component_factory = {};\n}\nwindow.component_factory[\"showeval\"] = function (opts) {\n return new ShowEval(opts);\n};\n"],"names":["seList","ShowEval","constructor","opts","super","this","divid","orig","id","containerDiv","classList","add","steps","s","raw","push","replace","slice","currentStep","createTrace","$","data","rb","currentStepDiv","addClass","append","setNextButton","setResetButton","i","length","endpoint","comment","includes","indexOf","substring","reset","caption","addCaption","indicate_component_ready","nextButtonSelector","thisObj","click","evaluateStep","resetButtonSelector","find","remove","setStep","logBookEvent","event","act","div_id","step","newWidth","getWidth","children","html","show","hide","width","text","newElem","createPreviousStepDiv","before","buttonId","attr","undefined","fadeInSpeed","evalElem","thisShowEval","css","fadeTo","window","setTimeout","animate","duration","document","on","each","index","useRunestoneServices","eBookConfig","raw_steps","closest","component_factory"],"sourceRoot":""}