var westdc = {}; westdc.dataservice = { //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") { html = westdc.dataservice.wsn.dialog.site(data); westdc.dataservice.creatWindow(html); } }, '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(); }); } }); } } westdc.dataservice.wsn = { request : function() { $.ajax({ 'type':"POST", 'url':'/data/wsn/', 'data':$('#dataservice-wsn-form').serialize(), 'success':function(data){ if(typeof(data) == 'undefined') { alert("数据源错误,请联系管理员"); return false; } if(!$.isEmptyObject(data.error)) { alert(data.error); return false; } html = westdc.dataservice.wsn.dialog.vars(data); westdc.dataservice.creatWindow(html); }, 'timeout': 30000, 'error': function(){ alert('出现错误,请刷新后重试'); } }); }, dialog : { site : function(data){ this.input = new Array(); for(i in data.data) { this.li = ''; this.input.push(this.li); } this.HTML = '
' + '' + '
'; return this.HTML; }, vars : function(data){ this.input = new Array(); for(i in data.data) { this.li = ''; this.input.push(this.li); } this.HTML = '
' + '' + '
'; return this.HTML; } } }