var project={"_id":"569e733ede78eca41cc5a732","id":"c29cc4a466032831660aac9bedd9347b56c62be3","name":"Population Growth of China","user":"566ac9850286a8f9080cdd79","description":"A simple line chart of the population of China since 1960 using World Bank API","created":"2016-01-19T16:40:33.860Z","shared":false,"server":"micro","datafiles":[{"file":{"link":"http://api.worldbank.org/countries/cn/indicators/SP.POP.TOTL?format=json&per_page=100","type":"URL/API","url":"http://api.worldbank.org/countries/cn/indicators/SP.POP.TOTL?format=json&per_page=100","message":{"error":false,"text":""}},"varname":"population","title":"Population Total","activated":true,"name":"datafile","linkedtofile":true,"optional":true,"content":"","sendtojs":true}],"packs":["highcharts","jquery"],"container":"mainpart","js":{"file":{"type":"","url":"","link":"","message":{"error":true,"text":"File not defined"},"depurl":"https://quipslib.s3.amazonaws.com/prod/c29cc4a466032831660aac9bedd9347b56c62be3/script.js"},"title":"Javascript","activated":true,"name":"js","linkedtofile":false,"optional":true,"content":"\nvar options={\n chart:{\n animation:false\n },\n title: {\n text: \"Population of \"+population[1][0].country.value\n },\n subtitle: {\n text: 'Source: World Bank'\n },\n xAxis: {\n categories: []\n },\n yAxis: {\n title: {\n text: 'Population'\n }\n },\n series: [{\n name: population[1][0].country.value,\n data: []\n }]\n }\n \n\n\n$(document).ready(function(){\n $(population[1].reverse()).each(function(i,row){\n if (row.value!=null) {\n options.xAxis.categories.push(row.date)\n options.series[0].data.push(Number(row.value))\n }\n \n })\n\n $('#container').highcharts(options);\n\n})\n"},"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://quipslib.s3.amazonaws.com/prod/c29cc4a466032831660aac9bedd9347b56c62be3/main.jade"},"title":"Jade","activated":true,"name":"jade","linkedtofile":false,"optional":false,"content":"#container(style=\"width:600px;height:300px\")"},"deploydate":"2016-02-13T03:24:08.748Z","capture":"https://quipslib.s3.amazonaws.com/prod/c29cc4a466032831660aac9bedd9347b56c62be3/capture.png","prod":true,"published":"2016-01-19T17:32:35.598Z","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"}],"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]() } } }) }