text: var BGMapping=function(){function t(){var t=this;this.viewTeam="";this.isData=false;this.offset=0;this.marker=[];this.mapOption={zoom:16,center:new google.maps.LatLng(37.397983,140.388412),mapTypeId:google.maps.MapTypeId.ROADMAP,scrollwheel:true,scaleControl:true,panControl:true,zoomControl:true,mapTypeControl:true,streetViewControl:true,draggable:true};this.teamSetting=[];this.teamData=[];this.teamMarker=[];this.teamRoot=[];this.template={filterTeam:Cmn.dir+"/mus/filterTeam.mustache",fukudashi:Cmn.dir+"/mus/fukidashi.mustache",list:Cmn.dir+"/mus/backendList.mustache"};this.target={table:"#resultListBody",result:".resultList"};var e=this,a=$("#resultMap").get(0);e.areaMap=new google.maps.Map(a,e.mapOption);$.ajax({url:Cmn.dir+"/data/category.json",dataType:"json",type:"GET",async:false,success:function(e){t.category=e}});this.markerBounds=new google.maps.LatLngBounds;e.getEntryData();$(document).on("click",".jsClick-ModalImage",function(t){t.preventDefault();var e=$(this).data("image"),a=Frame.getBrowserWidth(),r=Frame.getBrowserHeight(),i='<img src="'+Cmn.dir+"/uploads/"+e+'" alt="">';$("#modal-contents").html(i);$("#modal").removeClass("hide")});$("#modal-bg").on("click",function(){$("#modal").addClass("hide");$("#modal-contents").html("")});$(document).on("change","#filter-team",function(){e.resultList.removeClass("hide");var t=$(this).val();if(t==="0"){e.viewTeam="";for(var a=0,r=e.marker.length;a<r;a++){var i=e.marker[a];i.setVisible(true)}}else{e.viewTeam=t;e.resultList.filter(function(e){var a=$(this),r=a.data("team");if(r!==t)a.addClass("hide")});for(var a=0,r=e.marker.length;a<r;a++){var i=e.marker[a],n=i.team;if(n===t){i.setVisible(true)}else{i.setVisible(false)}}}});$("#entryTotal-btn").on("click",function(t){t.preventDefault();$("#entryTotal-data").toggleClass("show")});$(document).on("click",".jsClick-Move",function(t){var a=$(this),r=a.data("lat"),i=a.data("lng"),n=new google.maps.LatLng(r,i);e.areaMap.setCenter(n);e.areaMap.setZoom(18)});setInterval(function(){e.getEntryData()},6e4);setInterval(function(){if(t.isData===false)return false;for(var e=0,a=t.resultList.length;e<a;e++){var r=$(t.resultList[e]),i=r.find(".created"),n=i.data("created"),s=t.getTimeDiff(n);i.text(s)}},1e4);setInterval(function(){$.ajax({url:Cmn.dir+"/deleteData",dataType:"json",type:"GET",success:function(t){if(t.status==="success"){e.resultList.filter(function(a){var r=$(this),i=String(r.data("id")),n=t.list.indexOf(i);if(n>-1){r.remove();e.resultList.splice(a,1);e.marker[a].setMap(null)}})}},error:function(){},complete:function(){}})},3e5);setInterval(function(){for(var e=0,a=t.teamSetting.length;e<a;e++){var r=t.teamSetting[e];r.total=0}for(var i=0,n=t.teamData.length;i<n;i++){var s=t.teamData[i],o=t.teamSetting.filter(function(t,e,a){return t.name===s.team});o[0].total++}var l="";for(var m=0,u=t.teamSetting.length;m<u;m++){var c=t.teamSetting[m];l+="<li>"+c.name+" : "+c.total+"件</li>"}$("#entryTotal-data").html(l)},1e4)}t.prototype.getEntryData=function(){var t=this;$.ajax({url:Cmn.dir+"/allData?offset="+this.offset,dataType:"json",type:"GET",success:function(e){switch(e.status){case"success":t.isData=true;t.offset=e.count;t.setTeamList(e.data);break;default:break}},error:function(){},complete:function(){}})};t.prototype.setTeamList=function(t){var e=this;var a="",r=t.length;$.get(this.template.filterTeam,function(i){for(var n=0,s=t.length;n<s;n++){var o=t[n],l=0,m=e.teamSetting.filter(function(t,e,a){return t.name===o.team});if(m.length===0){var u=e.teamSetting.length,c=e.getRandomColor(e.teamSetting),f={name:o.team,color:c,id:u,total:0};e.teamSetting.push(f);l=u;a+=Mustache.render(i,o)}else{l=m[0].id}o.team_id=l;e.teamData.push(o)}$("#filter-team").append(a);e.setMarker(r);e.setList(r)})};t.prototype.setList=function(t){var e=this;var a=this.teamData.length-t;$.get(this.template.list,function(t){var r="";for(var i=e.teamData.length-1;i>=a;i--){var n=e.teamData[i],s=e.viewTeam===n.team||e.viewTeam===""?"":" hide";n.color=e.teamSetting[n.team_id].color;n.category=e.category[n.cat];n.cls=s;n.created=e.getTimeDiff(n.created_at);r+=Mustache.render(t,n)}$(e.target.table).prepend(r);e.resultList=$(e.target.result)})};t.prototype.setMarker=function(t){var e=this.teamData.length-t;for(var a=e,r=this.teamData.length;a<r;a++){var i=this.teamData[a];if(!i.lat||!i.lng)continue;var n=new google.maps.LatLng(i.lat,i.lng),s=i.team===this.viewTeam||this.viewTeam==="",o=this.teamSetting[i.team_id].color,l=new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_bubble_text_small&chld=bb|"+i.data_id+"|"+o+"|000000"),m=new google.maps.Marker({position:n,icon:l,map:this.areaMap,team:i.team,visible:s});this.marker.push(m);this.markerBounds.extend(n)}this.areaMap.fitBounds(this.markerBounds)};t.prototype.getRandomColor=function(t){if(t===void 0){t=[]}var e=a();return e;function a(){var t=(Math.random()*16777215|0).toString(16);return("000000"+t).slice(-6)}};t.prototype.getTimeDiff=function(t){if(t==="")return"";var e=(new Date).getTime(),a=t.replace(/-/g,"/"),r=new Date(a).getTime(),i=e-r,n=i/1e3>>0;if(n<60){return n+"秒前"}n=n/60>>0;if(n<60){return n+"分前"}n=n/60>>0;if(n<24){return n+"時間前"}n=n/24>>0;if(n<365){return t}};return t}();new BGMapping;