2013-07-26 10:43:30 +00:00
|
|
|
var westdc = {};
|
|
|
|
westdc.dataservice = {
|
2013-07-25 09:13:57 +00:00
|
|
|
//wsn 选择数据
|
|
|
|
choiceData : function(uuid)
|
|
|
|
{
|
|
|
|
this.uuid = uuid;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
'type':"POST",
|
|
|
|
'url':'/data/dataservice',
|
|
|
|
'data':'uuid=' + this.uuid,
|
|
|
|
'success':function(data){
|
|
|
|
if(typeof(data) == 'undefined')
|
|
|
|
{
|
|
|
|
alert("数据源错误,请联系管理员");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$.isEmptyObject(data.error))
|
|
|
|
{
|
|
|
|
alert(data.error);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(data.type == "wsn")
|
|
|
|
{
|
2013-07-26 10:43:30 +00:00
|
|
|
html = westdc.dataservice.wsn.dialog.site(data);
|
|
|
|
westdc.dataservice.creatWindow(html);
|
2013-07-25 09:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
'timeout': 30000,
|
|
|
|
'error': function(){
|
|
|
|
alert('出现错误,请刷新后重试');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
creatWindow : function(html){
|
|
|
|
$.colorbox({
|
|
|
|
initialHeight: '0',
|
|
|
|
initialWidth: '0',
|
|
|
|
html: html,
|
|
|
|
opacity: '0.3',
|
|
|
|
onComplete: function(){
|
|
|
|
$('.confirm_yes').click(function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
$('.confirm_no').click(function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
$.colorbox.close();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-26 10:43:30 +00:00
|
|
|
westdc.dataservice.wsn = {
|
2013-07-25 09:13:57 +00:00
|
|
|
request : function()
|
|
|
|
{
|
|
|
|
$.ajax({
|
|
|
|
'type':"POST",
|
|
|
|
'url':'/data/wsn/',
|
2013-07-26 10:43:30 +00:00
|
|
|
'data':$('#dataservice-wsn-form').serialize(),
|
2013-07-25 09:13:57 +00:00
|
|
|
'success':function(data){
|
2013-07-26 10:43:30 +00:00
|
|
|
if(typeof(data) == 'undefined')
|
2013-07-25 09:13:57 +00:00
|
|
|
{
|
2013-07-26 10:43:30 +00:00
|
|
|
alert("数据源错误,请联系管理员");
|
|
|
|
return false;
|
2013-07-25 09:13:57 +00:00
|
|
|
}
|
2013-07-26 10:43:30 +00:00
|
|
|
|
|
|
|
if(!$.isEmptyObject(data.error))
|
|
|
|
{
|
|
|
|
alert(data.error);
|
|
|
|
return false;
|
2013-07-25 09:13:57 +00:00
|
|
|
}
|
2013-07-26 10:43:30 +00:00
|
|
|
|
|
|
|
html = westdc.dataservice.wsn.dialog.vars(data);
|
|
|
|
westdc.dataservice.creatWindow(html);
|
|
|
|
|
2013-07-25 09:13:57 +00:00
|
|
|
},
|
|
|
|
'timeout': 30000,
|
|
|
|
'error': function(){
|
|
|
|
alert('出现错误,请刷新后重试');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
dialog : {
|
|
|
|
site : function(data){
|
2013-07-26 10:43:30 +00:00
|
|
|
this.input = new Array();
|
|
|
|
for(i in data.data)
|
|
|
|
{
|
|
|
|
this.li = '<label class="checkbox">'
|
|
|
|
+ '<input type="checkbox" value="' + data.data[i].siteid + '" name="siteid[]" checked="checked" /> '
|
|
|
|
+ data.data[i].sitename
|
|
|
|
+ '</label>';
|
|
|
|
this.input.push(this.li);
|
|
|
|
}
|
|
|
|
this.HTML = '<div class=""><div class="modal-header"><h3>'+data.info.service_title+'</h3></div>'
|
|
|
|
+ '<div class="modal-body"><form id="dataservice-wsn-form">'
|
|
|
|
+ '<div>请选择要下载数据的观测点</div>'
|
|
|
|
+ '<div>'
|
|
|
|
+ this.input.join("")
|
|
|
|
+ '</div>'
|
|
|
|
+ '<input type="hidden" name="uuid" value="'+data.info.uuid+'" />'
|
|
|
|
+ '<input type="hidden" name="type" value="var" />'
|
|
|
|
+ '</form></div>'
|
|
|
|
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes" onclick=' + data.callback + '>下一步</a>'
|
|
|
|
+ '<a href="javascript:void(0);" class="btn confirm_no">取消</a></div></div>';
|
|
|
|
return this.HTML;
|
|
|
|
},
|
|
|
|
vars : function(data){
|
|
|
|
this.input = new Array();
|
|
|
|
for(i in data.data)
|
|
|
|
{
|
|
|
|
this.li = '<label class="checkbox">'
|
|
|
|
+ '<input type="checkbox" value="' + data.data[i].varid + '" name="siteid[]" checked="checked" /> '
|
|
|
|
+ data.data[i].nameview
|
|
|
|
+ '</label>';
|
|
|
|
this.input.push(this.li);
|
|
|
|
}
|
|
|
|
this.HTML = '<div class=""><div class="modal-header"><h3>'+data.info.service_title+'</h3></div>'
|
|
|
|
+ '<div class="modal-body"><form id="dataservice-wsn-form">'
|
|
|
|
+ '<div>请选择需要下载的变量</div>'
|
|
|
|
+ '<div>'
|
|
|
|
+ this.input.join("")
|
|
|
|
+ '</div>'
|
|
|
|
+ '<input type="hidden" name="uuid" value="'+data.uuid+'" />'
|
|
|
|
+ '<input type="hidden" name="type" value="var" />'
|
|
|
|
+ '</form></div>'
|
|
|
|
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes" onclick=' + data.callback + '>提交</a>'
|
|
|
|
+ '<a href="javascript:void(0);" class="btn confirm_no">取消</a></div></div>';
|
|
|
|
return this.HTML;
|
|
|
|
|
2013-07-25 09:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|