123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 |
- function getUrlParam(){
- var encondeCondition=window.location.search;
- var condition= decodeURI(decodeURI(encondeCondition.substring(1,encondeCondition.length)));
- var conditionArr=condition.split("&");
- var condJson={};
- for(var item in conditionArr){
- var temArr=conditionArr[item].split("=");
- condJson[temArr[0]]=temArr[1];
- }
- return condJson;
- };
- $(function(){
- $("input").each(function(i){
- if($(this).attr("value")){
- $(this).focus();
- $(this).blur();
- };
- });
- });
- $(function(){
-
- var point = getUrlParam();
- $("#posX").text(point.x);
- $("#posY").text(point.y);
-
- $("#LONGITUDE").attr("value",point.x);
- $("#LATITUDE").attr("value",point.y);
- $("#ORDER_NUM").attr("value",point.pi);
-
- var $no = "<img src='/nwyj/images/cockpit/btn/no.png'>" ;
- var $ok = "<img src='/nwyj/images/cockpit/btn/ok.png'>" ;
-
- var reg = new RegExp("^([0-9]+(.[0-9]{1,5})?)?$");
-
- //七级风圈离开焦点校验
- $("#SEVEN_RADIUS").on("blur",function(){
- var data = $("#SEVEN_RADIUS").val() ;
- var flg = valIsNull(data);
-
- //校验七级风圈是否为正实数
- var obj = $("#SEVEN_RADIUS").val();
- if(!reg.test(obj)){
- appendValid("SEVEN_RADIUS", $no, "<span class=''>请输入数字!</span>", false);
- clearValid() ;
- return false ;
- }
-
- //校验是否输入数据
- if(flg){//空
- appendValid("SEVEN_RADIUS", $no, "<span class=''>请输入风圈半径!</span>", false);
- clearValid() ;
- return false;
- }else{//有数据
-
- //校验数据是否为可用范围
- flg = valIsValid(data);
- if(flg){//可用
- $("._typhoon_disa").removeClass("_no_drop");
- $("._typhoon_disa").removeAttr("disabled");
- appendValid("SEVEN_RADIUS", $ok, "", true);
-
- //校验十级与十二级是否为可用
- if($("._typhoon_disa").hasClass("_no_drop")){//不可用
- appendValid("SEVEN_RADIUS", $ok, "", true);
- }else{//可用
- var ten = $("#TEN_RADIUS").val() ;
-
- //判断十级是否为空
- if(!valIsNull(ten)){//不为空
- //校验十级风圈是否为正实数
- obj = $("#TEN_RADIUS").val();
- if(!reg.test(obj)){
- appendValid("TEN_RADIUS", $no, "<span class=''>请输入数字!</span>", false);
- valTewnt();
-
- return false ;
- }
-
- if(valIsValid(ten)){//十级为可用范围
- if(Number(ten) >= Number(data)){//十级大于等于七级
- appendValid("TEN_RADIUS", $no, "<span class=''>范围要小于七级风圈半径!</span>", false);
- }else{
- appendValid("TEN_RADIUS", $ok, "", true);
- }
- }else{//不可用范围
- appendValid("TEN_RADIUS", $no, "<span class=''>请输入合理的风圈半径!</span>", false);
- }
- }else{//十级为空
- appendValid("TEN_RADIUS", "", "", true);
- };
-
- valTewnt();
-
- }
-
-
- }else{//不可用
- appendValid("SEVEN_RADIUS", $no, "<span class=''>请输入合理的风圈半径!</span>", false);
- clearValid() ;
- return false ;
- }
-
- }
-
- });
-
-
- //十级风圈离开焦点校验
- $("#TEN_RADIUS").on("blur",function(){
- var sev = $("#SEVEN_RADIUS").val() ; //七级风圈(一定是正确数据)
- var ten = $("#TEN_RADIUS").val() ; //十级风圈
- var twev = $("#TWELVE_RADIUS").val() ;//十二级风圈
-
- //判断十级风圈是否输入数据
- if(valIsNull(ten)){//十级为空
-
- appendValid("TEN_RADIUS", "", "", true);
- //判断十二级风圈是否为空
- if(valIsNull(twev)){//十二级为空
- appendValid("TWELVE_RADIUS", "", "", true);
-
- }else{//十二级不为空
- if(Number(twev) >= Number(sev)){//十二级大于等于七级
- appendValid("TWELVE_RADIUS", $no, "<span class=''>范围要小于七级风圈半径!</span>", false);
- }else{
- appendValid("TWELVE_RADIUS", $ok, "", true);
- };
- //校验是否为正实数
- var obj = $("#TWELVE_RADIUS").val();
- if(!reg.test(obj)){
- appendValid("TWELVE_RADIUS", $no, "<span class=''>请输入数字!</span>", false);
- return false ;
- } else {
- appendValid("TWELVE_RADIUS", $ok, "", true);
- };
- }
- }else{//十级不为空
-
- //校验是否为正实数
- var obj = $("#TEN_RADIUS").val();
- if(!reg.test(obj)){
- appendValid("TEN_RADIUS", $no, "<span class=''>请输入数字!</span>", false);
- return false ;
- } else {
- appendValid("TEN_RADIUS", $ok, "", true);
- };
-
- if(valIsValid(ten)){//十级为可用范围
-
- if(Number(ten) >= Number(sev)){//十级大于等于七级
- appendValid("TEN_RADIUS", $no, "<span class=''>范围要小于七级风圈半径!</span>", false);
- }else{
- appendValid("TEN_RADIUS", $ok, "", true);
- }
-
- //判断十二级是否为空
- if(valIsNull(twev)){//十二级为空
- appendValid("TWELVE_RADIUS", "", "", true);
- }else{//十二级不为空
- if(Number(twev) >= Number(ten)){//十二级大于等于十级
- appendValid("TWELVE_RADIUS", $no, "<span class=''>范围要小于十级风圈半径!</span>", false);
- }else{
- //校验是否为正实数
- var obj = $("#TWELVE_RADIUS").val();
- if(!reg.test(obj)){
- appendValid("TWELVE_RADIUS", $no, "<span class=''>请输入数字!</span>", false);
- return false ;
- } else {
- appendValid("TWELVE_RADIUS", $ok, "", true);
- };
- };
- }
- }else{//十级为不可用范围
- appendValid("TEN_RADIUS", $no, "<span class=''>请输入合理的风圈半径!</span>", false);
-
- }
- }
-
- });
-
-
- //十二级风圈离开焦点校验
- $("#TWELVE_RADIUS").on("blur",function(){
- var ten = $("#TEN_RADIUS").val() ; //十级风圈
- var twev = $("#TWELVE_RADIUS").val() ;//十二级风圈
-
- //判断十二级风圈是否输入数据
- if(valIsNull(twev)){//十二级为空
- appendValid("TWELVE_RADIUS", "", "", true);
-
- }else{//十二级不为空
-
- //校验是否为正实数
- var obj = $("#TWELVE_RADIUS").val();
- if(!reg.test(obj)){
- appendValid("TWELVE_RADIUS", $no, "<span class=''>请输入数字!</span>", false);
- return false ;
- } else {
- //判断十二级是否可用
- if(valIsValid(twev)){//可用范围
- if(Number(twev) >= Number(ten)){//十二级大于等于十级
- appendValid("TWELVE_RADIUS", $no, "<span class=''>范围要小于十级风圈半径!</span>", false);
- return false ;
- }else{
- appendValid("TWELVE_RADIUS", $ok, "", true);
- };
- }else{//不可用
- appendValid("TWELVE_RADIUS", $no, "<span class=''>请输入合理的风圈半径!</span>", false);
- return false ;
- };
- };
-
-
- };
- });
-
-
- //最大风力离开焦点校验
- $("#MAX_STRENGTH").on("blur",function(){
-
- var obj = $("#MAX_STRENGTH").val();
-
- if(valIsNull(obj)){//为空
- appendValid("MAX_STRENGTH", "", "", true);
-
- }else{//不为空
- //校验是否为正实数
- if(!reg.test(obj)){
- appendValid("MAX_STRENGTH", $no, "<span class=''>请输入数字!</span>", false);
- return false ;
- } else {
- appendValid("MAX_STRENGTH", $ok, "", true);
- };
- }
- });
-
- //最大风速离开焦点校验
- $("#MAX_SPEED").on("blur",function(){
- var obj = $("#MAX_SPEED").val();
- if(valIsNull(obj)){//为空
- appendValid("MAX_SPEED", "", "", true);
-
- }else{//不为空
- //校验是否为正实数
- if(!reg.test(obj)){
- appendValid("MAX_SPEED", $no, "<span class=''>请输入数字!</span>", false);
- return false ;
- } else {
- appendValid("MAX_SPEED", $ok, "", true);
- };
- }
- });
-
- //移动速度离开焦点校验
- $("#MOVEMENT_SPEED").on("blur",function(){
- var obj = $("#MOVEMENT_SPEED").val();
- if(valIsNull(obj)){//为空
-
- appendValid("MOVEMENT_SPEED", "", "", true);
-
- }else{//不为空
- if(!reg.test(obj)){
- appendValid("MOVEMENT_SPEED", $no, "<span class=''>请输入数字!</span>", false);
- return false ;
- } else {
- appendValid("MOVEMENT_SPEED", $ok, "", true);
- };
- }
- });
-
- //中心气压离开焦点校验
- $("#CENTRAL_PRESSURE").on("blur",function(){
- var obj = $("#CENTRAL_PRESSURE").val();
-
- if(valIsNull(obj)){//为空
-
- appendValid("CENTRAL_PRESSURE", "", "", true);
-
- }else{//不为空
-
- if(!reg.test(obj)){
- appendValid("CENTRAL_PRESSURE", $no, "<span class=''>请输入数字!</span>", false);
- return false ;
- } else {
- appendValid("CENTRAL_PRESSURE", $ok, "", true);
- };
- }
- });
-
- });
- /**
- * 按钮初始化
- */
- $(function(){
-
- //重取位置
- $("#reset_draw").click(function(){
- window.parent.window.resample();
- });
-
- //放弃绘制
- $("#giveup_draw").click(function(){
- if(window.confirm('你确定要放弃绘制吗?\n点击确定将会放弃\"' + parent.document.getElementById("TYPHOON_NAME_CH").value + '\"模拟台风添加的所有模拟点。')){
- window.parent.window.giveUpCurrent();
- return true;
- }else{
- return false;
- }
- });
-
- //继续绘制按钮
- $("#go_draw").click(function(){
- if(validation()){
- var param = $("form").serializeArray();
- param = serializeArrayToJson(param);
- window.parent.window.iframeGetPoint(param);
- window.parent.window.removeDrawWin();
- } else {
- alert("页面填写有误!");
- };
-
-
- });
-
- //结束绘制按钮
- $("#over_draw").click(function(){
-
- if(validation()){
- var param = $("form").serializeArray();
- param = serializeArrayToJson(param);
- window.parent.window.overDraw(param);
- window.parent.window.removeDrawWin();
- }else{
- alert("页面填写有误!");
- }
- });
- });
- /**
- * 将表单序列化的数组JSON变成JSON格式
- * @param seriArr
- * @returns {___anonymous8892_8893}
- */
- function serializeArrayToJson(seriArr){
- var res = {};
- var temp = {};
- var name = "" ;
- for(var key in seriArr){
- temp = seriArr[key];
- name = temp["name"];
- res[name] = temp["value"];
- };
- return res;
- };
- /**
- * 校验页面是否有不可法参数
- * @returns {Boolean}
- */
- function validation(){
- var flg = true ;
- $("input[valida='false']").each(function(i){
- flg = false ;
- });
- return flg ;
- };
- /**
- * 判断数据是否为空
- * @param data
- * @returns {Boolean} true:空 false:非空
- */
- function valIsNull(data){
- if(data == "" || data == undefined || data == null){
- return true;
- }
- return false;
- };
- /**
- * 判断数据是否为有效的,0-10000之间
- * @param data
- * @returns {Boolean}
- */
- function valIsValid(data){
- if(valIsNull(data)){
- return true;
- }else if(Number(data)<=0 || Number(data)>10000){
- return false ;
- };
- return true ;
- };
- /**
- * 清除七级风圈与十二级风圈内容
- */
- function clearValid(){
- if(!$("._typhoon_disa").hasClass("_no_drop")){
- $("._typhoon_disa").addClass("_no_drop");
- $("._typhoon_disa").attr("disabled","disabled");
- $("#TEN_RADIUS").val("");
- $("#TEN_RADIUS").attr("valida", true);
- $("#TWELVE_RADIUS").val("");
- $("#TWELVE_RADIUS").attr("valida", true);
- $(".TEN_RADIUS").empty();
- $(".TWELVE_RADIUS").empty();
- }
- };
- /**
- * 添加校验结果内容
- * @param id 要添加的class名称
- * @param $img 校验结果图片
- * @param $info 校验文字信息
- */
- function appendValid(id, $img, $info, flg){
- $("." + id).empty();
- $("." + id).append($img);
- $("." + id).append($info);
- $("#" + id).attr("valida", flg);
- };
- function valTewnt(){
- var data = $("#SEVEN_RADIUS").val() ;
- var twev = $("#TWELVE_RADIUS").val() ;
- var ten = $("#TEN_RADIUS").val() ;
-
- var $no = "<img src='/nwyj/images/cockpit/btn/no.png'>" ;
- var $ok = "<img src='/nwyj/images/cockpit/btn/ok.png'>" ;
-
- var reg = new RegExp("^([0-9]+(.[0-9]{1,5})?)?$");
-
- //判断十二级是否为空
- if(!valIsNull(twev)){//不为空
- //校验十二级风圈是否为正实数
- obj = $("#TWELVE_RADIUS").val();
- if(!reg.test(obj)){
- appendValid("TWELVE_RADIUS", $no, "<span class=''>请输入数字!</span>", false);
- return false ;
- }
-
- if(valIsValid(twev)){//十二级为可用范围
-
- if(!valIsNull(ten)){//判断十级是否为空
- if(Number(twev) >= Number(ten)){//十二级大于等于十级
- appendValid("TWELVE_RADIUS", $no, "<span class=''>范围要小于十级风圈半径!</span>", false);
- }else{
- appendValid("TWELVE_RADIUS", $ok, "", true);
- };
- }else{//十级为空,校验七级
- if(Number(twev) >= Number(data)){//十二级大于等于七级
- appendValid("TWELVE_RADIUS", $no, "<span class=''>范围要小于七级风圈半径!</span>", false);
- }else{
- appendValid("TWELVE_RADIUS", $ok, "", true);
- };
- };
- }else{//不可用范围
- appendValid("TWELVE_RADIUS", $no, "<span class=''>请输入合理的风圈半径!</span>", false);
- };
- }else{//为空
- appendValid("TWELVE_RADIUS", "", "", true);
- };
- };
-
|