// ---------------------------- ntcdata = { 'clloaded': false, 'plloaded': false, 'alloaded': false, 'C': [], 'P': [], 'A': [], 'points': [] }; ntc_timer = false; ntc_getdata_state = 0; function ntc_loadlabel() { if (ntcdata.clloaded == false) { json_request("rpc/getdata.php","dat=cl","ntc_loadlabel_result","ntc_loadlabel_callback()"); } else if (ntcdata.plloaded == false) { json_request("rpc/getdata.php","dat=pl","ntc_loadlabel_result","ntc_loadlabel_callback()"); } else if (ntcdata.alloaded == false) { //json_request("rpc/getdata.php","dat=al","ntc_loadlabel_result","ntc_loadlabel_callback()"); } ntc_renderdata_checkzoomchange(); } function ntc_loadlabel_nojson() { ntcdata.P = ntc_loadlabel_result.result; ntcdata.plloaded = true; ntc_renderdata_checkzoomchange(); } function ntc_loadlabel_callback(){ if (ntc_loadlabel_result.resulttype == 'cl') { ntcdata.C = ntc_loadlabel_result.result; ntcdata.clloaded = true; ntc_loadlabel(); } if (ntc_loadlabel_result.resulttype == 'pl') { ntcdata.P = ntc_loadlabel_result.result; ntcdata.plloaded = true; ntc_loadlabel(); } if (ntc_loadlabel_result.resulttype == 'al') { ntcdata.A = ntc_loadlabel_result.result; ntcdata.alloaded = true; ntc_getdata(); } } function ntc_getdata() { json_request("rpc/getdata.php","dat=d1","ntc_getdata_result","ntc_getdata_callback()"); } function ntc_getdata_callback() { //alert(ntc_getdata_result); if (ntc_getdata_result.resulttype == "d0") { if ( ntcdata.C[0].r != ntc_getdata_result.result[0].r || ntcdata.C[0].y != ntc_getdata_result.result[0].y || ntcdata.C[0].g != ntc_getdata_result.result[0].g ) { ntcdata.C[0].r = ntc_getdata_result.result[0].r; ntcdata.C[0].y = ntc_getdata_result.result[0].y; ntcdata.C[0].g = ntc_getdata_result.result[0].g; ntcdata.C[0].needupdate = true; } } else if (ntc_getdata_result.resulttype == "d1") { for(var i=0;i' + '' + ntcdata.C[0].g + ' / ' + '' + ntcdata.C[0].r + ''; divid = mmmap.drawCustomDivLevel(f, ntcdata.C[0].lat, ntcdata.C[0].lng , ntcdata.C[0].name, 2, 2); ntc_renderdata_remove(ntcdata.C[0].renderdiv); ntcdata.C[0].renderdiv = [divid]; ntcdata.C[0].needupdate = false; } } function ntc_renderdata_province() { var completecolor = ["#AA0000","#886600","#00AA00"]; var completefile = ["images/r.gif","images/y.gif","images/g.gif"]; for(var p in ntcdata.P) { if (typeof(ntcdata.P[p]) == 'object') { if ((ntcdata.P[p].needupdate == true) || (typeof(ntcdata.P[p].needupdate) == 'undefined')) { var sum = ntcdata.P[p].r + ntcdata.P[p].y + ntcdata.P[p].g; var complete; if (sum == 0) complete = 0; else complete = Math.round(100*ntcdata.P[p].g/sum); var cocolorinx = Math.round(sum/30); // short var f = document.createElement("div"); f.style.fontSize = "8pt"; f.style.fontWeight = "Bold"; f.style.fontFamily = "Tahoma"; //f.style.width = "50px"; f.style.cursor = "default"; f.innerHTML = '
' + '
'; var divid = mmmap.drawCustomDivLevel(f, ntcdata.P[p].lat, ntcdata.P[p].lng , ntcdata.P[p].name + ' ' + complete + '%', 3, 3); // percent //var no = 100 - complete; var no = Math.round(100*ntcdata.P[p].r/sum); f = document.createElement("div"); f.style.fontSize = "8pt"; f.style.fontWeight = "Bold"; f.style.fontFamily = "Tahoma"; f.style.width = "100px"; f.style.cursor = "default"; f.innerHTML = '
' + ntcdata.P[p].name + '
' + '' + complete + '% ' + no + '%' + '
'; var usename = ntcdata.P[p].name; if (mylang == "en") { usename = ntcdata.P[p].name_en; } var divid2 = mmmap.drawCustomDivLevel(f, ntcdata.P[p].lat, ntcdata.P[p].lng , usename, 4, 4); // complete var rc = 0; var yc = 0; var gc = 0; if (sum > 0 ) { rc = Math.round(100*ntcdata.P[p].r/sum); yc = Math.round(100*ntcdata.P[p].y/sum); gc = Math.round(100*ntcdata.P[p].g/sum); } var comeout = Math.round(100*sum/ntcdata.P[p].t); f = document.createElement("div"); f.style.fontSize = "8pt"; f.style.fontWeight = "Bold"; f.style.fontFamily = "Tahoma"; f.style.width = "100px"; f.style.cursor = "default"; f.innerHTML = '
' + usename + '
' + 'ใช้สิทธิ์: ' + addComma(sum) + ' (' + comeout + '%)
' + 'รับ: ' + gc + '%
' + '' + 'ไม่รับ: ' + rc + '%
'; var divid3 = mmmap.drawCustomDivLevel(f, ntcdata.P[p].lat, ntcdata.P[p].lng , ntcdata.P[p].name, 5, 5); ntc_renderdata_remove(ntcdata.P[p].renderdiv); ntcdata.P[p].renderdiv = [divid, divid2, divid3]; ntcdata.P[p].needupdate = false; } } } } function ntc_renderdata_amphur() { for(var a in ntcdata.A) { if (typeof(ntcdata.A[a]) == 'object') { if ((ntcdata.A[a].needupdate == true) || (typeof(ntcdata.A[a].needupdate) == 'undefined')) { var sum = ntcdata.A[a].r + ntcdata.A[a].y + ntcdata.A[a].g; var f = document.createElement("div"); f.style.fontSize = "8pt"; f.style.fontWeight = "Bold"; f.style.fontFamily = "Tahoma"; f.style.width = "100px"; f.style.cursor = "default"; f.innerHTML = '
' + ntcdata.A[a].name + '
' + '' + sum + ' / ' + '' + ntcdata.A[a].r + ' / ' + '' + ntcdata.A[a].y + ' / ' + '' + ntcdata.A[a].g + '
'; var divid = mmmap.drawCustomDivLevel(f, ntcdata.A[a].lat, ntcdata.A[a].lng , ntcdata.A[a].name, 6, 7); ntc_renderdata_remove(ntcdata.A[a].renderdiv); ntcdata.A[a].renderdiv = [divid]; ntcdata.A[a].needupdate = false; } } } } function ntc_renderdata_point() { var typecode = {"SC": "phone1", "HS": "phone2", "PT": "pubtel"}; var statuscode = {"R": "ยังไม่ได้ติดตั้ง", "Y": "กำลังดำเนินการติดตั้ง", "G": "ติดตั้งเสร็จเรียบร้อย"}; var colorcode = {"R": "#FF0000", "Y": "#FFFF00", "G": "#00FF00"}; for(var p in ntcdata.points) { if (typeof(ntcdata.points[p]) == 'object') { if ((ntcdata.points[p].needupdate == true) || (typeof(ntcdata.points[p].needupdate) == 'undefined')) { var f = document.createElement("div"); f.innerHTML = ""; var f2 = document.createElement("div"); f2.innerHTML = ""; popuptitle = ntcdata.points[p].title; t1 = ntcdata.points[p].start_date.substr(0,ntcdata.points[p].start_date.indexOf(" ")); t2 = t1.split("-"); sd = (t1 != "0000-00-00")?(t2[2] + "/" + t2[1] + "/" + t2[0]):"-"; t1 = ntcdata.points[p].estop_date.substr(0,ntcdata.points[p].estop_date.indexOf(" ")); t2 = t1.split("-"); etd = (t1 != "0000-00-00")?(t2[2] + "/" + t2[1] + "/" + t2[0]):"-"; t1 = ntcdata.points[p].stop_date.substr(0,ntcdata.points[p].stop_date.indexOf(" ")); t2 = t1.split("-"); td = (t1 != "0000-00-00")?(t2[2] + "/" + t2[1] + "/" + t2[0]):"-"; popuptext = "ที่อยู่: " + ntcdata.points[p].address + " หมู่ " + ntcdata.points[p].moo + ", " + ntcdata.points[p].tambol + ", " + ntcdata.points[p].district + ", " + ntcdata.points[p].province + "
" + "สถานะ:
" + "วันเริ่มติด: " + ((sd != "0000-00-00")?sd:"-") + "
" + "คาดว่าเสร็จ: " + ((etd != "0000-00-00")?etd:"-") + "
" + "วันที่เสร็จ: " + ((td != "0000-00-00")?td:"-") + "
" + "
  [แก้ไข]
"; var divid = mmmap.drawCustomDivLevelWithPopup(f, ntcdata.points[p].latitude, ntcdata.points[p].longitude, popuptitle, 8, 14, popuptext); var divid2 = mmmap.drawCustomDivLevelWithPopup(f2, ntcdata.points[p].latitude, ntcdata.points[p].longitude, popuptitle, 7, 7, popuptext); // var divid = mmmap.drawCustomDivLevel(f, ntcdata.points[p].latitude, ntcdata.points[p].longitude , ntcdata.points[p].name, 7, 14); ntc_renderdata_remove(ntcdata.points[p].renderdiv); ntcdata.points[p].renderdiv = [divid, divid2]; ntcdata.points[p].needupdate = false; } } } } // --- Below is old version // ---------------------------------------------------------------- // ---------------------------------------------------------------- function drawpoint(resp){ updatelock = false; typecode = {"SC": "phone1", "HS": "phone2", "PT": "pubtel"}; statuscode = {"R": "ยังไม่ได้ติดตั้ง", "Y": "กำลังดำเนินการติดตั้ง", "G": "ติดตั้งเสร็จเรียบร้อย"}; colorcode = {"R": "#FF0000", "Y": "#FFFF00", "G": "#00FF00"}; var r= eval("(" + resp.responseText + ")"); newpointarray = new Array(); newpointarrayinfo = new Array(); pointcount = 0; debug=""; for(i=0;i"; // testdiv.innerHTML = ""; testdiv.info = r.points[i]; // testdiv.title = r.points[i].title; // loop to find match match = false; matchindex = 0; for (j=0;j" + "สถานะ:
" + "วันเริ่มติด: " + ((sd != "0000-00-00")?sd:"-") + "
" + "คาดว่าเสร็จ: " + ((etd != "0000-00-00")?etd:"-") + "
" + "วันที่เสร็จ: " + ((td != "0000-00-00")?td:"-") + "
" + "
  [แก้ไข]
"; newpointarray[pointcount] = mmmap.drawCustomDivLevelWithPopup(testdiv, r.points[i].latitude, r.points[i].longitude, popuptitle, 4, 10, popuptext); newpointarrayinfo[pointcount] = testdiv.info; pointcount++; } else { //alert(pointarrayinfo[matchindex].id + " " + pointarrayinfo[matchindex].title + " " + pointarrayinfo[matchindex].status); newpointarray[pointcount] = pointarray[matchindex]; newpointarrayinfo[pointcount] = pointarrayinfo[matchindex]; pointarray[matchindex] = -1; pointcount++; } //alert("D" + i + " " + pointarray[i]); } //alert(debug); for(i=0;iเพิ่มสถานที่ใหม่ตรงนี้'; return txt; } function deletelocationdiv(){ for(ii=0;ii" + "สถานะ:
" + "วันเริ่มติด: " + ((sd != "0000-00-00")?sd:"-") + "
" + "คาดว่าเสร็จ: " + ((etd != "0000-00-00")?etd:"-") + "
" + "วันที่เสร็จ: " + ((td != "0000-00-00")?td:"-") + "
" + "
  [แก้ไข]
"; //alert(escape(popuptext)); result += "
" + "" + "" + t.title + "
" + t.tambol + " " + t.district + "
"; } document.getElementById("search_result_set").innerHTML = result; } function dosearch(kw){ var pars = "q=" + kw; setkeyword(kw); var pointrequest = new Ajax.Request( getsearchurl, { method: 'post', parameters: pars, onComplete: showsearchresult }); } function showsearchbox(s){ if (s == true) { document.getElementById("showsearch_button").style.display = "none"; document.getElementById("search_result").style.display = "block"; sresult = true; mapresize(); } else { document.getElementById("showsearch_button").style.display = "block"; document.getElementById("search_result").style.display = "none"; sresult = false; mapresize(); } } function clearsearch(){ setkeyword(''); mapupdate(); document.getElementById('search_result_set').innerHTML = ''; document.getElementById('searchbox').value = 'พิมพ์คำค้นหาที่นี่'; document.getElementById('searchbox').style.fontStyle='italic'; mapresize(); } function updatetimeout(){ mapupdate(); //setTimeout("updatetimeout()", 20000); } //setTimeout("updatetimeout()", 20000); function doDSearch(){ dosearch(document.getElementById('searchbox').value); mapupdate(); } function addComma(number) { number = '' + number; if (number.length > 3) { var mod = number.length % 3; var output = (mod > 0 ? (number.substring(0,mod)) : ''); for (i=0 ; i < Math.floor(number.length / 3); i++) { if ((mod == 0) && (i == 0)) output += number.substring(mod+ 3 * i, mod + 3 * i + 3); else output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3); } return (output); } else return number; }