<?xml version="1.0" encoding="UTF-8"?>
<Module>
  <ModulePrefs title="__MSG_title__"
	       description="__MSG_description__"
	       author="Wenchao Tong"
	       author_email="tongwenchao+klue@gmail.com"
	       author_affiliation="Google Shanghai"
	       author_location="Shanghai, China"
	       scrolling="true">
    <Require feature="sharedmap"/>
    <Require feature="dynamic-height"/>
    <Locale messages="http://eventlet.appspot.com/mapplet/klue/ALL_ALL.xml" />
    <Locale lang="en" messages="http://eventlet.appspot.com/mapplet/klue/en_ALL.xml" />
  </ModulePrefs>
  <Content type="html">
    <![CDATA[
    <style>tr{font-size:10pt}label.eventitem{cursor:pointer;text-decoration:underline;color:#00f}td.category{background-color:#e5ecf9;height:1.4em;font-size:1.2em;padding-left:.3em}span.startdate{font-size:.7em;color:grey;white-space:nowrap}span.ongoing{font-size:.7em;color:grey}a{cursor:pointer;text-decoration:underline;color:#00f}a.more{font-size:.8em;color:green}</style>

    <div id="klue_main"></div>
    <div id="klue_category" style="display: none;"></div>
    <div><i><a href='__MSG_provider_url__' target='_blank'>__MSG_provider__</a></i></div>

    <script>var klue={};klue.Coordinate={CENTER_LAT:4.094203,CENTER_LNG:101.583276,NE_LAT:15.3944,NE_LNG:117.531112,SW_LAT:4.123774,SW_LNG:101.583276};klue.NIGHTLIFE="Nightlife";klue.FILM="Film";klue.Zoom={CENTER:6,EVENT:10};klue.REFRESH_INTERNAL=1800;klue.JSON_URL="__MSG_json_url__";klue.eventIdDict={};klue.eventTypeDict={};klue.currentCategory="all";klue.ONGOING_RANGE=2592000000;
klue.Event=function(a){this.title=a.title;this.description=a.description;this.price=a.price;this.date=a.date;this.category=a.category;this.address=a.address;this.contact=a.contact;this.email=a.email;this.train=a.train;this.venue=a.venue;this.endDate=a.endDate;this.startDate=a.startDate;this.guid=a.guid;this.latitude=a.latitude;this.longitude=a.longitude;var b=this.startDate.split("-"),d=this.endDate.split("-"),c=new Date(parseInt(b[0],10),parseInt(b[1],10)-1,parseInt(b[2],10)),e=new Date(parseInt(d[0],
10),parseInt(d[1],10)-1,parseInt(d[2],10));this.ongoing=Math.abs(e.getTime()-c.getTime())>klue.ONGOING_RANGE};
klue.Event.prototype.b=function(){var a=[];a.push('<div style="width: 400px; border: 1px solid rgb(213, 221, 243); ','margin-bottom: 3px;">','<div style="padding: 4px; background-color: rgb(232, 236, 249); ','margin-bottom: 3px; color: rgb(0, 0, 0); font-weight: bold;">');a.push('<a href="',this.guid,'" target="_blank">',this.title,"</a>","</div>");a.push('<span style="font-size:12px;">');this.description&&a.push('<div style="padding: 4px; margin-bottom: 3px;">',this.description,"</div>");this.price&&
a.push('<div style="padding: 4px; margin-bottom: 3px;">',this.price,"</div>");this.date&&a.push('<div style="padding: 4px; margin-bottom: 3px;">',this.date,"</div>");a.push('<div style="padding: 4px; margin-bottom: 3px;">',"__MSG_category__: ",this.category,"</div>");this.venue&&a.push('<div style="padding: 4px; margin-bottom: 3px;">',this.venue,"</div>");this.address&&this.address!="N/A"&&a.push('<div style="padding: 4px; margin-bottom: 3px;">',"__MSG_address__: ",this.address,"</div>");this.contact&&
this.contact!="N/A"&&a.push('<div style="padding: 4px; margin-bottom: 3px;">',"__MSG_contact__: ",this.contact,"</div>");this.email&&this.email!="N/A"&&a.push('<div style="padding: 4px; margin-bottom: 3px;">',"__MSG_email__: ",this.email,"</div>");this.train&&this.train!="N/A"&&a.push('<div style="padding: 4px; margin-bottom: 3px;">',"__MSG_train__: ",this.train,"</div>");a.push("</span></div>");return a.join("")};
klue.Event.prototype.c=function(){var a=new GLatLng(this.latitude,this.longitude),b=new GMarker(a);GEvent.bind(b,"click",this,function(){b.openInfoWindowHtml(this.b())});return b};klue.Event.prototype.a=function(a){return['<input type="checkbox" id="',a?"all":"",this.guid,'" onclick="klue.onClickEvent(\'',this.guid,"')\" />",'<label class="eventitem" for="',a?"all":"",this.guid,'" >',this.title,"</label>"].join("")};
klue.onClickEvent=function(a){var b=[],d=[],c=klue.currentCategory=="all"?"all":"";for(var e in klue.eventTypeDict[klue.currentCategory]){var f=klue.eventTypeDict[klue.currentCategory][e];if(_gel(c+f.guid).checked){b.push(f.guid);d.push(new GLatLng(f.latitude,f.longitude))}}klue.map.clearOverlays();for(var e in b){var f=klue.eventIdDict[b[e]],g=a==f.guid,i=f.c();klue.map.addOverlay(i);if(g){var h=new GLatLng(f.latitude,f.longitude);klue.map.setCenter(h);i.openInfoWindowHtml(f.b())}}};
klue.initMainData=function(a){var b=eval("("+a+")");klue.eventTypeDict.all=[];var d=[];for(var c in b)c!=klue.NIGHTLIFE&&c!=klue.FILM&&d.push(c);d.sort();d.push(klue.NIGHTLIFE);d.push(klue.FILM);var e=["<table>"];for(var f in d){var g=d[f];if(!(b[g]===undefined)){var i=b[g][0];e.push('<tr><td class="category"><b>',g,"</b></td></tr>");for(var c=1;c<b[g].length;c++){var h=new klue.Event(b[g][c]);if(!(h.latitude==null||h.longitude==null)){klue.eventIdDict[h.guid]=h;klue.eventTypeDict.all.push(h);e.push("<tr><td>",
h.a(true),' <span class="startdate">',klue.formatDateString(h.startDate),"</span>");h.ongoing&&e.push(' <span class="ongoing">Ongoing</span>');e.push("</td></tr>")}}i>5&&e.push("<tr><td><a onclick=\"klue.onClickMore('",g,'\')" class="more">',i-5," more >></a></td></tr>")}}e.push("</table>");_gel("klue_main").innerHTML=e.join("");_IG_AdjustIFrameHeight()};
klue.onClickMore=function(a){if(a==null)a=klue.currentCategory;else klue.currentCategory=a;var b=a=="all";_gel("klue_main").style.display=b?"block":"none";_gel("klue_category").style.display=b?"none":"block";if(b)for(var d in klue.eventTypeDict.all){var c=klue.eventTypeDict.all[d];_gel("all"+c.guid).checked=false}else if(klue.eventTypeDict[a]==null){_gel("klue_category").innerHTML="loading...";_IG_FetchContent(klue.JSON_URL+"?category="+escape(a),klue.loadCategory,{refreshInterval:klue.REFRESH_INTERVAL});
return}else klue.listCategory(a);_IG_AdjustIFrameHeight();klue.map.clearOverlays();klue.resetMap()};
klue.listCategory=function(a){var b=["<table><tr><td><a onclick=\"klue.onClickMore('all')\">","<< Back to Main List</a></td></tr>",'<tr><td class="category"><b>',a,"</b></td></tr>"];for(var d in klue.eventTypeDict[a]){var c=klue.eventTypeDict[a][d];b.push("<tr><td>",c.a(false),' <span class="startdate">',klue.formatDateString(c.startDate),"</span>");c.ongoing&&b.push(' <span class="ongoing">Ongoing</span>');b.push("</td></tr>")}b.push("</table>");_gel("klue_category").innerHTML=b.join("")};
klue.loadCategory=function(a){var b=eval("("+a+")");if(b.length==0){alert("The data feed has error.");klue.onClickMore("all")}klue.eventTypeDict[klue.currentCategory]=[];for(var d in b){var c=new klue.Event(b[d]);if(!(c.latitude==null||c.longitude==null)){klue.eventIdDict[c.guid]=c;klue.eventTypeDict[klue.currentCategory].push(c)}}klue.onClickMore(null)};
klue.resetMap=function(){klue.map.getCenterAsync(function(a){var b=new GLatLngBounds(new GLatLng(klue.Coordinate.SW_LAT,klue.Coordinate.SW_LNG),new GLatLng(klue.Coordinate.NE_LAT,klue.Coordinate.NE_LNG));b.contains(a)||klue.map.setCenter(new GLatLng(klue.Coordinate.CENTER_LAT,klue.Coordinate.CENTER_LNG),klue.Zoom.CENTER)})};
klue.formatDateString=function(a){var b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],d=a.split("-"),c=d[0],e=d[1],f=d[2],g=b[parseInt(e,10)-1];return[f,g,c].join(" ")};klue.main=function(){klue.map=new GMap2;klue.resetMap();_IG_FetchContent(klue.JSON_URL,klue.initMainData,{refreshInterval:klue.REFRESH_INTERVAL})};_IG_RegisterOnloadHandler(klue.main);</script>
    ]]>
  </Content>
</Module>
