var project={"_id":"5810be0316e67726d5d73e60","id":"df7f8cdaa57ae371a6099a66324b674087df5669","name":"Tsunami V2","user":"566ac9850286a8f9080cdd79","description":"","created":"2016-10-25T17:38:51.426Z","shared":false,"server":"micro","datafiles":[{"file":{"link":"https://s3.amazonaws.com/istarsshare/tsunamis.json","type":"URL/API","url":"https://s3.amazonaws.com/istarsshare/tsunamis.json","message":{"error":false,"text":""}},"varname":"airports","title":"Tsunamis in Airports","activated":true,"name":"datafile","linkedtofile":true,"optional":true,"content":"","sendtojs":true}],"packs":["highcharts","jquery","D3"],"container":"mainpart","js":{"file":{"type":"","url":"","link":"","message":{"error":true,"text":"File not defined"},"depurl":"https://quipslibistars.s3.amazonaws.com/prod/df7f8cdaa57ae371a6099a66324b674087df5669/script.js"},"title":"Javascript","activated":true,"name":"js","linkedtofile":false,"optional":true,"content":"var color=d3.scale.linear().\n domain([0,1,5,10,20,50])\n .range(['rgb(252,194,251)','rgb(254,121,236)','rgb(158,126,233)',\n 'rgb(149,37,186)','rgb(137,27,155)','rgb(81,56,134)']);\n\nfunction draw(){\n var tsus={}\n $(airports).each(function(i,v){\n var n=v.airportName+\" (\"+v.airportCode+\"), \"+v.countryName+\" - \"+v.nb_tsunamis\n if (n.length>40) {\n n=v.airportName.substring(0,v.airportName.length-(n.length-40))+\"... (\"+v.airportCode+\"), \"+v.countryName+\" - \"+v.nb_tsunamis\n }\n chart.yAxis.categories.push(n)\n $(v.tsunamis).each(function(k,u){\n if (!tsus[u.id]) {\n tsus[u.id]={name:u.name+\" (\"+u.country+\"), \"+u.date.substring(0,10),data:[]}\n }\n\n tsus[u.id].data.push({\n color:color(u.height),\n x:u.distance,y:i,z:u.height,\n distance:Math.round(u.distance),date:u.date.substring(0,10)\n })\n \n })\n })\n for (var key in tsus) {\n chart.series.push(tsus[key])\n }\n\n $(\"#chart\").highcharts(chart)\n}\n\n\n\nvar chart={\n\n chart: {\n type: 'bubble',\n plotBorderWidth: 1,\n zoomType: 'xy'\n },\n credits:{\n enabled:false\n },\n\n legend: {\n enabled: false\n },\n\n title: {\n text: 'Tsunamis around International Aerodromes'\n },\n\n subtitle: {\n text: '30 most frequently exposed int. aerodromes between 1996 and 2016.
Source: ICAO and NOAA'\n },\n\n xAxis: {\n gridLineWidth: 1,\n title: {\n text: 'Distance from epicenter (km)'\n }\n \n },\n\n yAxis: {\n min:2,\n max:29,\n categories:[],\n title: {\n text: ''\n }\n \n },\n plotOptions:{\n bubble:{\n minSize:1,\n maxSize:30 \n }\n },\ntooltip: {\n useHTML: true,\n headerFormat: '
',\n pointFormat: 'Tsunami
{series.name}
Height: {point.y}m
Distance: {point.distance}km',\n footerFormat: '
',\n followPointer: true\n },\n series: []\n\n };\n\ndraw()"},"css":{"file":{"type":"","url":"","link":"","message":{"error":true,"text":"File not defined"}},"title":"Cascading Style Sheet (CSS)","activated":false,"name":"css","linkedtofile":false,"optional":true},"jade":{"file":{"type":"","url":"","link":"","message":{"error":true,"text":"File not defined"},"depurl":"https://quipslibistars.s3.amazonaws.com/prod/df7f8cdaa57ae371a6099a66324b674087df5669/main.jade"},"title":"Jade","activated":true,"name":"jade","linkedtofile":false,"optional":false,"content":"#chart(style=\"width:800px;height:800px\")"},"sharedwith":["57dfeb1654955f1127d5672b"],"morejs":[{"url":"https://code.highcharts.com/highcharts-more.js"}],"capture":"https://quipslibistars.s3.amazonaws.com/prod/df7f8cdaa57ae371a6099a66324b674087df5669/capture.png","prod":true,"deploydate":"2016-10-26T19:53:43.404Z","libs":[{"_id":"5672b2dbf36b083214f3e63c","description":"","key":"","version":"4.2.0","link":"https://code.highcharts.com/highcharts.js","name":"highcharts","__v":0,"haskey":false,"required":false,"website":"Highcharts.com"},{"_id":"5672b602f36b083214f3e63e","description":"The Write Less, Do More, JavaScript Library","key":"","version":"2.1.1","link":"https://code.jquery.com/jquery-2.1.4.js","name":"jquery","__v":0,"required":true,"haskey":false,"website":"https://jquery.com"},{"_id":"568c42d091ce286c15af73fd","required":false,"description":"A JavaScript library for visualizing data with HTML, SVG and CSS.","haskey":false,"version":"3","link":"//d3js.org/d3.v3.min.js,//d3js.org/topojson.v0.min.js","name":"D3","__v":0,"website":"http://d3js.org"}],"host":"https://quips.anbdata.com","version":"prod"} function loadjquery(url,callback) { if(typeof jQuery=='undefined') { loadScript(url,callback) } else { callback() } } function loadScript(url, callback) { var script = document.createElement("script") script.type = "text/javascript"; if (script.readyState) { //IE script.onreadystatechange = function () { if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null; callback(); } }; } else { //Others script.onload = function () { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } (function () { loadjquery("https://code.jquery.com/jquery-2.1.4.js", function () { //jQuery loaded $("#"+project.container).html("") var libs=[] $(project.libs).each(function(i,v){ if (v.name!="jquery") { $(v.link.split(",")).each(function(j,u){ if (u.slice(-2)=="js") { libs.push(u+(v.haskey?"?key="+project[v.name+"key"]:"")) } else { $("head").append("") } }) } }) if (project.morejs) { $(project.morejs).each(function(i,v){ if ((v.url.substring(0,2)=="//")||(v.url.substring(0,8)=="https://")||(v.url.substring(0,7)=="http://")) { libs.push(v.url) } }) } if (project.morecss) { $(project.morecss).each(function(i,v){ $("head").append("") }) } loadlibs(libs.reverse()) }); })(); function loadlibs(libs){ if (libs.length>0) { var l=libs.pop() loadScript(l,function(){ //$.getScript(l,function(res){ loadlibs(libs) }) //.fail(function(e){ // loadlibs(libs) // //}) } else { start() } } function putscriptcontent(content){ var script = document.createElement("script") script.type = "text/javascript"; $(script).text(content) document.getElementsByTagName("head")[0].appendChild(script); } function start(){ //load jade $.getJSON(project.host+"/project/"+project.version+"/"+project.id+"/render?callback=?"+(project.datachange?"&data="+project.datachange:""),function(res){ $("#"+project.container).html(res.html) if (project.css.activated) { if (project.css.linkedtofile) { $("head").append("")} else { $("head").append("")} } if (project.js.activated) { if (project.js.linkedtofile) { $.getScript(project.js.file[(project.prod?"depurl":"url")])} else { putscriptcontent(project.js.content)} if (project.mainjs) { window[project.mainjs]() } } }) }