From 03b5103d851749bcc19c55443b88c53df869762a Mon Sep 17 00:00:00 2001 From: Pete Boysen Date: Sun, 11 Sep 2016 14:29:48 -0500 Subject: [PATCH] restart no longer changes input values --- sims/mtnsim/mtnsim-built-min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sims/mtnsim/mtnsim-built-min.js b/sims/mtnsim/mtnsim-built-min.js index 602560c..ef22d55 100644 --- a/sims/mtnsim/mtnsim-built-min.js +++ b/sims/mtnsim/mtnsim-built-min.js @@ -1 +1 @@ -!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o0?tr.appendChild(getCol(json.cloudbase)):tr.appendChild(document.createElement("td").appendChild(document.createTextNode("Clear"))),tr.appendChild(getDelete(row)),tr}var _get=function get(object,property,receiver){null===object&&(object=Function.prototype);var desc=Object.getOwnPropertyDescriptor(object,property);if(void 0===desc){var parent=Object.getPrototypeOf(object);return null===parent?void 0:get(parent,property,receiver)}if("value"in desc)return desc.value;var getter=desc.get;if(void 0!==getter)return getter.call(receiver)},_createClass=function(){function defineProperties(target,props){for(var i=0;it;t++)this.plot(t,icesaturation(t));for(var t=0;tsat&&(this.vapor=sat,updateSettings===!0&&(this.settings.setTemp(this.temp),this.settings.setVapor(sat)));var x=this.xaxis.getLoc(this.temp),y=this.yaxis.getLoc(this.vapor);this.marker.x=x-2,this.marker.y=y-2,updateSettings===!0&&this.moveLeaf(x,y)}},{key:"update",value:function(trial){this.temp=trial.temp,this.vapor=trial.vapor,this.plot(trial.temp,trial.vapor),this.moveMarker(!1),this.showLeaf()}}]),ETGraph}(_utils.Graph),ATGraph=function(_Graph2){function ATGraph(stage){_classCallCheck(this,ATGraph);var _this3=_possibleConstructorReturn(this,Object.getPrototypeOf(ATGraph).call(this,{stage:stage,w:200,h:200,xlabel:"Temperature(C)",ylabel:"Altitude(km)",xscale:"linear",yscale:"linear",minX:-20,maxX:30,minY:0,maxY:5,majorX:10,minorX:5,majorY:1,minorY:.5}));return _this3.temp=20,_this3.altitude=0,_this3.cloudbase=0,_this3}return _inherits(ATGraph,_Graph2),_createClass(ATGraph,[{key:"update",value:function(trial){this.plot(trial.temp,trial.altitude)}}]),ATGraph}(_utils.Graph),IceGraph=function(_Graph3){function IceGraph(stage){_classCallCheck(this,IceGraph);var _this4=_possibleConstructorReturn(this,Object.getPrototypeOf(IceGraph).call(this,{stage:stage,x:60,y:110,w:75,h:100,xlabel:"C",xscale:"linear",yscale:"linear",minX:-15,maxX:1,minY:1,maxY:5,majorX:5,majorY:1,background:"#EEE"})),liquid=new createjs.Text("Liquid","10px Arial","#000");liquid.x=65,liquid.y=40,stage.addChild(liquid);var ice=new createjs.Text("Ice","10px Arial","#000");return ice.x=90,ice.y=70,stage.addChild(ice),_this4}return _inherits(IceGraph,_Graph3),_createClass(IceGraph,[{key:"render",value:function(){_get(Object.getPrototypeOf(IceGraph.prototype),"render",this).call(this);for(var t=this.xaxis.min;t<=this.xaxis.max;t++)this.plot(t,saturation(t));this.endPlot();for(var t=this.xaxis.min;t<=this.xaxis.max;t++)this.plot(t,icesaturation(t));this.endPlot()}}]),IceGraph}(_utils.Graph),Mtn=function(){function Mtn(stage,settings,finish){var _this5=this;_classCallCheck(this,Mtn),this.stage=stage,this.settings=settings,this.finish=finish,createjs.Sound.registerSound({id:"thunder",src:"assets/thunder.mp3"}),createjs.Sound.registerSound({id:"wind",src:"assets/wind.mp3"}),this.wind=null,this.thunder=null,this.mtn=new createjs.Bitmap("assets/mountain.png"),this.leaf=new createjs.Bitmap("assets/leaf.gif"),this.cloud=new createjs.Bitmap("assets/thundercloud.png"),this.bolt=new createjs.Bitmap("assets/lightning.png"),this.leaftween=null,this.mtn.x=0,this.mtn.y=0,this.mtn.scaleX=.5,this.mtn.scaleY=.5,this.bolt.x=-100,this.bolt.scaleX=.015,this.bolt.scaleY=.015,this.running=!1,this.lightning=!1,this.lighttick=0,this.path=[50,164,60,155,74,152,80,140,90,131,100,125,112,122,120,110,137,92,140,75,151,64,150,60,173,56,185,60,204,70,210,80,221,92,221,95,224,105,230,110,246,121,250,130,268,141,280,150,290,164],this.results=document.getElementById("results_table"),document.getElementById("delete_all").addEventListener("click",function(event){confirm("Delete all data?")&&_this5.deleteResults()}),this.trial=new Trial,this.showResults()}return _createClass(Mtn,[{key:"render",value:function(){this.stage.addChild(this.mtn),this.stage.addChild(this.leaf),this.stage.addChild(this.cloud),this.stage.addChild(this.bolt),this.leaf.x=50,this.leaf.y=165,this.cloud.x=-1e3,this.cloud.y=0,this.lastalt=0,this.cloud.scaleX=.1,this.cloud.scaleY=.05}},{key:"clear",value:function(){this.stage.removeAllChildren(),this.render()}},{key:"play",value:function(){var _this6=this;this.temp=this.settings.getTemp(),this.vapor=this.settings.getVapor(),this.trial.init({temp:this.temp,vapor:this.vapor,humidity:humidity(this.temp,this.vapor),dewpoint:dewpoint(this.temp,this.vapor)}),this.factor=10,this.lastalt=0,this.leaftween=createjs.Tween.get(this.leaf).to({guide:{path:this.path}},12e3),this.leaftween.call(function(){_this6.wind&&_this6.wind.stop(),_this6.running=!1,_this6.addTrial(),_this6.finish&&_this6.finish()}),this.running=!0,this.leaftween.play(),this.playSound("wind")}},{key:"showResults",value:function(){for(var _this7=this,i=this.results.children.length-1;i>1;i--)this.results.removeChild(this.results.children[i]);var trials=store.get(mtnsim_results);trials?trials.forEach(function(json){return _this7.results.appendChild(getRow(json))}):store.set(mtnsim_results,[])}},{key:"addTrial",value:function(){var trials=store.get(mtnsim_results),json=this.trial.toJSON();store.set(mtnsim_results,trials.concat(json)),this.results.appendChild(getRow(json))}},{key:"deleteTrial",value:function(row){var trials=store.get(mtnsim_results);trials.splice(row,1),store.set(mtnsim_results,trials),this.showResults()}},{key:"deleteResults",value:function(){store.set(mtnsim_results,[]),this.showResults()}},{key:"pause",value:function(_pause){this.leaftween.setPaused(_pause),this.wind&&(this.wind.paused=_pause),this.thunder&&(this.thunder.paused=_pause),this.running=!_pause}},{key:"playSound",value:function(sound){if(!this.settings.mute.checked)switch(sound){case"wind":this.wind=createjs.Sound.play(sound,{loop:2});break;case"thunder":this.thunder=createjs.Sound.play(sound)}}},{key:"update",value:function(trial){var oldA=trial.altitude,oldT=trial.temp;trial.altitude=(165-this.leaf.y)/165*5,trial.altitude<0&&(trial.altitude=0),trial.temp=Number(oldT-this.factor*(trial.altitude-oldA)),trial.humidity=humidity(trial.temp,trial.vapor),trial.dewpoint=dewpoint(trial.temp,trial.vapor);var sat=saturation(trial.temp);trial.vapor>sat&&(this.animateClouds(),trial.vapor=sat,trial.humidity=100,this.factor=6),trial.temp>oldT&&(this.factor=10)}},{key:"animateClouds",value:function(){0==this.trial.cloudbase&&(this.trial.cloudbase=this.trial.altitude,this.cloud.x=this.leaf.x-2,this.cloud.y=this.leaf.y,this.bolt.y=this.cloud.y+20,this.lasty=this.leaf.y),this.trial.altitude-this.lastalt>.1&&(this.lastalt=this.trial.altitude,this.cloud.scaleX+=.021,this.cloud.scaleY+=.02,this.cloud.y=this.leaf.y),!this.lightning&&this.leaf.x<140&&this.trial.temp<=-5&&this.trial.altitude-this.trial.cloudbase>.5&&(this.lighttick=0,this.lightning=!0)}},{key:"newTrial",value:function(){this.trial=new Trial}},{key:"tick",value:function(etgraph,atgraph){if(this.running===!0&&(this.update(this.trial),etgraph.update(this.trial),atgraph.update(this.trial),this.lightning===!0)){switch(this.lighttick){case 0:this.bolt.x=this.cloud.x+10;break;case 5:this.bolt.x+=10;break;case 7:this.bolt.x+=10;break;case 10:this.bolt.x=-100;break;case 60:this.playSound("thunder"),this.lightning=!1}this.lighttick++}}}]),Mtn}(),MtnSim=function(){function MtnSim(){var _this8=this;_classCallCheck(this,MtnSim),this.mainstage=new createjs.Stage("maincanvas"),this.etstage=new createjs.Stage("etgraph"),this.atstage=new createjs.Stage("atgraph"),this.buttons=new Buttons,this.settings=new Settings,this.etgraph=new ETGraph(this.etstage,this.settings),this.atgraph=new ATGraph(this.atstage),this.mtn=new Mtn(this.mainstage,this.settings,function(){_this8.buttons.restart.disabled=!1,_this8.buttons.pause.disabled=!0}),this.pause=!1,this.buttons.addListener(function(e){switch(e.target.id){case"run":_this8.enablePlay(!1),_this8.buttons.pause.value="Pause",_this8.pause=!1,_this8.mtn.play();break;case"pause":_this8.pause=!_this8.pause,_this8.mtn.pause(_this8.pause),e.target.value=_this8.pause?"Resume":"Pause";break;case"restart":_this8.reset(),_this8.mtn.clear(),_this8.etgraph.clear(),_this8.atgraph.clear(),_this8.etgraph.render(),_this8.atgraph.render(),_this8.mtn.newTrial()}})}return _createClass(MtnSim,[{key:"reset",value:function(){this.enablePlay(!0),this.settings.setTemp(20),this.settings.setVapor(7)}},{key:"enablePlay",value:function(play){this.buttons.run.disabled=!play,this.buttons.pause.disabled=play,this.buttons.restart.disabled=!play}},{key:"render",value:function(){var _this9=this;this.buttons.run.disabled=!1,this.buttons.mute.checked=!1,this.buttons.pause.disabled=!0,this.buttons.restart.disabled=!0,this.reset(),this.etgraph.render(),this.atgraph.render(),this.mtn.render(),createjs.Ticker.addEventListener("tick",function(e){_this9.mtn.tick(_this9.etgraph,_this9.atgraph),_this9.etstage.update(),_this9.atstage.update(),_this9.mainstage.update()})}}]),MtnSim}(),mtnsim=new MtnSim;mtnsim.render()},{"../utils":4}],2:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i=this.originY&&v<=this.originY+this.h:v>=this.originX&&v<=this.originY+this.w}}]),Axis}()},{}],3:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i=this.xaxis.min&&xv<=this.xaxis.max&&yv>=this.yaxis.min&&yv<=this.yaxis.max){var x=this.xaxis.getLoc(xv),y=this.yaxis.getLoc(yv);this.last&&(this.moveMarker(this.last.x,this.last.y),this.drawLine(this.last.x,this.last.y,x,y)),this.last=new createjs.Point(x,y),this.moveMarker(x,y)}}},{key:"endPlot",value:function(){this.last=null}}]),Graph}()},{"./axis":2}],4:[function(require,module,exports){"use strict";function getParams(){var params={};return location.search&&location.search.slice(1).split("&").forEach(function(part){var pair=part.split("=");pair[0]=decodeURIComponent(pair[0]),pair[1]=decodeURIComponent(pair[1]),params[pair[0]]="undefined"!==pair[1]?pair[1]:!0}),params}function getStore(){return store.enabled?store:void alert('Local storage is not supported by your browser. Please disable "Private Mode", or upgrade to a modern browser.')}Object.defineProperty(exports,"__esModule",{value:!0});var _graph=require("./graph");Object.defineProperty(exports,"Graph",{enumerable:!0,get:function(){return _graph.Graph}}),exports.getParams=getParams,exports.getStore=getStore;var store=(require("./json2"),require("./store"))},{"./graph":3,"./json2":5,"./store":6}],5:[function(require,module,exports){"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj};"object"!==("undefined"==typeof JSON?"undefined":_typeof(JSON))&&(JSON={}),function(){function f(n){return 10>n?"0"+n:n}function this_value(){return this.valueOf()}function quote(string){return rx_escapable.lastIndex=0,rx_escapable.test(string)?'"'+string.replace(rx_escapable,function(a){var c=meta[a];return"string"==typeof c?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,partial,mind=gap,value=holder[key];switch(value&&"object"===("undefined"==typeof value?"undefined":_typeof(value))&&"function"==typeof value.toJSON&&(value=value.toJSON(key)),"function"==typeof rep&&(value=rep.call(holder,key,value)),"undefined"==typeof value?"undefined":_typeof(value)){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value)return"null";if(gap+=indent,partial=[],"[object Array]"===Object.prototype.toString.apply(value)){for(length=value.length,i=0;length>i;i+=1)partial[i]=str(i,value)||"null";return v=0===partial.length?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]",gap=mind,v}if(rep&&"object"===("undefined"==typeof rep?"undefined":_typeof(rep)))for(length=rep.length,i=0;length>i;i+=1)"string"==typeof rep[i]&&(k=rep[i],v=str(k,value),v&&partial.push(quote(k)+(gap?": ":":")+v));else for(k in value)Object.prototype.hasOwnProperty.call(value,k)&&(v=str(k,value),v&&partial.push(quote(k)+(gap?": ":":")+v));return v=0===partial.length?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}",gap=mind,v}}var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value);var gap,indent,meta,rep;"function"!=typeof JSON.stringify&&(meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(value,replacer,space){var i;if(gap="",indent="","number"==typeof space)for(i=0;space>i;i+=1)indent+=" ";else"string"==typeof space&&(indent=space);if(rep=replacer,replacer&&"function"!=typeof replacer&&("object"!==("undefined"==typeof replacer?"undefined":_typeof(replacer))||"number"!=typeof replacer.length))throw new Error("JSON.stringify");return str("",{"":value})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(holder,key){var k,v,value=holder[key];if(value&&"object"===("undefined"==typeof value?"undefined":_typeof(value)))for(k in value)Object.prototype.hasOwnProperty.call(value,k)&&(v=walk(value,k),void 0!==v?value[k]=v:delete value[k]);return reviver.call(holder,key,value)}var j;if(text=String(text),rx_dangerous.lastIndex=0,rx_dangerous.test(text)&&(text=text.replace(rx_dangerous,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),rx_one.test(text.replace(rx_two,"@").replace(rx_three,"]").replace(rx_four,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}()},{}],6:[function(require,module,exports){(function(global){"use strict";module.exports=function(){function isLocalStorageNameSupported(){try{return localStorageName in win&&win[localStorageName]}catch(err){return!1}}var storage,store={},win="undefined"!=typeof window?window:global,doc=win.document,localStorageName="localStorage",scriptTag="script";if(store.disabled=!1,store.version="1.3.20",store.set=function(key,value){},store.get=function(key,defaultVal){},store.has=function(key){return void 0!==store.get(key)},store.remove=function(key){},store.clear=function(){},store.transact=function(key,defaultVal,transactionFn){null==transactionFn&&(transactionFn=defaultVal,defaultVal=null),null==defaultVal&&(defaultVal={});var val=store.get(key,defaultVal);transactionFn(val),store.set(key,val)},store.getAll=function(){var ret={};return store.forEach(function(key,val){ret[key]=val}),ret},store.forEach=function(){},store.serialize=function(value){return JSON.stringify(value)},store.deserialize=function(value){if("string"==typeof value)try{return JSON.parse(value)}catch(e){return value||void 0}},isLocalStorageNameSupported())storage=win[localStorageName],store.set=function(key,val){return void 0===val?store.remove(key):(storage.setItem(key,store.serialize(val)),val)},store.get=function(key,defaultVal){var val=store.deserialize(storage.getItem(key));return void 0===val?defaultVal:val},store.remove=function(key){storage.removeItem(key)},store.clear=function(){storage.clear()},store.forEach=function(callback){for(var i=0;idocument.w=window'),storageContainer.close(),storageOwner=storageContainer.w.frames[0].document,storage=storageOwner.createElement("div")}catch(e){storage=doc.createElement("div"),storageOwner=doc.body}var withIEStorage=function(storeFunction){return function(){var args=Array.prototype.slice.call(arguments,0);args.unshift(storage),storageOwner.appendChild(storage),storage.addBehavior("#default#userData"),storage.load(localStorageName);var result=storeFunction.apply(store,args);return storageOwner.removeChild(storage),result}},forbiddenCharsRegex=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g"),ieKeyFix=function(key){return key.replace(/^d/,"___$&").replace(forbiddenCharsRegex,"___")};store.set=withIEStorage(function(storage,key,val){return key=ieKeyFix(key),void 0===val?store.remove(key):(storage.setAttribute(key,store.serialize(val)),storage.save(localStorageName),val)}),store.get=withIEStorage(function(storage,key,defaultVal){key=ieKeyFix(key);var val=store.deserialize(storage.getAttribute(key));return void 0===val?defaultVal:val}),store.remove=withIEStorage(function(storage,key){key=ieKeyFix(key),storage.removeAttribute(key),storage.save(localStorageName)}),store.clear=withIEStorage(function(storage){var attributes=storage.XMLDocument.documentElement.attributes;storage.load(localStorageName);for(var i=attributes.length-1;i>=0;i--)storage.removeAttribute(attributes[i].name);storage.save(localStorageName)}),store.forEach=withIEStorage(function(storage,callback){for(var attr,attributes=storage.XMLDocument.documentElement.attributes,i=0;attr=attributes[i];++i)callback(attr.name,store.deserialize(storage.getAttribute(attr.name)))})}try{var testKey="__storejs__";store.set(testKey,testKey),store.get(testKey)!=testKey&&(store.disabled=!0),store.remove(testKey)}catch(e){store.disabled=!0}return store.enabled=!store.disabled,store}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]); \ No newline at end of file +!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o0?tr.appendChild(getCol(json.cloudbase)):tr.appendChild(document.createElement("td").appendChild(document.createTextNode("Clear"))),tr.appendChild(getDelete(row)),tr}var _get=function get(object,property,receiver){null===object&&(object=Function.prototype);var desc=Object.getOwnPropertyDescriptor(object,property);if(void 0===desc){var parent=Object.getPrototypeOf(object);return null===parent?void 0:get(parent,property,receiver)}if("value"in desc)return desc.value;var getter=desc.get;if(void 0!==getter)return getter.call(receiver)},_createClass=function(){function defineProperties(target,props){for(var i=0;it;t++)this.plot(t,icesaturation(t));for(var t=0;tsat&&(this.vapor=sat,updateSettings===!0&&(this.settings.setTemp(this.temp),this.settings.setVapor(sat)));var x=this.xaxis.getLoc(this.temp),y=this.yaxis.getLoc(this.vapor);this.marker.x=x-2,this.marker.y=y-2,updateSettings===!0&&this.moveLeaf(x,y)}},{key:"update",value:function(trial){this.temp=trial.temp,this.vapor=trial.vapor,this.plot(trial.temp,trial.vapor),this.moveMarker(!1),this.showLeaf()}}]),ETGraph}(_utils.Graph),ATGraph=function(_Graph2){function ATGraph(stage){_classCallCheck(this,ATGraph);var _this3=_possibleConstructorReturn(this,Object.getPrototypeOf(ATGraph).call(this,{stage:stage,w:200,h:200,xlabel:"Temperature(C)",ylabel:"Altitude(km)",xscale:"linear",yscale:"linear",minX:-20,maxX:30,minY:0,maxY:5,majorX:10,minorX:5,majorY:1,minorY:.5}));return _this3.temp=20,_this3.altitude=0,_this3.cloudbase=0,_this3}return _inherits(ATGraph,_Graph2),_createClass(ATGraph,[{key:"update",value:function(trial){this.plot(trial.temp,trial.altitude)}}]),ATGraph}(_utils.Graph),IceGraph=function(_Graph3){function IceGraph(stage){_classCallCheck(this,IceGraph);var _this4=_possibleConstructorReturn(this,Object.getPrototypeOf(IceGraph).call(this,{stage:stage,x:60,y:110,w:75,h:100,xlabel:"C",xscale:"linear",yscale:"linear",minX:-15,maxX:1,minY:1,maxY:5,majorX:5,majorY:1,background:"#EEE"})),liquid=new createjs.Text("Liquid","10px Arial","#000");liquid.x=65,liquid.y=40,stage.addChild(liquid);var ice=new createjs.Text("Ice","10px Arial","#000");return ice.x=90,ice.y=70,stage.addChild(ice),_this4}return _inherits(IceGraph,_Graph3),_createClass(IceGraph,[{key:"render",value:function(){_get(Object.getPrototypeOf(IceGraph.prototype),"render",this).call(this);for(var t=this.xaxis.min;t<=this.xaxis.max;t++)this.plot(t,saturation(t));this.endPlot();for(var t=this.xaxis.min;t<=this.xaxis.max;t++)this.plot(t,icesaturation(t));this.endPlot()}}]),IceGraph}(_utils.Graph),Mtn=function(){function Mtn(stage,settings,finish){var _this5=this;_classCallCheck(this,Mtn),this.stage=stage,this.settings=settings,this.finish=finish,createjs.Sound.registerSound({id:"thunder",src:"assets/thunder.mp3"}),createjs.Sound.registerSound({id:"wind",src:"assets/wind.mp3"}),this.wind=null,this.thunder=null,this.mtn=new createjs.Bitmap("assets/mountain.png"),this.leaf=new createjs.Bitmap("assets/leaf.gif"),this.cloud=new createjs.Bitmap("assets/thundercloud.png"),this.bolt=new createjs.Bitmap("assets/lightning.png"),this.leaftween=null,this.mtn.x=0,this.mtn.y=0,this.mtn.scaleX=.5,this.mtn.scaleY=.5,this.bolt.x=-100,this.bolt.scaleX=.015,this.bolt.scaleY=.015,this.running=!1,this.lightning=!1,this.lighttick=0,this.path=[50,164,60,155,74,152,80,140,90,131,100,125,112,122,120,110,137,92,140,75,151,64,150,60,173,56,185,60,204,70,210,80,221,92,221,95,224,105,230,110,246,121,250,130,268,141,280,150,290,164],this.results=document.getElementById("results_table"),document.getElementById("delete_all").addEventListener("click",function(event){confirm("Delete all data?")&&_this5.deleteResults()}),this.trial=new Trial,this.showResults()}return _createClass(Mtn,[{key:"render",value:function(){this.stage.addChild(this.mtn),this.stage.addChild(this.leaf),this.stage.addChild(this.cloud),this.stage.addChild(this.bolt),this.leaf.x=50,this.leaf.y=165,this.cloud.x=-1e3,this.cloud.y=0,this.lastalt=0,this.cloud.scaleX=.1,this.cloud.scaleY=.05}},{key:"clear",value:function(){this.stage.removeAllChildren(),this.render()}},{key:"play",value:function(){var _this6=this;this.temp=this.settings.getTemp(),this.vapor=this.settings.getVapor(),this.trial.init({temp:this.temp,vapor:this.vapor,humidity:humidity(this.temp,this.vapor),dewpoint:dewpoint(this.temp,this.vapor)}),this.factor=10,this.lastalt=0,this.leaftween=createjs.Tween.get(this.leaf).to({guide:{path:this.path}},12e3),this.leaftween.call(function(){_this6.wind&&_this6.wind.stop(),_this6.running=!1,_this6.addTrial(),_this6.finish&&_this6.finish()}),this.running=!0,this.leaftween.play(),this.playSound("wind")}},{key:"showResults",value:function(){for(var _this7=this,i=this.results.children.length-1;i>1;i--)this.results.removeChild(this.results.children[i]);var trials=store.get(mtnsim_results);trials?trials.forEach(function(json){return _this7.results.appendChild(getRow(json))}):store.set(mtnsim_results,[])}},{key:"addTrial",value:function(){var trials=store.get(mtnsim_results),json=this.trial.toJSON();store.set(mtnsim_results,trials.concat(json)),this.results.appendChild(getRow(json))}},{key:"deleteTrial",value:function(row){var trials=store.get(mtnsim_results);trials.splice(row,1),store.set(mtnsim_results,trials),this.showResults()}},{key:"deleteResults",value:function(){store.set(mtnsim_results,[]),this.showResults()}},{key:"pause",value:function(_pause){this.leaftween.setPaused(_pause),this.wind&&(this.wind.paused=_pause),this.thunder&&(this.thunder.paused=_pause),this.running=!_pause}},{key:"playSound",value:function(sound){if(!this.settings.mute.checked)switch(sound){case"wind":this.wind=createjs.Sound.play(sound,{loop:2});break;case"thunder":this.thunder=createjs.Sound.play(sound)}}},{key:"update",value:function(trial){var oldA=trial.altitude,oldT=trial.temp;trial.altitude=(165-this.leaf.y)/165*5,trial.altitude<0&&(trial.altitude=0),trial.temp=Number(oldT-this.factor*(trial.altitude-oldA)),trial.humidity=humidity(trial.temp,trial.vapor),trial.dewpoint=dewpoint(trial.temp,trial.vapor);var sat=saturation(trial.temp);trial.vapor>sat&&(this.animateClouds(),trial.vapor=sat,trial.humidity=100,this.factor=6),trial.temp>oldT&&(this.factor=10)}},{key:"animateClouds",value:function(){0==this.trial.cloudbase&&(this.trial.cloudbase=this.trial.altitude,this.cloud.x=this.leaf.x-2,this.cloud.y=this.leaf.y,this.bolt.y=this.cloud.y+20,this.lasty=this.leaf.y),this.trial.altitude-this.lastalt>.1&&(this.lastalt=this.trial.altitude,this.cloud.scaleX+=.021,this.cloud.scaleY+=.02,this.cloud.y=this.leaf.y),!this.lightning&&this.leaf.x<140&&this.trial.temp<=-5&&this.trial.altitude-this.trial.cloudbase>.5&&(this.lighttick=0,this.lightning=!0)}},{key:"newTrial",value:function(){this.trial=new Trial}},{key:"tick",value:function(etgraph,atgraph){if(this.running===!0&&(this.update(this.trial),etgraph.update(this.trial),atgraph.update(this.trial),this.lightning===!0)){switch(this.lighttick){case 0:this.bolt.x=this.cloud.x+10;break;case 5:this.bolt.x+=10;break;case 7:this.bolt.x+=10;break;case 10:this.bolt.x=-100;break;case 60:this.playSound("thunder"),this.lightning=!1}this.lighttick++}}}]),Mtn}(),MtnSim=function(){function MtnSim(){var _this8=this;_classCallCheck(this,MtnSim),this.mainstage=new createjs.Stage("maincanvas"),this.etstage=new createjs.Stage("etgraph"),this.atstage=new createjs.Stage("atgraph"),this.buttons=new Buttons,this.settings=new Settings,this.etgraph=new ETGraph(this.etstage,this.settings),this.atgraph=new ATGraph(this.atstage),this.mtn=new Mtn(this.mainstage,this.settings,function(){_this8.buttons.restart.disabled=!1,_this8.buttons.pause.disabled=!0}),this.pause=!1,this.buttons.addListener(function(e){switch(e.target.id){case"run":_this8.enablePlay(!1),_this8.buttons.pause.value="Pause",_this8.pause=!1,_this8.mtn.play();break;case"pause":_this8.pause=!_this8.pause,_this8.mtn.pause(_this8.pause),e.target.value=_this8.pause?"Resume":"Pause";break;case"restart":_this8.reset(),_this8.mtn.clear(),_this8.etgraph.clear(),_this8.atgraph.clear(),_this8.etgraph.render(),_this8.atgraph.render(),_this8.mtn.newTrial()}})}return _createClass(MtnSim,[{key:"reset",value:function(){this.enablePlay(!0)}},{key:"enablePlay",value:function(play){this.buttons.run.disabled=!play,this.buttons.pause.disabled=play,this.buttons.restart.disabled=!play}},{key:"render",value:function(){var _this9=this;this.buttons.run.disabled=!1,this.buttons.mute.checked=!1,this.buttons.pause.disabled=!0,this.buttons.restart.disabled=!0,this.reset(),this.etgraph.render(),this.atgraph.render(),this.mtn.render(),createjs.Ticker.addEventListener("tick",function(e){_this9.mtn.tick(_this9.etgraph,_this9.atgraph),_this9.etstage.update(),_this9.atstage.update(),_this9.mainstage.update()})}}]),MtnSim}(),mtnsim=new MtnSim;mtnsim.render()},{"../utils":4}],2:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i=this.originY&&v<=this.originY+this.h:v>=this.originX&&v<=this.originY+this.w}}]),Axis}()},{}],3:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i=this.xaxis.min&&xv<=this.xaxis.max&&yv>=this.yaxis.min&&yv<=this.yaxis.max){var x=this.xaxis.getLoc(xv),y=this.yaxis.getLoc(yv);this.last&&(this.moveMarker(this.last.x,this.last.y),this.drawLine(this.last.x,this.last.y,x,y)),this.last=new createjs.Point(x,y),this.moveMarker(x,y)}}},{key:"endPlot",value:function(){this.last=null}}]),Graph}()},{"./axis":2}],4:[function(require,module,exports){"use strict";function getParams(){var params={};return location.search&&location.search.slice(1).split("&").forEach(function(part){var pair=part.split("=");pair[0]=decodeURIComponent(pair[0]),pair[1]=decodeURIComponent(pair[1]),params[pair[0]]="undefined"!==pair[1]?pair[1]:!0}),params}function getStore(){return store.enabled?store:void alert('Local storage is not supported by your browser. Please disable "Private Mode", or upgrade to a modern browser.')}Object.defineProperty(exports,"__esModule",{value:!0});var _graph=require("./graph");Object.defineProperty(exports,"Graph",{enumerable:!0,get:function(){return _graph.Graph}}),exports.getParams=getParams,exports.getStore=getStore;var store=(require("./json2"),require("./store"))},{"./graph":3,"./json2":5,"./store":6}],5:[function(require,module,exports){"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj};"object"!==("undefined"==typeof JSON?"undefined":_typeof(JSON))&&(JSON={}),function(){function f(n){return 10>n?"0"+n:n}function this_value(){return this.valueOf()}function quote(string){return rx_escapable.lastIndex=0,rx_escapable.test(string)?'"'+string.replace(rx_escapable,function(a){var c=meta[a];return"string"==typeof c?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,partial,mind=gap,value=holder[key];switch(value&&"object"===("undefined"==typeof value?"undefined":_typeof(value))&&"function"==typeof value.toJSON&&(value=value.toJSON(key)),"function"==typeof rep&&(value=rep.call(holder,key,value)),"undefined"==typeof value?"undefined":_typeof(value)){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value)return"null";if(gap+=indent,partial=[],"[object Array]"===Object.prototype.toString.apply(value)){for(length=value.length,i=0;length>i;i+=1)partial[i]=str(i,value)||"null";return v=0===partial.length?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]",gap=mind,v}if(rep&&"object"===("undefined"==typeof rep?"undefined":_typeof(rep)))for(length=rep.length,i=0;length>i;i+=1)"string"==typeof rep[i]&&(k=rep[i],v=str(k,value),v&&partial.push(quote(k)+(gap?": ":":")+v));else for(k in value)Object.prototype.hasOwnProperty.call(value,k)&&(v=str(k,value),v&&partial.push(quote(k)+(gap?": ":":")+v));return v=0===partial.length?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}",gap=mind,v}}var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value);var gap,indent,meta,rep;"function"!=typeof JSON.stringify&&(meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(value,replacer,space){var i;if(gap="",indent="","number"==typeof space)for(i=0;space>i;i+=1)indent+=" ";else"string"==typeof space&&(indent=space);if(rep=replacer,replacer&&"function"!=typeof replacer&&("object"!==("undefined"==typeof replacer?"undefined":_typeof(replacer))||"number"!=typeof replacer.length))throw new Error("JSON.stringify");return str("",{"":value})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(holder,key){var k,v,value=holder[key];if(value&&"object"===("undefined"==typeof value?"undefined":_typeof(value)))for(k in value)Object.prototype.hasOwnProperty.call(value,k)&&(v=walk(value,k),void 0!==v?value[k]=v:delete value[k]);return reviver.call(holder,key,value)}var j;if(text=String(text),rx_dangerous.lastIndex=0,rx_dangerous.test(text)&&(text=text.replace(rx_dangerous,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),rx_one.test(text.replace(rx_two,"@").replace(rx_three,"]").replace(rx_four,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}()},{}],6:[function(require,module,exports){(function(global){"use strict";module.exports=function(){function isLocalStorageNameSupported(){try{return localStorageName in win&&win[localStorageName]}catch(err){return!1}}var storage,store={},win="undefined"!=typeof window?window:global,doc=win.document,localStorageName="localStorage",scriptTag="script";if(store.disabled=!1,store.version="1.3.20",store.set=function(key,value){},store.get=function(key,defaultVal){},store.has=function(key){return void 0!==store.get(key)},store.remove=function(key){},store.clear=function(){},store.transact=function(key,defaultVal,transactionFn){null==transactionFn&&(transactionFn=defaultVal,defaultVal=null),null==defaultVal&&(defaultVal={});var val=store.get(key,defaultVal);transactionFn(val),store.set(key,val)},store.getAll=function(){var ret={};return store.forEach(function(key,val){ret[key]=val}),ret},store.forEach=function(){},store.serialize=function(value){return JSON.stringify(value)},store.deserialize=function(value){if("string"==typeof value)try{return JSON.parse(value)}catch(e){return value||void 0}},isLocalStorageNameSupported())storage=win[localStorageName],store.set=function(key,val){return void 0===val?store.remove(key):(storage.setItem(key,store.serialize(val)),val)},store.get=function(key,defaultVal){var val=store.deserialize(storage.getItem(key));return void 0===val?defaultVal:val},store.remove=function(key){storage.removeItem(key)},store.clear=function(){storage.clear()},store.forEach=function(callback){for(var i=0;idocument.w=window'),storageContainer.close(),storageOwner=storageContainer.w.frames[0].document,storage=storageOwner.createElement("div")}catch(e){storage=doc.createElement("div"),storageOwner=doc.body}var withIEStorage=function(storeFunction){return function(){var args=Array.prototype.slice.call(arguments,0);args.unshift(storage),storageOwner.appendChild(storage),storage.addBehavior("#default#userData"),storage.load(localStorageName);var result=storeFunction.apply(store,args);return storageOwner.removeChild(storage),result}},forbiddenCharsRegex=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g"),ieKeyFix=function(key){return key.replace(/^d/,"___$&").replace(forbiddenCharsRegex,"___")};store.set=withIEStorage(function(storage,key,val){return key=ieKeyFix(key),void 0===val?store.remove(key):(storage.setAttribute(key,store.serialize(val)),storage.save(localStorageName),val)}),store.get=withIEStorage(function(storage,key,defaultVal){key=ieKeyFix(key);var val=store.deserialize(storage.getAttribute(key));return void 0===val?defaultVal:val}),store.remove=withIEStorage(function(storage,key){key=ieKeyFix(key),storage.removeAttribute(key),storage.save(localStorageName)}),store.clear=withIEStorage(function(storage){var attributes=storage.XMLDocument.documentElement.attributes;storage.load(localStorageName);for(var i=attributes.length-1;i>=0;i--)storage.removeAttribute(attributes[i].name);storage.save(localStorageName)}),store.forEach=withIEStorage(function(storage,callback){for(var attr,attributes=storage.XMLDocument.documentElement.attributes,i=0;attr=attributes[i];++i)callback(attr.name,store.deserialize(storage.getAttribute(attr.name)))})}try{var testKey="__storejs__";store.set(testKey,testKey),store.get(testKey)!=testKey&&(store.disabled=!0),store.remove(testKey)}catch(e){store.disabled=!0}return store.enabled=!store.disabled,store}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]); \ No newline at end of file