signal.js
1.93 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
//信源
//function activity_preview(){
// window.location.href='../../pages/activity/activity_preview.jsp';
//}
function t_signal_add_or_update(id) {
$("#t_signal_save_btn").html("后台处理中...");
$("#t_signal_save_btn").attr("disabled", "disabled");
//构造t_signal对象
var type;
$("input[name='type']:checked").each(function() {
type = this.value;
});
var t_signal = new Object();
t_signal.name = $('#name').val();
t_signal.ip = $('#ip').val();
t_signal.alias= $('#alias').val();
t_signal.type =type;
t_signal.admin_url = $('#admin_url').val();
t_signal.stream_name = $('#stream_name').val();
var json = JSON.stringify(t_signal);
$.ajax({
url : BASE+'/signal/add',
type : 'post',
datatype : "json",
data : {
id :id,
json :json
},
async : true,
error : function(data) {
alert('保存时发生错误!');
$("#t_signal_save_btn").attr("disabled", false);
},
success : function(data) {
$("#t_signal_save_btn").html("保存完成");
$("#t_signal_save_btn").attr("disabled", false);
showTip(data.success);
location.href = BASE+'/signal/list/1';
}
});
}
function t_signal_edit(id){
window.location.href = BASE+"/signal/edit/"+id;
}
function t_signal_delete(id) {
if (window.confirm('您确定要删除吗!')) {
$.ajax({
url : BASE+'/signal/delete/' + id,
type : 'post',
async : true,
error : function() {
alert('error');
},
success : function(data) {
if (data.success) {
alert('删除成功!');
location.href = BASE+'/signal/list/1';
} else {
showTips("不允许删除!");
}
}
});
}
}
function open_signal(id,state){
$.ajax({
url : BASE+'/signal/close',
type : 'post',
async : true,
data : {
id :id,
state:state
},
error : function() {
alert('error');
},
success : function(data) {
if (data.success) {
location.href = BASE+'/signal/list/1';
} else {
showTips("操作失败!");
}
}
});
}