-/*
- * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Author: Zhaoxing Meng
- * email: meng.zhaoxing1@zte.com.cn
- */
-$(function(){
-
- $('#msbTable tbody').on('click', 'td.details-control', function () {
- var tr = $(this).closest('tr');
- var row = table.row( tr );
- if ( row.child.isShown() ) {
- // This row is already open - close it
- row.child.hide();
- tr.removeClass('shown');
- }
- else {
- // Open this row
- var nodes=row.data()[1].match(/\d+.\d+.\d+.\d+:\d+:(-)?\d+/g)
-
- row.child( routeUtil.formatDetail(nodes) ).show();
- tr.addClass('shown');
- }
- } );
-
- $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
- //Get the name of the TAB has been activated
- var activeTab = $(e.target).text();
- if(this.id=="customTab" || this.id=="msbTab"){
- $("#serviceContent").hide();
- $("#upArrawDiv").hide();
- }
- else{
- $("#serviceContent").show();
- $("#upArrawDiv").show();
- $('#msbSubPage').attr("src","");
- $(".stats_box .routeDiv").removeClass("active");
- vm.selectedRouteType="";
- vm.routeTargetTitle=$.i18n.prop("org_openo_msb_route_content_title");
-
- }
- });
-
-
- $("[data-toggle='tooltip']").tooltip();
-
- $('#metricsFullurl').on('show.bs.collapse', function () {
- $('#metricsUrlCollapse').removeClass('fa-plus').addClass('fa-minus');
-
- });
-
- $('#metricsFullurl').on('hide.bs.collapse', function () {
- $('#metricsUrlCollapse').removeClass('fa-minus').addClass('fa-plus');
- });
-
- $('#apiJsonFullurl').on('show.bs.collapse', function () {
- $('#apiJsonCollapse').removeClass('fa-plus').addClass('fa-minus');
-
- });
-
- $('#apiJsonFullurl').on('hide.bs.collapse', function () {
- $('#apiJsonCollapse').removeClass('fa-minus').addClass('fa-plus');
- });
-
-
-
- $(".form-tip").blur(function(){
- if($.trim($(this).val())==""){
- $(this).removeClass("form-input-focus");
- $(this).prev().removeClass("item-tip-focus");
- }});
-
-$(".form-tip").focus(function(){
- if(!$(this).hasClass("form-input-focus")){
- $(this).addClass("form-input-focus");
- $(this).prev().addClass("item-tip-focus");
- }});
-
-$(".item-tip").click(function(){
- $(this).next().focus();
-});
-
-
-
-$("input[name='version']").blur(function(){
- $(this).val($(this).val().toLowerCase());
- routeUtil.changeTargetServiceUrl();
-});
-
-
-$("input[name='url']").blur(function(){
-
-routeUtil.changeTargetServiceUrl();
-
-});
-$("input[name='serviceName']").blur(function(){
-
-routeUtil.changeTargetServiceUrl();
-
-});
-
-
-
-$("select[name='protocol']").change(function(){
-
-routeUtil.changeTargetServiceUrl();
-
-});
-
-/*
-
-$("input[name='oriService']").blur(function(){
- var oriService=$.trim($(this).val());
- if(oriService==""){
- $("input[name='serviceName']").val("");
- $("input[name='version']").val("");
- $("input[name='server']").val("");
- $("input[name='url']").val("");
- return;
- }
-
-
-
- var reg=/^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/
- var reg_standard_match=/^(.*:\d{1,5})\/api\/(.*)\/(v.*)$/
- var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/
- if(reg.test(oriService)){
- if(reg_standard_match.test(oriService)){
- //标准api
- var group = oriService.match(reg_standard_match);
- $("input[name='serviceName']").val(group[2]);
- $("input[name='server']").val(group[1].replace("http://",""));
-
-
- var version=group[3];
- var reg_endName_match=/^(.*?)\/.*$/
- if(reg_endName_match.test(version)){
- version = version.match(reg_endName_match)[1];
- }
- $("input[name='version']").val(version);
- $("input[name='url']").val("/api/"+group[2]+"/"+version);
-
- if(!$("input[name='version']").hasClass("form-input-focus")){
- $("input[name='version']").addClass("form-input-focus");
- $("input[name='version']").prev().addClass("item-tip-focus");
- }
-
-
-
- }
- else{
- //非标准api
- var group = oriService.match(reg_unstandard_match);
- var reg_endName_match=/^(.*?)\/$/
- var url=group[2];
- if(url!="/" && reg_endName_match.test(url)){
- url = url.match(reg_endName_match)[1];
- }
-
-
- $("input[name='serviceName']").val("");
- $("input[name='version']").val("");
- $("input[name='server']").val(group[1].replace("http://",""));
- $("input[name='url']").val(url);
- }
-
- if(!$("input[name='server']").hasClass("form-input-focus")){
- $("input[name='server']").addClass("form-input-focus");
- $("input[name='server']").prev().addClass("item-tip-focus");
- }
- }
-
-
-});
-
-
-$("input[name='iuioriService']").blur(function(){
- var oriService=$.trim($(this).val());
- if(oriService==""){
- $("input[name='iuiserviceName']").val("");
- $("input[name='iuiserver']").val("");
- $("input[name='iuiurl']").val("");
- return;
- }
-
-
-
- var reg=/^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/
- var reg_standard_match=/^(.*:\d{1,5})\/iui\/(.*|.*\/)$/
- var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/
- if(reg.test(oriService)){
- if(reg_standard_match.test(oriService)){
- //标准api
- var group = oriService.match(reg_standard_match);
-
-
- $("input[name='iuiserver']").val(group[1].replace("http://",""));
-
-
- var serviceName=group[2];
- var reg_endName_match=/^(.*?)\/.*$/
- if(reg_endName_match.test(serviceName)){
- serviceName = serviceName.match(reg_endName_match)[1];
- }
- $("input[name='iuiserviceName']").val(serviceName);
- $("input[name='iuiurl']").val("/iui/"+serviceName);
-
- }
- else{
- //非标准api
- var group = oriService.match(reg_unstandard_match);
-
- var reg_endName_match=/^(.*?)\/$/
- var url=group[2];
- if(url!="/" && reg_endName_match.test(url)){
- url = url.match(reg_endName_match)[1];
- }
- $("input[name='iuiserver']").val(group[1].replace("http://",""));
- $("input[name='iuiurl']").val(url);
- }
-
- if(!$("input[name='iuiserver']").hasClass("form-input-focus")){
- $("input[name='iuiserver']").addClass("form-input-focus");
- $("input[name='iuiserver']").prev().addClass("item-tip-focus");
- }
- }
-
-
-});
-
-$("input[name='customoriService']").blur(function(){
- var oriService=$.trim($(this).val());
- if(oriService==""){
- $("input[name='customserviceName']").val("");
- $("input[name='customserver']").val("");
- $("input[name='customurl']").val("");
- return;
- }
-
-
-
- var reg=/^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/
-
- var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/
- if(reg.test(oriService)){
-
-
- var group = oriService.match(reg_unstandard_match);
-
- var reg_endName_match=/^(.*?)\/$/
- var url=group[2];
- if(url!="/" && reg_endName_match.test(url)){
- url = url.match(reg_endName_match)[1];
- }
- $("input[name='customserver']").val(group[1].replace("http://",""));
- $("input[name='customurl']").val(url);
- $("input[name='customserviceName']").val(url);
-
-
- if(!$("input[name='customserver']").hasClass("form-input-focus")){
- $("input[name='customserver']").addClass("form-input-focus");
- $("input[name='customserver']").prev().addClass("item-tip-focus");
- }
- }
-
-
-});
-
-*/
-
- jQuery.validator.addMethod("ip", function(value, element) {
- return this.optional(element) || /^(([-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})$/.test(value);
- }, $.i18n.prop('org_openo_msb_route_validator_ip_format'));
-
-
-
- jQuery.validator.addMethod("url_head", function(value, element) {
- return this.optional(element) || /^\/.+((?!\/).)$/i.test(value) || /^\/$/i.test(value);
- }, $.i18n.prop('org_openo_msb_route_validator_url_head_format'));
-
-
-jQuery.validator.addMethod("url_head_only", function(value, element) {
- return this.optional(element) || /^\/.*$/i.test(value);
- }, $.i18n.prop('org_openo_msb_route_validator_url_head_only_format'));
-
- jQuery.validator.addMethod("version", function(value, element) {
- return this.optional(element) || /^v\d+(\.\d+)?$/i.test(value);
- }, $.i18n.prop('org_openo_msb_route_form_version_tip'));
-
- jQuery.validator.addMethod("service_url", function(value, element) {
- return this.optional(element) || /^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/.test(value);
- }, $.i18n.prop('org_openo_msb_route_validator_url_format'));
-
- jQuery.validator.addMethod("url_line", function(value, element) {
- return this.optional(element) || /^((?!\/).)*$/.test(value);
- }, $.i18n.prop('org_openo_msb_route_validator_url_line_format'));
-
- jQuery.validator.addMethod("content", function(value, element) {
- return this.optional(element) || /^([0-9a-zA-Z]|-|_)*$/i.test(value);
- }, $.i18n.prop('org_openo_msb_route_validator_content_format'));
-
- jQuery.validator.addMethod("custom_content", function(value, element) {
- return this.optional(element) || /^([0-9a-zA-Z]|-|_|\/)*$/i.test(value);
- }, $.i18n.prop('org_openo_msb_route_validator_content_format'));
-
-
- });
-
- var form = $('#routeForm');
- var error = $('.alert-danger', form);
- var success = $('.alert-success', form);
-
- var iuiform = $('#iuirouteForm');
- var iuierror = $('.alert-danger', iuiform);
- var iuisuccess = $('.alert-success', iuiform);
-
-
- var customform = $('#customrouteForm');
- var customerror = $('.alert-danger', customform);
- var customsuccess = $('.alert-success', customform);
-
- var msbform = $('#msbForm');
- var msberror = $('.alert-danger', msbform);
- var msbsuccess = $('.alert-success', msbform);
-
-
- form.validate({
- doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
- errorElement: 'span', //default input error message container
- errorClass: 'help-block', // default input error message class
- focusInvalid: false, // do not focus the last invalid input
- rules: {
- /* oriService:{
- service_url:true,
- maxlength:100
- },*/
- serviceName:{
- required: true,
- url_line:true,
- content:true,
- maxlength:50
- },
- version:{
- // required: true,
- maxlength:50,
- version:true
- },
- url:{
- required: true,
- url_head:true,
- maxlength:50
- },
- metricsUrl:{
- url_head:true,
- maxlength:50
- },
- server:{
- ip:true,
- maxlength:50
- }
- },
- messages: {
- serviceName:{
- required: "Please enter the service name"
- },
- url:{
- required: "Please enter the URL address"
-
- },
- server:{
- required:"Please enter the Host address"
-
- },
-
- },
- errorPlacement: function (error, element) { // render error placement for each input type
- error.insertAfter(element); // for other inputs, just perform default behavior
- },
-
- invalidHandler: function (event, validator) { //display error alert on form submit
- success.hide();
- error.show();
- //ZteFrameWork.scrollTo(error, -200);
- },
-
- highlight: function (element) { // hightlight error inputs
- $(element)
- .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
- },
-
- unhighlight: function (element) { // revert the change done by hightlight
- $(element)
- .closest('.form-group').removeClass('has-error'); // set error class to the control group
- },
-
- success: function (label) {
- label
- .addClass('valid') // mark the current input as valid and display OK icon
- .closest('.form-group').removeClass('has-error'); // set success class to the control group
- },
- submitHandler: function (form) {
- success.show();
- error.hide();
- //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
- }
-
- });
-
- iuiform.validate({
- doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
- errorElement: 'span', //default input error message container
- errorClass: 'help-block', // default input error message class
- focusInvalid: false, // do not focus the last invalid input
- rules: {
- /*iuioriService:{
- service_url:true,
- maxlength:100
- },*/
- iuiserviceName:{
- required: true,
- url_line:true,
- maxlength:50,
- content:true
- },
- iuiurl:{
- required: true,
- url_head:true,
- maxlength:50
- },
- iuiserver:{
- ip:true,
- maxlength:50
- }
- },
- messages: {
- iuiserviceName:{
- required: "Please enter the service name"
- },
- iuiurl:{
- required:"Please enter the URL address"
-
- },
- iuiserver:{
- required: "Please enter the Host address"
- },
-
- },
- errorPlacement: function (iuierror, element) { // render error placement for each input type
- iuierror.insertAfter(element); // for other inputs, just perform default behavior
- },
-
- invalidHandler: function (event, validator) { //display error alert on form submit
- iuisuccess.hide();
- iuierror.show();
- //ZteFrameWork.scrollTo(error, -200);
- },
-
- highlight: function (element) { // hightlight error inputs
- $(element)
- .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
- },
-
- unhighlight: function (element) { // revert the change done by hightlight
- $(element)
- .closest('.form-group').removeClass('has-error'); // set error class to the control group
- },
-
- success: function (label) {
- label
- .addClass('valid') // mark the current input as valid and display OK icon
- .closest('.form-group').removeClass('has-error'); // set success class to the control group
- },
- submitHandler: function (form) {
- iuisuccess.show();
- iuierror.hide();
- //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
- }
-
- });
-
- customform.validate({
- doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
- errorElement: 'span', //default input error message container
- errorClass: 'help-block', // default input error message class
- focusInvalid: false, // do not focus the last invalid input
- rules: {
- /*customoriService:{
- service_url:true,
- maxlength:100
- },*/
- customserviceName:{
- required: false,
- url_head:true,
- maxlength:100,
- custom_content:true
- },
- customurl:{
- required: true,
- url_head:true,
- maxlength:50
- },
- customserver:{
- ip:true,
- maxlength:50
- }
- },
- messages: {
- customserviceName:{
- required: "Please enter the service name"
- },
- customurl:{
- required: "Please enter the URL address"
-
- }
-
- },
- errorPlacement: function (customerror, element) { // render error placement for each input type
- customerror.insertAfter(element); // for other inputs, just perform default behavior
- },
-
- invalidHandler: function (event, validator) { //display error alert on form submit
- customsuccess.hide();
- customerror.show();
- //ZteFrameWork.scrollTo(error, -200);
- },
-
- highlight: function (element) { // hightlight error inputs
- $(element)
- .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
- },
-
- unhighlight: function (element) { // revert the change done by hightlight
- $(element)
- .closest('.form-group').removeClass('has-error'); // set error class to the control group
- },
-
- success: function (label) {
- label
- .addClass('valid') // mark the current input as valid and display OK icon
- .closest('.form-group').removeClass('has-error'); // set success class to the control group
- },
- submitHandler: function (form) {
- customsuccess.show();
- customerror.hide();
- //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
- }
-
- });
-
-
- msbform.validate({
- doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
- errorElement: 'span', //default input error message container
- errorClass: 'help-block', // default input error message class
- focusInvalid: false, // do not focus the last invalid input
- rules: {
-
- serviceName:{
- required: true,
- // url_line:true,
- custom_content:true,
- maxlength:50
- },
- version:{
- maxlength:50,
- version:true
- },
- url:{
- url_head:true,
- maxlength:50
- },
- newHost:{
- ip:true,
- maxlength:50
- },
- newttl:{
- digits:true,
- min:0
- },
- protocol:{
- required: true
- },
- type:{
- required: true
- }
- },
- messages: {
- serviceName:{
- required: "Please enter the service name"
- },
- protocol:{
- required: "Please select a service protocol"
- },
- type:{
- required: "Please select a service type"
-
- },
- newttl:{
- digits:"Please enter an integer",
- min: "Not a negative"
- }
-
- },
- errorPlacement: function (msberror, element) { // render error placement for each input type
- msberror.insertAfter(element); // for other inputs, just perform default behavior
- },
-
- invalidHandler: function (event, validator) { //display error alert on form submit
- msbsuccess.hide();
- msberror.show();
- //ZteFrameWork.scrollTo(error, -200);
- },
-
- highlight: function (element) { // hightlight error inputs
- $(element)
- .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
- },
-
- unhighlight: function (element) { // revert the change done by hightlight
- $(element)
- .closest('.form-group').removeClass('has-error'); // set error class to the control group
- },
-
- success: function (label) {
- label
- .addClass('valid') // mark the current input as valid and display OK icon
- .closest('.form-group').removeClass('has-error'); // set success class to the control group
- },
- submitHandler: function (form) {
- msbsuccess.show();
- msberror.hide();
- //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
- }
-
- });
-
-
+/*\r
+ * Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+$(function(){\r
+\r
+ $('#msbTable tbody').on('click', 'td.details-control', function () {\r
+ var tr = $(this).closest('tr');\r
+ var row = table.row( tr );\r
+ if ( row.child.isShown() ) {\r
+ // This row is already open - close it\r
+ row.child.hide();\r
+ tr.removeClass('shown');\r
+ }\r
+ else {\r
+ // Open this row\r
+ var nodes=row.data()[1].match(/\d+.\d+.\d+.\d+:\d+:(-)?\d+/g) \r
+ \r
+ row.child( routeUtil.formatDetail(nodes) ).show();\r
+ tr.addClass('shown');\r
+ }\r
+ } );\r
+\r
+ $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {\r
+ //Get the name of the TAB has been activated\r
+ var activeTab = $(e.target).text(); \r
+ if(this.id=="customTab" || this.id=="msbTab"){\r
+ $("#serviceContent").hide();\r
+ $("#upArrawDiv").hide();\r
+ }\r
+ else{\r
+ $("#serviceContent").show();\r
+ $("#upArrawDiv").show();\r
+ $('#msbSubPage').attr("src","");\r
+ $(".stats_box .routeDiv").removeClass("active");\r
+ vm.selectedRouteType="";\r
+ vm.routeTargetTitle=$.i18n.prop("org_onap_msb_route_content_title");\r
+ \r
+ }\r
+ });\r
+\r
+\r
+ $("[data-toggle='tooltip']").tooltip();\r
+\r
+ $('#metricsFullurl').on('show.bs.collapse', function () {\r
+ $('#metricsUrlCollapse').removeClass('fa-plus').addClass('fa-minus');\r
+ \r
+ });\r
+ \r
+ $('#metricsFullurl').on('hide.bs.collapse', function () {\r
+ $('#metricsUrlCollapse').removeClass('fa-minus').addClass('fa-plus');\r
+ });\r
+\r
+ $('#apiJsonFullurl').on('show.bs.collapse', function () {\r
+ $('#apiJsonCollapse').removeClass('fa-plus').addClass('fa-minus');\r
+ \r
+ });\r
+ \r
+ $('#apiJsonFullurl').on('hide.bs.collapse', function () {\r
+ $('#apiJsonCollapse').removeClass('fa-minus').addClass('fa-plus');\r
+ });\r
+\r
+\r
+\r
+ $(".form-tip").blur(function(){\r
+ if($.trim($(this).val())==""){\r
+ $(this).removeClass("form-input-focus");\r
+ $(this).prev().removeClass("item-tip-focus");\r
+ }});\r
+\r
+$(".form-tip").focus(function(){\r
+ if(!$(this).hasClass("form-input-focus")){\r
+ $(this).addClass("form-input-focus");\r
+ $(this).prev().addClass("item-tip-focus");\r
+ }});\r
+\r
+$(".item-tip").click(function(){\r
+ $(this).next().focus();\r
+});\r
+\r
+\r
+\r
+$("input[name='version']").blur(function(){\r
+ $(this).val($(this).val().toLowerCase());\r
+ routeUtil.changeTargetServiceUrl();\r
+});\r
+\r
+\r
+$("input[name='url']").blur(function(){\r
+\r
+routeUtil.changeTargetServiceUrl();\r
+\r
+});\r
+$("input[name='serviceName']").blur(function(){\r
+\r
+routeUtil.changeTargetServiceUrl();\r
+\r
+});\r
+\r
+\r
+\r
+$("select[name='protocol']").change(function(){\r
+\r
+routeUtil.changeTargetServiceUrl();\r
+\r
+});\r
+\r
+/*\r
+\r
+$("input[name='oriService']").blur(function(){\r
+ var oriService=$.trim($(this).val());\r
+ if(oriService==""){\r
+ $("input[name='serviceName']").val("");\r
+ $("input[name='version']").val("");\r
+ $("input[name='server']").val("");\r
+ $("input[name='url']").val("");\r
+ return;\r
+ }\r
+ \r
+ \r
+\r
+ var reg=/^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/ \r
+ var reg_standard_match=/^(.*:\d{1,5})\/api\/(.*)\/(v.*)$/ \r
+ var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/ \r
+ if(reg.test(oriService)){ \r
+ if(reg_standard_match.test(oriService)){ \r
+ //标准api\r
+ var group = oriService.match(reg_standard_match);\r
+ $("input[name='serviceName']").val(group[2]); \r
+ $("input[name='server']").val(group[1].replace("http://",""));\r
+\r
+\r
+ var version=group[3];\r
+ var reg_endName_match=/^(.*?)\/.*$/\r
+ if(reg_endName_match.test(version)){\r
+ version = version.match(reg_endName_match)[1];\r
+ }\r
+ $("input[name='version']").val(version);\r
+ $("input[name='url']").val("/api/"+group[2]+"/"+version);\r
+\r
+ if(!$("input[name='version']").hasClass("form-input-focus")){\r
+ $("input[name='version']").addClass("form-input-focus");\r
+ $("input[name='version']").prev().addClass("item-tip-focus");\r
+ }\r
+ \r
+ \r
+\r
+ }\r
+ else{\r
+ //非标准api\r
+ var group = oriService.match(reg_unstandard_match);\r
+ var reg_endName_match=/^(.*?)\/$/\r
+ var url=group[2];\r
+ if(url!="/" && reg_endName_match.test(url)){\r
+ url = url.match(reg_endName_match)[1];\r
+ }\r
+\r
+\r
+ $("input[name='serviceName']").val("");\r
+ $("input[name='version']").val("");\r
+ $("input[name='server']").val(group[1].replace("http://",""));\r
+ $("input[name='url']").val(url);\r
+ }\r
+\r
+ if(!$("input[name='server']").hasClass("form-input-focus")){\r
+ $("input[name='server']").addClass("form-input-focus");\r
+ $("input[name='server']").prev().addClass("item-tip-focus");\r
+ }\r
+ }\r
+ \r
+ \r
+});\r
+\r
+\r
+$("input[name='iuioriService']").blur(function(){\r
+ var oriService=$.trim($(this).val());\r
+ if(oriService==""){\r
+ $("input[name='iuiserviceName']").val("");\r
+ $("input[name='iuiserver']").val("");\r
+ $("input[name='iuiurl']").val("");\r
+ return;\r
+ }\r
+ \r
+ \r
+\r
+ var reg=/^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/ \r
+ var reg_standard_match=/^(.*:\d{1,5})\/iui\/(.*|.*\/)$/ \r
+ var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/ \r
+ if(reg.test(oriService)){ \r
+ if(reg_standard_match.test(oriService)){ \r
+ //标准api\r
+ var group = oriService.match(reg_standard_match);\r
+\r
+ \r
+ $("input[name='iuiserver']").val(group[1].replace("http://",""));\r
+ \r
+\r
+ var serviceName=group[2];\r
+ var reg_endName_match=/^(.*?)\/.*$/\r
+ if(reg_endName_match.test(serviceName)){\r
+ serviceName = serviceName.match(reg_endName_match)[1];\r
+ }\r
+ $("input[name='iuiserviceName']").val(serviceName);\r
+ $("input[name='iuiurl']").val("/iui/"+serviceName);\r
+ \r
+ }\r
+ else{\r
+ //非标准api\r
+ var group = oriService.match(reg_unstandard_match);\r
+ \r
+ var reg_endName_match=/^(.*?)\/$/\r
+ var url=group[2];\r
+ if(url!="/" && reg_endName_match.test(url)){\r
+ url = url.match(reg_endName_match)[1];\r
+ }\r
+ $("input[name='iuiserver']").val(group[1].replace("http://",""));\r
+ $("input[name='iuiurl']").val(url);\r
+ }\r
+\r
+ if(!$("input[name='iuiserver']").hasClass("form-input-focus")){\r
+ $("input[name='iuiserver']").addClass("form-input-focus");\r
+ $("input[name='iuiserver']").prev().addClass("item-tip-focus");\r
+ }\r
+ }\r
+ \r
+ \r
+});\r
+\r
+$("input[name='customoriService']").blur(function(){\r
+ var oriService=$.trim($(this).val());\r
+ if(oriService==""){\r
+ $("input[name='customserviceName']").val("");\r
+ $("input[name='customserver']").val("");\r
+ $("input[name='customurl']").val("");\r
+ return;\r
+ }\r
+ \r
+ \r
+\r
+ var reg=/^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/ \r
+ \r
+ var reg_unstandard_match=/^(.*:\d{1,5})(\/.*)$/ \r
+ if(reg.test(oriService)){ \r
+ \r
+\r
+ var group = oriService.match(reg_unstandard_match);\r
+ \r
+ var reg_endName_match=/^(.*?)\/$/\r
+ var url=group[2];\r
+ if(url!="/" && reg_endName_match.test(url)){\r
+ url = url.match(reg_endName_match)[1];\r
+ }\r
+ $("input[name='customserver']").val(group[1].replace("http://",""));\r
+ $("input[name='customurl']").val(url);\r
+ $("input[name='customserviceName']").val(url);\r
+ \r
+\r
+ if(!$("input[name='customserver']").hasClass("form-input-focus")){\r
+ $("input[name='customserver']").addClass("form-input-focus");\r
+ $("input[name='customserver']").prev().addClass("item-tip-focus");\r
+ }\r
+ }\r
+ \r
+ \r
+});\r
+\r
+*/\r
+\r
+ jQuery.validator.addMethod("ip", function(value, element) { \r
+ return this.optional(element) || /^(([-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})$/.test(value); \r
+ }, $.i18n.prop('org_onap_msb_route_validator_ip_format'));\r
+\r
+\r
+\r
+ jQuery.validator.addMethod("url_head", function(value, element) { \r
+ return this.optional(element) || /^\/.+((?!\/).)$/i.test(value) || /^\/$/i.test(value); \r
+ }, $.i18n.prop('org_onap_msb_route_validator_url_head_format'));\r
+\r
+\r
+jQuery.validator.addMethod("url_head_only", function(value, element) { \r
+ return this.optional(element) || /^\/.*$/i.test(value); \r
+ }, $.i18n.prop('org_onap_msb_route_validator_url_head_only_format'));\r
+ \r
+ jQuery.validator.addMethod("version", function(value, element) { \r
+ return this.optional(element) || /^v\d+(\.\d+)?$/i.test(value); \r
+ }, $.i18n.prop('org_onap_msb_route_form_version_tip'));\r
+\r
+ jQuery.validator.addMethod("service_url", function(value, element) { \r
+ return this.optional(element) || /^(|http:\/\/)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))):(\d{1,5})\/.*$/.test(value); \r
+ }, $.i18n.prop('org_onap_msb_route_validator_url_format'));\r
+\r
+ jQuery.validator.addMethod("url_line", function(value, element) { \r
+ return this.optional(element) || /^((?!\/).)*$/.test(value); \r
+ }, $.i18n.prop('org_onap_msb_route_validator_url_line_format'));\r
+\r
+ jQuery.validator.addMethod("content", function(value, element) { \r
+ return this.optional(element) || /^([0-9a-zA-Z]|-|_)*$/i.test(value); \r
+ }, $.i18n.prop('org_onap_msb_route_validator_content_format'));\r
+\r
+ jQuery.validator.addMethod("custom_content", function(value, element) { \r
+ return this.optional(element) || /^([0-9a-zA-Z]|-|_|\/)*$/i.test(value); \r
+ }, $.i18n.prop('org_onap_msb_route_validator_content_format'));\r
+\r
+\r
+ });\r
+\r
+ var form = $('#routeForm');\r
+ var error = $('.alert-danger', form);\r
+ var success = $('.alert-success', form);\r
+\r
+ var iuiform = $('#iuirouteForm');\r
+ var iuierror = $('.alert-danger', iuiform);\r
+ var iuisuccess = $('.alert-success', iuiform);\r
+\r
+\r
+ var customform = $('#customrouteForm');\r
+ var customerror = $('.alert-danger', customform);\r
+ var customsuccess = $('.alert-success', customform);\r
+\r
+ var msbform = $('#msbForm');\r
+ var msberror = $('.alert-danger', msbform);\r
+ var msbsuccess = $('.alert-success', msbform);\r
+\r
+\r
+ form.validate({\r
+ doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.\r
+ errorElement: 'span', //default input error message container\r
+ errorClass: 'help-block', // default input error message class\r
+ focusInvalid: false, // do not focus the last invalid input\r
+ rules: { \r
+ /* oriService:{\r
+ service_url:true,\r
+ maxlength:100\r
+ },*/\r
+ serviceName:{\r
+ required: true,\r
+ url_line:true,\r
+ content:true,\r
+ maxlength:50\r
+ },\r
+ version:{\r
+ // required: true,\r
+ maxlength:50,\r
+ version:true\r
+ },\r
+ url:{\r
+ required: true,\r
+ url_head:true,\r
+ maxlength:50\r
+ },\r
+ metricsUrl:{\r
+ url_head:true,\r
+ maxlength:50\r
+ },\r
+ server:{\r
+ ip:true,\r
+ maxlength:50\r
+ }\r
+ },\r
+ messages: { \r
+ serviceName:{\r
+ required: "Please enter the service name"\r
+ }, \r
+ url:{\r
+ required: "Please enter the URL address"\r
+ \r
+ }, \r
+ server:{\r
+ required:"Please enter the Host address"\r
+ \r
+ }\r
+\r
+ },\r
+ errorPlacement: function (error, element) { // render error placement for each input type\r
+ error.insertAfter(element); // for other inputs, just perform default behavior\r
+ },\r
+\r
+ invalidHandler: function (event, validator) { //display error alert on form submit \r
+ success.hide();\r
+ error.show();\r
+ //ZteFrameWork.scrollTo(error, -200);\r
+ },\r
+\r
+ highlight: function (element) { // hightlight error inputs\r
+ $(element)\r
+ .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group\r
+ },\r
+\r
+ unhighlight: function (element) { // revert the change done by hightlight\r
+ $(element)\r
+ .closest('.form-group').removeClass('has-error'); // set error class to the control group\r
+ },\r
+\r
+ success: function (label) {\r
+ label\r
+ .addClass('valid') // mark the current input as valid and display OK icon\r
+ .closest('.form-group').removeClass('has-error'); // set success class to the control group\r
+ },\r
+ submitHandler: function (form) {\r
+ success.show();\r
+ error.hide();\r
+ //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax\r
+ }\r
+\r
+ });\r
+\r
+ iuiform.validate({\r
+ doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.\r
+ errorElement: 'span', //default input error message container\r
+ errorClass: 'help-block', // default input error message class\r
+ focusInvalid: false, // do not focus the last invalid input\r
+ rules: { \r
+ /*iuioriService:{\r
+ service_url:true,\r
+ maxlength:100\r
+ },*/\r
+ iuiserviceName:{\r
+ required: true,\r
+ url_line:true,\r
+ maxlength:50,\r
+ content:true\r
+ }, \r
+ iuiurl:{\r
+ required: true,\r
+ url_head:true,\r
+ maxlength:50\r
+ },\r
+ iuiserver:{\r
+ ip:true,\r
+ maxlength:50\r
+ }\r
+ },\r
+ messages: { \r
+ iuiserviceName:{\r
+ required: "Please enter the service name"\r
+ },\r
+ iuiurl:{\r
+ required:"Please enter the URL address"\r
+ \r
+ },\r
+ iuiserver:{\r
+ required: "Please enter the Host address"\r
+ }\r
+ },\r
+ errorPlacement: function (iuierror, element) { // render error placement for each input type\r
+ iuierror.insertAfter(element); // for other inputs, just perform default behavior\r
+ },\r
+\r
+ invalidHandler: function (event, validator) { //display error alert on form submit \r
+ iuisuccess.hide();\r
+ iuierror.show();\r
+ //ZteFrameWork.scrollTo(error, -200);\r
+ },\r
+\r
+ highlight: function (element) { // hightlight error inputs\r
+ $(element)\r
+ .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group\r
+ },\r
+\r
+ unhighlight: function (element) { // revert the change done by hightlight\r
+ $(element)\r
+ .closest('.form-group').removeClass('has-error'); // set error class to the control group\r
+ },\r
+\r
+ success: function (label) {\r
+ label\r
+ .addClass('valid') // mark the current input as valid and display OK icon\r
+ .closest('.form-group').removeClass('has-error'); // set success class to the control group\r
+ },\r
+ submitHandler: function (form) {\r
+ iuisuccess.show();\r
+ iuierror.hide();\r
+ //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax\r
+ }\r
+\r
+ });\r
+\r
+ customform.validate({\r
+ doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.\r
+ errorElement: 'span', //default input error message container\r
+ errorClass: 'help-block', // default input error message class\r
+ focusInvalid: false, // do not focus the last invalid input\r
+ rules: { \r
+ /*customoriService:{\r
+ service_url:true,\r
+ maxlength:100\r
+ },*/\r
+ customserviceName:{\r
+ required: false,\r
+ url_head:true,\r
+ maxlength:100,\r
+ custom_content:true\r
+ }, \r
+ customurl:{\r
+ required: true,\r
+ url_head:true,\r
+ maxlength:50\r
+ },\r
+ customserver:{\r
+ ip:true,\r
+ maxlength:50\r
+ }\r
+ },\r
+ messages: { \r
+ customserviceName:{\r
+ required: "Please enter the service name"\r
+ }, \r
+ customurl:{\r
+ required: "Please enter the URL address"\r
+ \r
+ }\r
+\r
+ },\r
+ errorPlacement: function (customerror, element) { // render error placement for each input type\r
+ customerror.insertAfter(element); // for other inputs, just perform default behavior\r
+ },\r
+\r
+ invalidHandler: function (event, validator) { //display error alert on form submit \r
+ customsuccess.hide();\r
+ customerror.show();\r
+ //ZteFrameWork.scrollTo(error, -200);\r
+ },\r
+\r
+ highlight: function (element) { // hightlight error inputs\r
+ $(element)\r
+ .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group\r
+ },\r
+\r
+ unhighlight: function (element) { // revert the change done by hightlight\r
+ $(element)\r
+ .closest('.form-group').removeClass('has-error'); // set error class to the control group\r
+ },\r
+\r
+ success: function (label) {\r
+ label\r
+ .addClass('valid') // mark the current input as valid and display OK icon\r
+ .closest('.form-group').removeClass('has-error'); // set success class to the control group\r
+ },\r
+ submitHandler: function (form) {\r
+ customsuccess.show();\r
+ customerror.hide();\r
+ //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax\r
+ }\r
+\r
+ });\r
+\r
+\r
+ msbform.validate({\r
+ doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.\r
+ errorElement: 'span', //default input error message container\r
+ errorClass: 'help-block', // default input error message class\r
+ focusInvalid: false, // do not focus the last invalid input\r
+ rules: { \r
+ \r
+ serviceName:{\r
+ required: true,\r
+ // url_line:true,\r
+ custom_content:true,\r
+ maxlength:50\r
+ },\r
+ version:{\r
+ maxlength:50,\r
+ version:true\r
+ },\r
+ url:{\r
+ url_head:true,\r
+ maxlength:50\r
+ },\r
+ newHost:{\r
+ ip:true,\r
+ maxlength:50\r
+ },\r
+ newttl:{\r
+ digits:true,\r
+ min:0\r
+ },\r
+ protocol:{\r
+ required: true\r
+ },\r
+ type:{\r
+ required: true\r
+ }\r
+ },\r
+ messages: { \r
+ serviceName:{\r
+ required: "Please enter the service name"\r
+ },\r
+ protocol:{\r
+ required: "Please select a service protocol"\r
+ }, \r
+ type:{\r
+ required: "Please select a service type"\r
+ \r
+ },\r
+ newttl:{\r
+ digits:"Please enter an integer",\r
+ min: "Not a negative" \r
+ }\r
+\r
+ },\r
+ errorPlacement: function (msberror, element) { // render error placement for each input type\r
+ msberror.insertAfter(element); // for other inputs, just perform default behavior\r
+ },\r
+\r
+ invalidHandler: function (event, validator) { //display error alert on form submit \r
+ msbsuccess.hide();\r
+ msberror.show();\r
+ //ZteFrameWork.scrollTo(error, -200);\r
+ },\r
+\r
+ highlight: function (element) { // hightlight error inputs\r
+ $(element)\r
+ .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group\r
+ },\r
+\r
+ unhighlight: function (element) { // revert the change done by hightlight\r
+ $(element)\r
+ .closest('.form-group').removeClass('has-error'); // set error class to the control group\r
+ },\r
+\r
+ success: function (label) {\r
+ label\r
+ .addClass('valid') // mark the current input as valid and display OK icon\r
+ .closest('.form-group').removeClass('has-error'); // set success class to the control group\r
+ },\r
+ submitHandler: function (form) {\r
+ msbsuccess.show();\r
+ msberror.hide();\r
+ //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax\r
+ }\r
+\r
+ });\r
+\r
+\r