captureSettingsCommon.js
6.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// 初始化时间段选择框
$().ready(function (params) {
//时间选择控件
$(".timeSpans").click(showTimeSelector).focus(onTimeSelectorFocus);
$(".timeSelectorAdd").click(addTimePicker);//添加空的时间段选择框
$(".timeSelectorSave").click(saveTimeSpans);//保存选择的时间段
$(".timeSelector").click(function (e) {
e.stopPropagation();
});
$(document).click(function () {
saveTimeSpan(null);
});
});
//不让时间对话框获取焦点
function onTimeSelectorFocus(event) {
this.blur();
}
//显示时间段选择窗口
function showTimeSelector(event) {
event.stopPropagation();
if (showedDatepicker) {
saveTimeSpan(null);
}
//保存当前时间控件
showedDatepicker = $(event.currentTarget).next().find(".timeSpanContainer");
var timeValue = event.currentTarget.value;//获取已选择的时间段
var timeSpanArray = timeValue.split(";");
var htmlTagsArray = new Array();
var tagId1, tagId2;
var timePair, timeStart, timeEnd;
for (var i = 0; i < timeSpanArray.length; i++) {
tagId1 = "s" + i;
tagId2 = "e" + i;
timePair = $.trim(timeSpanArray[i]).split('-');
//如果时间段不合法(开始,结束时间缺少),直接跳过该值
if (timePair.length != 2) {
continue;
}
htmlTagsArray.push("<li><input type='text' id='" + tagId1 + "' class='Wdate timePicker' value='" + timePair[0] + "' onclick=\"WdatePicker({dateFmt:'HH:mm', maxDate: '#F{$dp.$D(\\'" + tagId2 + "\\')||\\'23:59:59\\'}'})\" /> - ");
htmlTagsArray.push("<input type='text' id='" + tagId2 + "' class='Wdate timePicker' value='" + timePair[1] + "' onclick=\"WdatePicker({dateFmt:'HH:mm', minDate: '#F{$dp.$D(\\'" + tagId1 + "\\')||\\'00:00:00\\'}'})\" />");
htmlTagsArray.push("<a href='#' class='btnDelete' /></a></li>");
}
//显示控件(先清空,再添加新的时间选择控件)
var timeSelector = $(event.currentTarget).parent().find(".timeSelector");
//先解绑删除按钮事件
$(".btnDelete").unbind("click");
timeSelector.find(".timeSpanContainer").html("").html(htmlTagsArray.join(""));
//显示时间段选择组件的位置
timeSelector.css("top", 27).css("left", 4).show();
timeSelector.show();
//绑定删除时间段的方法
$(".btnDelete").bind("click", deleteTimePicker);
//判断是否显示添加时间段按钮
if (htmlTagsArray.length >= 10) {
timeSelector.find(".timeSelectorAdd").hide();
} else {
timeSelector.find(".timeSelectorAdd").show();
}
}
//添加空的时间段选择控件
function addTimePicker(event) {
event.stopPropagation();
var timeSpanContainer = $(event.currentTarget).parent().find(".timeSpanContainer");
var timePickerLength = timeSpanContainer.find("li").length;
var newTimePickerArray = new Array();
var tagId1 = "s" + (timePickerLength - 1);
var tagId2 = "e" + (timePickerLength - 1);
newTimePickerArray.push("<li><input type='text' id='" + tagId1 + "' class='Wdate timePicker' onclick=\"WdatePicker({dateFmt:'HH:mm', maxDate: '#F{$dp.$D(\\'" + tagId2 + "\\')||\\'23:59:59\\'}'})\" /> - ");
newTimePickerArray.push("<input type='text' id='" + tagId2 + "' class='Wdate timePicker' onclick=\"WdatePicker({dateFmt:'HH:mm', minDate: '#F{$dp.$D(\\'" + tagId1 + "\\')||\\'00:00:00\\'}'})\" />");
newTimePickerArray.push("<a href='#' class='btnDelete' /></a></li>");
timeSpanContainer.append(newTimePickerArray.join(""));
//添加删除的事件绑定
$(".btnDelete").bind("click", deleteTimePicker);
if (timePickerLength + 1 >= 10) {
timeSpanContainer.parent().find(".timeSelectorAdd").hide();
}
}
//删除之前的时间控件
function deleteTimePicker(event) {
event.stopPropagation();
var liContainer = $(event.currentTarget).parent();
var timespansContainer = liContainer.parents(".timeSelector");
//先解绑删除按钮的事件
$(event.currentTarget).unbind();
liContainer.remove();
//检测时间段控件的个数
var timeSpansCount = timespansContainer.find("li").length;
if (timeSpansCount < 10) {
timespansContainer.parent().find(".timeSelectorAdd").show();
}
}
//保存已修改的时间段的值
function saveTimeSpans(event) {
var timeSpanContainer = $(event.currentTarget).parent().find(".timeSpanContainer");
saveTimeSpan(timeSpanContainer);
}
function saveTimeSpan(container) {
if (!container) {
container = showedDatepicker;
}
if (!container) {
return;
}
var timePickerPairsContainer = container.find("li");
var timeSpanValueArray = new Array();
var timePickers;
for (var i = 0; i < timePickerPairsContainer.length; i++) {
var timePickerPairs = $(timePickerPairsContainer[i]).find(".Wdate");
if (timePickerPairs.length == 2 && timePickerPairs[0].value && timePickerPairs[1].value) {
timeSpanValueArray.push(timePickerPairs[0].value + "-" + timePickerPairs[1].value);
}
}
//保存到原始
var valueContainer = container.parent().siblings("input");
valueContainer.val(timeSpanValueArray.join(";"));
//关闭
container.parent().hide();
showedDatepicker = null;
}
//------------------------------------ roi ocx -----------------------------
function ROIOcxController(ocxObj) {
var ocxObject = ocxObj;
this.showPage = function () {
showOcxPage();
};
this.showDialog = function () {
showOcxDialog();
};
this.loadUrlPage = function (imgUrl) {
loadOcxUrlPage(imgUrl);
};
this.loadUrlXml = function (imgUrl) {
loadOcxUrlXml(imgUrl);
};
function showOcxPage() {
ocxObject.showRoiPage();
};
function showOcxDialog() {
ocxObject.AboutBox();
};
function loadOcxUrlPage(imgUrl) {
var err = ocxObject.loadRoiPictureFromUrl(imgUrl);
if (err != 0) {
//alert("loadRoiPictureFromUrl: err = " + err);
}
};
function loadOcxUrlXml(imgUrl) {
var err = ocxObject.loadRoiXmlFromUrl(imgUrl);
if (err != 0) {
//alert("loadRoiXmlFromXml: err = " + err);
}
};
}
// 显示Ocx
function showOcxObj() {
$("#roiOcxObject").show();
}
// 隐藏Ocx
function hideOcxObj() {
$("#roiOcxObject").hide();
}