From 3d042d10258e3c6763bedb7da1071c7568788e73 Mon Sep 17 00:00:00 2001 From: sunqi310 Date: Wed, 14 Sep 2016 15:31:25 +0800 Subject: Add extsys gui Change-Id: Ifd4007f7f41b6efcc5abb120a1edf3e81f213d6d Signed-off-by: sunqi310 --- .../src/main/webapp/extsys/vnfm/js/commonUtil.js | 128 +++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 openo-portal/portal-extsys/src/main/webapp/extsys/vnfm/js/commonUtil.js (limited to 'openo-portal/portal-extsys/src/main/webapp/extsys/vnfm/js/commonUtil.js') diff --git a/openo-portal/portal-extsys/src/main/webapp/extsys/vnfm/js/commonUtil.js b/openo-portal/portal-extsys/src/main/webapp/extsys/vnfm/js/commonUtil.js new file mode 100644 index 00000000..abc4cd63 --- /dev/null +++ b/openo-portal/portal-extsys/src/main/webapp/extsys/vnfm/js/commonUtil.js @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2015 ZTE, Inc. and others. All rights reserved. (ZTE) + * + * 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. + */ +var commonUtil = {}; +commonUtil.arrayRemove = function( aryInstance , index ){ + if(aryInstance == undefined || aryInstance == null){ + return; + } + for(var i=0,n=0;i 2006-07-02 08:09:04.423 +// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 +commonUtil.parseDate = function( dateObj , format){ + var o = { + "M+" : dateObj.getMonth()+1, //month + "d+" : dateObj.getDate(), //day + "h+" : dateObj.getHours(), //hour + "m+" : dateObj.getMinutes(), //minute + "s+" : dateObj.getSeconds(), //second + "q+" : Math.floor((dateObj.getMonth()+3)/3), //quarter + "S" : dateObj.getMilliseconds() //millisecond + } + if(/(y+)/.test(format)) format=format.replace(RegExp.$1, + (dateObj.getFullYear()+"").substr(4 - RegExp.$1.length)); + for(var k in o) + if(new RegExp("("+ k +")").test(format)) + format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : + ("00"+ o[k]).substr((""+ o[k]).length)); + return format; +}; + +//tooltip +commonUtil.showMessage = function(message, type) { + $.growl({ + icon: "fa fa-envelope-o fa-lg", + title: "  " + $.i18n.prop("nfv-nso-iui-common-tip"), + message: message + },{ + type: type + }); +}; + +commonUtil.registerCometdMessage = function(url, channel, callback) { + var cometd = new $.Cometd(); + var cometdURL = location.protocol + "//" + location.host + url; + cometd.configure({ + url : cometdURL, + logLevel : "info" + }); + // unregister websocket transport, use long-polling transport + cometd.unregisterTransport('websocket'); + // store channel object parameters(this object include channel and callback function), start from arguments[1] + var _args = arguments; + + cometd.addListener("/meta/handshake", function(handshake){ + if(handshake.successful === true) { + cometd.batch(function() { + //subscribe channel + cometd.subscribe(channel, function(message){ + callback.call(this, message.data); + }); + }); + } + }); + cometd.handshake(); +} + +commonUtil.format = function() { + if(arguments.length == 0) { + return null; + } + var str = arguments[0]; + for(var i=0; i