d3.select("li#evento").style("background-color","#cedeef"); var li = d3.select("article.label","ul").selectAll("li"); var img_path = " #path ../../cal/img/"; var json_path = " #data admin/event/json/"; /* menu hide and show edit window*/ li.on("click",function(){ li.style("background-color","#e6eeff"); d3.select(this).style("background-color","#cedeef"); d3.selectAll("div.ehide").style("display","none"); d3.select( "div#"+d3.select(this).attr("value") ).style("display","block"); }); /*preview event image*/ function updateImage(){ var iname=d3.select("select#eimg").node().value; if(iname != 0){ d3.select("div#esimg").style("background-image","url("+img_path+iname+")");} else{ d3.select("div#esimg").style("background-image","none"); } } d3.select("select#eimg").on("change",updateImage); /*preload form contents for event*/ d3.select("select#eprev").on("change",function(){ var eprev_id=d3.select("select#eprev").node().value; d3.json( json_path+"qEvent.q&ecourse="+eprev_id ,function(d){ if(d[0] !=undefined) {if(d[0].cid != 0){ dropdownUpdate("ecourse",d[0].cid); dropdownUpdate("eplace",d[0].pid); d3.select("input#dini").attr("value",d[0].dini); dropdownUpdate("mini",d[0].mini); dropdownUpdate("yini",d[0].yini); d3.select("input#dend").attr("value",d[0].dend); dropdownUpdate("mend",d[0].mend); dropdownUpdate("yend",d[0].yend); d3.select("input#cost").attr("value",d[0].cost); d3.select("input#promo").attr("value",d[0].promo); d3.select("input#pen").attr("checked",d[0].pen); d3.select("input#een").attr("checked",d[0].een); dropdownUpdate("eimg",d[0].eimg); updateImage(); }} }); }); /*preload form content for course*/ d3.select("select#cprev").on("change",function(){ var cprev_id=d3.select("select#cprev").node().value; d3.json(json_path+"qCourse.q&course="+cprev_id ,function(d){ if(d[0]!=undefined){if(d[0].cid != 0){ d3.select("input#cname").attr("value",d[0].cname); d3.select("textarea#csubjects").text(d[0].csubjects); d3.select("textarea#cservices").text(d[0].cservices); }} }); }); /*preload form content for place*/ d3.select("select#pprev").on("change",function(){ var pprev_id=d3.select("select#pprev").node().value; d3.json(json_path+"qPlace.q&course="+pprev_id ,function(d){ if(d[0]!=undefined){if(d[0].pid != 0){ d3.select("input#pname").attr("value",d[0].pname); d3.select("input#paddr").attr("value",d[0].paddr); d3.select("input#pobs").attr("value",d[0].pobs); d3.select("input#pto").attr("value",d[0].pto); d3.select("input#pst").attr("value",d[0].pst); d3.select("input#pco").attr("value",d[0].pco); d3.select("input#plat").attr("value",d[0].plat); d3.select("input#plng").attr("value",d[0].plng); d3.select("input#pen").attr("checked",d[0].pen); }} }); }); /*support "selected" option on other drop down*/ function dropdownUpdate(name,value){ d3.select("select#"+name).selectAll("option").each(function(d,i) { d3.select(this).attr("selected",function(){ return this.value == value? "selected":null; }); }); }