ASCU_ALL/Site/js/main.js

155 lines
5.2 KiB
JavaScript
Raw Normal View History

2021-11-12 15:00:41 +05:00
var pasport_vdp = new Pasport();
var tech_cycle = new TechCycle();
var search1_date = $('#Search1_date');
var search1_list_pasport = $('#Search1_list_pasport');
var search1_button = $('#Search1_button');
var button_load_all = $('#Pasport_button_LoadAll');
var search2_select_vdp = $('#Search2_select_vdp');
var search2_date_start = $('#Search2_date_start');
var search2_date_end = $('#Search2_date_end');
var search2_time_start = $('#Search2_time_start');
var search2_time_end = $('#Search2_time_end');
var search2_button_load = $('#Search2_button_load');
var analog_Chart = new AnalogChart();
$(document).ready(function () {
var d = new Date();
var t = d.getFullYear() + "-" +
("0" + (d.getMonth() + 1)).slice(-2) + "-" +
("0" + d.getDate()).slice(-2);
search1_date.val(t);
search2_date_end.val(t);
t = ("0" + d.getHours()).slice(-2) + ":" +
("0" + d.getMinutes()).slice(-2) + ":" +
("0" + d.getSeconds()).slice(-2);
search2_time_end.val(t);
search2_time_start.val(t);
d.setDate(d.getDate() - 3);
t = d.getFullYear() + "-" +
("0" + (d.getMonth() + 1)).slice(-2) + "-" +
("0" + d.getDate()).slice(-2);
search2_date_start.val(t);
for (var i = 1; i < 51; i++)
search2_select_vdp.append('<option>' + i + '</option>');
for (var i = 91; i < 95; i++)
search2_select_vdp.append('<option>' + i + '</option>');
});
search1_date.change(function () {
search1_list_pasport.empty();
pasport_vdp.Clear();
tech_cycle.Clear();
analog_Chart.Clear();
var value = search1_date.val();
value = value.split('-');
value = new Date(value[0], value[1] - 1, value[2]);
if (value < new Date(2001, 01, 21))
search1_date.val("2001-02-21");
if (value > new Date()) {
var date = new Date();
date =
date.getFullYear() + "-" +
("0" + (date.getMonth() + 1)).slice(-2) + "-" +
("0" + date.getDate()).slice(-2);
search1_date.val(date);
}
});
search1_button.click(function () {
if (!search1_date.val())
return;
$.ajax({
type: "POST",
url: 'http://' + document.URL.split("/")[2] + '/api/dirbrowse',
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({ "date": search1_date.val() }),
failure: function (errMsg) {
alert(errMsg);
},
beforeSend: function (jqXHR, settings) {
pasport_vdp.Clear();
search1_list_pasport.empty();
},
success: function (date) {
if (date.length == 0)
search1_list_pasport.append('<option>Плавок нет</option>');
for (var i = 0; i < date.length; i++)
search1_list_pasport.append('<option value="' + date[i].Dir + '">' + date[i].Name + '</option>');
search1_list_pasport.change();
}
});
});
search1_list_pasport.change(function () {
var chk = search1_list_pasport.find(":selected").val();
if (chk == undefined || chk == "" || chk == "Плавок нет")
return;
if (chk != pasport_vdp._server_dir) {
pasport_vdp.Download(chk);
}
tech_cycle.Clear();
analog_Chart.Clear();
});
button_load_all.click(function () {
tech_cycle.Download(pasport_vdp);
analog_Chart = new AnalogChart(pasport_vdp.num_vdp, pasport_vdp.time_start, pasport_vdp.time_end);
analog_Chart.LoadData();
});
search2_button_load.click(function () {
if (search2_date_start.val() == undefined ||
search2_date_end.val() == undefined ||
search2_time_start.val() == undefined ||
search2_time_end.val() == undefined) {
alert("Не верно указаны даты.");
return;
}
pasport_vdp.Clear();
tech_cycle.Clear();
analog_Chart.Clear();
var d = search2_date_start.val().split('-');
var t = search2_time_start.val().split(':');
var r_start = new Date(d[0], d[1], d[2], t[0], t[1], t[2]);
d = search2_date_end.val().split('-');
t = search2_time_end.val().split(':');
var r_end = new Date(d[0], d[1], d[2], t[0], t[1], t[2]);
var delta = r_end - r_start;
delta = Math.round(delta / 1000 / 60 / 60 / 24);
if (delta < 0) {
alert("Не верно указаны даты.");
return;
}
if (delta > 3) {
alert("Временной интервал больше 4 дней.");
return;
}
var ds = search2_date_start.val().split('-');
var ts = search2_time_start.val().split(':');
var de = search2_date_end.val().split('-');
var te = search2_time_end.val().split(':');
tech_cycle.DownloadFormTime(
search2_select_vdp.find(":selected").val(),
ds[2] + '.' + ds[1] + '.' + ds[0] + ' ' + ts[0] + ':' + ts[1] + ':' + ts[2],
de[2] + '.' + de[1] + '.' + de[0] + ' ' + te[0] + ':' + te[1] + ':' + te[2]);
analog_Chart = new AnalogChart(search2_select_vdp.find(":selected").val(),
ds[2] + '.' + ds[1] + '.' + ds[0] + ' ' + ts[0] + ':' + ts[1] + ':' + ts[2],
de[2] + '.' + de[1] + '.' + de[0] + ' ' + te[0] + ':' + te[1] + ':' + te[2]);
analog_Chart.LoadData();
})
$("#test_button").click(function () {
analog_Chart.LoadData();
});