Files
fleet-contractor/Site/js/mapview/mapview.min.js
2024-03-26 15:56:31 +08:00

1 line
127 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function openAddEnginHours(n){primarydatadourceMVEH=undefined;assetdataEH=n;var i=customerdatetime.split(" "),r=i[0],t=i[1].split(":"),u=t[0].length==1?"0"+t[0]:t[0],f=t[1];$("#dialogaddgenginehours_enginehours").val("");$("#dialogadd_enginehourstimezone").val(customertimezone?customertimezone:"UTC");$("#dialogaddenginehours_date").val(r);$("#dialogaddenginehours_timehour").val(u);$("#dialogaddenginehours_timeminute").val(f);$("#dialogaddenginehours_Notes").val("");assetdataEH.TelematicsEnabled&&!assetdataEH.EngineHours.IsEmpty&&(assetdataEH.EngineHours.DataSource.toLowerCase()=="calamp"||assetdataEH.EngineHours.DataSource.toLowerCase()=="pedigree")?(isAddEH=!1,primarydatadourceMVEH=assetdataEH.EngineHours.DataSource):isAddEH=!0;$("#dialog_addenginehours .dialog-title span.title").text(isAddEH?GetTextByKey("P_MV_ADDENGINEHOURS","Add Engine Hours"):GetTextByKey("P_MV_ADJUSTENGINEHOURS","Adjust Engine Hours"));showmaskbg(!0);$("#dialog_addenginehours").attr("act","add").css({top:(document.documentElement.clientHeight-$("#dialog_addenginehours").height())/3,left:(document.documentElement.clientWidth-$("#dialog_addenginehours").width())/2}).showDialogfixed();$("#dialogaddgenginehours_enginehours").focus()}function OnAddEngineHours(){var t,i,n,f,r,u;if($("#addenginehoursmask").show(),t=isAddEH?GetTextByKey("P_MV_ADDENGINEHOURS","Add Engine Hours"):GetTextByKey("P_MV_ADJUSTENGINEHOURS","Adjust Engine Hours"),i=$("#selContractor").val(),i||(i=""),n={CustomerID:i,AssetID:assetdataEH.Id,EngineHours:$("#dialogaddgenginehours_enginehours").val(),EngineHoursDate:$("#dialogaddenginehours_date").val(),Notes:$("#dialogaddenginehours_Notes").val(),DataSource:primarydatadourceMVEH},n.EngineHours!==""){if(isNaN(n.EngineHours)){_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSFORMATERROR","Engine Hours format error."),t);$("#addenginehoursmask").hide();return}if(n.EngineHours<=0){_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSMUSTBEGREATERTHAN0","Engine Hours must be greater than 0."),t);$("#addenginehoursmask").hide();return}}else{_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSCANNOTBEEMPTY","Engine Hours cannot be empty."),t);$("#addenginehoursmask").hide();return}if(n.EngineHoursDate===""){_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSDATECANNOTBEEMPTY","Engine Hours Date cannot be empty."),t);$("#addenginehoursmask").hide();return}f=$("#dialogadd_enginehourstimezone").find("option:selected").attr("offset");n.OffsetMinute=f;var e=$("#dialogadd_enginehourstimezone").find("option:selected").text(),o=$("#dialogaddenginehours_timehour").val(),s=$("#dialogaddenginehours_timeminute").val();n.EngineHoursDate=n.EngineHoursDate.replace("-","/")+" "+o+":"+s+":00";r=o+":"+s;u="";u=isAddEH?GetTextByKey("P_MV_UPDATEENGINEHOURS","Do you want to update the engine hours to reflect: {0} hours at {1} {2}?").replace("{0}",n.EngineHours).replace("{1}",r).replace("{2}",e):GetTextByKey("P_MV_UPDATEENGINEHOURS1","If you proceed, engine hours will be updated to reflect: {0} hours at {1} <br/> {2}. <br/><br/>Note that this asset is telematic enabled and the primary data source is {3}.<br/><br/> Would you like to proceed?").replace("{0}",n.EngineHours).replace("{1}",r).replace("{2}",e).replace("{3}",assetdataEH.EngineHours.DataSourceName);showConfirm1(u,t,function(){$("#addenginehoursmask").hide();isAddEH?AddManuallyInputEngineHours(n,t):CheckEngineHourMinimumTime(n,t)},function(){$("#addenginehoursmask").hide()})}function AddManuallyInputEngineHours(n,t){var i=JSON.stringify(n);i=htmlencode(i);devicerequest("AddManuallyInputEngineHours",i,function(n){n!=="OK"?_dialog.showAlert(n,t):_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSUPDATESUCCESSFUL","Engine Hours Update Successful."),t);$("#dialog_addenginehours").hideDialog();$("#addenginehoursmask").hide()},function(n){console.log(n);_dialog.showAlert(GetTextByKey("P_MV_FAILEDTOADDENGINEHOURS","Failed to add Engine Hours."),t);$("#addenginehoursmask").hide()})}function CheckEngineHourMinimumTime(n,t){var i=JSON.stringify(n);i=htmlencode(i);devicerequest("CheckEngineHourMinimumTime",i,function(i){if(i>0){i==1?_dialog.showAlert(GetTextByKey("P_MV_CHECKENGINEHOURSMINNIMUMTIME","The adjustment cannot be completed as provided. The engine hours reading date provided cannot be prior to initial telematic data available for the asset."),t):_dialog.showAlert(GetTextByKey("P_MV_CHECKENGINEHOURSMINNIMUMTIME1","The adjustment cannot be completed as provided. The engine hours reading date provided must be prior to or equal to the latest telematic data available for the asset."),t);$("#addenginehoursmask").hide();return}SaveAdjustEngineHours(n,t)},function(){})}function SaveAdjustEngineHours(n,t){var i=JSON.stringify(n);i=htmlencode(i);devicerequest("SaveAdjustEngineHours",i,function(n){n!=="OK"?_dialog.showAlert(n,t):_dialog.showAlert(GetTextByKey("P_MV_ENGINEHOURSUPDATESUCCESSFUL","Engine Hours Update Successful."),t);$("#dialog_addenginehours").hideDialog();$("#addenginehoursmask").hide()},function(n){console.log(n);_dialog.showAlert(GetTextByKey("P_MV_FAILEDTOADJUSTENGINEHOURS","Failed to adjust Engine Hours."),t);$("#addenginehoursmask").hide()})}function openAddOdometer(n){primarydatadourceMVOdo=undefined;assetdataOdo=n;var i=customerdatetime.split(" "),r=i[0],t=i[1].split(":"),u=t[0].length==1?"0"+t[0]:t[0],f=t[1];$("#dialogadd_odometer").val("");$("#dialogadd_sel_odometeruom").val(systemunitofodometer);$("#dialogadd_odometertimezone").val(customertimezone?customertimezone:"UTC");$("#dialogadd_odometerdate").val(r);$("#dialogadd_timehour").val(u);$("#dialogadd_timeminute").val(f);$("#dialogadd_notes").val("");assetdataOdo.TelematicsEnabled&&!assetdataOdo.Odometer.IsEmpty&&(assetdataOdo.Odometer.DataSource.toLowerCase()=="calamp"||assetdataOdo.Odometer.DataSource.toLowerCase()=="pedigree")?(isAddOdo=!1,primarydatadourceMVOdo=assetdataOdo.Odometer.DataSource):isAddOdo=!0;$("#dialog_addodometer .dialog-title span.title").text(isAddOdo?GetTextByKey("P_MV_ADDODOMETER","Add Odometer"):GetTextByKey("P_MV_ADJUSTODOMETER","Adjust Odometer"));showmaskbg(!0);$("#dialog_addodometer").attr("act","add").css({top:(document.documentElement.clientHeight-$("#dialog_addodometer").height())/3,left:(document.documentElement.clientWidth-$("#dialog_addodometer").width())/2}).showDialogfixed();$("#dialogadd_odometer").focus()}function OnAddOdometer(){var t,i,n,f,r,u;if($("#addodomask").show(),t=isAddOdo?GetTextByKey("P_MV_ADDODOMETER","Add Odometer"):GetTextByKey("P_MV_ADJUSTODOMETER","Adjust Odometer"),i=$("#selContractor").val(),i||(i=""),n={CustomerID:i,AssetID:assetdataOdo.Id,Odometer:$("#dialogadd_odometer").val(),UOM:$("#dialogadd_sel_odometeruom").val(),OdometerDate:$("#dialogadd_odometerdate").val(),Notes:$("#dialogadd_notes").val(),DataSource:primarydatadourceMVOdo},n.Odometer!==""){if(isNaN(n.Odometer)){_dialog.showAlert(GetTextByKey("P_MV_ODOMETERFORMATERROR","Odometer format error."),t);$("#addodomask").hide();return}if(n.Odometer<=0){_dialog.showAlert(GetTextByKey("P_MV_ODOMETERMUSTBEGREATERTHAN0","ODOMeter must be greater than 0."),t);$("#addodomask").hide();return}}else{_dialog.showAlert(GetTextByKey("P_MV_ODOMETRCANNOTBEEMPTY","Odometer cannot be empty."),t);$("#addodomask").hide();return}if(n.OdometerDate===""){_dialog.showAlert(GetTextByKey("P_MV_ODOMETRDATACANNOTBEEMPTY","Odometer date cannot be empty."),t);$("#addodomask").hide();return}f=$("#dialogadd_odometertimezone").find("option:selected").attr("offset");n.OffsetMinute=f;var e=$("#dialogadd_enginehourstimezone").find("option:selected").text(),o=$("#dialogadd_timehour").val(),s=$("#dialogadd_timeminute").val();n.OdometerDate=n.OdometerDate.replace("-","/")+" "+o+":"+s+":00";r=o+":"+s;u="";u=isAddOdo?GetTextByKey("P_MV_UPDATETHEODOMETER","Do you want to update the odometer to reflect: {0} {1} at {2} {3}?").replace("{0}",n.Odometer).replace("{1}",n.UOM).replace("{2}",r).replace("{3}",e):GetTextByKey("P_MV_UPDATETHEODOMETER1","If you proceed, odometer will be updated to reflect: {0} {1} at {2} <br/> {3}.<br/><br/> Note that this asset is telematic enabled and the primary data source is {4}.<br/><br/>Would you like to proceed?").replace("{0}",n.Odometer).replace("{1}",n.UOM).replace("{2}",r).replace("{3}",e).replace("{4}",assetdataOdo.Odometer.DataSourceName);showConfirm1(u,t,function(){$("#addodomask").hide();isAddOdo?AddManuallyInputOdometer(n,t):CheckOdometerMinnimumTime(n,t)},function(){$("#addodomask").hide()})}function AddManuallyInputOdometer(n,t){var i=JSON.stringify(n);i=htmlencode(i);devicerequest("AddManuallyInputOdometer",i,function(n){n!=="OK"?_dialog.showAlert(n,t):_dialog.showAlert(GetTextByKey("P_MV_ODOMETERUPDATESUCCESSFUL","Odometer Update Successful."),t);$("#dialog_addodometer").hideDialog();$("#addodomask").hide()},function(){_dialog.showAlert(GetTextByKey("P_MV_FAILEDTOADDODOMETER","Failed to add Odometer."),t);$("#addodomask").hide()})}function CheckOdometerMinnimumTime(n,t){var i=JSON.stringify(n);i=htmlencode(i);devicerequest("CheckOdometerMinnimumTime",i,function(i){if(i>0){i==1?_dialog.showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME","The adjustment cannot be completed as provided. The odometer reading date provided cannot be prior to initial telematic data available for the asset."),t):_dialog.showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME1","The adjustment cannot be completed as provided. The odometer reading date provided must be prior to or equal to the latest telematic data available for the asset."),t);$("#addodomask").hide();return}SaveAdjustOdometer(n,t)},function(){})}function SaveAdjustOdometer(n,t){var i=JSON.stringify(n);i=htmlencode(i);devicerequest("SaveAdjustOdometer",i,function(n){n!=="OK"?_dialog.showAlert(n,t):_dialog.showAlert(GetTextByKey("P_MV_ODOMETERUPDATESUCCESSFUL","Odometer Update Successful."),t);$("#dialog_addodometer").hideDialog();$("#addodomask").hide()},function(){_dialog.showAlert(GetTextByKey("P_MV_FAILEDTOADJUSTODOMETER","Failed to adjust Odometer."),t);$("#addodomask").hide()})}function updateAssets(){var u,n,f,i,t,r;if(assetDictionary=[[]],groupAssets=[[]],jobsiteAssets=[[]],allAssets)for(u=0;u<allAssets.length;u++){if(n=allAssets[u],f=""+n.ID%100,assetDictionary[f]||(assetDictionary[f]=[]),assetDictionary[f].push(n),n.AssetGroups&&n.AssetGroups.length>0)for(t=0;t<n.AssetGroups.length;t++)i=n.AssetGroups[t].toLowerCase(),groupAssets[i]||(groupAssets[i]=[]),groupAssets[i].push(n);else i="-1",groupAssets[i]||(groupAssets[i]=[]),groupAssets[i].push(n);if(n.JobSites&&n.JobSites.length>0)for(t=0;t<n.JobSites.length;t++)r=n.JobSites[t],jobsiteAssets[r]||(jobsiteAssets[r]=[]),jobsiteAssets[r].push(n);else r=-1,jobsiteAssets[r]||(jobsiteAssets[r]=[]),jobsiteAssets[r].push(n)}}function getAsset(n){var r=""+n%100,i=assetDictionary[r],t;if(i)for(t=0;t<i.length;t++)if(i[t].ID==n)return i[t]}function getAssetByID(n){_network.mapviewquery("GetAssetByID",JSON.stringify([n,companyids]),function(n){n&&typeof n!="string"&&mapHelper.showAssetDetailInfo(n)},function(){})}function getAssetPopupContent(n,t){var i=t.Location,r="<b>"+GetTextByKey("P_MV_NAME_COLON","Name:")+" <\/b> "+htmlencode(t.DisplayName)+"<br/>",s,e,o,f,u;return r+="<b>"+GetTextByKey("P_MV_SN_COLON","SN:")+" <\/b>"+t.VIN+"<br/>",r+="<b>"+GetTextByKey("P_MV_MAKE_COLON","Make:")+" <\/b>"+t.Make+"<br/>",r+="<b>"+GetTextByKey("P_MV_MODEL_COLON","Model:")+" <\/b>"+t.Model+"<br/>",r+="<b>"+GetTextByKey("P_MV_TYPE_COLON","Type:")+" <\/b>"+t.AssetType+"<br/>",t.EngineHours>0&&(r+="<b>"+GetTextByKey("P_MV_ENGINEHOURS_COLON","Engine Hours:")+" <\/b>"+t.EngineHours.toLocaleString()+"<br/>"),t.Odometer>0&&(s=t.Odometer.toLocaleString(),t.Odometer>0&&t.OdometerUOM&&(s+=" "+t.OdometerUOM),r+="<b>"+GetTextByKey("P_MV_ODOMETER_COLON","Odometer:")+" <\/b>"+s+"<br/>"),i.LocationTimeText!==""&&(r+="<b>"+GetTextByKey("P_MV_LOCATIONUPDATED_COLON","Location Updated:")+" <\/b>"+i.LocationTimeText+"<br/>"),t.EngineHours>0&&t.EngineHoursDateText!==""&&(r+="<b>"+GetTextByKey("P_MV_ENGINEHOURSUPDATED_COLON","Engine Hours Updated:")+" <\/b>"+t.EngineHoursDateText+"<br/>"),e="",i.Speed>=0&&(e=i.Speed+" "+(i.SpeedUnit==="mi/h"?"mph":i.SpeedUnit)),e!==""&&(r+="<b>"+GetTextByKey("P_MV_CURRENTSPEED_COLON","Current Speed:")+" <\/b>"+e+"<br/>"),o="",i.PostedSpeed>0&&(o=i.PostedSpeed+" "+i.PostedSpeedUnit),o!==""&&(r+="<b>"+GetTextByKey("P_MV_POSTEDSPEED_COLON","Posted Speed:")+" <\/b>"+o+"<br/>"),i.Street!==""&&(r+="<b>"+GetTextByKey("P_MV_STREET_COLON","Street:")+" <\/b>"+i.Street+"<br/>"),t.GroupNames!==""&&(r+="<b>"+GetTextByKey("P_MV_GROUPS_COLON","Groups:")+" <\/b>"+htmlencode(t.GroupNames)+"<br/>"),t.Description&&t.Description!==""&&(t.Description=htmlencode(t.Description),t.Description.indexOf("\r\n")>-1&&(f=new RegExp("\r\n","g"),t.Description=t.Description.replace(f,"<br/>")),t.Description.indexOf("\n")>-1&&(f=new RegExp("\n","g"),t.Description=t.Description.replace(f,"<br/>")),r+="<br/><b>"+GetTextByKey("P_MV_DESCRIPTION_COLON","Description:")+" <\/b><br/>"+t.Description+"<br/>"),t.AlertTip&&(t.AlertTip=htmlencode(t.AlertTip),t.AlertTip.indexOf("\r\n")>-1&&(f=new RegExp("\r\n","g"),t.AlertTip=t.AlertTip.replace(f,"<br/>")),r+="<br/>"+t.AlertTip+"<br/>"),notShowIcons||(u='<div style="margin-top:10px;">',u+='<span class="icondetail" style="margin-right: 10px; cursor: pointer; " onclick="showMachineDetail(\''+n+"',"+t.ID+", '"+encodeURIComponent(t.VIN).replace("'","\\'")+'\')" title="'+GetTextByKey("P_MV_DETAIL","Detail")+'"><\/span>',u+='<span class="icondirection" style="margin-right: 10px;cursor: pointer;" onclick="doDirections('+i.Latitude+",'"+i.Longitude+'\')" title="'+GetTextByKey("P_MV_DIRECTIONS","Directions")+'"><\/span>',i.FromSmartWitness&&enableSmartWitness&&(u+="<span class='iconvideo' style='margin-right: 10px;cursor:pointer;' onclick='openRequestVideoDialog(\""+n+'",'+t.ID+")' title='"+GetTextByKey("P_MV_VIDEOREQUEST","Video Request")+"'><\/span>"),u+="<span class='iconmail' style='margin-right: 10px;cursor:pointer;' onclick='openSendEmails(\""+n+'",'+t.ID+",0)' title='"+GetTextByKey("P_MV_SENDLOCATION","Send Location")+"'><\/span>",assetLocations[t.ID]=i,u+='<span class="iconweather" style="margin-right: 10px; cursor: pointer; " onclick="doWeather('+i.Latitude+",'"+i.Longitude+'\')" title="'+GetTextByKey("P_MV_WEATHER","Weather")+'"><\/span>',canEditAsset&&(u+='<span class="iconasset" style="margin-right: 10px; cursor: pointer; " onclick="OnEditAsset(\''+n+"','"+t.ID+'\')" title="'+GetTextByKey("P_MV_EDITASSET","Edit Asset")+'"><\/span>'),canViewWorkOrder&&(u+='<span class="iconmapworkorder" style="margin-right: 10px; cursor: pointer; " onclick="OnViewWorkOrder(\''+n+"','"+t.ID+'\')" title="'+GetTextByKey("P_MV_WORKORDERS","Work Orders")+'"><\/span>'),canViewMR&&(u+='<span class="iconmaintenancerecord" style="margin-right: 10px; cursor: pointer; " onclick="OnViewMaintenanceRecord(\''+n+"','"+t.ID+'\')" title="'+GetTextByKey("P_MV_MAINTENANCERECORD","Maintenance Record")+'"><\/span>'),u+='<span class="iconlochis" style="margin-right: 10px; cursor: pointer; " onclick="doLocationHistory(\''+n+"',"+t.ID+", '"+encodeURIComponent(t.DisplayName).replace("'","\\'")+'\')" title="'+GetTextByKey("P_MA_LOCATIONHISTORY","Location History")+'" data-asset='+t+"><\/span>",u+="<\/div>",r+=u),r}function machineDetailClick(n){n&&(showMachineDetail(n.CompanyID||"",n.ID,n.VIN),clearLocationHistory(),$("#locationhistoryDiv").hide(),$("#tripDiv").hide(),selectedAsset&&(selectedAsset.State.Highlight=!1),n.State.Highlight=!0,selectedAsset=n)}function showMachineDetail(n,t,i){$("#divassetview").show();$("#divtimelineview").hide();$("#divmapview").hide();execIframeFunc("loadAsset",[n,t,i,0],"ifassetview");PopupViewShowing=!0}function closePopupView(){$("#divassetview").hide();$("#divtimelineview").hide();$("#divmapview").show();PopupViewShowing=!1;selectedAsset&&(selectedAsset.State.Highlight=!1)}function getMapAlertLayerLang(n,t){var f,u,r,i;if(!n||n.length==0)return t;for(f=["fr-fr","fr-ca"],u=0;u<n.length;u++)if(r=n[u],_fleet.currentLang===r.Key)if(r.Value==="")if(f.indexOf(r.Key)>=0){for(i=0;i<n.length;i++)if(n[i].Key==="fr")return n[i].Value===""?t:n[i].Value}else return t;else return r.Value;return t}function showMapAlertLayer(n){var u=$("<option><\/option>").val("").text("(None)"),i=$("#selMapAlertLayer"),r,t;for(i.empty(),i.append(u),r=0;r<n.length;r++)t=n[r],u=$("<option><\/option>").val(t.ID).text(getMapAlertLayerLang(t.LocalNames,t.Name)).data("mal",t),i.append(u);userParams&&userParams.MapAlertLayer&&i.val(userParams.MapAlertLayer);showMapAlertLayerDetail()}function showMapAlertLayerDetail(){var u=$("#selMapAlertLayer").find("option:selected").data("mal"),f=$("#tbLegend"),e,r,o,c,s,t,h,l,n,i,a;if(f.empty(),e=!1,u&&u.Layers)for(n=0;n<u.Layers.length;n++)r=u.Layers[n],r.Pivots&&r.Pivots.length>0&&(e=!0),i=$("<tr style='border-bottom: 1px solid lightgray;'><\/tr>"),f.append(i),t=$("<td><\/td>").css("width",30),t.append($("<img><\/img>").attr("src",r.LegendUrl).css({width:18,"vertical-align":"middle"})),i.append(t),t=$("<td><\/td>").html(getMapAlertLayerLang(r.LocalTitles,r.Title)).css({"padding-left":10,width:220}),i.append(t);for(o=["InMotion","StoppedOn","StoppedOff","CGain","CLoss","RoadClosure","LaneClosure","DriverInsights","SeatBelt"],c=[GetTextByKey("P_MA_INMOTION","In Motion"),GetTextByKey("P_MA_STOPPEDON","Stopped On"),GetTextByKey("P_MA_STOPPEDOFF","Stopped Off"),GetTextByKey("P_MA_CONNECTIVITYRECOVERY","Connectivity Recovery"),GetTextByKey("P_MA_CONNECTIVITYLOSS","Connectivity Loss"),GetTextByKey("P_MA_ROADCLOSURE","Road Closure"),GetTextByKey("P_MA_LANECLOSURE","Lane Closure"),GetTextByKey("P_MA_DRIVERINSIGHTS","Driver Insights"),GetTextByKey("P_MV_SEATBELTNOTDETECTED","Seat Belt Not Detected")],n=0;n<o.length;n++)i=$("<tr style='border-bottom: 1px solid lightgray;'><\/tr>"),f.append(i),s=userParams.MachineIconURL+"?legend="+o[n],t=$("<td><\/td>").css("width",30),t.append($("<img><\/img>").attr("src",s).css({width:18,"vertical-align":"middle"})),i.append(t),t=$("<td><\/td>").html(c[n]).css({"padding-left":10,width:220}),i.append(t);for(h=["#ff3f48cc","#ff00a8f3","#ffff89e6","#ffff7f27","#ffec1c24"],l=[GetTextByKey("P_MA_HARDACCELERATION","Hard Acceleration"),GetTextByKey("P_MA_HARDBRAKE","Hard Brake"),GetTextByKey("P_MA_HARDTURN","Hard Turn"),GetTextByKey("P_MA_SPEEDINGLOWSEVERITY","Speeding: Low Severity"),GetTextByKey("P_MA_SPEEDINGHIGHSEVERITY","Speeding: High Severity")],n=0;n<h.length;n++){i=$("<tr style='border-bottom: 1px solid lightgray;'><\/tr>");f.append(i);var v=userParams.MachineMovingIconURL,s=v+"?tp=0&bkcolor="+encodeURIComponent(h[n])+"&heading=45",t=$("<td><\/td>").css("width",30);t.append($("<img><\/img>").attr("src",s).css({width:18,"vertical-align":"middle"}));i.append(t);t=$("<td><\/td>").html(l[n]).css({"padding-left":10,width:220});i.append(t)}e?$("#setparameter").css("display",""):$("#setparameter").css("display","none");a=$("#mapAlertLayerDiv").width()+100;$("#filterIconDiv").css("right",a)}function setParameterDatimeTimePicker(n){n.datetimepicker({timepicker:!1,format:"m/d/Y",enterLikeTab:!1,onSelectDate:function(n,t){var i=(new DateFormatter).formatDate(n,"m/d/Y 00:00:00");t.parent().data("val",[i])}})}function getAlertLayerParameters(){var t,n,i,r;if(parameterinput.length>0)for(t=0;t<parameterinput.length;t++)n=parameterinput[t],i=n.data("parameter"),i.ParameterValue=n.data("inputtype")=="dropdown"?n.allselected()?ALL_VALUE:i.IsField&&i.MutipleSelect?n.dropdownVals().join(","):n.dropdownVal():n.val();return(r=$("#selMapAlertLayer").find("option:selected").data("mal"),r)?r.Layers:null}function setAlertLayerParameters(){var u,f,t,e,i,n,r;if(parameterinput=[],paramindex=-1,u=$("#ul_parameter"),u.empty(),f=$("#parameter_right"),f.empty(),t=$("#selMapAlertLayer").find("option:selected").data("mal"),e=0,t&&t.Layers)for(i=0;i<t.Layers.length;i++)if(n=t.Layers[i],n&&n.Pivots){var o=$("<li class='nav_item'><\/li>").data("layerid",n.ID).click(e++,layerclick),s=$("<img><\/img>").attr("src",n.LegendUrl).css({width:18,"vertical-align":"middle"}),h=$("<span><\/span>").text(getMapAlertLayerLang(n.LocalTitles,n.Title)).css({"margin-left":10,"vertical-align":"middle"});o.append(s).append(h);u.append(o);r=$("<table class='tb_parameter'><\/table>").data("layerid",n.ID);e==1?o.addClass("selected"):r.css("display","none");f.append(r);n.Pivots&&n.Pivots.length>0&&createParameters(n.Pivots,r)}}function createParameters(n,t){for(var i,r,u,o,f,s=!1,h=!1,e=0;e<n.length;e++)i=n[e],i.IsCriteriaSQL&&!s&&(r=$("<tr><\/tr>").append("<td colspan='2' style='padding-left:10px;font-weight:bold;font-size:16px;'>"+GetTextByKey("P_MV_CRITERIA","Criteria")+"<\/td>"),t.append(r),s=!0),i.IsCriteriaSQL||h||(r=$("<tr><\/tr>").append("<td colspan='2' style='padding-left:10px;font-weight:bold;font-size:16px;'>"+GetTextByKey("P_MV_ALERT","Alert")+"<\/td>"),t.append(r),h=!0),u=$("<tr><\/tr>"),t.append(u),u.append($("<td><\/td>").addClass("td_paramtype").html(getMapAlertLayerLang(i.LocalCaptions,i.Caption))),o=$("<td><\/td>"),f=createParameterInput(i),parameterinput.push(f),i.DataType==3&&i.DisplayStyle!=1&&i.DisplayStyle!=2&&setParameterDatimeTimePicker(f),o.append(f),u.append(o)}function FALSE(){return!1}function createParameterInput(n){var t=getParameterValue(n.ID,n.IsCriteriaSQL);if(t==null&&(t=n.DefaultValue),n.DisplayStyle==0)return $("<input type='text' />").val(t).data("parameter",n).attr("paramcaption",n.Name.toLowerCase()).keyup(function(){$("[paramcaption='"+n.Name.toLowerCase()+"']").val($(this).val())}).change(function(){$("[paramcaption='"+n.Name.toLowerCase()+"']").val($(this).val())});if(n.DisplayStyle==1||n.DisplayStyle==2){var i=$('<div class="div_filter"><\/div>').data("parameter",n).data("inputtype","dropdown"),u=getLookupDatasource(n.LookupDatasourceID),r=[...u.Items];return!n.IsAllAllowed||n.IsField&&n.MutipleSelect||r.splice(0,0,{Key:ALL_VALUE,Value:ALL_TEXT}),i.css("width",200).dropdown(r,{search:!0,multiselect:n.IsField&&n.MutipleSelect,valueKey:"Key",allowselectall:n.IsAllAllowed,textKey:n.DisplayCaptionField?"Value":"Key"}),n.IsField&&n.MutipleSelect?t==ALL_VALUE?i.allselected(!0):t&&i.dropdownVals(t.split(",")):i.dropdownVal(t),i}}function getLookupDatasource(n){var t=$("#selMapAlertLayer").find("option:selected").data("mal"),i,r;if(t&&t.LookupDataSources)for(i=0;i<t.LookupDataSources.length;i++)if(r=t.LookupDataSources[i],r.ID.toLowerCase()==n.toLowerCase())return r;return null}function layerclick(n){$("#ul_parameter li").removeClass("selected");$(this).addClass("selected");var i=n.data,t=$(".tb_parameter");t.hide();$(t[i]).show()}function getParameterValue(n,t){var f,i,r,u,e,o;if(parametervalues&&parametervalues.length>0)for(f=0;f<parametervalues.length;f++)if(i=parametervalues[f],i.Pivots){for(r=[],u=0;u<i.Pivots.length;u++)i.Pivots[u].IsCriteriaSQL==t&&r.push(i.Pivots[u]);if(i&&(r||r))for(e=0;e<r.length;e++)if(o=r[e],o.ID==n)return o.ParameterValue}return null}function openSetAlertLayerParameters(){setAlertLayerParameters();showmaskbg(!0);$("#dialog_parameter .dialog-title span.title").text(GetTextByKey("P_MV_PIVOTS","Pivots"));$("#dialog_parameter").attr("act","edit").css({width:570,top:(document.documentElement.clientHeight-$("#dialog_parameter").height())/2,left:(document.documentElement.clientWidth-$("#dialog_parameter").width())/2}).showDialogfixed();pivotsDialogOpend=!0}function setParameterCompleted(){parametervalues=getAlertLayerParameters();assetObject.searchMachine(!1);$("#dialog_parameter").hideDialog();showmaskbg(!1);pivotsDialogOpend=!1}function initMapMenuItems(n){var e,i,o,t,l,a,b,s,u,h,r,c;if(n){var k=$("#mapmenu ul").empty(),v=!1,f={},y={},p=!1,w=["100","150","200","250","300","350","400","450","500","550","600","650","675","700","9999"];for(e=0;e<w.length;e++)for(i=w[e],o=0;o<n.length;o++)if(t=n[o],t.Visible&&t.ID!="100")if(t.ID==i||i=="675"&&t.ID=="150"||i=="9999"&&t.ModuleType==1)if(p=!0,t.ModuleType==0){if(r={},r.name=t.CurrentName,r.icon=createicon,allItemUrls["m"+i]=t.Url,i=="675"&&(r.name=GetTextByKey("P_JS_ASSETSCHEDULINGANDDISPATCHING","Asset Scheduling and Dispatching"),allItemUrls["m"+i]="JobSite/img/dispatch.png"),l=0,t.SubItems&&t.SubItems.length>0){for(a={},i=="150"&&canEditJobsite&&(b={FeatureID:150,ID:"nav_addjobsite",IconPath:"img/jobsite.png",PageUrl:"AddJobSite.aspx",Title:"Add JobSite",Url:"JobSite/AddJobSite.aspx"},t.SubItems.push(b)),s=0;s<t.SubItems.length;s++)(u=t.SubItems[s],i!="150"||u.FeatureID==100||u.FeatureID==150)&&(i!="675"||u.FeatureID!=100&&u.FeatureID!=150)&&(h={},h.name=getitemname(u.ID,u.Title),h.icon=function(){return"context-menu-icon menuicon"},a["sm"+u.ID]=h,l++,allItemUrls["sm"+u.ID]=u.Url);r.items=a}(i!="150"&&i!="675"||l>0)&&(f["m"+i]=r)}else t.ModuleType==1&&(v||(f.sep1="---------",r={},r.name=GetTextByKey("P_MAIN_DASHBOARDS","Dashboards"),r.icon=createicon,r.items=y,f.wsp=r,v=!0),c={},c.name=t.Name,c.icon=createicon,y["w"+t.ID]=c,allItemUrls["w"+t.ID]=t.Url);else continue;p&&$.contextMenu({selector:"#mapView",callback:function(n){var t=allItemUrls[n];t&&(t.length>4&&t.substring(0,4)=="http"||t.length>0&&t[0]=="/"||(t=_network.root+t),n.indexOf("nav_addjobsite")>=0?OnAddJobsite():window.open(t,"_blank"))},items:f});$(".context-menu-item .context-menu-list").css({"max-height":$(document).height()-150,"overflow-x":"hidden","overflow-y":"auto"});$(window).resize(function(){$(".context-menu-item .context-menu-list").css("max-height",$(window).height()-150)})}}function createicon(n,t,i){var r=i.substr(1);return"context-menu-icon menuicon"+(r=="100"?" menuiconmap":r=="150"?" menuiconjobsite":r=="200"?" menuiconpmalerts":r=="250"?" menuiconfilterq":r=="300"?" menuiconcredentials":r=="350"?" menuiconpmsecurity":r=="400"?" menuiconassets":r=="450"?" menuiconfic":r=="500"?" menuiconm3":r=="550"?" menuiconjobsitelimit":r=="600"?" menuiconotrconfig":r=="650"?" menuiconinspection":r=="675"?" menuicondispatch":r=="700"?" menuiconteam":r==="sp"?" menuicondashboard":" menuiconwsp")}function getitemname(n,t){return n==="nav_jobsiterequirements"?t=GetTextByKey("P_JS_JOBSITEREQUIREMENTS",t):n==="nav_dispatchrequests"?t=GetTextByKey("P_JS_DISPATCHREQUESTS",t):n==="nav_jobsitemanage"?t=GetTextByKey("P_JOBSITES",t):n==="nav_scheduler"?t=GetTextByKey("P_JS_SCHEDULER",t):n==="nav_alertsmanagement"?t=GetTextByKey("P_ALERTSMANAGEMENTNEW",t):n==="nav_alertsmappings"?t=GetTextByKey("P_ALERTMAPPINGS",t):n==="nav_workorder"?t=GetTextByKey("P_WORKORDERNEW",t):n==="nav_workorderhis"?t=GetTextByKey("P_WORKORDERHISTORY",t):n==="nav_record"?t=GetTextByKey("P_MAINTENANCERECORDLEGACY",t):n==="nav_fuelrecord"?t=GetTextByKey("P_FUELRECORDS",t):n==="nav_maintenanceschedule"?t=GetTextByKey("P_PM_MAINTENANCESCHEDULES",t):n==="nav_scheduler"?t=GetTextByKey("P_JS_SCHEDULER",t):n==="nav_surveymanagementresult"?t=GetTextByKey("P_WOS_SURVEYMANAGEMENTRESULT",t):n==="nav_wosurveytemplate"?t=GetTextByKey("P_WOS_TEMPLATES",t):n==="nav_wosurveytemplatereport"?t=GetTextByKey("P_WOS_TEMPLATES_REPORT",t):n==="nav_credential"?t=GetTextByKey("P_CREDENTIALS",t):n==="nav_jdlink"?t=GetTextByKey("P_JOHNDEERE",t):n==="nav_jdnotification"?t=GetTextByKey("P_JOHNDEERENOTIFICATIONS",t):n==="nav_apicredential"?t=GetTextByKey("P_APICREDENTIALS",t):n==="nav_users"?t=GetTextByKey("P_USERS",t):n==="nav_user_group"?t=GetTextByKey("P_USERSGROUP",t):n==="nav_dts"?t=GetTextByKey("P_DATATABLEPERMISSION",t):n==="nav_filters"?t=GetTextByKey("P_DASHBOARDFILTERS",t):n==="nav_curfew"?t=GetTextByKey("P_CURFEWCONFIGURATION",t):n==="nav_curfewmt"?t=GetTextByKey("P_CURFEWMOVEMENTTOLERANCE",t):n==="nav_usertocontractor"?t=GetTextByKey("P_USERTOCONTRACTOR",t):n==="nav_managmachines"?t=GetTextByKey("P_MANAGEASSETS",t):n==="nav_managrentals"?t=GetTextByKey("P_MANAGERENTALS",t):n==="nav_machinegroups"?t=GetTextByKey("P_ASSETGROUPS",t):n==="nav_managegpsdevices"?t=GetTextByKey("P_MANAGEDEVICES",t):n==="nav_managmodels"?t=GetTextByKey("P_MANAGEMODELS",t):n==="nav_customerrecord"?t=GetTextByKey("P_CUSTOMERRECORD",t):n==="nav_addjobsite"?t=GetTextByKey("P_JS_ADDJOBSITE",t):n==="nav_assethistory"&&(t=GetTextByKey("P_MA_ASSETHISTORY",t)),t}function getMachineStateObj(n){var t=machineStates["MID"+n];return t||(t={Selected:!1,Highlight:!1,ShowSummary:!1},machineStates["MID"+n]=t),t}function resetMachineState(){machineStates=[];clearLocationHistory();$("#locationhistoryDiv").hide();resiezrightCtrl();$("#tripDiv").hide();allJobsites=[];allGroups=[]}function initPlayBar(){$.playBar.addBar($("#divPlayBar"),0);$.playBar.changeBarColor("#FFA500");$.playBar.changeFontColor("#000000");$.playBar.onPlayClick=onPlayClick}function onPlayClick(n){var t=getLocationHistory(n);t===1&&(n?$.playBar.PlayEnd():$.playBar.Play())}function openSetLocationHistory(){$("#dialog_locationhistory .dialog-title span.title").text(GetTextByKey("P_MA_LOCATIONHISTORY","Location History"));$("#btnLoadTrip").hide();getAssetDatasources();$("#locationhistoryDiv").show();$("#rightCtrl").width()==0&&$("#splitIconRight").click();resiezrightCtrl()}function locationHistoryClick(n){if(locationTimeperiodChange(),$("#btnClearTrip").trigger("click"),PopupViewShowing){n&&(showmaskbg(!0),$("#dialog_lochis").css({width:document.documentElement.clientWidth-200,height:document.documentElement.clientHeight-150}).showDialogfixed(),execIframeFunc("getlocationhis",[n.data.CompanyID||"",n.data.ID,n.data.DisplayName],"iframelochis"));return}if(n&&(currentLocationHistoryMachine=n.data),currentLocationHistoryMachine){$.playBar.Clear();LocationHistoryInfo=null;mapHelper.clearLocationHistory();var t=currentLocationHistoryMachine.DisplayName;t&&t!=""||(t+=" - "+currentLocationHistoryMachine.DisplayName);$("#spMachineName").text(t);openSetLocationHistory()}}function locationTimeperiodChange(){var u=getCurrentDate(),r,i,o,f;if(u||(u=currentdate),r=$("#dialog_timeperiod").val(),i=!1,r!=="4"){i=!0;var n=new Date(u),t=new Date(u),s=t.getHours(),e=t.getMinutes();r==="2"?(n.setDate(n.getDate()-1),t.setDate(t.getDate()-1)):r==="3"?n.setDate(n.getDate()-6):r==="5"&&n.setDate(n.getDate()-1);n=n.getMonth()+1+"/"+n.getDate()+"/"+n.getFullYear();t=t.getMonth()+1+"/"+t.getDate()+"/"+t.getFullYear();$("#dateFrom").val(n);$("#dateTo").val(t);$("#dialog_starttimehour").val("00");$("#dialog_starttimeminute").val("00");$("#dialog_endtimehour").val("23");$("#dialog_endtimeminute").val("59");r==="5"&&(o=e+1,f=s,e==59&&(f=f+1,o=0),$("#dialog_starttimehour").val(setTimeSelect(f)),$("#dialog_starttimeminute").val(setTimeSelect(o)),$("#dialog_endtimehour").val(setTimeSelect(s)),$("#dialog_endtimeminute").val(setTimeSelect(e)))}$("#dateFrom").attr("disabled",i);$("#dialog_starttimehour").attr("disabled",i);$("#dialog_starttimeminute").attr("disabled",i);$("#dateTo").attr("disabled",i);$("#dialog_endtimehour").attr("disabled",i);$("#dialog_endtimeminute").attr("disabled",i)}function getLocationHistory(n){var t=$("#dateFrom").val(),i=$("#dateTo").val(),u=$("#dialog_starttimehour").val(),f=$("#dialog_starttimeminute").val(),e=$("#dialog_endtimehour").val(),o=$("#dialog_endtimeminute").val();if(t=t.replace("-","/")+" "+u+":"+f+":00",i=i.replace("-","/")+" "+e+":"+o+":59",new Date(t)>new Date(i)){_dialog.showAlert(GetTextByKey("P_MV_FROMDATETIMEMUSTBEPRIORTOTODATETIME","From Date/Time must be prior to To Date/Time."),GetTextByKey("P_MA_LOCATIONHISTORY","Location History"));return}var s=currentLocationHistoryMachine.CompanyID||"",h=currentLocationHistoryMachine.ID,r=h+";"+t+";"+i,c=$("#chkExclude00Loc").is(":checked");if(r+=";"+s+";"+(c?"1":"0")+";"+Datasource,$("#selLocDatasource").val()=="0"){if($.playBar.getAllTime()>0&&lastHisFromDT==t&&lastHisToDT==i)return 1;$.playBar.Clear();LocationHistoryInfo=null;mapHelper.clearLocationHistory();lastHisFromDT=t;lastHisToDT=i;$("#btnHisLoading").show();_network.mapviewquery("GetHistoryLocation",r,function(t){$("#btnHisLoading").hide();t&&t.Machine.ID===currentLocationHistoryMachine.ID&&showLocationHistory(t,n)},function(){$("#btnHisLoading").hide()})}else getMultipleHistoryLocation(t,i)}function showLocationHistory(n,t){LocationHistoryInfo=n;LocationHistoryInfo.Machine&&LocationHistoryInfo.Locations&&($.playBar.onBarChanged=doShowLocationHistory,t?$.playBar.restTime(LocationHistoryInfo.Locations.length*1e3,!0,!0):$.playBar.restTime(LocationHistoryInfo.Locations.length*1e3))}function doShowLocationHistory(n,t){var i=parseInt(n/1e3)-1;i<0&&(i=0);LocationHistoryInfo.Machine&&LocationHistoryInfo.Locations&&(t?mapHelper.showLocationHistoryFromStart(LocationHistoryInfo.Machine,LocationHistoryInfo.Locations,i,!0):i<LocationHistoryInfo.Locations.length&&mapHelper.showLocationHistory(LocationHistoryInfo.Machine,LocationHistoryInfo.Locations[i],!0))}function clearLocationHistory(){$.playBar.Clear();LocationHistoryInfo=null;isMapLoaded&&mapHelper.clearLocationHistory()}function setUserParams(){_network.mapviewquery("SetUserParams",JSON.stringify(userParams),function(){})}function displayFilerIcon(){var n=$("#txtMachineSearchText").val();n+=$("#txtJobSiteSearchText").val();n+=$("#txtAssetGroupSearchText").val();var t=assetObject.getUnShownMachines(),i=jobsiteObject.getUnShownJobsites(),r=jobsiteObject.getUnShownMachines();$.trim(n)===""&&$("#selOnroad").val()=="-1"&&$("#exclude00Div").attr("state")=="0"&&t.length==0&&i.length==0&&r.length==0?$("#filterIconDiv").hide():$("#filterIconDiv").show()}function doDirections(n,t){var i="https://www.google.com/maps/dir/?api=1&destination="+n+","+t+"&travelmode=driving";window.open(i)}function doWeather(n,t){var i="https://www.wunderground.com/weather/"+n+","+t;window.open(i)}function doLocationHistory(n,t,i){selectedAsset&&(selectedAsset.State.Highlight=!1);var r={CompanyID:n,ID:t,DisplayName:decodeURIComponent(i)},u={data:r};locationHistoryClick(u)}function getNowFormatDate(){_network.mapviewquery("GetNowFormatDate","",function(n){$("#refreshTimeDiv").text(GetTextByKey("P_MV_LASTREFRESHED","Last Refreshed: ")+n)})}function treeIconClick(n){var t=$(n.target),i=t.parent().children(".subul");t.hasClass("treeiconc")?(t.removeClass("treeiconc").addClass("treeicone"),i.show()):(t.removeClass("treeicone").addClass("treeiconc"),i.hide())}function isAssetMatch(n,t){return!t||t==""?!0:n&&(t=t.toLowerCase(),n.ID.toString().indexOf(t)>=0||n.VIN.toLowerCase().indexOf(t)>=0||n.DisplayName.toLowerCase().indexOf(t)>=0||n.Make.toLowerCase().indexOf(t)>=0||n.Model.toLowerCase().indexOf(t)>=0||n.AssetType.toLowerCase().indexOf(t)>=0)?!0:!1}function openVideoDialog(n){var r=$.trim(decodeURIComponent(n)),t=new $form,i;t.createForm("",$("body"),600,400);i=$('<div style="height: 100%"><video width="100%" height="100%" src="'+r+'" controls="controls" autoplay="autoplay"><\/video><\/div>');t.bodyCtrlAppend(i);t.show();t.maskbg&&t.maskbg.css("z-index",650);t.formCtrl&&t.formCtrl.css("z-index",700);t.maskbg.hide()}function openRequestVideoDialog(n,t){var r,o,e,i,u,f;_videoRequestAssetID=n;t===undefined?(r=assetLocations[n],$("#dialog_hlogid").val("-1")):(r=assetHisLocations[t],$("#dialog_hlogid").val(t));o=r.LocationTimeText;r&&r.LocationTimeText&&r.LocationTimeText!=""?(i=new Date(o),e=i.getMonth()+1+"/"+i.getDate()+"/"+i.getFullYear()):(i=new Date(currentdate),e=i.getMonth()+1+"/"+i.getDate()+"/"+i.getFullYear());$("#dialog_videodate").val(e);u=i.getHours();u=(u<10?"0":"")+u;$("#dialog_videohour").val(u);f=i.getMinutes();f=(f<10?"0":"")+f;$("#dialog_videominute").val(f);$("#dialog_videoct").prop("checked",!1);$("#dialog_videoct").change();showmaskbg(!0);$("#dialog_requestvideo").attr("act","edit").css({width:300,top:(document.documentElement.clientHeight-$("#dialog_requestvideo").height())/4,left:(document.documentElement.clientWidth-$("#dialog_requestvideo").width())/2}).showDialogfixed()}function requestVideo(){var r=$("#dialog_videoct").prop("checked")?1:0,t=$("#dialog_videodate").val(),u=$("#dialog_videohour").val(),f=$("#dialog_videominute").val(),i,n;t=t.replace("-","/")+" "+u+":"+f+":00";i=$("#r30sec").prop("checked")?1:0;n=$("#dialog_hlogid").val()=="-1"?assetLocations[_videoRequestAssetID]:assetHisLocations[parseInt($("#dialog_hlogid").val())];var e=n.CompanyID||"",o=n.LogId,s=n.DataSource,h=n.SubSource,c=n.EventType,l=n.MsgUID;_network.mapviewquery("RequestVideo",JSON.stringify([e,_videoRequestAssetID,r,t,i,o,s,h,c,l]),function(n){n=="OK"?_dialog.showAlert(GetTextByKey("P_MV_REQUESTVIDEOSUCCESSFULLY","A video has been successfully requested for this Asset at the timestamp indicated. The requested video will be emailed to you once it is available. If the Asset or Camera are currently offline, the requested video will be sent as soon as it is available."),GetTextByKey("P_MV_REQUESTVIDEO","Request Video")):_dialog.showAlert(GetTextByKey("P_MV_REQUESTVIDEOFAILED","Request video failed."),GetTextByKey("P_MV_REQUESTVIDEO","Request Video"))},function(){})}function openTrips(n){$("#tbTrips").empty();getAssetTripLins(n)}function openTheft(n){var t=$("#dateFrom").val(),i=$("#dateTo").val(),r=$("#dialog_starttimehour").val(),u=$("#dialog_starttimeminute").val(),f=$("#dialog_endtimehour").val(),e=$("#dialog_endtimeminute").val();if(t=t.replace("-","/")+" "+r+":"+u+":00",i=i.replace("-","/")+" "+f+":"+e+":59",new Date(t)>new Date(i)){_dialog.showAlert(GetTextByKey("P_MV_FROMDATETIMEMUSTBEPRIORTOTODATETIME","From Date/Time must be prior to To Date/Time."),GetTextByKey("P_MA_LOCATIONHISTORY","Location History"));return}typeof n=="function"&&n();getTheftDatasources(t,i)}function getAssetDatasources(){var t=currentLocationHistoryMachine.CompanyID||"",i=currentLocationHistoryMachine.ID,r=i+";"+t,u=$("#containerTheft").empty(),n=$("#selLocDatasource").val();prumaryDatasource=null;_network.mapviewquery("GetAssetLocationDataSources",r,function(t){for(var i,e,f,r=0;r<t.length;r++)i=t[r],i.color=i.IsPrimary?[225,95,72]:lineColors[r%16],i.IsPrimary&&(prumaryDatasource=i.DataSource),e=$('<div class="theft-datasource-item"><\/div>'),f=$("<label><\/label>"),f.append($('<input type="checkbox"><\/input>').data("ds",i).val(String(r)).prop({disabled:n=="0",checked:n!="0"||i.IsPrimary})),f.append($('<span class="theft-datasource-line"><\/span>').css({"background-color":"#"+i.color.map(function(n){return Number(n).toString(16).padStart(2,"0")}).join(""),height:i.IsPrimary?5:3})),f.append($("<span><\/span>").text(i.DisplayName)),e.append(f),u.append(e);prumaryDatasource&&prumaryDatasource.toLowerCase()==="calamp"&&n=="0"?$("#btnLoadTrip").show():$("#btnLoadTrip").hide();resiezrightCtrl()})}function getAssetTripLins(n){var u=currentLocationHistoryMachine.CompanyID||"",f=currentLocationHistoryMachine.ID,t=$("#dateFrom").val(),i=$("#dateTo").val(),e=$("#dialog_starttimehour").val(),o=$("#dialog_starttimeminute").val(),s=$("#dialog_endtimehour").val(),h=$("#dialog_endtimeminute").val(),r;(t=t.replace("-","/")+" "+e+":"+o+":00",i=i.replace("-","/")+" "+s+":"+h+":59",new Date(t)>new Date(i))||(n?$("#tripDiv").css({left:"unset",right:11,bottom:0,height:"65%"}):$("#tripDiv").css({left:0,right:"unset",bottom:1,height:450}),$("#tripDiv").show(),r=f+";"+t+";"+i,r+=";"+u,_network.mapviewquery("GetAssetTripLins",r,function(n){showAssetTripLins(n)},function(){}))}function changeLocDatasource(){var n=$("#selLocDatasource").val();n=="0"?(prumaryDatasource&&prumaryDatasource.toLowerCase()==="calamp"?$("#btnLoadTrip").show():$("#btnLoadTrip").hide(),$("#playBarContainer").show(),$("#btnTheftModeReload").hide()):n=="1"?($("#btnClearTrip").trigger("click"),$("#btnLoadTrip").hide(),$("#playBarContainer").hide(),$("#btnTheftModeReload").show()):($("#btnClearTrip").trigger("click"),$("#btnLoadTrip").hide(),$("#playBarContainer").hide(),$("#btnTheftModeReload").show());$("#containerTheft").find('input[type="checkbox"]').each(function(){var t=$(this),i=t.data("ds");t.prop({disabled:n=="0",checked:n!="0"||i.IsPrimary})});resiezrightCtrl()}function resiezrightCtrl(){setTimeout(function(){$("#divLegend").css("max-height",$("#rightCtrl").height()-($("#locationhistoryDiv").is(":hidden")?0:$("#locationhistoryDiv").height())-50)})}function getMultipleHistoryLocation(n,t){var u=currentLocationHistoryMachine.CompanyID||"",f=currentLocationHistoryMachine.ID,e=$("#chkExclude00Loc").is(":checked"),o=f+";"+n+";"+t+";"+u+";"+(e?"1":"0")+";",s=$("#containerTheft"),i=[],r;s.find('input[type="checkbox"]').each(function(){var n=$(this);n.prop("checked")&&i.push(n.data("ds"))});dsLocations=[];r=i.map(function(n,t){return new Promise(function(i){_network.mapviewquery("GetHistoryLocation",o+n.DataSource+";"+n.SubSource,function(r){r?.Machine?.ID===currentLocationHistoryMachine.ID&&(r.DataSource=n,dsLocations[t]=r);i(r)},i)})});clearLocationHistory();Promise.all(r).then(function(){var n,i,t;if($("#selLocDatasource").val()=="1")for(t=0;t<dsLocations.length;t++)n=dsLocations[t],n.Locations.length>0&&mapHelper.showLocationHistoryFromStart(n.Machine,n.Locations,n.Locations.length-1,t==dsLocations.length-1,!0,n.DataSource.IsPrimary?null:n.DataSource.color,n.DataSource.IsPrimary?null:3);else{for(n=null,i=[],t=0;t<dsLocations.length;t++)n=dsLocations[t],n.Locations.length>0&&(i=i.concat(n.Locations));n&&i.length>0&&(i.sort(function(n,t){return n.LocationTime==t.LocationTime?0:n.LocationTime>t.LocationTime?1:-1}),mapHelper.showLocationHistoryFromStart(n.Machine,i,i.length-1,!0,!0,null,null))}})}function getTheftDatasources(n,t){var u=currentLocationHistoryMachine.CompanyID||"",f=currentLocationHistoryMachine.ID,r,i;$("#theftLoading").show();r=f+";"+u;i=$("#containerTheft").empty();_network.mapviewquery("GetTheftDatasources",r,function(r){var u;mapHelper.clearLocationHistory();var f=currentLocationHistoryMachine.CompanyID||"",e=currentLocationHistoryMachine.ID,o=$("#chkExclude00Loc").is(":checked"),s=e+";"+n+";"+t+";"+f+";"+(o?"1":"0")+";";dsLocations=[];u=r.map(function(n,t,i){return new Promise(function(r){_network.mapviewquery("GetHistoryLocation",s+n.DataSource+";"+n.SubSource,function(u){u?.Machine?.ID===currentLocationHistoryMachine.ID&&(n.color=n.IsPrimary?[225,95,72]:lineColors[t%16],n.count=u?.Locations?.length,u.DataSource=n,dsLocations[t]=u,n.count>0&&mapHelper.showLocationHistoryFromStart(u.Machine,u.Locations,u.Locations.length-1,t==i.length-1,!0,n.IsPrimary?null:n.color,n.IsPrimary?null:3));r(u);resiezrightCtrl()},r)})});Promise.all(u).then(function(){function e(){var r,n,u,t;if(mapHelper.clearLocationHistory(),r=[],i.find('input[type="checkbox"]').each(function(){var n=$(this);n.prop("checked")&&r.push(dsLocations[n.val()])}),$("#selLocDatasource").val()=="1")for(t=0;t<r.length;t++)n=r[t],mapHelper.showLocationHistoryFromStart(n.Machine,n.Locations,n.Locations.length-1,t==r.length-1,!0,n.DataSource.IsPrimary?null:n.DataSource.color,n.DataSource.IsPrimary?null:3);else{for(n=null,u=[],t=0;t<r.length;t++)n=r[t],u=u.concat(n.Locations);n&&u.length>0&&(u.sort(function(n,t){return n.LocationTime==t.LocationTime?0:n.LocationTime>t.LocationTime?1:-1}),mapHelper.showLocationHistoryFromStart(n.Machine,u,u.length-1,!0,!0,null,null))}}var t,n,f,u;$("#selLocDatasource").off("change").on("change",e);for(t=0;t<r.length;t++)(n=r[t],n.color!=null)&&(f=$('<div class="theft-datasource-item"><\/div>'),u=$("<label><\/label>"),u.append($('<input type="checkbox"><\/input>').data("ds",n).val(String(t)).prop({disabled:!(n.count>0),checked:n.count>0}).on("change",e)),u.append($('<span class="theft-datasource-line"><\/span>').css({"background-color":"#"+n.color.map(function(n){return Number(n).toString(16).padStart(2,"0")}).join(""),height:n.IsPrimary?5:3})),u.append($("<span><\/span>").text(n.DisplayName)),f.append(u),i.append(f));$("#theftLoading").hide()})},function(){})}function showAssetTripLins(n){var e=$("#tbTrips"),f,t,i;for(e.empty(),f=0;f<n.length;f++){var r=n[f],l=getTripColor(r),u=$("<tr style='border-bottom: 1px solid lightgray;'><\/tr>");e.append(u);t=$("<td><\/td>").css("width",30);u.append(t);var o=$(' <div class="div_check"><\/div>'),s="tripitem"+f,h=$('<input type="checkbox" value="1" name="" id="'+s+'"/>').data("trip",r).data("row",u),c=$('<label for="'+s+'" class="la1_check"><\/label>');c.css("background-color",l);o.append(h).append(c);t.append(o);h.click(function(n){var t=$(n.target).data("trip"),i=$(n.target).data("row");t&&(t.TripOn||t.TripOff)&&($(n.target).prop("checked")?(mapHelper.changeLineColor(t.TripOn?t.TripOn.LocalAsofTime:null,t.TripOff?t.TripOff.LocalAsofTime:null,getTripColorArray(t)),i.css("background-color","lightgray")):(mapHelper.changeLineColor(t.TripOn?t.TripOn.LocalAsofTime:null,t.TripOff?t.TripOff.LocalAsofTime:null,null),i.css("background-color","white")))});t=$("<td><\/td>").css("width",150);u.append(t);i=$("<span><\/span>").text(r.TripOnLocalAsofTimeStr);t.append(i).append($("<br>"));i=$("<span><\/span>").text(r.TripOffLocalAsofTimeStr);t.append(i);t=$("<td><\/td>").css("width",180);u.append(t);i=$('<span class="tripaddress_span"><\/span>').attr("title",r.TripOnAddress).text(r.TripOnAddress);t.append(i).append($("<br>"));i=$('<span class="tripaddress_span"><\/span>').attr("title",r.TripOffAddress).text(r.TripOffAddress);t.append(i);t=$("<td><\/td>").css({width:100,"text-align":"right"});u.append(t);i=$("<span><\/span>").text(r.TripDistance?r.TripDistance:"");t.append(i);i=$("<span><\/span>").text(r.TripDistance?" "+r.TripDistanceUnit:"");t.append(i);t=$("<td><\/td>").css("width",60);u.append(t);i=$('<span style="padding-left:6px;"><\/span>').text(r.TripTimeStr);t.append(i)}}function getTripColor(n){var t="#c8c4c4";return n.Color===0?t="#0000FF":n.Color===1?t="#4FBC20":n.Color===2?t="#FF00FF":n.Color===3?t="#FFFF00":n.Color===4?t="#ebbeb3":n.Color===5&&(t="#ff0000"),t}function getTripColorArray(n){var t=[225,95,72];return n.Color===0?t=[0,0,255]:n.Color===1?t=[79,188,32]:n.Color===2?t=[255,0,255]:n.Color===3?t=[255,255,0]:n.Color===4?t=[235,190,179]:n.Color===5&&(t=[255,0,0]),t}function getAssetMapAttachments(n,t){showmaskbg(!0);$("#dialog_assetattachments").css({top:(document.documentElement.clientHeight-$("#dialog_assetattachments").height())/4,left:(document.documentElement.clientWidth-$("#dialog_assetattachments").width())/2}).showDialogfixed();var i=$("#divassetattachments").empty();i.find(".attachmentsmask").show();_network.mapviewquery("GetAssetMapAttachments",JSON.stringify([n,t]),function(n){var r,t,u,f,e;if(i.find(".attachmentsmask").hide(),n&&n.length>0)for(r=0;r<n.length;r++)t=n[r],imgTypes.indexOf(t.FileType.toLowerCase())>=0&&(t.ThumbnailUrl=t.Url+"&thumb=1"),u=createAttaDiv(t),$.inArray(t.FileType.toLowerCase(),printTypes)>=0&&(f=$('<span class="attaprint"><\/span>').attr("title",GetTextByKey("P_WO_PRINT","Print")).click(t,function(n){openPrintFrame(n.data.AttachmentType,n.data.AttachmentIdStr)}),u.append(f)),t.FileType.toLowerCase()!="url"&&(e=$('<span class="attadownload"><\/span>').attr("title",GetTextByKey("P_WO_DOWNLOAD","Download")).click(t,function(n){openDownloadFrame(n.data.Url+"&d=1")}),u.append(e)),i.append(u)},function(){i.find(".attachmentsmask").hide()})}function createAttaDiv(n){var t=$('<div class="divatt"><\/div>').attr("title",n.Name),i,r;return n.FileType&&n.FileType!=""||(n.FileType=".jpg"),imgTypes.indexOf(n.FileType.toLowerCase())>=0?(i=$('<img class="picture"><\/img>').attr("src",n.ThumbnailUrl),i.click(n,function(n){window.open(n.data.Url,"_blank")}),t.append(i)):(r=$('<img class="picture" />').click(n,function(n){window.open(n.data.Url)}),setAttachemntIcon(n.FileType,r),t.append(r)),t}function setAttachemntIcon(n,t){[".doc",".docx"].indexOf(n)>=0?t.attr("src","img/icon/word.jpg"):[".xls",".xlsx"].indexOf(n)>=0?t.attr("src","img/icon/excel.jpg"):[".ppt",".pptx"].indexOf(n)>=0?t.attr("src","img/icon/ppt.jpg"):[".pdf",".xps"].indexOf(n)>=0?t.attr("src","img/icon/pdf.jpg"):[".mp4",".mov",".avi",".mkv",".3gp",".ts",".m2ts"].indexOf(n)>=0?t.attr("src","img/icon/vedio.jpg"):[".zip",".rar",".7z"].indexOf(n)>=0?t.attr("src","img/icon/zip.jpg"):[".msg"].indexOf(n)>=0?t.attr("src","img/icon/msg.jpg"):[".xml"].indexOf(n)>=0?t.attr("src","img/icon/xml.jpg"):t.attr("src","img/icon/txt.jpg")}function initaiwebsocket(){function t(){typeof AiNotifyAddress!="undefined"&&(n=new $websocket(AiNotifyAddress),n.onreceive=i,n.connect())}function i(n){if(console.log(JSON.stringify(n)),n&&n.CMD=="100"){var t=getAsset(n.Args.Id);t&&mapHelper.locateMachine(t)}}var n;t()}function OnRightExpend(n){var t=$(n),i=t.attr("target");t.hasClass("iconchevrondown")?(t.removeClass("iconchevrondown").addClass("iconchevronright"),$("#"+i).hide()):(t.removeClass("iconchevronright").addClass("iconchevrondown"),$("#"+i).show());resiezrightCtrl()}function showGridList(n){showSearchList(n,userParams.MapViewSearches)}function showSearchList(n,t){var u,r,i,f;if(n.setData([]),t&&t.length!==0){for(u=[],r=0;r<t.length;r++){i=t[r];for(f in i)f==="IsDefault"&&(i.IsDefaultText=i.IsDefault?GetTextByKey("P_MV_YES","Yes"):GetTextByKey("P_MV_NO","No"));i.Text=!1;i.Email=!1;u.push(i)}n.setData(u)}}function openSavedSearches(){showmaskbg(!0);$("#dialog_savedsearches .dialog-title span.title").text(GetTextByKey("P_MV_SAVEDSEARCHES","Saved Searches"));$("#dialog_savedsearches").css({width:450,top:(document.documentElement.clientHeight-$("#dialog_savedsearches").height())/4,left:(document.documentElement.clientWidth-$("#dialog_savedsearches").width())/2}).showDialogfixed();showGridList(savedsearches_dt)}function InitSavedSearchGrid(){var t,r,i,n;savedsearches_dt=createGridView("#savedsearchlist");t=[{name:"Name",caption:GetTextByKey("P_MV_SEARCHNAME","Search Name"),valueIndex:"Name",css:{width:250,"text-align":"left"}},{name:"IsDefault",caption:GetTextByKey("P_MV_DEFAULT","Default"),valueIndex:"IsDefaultText",css:{width:70,"text-align":"left"}},{name:"Apply",caption:"",css:{width:30,"text-align":"center"}},{name:"Delete",caption:"",css:{width:30,"text-align":"center"}}];r=[];for(i in t)n={},n.name=t[i].name,n.caption=t[i].caption,n.visible=!0,n.sortable=!0,n.width=t[i].css.width,n.align=t[i].css["text-align"],n.key=t[i].valueIndex,t[i].type&&(n.type=t[i].type),n.name==="Apply"?(n.sortable=!1,n.resizable=!1,n.type=GridView.ColumnTypes.Icon,n.text="history",n.iconType="fa-light",n.events={onclick:function(){onLoadSavedSearches(this)}},n.attrs={title:GetTextByKey("P_MV_APPLY","Apply")}):n.name==="Delete"&&(n.sortable=!1,n.resizable=!1,n.type=GridView.ColumnTypes.Icon,n.text="times",n.iconType="fa-light",n.events={onclick:function(){OnDeleteSavedSearches(this)}},n.attrs={title:GetTextByKey("P_MV_DELETE","Delete")}),r.push(n);savedsearches_dt.multiSelect=!1;savedsearches_dt.columns=r;savedsearches_dt.init();savedsearches_dt.onSelectedRowChanged=function(n){var t=savedsearches_dt.source[n];t&&$("#savedsearch_searchname").val(t.Name)};savedsearches_dt.onRowDblClicked=function(n){var t=savedsearches_dt.source[n];t&&onLoadSavedSearches(t)}}function OnDeleteSavedSearches(n){n&&showConfirm(GetTextByKey("P_MV_SEARCHDELETEWANTTOCONTINUE","Search {0} will be permanently deleted.Do you want to continue?").replace("{0}",n.Name),GetTextByKey("P_MV_DELETESEARCH","Delete Search"),function(){_network.mapviewquery("DeleteMapViewSearch",n.Name,function(n){n&&(userParams.MapViewSearches=n,showGridList(savedsearches_dt))},function(){_dialog.showAlert(GetTextByKey("P_MV_FAILEDTODELETETHISSEARCH","Failed to delete this search."),GetTextByKey("P_MV_DELETESEARCH","Delete Search"))})})}function onLoadSavedSearches(n){var i,t;if(!n){if(i=$("#savedsearch_searchname").val(),i==="")return;if(!userParams.MapViewSearches||userParams.MapViewSearches.length==0){_dialog.showAlert(GetTextByKey("P_MV_YOUHAVENOSAVEDSEARCHES","You have no saved searches."),"");return}for(t=0;t<userParams.MapViewSearches.length;t++)if(userParams.MapViewSearches[t].Name.toLowerCase()===i.toLowerCase()){n=userParams.MapViewSearches[t];break}}if(!n){_dialog.showAlert(GetTextByKey("P_MV_SEARCHDOESNOTEXIST","Search {0} does not exist.").replace("{0}",$("#savedsearch_searchname").val()),"");return}setSavedSearche(n);refreshData();$("#dialog_savedsearches").hideDialog();showmaskbg(!1)}function setSavedSearche(n){$("#selOnroad").val(n.Onroad);$("#selAttachment").val(n.Attachment);$("#txtMachineSearchText").val(n.AssetDefaultSearch);$("#txtJobSiteSearchText").val(n.JobSiteDefaultSearch);$("#txtAssetGroupSearchText").val(n.AssetGroupDefaultSearch);setExclude00(n.ExcludeNoLocation);assetObject.setUnShownMachines(n.UnShownMachines);jobsiteObject.setUnShownJobsites(n.UnShownJobsites);jobsiteObject.setUnShownMachines(n.UnShownJobsiteMachines);resetMachineState()}function openSaveSearch(){$("#savesearch_searchname").val("");$("#savesearch_default").prop("checked",!1);showmaskbg(!0);$("#dialog_savesearch .dialog-title span.title").text(GetTextByKey("P_MV_SAVESEARCH","Save Search"));$("#dialog_savesearch").attr("act","edit").css({width:450,top:(document.documentElement.clientHeight-$("#dialog_savesearch").height())/4,left:(document.documentElement.clientWidth-$("#dialog_savesearch").width())/2}).showDialogfixed();showGridList(savesearch_dt)}function InitSaveSearchGrid(){var t,r,i,n;savesearch_dt=createGridView("#savesearchlist");t=[{name:"Name",caption:GetTextByKey("P_MV_SEARCHNAME","Search Name"),valueIndex:"Name",css:{width:250,"text-align":"left"}},{name:"IsDefault",caption:GetTextByKey("P_MV_DEFAULT","Default"),valueIndex:"IsDefaultText",css:{width:70,"text-align":"left"}}];r=[];for(i in t)n={},n.name=t[i].name,n.caption=t[i].caption,n.visible=!0,n.sortable=!0,n.width=t[i].css.width,n.align=t[i].css["text-align"],n.key=t[i].valueIndex,t[i].type&&(n.type=t[i].type),r.push(n);savesearch_dt.canMultiSelect=!1;savesearch_dt.columns=r;savesearch_dt.init()}function onSaveSearch(){var u=$("#savesearch_searchname").val(),n={Name:u,IsDefault:$("#savesearch_default").prop("checked"),Onroad:$("#selOnroad").val(),Attachment:$("#selAttachment").val(),AssetDefaultSearch:$("#txtMachineSearchText").val(),JobSiteDefaultSearch:$("#txtJobSiteSearchText").val(),AssetGroupDefaultSearch:$("#txtAssetGroupSearchText").val(),ExcludeNoLocation:$("#exclude00Div").attr("state")!="0",UnShownMachines:assetObject.getUnShownMachines(),UnShownJobsites:jobsiteObject.getUnShownJobsites(),UnShownJobsiteMachines:jobsiteObject.getUnShownMachines()},i,t,r;if(n.Name===""){_dialog.showAlert(GetTextByKey("P_MV_SEARCHNAMEISREQUIRED","Search Name is required."),GetTextByKey("P_MV_SAVESEARCH","Save Search"));return}if(i=!1,userParams.MapViewSearches)for(t=0;t<userParams.MapViewSearches.length;t++)if(r=userParams.MapViewSearches[t],r.Name.toLowerCase()===n.Name.toLowerCase()){i=!0;break}i?showConfirm(GetTextByKey("P_MV_SEARCHALREADYEXIST","Search {0} already exists. Would you like to replace?").replace("{0}",n.Name),GetTextByKey("P_MV_SAVESEARCH","Save Search"),function(){SaveMapViewSearch(n)}):SaveMapViewSearch(n)}function SaveMapViewSearch(n){_network.mapviewquery("SaveMapViewSearch",JSON.stringify(n),function(n){n&&(userParams.MapViewSearches=n,showGridList(savesearch_dt),$("#savesearch_searchname").val(""),$("#savesearch_default").prop("checked",!1),_dialog.showAlert(GetTextByKey("P_MV_SAVSUCCESSFULLY","Saved successfully."),GetTextByKey("P_MV_SAVESEARCH","Save Search")),$("#dialog_savesearch").hideDialog(),showmaskbg(!1))},function(){_dialog.showAlert(GetTextByKey("P_MV_FAILEDTOSAVETHISSEARCH","Failed to save this search."),GetTextByKey("P_MV_SAVESEARCH","Save Search"))})}function initshape(){shapevm=new Vue({el:"#shapeList",data:{shapes:[],DeleteTitle:GetTextByKey("P_MV_DELETE","Delete")},methods:{reload:function(n){var i,r,u,t;for(this.shapes=n,i=0,r=0;r<this.shapes.length;r++)u=this.shapes[r],u.Selected&&i++;t=document.getElementById("chkSelectAllShape");i==0?(t.checked=!1,t.indeterminate=!1):i==this.shapes.length?(t.checked=!0,t.indeterminate=!1):t.indeterminate=!0},chkShapeClick:function(n,t){var i=$(n.target),r=i.prop("checked");r?(getShapeFileData(t),selectedShapeFileID.indexOf(t.ID)<0&&selectedShapeFileID.push(t.ID)):(mapHelper.removeShape(t),selectedShapeFileID.splice(selectedShapeFileID.indexOf(t.ID),1));this.reload(this.shapes)},linkShapeClick:function(n){locateShape(n);n.Selected=!0;selectedShapeFileID.indexOf(n.ID)<0&&selectedShapeFileID.push(n.ID);this.reload(this.shapes)},deleteShapeClick:function(n){var t={data:n};deleteShapeClick(t)}}})}function getShapeFileInfos(){var n={Key:companyids,Value:htmlencode($("#txtShapeSearchText").val())};_network.mapviewquery("GetShapeFileInfos",JSON.stringify(n),function(n){if(typeof n=="string"){_dialog.showAlert(n,GetTextByKey("P_MV_ERROR","Error"));return}for(var t in n)n[t].Selected=selectedShapeFileID.indexOf(n[t].ID)<0?!1:!0;shapevm.reload(n)},function(){})}function showConfirm1(n,t,i){showmaskbg(!0);$("#addodomask").show();$("#addenginehoursmask").show();_dialog.showConfirm(n,t,function(n){showmaskbg(!1);$("#addodomask").hide();$("#addenginehoursmask").hide();typeof i=="function"&&i(n)},function(){showmaskbg(!1);$("#addodomask").hide();$("#addenginehoursmask").hide()})}function deleteShapeClick(n){if(n.data){var t={Key:n.data.CompanyID||"",Value:n.data.ID};showmaskbg(!0);showConfirm1(GetTextByKey("P_MV_DOYOUWANTTODELETETHESHAPEFILE","Do you want to delete the shape file?"),GetTextByKey("p_MV_DELETESHAPEFILE","Delete Shape File"),function(){_network.mapviewquery("DeleteShape",JSON.stringify(t),function(){mapHelper.removeShape(n.data);getShapeFileInfos()},function(){_dialog.showAlert(GetTextByKey("P_MV_FAILEDTODELETETHISSHAPLEFILE","Failed to delete this shaple file."),GetTextByKey("p_MV_DELETESHAPEFILE","Delete Shape File"))})})}}function openImportShapeFile(){$("#dialog_shapename").val("");$("#dialog_shapenotes").val("");$("#span_filename").text("");showmaskbg(!0);$("#dialog_importshapefile .dialog-title span.title").text(GetTextByKey("P_MV_IMPORTSHAPEFILE","Import Shape File"));$("#dialog_importshapefile").attr("act","edit").css({width:500,top:(document.documentElement.clientHeight-$("#dialog_importshapefile").height())/4,left:(document.documentElement.clientWidth-$("#dialog_importshapefile").width())/2}).showDialogfixed()}function UploadImportShapeFile(){var n=$('<input type="file" style="display: none;" accept=".shp,.kml,.kmz"/>');n.change(function(){var n=this.files[0],t;shapefiledata=n;$("#span_filename").text(n.name);t=$("#dialog_shapename").val();t&&t.length!=0||(n.name.length>100?$("#dialog_shapename").val(n.name.substring(0,100)):$("#dialog_shapename").val(n.name))}).click()}function SaveImportShapeFile(){var t,i,n;if(shapefiledata){if(t={Key:companyids,Value:$("#dialog_shapename").val(),Tag1:$("#dialog_shapenotes").val()},!t.Value||t.Value.length==0){_dialog.showAlert(GetTextByKey("P_MV_SHAPENAMECANNOTBEEMPTY","Shape name cannot be empty."),GetTextByKey("P_MV_IMPORTSHAPEFILE","Import Shape File"));return}i=JSON.stringify(t);i=htmlencode(i);n=new FormData;n.append("iconFile",shapefiledata);n.append("MethodName","ImportShape");n.append("ClientData",i);$.ajax({url:"mapview.ashx?tp=ashx",type:"POST",dataType:"json",processData:!1,contentType:!1,data:n,"async":!0,success:function(n){if(n!=="OK"){_dialog.showAlert(n,GetTextByKey("P_MV_ERROR","Error"));return}getShapeFileInfos();shapefiledata=undefined;$("#dialog_importshapefile").hideDialog();showmaskbg(!1)},error:function(n){_dialog.showAlert(n.statusText,GetTextByKey("P_MV_IMPORTSHAPEFILE","Import Shape File"))}})}}function getShapeFileData(n,t){var i={Key:n.CompanyID||"",Value:n.ID,Tag1:n.FileName};_network.mapviewquery("GetShapeData",JSON.stringify(i),function(i){if(typeof i=="string"){_dialog.showAlert(i,GetTextByKey("P_MV_ERROR","Error"));return}n.Shape=i;t?locateShape(n):mapHelper.showShape(n)},function(){})}function locateShape(n){n.Shape?(mapHelper.showShape(n),mapHelper.locateShape(n)):getShapeFileData(n,!0)}var isAddEH=!0,primarydatadourceMVEH,assetdataEH,isAddOdo=!0,primarydatadourceMVOdo,assetdataOdo,allBasicAssetsObj,allBasicAssetsObj_Timeout=null,BasicAssetsExpire=!1,allAssets,selectedAsset=undefined,assetDictionary=[[]],allGroups,groupAssets=[[]],jobsiteAssets=[[]],unshownMachineID=[],assetLocations,assetHisLocations,PopupViewShowing,unshownJobSiteID,ALL_TEXT,ALL_VALUE,parameterinput,paramindex,idindex,parametervalues,allItemUrls,lastHisFromDT,lastHisToDT,_videoRequestAssetID,prumaryDatasource,lineColors,dsLocations,imgTypes,printTypes,savedsearches_dt,savesearch_dt,shapevm,selectedShapeFileID,shapefiledata;typeof AssetObject!="function"&&(AssetObject=function(n){function d(t){var u=t.Selected,i,s,r,h;if(t&&t.Machines){var f=[],e=[],o=[];for(r in t.Machines)i=t.Machines[r],i.State.Selected!=u&&(i.State.Selected=u,u?(f.push(i),o.push(i.ID)):(e.push(i),unshownMachineID.push(i.ID)));if(o.length>0){for(s=[],r=0;r<unshownMachineID.length;r++)h=unshownMachineID[r],o.indexOf(h)<0&&s.push(h);unshownMachineID=s}f.length>0&&n.showMachines(f);e.length>0&&n.removeMachines(e);displayFilerIcon()}}function ot(n){var u,r;if(typeof n=="string"&&(n=n.split(String.fromCharCode(175))),n=="")return[];for(u=[],r=0;r<n.length;r++){var i={},f=n[r],t=f.split(String.fromCharCode(170));i.Id=Number(t[0]);i.VIN=t[1];i.Name=t[2];i.MakeName=t[3];i.ModelName=t[4];i.TypeName=t[5];i.OnRoad=t[6]=="1";i.Attachment=t[7]=="1";i.AssetGroups=t[8]?t[8].split(","):["-1"];i.JobSites=t[9]?t[9].split(","):["-1"];u.push(i)}return u}function it(n){var f,u,s,r,i;if(typeof n=="string"&&(n=n.split(String.fromCharCode(175))),n=="")return[];for(f=[],u=0;u<n.length;u++){var t={},e=n[u],o=e.split(String.fromCharCode(171));o.length==2&&(s=o[0].split(String.fromCharCode(170)),t.CompanyID=s[0],t.CompanyName=s[1],e=o[1]);r=e.split(String.fromCharCode(170));t.ID=Number(r[0]);t.Latitude=Number(r[1]);t.Longitude=Number(r[2]);t.IconUrl=r[3];t.AlertTips=r[4];t.Priority=Number(r[5]);t.ViewAlertTypes=r[6];allBasicAssetsObj&&(i=allBasicAssetsObj.getAsset(t.ID),i&&(t.VIN=i.VIN,t.DisplayName=i.Name,t.Make=i.MakeName,t.Model=i.ModelName,t.AssetType=i.TypeName,t.OnRoad=i.OnRoad,t.Attachment=i.Attachment,t.AssetGroups=i.AssetGroups,t.JobSites=i.JobSites));f.push(t)}return f}function s(){machineAlert&&(_dialog.close(machineAlert),machineAlert=null);machineAlert=_dialog.showAlert(GetTextByKey("P_MV_UNABLETOOBTAINASSETDATAATTEMPTINGTORECONNECT","Unable to obtain asset data. Attempting to reconnect..."),GetTextByKey("P_MV_REFRESHMACHINEDATA","Refresh machine data"))}function rt(){for(var t,u=[],r=0;r<allAssets.length;r++)t=allAssets[r],t.State=getMachineStateObj(t.ID),unshownMachineID.indexOf(t.ID)<0&&(t.State.Selected=!0,u.push(t),allJobSiteMachine["MID"+t.ID]=t);n.showMachines(u);i.reload(allAssets)}function st(n){for(var t,f,e,o,s,i,h,u=n.length-1;u>=0;u--){if(t=n[u],t.Collapsed=!0,t.Selected=!0,allGroups)for(i=0;i<allGroups.length;i++)if(f=allGroups[i],t.ID===f.ID){t.Collapsed=f.Collapsed;t.Selected=f.Selected;break}if(e=$.trim($("#txtAssetGroupSearchText").val()),t.Matched=!0,e!=""&&t.Name.toLowerCase().indexOf(e.toLocaleLowerCase())<0&&(t.Matched=!1),o=[],groupAssets[t.ID.toLowerCase()])for(s=groupAssets[t.ID.toLowerCase()],i=0;i<s.length;i++)h=s[i],(t.Matched||isAssetMatch(h,e))&&o.push(h);t.Machines=o;t.Matched||t.Machines.length!=0||n.splice(u,1)}allGroups=n;r.reload(allGroups)}function ut(n){g(n.Machines)}function g(t){var f,e,o,r,h,i,u,s;if(t||(t=allAssets),t&&t.length>0){r=null;for(h in t)(i=t[h],i.State.Selected)&&((f==null||f<i.Longitude)&&(f=i.Longitude),(e==null||e>i.Longitude)&&(e=i.Longitude),(o==null||o<i.Latitude)&&(o=i.Latitude),(r==null||r>i.Latitude)&&(r=i.Latitude));f!=e||o!=r?(u=new ExtentC,u.xmax=f+.001,u.xmin=e-.001,u.ymax=o+.001,u.ymin=r-.001,n.gotoMap(u)):(s=new PointC({longitude:t[0].Longitude,latitude:t[0].Latitude}),n.centerAt(s))}else t.length==1&&(s=new PointC({longitude:t[0].Longitude,latitude:t[0].Latitude}),n.centerAt(s))}function ft(t){t&&(t.State.Selected?(n.showMachine(t),unshownMachineID.splice(unshownMachineID.indexOf(t.ID),1)):(n.removeMachine(t),unshownMachineID[unshownMachineID.length]=t.ID),r.reload(allGroups),displayFilerIcon())}function et(t){t&&(t.State.Selected?n.locateMachine(t):(t.State.Selected=!0,unshownMachineID.splice(unshownMachineID.indexOf(t.ID),1),n.showMachine(t),n.locateMachine(t)),displayFilerIcon())}function ht(n){if(n&&n.length>0){hasContractor=!0;var t=$("#selContractor");t.data("dropdown").setSource(n);userParams&&userParams.MapViewContratorID&&userParams.MapViewContratorID!=""&&(companyids=userParams.MapViewContratorID,t.dropdownVals(userParams.MapViewContratorID.split(",")));$("#contractorCtrl").css("display","inline-flex")}else $("#btnToggleTimeline").show(),$("#btnImportShapeFile").show()}function ct(){typeof MSGWebSocketURL!="undefined"&&(nt=new $websocket(MSGWebSocketURL),nt.onreceive=lt,nt.connect())}function lt(n){console.log(JSON.stringify(n));n&&(n.Code=="200"||n.Code=="201")&&t.getAssetBasicInfoByAssets([n.Message])}var b=!0,h=[],a=!1,k=!1,o=!1,u,t=this,v=2,y=50,w=40,tt=function(n){return(n>0?Math.floor:Math.ceil)(n)},c,i=new Vue({el:"#machineList",data:{machines:[],startIndex:0,bodyContentStyle:{top:null},bodyContainerHeight:0,bodyContainerStyle:{height:null},scrollTop:0,HistoryTitle:GetTextByKey("P_MA_LOCATIONHISTORY","Location History")},computed:{bodyClientRowCount:function(){var n=document.getElementById("contentCtrl").clientHeight;return tt((n-1)/y)+1},innerMachines:function(){var n=this.startIndex,t;return(n<0&&(n=0),this.machines==null||this.machines.length<w)?this.machines.slice():(t=this.bodyClientRowCount+n+v*2+1,t>this.machines.length&&(t=this.machines.length),this.machines.slice(n,t))}},methods:{reload:function(n){var t,i,r;this.machines=n;t=n&&n.length*y;this.bodyContainerHeight=t;this.bodyContainerStyle.height=t&&t+"px";n.length<w?(this.startIndex=-1,this.startIndex=0,this.bodyContentStyle.top="0px"):(i=this.startIndex,r=n.length-this.bodyClientRowCount,i>r&&(i=r),this.startIndex=-1,this.startIndex=i)},refresh:function(){var n=this.startIndex;this.startIndex=-1;this.startIndex=n},chkMachineClick:function(n){ft(n)},linkMachineClick:function(n){et(n);this.refresh();c&&(c.status=1);$("#assetsummary").hide();$("#assetsummarytrigle").hide()},locationHistoryClick:function(n){selectedAsset&&(selectedAsset.State.Highlight=!1);n.State.Highlight=!0;this.refresh();selectedAsset=n;var t={data:n};locationHistoryClick(t)},assetSummaryMouseover:function(n,t){var r,i;$("#assetsummary").empty();$("#assetsummary").show();$("#assetsummarytrigle").show();r=t.clientX+10;r=$(t.target).offset().left+$(t.target).width()+90;i=$(t.target).offset().top;i+10+$("#assetsummary").height()>document.documentElement.clientHeight&&(i=document.documentElement.clientHeight-$("#assetsummary").height()-10);i=i-60;$("#assetsummary").css({left:r,top:i});$("#assetsummarytrigle").css({left:r+1,top:$(t.target).offset().top-60});c&&(c.status=1);c=new $assetsummary($("#assetsummary"),n.CompanyID||"",n.ID,n.ViewAlertTypes,n.AlertTips,0)},assetSummaryMouseleave:function(n,t){c&&(c.status=1);var i=$(t.toElement);i.prop("id")!="assetsummary"&&i.parents("#assetsummary").length==0&&i.prop("id")!="assetsummarytrigle"&&($("#assetsummary").hide(),$("#assetsummarytrigle").hide())}}}),e,nt;this.onscrollAssets=function(n){var t,r;i.machines==null||i.machines.length<w||(t=n==null?0:n.target.scrollTop,t-=t%y+v*y,t<0?t=0:(r=i.bodyContainerHeight-(i.bodyClientRowCount+v*2+1)*y,t>r&&(t=r)),i.scrollTop!==t&&(i.scrollTop=t,i.startIndex=t/y,i.bodyContentStyle.top=t&&t+"px"))};this.refreshAssetList=function(){i.refresh()};var p=26,l=[],f=[],r=new Vue({el:"#assetGroupList",data:{startIndex:0,bodyContentStyle:{top:null},bodyContainerHeight:0,bodyContainerStyle:{height:null},scrollTop:0,HistoryTitle:GetTextByKey("P_MA_LOCATIONHISTORY","Location History")},computed:{bodyClientRowCount:function(){var n=document.getElementById("contentCtrl").clientHeight;return tt((n-1)/p)+1},innerAssetgroupMachines:function(){var n=this.startIndex,t;return(n<0&&(n=0),f==null||f.length<w)?f.slice():(t=this.bodyClientRowCount+n+v*2+1,t>f.length&&(t=f.length),f.slice(n,t))}},methods:{fillMachines:function(){for(var n,r,u,h,t,e,a,i=[],c=!1,o=0,s=0;s<l.length;s++){if(n=l[s],n.__isGroup=!0,n.__indeterminate=!1,i.push(n),r=0,n.Machines&&n.Machines.length>0){for(u=0;u<n.Machines.length;u++)h=n.Machines[u],h.State.Selected&&r++,n.Collapsed||i.push(h);r==0?(n.Selected=!1,n.__indeterminate=!1):r==n.Machines.length?(n.Selected=!0,n.__indeterminate=!1):(n.__indeterminate=!0,c=!0)}else n.__indeterminate=!1;n.Selected&&o++}f=i;t=document.getElementById("chkSelectAllAssetGroup");t.indeterminate=c;o==0?t.checked=!1:o==l.length?t.checked=!0:t.indeterminate=!0;e=i.length*p;this.bodyContainerHeight=e;this.bodyContainerStyle.height=e&&e+"px";a=this.startIndex;this.startIndex=-1;this.startIndex=a;this.$nextTick(function(){var n=document.getElementById("contentCtrl");this.bodyContainerHeight+26<=n.clientHeight&&(this.bodyContentStyle.top=0,this.startIndex=0)})},reload:function(n){l=n;this.fillMachines()},refresh:function(){var n=this.startIndex;this.startIndex=-1;this.startIndex=n},treeIconClick:function(n,t){if(t){var i=$(n.target);i.hasClass("treeiconc")?i.removeClass("treeiconc").addClass("treeicone"):i.removeClass("treeicone").addClass("treeiconc");t.Collapsed=!t.Collapsed;this.fillMachines()}else treeIconClick(n)},chkMachineClick:function(n){ft(n)},linkMachineClick:function(n){et(n);this.refresh()},locationHistoryClick:function(n){selectedAsset&&(selectedAsset.State.Highlight=!1);n.State.Highlight=!0;this.refresh();selectedAsset=n;var t={data:n};locationHistoryClick(t)},chkAssetGroupClick:function(n,t){d(t);this.fillMachines()},linkAssetGroupClick:function(n,t){t.Selected?ut(t):(t.Selected=!0,d(t),this.fillMachines(),ut(t))}}});this.onscrollGroupMachines=function(n){var t,i;f==null||f.length<w||(t=n==null?0:n.target.scrollTop,t-=t%p+v*p,t<0?t=0:(i=r.bodyContainerHeight-(r.bodyClientRowCount+v*2+1)*p,t>i&&(t=i)),r.scrollTop!==t&&(r.scrollTop=t,r.startIndex=t/p,r.bodyContentStyle.top=t&&t+"px"))};this.refreshAssetGroupList=function(){r.refresh()};this.selectAllAssetGroups=function(n){var t,i;if(l){for(t=0;t<l.length;t++)i=l[t],i.Selected!=n&&(i.Selected=n,d(i));r.fillMachines()}};this.getUnShownMachines=function(){return unshownMachineID};this.setUnShownMachines=function(n){if(unshownMachineID=[],n)for(var t in n)unshownMachineID.push(eval(n[t]))};this.searchMachine=function(n){o||(o=!0,$("#loadingDiv").show(),currentShownIndex=-1,h.splice(0,h.length),allBasicAssetsObj&&!BasicAssetsExpire?this.loadMapAlertLayer(n):this.getAssetBasicInfos(function(){t.loadMapAlertLayer(n)}),this.getCompanyLocations(),displayFilerIcon())};this.searchMachine1=function(n){o||(o=!0,$("#loadingDiv").show(),currentShownIndex=-1,h.splice(0,h.length),allBasicAssetsObj&&!BasicAssetsExpire?IsDealer||MapViewSearchAssetsApiAddress==""?this.loadMapAlertLayer(n):this.loadMapAlertLayer1(n):IsDealer||MapViewSearchAssetsApiAddress==""?this.getAssetBasicInfos(function(){t.loadMapAlertLayer(n)}):this.getAssetBasicInfos1(function(){t.loadMapAlertLayer1(n)}),this.getCompanyLocations(),displayFilerIcon())};this.getAssetBasicInfos=function(n){a||(a=!0,_network.mapviewquery("GetAssetBasicInfos",htmlencode(JSON.stringify([companyids])),function(t){a=!1;typeof t!="string"?(allBasicAssetsObj=new AllBasicAssetsObject,allBasicAssetsObj.setAssets(t),BasicAssetsExpire=!1,allBasicAssetsObj_Timeout&&clearTimeout(allBasicAssetsObj_Timeout),allBasicAssetsObj_Timeout=setTimeout(function(){BasicAssetsExpire=!0},3e5),n&&n()):s()},function(){a=!1;s()}))};this.getAssetBasicInfos1=function(n){var t=$("#selMapAlertLayer").val(),i;t||(t="");i={ViewID:t,ContractorID:companyids,SearchText:htmlencode($("#txtMachineSearchText").val()),Onroad:$("#selOnroad").val(),Layers:parametervalues,ExcludeNoLocation:$("#exclude00Div").attr("state")!="0",Attachment:$("#selAttachment").val()};_network.apipost(MapViewSearchAssetsApiAddress,companyid,i,function(t){a=!1;t!=="0"?(t=ot(t),allBasicAssetsObj=new AllBasicAssetsObject,allBasicAssetsObj.setAssets(t),BasicAssetsExpire=!1,allBasicAssetsObj_Timeout&&clearTimeout(allBasicAssetsObj_Timeout),allBasicAssetsObj_Timeout=setTimeout(function(){BasicAssetsExpire=!0},3e5),n&&n()):s()},function(){a=!1;s()})};e=[];this.getAssetBasicInfoByAssets=function(n){var i,r;if(k){for(i=0;i<n.length;i++)r=n[i],e.indexOf(r)<0&&e.push(r);return}k=!0;_network.mapviewquery("GetAssetBasicInfoByAssets",htmlencode(JSON.stringify([companyids,JSON.stringify(n)])),function(n){k=!1;typeof n!="string"&&allBasicAssetsObj&&allBasicAssetsObj.changeAssets(n);e.length>0&&(t.getAssetBasicInfoByAssets(e),e=[])},function(){k=!1;e.length>0&&(t.getAssetBasicInfoByAssets(e),e=[])})};this.getMachines=function(i){var r=$("#selMapAlertLayer").val(),u;r||(r="");u={IsAutoRefresh:i,ViewID:r,ContractorID:companyids,SearchText:htmlencode($("#txtMachineSearchText").val()),Onroad:$("#selOnroad").val(),Layers:parametervalues,ExcludeNoLocation:$("#exclude00Div").attr("state")!="0",Attachment:$("#selAttachment").val()};_network.mapviewquery("GetAssets",JSON.stringify(u),function(r){typeof r!="string"?(n.clearMachine(),allAssets=it(r),updateAssets(),t.getAssetGroups(u),jobsiteObject.searchJobSite(i),rt(),(b||$("#autoRecenterDiv").attr("state")=="1")&&(b=!1,g()),getNowFormatDate()):s();o=!1;$("#loadingDiv").hide()},function(){o=!1;s();$("#loadingDiv").hide()})};this.getMachines1=function(i){var r=$("#selMapAlertLayer").val(),u;r||(r="");u={IsAutoRefresh:i,ViewID:r,ContractorID:companyids,SearchText:htmlencode($("#txtMachineSearchText").val()),Onroad:Number($("#selOnroad").val()),Layers:parametervalues,ExcludeNoLocation:$("#exclude00Div").attr("state")!="0",Attachment:Number($("#selAttachment").val())};_network.apipost(MapViewQueryViewAssetsApiAddress,companyid,u,function(r){r!=="0"?(n.clearMachine(),allAssets=it(r),updateAssets(),t.getAssetGroups(u),jobsiteObject.searchJobSite(i),rt(),(b||$("#autoRecenterDiv").attr("state")=="1")&&(b=!1,g()),getNowFormatDate()):s();o=!1;$("#loadingDiv").hide()},function(){o=!1;s();$("#loadingDiv").hide()})};this.getAssetGroups=function(){var n={ContractorID:companyids,SearchText:""};_network.mapviewquery("GetAssetGroups",JSON.stringify(n),function(n){typeof n!="string"&&st(n)},function(){})};this.selectAllMachine=function(t){for(var u,o,i,f=[],e=[],r=0;r<h.length;r++)u=h[r],o=u.attr("checked")=="checked",t!=o&&(u.attr("checked",t),i=h[r].machine,t?(f.push(i),unshownMachineID.splice(unshownMachineID.indexOf(i.ID),1)):(unshownMachineID[unshownMachineID.length]=i.ID,e.push(i)));n.showMachines(f);n.removeMachines(e);displayFilerIcon()};this.getContractor=function(n){_network.mapviewquery("GetContractors","",function(t){ht(t);n&&n()})};this.getCompanyLocations=function(){_network.mapviewquery("GetCompanyLocations",companyids,function(n){u=n;u&&u.length>0?$("#showDealerLocationsDiv").css("display","inline-block"):$("#showDealerLocationsDiv").hide();$("#showDealerLocationsDiv").attr("state")=="1"&&t.showLocations()},function(){$("#loadingDiv").hide()})};this.showLocations=function(){var t,i;if(u)for(t in u)i=u[t],n.showLocation(i)};this.clearLocations=function(){var t,i;if(u)for(t in u)i=u[t],n.removeLocation(i)};this.loadMapAlertLayer=function(n){var u=$("#selMapAlertLayer"),i=u.val(),r;i||(i=userParams.MapAlertLayer);r=companyids+";"+i;_network.mapviewquery("GetMapAlertLayers",r,function(i){i&&i.length>0?($("#mapAlertLayerDiv").show(),$("#splitIconRight").show(),$("#rightCtrl").show(),showMapAlertLayer(i)):($("#mapAlertLayerDiv").hide(),$("#splitIconRight").hide(),$("#rightCtrl").hide());t.getMachines(n)},function(){$("#loadingDiv").hide()})};this.loadMapAlertLayer1=function(n){var u=$("#selMapAlertLayer"),i=u.val(),r;i||(i=userParams.MapAlertLayer);r=companyids+";"+i;_network.mapviewquery("GetMapAlertLayers",r,function(i){i&&i.length>0?($("#mapAlertLayerDiv").show(),$("#splitIconRight").show(),$("#rightCtrl").show(),showMapAlertLayer(i)):($("#mapAlertLayerDiv").hide(),$("#splitIconRight").hide(),$("#rightCtrl").hide());t.getMachines1(n)},function(){$("#loadingDiv").hide()})};try{ct()}catch{}});typeof AllBasicAssetsObject!="function"&&(AllBasicAssetsObject=function(){var n=[];this.setAssets=function(t){var i={MaxId:0,Assets:[]},r,u;for(n.push(i),r=0;r<t.length;r++)u=t[r],i.Assets.length>=500&&(i={MaxId:0,Assets:[]},n.push(i)),i.MaxId=u.Id,i.Assets.push(u)};this.getAsset=function(t){for(var r,u,f,i=0;i<n.length;i++)if(r=n[i],!(r.MaxId<t))for(u=0;u<r.Assets.length;u++)if(f=r.Assets[u],f.Id==t)return f};this.changeAssets=function(t){var i,r,u;for(n.push({MaxId:0,Assets:[]}),i=0;i<t.length;i++)r=t[i],u=this.getAsset(r.Id),u?Object.assign(u,r):this.addAsset(r)};this.addAsset=function(t){for(var r,i=0;i<n.length;i++)(r=n[i],r.MaxId<t.Id&&i!=n.length-1)||(r.Assets.push(t),t.Id>r.MaxId&&(r.MaxId=t.Id))}});assetLocations=[];assetHisLocations=[];PopupViewShowing=!1;unshownJobSiteID=[];typeof JobsiteObject!="function"&&(JobsiteObject=function(n){function o(t){var u=t.Selected,i,s,r,h;if(t&&t.Machines){var f=[],e=[],o=[];for(r in t.Machines)i=t.Machines[r],i.State.Selected!=u&&(i.State.Selected=u,u?(f.push(i),o.push(i.ID)):(e.push(i),unshownMachineID[unshownMachineID.length]=i.ID));if(o.length>0){for(s=[],r=0;r<unshownMachineID.length;r++)h=unshownMachineID[r],o.indexOf(h)<0&&s.push(h);unshownMachineID=s}f.length>0&&n.showMachines(f);e.length>0&&n.removeMachines(e);displayFilerIcon()}}function h(){jobSiteAlert&&(_dialog.close(jobSiteAlert),jobSiteAlert=null);jobSiteAlert=_dialog.showAlert(GetTextByKey("P_MV_UNABLETOOBTAINJOBSITEDATAATTEMPTINGTORECONNECT","Unable to obtain jobsite data. Attempting to reconnect..."),GetTextByKey("P_MV_REFRESHJOBSITEDATA","Refresh jobsite data"))}function a(i){var h,e,u,o,s,c,l,f,a;for(n.removeJobsites(r),h=[],e=i.length-1;e>=0;e--){if(u=i[e],u.Collapsed=!0,u.Selected=!0,u.Shown=!0,r)for(f=0;f<r.length;f++)if(o=r[f],u.ID===o.ID){u.Collapsed=o.Collapsed;u.Selected=o.Selected;u.Shown=o.Shown;break}if(s=$.trim($("#txtJobSiteSearchText").val()),u.Matched=!0,s!=""&&u.Name.toLowerCase().indexOf(s.toLocaleLowerCase())<0&&(u.Matched=!1),c=[],jobsiteAssets[u.ID])for(l=jobsiteAssets[u.ID],f=0;f<l.length;f++)a=l[f],(u.Matched||isAssetMatch(a,s))&&c.push(a);u.Machines=c;u.Matched||u.Machines.length!=0?u.Shown&&(n.showJobSite(u),h.push(u)):i.splice(e,1)}n.refreshJobsiteTooltip(h);r=i;t.reload(r);return}function c(t,i){var r=$(t.target);r.is("span")||(r=r.prev());i.Shown?(r.removeClass("switchoff").addClass("switchon"),n.showJobSite(i),unshownJobSiteID.splice(unshownJobSiteID.indexOf(i.ID),1)):(r.removeClass("switchon").addClass("switchoff"),n.removeJobSite(i,!0),unshownJobSiteID[unshownJobSiteID.length]=i.ID);displayFilerIcon()}function v(i){i&&(i.State.Selected?(n.showMachine(i),unshownMachineID.splice(unshownMachineID.indexOf(i.ID),1)):(n.removeMachine(i),unshownMachineID[unshownMachineID.length]=i.ID),t.reload(r),displayFilerIcon())}function y(t){t&&(t.State.Selected?n.locateMachine(t):(t.State.Selected=!0,unshownMachineID.splice(unshownMachineID.indexOf(t.ID),1),n.showMachine(t),n.locateMachine(t)),displayFilerIcon())}var r,e=2,s=40,l=function(n){return(n>0?Math.floor:Math.ceil)(n)};this.getUnShownMachines=function(){return unshownMachineID};this.setUnShownMachines=function(){};this.getUnShownJobsites=function(){return unshownJobSiteID};this.setUnShownJobsites=function(n){if(unshownJobSiteID=[],n)for(var t in n)unshownJobSiteID.push(eval(n[t]))};var f=26,u=[],i=[],t=new Vue({el:"#jobsiteList",data:{startIndex:0,bodyContentStyle:{top:null},bodyContainerHeight:0,bodyContainerStyle:{height:null},scrollTop:0,HistoryTitle:GetTextByKey("P_MA_LOCATIONHISTORY","Location History")},computed:{bodyClientRowCount:function(){var n=document.getElementById("contentCtrl").clientHeight;return l((n-1)/f)+1},innerJobsiteMachines:function(){var n=this.startIndex,t;return(n<0&&(n=0),i==null||i.length<s)?i.slice():(t=this.bodyClientRowCount+n+e*2+1,t>i.length&&(t=i.length),i.slice(n,t))}},methods:{fillMachines:function(){for(var n,o,t,a,r,s,v,e=[],l=!1,h=0,c=0;c<u.length;c++){if(n=u[c],n.__isJobsite=!0,n.__indeterminate=!1,e.push(n),o=0,n.Machines&&n.Machines.length>0){for(t=0;t<n.Machines.length;t++)a=n.Machines[t],a.State.Selected&&o++,n.Collapsed||e.push(n.Machines[t]);o==0?(n.Selected=!1,n.__indeterminate=!1):o==n.Machines.length?(n.Selected=!0,n.__indeterminate=!1):(n.__indeterminate=!0,l=!0)}else n.__indeterminate=!1;n.Selected&&h++}i=e;r=document.getElementById("chkSelectAll");r.indeterminate=l;h==0?r.checked=!1:h==u.length?r.checked=!0:r.indeterminate=!0;s=e.length*f;this.bodyContainerHeight=s;this.bodyContainerStyle.height=s&&s+"px";v=this.startIndex;this.startIndex=-1;this.startIndex=v;this.$nextTick(function(){var n=document.getElementById("contentCtrl");this.bodyContainerHeight+26<=n.clientHeight&&(this.bodyContentStyle.top=0,this.startIndex=0)})},reload:function(n){u=n;this.fillMachines()},refresh:function(){var n=this.startIndex;this.startIndex=-1;this.startIndex=n},treeIconClick:function(n,t){if(t){var i=$(n.target);i.hasClass("treeiconc")?i.removeClass("treeiconc").addClass("treeicone"):i.removeClass("treeicone").addClass("treeiconc");t.Collapsed=!t.Collapsed;this.fillMachines()}else treeIconClick(n)},chkJobsiteClick:function(n,t){o(t);this.fillMachines()},linkJobSiteClick:function(t,i){i.Selected||(i.Selected=!0,o(i),this.fillMachines());i.Shown?n.locateJobSite(i):(i.Shown=!0,c(t,i),n.locateJobSite(i))},showJobsiteClick:function(n,t){t.Shown=!t.Shown;c(n,t)},chkMachineClick:function(n){v(n)},linkMachineClick:function(n){y(n);this.refresh()},locationHistoryClick:function(n){selectedAsset&&(selectedAsset.State.Highlight=!1);n.State.Highlight=!0;selectedAsset=n;var t={data:n};locationHistoryClick(t)}}});this.refreshJobsiteList=function(){t.refresh()};this.selectAllJobsites=function(n){var i,r;if(u){for(i=0;i<u.length;i++)r=u[i],r.Selected!=n&&(r.Selected=n,o(r));t.fillMachines()}};this.onscrollJobsiteMachines=function(n){var r,u;i==null||i.length<s||(r=n==null?0:n.target.scrollTop,r-=r%f+e*f,r<0?r=0:(u=t.bodyContainerHeight-(t.bodyClientRowCount+e*2+1)*f,r>u&&(r=u)),t.scrollTop!==r&&(t.scrollTop=r,t.startIndex=r/f,t.bodyContentStyle.top=r&&r+"px"))};this.searchJobSite=function(n){this.getJobSites(n)};this.getJobSites=function(n){var t={IsAutoRefresh:n,ContractorID:companyids,SearchText:"",Onroad:$("#selOnroad").val()};_network.mapviewquery("GetJobSites",JSON.stringify(t),function(n){n!="-1"?a(n):h()},function(){h()})}});ALL_TEXT="(All)";ALL_VALUE="@all";$(function(){$(document).mousedown(function(n){var t=$(n.target),i;t.hasClass("div_filter")||(t=t.parents(".div_filter"));t.length==0&&$(".div_panel").hide();i=t.find(".div_panel");$(".div_panel").each(function(){$(this).is(i)||i.hide()})})}());parameterinput=[];paramindex=-1;idindex=0;typeof MapObject!="function"&&(MapC=undefined,LocatorC=undefined,esriConfigC=undefined,WebTileLayerC=undefined,GraphicsLayerC=undefined,GraphicC=undefined,PointC=undefined,MultipointC=undefined,PolylineC=undefined,PolygonC=undefined,CircleC=undefined,ExtentC=undefined,GeometryEngineC=undefined,SimpleMarkerSymbolC=undefined,SimpleLineSymbolC=undefined,SimpleFillSymbolC=undefined,TextSymbolC=undefined,PictureMarkerSymbolC=undefined,FontC=undefined,InfoWindowC=undefined,PopupTemplateC=undefined,InfoTemplateC=undefined,BasemapToggleC=undefined,BasemapGalleryC=undefined,BasemapC=undefined,BasemapLayerC=undefined,UnitsC=undefined,ColorC=undefined,ClusterLayerC=undefined,ArcGISDynamicMapServiceLayerC=undefined,WMSLayerC=undefined,WMSLayerInfoC=undefined,On=undefined,Dom=undefined,MapObject=function(){this.mapContainer="";this.basemapToggleContainer="";this.mapInitialized=undefined;this.MyMap=undefined;this.BaseMachineLayer=undefined;this.BaseMapLayer=undefined;this.HisptoryPointLayer=undefined;this.RoutePointLayer=undefined;this.RouteSelectionPointLayer=undefined;this.SearchPointLayer=undefined;this.BasePolygonLayer=undefined;this.TrafficLayer=undefined;this.WeatherLayer=undefined;this.TransportationLayer=undefined;this.load=function(n,t,i){this.mapContainer=n;this.basemapToggleContainer=t;this.mapInitialized=i;this.initMap(this)};this.initialized=function(n){var i=currentbasemap,r,t,f,e,o,u;userParams?userParams.BaseMap=="Imagery"?(i="satellite",$("#basemapImg").css("background-image","url('https://js.arcgis.com/3.44/esri/images/basemap/satellite.jpg')"),$("#basemapTitle").text(GetTextByKey("P_MAP_IMAGERY","Imagery"))):userParams.BaseMap=="Streets"?(i="streets",$("#basemapImg").css("background-image","url('https://js.arcgis.com/3.44/esri/images/basemap/streets.jpg')"),$("#basemapTitle").text(GetTextByKey("P_MAP_STREETS","Streets"))):($("#basemapImg").css("background-image","url('https://js.arcgis.com/3.44/esri/images/basemap/topo.jpg')"),$("#basemapTitle").text(GetTextByKey("P_MAP_TOPOGRAPHIC","Topographic"))):($("#basemapImg").css("background-image","url('https://js.arcgis.com/3.44/esri/images/basemap/topo.jpg')"),$("#basemapTitle").text(GetTextByKey("P_MAP_TOPOGRAPHIC","Topographic")));n.MyMap=new MapC(this.mapContainer,{basemap:i,center:[0,0],zoom:5,sliderPosition:"top-right",slider:showMapSlider});typeof setCookie=="function"&&setCookie("basemap",i);n.MyMap.disableKeyboardNavigation();n.MyMap.on("load",function(){$("#mapView_zoom_slider").css("top",100).css("right",10)});n.MyMap.on("click",function(t){var i,r;window.currentRouteStop!=null?(i={x:t.mapPoint.getLongitude(),y:t.mapPoint.getLatitude()},i.name=i.x.toFixed(6)+", "+i.y.toFixed(6),window.currentRouteStop.data("stop",i),window.currentRouteStop.val(i.name).trigger("change"),window.currentRouteStopName=window.currentRouteStop,r=new PointC([i.x,i.y]),n.Locator.locationToAddress(r,100),window.currentRouteStop.removeClass("focusing"),$("#routeCurrentLocation").hide(),delete window.currentRouteStop):$("#basemapGallery").hide()});this.BasePolygonLayer=n.addGraphicsLayer();this.BaseMapLayer=n.addGraphicsLayer();this.HisptoryPointLayer=n.addGraphicsLayer();this.RoutePointLayer=n.addGraphicsLayer();this.RouteSelectionPointLayer=n.addGraphicsLayer();this.SearchPointLayer=n.addGraphicsLayer();r=new ClusterLayerC({labelOffset:35,labelColor:"#F00",labelFontSize:"20px",labelFontFamily:"Calibri",labelFontWeight:FontC.WEIGHT_BOLD});n.MyMap.addLayer(r);this.BaseMachineLayer=r;this.TransportationLayer=new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/arcgis/rest/services/Reference/World_Transportation/MapServer");i=="satellite"&&n.MyMap.addLayer(this.TransportationLayer);t=new BasemapGalleryC({showArcGISBasemaps:!1,map:this.MyMap},this.basemapToggleContainer);f=new esri.dijit.Basemap({layers:[new esri.dijit.BasemapLayer({url:"http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer"})],title:GetTextByKey("P_MAP_IMAGERY","Imagery"),thumbnailUrl:"https://js.arcgis.com/3.44/esri/images/basemap/satellite.jpg"});t.add(f);e=new esri.dijit.Basemap({layers:[new esri.dijit.BasemapLayer({url:"http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"})],title:GetTextByKey("P_MAP_TOPOGRAPHIC","Topographic"),thumbnailUrl:"https://js.arcgis.com/3.44/esri/images/basemap/topo.jpg"});t.add(e);o=new esri.dijit.Basemap({layers:[new esri.dijit.BasemapLayer({url:"http://server.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer"})],title:GetTextByKey("P_MAP_STREETS","Streets"),thumbnailUrl:"https://js.arcgis.com/3.44/esri/images/basemap/streets.jpg"});t.add(o);t.startup();u=this;t.on("selection-change",function(){var i=t.getSelected(),r;i&&(i.title=="Imagery"?n.MyMap.addLayer(u.TransportationLayer):n.MyMap.removeLayer(u.TransportationLayer),$("#basemapImg").css("background-image","url('"+i.thumbnailUrl+"')"),$("#basemapTitle").text(i.title),userParams&&(userParams.Basemap=i.title,setUserParams(),typeof setCookie=="function"&&(r="topo",userParams.Basemap=="Imagery"?r="satellite":userParams.Basemap=="Streets"&&(r="streets"),setCookie("basemap",r))));$("#basemapGallery").hide()});t.on("error",function(n){console.log("basemap gallery error:  ",n)});this.mapInitialized&&this.mapInitialized()};this.initMap=function(n){require(["esri/map","esri/tasks/locator","esri/layers/WebTiledLayer","esri/layers/GraphicsLayer","esri/graphic","esri/geometry/Point","esri/geometry/Multipoint","esri/geometry/Polyline","esri/geometry/Polygon","esri/geometry/Circle","esri/geometry/Extent","esri/geometry/geometryEngine","esri/symbols/SimpleMarkerSymbol","esri/symbols/SimpleLineSymbol","esri/symbols/SimpleFillSymbol","esri/symbols/TextSymbol","esri/symbols/PictureMarkerSymbol","esri/symbols/Font","esri/dijit/InfoWindow","esri/dijit/PopupTemplate","esri/InfoTemplate","esri/dijit/BasemapToggle","esri/dijit/BasemapGallery","esri/dijit/Basemap","esri/dijit/BasemapLayer","esri/units","esri/Color","extras1/clusterlayer","esri/layers/ArcGISDynamicMapServiceLayer","esri/layers/WMSLayer","esri/layers/WMSLayerInfo","esri/urlUtils","dojo/on","dojo/dom","dojo/domReady!"],function(t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt,it,rt,ut,ft,et,ot,st,ht,ct,lt,at,vt){if(MapC=t,LocatorC=i,esriConfigC=esriConfig,WebTileLayerC=r,GraphicsLayerC=u,GraphicC=f,PointC=e,MultipointC=o,PolylineC=s,PolygonC=h,CircleC=c,ExtentC=l,GeometryEngineC=a,SimpleMarkerSymbolC=v,SimpleLineSymbolC=y,SimpleFillSymbolC=p,TextSymbolC=w,PictureMarkerSymbolC=b,FontC=k,InfoWindowC=d,PopupTemplateC=g,InfoTemplateC=nt,BasemapToggleC=tt,BasemapGalleryC=it,BasemapC=rt,BasemapLayerC=ut,UnitsC=ft,ColorC=et,ClusterLayerC=ot,ArcGISDynamicMapServiceLayerC=st,WMSLayerC=ht,WMSLayerInfoC=ct,On=at,Dom=vt,lt.addProxyRule({urlPrefix:"traffic.arcgis.com",proxyUrl:"proxy/proxy.ashx"}),n){n.initialized(n);n.Locator=new i("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer");n.LocatorAsync=new i("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer");n.Locator.on("location-to-address-complete",function(n){var r,t,i;n.address.address&&(r=n.address.address,window.currentRouteStopName&&(t=getAddressLabel(r),window.currentRouteStopName.val(t),i=window.currentRouteStopName.data("stop"),i!=null&&(i.name=t),delete window.currentRouteStopName))})}})};this.addGraphicsLayer=function(){var n=new GraphicsLayerC;return this.MyMap.addLayer(n),n};this.showTrafficLayer=function(n){n?(this.TrafficLayer||(this.TrafficLayer=new ArcGISDynamicMapServiceLayerC("https://traffic.arcgis.com/arcgis/rest/services/World/Traffic/MapServer")),this.TrafficLayer.refreshInterval=3,this.MyMap.addLayer(this.TrafficLayer)):this.TrafficLayer&&this.MyMap.removeLayer(this.TrafficLayer)};this.showWeatherLayer=function(n){if(n){if(!this.WeatherLayer){var t=new WMSLayerInfoC({name:"base_reflectivity_mosaic",title:"Weahter"}),i={extent:new ExtentC(-126.4,31-109.7,41.5,{wkid:4326}),layerInfos:[t]};this.WeatherLayer=new WMSLayerC("https://nowcoast.noaa.gov/geoserver/weather_radar/wms",{resourceInfo:i,visibleLayers:["base_reflectivity_mosaic"]})}this.WeatherLayer.refreshInterval=5;this.MyMap.addLayer(this.WeatherLayer)}else this.WeatherLayer&&this.MyMap.removeLayer(this.WeatherLayer)}});typeof MapHelper!="function"&&(MapHelper=function(n){function b(){var e=!1;t.BaseMachineLayer.on("mouse-over",function(n){e||(t.BaseMachineLayer.clearSingles(),c(n,0))});t.BaseMachineLayer.on("mouse-out",function(){e||(t.MyMap.infoWindow.hide(),i&&(i.status=1))});t.BaseMachineLayer.on("click",function(n){n.graphic&&(window.currentRouteStopName!=null||(e=!0,h=!1))});t.BaseMapLayer.on("mouse-over",function(n){e||c(n)});t.BaseMapLayer.on("mouse-out",function(){e||t.MyMap.infoWindow.hide()});t.BaseMapLayer.on("click",function(n){n.graphic&&!n.graphic.isHistoryLine&&(t.BaseMachineLayer.clearSingles(),n.graphic.getDojoShape().moveToFront(),c(n),e=!0,h=!1)});t.BasePolygonLayer.on("mouse-over",function(n){!e&&userParams.ShowJSTooltip&&(t.MyMap.infoWindow.clearFeatures(),c(n,1))});t.BasePolygonLayer.on("mouse-out",function(){e||(t.MyMap.infoWindow.hide(),r&&(r.status=1))});t.HisptoryPointLayer.on("click",function(n){if(n.graphic&&!n.graphic.isCamSymbol){t.MyMap.infoWindow.clearFeatures();n.graphic.StartOrEndPoint&&n.graphic.StartOrEndPoint.getDojoShape().moveToFront();n.graphic.CameraGraphic&&n.graphic.CameraGraphic.getDojoShape().moveToFront();n.graphic.getDojoShape().moveToFront();e=!0;h=!0;t.MyMap.infoWindow.setFeatures(f);var i=f.indexOf(n.graphic);i>=0&&t.MyMap.infoWindow.select(i);t.MyMap.infoWindow.show(n.screenPoint,t.MyMap.getInfoWindowAnchor(n.screenPoint))}});t.HisptoryPointLayer.on("mouse-over",function(n){e||(t.MyMap.infoWindow.clearFeatures(),c(n))});t.HisptoryPointLayer.on("mouse-out",function(){e||t.MyMap.infoWindow.hide()});t.BasePolygonLayer.on("click",function(n){var i,f,o,r;if(n.graphic){t.MyMap.infoWindow.clearFeatures();n.graphic.getDojoShape().moveToFront();e=!0;h=!1;i=[];for(f in u)f.indexOf("JSID")<0||(o=u[f],GeometryEngineC.intersects(n.graphic.geometry,o.geometry)&&i.push(o));i.length>0?(t.MyMap.infoWindow.setFeatures(i),t.MyMap.infoWindow.show(n.screenPoint,t.MyMap.getInfoWindowAnchor(n.screenPoint)),r=$(".esriPopupWrapper"),$(".maximize").css("display","none"),r.find(".next").removeAttr("title"),r.find(".prev").removeAttr("title"),r.find(".close").removeAttr("title")):c(n)}});t.MyMap.infoWindow.on("hide",function(){e=!1;t.BaseMachineLayer._popupedClusterData=null;i=null;r=null});t.MyMap.infoWindow.on("selection-change",function(){var n=t.MyMap.infoWindow.getSelectedFeature(),o,f,e,u;n&&n.attributes&&enableInfoWindow&&(n.attributes.Type===0?window.currentRouteStop!=null?(o={x:n.geometry.x,y:n.geometry.y,name:GetTextByKey("P_MR_ASSET","Asset")+": "+n.attributes.DisplayName,assetId:n.attributes.ID},window.currentRouteStop.data("stop",o),window.currentRouteStop.val(o.name).trigger("change"),window.currentRouteStopName=window.currentRouteStop,t.Locator.locationToAddress(new PointC([o.x,o.y]),100),window.currentRouteStop.removeClass("focusing"),$("#routeCurrentLocation").hide(),delete window.currentRouteStop,t.MyMap.infoWindow.clearFeatures(),t.MyMap.infoWindow.hide()):(t.MyMap.infoWindow.resize(520,460),$(".contentPane").css("height",460).unbind(),typeof $assetsummary=="function"?(t.MyMap.infoWindow.setContent("<div id='assetDetailCtrl'><\/div>"),i&&(i.status=1),f=null,t.MyMap.infoWindow.features&&t.MyMap.infoWindow.features.length>0&&(f=t.MyMap.infoWindow.features.map(function(n){return n.attributes})),i=new $assetsummary("assetDetailCtrl",n.attributes.CompanyID||"",n.attributes.ID,n.attributes.ViewAlertTypes,n.attributes.AlertTip,1,f),u=$(".esriPopupWrapper"),u.find(".tempdropdown").remove(),u.find(".title").unbind().removeClass("titlelink"),f.length>1&&u.find(".title").addClass("titlelink").click(function(){var i=$('<div class="tempdropdown" style="width: 460px;margin-left:46px;position:absolute;top:24px;z-index:1;background: white;"><\/div>');i.dropdown(f,{search:!0,valueKey:"ID",textKey:"DisplayName_O",searchKeys:["Name","Name2","VIN"]});i.find(".dropdown-wrapper").css("border","1px solid #b9b9b9");i.dropdownVal(n.attributes.ID);i.on("select",function(i,r){if(r&&r.ID!=n.attributes.ID){var e=f.filter(function(n){return n.ID==r.ID});e&&e.length>0&&t.MyMap.infoWindow.select(f.indexOf(e[0]))}u.find(".tempdropdown").remove()});$(".esriPopupWrapper").find(".tempdropdown").remove();$(".esriPopupWrapper").append(i)})):(t.MyMap.infoWindow.currentattributes=n.attributes,getAssetByID(n.attributes.ID))):n.attributes.Type===1?(t.MyMap.infoWindow.resize(420,300),$(".contentPane").css("height",300),typeof $jobsitesummary=="function"&&(t.MyMap.infoWindow.setContent("<div id='JobsiteDetailCtrl'><\/div>"),r&&(r.status=1),e=null,t.MyMap.infoWindow.features&&t.MyMap.infoWindow.features.length>0&&(e=t.MyMap.infoWindow.features.map(function(n){return n.jobsite})),r=new $jobsitesummary("JobsiteDetailCtrl",n.jobsite,1,e),r.jobsitechanged=function(n){n>=0&&t.MyMap.infoWindow.select(n)},u=$(".esriPopupWrapper"),u.find(".tempdropdown").remove(),u.find(".title").unbind().removeClass("titlelink"),e.length>1&&u.find(".title").addClass("titlelink").click(function(){var i=$('<div class="tempdropdown" style="width: 360px;margin-left:46px;position:absolute;top:24px;z-index:1;background: white;"><\/div>');i.dropdown(e,{search:!0,valueKey:"ID",textKey:"Name"});i.find(".dropdown-wrapper").css("border","1px solid #b9b9b9");i.dropdownVal(n.jobsite.ID);i.on("select",function(i,r){if(r&&r.ID!=n.jobsite.ID){var f=e.filter(function(n){return n.ID==r.ID});f&&f.length>0&&t.MyMap.infoWindow.select(e.indexOf(f[0]))}u.find(".tempdropdown").remove()});$(".esriPopupWrapper").find(".tempdropdown").remove();$(".esriPopupWrapper").append(i)}))):n.attributes.Type===2?(t.MyMap.infoWindow.resize(420,200),$(".contentPane").css("height",200),t.MyMap.infoWindow.setContent(n.attributes.infoContent+"<br/>")):n.attributes.Type===3&&t.MyMap.infoWindow.setContent(n.attributes.infoContent+"<br/>"))});t.SearchPointLayer.on("click",function(n){var r=$("#routePlaces").data("parent"),i,u;r!=null&&(i=n.graphic,i!=null)&&(u=t.MyMap.getLevel(),u<14&&t.MyMap.setLevel(14),t.MyMap.centerAt(i.geometry),$("#routePlaces").hide(),t.SearchPointLayer.clear(),r.val(i.attributes.name).data("stop",{x:i.geometry.x,y:i.geometry.y,name:i.attributes.name}).trigger("change"))});n&&n()}function c(n,u){var f=$(".esriPopupWrapper"),e;f.find(".tempdropdown").remove();f.find(".title").unbind().removeClass("titlelink");f.find(".next").removeAttr("title");f.find(".prev").removeAttr("title");f.find(".close").removeAttr("title");$(".esriPopupWrapper").find(".tempdropdown").remove();enableInfoWindow&&n.graphic&&n.graphic.attributes&&($(".maximize").css("display","none"),$(".actionsPane").addClass("hidden"),t.MyMap.infoWindow.setTitle(n.graphic.attributes.name||n.graphic.attributes.DisplayName),u==0?(t.MyMap.infoWindow.resize(520,460),$(".contentPane").css("height",460).unbind(),typeof $assetsummary=="function"?(t.MyMap.infoWindow.setContent("<div id='assetDetailCtrl'><\/div>"),i&&(i.status=1),i=new $assetsummary("assetDetailCtrl",n.graphic.attributes.CompanyID||"",n.graphic.attributes.ID,n.graphic.attributes.ViewAlertTypes,n.graphic.attributes.AlertTip,1)):(e=t.MyMap.infoWindow.currentattributes,e&&n.graphic.attributes.ID==e.ID||(t.MyMap.infoWindow.currentattributes=n.graphic.attributes,getAssetByID(n.graphic.attributes.ID)))):u==1?(t.MyMap.infoWindow.resize(420,300),$(".contentPane").css("height",300),typeof $jobsitesummary=="function"?(t.MyMap.infoWindow.setContent("<div id='JobsiteDetailCtrl'><\/div>"),r&&(r.status=1),r=new $jobsitesummary("JobsiteDetailCtrl",n.graphic.jobsite,1)):t.MyMap.infoWindow.setContent(n.graphic.attributes.infoContent+"<br/>")):(t.MyMap.infoWindow.resize(undefined,undefined),$(".contentPane").css("height","unset"),t.MyMap.infoWindow.setContent(n.graphic.attributes.infoContent+"<br/>")),t.MyMap.infoWindow.show(n.screenPoint,t.MyMap.getInfoWindowAnchor(n.screenPoint)))}function k(n){var o=new PointC({longitude:n.Longitude,latitude:n.Latitude}),f=UnitsC.MILES,e,u,t,i,r;return n.Radius_UOM==="Kilometre"&&(f=UnitsC.KILOMETERS),e=new CircleC({center:o,radius:n.Radius,radiusUnit:f,geodesic:!0}),u=new SimpleFillSymbolC({color:[n.Color.Red,n.Color.Green,n.Color.Blue,51],outline:{color:[n.Color.Red,n.Color.Green,n.Color.Blue]}}),u.setStyle(SimpleFillSymbolC.STYLE_SOLID),t="<b>"+GetTextByKey("P_MV_NAME_COLON","Name:")+" <\/b>"+htmlencode(n.Name)+"<br/>",t+="<b>"+GetTextByKey("P_MV_CODE_COLON","Code:")+" <\/b>"+htmlencode(n.Code)+"<br/>",t+="<b>"+GetTextByKey("P_MV_NUMBER_COLON","Number:")+" <\/b>"+htmlencode(n.Number)+"<br/>",t+="<b>"+GetTextByKey("P_MV_LATLONG_COLON","Lat/Long:")+" <\/b>"+n.Latitude+", "+n.Longitude+"<br/>",t+="<b>"+GetTextByKey("P_MV_DELIVERYADDRESS_COLON","Delivery Address:")+" <\/b>"+htmlencode(n.Address1)+"<br/>",t+="<br/><b>"+GetTextByKey("P_MV_FOREMAN_COLON","Foreman:")+" <\/b>"+htmlencode(n.Foreman)+"<br/>",t+="<br/><b>"+GetTextByKey("P_MV_STARTDATE_COLON","Start Date:")+" <\/b>"+n.StartDateStr+"<br/>",t+="<b>"+GetTextByKey("P_MV_ENDDATE_COLON","End Date:")+" <\/b>"+n.EndDateStr+"<br/>",t+="<br/><b>"+GetTextByKey("P_MV_NOTES_COLON","Notes:")+" <\/b>"+htmlencode(n.Notes)+"<br/>",i=new GraphicC(e,u),r=htmlencode(n.Name),n.Code&&$.trim(n.Code)!=""&&(r+=" / "+htmlencode(n.Code)),n.Number&&$.trim(n.Number)!=""&&(r+=" / "+htmlencode(n.Number)),i.setAttributes({infoContent:t,name:r,Type:1}),i.jobsite=n,i}function d(n){for(var f,s,h,e,t,i,r,o=[],u=0;u<n.Polygon.length;u++)f=n.Polygon[u],s=[f.Longitude,f.Latitude],o.push(s);return h=new PolygonC(o),e=new SimpleFillSymbolC({color:[n.Color.Red,n.Color.Green,n.Color.Blue,51],outline:{color:[n.Color.Red,n.Color.Green,n.Color.Blue]}}),e.setStyle(SimpleFillSymbolC.STYLE_SOLID),t="<b>"+GetTextByKey("P_MV_NAME_COLON","Name:")+" <\/b>"+htmlencode(n.Name)+"<br/>",t+="<b>"+GetTextByKey("P_MV_CODE_COLON","Code:")+" <\/b>"+htmlencode(n.Code)+"<br/>",t+="<b>"+GetTextByKey("P_MV_NUMBER_COLON","Number:")+" <\/b>"+htmlencode(n.Number)+"<br/>",t+="<b>"+GetTextByKey("P_MV_LATLONG_COLON","Lat/Long:")+" <\/b>"+n.Latitude+", "+n.Longitude+"<br/>",t+="<b>"+GetTextByKey("P_MV_DELIVERYADDRESS_COLON","Delivery Address:")+" <\/b>"+htmlencode(n.Address1)+"<br/>",t+="<br/><b>"+GetTextByKey("P_JS_FOREMAN_COLON","Foreman:")+" <\/b>"+htmlencode(n.Foreman)+"<br/>",t+="<br/><b>"+GetTextByKey("P_MV_STARTDATE_COLON","Start Date:")+" <\/b>"+n.StartDateStr+"<br/>",t+="<b>"+GetTextByKey("P_MV_ENDDATE_COLON","End Date:")+" <\/b>"+n.EndDateStr+"<br/>",t+="<br/><b>"+GetTextByKey("P_MV_NOTES_COLON","Notes:")+" <\/b>"+htmlencode(n.Notes)+"<br/>",i=new esri.Graphic(h,e),r=htmlencode(n.Name),n.Code&&$.trim(n.Code)!=""&&(r+=" / "+htmlencode(n.Code)),n.Number&&$.trim(n.Number)!=""&&(r+=" / "+htmlencode(n.Number)),i.setAttributes({infoContent:t,name:r,Type:1}),i.jobsite=n,i}var t=new MapObject,u,e,i,r,h;t.load("mapView","basemapGallery",b);u=[];e=[];this.unShownMachineIDs=[];this.unShownJobSiteIDs=[];h=!1;this.changeBaseMap=function(n){t.MyMap.setBasemap(n)};this.showTraffic=function(n){t.showTrafficLayer(n)};this.showWeather=function(n){t.showWeatherLayer(n)};this.showAssetDetailInfo=function(n){var i=t.MyMap.infoWindow.currentattributes,r;i&&i.Type===0&&i.ID==n.ID&&(n.ViewAlertTypes=i.ViewAlertTypes,n.AlertTip=i.AlertTip,r=getAssetPopupContent(n),t.MyMap.infoWindow.setContent(r+"<br/>"),i.infoContent=r)};this.showMachine=function(n){this.removeMachine(n);var i=this.createMachinePoint(n);t.BaseMachineLayer.add(i);t.MyMap.infoWindow.currentattributes=null;e["MachineID"+n.ID]=i};this.showMachines=function(n){var o=[],s=!1,h=-1,u,r,f;for(typeof clearAssetsummaryCache=="function"&&clearAssetsummaryCache(),i&&i.status==0&&(h=i.assetid),u=0;u<n.length;u++)r=n[u],f=this.createMachinePoint(r),o.push(f),e["MachineID"+r.ID]=f,h==r.ID&&(s=!0,i&&i.status==0&&(i.viewalerttypes=r.ViewAlertTypes,i.alerttips=r.AlertTips));i&&i.status==0&&(s?i.refresh():(t.MyMap.infoWindow.currentattributes=null,alwaysShow=!1,t.MyMap.infoWindow.hide()));t.BaseMachineLayer.adds(o)};this.createMachinePoint=function(n){var t="<b>"+GetTextByKey("P_MV_NAME_COLON","Name:")+" <\/b> "+htmlencode(n.Name)+"<br/>",i,r;return t+="<b>"+GetTextByKey("P_MV_NAMECUSTOM_COLON","Name (Custom):")+" <\/b>"+htmlencode(n.Name2)+"<br/>",t+="<b>"+GetTextByKey("P_MV_SN_COLON","SN:")+" <\/b>"+n.VIN+"<br/>",t+="<b>"+GetTextByKey("P_MV_MAKE_COLON","Make:")+" <\/b>"+n.Make+"<br/>",t+="<b>"+GetTextByKey("P_MV_MODEL_COLON","Model:")+" <\/b>"+n.Model+"<br/>",t+="<b>"+GetTextByKey("P_MV_TYPE_COLON","Type:")+" <\/b>"+n.AssetType+"<br/>",i={Type:0,CompanyID:n.CompanyID||"",ID:n.ID,Name:htmlencode(n.Name),Name2:htmlencode(n.Name2),VIN:n.VIN,DisplayName:htmlencode(n.DisplayName),DisplayName_O:n.DisplayName+" ("+n.VIN+")",Make:n.Make,Model:n.Model,AssetType:n.AssetType,ViewAlertTypes:n.ViewAlertTypes,AlertTip:n.AlertTips,IconUrl:n.IconUrl,EmptyIconUrl:n.IconUrl.replace("typeid","typeid=-1&t").replace("mid","m"),Priority:n.Priority,infoContent:t},r={id:n.ID,x:n.Longitude,y:n.Latitude,attributes:i},r};this.locateMachine=function(n,i,r){$(".maximize").css("display","none");$(".actionsPane").addClass("hidden");r||(r=t.MyMap.getLevel(),r<6&&(r=6));t.MyMap.setLevel(r);var u=e["MachineID"+n.ID];return u&&t.BaseMachineLayer.locate(u,!0,i),u};this.gotoMap=function(n){n&&t.MyMap.setExtent(n,!0)};this.centerAt=function(n){t.MyMap.centerAt(n)};this.removeMachine=function(n){var i=e["MachineID"+n.ID];i&&(t.BaseMachineLayer.remove(i),delete e["MachineID"+n.ID])};this.removeMachines=function(n){var i,r,u;if(n&&n.length>0){i=[];for(r in n)u=e["MachineID"+n[r].ID],i.push(u.id),delete e["MachineID"+n[r].ID];t.BaseMachineLayer.removebyid(i)}};this.clearMachine=function(){e=[];t.BaseMachineLayer.clearData()};this.showJobSite=function(n){if(this.removeJobSite(n),n.Longitude!=0||n.Latitude!=0){var i=null;n.Radius>0?i=k(n):n.Polygon&&n.Polygon.length>=4&&(i=d(n));i&&(t.BasePolygonLayer.add(i),u["JSID"+n.ID]=i)}};this.refreshJobsiteTooltip=function(n){var i,u;if(r&&r.jobsite&&r.status==0){for(i=0;i<n.length;i++)if(u=n[i],r.jobsite.ID==u.ID){r.refresh(u);return}r&&r.status==0&&(t.MyMap.infoWindow.currentattributes=null,alwaysShow=!1,t.MyMap.infoWindow.hide())}};this.locateJobSite=function(n){var i=u["JSID"+n.ID],r,f;i&&(t.MyMap.setExtent(i.geometry.getExtent(),!0),r="<b>"+GetTextByKey("P_MV_NAME_COLON","Name:")+" <\/b>"+htmlencode(n.Name)+"<br/>",r+="<b>"+GetTextByKey("P_MV_LATITUDE_COLON","Latitude:")+" <\/b>"+n.Latitude+"<br/>",r+="<b>"+GetTextByKey("P_MV_LONGITUDE_COLON","Longitude:")+" <\/b> "+n.Longitude+"<br/>",f=new PointC({longitude:n.Longitude,latitude:n.Latitude}),c({graphic:i,screenPoint:f},1))};this.removeJobSite=function(n,i){var o=u["JSID"+n.ID],f,e;if(o&&(t.BasePolygonLayer.remove(o),delete u["JSID"+n.ID],i&&r&&r.status==0&&t.MyMap.infoWindow.features))for(f=0;f<t.MyMap.infoWindow.features.length;f++)if(e=t.MyMap.infoWindow.features[f],e&&e.jobsite&&e.jobsite.ID==n.ID){setTimeout(function(){t.MyMap.infoWindow.hide()});break}};this.removeJobsites=function(n){var t,i;if(n&&n.length>0)for(t in n)i=n[t],this.removeJobSite(i)};var o,v=[],s=[],f=[];this.showLocationHistoryFromStart=function(n,t,i,r,u,f,e){var s,c,h;for(u?o=null:this.clearLocationHistory(),s=0;s<t.length&&s<=i;s++)c=t[s],h=null,u&&(s==0?h=0:(s==t.length-1||s==i)&&(h=1)),this.showLocationHistory(n,c,s==i&&r,f,e,h)};this.showLocationHistory=function(n,i,r,u,e,h){var a=new PointC({longitude:i.Longitude,latitude:i.Latitude}),c,b,y,p,w,l;return a.loc=i,o?(c=new PolylineC({paths:[[]]}),b=new PointC({longitude:o.Longitude,latitude:o.Latitude}),c.insertPoint(0,c.paths[0].length,b),c.insertPoint(0,c.paths[0].length,a),v["l"+o.LogId]=c,c.StartTime=o.LocationTime,c.EndTime=i.LocationTime,y=this.createLocationHistoryLineGraphic(c,u,e),s["l"+o.LogId]=y,y.isHistoryLine=!0,t.BaseMapLayer.add(y)):(p=t.MyMap.getLevel(),p<12&&(p=12,t.MyMap.setLevel(p))),w=null,h==0?w=this.createLocationHistorySymbolPoint(a,[34,139,34]):h==1&&(w=this.createLocationHistorySymbolPoint(a,[255,0,0])),o=i,l=this.createLocationHistoryPoint(n,a),l.StartOrEndPoint=w,l.StartOrEndPoint&&t.HisptoryPointLayer.add(l.StartOrEndPoint),l.CameraGraphic&&t.HisptoryPointLayer.add(l.CameraGraphic),t.HisptoryPointLayer.add(l),f.push(l),r&&setTimeout(function(){t.MyMap.centerAt(a)},100),a};this.clearLocationHistory=function(){var n;o=null;v=[];for(n in s)t.BaseMapLayer.remove(s[n]);s=[];for(n in f)f[n].StartOrEndPoint&&t.HisptoryPointLayer.remove(f[n].StartOrEndPoint),f[n].CameraGraphic&&t.HisptoryPointLayer.remove(f[n].CameraGraphic),t.HisptoryPointLayer.remove(f[n]);f=[];h&&(h=!1,t.MyMap.infoWindow.hide())};var l,w=[],y=[],a=[],p;this.showSelection=function(n){var i;if(n!=null)for(t.RouteSelectionPointLayer.clear(),i=0;i<n.length;i++){var f=n[i],e=new PointC([f.x,f.y]),r=new SimpleMarkerSymbolC(SimpleMarkerSymbolC.STYLE_CIRCLE,12,null,new ColorC("black")),u=new GraphicC(e,r);t.RouteSelectionPointLayer.add(u);r=new SimpleMarkerSymbolC(SimpleMarkerSymbolC.STYLE_CIRCLE,9,null,new ColorC("white"));u=new GraphicC(e,r);t.RouteSelectionPointLayer.add(u)}};this.clearPlaces=function(){t.SearchPointLayer.clear()};this.searchPlaces=function(n,i){var r=t.MyMap.extent.getCenter(),u={address:{address:n},location:new PointC([r.getLongitude(),r.getLatitude()]),outFields:["PlaceName","Place_addr"],maxLocations:10,langCode:_fleet.currentMapLang};t.Locator.addressToLocations(u).then(function(n){i(n)})};this.showPlaces=function(n){var i,r,u;for(t.SearchPointLayer.clear(),i=0;i<n.length;i++)r=n[i],u=this.createPlacePinPoint(new PointC([r.location.x,r.location.y]),r),t.SearchPointLayer.add(u)};this.getRouteLocationFromAsset=function(n){var t=allAssets.filter(function(t){return t.ID==n})[0];return t!=null?{x:t.Longitude,y:t.Latitude}:null};this.getRouteFromPosition=function(n){var i,r;window.currentRouteStop!=null&&(i={x:n.longitude,y:n.latitude},i.name=i.x.toFixed(6)+", "+i.y.toFixed(6),window.currentRouteStop.data("stop",i),window.currentRouteStop.val(i.name).trigger("change"),window.currentRouteStopName=window.currentRouteStop,r=new PointC([i.x,i.y]),t.Locator.locationToAddress(r,100),window.currentRouteStop.removeClass("focusing"),delete window.currentRouteStop)};this.getRouteFromPositionAsync=function(n){var i=new PointC([n.x,n.y]);return t.LocatorAsync.locationToAddress(i,100)};this.showRouteFromStart=function(n,i,r){var u,f;for(i==0&&(this.clearRouteHistory(),t.RouteSelectionPointLayer.clear(),p=new MultipointC),u=0;u<n.length;u++)f=n[u],p.addPoint(new PointC({longitude:f[0],latitude:f[1]})),this.showRoute({Index:i+u,Longitude:f[0],Latitude:f[1]},u==0,u==n.length-1,i==0,r);r&&t.MyMap.setExtent(p.getExtent())};this.showRoute=function(n,i,r,u,f){var o=new PointC({longitude:n.Longitude,latitude:n.Latitude}),e;if(o.loc=n,l==null&&(l={type:"polyline",paths:[[]]},w.push(l)),l.paths[0].push([n.Longitude,n.Latitude]),r){var c=new PolylineC({paths:l.paths}),h=new SimpleLineSymbolC({color:[47,99,209],width:5}),s=new GraphicC(c,h);y.push(s);t.BaseMapLayer.add(s);h=new SimpleLineSymbolC({color:[110,154,245],width:3});s=new GraphicC(c,h);y.push(s);t.BaseMapLayer.add(s);l=null}return(u&&i||r)&&(e=this.createRouteHistoryPoint(o,12,"black"),t.RoutePointLayer.add(e),a.push(e),e=this.createRouteHistoryPoint(o,7,"white"),t.RoutePointLayer.add(e),a.push(e)),r&&(e=this.createRouteHistoryPoint(o,3,"black"),t.RoutePointLayer.add(e),a.push(e),f&&(e=this.createRoutePinPoint(o),t.RoutePointLayer.add(e),a.push(e))),o};this.clearRouteHistory=function(){var n;for(l=null,w=[],n=0;n<y.length;n++)t.BaseMapLayer.remove(y[n]);y=[];for(n in a)t.RoutePointLayer.remove(a[n]);a=[]};this.createRouteHistoryPoint=function(n,t,i){var r=new SimpleMarkerSymbolC(SimpleMarkerSymbolC.STYLE_CIRCLE,t,null,new ColorC(i));return new GraphicC(n,r)};this.createRoutePinPoint=function(n){var t=new PictureMarkerSymbolC("img/pin.png",23,34);return new GraphicC(n,t)};this.createPlacePinPoint=function(n,t){var r=new PictureMarkerSymbolC("https://static.arcgis.com/images/Symbols/Shapes/RedPin1LargeB.png",30,34),i=new GraphicC(n,r);return i.setAttributes({name:t.attributes.Place_addr||t.address}),i};this.changeLineColor=function(n,i,r){var c,l,e,a,f,u,o;if(Object.keys(v).length!=0){n||(n="1900-1-1");i||(i="2099-12-31");c=new Date(n.replace(/-/g,"/").replace("T"," "));l=new Date(i.replace(/-/g,"/").replace("T"," "));for(u in v){var h=v[u],y=new Date(h.StartTime.replace(/-/g,"/").replace("T"," ")),p=new Date(h.EndTime.replace(/-/g,"/").replace("T"," "));y>=c&&p<=l&&(e=this.createLocationHistoryLineGraphic(h,r),r&&(e.isTrip=!0),a=s[u],t.BaseMapLayer.remove(a),s[u]=e,t.BaseMapLayer.add(e))}f=null;for(u in s)o=s[u],o.isTrip&&(f=f==null?o.geometry.getExtent():f.union(o.geometry.getExtent()));f&&r&&t.MyMap.setExtent(f,!0)}};this.createLocationHistorySymbolPoint=function(n,t){var i=new SimpleMarkerSymbolC({color:[255,255,255],size:8,style:"esriSMSCircle",outline:{color:t,width:6,style:"esriSLSSolid"}});return i.size==0&&i.setSize(8),i.outline.width==0&&i.outline.setWidth(8),new GraphicC(n,i)};var g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEySURBVDhPtVItT8RAEB1ZWbnmksrKSmQVGlmJrOw/2BWXQAIhCJIicRjkJeCKQ5w4WbmyAlGBKG6Z3c4c2+1eguElr5vOx5s3ycD/QkK+uduc41tQ5A+QkICCK+SENO2+NfYlPmNeUGUEdpKCnhvErTAW+UPuiwxYV1KHh3my9gpNvaudgHpXvoDluHaioA2KTKc7J9B/9os48ZU6EfN0tzOT7TOCNWZKyFjA7r5Isn1GZA0rcMECdZhk+8PX4N7oGhK/JFD6CbZ/GA4m2SZHsdUaEi5ZIPUT1v44jSa7z9x/ep0aPer1GosDU9Bxwk4sn8pFcfFYOEdeTFMnAc8Wg5O137w1fuGR1Uv1u8aJY6rEjfgOG33aAVjXUEcEs5OPsJF44oxjkHCGrJEK2cQbAX4AQa0yMfhNcXQAAAAASUVORK5CYII=",nt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAI9SURBVDhPvVQhjOJQEK1EInGLRCKRSOTKypVIJK4/gQTEJVtBsgiSIkhAXAKCZBEksEEgEBUnKhBsgkCc6CWIboKYnff5A21hb3PmXvJS/u/M+/NmfrH+OxzHyTPLMRbMq38DJ1aUUj6Tut0u9ft9/cSaGfD7JxP6d3BglhO8TqdDQRAQEPwO6O39jfyDr9fb7ZZ6vR6EXzk+Z1JvgZcctJtMJnSMjlSf1ynTzJClLHrZvOgnaP+06XA80Gq1okaj8Yfz7reBxYbT6VRXUugULgK5HzldWXpvsVvQZrNBpWsjcQWfYsMmKsu7+UsiWJ1WtaBaqsR+tp3VlaK/nF83UmfAKkMnx5NAVAKgl+l3lUGFwjBElaGR0tUVms0mRafo0jOh2BXEbQt34Y5c10WV517yj0dMDb1LB4tdQdo2OA7GNBqNIGiLYBXDiE9SKHbRK+CebWfh0HK5hKASQXswGOjkeKDYReVohYinbXu+R7hqKEwES+12m8IoTATCLvZk6pgq+pW2jQPxFbFOUQsCmBKmVe6XL4GoKL4Gi91iotc47HQ6YcoRC2aMnK5SwTZ6BHuwW5vVEmJCfCliG4fO53MIekbqDKjzps+g4a8hPbgPN0Jx4sDn9TPt93uIHTg/a6SuQA9ardYHPn5UWuqVvhRDZRAz969iJG7BL0t8YoCpRVFE6/1aXydcDVQEIfTM2ERlX4sJOAj2W0z9nc5mM33P8MQa+0yP425tfgdOwr90jamYdbO+TjMBy/oEcsmWzBePQsYAAAAASUVORK5CYII=",tt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADvSURBVDhPnZItD8JADIZfiUQikUgkjiX7wCKRk0gEnjkSBIoEP8NPQILjJyCRSCRupb3rLdtyLNnepLlc7572ei3+iRJMKERAMabqahfNMShi7Nm+DFHViggXPh/p1bokA194NqGqcdC3vEYRK5MxwssHNI0DfGovYMfZHG4DojyzdkjtXlbnk70NcDWg1mlrlAtO+c5mk9VJzsUntsDY1Fo6usAJluBa173gGBm0l33gVGoelo5usB0e/rBbF1jaakCRjKL58WqrtC1eX3NQGF6VLWsxzrpRpC59wcML+UbTJ44+YzsydC9CnPwQ8AONg7vacAr1YwAAAABJRU5ErkJggg==",it="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIYSURBVDhPvZQxaFpRFIYdMzpmzOjY0a1ZAkKXdqpDh9ApUAgpZJAuPtCgdKmlQhwsShDiUiJUqAUhgoQMDnbKGwwE6pAu5RVCscXh7//fd2818aVtHPrD4XrvPed7555zr7H/rmw2u0Zbn7OE3bqbGJjyPG9IQ6VSQb1eN6PmNJ/7m9b1z6JjnAG1crkM3/dh9Jnjp2PgfGimo9EI1WpV4A/0X7Whi9ImnS5arRam36+AtxngwQqwEbtue2ng6yX6/T5yudw3xkWXgbDDdrsdZvI0sQiat8erJuvBYKBMTy1iJn4lrWOazJ6sRUNu2qO4yVT1ZXzGokLpqBTweit03l0HDrzQXm6Gc41uTXP5vUghCAJlGViUyS6Rz+eBn5NZzRTkdJC1axydtK812ZcLlEolZRnWkj8eqmumds7pLsCTIzSbTQHTDrhlmvF+fzkg13u9noCeA6YbjUZ415YBfqxBV02JOWCyWCwCV8FyQJZKr4icewYoqUvq1u/u/SuQV2w6narLEwJXLM5k6Zlj65mp0/PXxn0kao1l6na7AtYsKpToXBxSwPFh9JO7ae9eYTweC3bJ+LhFzaQaFAqFH3r8JtPtZDTIPjvB7P1LWcSiuJnkF311bTLhRT87Bfaf84j3gTfPDEg1s8dUZrfDnOik4xdo5p12Oh1zzzRqrnVajX6Lx/ybGKR/6R2aR8vY+ayb1xSL/QL9uQvrk6zAAAAAAABJRU5ErkJggg==",rt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADWSURBVDhPjZItFsIwEIRXIpFIZGUlskdAIpFIjlCHrOQIPQKykiMgI5FIHOHbNq/N9gcy781LOpnJbprIErxIBguYB+k3MK4+Ihf4Zu5jotWMm2C1YCHH8IgDY7L+ZCxCpAOCVnSxcYn4XoxDBwjX3lBV3jfNlHUdb3Brg3xo1eGMapyDc304cNue1Yjp4b22fDJierjUynqXg5gePmp4bcT0cPd4aL3pxYQwftcGFQiZ+eP/aR8K4UPKBnjOIWLBonZwHweU6NOnOQeMO6hXWGql+ZDIF0fPnCjLPKZjAAAAAElFTkSuQmCC",ut="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFWSURBVDhPY6Ap2FEZqbG9OtxhZ1WoAVSIMNhfH8+xsyqsfUdl2PedVeH/d9fF/AfRILyjKnz5lpJQCahSTACyCaj5OkwDCN/ZuxrOhuLnIFdBtSAA1Ob7aIr///7+5f/epiQUsR2V4e8xXLKzMnw6siIQPj278T8IXFwxEUUcirdDtUJsh/kZGYOcDwJPzx5AEYfh7eXhCmADIH7HVPD23lWwAd/evcKQA2GgpQFgA7ZXhWagS4L8DQI/Pr0H00f6C1HkwbgyvAFiADiuUSXPL+kBB+Ch7hywITe2LESRB+HtVeEJYAP21/sLoEs+OrkLrglk2Murp1DkIRgpgQGjcD+yJLoGEB85UYGiHKoVAkDJFhYTIGefmF6DpDgcHAbIYlgT087KsAiQIegJB4Zh4jsqwgqgWjAByCXA0D2OrhmKsSdjbGBbVZgFOHqBUQWyEbtGBgYAaNW8JHqlggcAAAAASUVORK5CYII=",ft="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJVSURBVDhPvVQxSBtRGM7o6NjR0bGjY0fHbs3gULro0MFuUkpzmsAFFIwQaMCDpBBswCVDxNhGOIyl1SOEDHrFSBWjFQV7IuKpR/n7fy/vJbm7tKWLH3yc773///L9//+ekQdHLBYbYj7p4bA8+j9w4qimaXUmZTIZyuVy4os10+bz5zL07+DAQU7IptNpsm2bgOvzE7r4vkNXPw7EutlskmEYEF7l+EcyNQwcctBBsVikO/eG9taW6NPbMVp7/azzBRuFBbq9cqharVI8Hr/kvP5tYLEPpVJJONmcf9URAPfXl31rUx8Xri3LgtMvUqIL/pUoyoSzjdmXvmTQc69pfeaFbw9rOEV/OX9KSrWBUhm0WzR8SaC1OC16h1KDZ7WcTo7jwKUjpYS74UQiQb+8e1+vFFEucFIzQ2fgzc9zSqVScNnuJf/xFFND7/oloFcAEvudn+1sU6FQgGBUCU5gGEdbH0PB6BOAXgHBYYH7lWUyTROCmhKM5vN54SQYXM/PiYFgUBD9VnofijnmVuCqwZgSHEkmkyIxGAzXSgTiKC8Yg1bhFbHOYyEIYEqYlmVM+4KDAlj3Dg7OPc/DlF0WHJBywqWGsvHMVAKCv75700kG0cPePbSpUqlAMCul2oA6b9YZdNr4LESDF1lR7R9urlCr1YLYKecPSqku0ANd12/x+OF0K+BOUT07iMn7NyolwuDDEf5FG1NzXZecoz0xGFwNOIIQeibLhLM/iylwEMrXmeKdlstlcc/wxRr7zCzHhcv8FzgJ/6UnmRpzSq670/QhEvkNNxMGho8aL+YAAAAASUVORK5CYII=",et="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAVCAYAAAAnzezqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAC8ElEQVR42uyVb2jUdRzHX5/fvxv73e7WOb3WjbuWLTRTnJZJZLmghAzWsywMrSCiB1GQIIgJghD9gbACgwIHkYtiPTEXQjI0NdzahN2EtE7L7drmzd3d5u5+9/vz7YH3zCiYO33SC77wffDhy5v35/P+fuSzM1kO/jLx2rmJa68USp5CRDFfFJiGGA/caQ+8u6l1T7IxNO54ChH46VKB0aKDLkKgoGtwnE1tMYzBsdn3TmfyOwDE0LgpBFwvYCiTX7Ov788Hd3ekNpq6zBQdn5IXIAi6JhiASPV+6OzkS9GwRc/W+0k0WLjB/A0QAU2ENw//ztF0bk1fKrqqpTF08kKuxGLbpN7SuDLrrj9xqbAvW3Ba0hPXDhvFkqfdF6/n0VQES79JB6o8lGjgaDrHham5EKLQBTQh2j82u+dIOveqW/btugaT/svFbRoaKHX9LBR+9TERUbapU3T8zv2nskM9P2ffikdCdu/r7bywegle2ReDGqIJie/PT3/Rn8m/XKn4vPFUK7s7kjTZJt8MT4JS1ESAVDPRk84dcPKO3d52Bx88s5Qn7mm8obY2DoiAr0QXsd/pbGPHYy2ELf0fS2siQFWH6qvnl9O5fNG/t6kmAqouxMPmf88Jt5n/BWg1i6FS9IxMUSh7t0GACOjC+70Z1n0yyJHzV29xCpQCEZa1RvvGpp3pzZ8Osf3bX7l4tXxrZ+CRZGTX9oebN9+bjGS6jl9m7UcDfHl2EgBdpMYtAPJlt67JNk9vWbV42bPr7vrQBefFg8M83ZVmtOiAJhgE17dXsIACKn4AChpDJqYmTJc8d8PdkbdXxOsPfHdu6vPekdzjKIhFQzPGimY7P/LXbGznDxdZuqgO15//XtZEmHN9ugbGMev0SnsiPNEcthCZo+IrdOG351Y2bcymIlu+Hr6y/sm2WLexbW18694fnUP7j/0RA7wF+IeFkG7t7Eh+vCEVHan4AYmIxZnRGWYcj0BBPGx2hy29u8HS+HsA3l0gQ1y8X+cAAAAASUVORK5CYII=";this.createLocationHistoryPoint=function(n,t){var s=null,l,a,i,v,y,r,u,o,p,f,w;t.loc.Abnormal?s=new PictureMarkerSymbolC(t.loc.IconURL,14,14):(s=t.loc.DriverInsight!=0?new PictureMarkerSymbolC(t.loc.SeatBelt==2?ft:ut,14,14):t.loc.MoveStatus==1?new PictureMarkerSymbolC(t.loc.SeatBelt==2?nt:g,14,14):t.loc.MoveStatus==2?new PictureMarkerSymbolC(t.loc.SeatBelt==2?it:tt,14,14):t.loc.MoveStatus==3?new PictureMarkerSymbolC(rt,14,14):new PictureMarkerSymbolC(t.loc.IconURL,14,14),s.setAngle(t.loc.Heading));var h=!1,c="<div style='min-height:200px;'>",e="<div class='divicon_left'>";if(t.loc.SmartWitnessVideoUrl&&t.loc.SmartWitnessVideoUrl.length>0)for(h=!0,l=0;l<t.loc.SmartWitnessVideoUrl.length;l++)a=t.loc.SmartWitnessVideoUrl[l],e+=a.Key=="Driver Cam"?"<a style='cursor:pointer;margin-left:5px;' onclick='openVideoDialog(\""+encodeURIComponent(a.Value)+"\")'><img style='width:50px;' src='"+_network.root+"img/DriverCam.png?v=1'/><\/a>":"<a style='cursor:pointer;margin-left:5px;' onclick='openVideoDialog(\""+encodeURIComponent(a.Value)+"\")'><img style='width:50px;' src='"+_network.root+"img/RoadCam.png?v=1'/><\/a>",e+="<br/>";return t.loc.FromSmartWitness&&enableSmartWitness&&(h&&(e+="<br/>"),h=!0,e+="<a style='cursor:pointer;' onclick='openRequestVideoDialog("+n.ID+","+t.loc.LogId+")' title='"+GetTextByKey("P_MV_VIDEOREQUEST","Video Request")+"'><img style='width:50px;' src='"+_network.root+"img/RequestVideo.png?v=1'><\/a>",assetHisLocations[t.loc.LogId]=t.loc),i="",h?(e+="<\/div>",c+=e,i+="<div style='margin-left:60px;'>"):i+="<div>",i+="<div><b>"+GetTextByKey("P_MV_NAME_COLON","Name:")+" <\/b>"+htmlencode(n.Name)+"<br/>",i+="<b>"+GetTextByKey("P_MV_NAMECUSTOM_COLON","Name (Custom):")+" <\/b> "+htmlencode(n.Name2)+"<br/>",i+="<b>"+GetTextByKey("P_MV_SN_COLON","SN:")+" <\/b> "+n.VIN+"<br/>",i+="<b>"+GetTextByKey("P_MV_LATITUDE_COLON","Latitude:")+" <\/b>"+t.loc.Latitude+"<br/>",i+="<b>"+GetTextByKey("P_MV_LONGITUDE_COLON","Longitude:")+" <\/b>"+t.loc.Longitude+"<br/>",v="",t.loc.Speed>=0&&(v=t.loc.Speed.toLocaleString()+" "+t.loc.SpeedUnit),v!==""&&(i+="<b>"+GetTextByKey("P_MV_CURRENTSPEED_COLON","Current Speed:")+" <\/b>"+v+"<br/>"),y="",t.loc.PostedSpeed>0&&(y=t.loc.PostedSpeed.toLocaleString()+" "+(t.loc.PostedSpeedUnit==="mi/h"?"mph":t.loc.PostedSpeedUnit)),y!==""&&(i+="<b>"+GetTextByKey("P_MV_POSTEDSPEED_COLON","Posted Speed:")+" <\/b>"+y+"<br/>"),t.loc.Street!==""&&(i+="<b>"+GetTextByKey("P_MV_STREET_COLON","Street:")+"<\/b>"+t.loc.Street+"<br/>"),t.loc.LocationTimeText!==""&&(i+="<b>"+GetTextByKey("P_MV_TIME_COLON","Time:")+" <\/b>"+t.loc.LocationTimeText+"<br/>"),r="",t.loc.DriverInsight===1?r=GetTextByKey("P_MV_ADVANCEDDRIVERASSISTANCESYSTEMS","Advanced Driver Assistance Systems"):t.loc.DriverInsight===2?r=GetTextByKey("P_MV_LANEDEPARTUREWARNINGLEFTSIDE","Lane Departure Warning (left side)"):t.loc.DriverInsight===3?r=GetTextByKey("P_MV_LANEDEPARTUREWARNINGRIGHTSIDE","Lane Departure Warning (right side)"):t.loc.DriverInsight===4?r=GetTextByKey("P_MV_FORWARDCOLLISIONWARNING","Forward Collision Warning"):t.loc.DriverInsight===5?r=GetTextByKey("P_MV_TAILGATING","Tailgating"):t.loc.DriverInsight===6?r=GetTextByKey("P_MV_DISTRACTIONS","Distractions"):t.loc.DriverInsight===7?r=GetTextByKey("P_MV_PHONEATEARCALLING","Phone at Ear (Calling)"):t.loc.DriverInsight===20?r=GetTextByKey("P_MV_DRIVERSTATEMONITORING","Driver State Monitoring"):t.loc.DriverInsight===21?r=GetTextByKey("P_MV_FATIGUE","Fatigue"):t.loc.DriverInsight===22?r=GetTextByKey("P_MV_DISTRACTIONS","Distractions"):t.loc.DriverInsight===23&&(r=GetTextByKey("P_MV_PHONEATEARCALLING","Phone at Ear (Calling)")),u="",t.loc.HarshDringEvent===1?u=GetTextByKey("P_MV_HARDACCELERATION","Hard Acceleration"):t.loc.HarshDringEvent===2?u=GetTextByKey("P_MV_HARDBRAKE","Hard Brake"):t.loc.HarshDringEvent===3&&(u=GetTextByKey("P_MV_HARDBTURN","Hard Turn")),o="",t.loc.SpeedingBehavior===1?o=GetTextByKey("P_MV_SPEEDINGLOWSEVERITY","Speeding: Low Severity"):t.loc.SpeedingBehavior===2&&(o=GetTextByKey("P_MV_SPEEDINGHIGHSEVERITY","Speeding: High Severity")),(r!==""||o!==""||u!=="")&&(i+="<br/>",r!==""&&(i+=r+"<br/>"),u!==""&&(i+=u+"<br/>"),o!==""&&(i+=o+"<br/>")),i+="<\/div>",c+=i,c+="<\/div>",p=new GraphicC(t,s),p.setAttributes({infoContent:c,name:htmlencode(n.DisplayName),Type:2}),t.loc.SmartWitnessVideoUrl&&t.loc.SmartWitnessVideoUrl.length>0&&(f=new PictureMarkerSymbolC(s.toJson()),f.setUrl(et),f.setAngle(0),f.setWidth(24),f.setHeight(18),f.setOffset(3,0),w=new GraphicC(t,f),w.isCamSymbol=!0,p.CameraGraphic=w),p};this.createLocationHistoryLineGraphic=function(n,t,i){var r;return t||(t=[225,95,72]),r=new SimpleLineSymbolC({color:t,width:i||5}),r.width==0&&(r.width=i||5),new GraphicC(n,r)};this.showLocation=function(n){var f,e,i,r;(this.removeLocation(n),n.Longitude!=0||n.Latitude!=0)&&(f=new PointC({longitude:n.Longitude,latitude:n.Latitude}),f.z=10,e=new PictureMarkerSymbolC(n.IconUrl,20,20),i="<b>"+GetTextByKey("P_MV_NAME_COLON","Name:")+" <\/b> "+htmlencode(n.LocationName)+"<br/>",i+="<b>"+GetTextByKey("P_MV_LATITUDE_COLON","Latitude:")+" <\/b>"+n.Latitude+"<br/>",i+="<b>"+GetTextByKey("P_MV_LONGITUDE_COLON","Longitude:")+" <\/b>"+n.Longitude+"<br/>",i+="<b>"+GetTextByKey("P_MV_NOTES_COLON","Notes:")+" <\/b>"+n.Notes+"<br/>",r=new GraphicC(f,e),r.setAttributes({infoContent:i,name:htmlencode(n.LocationName)}),t.BaseMapLayer.add(r),u["LocationID"+n.ID]=r)};this.removeLocation=function(n){var i=u["LocationID"+n.ID];i&&(t.BaseMapLayer.remove(i),delete u["LocationID"+n.ID])};this.showShape=function(n){var b,v,s,y,k,h,i,p,f,e,o,w,r;if(this.removeShape(n),n&&n.Shape){var c=[],l="<b>"+GetTextByKey("P_MV_NAME_COLON","Name:")+" <\/b> "+htmlencode(n.Name)+"<br/>",a=new RegExp("\r\n","g");if(n.Notes=n.Notes.replace(a,"<br/>"),a=new RegExp("\n","g"),n.Notes=n.Notes.replace(a,"<br/>"),l+="<b>"+GetTextByKey("P_MV_NOTES_COLON","Notes:")+" <\/b>"+htmlencode(n.Notes)+"<br/>",n.Shape.Points&&n.Shape.Points.length>0){for(b=new SimpleMarkerSymbolC(SimpleMarkerSymbolC.STYLE_CIRCLE,6,null,new ColorC("#FFA500")),v=new MultipointC,i=0;i<n.Shape.Points.length;i++)e=n.Shape.Points[i],o=new PointC({longitude:e.Longitude,latitude:e.Latitude}),v.addPoint(o);r=new GraphicC(v,b);r.setAttributes({infoContent:l,name:htmlencode(n.Name),Type:3});t.BasePolygonLayer.add(r);c.push(r)}if(n.Shape.Polylines&&n.Shape.Polylines.length>0){for(s=new PolylineC({paths:[]}),i=0;i<n.Shape.Polylines.length;i++)for(y=n.Shape.Polylines[i],s.addPath([]),f=0;f<y.Points.length;f++)e=y.Points[f],o=new PointC({longitude:e.Longitude,latitude:e.Latitude}),s.insertPoint(s.paths.length-1,f,o);k=new SimpleLineSymbolC({color:[255,165,0],width:2});r=new GraphicC(s,k);r.setAttributes({infoContent:l,name:htmlencode(n.Name),Type:3});t.BasePolygonLayer.add(r);c.push(r)}if(n.Shape.Polygons&&n.Shape.Polygons.length>0){for(h=new PolygonC({rings:[]}),i=0;i<n.Shape.Polygons.length;i++)for(p=n.Shape.Polygons[i],h.addRing([]),f=0;f<p.Points.length;f++)e=p.Points[f],o=new PointC({longitude:e.Longitude,latitude:e.Latitude}),h.insertPoint(h.rings.length-1,f,o);w=new SimpleFillSymbolC({color:[255,165,0,51],outline:{color:[255,165,0]}});w.setStyle(SimpleFillSymbolC.STYLE_SOLID);r=new GraphicC(h,w);r.setAttributes({infoContent:l,name:htmlencode(n.Name),Type:3});t.BasePolygonLayer.add(r);c.push(r)}u["ShapeID"+n.ID]=c}};this.removeShape=function(n){var r=u["ShapeID"+n.ID],i,f;if(r)for(i=0;i<r.length;i++)f=r[i],t.BasePolygonLayer.remove(f),delete u["ShapeID"+n.ID]};this.locateShape=function(n){var i=u["ShapeID"+n.ID],r;i&&i.length>0&&(r=t.MyMap.getLevel(),r<6&&(r=6),t.MyMap.setLevel(r),i[0].geometry.type=="point"?t.MyMap.centerAt(i[0].geometry):t.MyMap.setExtent(i[0].geometry.getExtent(),!0))}});allItemUrls=[];var currentLocationHistoryMachine,LocationHistoryInfo,allJobSiteMachine=[],machineStates=[],enableInfoWindow=!0,showMapSlider=!0,currentbasemap="topo";_network.mapviewquery=function(n,t,i,r,u){_network.request("mapview.ashx?tp=ashx",-1,n,t,i,r,u)};prumaryDatasource=null;lineColors=[[67,134,216],[255,154,46],[219,68,63],[168,212,79],[133,96,179],[60,191,227],[175,216,248],[0,142,142],[139,186,0],[250,189,15],[250,110,70],[157,8,13],[161,134,190],[204,102,0],[253,198,137]];imgTypes=[".jfif",".jpg",".jpeg",".bmp",".png",".tiff",".gif"];printTypes=[".pdf",".jfif",".jpg",".jpeg",".bmp",".png",".tiff",".gif"];$(function(){InitSavedSearchGrid();InitSaveSearchGrid();$("#btnSavedSearches").click(openSavedSearches);$("#btnSaveSearchDetault").click(openSaveSearch);$("#dialog_savedsearches").dialog(function(){showmaskbg(!1)});$("#dialog_savesearch").dialog(function(){showmaskbg(!1)})});$(function(){initshape()});selectedShapeFileID=[],function(n){function ft(){h=!0;t=0;i=0;e=0;r=0;u=0;l=0;a=0;w=0;v=0;t=0;b=0}function et(i){if(nt=i.clientX,g){var r=nt-rt;rt=nt;r<0?t- -r>0&&(t=t- -r):t=t+r<o?t+r:o;st();n(".TheColorBar").css("width",t+1);n(".TimeBall").css("left",t)}}function ot(){if(g){g=!1;it=!1;nt=0;var r=parseInt(i/1e3);v=t-r*k;h&&tt();s=!0}n(document).unbind("mousemove",et);n(document).unbind("mouseup",ot)}function st(){i=parseInt(t/o*f);var s=ut(i);l>0?s.hHour?n(".BarBeginTime").html(s.StringTime):n(".BarBeginTime").html("00:"+s.StringTime):n(".BarBeginTime").html(s.StringTime);u=s.Tsec;r=s.Tmin;e=s.Thour}function ht(){var h,c,l;if(t=t*1+k-v,v>0&&(v=0),t<o&&i<f?(i=i+1e3,u=u+1,u>59&&(u=0,r=r+1,r>59&&(r=0,e=e+1)),h=u>9?""+u:"0"+u,c=r>9?""+r:"0"+r,l=e>9?""+e:"0"+e,e>0&&(b=1),b==0?n(".BarBeginTime").html(c+":"+h):n(".BarBeginTime").html(l+":"+c+":"+h)):(t=o,y()),n(".TheColorBar").css("width",t+1),n(".TimeBall").css("left",t),n.playBar.onBarChanged)n.playBar.onBarChanged(i,s);s=!1}function ut(t){var i=parseFloat(t)/1e3,s="",f,h,c,v=!1,e=0,r=0,u=0,o;return i>=60&&i<3600?(h=parseInt(i/60)<10?"0"+parseInt(i/60):parseInt(i/60),o=parseInt(i-parseInt(i/60)*60),f=o<10?"0"+o:""+o,a=parseInt(i/60),w=o,u=a,l=0,r=o,s=h+":"+f,n(".BarBeginTime").html("00:00")):i>=3600?(b=1,v=!0,e=parseInt(i/3600),u=parseInt((parseFloat(i/3600)-parseInt(i/3600))*60),r=parseInt((parseFloat((parseFloat(i/3600)-parseInt(i/3600))*60)-parseInt((parseFloat(i/3600)-parseInt(i/3600))*60))*60),c=e<10?"0"+e:""+e,h=u<10?"0"+u:""+u,f=r<10?"0"+r:""+r,l=e,a=u,w=r,s=c+":"+h+":"+f,n(".BarBeginTime").html("00:00:00")):(n(".BarBeginTime").html("00:00"),r=parseInt(i),f=parseInt(i)>9?""+parseInt(i):"0"+parseInt(i),a=0,w=parseInt(i),l=0,s="00:"+f),{hHour:v,Thour:e,Tmin:u,Tsec:r,StringTime:s}}function y(){it||(h=!1);clearInterval(p);n("#btnPlay").removeClass("BarPause");n("#btnPlay").addClass("BarPlay")}function tt(){if(i<=f){if(s&&n.playBar.onBarChanged){n.playBar.onBarChanged(i,s);s=!1}h=!0;p&&clearInterval(p);p=setInterval(ht,1e3);n("#btnPlay").removeClass("BarPlay");n("#btnPlay").addClass("BarPause")}}var h=!0,c=0,t=0,i=0,p,e=0,r=0,u=0,l=0,a=0,w=0,b=0,f=0,k=0,v=0,d=0,o=0,s=!1;jQuery.playBar={addBar:function(t,i){ft();f=i;t.empty();t.append("<div class='BarControl'><div class='BarBeginTime'>00:00<\/div><\/div>");n(".BarControl").append('<div class="TheBar"><div class="TimeBall"><\/div><div class="TheColorBar"><\/div><div class="TheWhiteBar"><\/div><\/div><div class="BarFinishTime">10:35<\/div><div id="btnPlay" class="BarPlay"><\/div><div id="btnPlayEnd" class="BarPlayEnd">');c=n(".TheBar").width();d=i/1e3;o=c-8;k=(c-10)/d;var r=ut(i);n(".BarFinishTime").html(r.StringTime);n("#btnPlay").on("click",function(){if(n.playBar.onPlayClick)n.playBar.onPlayClick(!1)}).attr("title",GetTextByKey("P_MV_PLAYBACK","Playback"));n("#btnPlayEnd").on("click",function(){if(n.playBar.onPlayClick)n.playBar.onPlayClick(!0)}).attr("title",GetTextByKey("P_MV_QUICKLOADSKIPTOEND","Quick Load/Skip to End"));tt()},restTime:function(i,r,u){ft();y();f=i;c=n(".TheBar").width();d=i/1e3;o=c-8;k=(c-10)/d;var e=ut(i);n(".BarFinishTime").html(e.StringTime);n(".TheColorBar").css("width",0);n(".TimeBall").css("left",0);s=r===undefined?!1:r;i>0&&(u?(t=o,st(),ht()):tt())},Play:function(){h?jQuery.playBar.Stop():jQuery.playBar.Begin()},PlayEnd:function(){jQuery.playBar.restTime(f,!0,!0)},Stop:function(){y()},Clear:function(){y();this.restTime(0);n("#btnPlay").removeClass("BarPause");n("#btnPlay").addClass("BarPlay")},Begin:function(){i>=f?this.restTime(f,!0):tt()},changeBarColor:function(t){var i=typeof t!="undefined"?t:"#3498DB";n(".TheColorBar").css("background",i);n(".TimeBall").css("background",i)},changeFontColor:function(t){var i=typeof t!="undefined"?t:"#3498DB";n(".BarBeginTime,.BarFinishTime").css("color",i)},getAllTime:function(){return f},getTheTime:function(){return i},onBarChanged:undefined,onPlayClick:undefined};var it=!1,g=!1,rt=0,nt=0;n(document).on("mousedown",".TimeBall",function(t){rt=t.clientX;it=!0;g=!0;h&&y();n(document).mousemove(et);n(document).mouseup(ot)})}(jQuery);