2 * Copyright 2016 ZTE, Inc. and others.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
19 $(".form-tip").blur(function(){
\r
20 if($.trim($(this).val())==""){
\r
21 $(this).removeClass("form-input-focus");
\r
22 $(this).prev().removeClass("item-tip-focus");
\r
25 $(".form-tip").focus(function(){
\r
26 if(!$(this).hasClass("form-input-focus")){
\r
27 $(this).addClass("form-input-focus");
\r
28 $(this).prev().addClass("item-tip-focus");
\r
31 $(".item-tip").click(function(){
\r
32 $(this).next().focus();
\r
35 $("input[name='version']").blur(function(){
\r
36 $(this).val($(this).val().toLowerCase());
\r
38 if(vm.msbRouteInfo.protocol=='REST' || vm.msbRouteInfo.protocol=='HTTP' ){
\r
39 routeUtil.changeTargetServiceUrl();
\r
45 $("input[name='serviceName']").change(function(){
\r
46 if(vm.msbRouteInfo.protocol=='REST' || vm.msbRouteInfo.protocol=='UI' || vm.msbRouteInfo.protocol=='HTTP'){
\r
47 routeUtil.changeTargetServiceUrl();
\r
52 $("input[name='url']").change(function(){
\r
54 routeUtil.changeTargetServiceUrl();
\r
59 $("select[name='protocol']").change(function(){
\r
61 routeUtil.changeTargetServiceUrl();
\r
65 $("input[name='chkVisualRange']").change(function(){
\r
67 routeUtil.changeTargetServiceUrl();
\r
71 $("input[name='publish_port']").change(function(){
\r
73 routeUtil.changeTargetServiceUrl();
\r
77 $("input[name='http_publish_port']").change(function(){
\r
79 routeUtil.changeTargetServiceUrl();
\r
83 $("input[name='networkPlaneType']").change(function(){
\r
85 routeUtil.changeTargetServiceUrl();
\r
89 $("#labels").change(function(){
\r
91 routeUtil.changeTargetServiceUrl();
\r
97 $("input[name='host']").change(function(){
\r
99 routeUtil.changeTargetServiceUrl();
\r
103 $("input[name='path']").change(function(){
\r
105 routeUtil.changeTargetServiceUrl();
\r
110 $("input[name='namespace']").change(function(){
\r
112 vm.getApigatewayInfo($(this).val());
\r
119 jQuery.validator.addMethod("ip", function(value, element) {
\r
120 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])))$/.test(value);
\r
121 }, $.i18n.prop("org_onap_msb_discover_validator_ip_format"));
\r
125 jQuery.validator.addMethod("url_head", function(value, element) {
\r
126 return this.optional(element) || /^\/.+((?!\/).)$/i.test(value) || /^\/$/i.test(value);
\r
127 }, $.i18n.prop("org_onap_msb_discover_validator_url_head_format"));
\r
130 jQuery.validator.addMethod("url_head_only", function(value, element) {
\r
131 return this.optional(element) || /^\/.*$/i.test(value);
\r
132 }, $.i18n.prop("org_onap_msb_discover_validator_url_head_only_format"));
\r
134 jQuery.validator.addMethod("version", function(value, element) {
\r
135 return this.optional(element) || /^v\d+(\.\d+)?$/i.test(value);
\r
136 }, $.i18n.prop("org_onap_msb_discover_form_version_tip"));
\r
138 jQuery.validator.addMethod("service_url", function(value, element) {
\r
139 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
140 }, $.i18n.prop("org_onap_msb_discover_validator_url_format"));
\r
142 jQuery.validator.addMethod("url_line", function(value, element) {
\r
143 return this.optional(element) || /^((?!\/).)*$/.test(value);
\r
144 }, $.i18n.prop("org_onap_msb_discover_validator_url_line_format"));
\r
146 jQuery.validator.addMethod("content", function(value, element) {
\r
147 return this.optional(element) || /^([0-9a-zA-Z]|-|_)*$/i.test(value);
\r
148 }, $.i18n.prop("org_onap_msb_discover_validator_content_format"));
\r
150 jQuery.validator.addMethod("custom_content", function(value, element) {
\r
151 return this.optional(element) || /^([0-9a-zA-Z]|-|_|\/)*$/i.test(value);
\r
152 }, $.i18n.prop("org_onap_msb_discover_validator_content_format"));
\r
154 jQuery.validator.addMethod("http_publish_port_content", function(value, element) {
\r
155 return this.optional(element) || /^([0-9]|\|)*$/i.test(value);
\r
156 }, $.i18n.prop("org_onap_msb_discover_validator_publish_port_format"));
\r
163 var msbform = $('#msbForm');
\r
164 var msberror = $('.alert-danger', msbform);
\r
165 var msbsuccess = $('.alert-success', msbform);
\r
169 doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
\r
170 errorElement: 'span', //default input error message container
\r
171 errorClass: 'help-block', // default input error message class
\r
172 focusInvalid: false, // do not focus the last invalid input
\r
200 http_publish_port:{
\r
201 http_publish_port_content:true
\r
222 required: "Please enter the service name"
\r
225 required:"Please select a service protocol"
\r
229 required:"Please select the service visibleRange"
\r
233 digits:"Please enter a number",
\r
234 min: "number must be > 0"
\r
237 digits:"Please enter a number"
\r
241 errorPlacement: function (msberror, element) { // render error placement for each input type
\r
242 msberror.insertAfter(element); // for other inputs, just perform default behavior
\r
245 invalidHandler: function (event, validator) { //display error alert on form submit
\r
248 //ZteFrameWork.scrollTo(error, -200);
\r
251 highlight: function (element) { // hightlight error inputs
\r
253 .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
\r
256 unhighlight: function (element) { // revert the change done by hightlight
\r
258 .closest('.form-group').removeClass('has-error'); // set error class to the control group
\r
261 success: function (label) {
\r
263 .addClass('valid') // mark the current input as valid and display OK icon
\r
264 .closest('.form-group').removeClass('has-error'); // set success class to the control group
\r
266 submitHandler: function (form) {
\r
269 //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
\r
275 var nodeform = $('#nodeForm');
\r
276 var nodeerror = $('.alert-danger', nodeform);
\r
277 var nodesuccess = $('.alert-success', nodeform);
\r
280 nodeform.validate({
\r
281 doNotHideMessage: true, //this option enables to show the error/success messages on tab switch.
\r
282 errorElement: 'span', //default input error message container
\r
283 errorClass: 'help-block', // default input error message class
\r
284 focusInvalid: false, // do not focus the last invalid input
\r
303 nodeInfo_max_fails:{
\r
308 nodeInfo_fail_timeout:{
\r
330 required:"Please enter the Host IP"
\r
333 required: "Please enter the Host Port",
\r
334 digits:"Please enter a number",
\r
335 min: "number must be > 1"
\r
341 nodeInfo_max_fails:{
\r
345 nodeInfo_fail_timeout:{
\r
365 errorPlacement: function (nodeerror, element) { // render error placement for each input type
\r
366 nodeerror.insertAfter(element); // for other inputs, just perform default behavior
\r
369 invalidHandler: function (event, validator) { //display error alert on form submit
\r
370 nodesuccess.hide();
\r
372 //ZteFrameWork.scrollTo(error, -200);
\r
375 highlight: function (element) { // hightlight error inputs
\r
377 .closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group
\r
380 unhighlight: function (element) { // revert the change done by hightlight
\r
382 .closest('.form-group').removeClass('has-error'); // set error class to the control group
\r
385 success: function (label) {
\r
387 .addClass('valid') // mark the current input as valid and display OK icon
\r
388 .closest('.form-group').removeClass('has-error'); // set success class to the control group
\r
390 submitHandler: function (form) {
\r
391 nodesuccess.show();
\r
393 //add here some ajax code to submit your form or just call form.submit() if you want to submit the form without ajax
\r
399 function spinnerButtonBindClick() {
\r
400 $('.spinner .btn:first-of-type').unbind().on('click', function () {
\r
401 var input = $('input', $(this).parents('.spinner'));
\r
403 if(input.val()=="") input.val("0");
\r
405 input.val(parseInt(input.val(), 10) + 1);
\r
406 if (input.val() > 1) {
\r
407 $('.spinner .btn:last-of-type').attr("disabled", false);
\r
410 $('.spinner .btn:last-of-type').unbind().on('click', function () {
\r
411 var input = $('input', $(this).parents('.spinner'));
\r
412 if(input.val()=="") input.val("2");
\r
414 input.val(parseInt(input.val(), 10) - 1);
\r
415 if (input.val() <= 1) {
\r
416 $('.spinner .btn:last-of-type').attr("disabled", true);
\r