var equipmentConfigurationFactory={loadEquipment:function(n){$.ajax({url:n,type:"GET",dataType:"json",async:!1,success:function(n){var t="";$("#eqConfigContent").find("tr").remove();t+="<tr><td>Config Time<\/td><td>deployID<\/td><td>dgID<\/td><td>eID<\/td><td>Description<\/td><td>Height<\/td><td>RInt<\/td><td>Gain<\/td><td>Offset<\/td><\/tr>";n!=null&&n.Alarms!=null&&n.Alarms.length>0?$.each(n.Alarms,function(n,i){t+="<tr><td>"+new Date(i.Timestamp).toString("dd/MM/yyyy HH:mm")+"<\/td><td>"+i.Deployment+"<\/td><td>"+i.DataGroupID+"<\/td><td>"+i.EquipmentID+"<\/td><td>"+i.Description+"<\/td><td>"+i.Height+"<\/td><td>"+i.RecordingInt+"<\/td><td>"+i.Gain+"<\/td><td>"+i.Offset+"<\/td>";t+="<\/tr>"}):t+="<tr><td><\/td><td><\/td><td><\/td><td><\/td><td>There are no current alarm messages.<\/td><td><\/td><\/tr>";t+='<tr style="height: auto;"><\/tr>';$("#eqConfigContent").append(t)}})},setEquipment:function(n,t){$.ajax({url:n,type:"GET",dataType:"json",async:!1,data:t,success:function(n){var t="";$("#eqConfigContent").find("tr").remove();n!=null&&n.Alarms!=null&&n.Alarms.length>0?$.each(n.Alarms,function(n,i){t+="<tr><td>"+new Date(i.Timestamp).toString("dd/MM/yyyy HH:mm")+"<\/td><td>"+i.Deployment+"<\/td><td>"+i.DataGroupID+"<\/td><td>"+i.EquipmentID+"<\/td><td>"+i.Description+"<\/td><td>"+i.Height+"<\/td><td>"+i.RecordingInt+"<\/td><td>"+i.Gain+"<\/td><td>"+i.Offset+'<\/td><td><button id="btnAck'+i.EquipmentID+'" onclick="configureAlarm('+i.EquipmentID+');">Set<\/button><\/td>';t+="<\/tr>"}):t+="<tr><td><\/td><td><\/td><td><\/td><td><\/td><td>There are no current alarm messages.<\/td><td><\/td><\/tr>";t+='<tr style="height: auto;"><\/tr>';$("#eqConfigContent").append(t)}})},getAlarmMessages:function(n){$.ajax({url:n,type:"GET",dataType:"json",async:!1,success:function(n){var t="";$("#almMsgContent").find("tr").remove();n!=null&&n.Alarms!=null&&n.Alarms.length>0?(setSystemState(n.SystemState),$.each(n.Alarms,function(n,i){var r="Cleared";i.State=="Active"?r=i.Level=="Faulty"?"Faulty":"Warning":i.State=="Acknowledged"&&(r="Acknowledged");t+='<tr><td><div id="almState'+i.AlarmID+'" class="msgAlarmState '+r.toLowerCase()+'" title="'+r+'"><\/div><\/td><td>'+new Date(i.Timestamp).toString("dd/MM/yyyy HH:mm")+"<\/td><td>"+i.EquipmentID+"<\/td><td>"+i.ParameterID+"<\/td><td>"+i.Message+"<\/td>";t+=i.State=="Active"&&i.Level=="Faulty"?'<td><button id="btnAck'+i.AlarmID+'" onclick="acknowledgeAlarm('+i.AlarmID+');">Ack<\/button><\/td>':"<td><\/td>";t+="<\/tr>"})):t+="<tr><td><\/td><td><\/td><td><\/td><td><\/td><td>There are no current alarm messages.<\/td><td><\/td><\/tr>";t+='<tr style="height: auto;"><\/tr>';$("#almMsgContent").append(t)},error:function(n,t,i){$("#almMsgContent").find("tr").remove();$("#almMsgContent").append("<tr><td><\/td><td><\/td><td><\/td><td><\/td><td>A problem occurred retrieving alarms: "+i+"<\/td><td><\/td><\/tr>")}})}},alarmConfigurationFactory={loadParameterValues:function(n,t){var i=t.value!=null?n+"/"+t.value:n;$.ajax({url:i,type:"GET",dataType:"json",success:function(n){n!=null&&$.each(n.Alarms,function(n,t){document.getElementById("SleepDuration").value=t.SleepDuration;t.AlarmType=="DataAge"?(document.getElementById("MinBoundaryRow").style.display="none",document.getElementById("MaxBoundaryRow").style.display="none",document.getElementById("DataAgeRow").style.display="table-row"):(document.getElementById("DataAgeRow").style.display="none",document.getElementById("MinBoundaryRow").style.display="table-row",document.getElementById("MaxBoundaryRow").style.display="table-row");document.getElementById("DataAge").value=t.DataAge;document.getElementById("Description").value=t.Description;document.getElementById("MinBoundary").value=t.MinBoundary;document.getElementById("ClearedDisplayDuration").value=t.ClearedDisplayDuration;document.getElementById("MaxBoundary").value=t.MaxBoundary;document.getElementById("AlarmId").textContent=t.AlarmID})}});$("#ErrorMessage").text("")},loadAlarm:function(n,t,i,r,u){$.ajax({url:n,type:"GET",dataType:"json",converters:{"text json":function(n){return $.parseJSON(n,!0)}},success:function(n){if(n!=null){var f='<select  Class="htmlTextBox" id = "'+r+'" ; onchange="getSelectedParameters(this)" >',e='<select Class="htmlTextBox" id = "'+u+'" ; onchange="getSelectedParameterVals(this)">';$.each(n.EquipmentList,function(t,i){$.each(n.Alarms,function(n,t){i.Value==t.EquipmentID&&(t.AlarmType=="DataAge"?(document.getElementById("MinBoundaryRow").style.display="none",document.getElementById("MaxBoundaryRow").style.display="none",document.getElementById("DataAgeRow").style.display="table-row"):(document.getElementById("DataAgeRow").style.display="none",document.getElementById("MinBoundaryRow").style.display="table-row",document.getElementById("MaxBoundaryRow").style.display="table-row"),n==0&&(document.getElementById("SleepDuration").value=t.SleepDuration,document.getElementById("DataAge").value=t.DataAge,document.getElementById("Description").value=t.Description,document.getElementById("MinBoundary").value=t.MinBoundary,document.getElementById("ClearedDisplayDuration").value=t.ClearedDisplayDuration,document.getElementById("MaxBoundary").value=t.MaxBoundary,document.getElementById("AlarmId").textContent=t.AlarmID,document.getElementById("EqId").value=t.EquipmentID),f.indexOf('id = "'+t.ParameterID+'"')==-1&&document.getElementById("EqId").value==t.EquipmentID&&(e+='<option id = "'+t.AlarmID+'" value="'+t.AlarmID+'">'+(t.ParameterName+"/"+t.AlarmType)+"<\/option>"))});f+='<option id = "'+i.Value+'" value="'+i.Value+'">'+i.Text+"<\/option>"});f+="<\/select>";e+="<\/select>";t.replaceWith(f);i.replaceWith(e);$("#ErrorMessage").text("")}}})},loadParameters:function(n,t,i,r){var u=t.value!=null?n+"/"+t.value:n;$.ajax({url:u,type:"GET",dataType:"json",success:function(n){if(n!=null){var t='<select Class="htmlTextBox" id = "'+r+'" ; onchange="getSelectedParameterVals(this)">';$.each(n.EquipmentList,function(i,r){$.each(n.Alarms,function(n,i){r.Value==i.EquipmentID&&(n==0&&(document.getElementById("SleepDuration").value=i.SleepDuration,document.getElementById("DataAge").value=i.DataAge,document.getElementById("Description").value=i.Description,document.getElementById("MinBoundary").value=i.MinBoundary,document.getElementById("ClearedDisplayDuration").value=i.ClearedDisplayDuration,document.getElementById("MaxBoundary").value=i.MaxBoundary,document.getElementById("AlarmId").textContent=i.AlarmID,document.getElementById("EqId").value=i.EquipmentID,i.AlarmType=="DataAge"?(document.getElementById("MinBoundaryRow").style.display="none",document.getElementById("MaxBoundaryRow").style.display="none",document.getElementById("DataAgeRow").style.display="table-row"):(document.getElementById("DataAgeRow").style.display="none",document.getElementById("MinBoundaryRow").style.display="table-row",document.getElementById("MaxBoundaryRow").style.display="table-row")),t.indexOf('id = "'+i.ParameterID+'"')==-1&&(t+='<option Class="htmlTextBox" id = "'+i.AlarmID+'" value="'+i.AlarmID+'">'+(i.ParameterName+"/"+i.AlarmType)+"<\/option>"))})});t+="<\/select>";i.replaceWith(t);$("#ErrorMessage").text("")}}})},validateCustomValues:function(n){var t=!0,u,f,i,r;return n!=null?(u=[],u.push(8),u.push(45),f=n.which?n.which:n.keyCode,f>=48&&f<=57||u.indexOf(f)!=-1):(document.getElementById("DataAgeRow").style.display=="none"?(i=$("#MinBoundary").val(),r=$("#MaxBoundary").val(),i===""?($("#ErrorMessage").text("Enter a min boundary  value."),t=!1):isNaN(i)&&($("#ErrorMessage").text("Invalid min boundary  value."),t=!1),r===""?($("#ErrorMessage").text("Enter a max boundary value."),t=!1):isNaN(r)&&($("#ErrorMessage").text("Invalid max boundary value."),t=!1),r!=""&&i!=""&&parseFloat(i)>=parseFloat(r)&&($("#ErrorMessage").text("Min boundary can't be greater/equal to the max."),t=!1)):($("#DataAge").val()===""&&($("#ErrorMessage").text("Enter a max data age value in minutes."),t=!1),(parseFloat($("#DataAge").val())<=0||isNaN(parseFloat($("#DataAge").val())))&&($("#ErrorMessage").text("Max data age value must be greater than zero."),t=!1)),t)}}