var ajaxLoadImg = $('
'); var ajaxLoader=true; var isAjaxStarted=false; var id = 0, Q = {},ajaxCount; var tempDisableLoader=false; $(document).ready(function() { $(".TableMenu >ul >li").click(function(){ $('.TableMenu').show(); }); $(".sec_TableMenu >ul >li").click(function(){ $('.sec_TableMenu').show(); }); $(".dataTables_length").mouseover(function(){ $(".TableMenu").hide(); $('.sec_TableMenu').hide(); }); var xhr; $(document).ajaxSend(function(e, jqx){ if(ajaxLoader && !tempDisableLoader) { $("#Loader").show(); }else{ tempDisableLoader=false; } jqx._id = ++id; Q[jqx._id] = jqx; }); $(document).ajaxComplete(function(e, jqx){ delete Q[jqx._id]; // jqx.responseText='{"status":"failure","statusCode":-999999,"message":"session Expired"}'; try{ var jobj=eval("(" + jqx.responseText + ")"); if(jobj.statusCode=='-999999'){ //$(".msgcontainer").msgShow({type:'msgerror',msg:jobj.message}); logout(); } }catch(e){} //console.log('Ajax count :'+Object.keys(Q).length); if( Object.keys(Q).length==0){ $("#Loader").hide(); } }); $(this).ajaxError(function(e, xhr, settings, exception) { //console.log('error'+xhr._id); Q = {}; $("#Loader").hide(); switch (xhr.status) { case 404: showError('File not found'); break; case 500: showError('Server error'); break; //case 0: // showError('Communication problem'); // break; default: if(xhr.status!='0') showError('Unknown error ' + xhr.status) } }); function showError(message){ if($(".msgcontainer").length!=0){ $(".msgcontainer").msgShow({type:'msgerror',msg:message}); $("#MainContainer").animate({ scrollTop: 0 }, "slow"); }else{ alert(message); } } $('.notibar>.close').click(function(){ $(this).parent().hide(); }); }); (function($){ $.fn.msgShow = function(options) { object=$(this); var settings = { type:'msginfo', msg:'Message', autoClose:true }; options = $.extend( settings, options ); return this.each (function () { var mainMsgDiv=$('
'); var closeDiv=$(''); mainMsgDiv.addClass(settings.type); mainMsgDiv.append(closeDiv); mainMsgDiv.append($('

'+settings.msg+'

')); object.html(mainMsgDiv); closeDiv.click(function(){ // $(this).parent().hide(); $(this).parent().fadeOut(function(){ $(this).remove(); }); }); if(settings.autoClose){ setTimeout( function () { //console.log("timer"); mainMsgDiv.fadeOut(function(){ mainMsgDiv.remove(); }); }, 4000 // milliseconds delay ); } });}; })(jQuery); if (!Array.prototype.map) { Array.prototype.map = function(callback, thisArg) { var T, A, k; if (this == null) { throw new TypeError(" this is null or not defined"); } // 1. Let O be the result of calling ToObject passing the |this| value as the argument. var O = Object(this); // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length". // 3. Let len be ToUint32(lenValue). var len = O.length >>> 0; // 4. If IsCallable(callback) is false, throw a TypeError exception. // See: http://es5.github.com/#x9.11 if (typeof callback !== "function") { throw new TypeError(callback + " is not a function"); } // 5. If thisArg was supplied, let T be thisArg; else let T be undefined. if (thisArg) { T = thisArg; } // 6. Let A be a new array created as if by the expression new Array(len) where Array is // the standard built-in constructor with that name and len is the value of len. A = new Array(len); // 7. Let k be 0 k = 0; // 8. Repeat, while k < len while(k < len) { var kValue, mappedValue; // a. Let Pk be ToString(k). // This is implicit for LHS operands of the in operator // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk. // This step can be combined with c // c. If kPresent is true, then if (k in O) { // i. Let kValue be the result of calling the Get internal method of O with argument Pk. kValue = O[ k ]; // ii. Let mappedValue be the result of calling the Call internal method of callback // with T as the this value and argument list containing kValue, k, and O. mappedValue = callback.call(T, kValue, k, O); // iii. Call the DefineOwnProperty internal method of A with arguments // Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true}, // and false. // In browsers that support Object.defineProperty, use the following: // Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true }); // For best browser support, use the following: A[ k ] = mappedValue; } // d. Increase k by 1. k++; } // 9. return A return A; }; } $(document).ready(function(){ cookie=false; rolesAudit(); }); function setCookieTrue(){ cookie=true; } function setCookieFalse(){ cookie=false; } function rolesAudit(){ $(".roleCheck").each(function(){ if(permissionArr[$(this).attr('permission')]==undefined){ $(this).hide(); $(this).attr('disabled','disabled'); } }); $(".moduleCheck").each(function(){ //console.log($(this).attr(module)); if($(this).attr(module)=="false"){ $(this).hide(); } }); if(usergroup!="Admin" && usergroup != "SMSAdmin"){ $(".adminOnly").remove(); } if(usergroup=="Admin" && usergroup == "SMSAdmin"){ $(".hideAdmin").remove(); } } function commgeniRemove(){ $(".commgeniRemove").each(function(){ //$(this).remove(); if($(this).attr('remove')=="true"){ $(this).remove(); //$(this).attr('disabled','disabled'); } }); } function propertyRemove(){ $(".propRemove").each(function(){ if(!eval(getCGProperty($(this).attr('property')))){ $(this).remove(); } }); } function rolesAuditRemove(){ $(".roleCheckRemove").each(function(){ //$(this).remove(); if(permissionArr[$(this).attr('permission')]==undefined){ $(this).remove(); //$(this).attr('disabled','disabled'); } }); $(".moduleCheck").each(function(){ //console.log($(this).attr(module)); if($(this).attr(module)=="false"){ $(this).remove(); } }); if(usergroup!="Admin" && usergroup != "SMSAdmin"){ $(".adminOnly").remove(); } } function checkPermission(object,id){ if(permissionArr[id]==undefined){ $(object).each(function(){ $(this).hide(); }); }else{ $(object).each(function(){ $(this).show(); }); } } function roleCheck(permissionId){ if(permissionArr[permissionId]==undefined){ return false; } else{ return true; } } function editDeletePermCheck(editId,deleteId){ if(permissionArr[editId]==undefined && permissionArr[deleteId]==undefined){ return false; } else{ return true; } } function numberFormat(data,decimal) { if(data!='' && data!='-'){ var val=eval(data); return val; } return data; } function secondsToMins(secs) { /*var minutes = Math.floor(secs / 60); var seconds = secs - minutes * 60; if(minutes<10){ minutes='0'+minutes; } if(seconds<10){ seconds='0'+seconds; } // return minutes+':'+seconds;*/ return secondsToTime(secs); } function secondsToMinsOnly(secs) { var minutes = Math.floor(secs / 60); var seconds = secs - minutes * 60; if(minutes<10){ minutes='0'+minutes; } if(seconds<10){ seconds='0'+seconds; } return minutes+':'+seconds; // return secondsToTime(secs); } function splitTimeZone(val){ var timeArr=val.split(" "); var timeZone=timeArr[timeArr.length-1]; if(timeZone.split("-").length>1){ return timeZone; } else{ return "+"+timeZone; } } function formatStandardDate(now){ var currentDate = now.getFullYear()+'-' + ('0' + (now.getMonth() + 1)).slice(-2) + '-' +('0' + (now.getDate() )).slice(-2) ; return currentDate; } function secondsToTime(secs) { var hours = Math.floor(secs / (60 * 60)); var divisor_for_minutes = secs % (60 * 60); var minutes = Math.floor(divisor_for_minutes / 60); var divisor_for_seconds = divisor_for_minutes % 60; var seconds = Math.ceil(divisor_for_seconds); var obj = { "h": hours, "m": minutes, "s": seconds }; if(hours<10){ hours='0'+hours; } if(minutes<10){ minutes='0'+minutes; } if(seconds<10){ seconds='0'+seconds; } return hours+':'+minutes+':'+seconds; } window.onerror = function(e) { Q = {}; $("#Loader").hide(); // console.log(e); // $(".msgcontainer").msgShow({type:'msgerror',msg:e}); }; var compareArrays = function(a, b) { return a.sort().join() === b.sort().join(); }; function insertArray(oldArray,newArray){ $.each(oldArray, function(key, value) { newArray[key] = value; }); } function pushValues(a,b){ for ( var z = 0; z < a.length; z = z + 1 ) { b.push(a[z]); } } function insertPrefixDest(a,b,c){ for ( var i = 0; i < a.length; i = i + 1 ) { var newDestArry=[]; if(c[a[ i ]] == undefined){ c[a[ i ]] = b; }else{ newDestArry = c[a[ i ]]; for( var j = 0; j < b.length; j = j + 1 ) { newDestArry.push(b[j]); } c[a[ i ]] = newDestArry; } } } function isNumberEvent(evt) { evt = (evt) ? evt : window.event; var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false; } return true; } function getAllCount(arr) { var count = 0; for ( var i = 0; i < arr.length; i = i + 1 ) { if(arr[i] == "ALL"){ count = count+1; } } return count; } jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) { var _that = this; if ( iDelay === undefined ) { iDelay = 500; } this.each( function ( i ) { $.fn.dataTableExt.iApiIndex = i; var $this = this, oTimerId = null, sPreviousSearch = null, anControl = $( 'input', _that.fnSettings().aanFeatures.f ); anControl.unbind( 'keyup' ).bind( 'keyup', function() { var $$this = $this; if (sPreviousSearch === null || sPreviousSearch != anControl.val()) { window.clearTimeout(oTimerId); sPreviousSearch = anControl.val(); oTimerId = window.setTimeout(function() { $.fn.dataTableExt.iApiIndex = i; _that.fnFilter( anControl.val() ); }, iDelay); } }); return this; } ); return this; }; function getLoggedInGroupType(){ var type; if(usergroup=='Admin'){ type=1; }else if(usergroup=='Distributor'){ type=2; }else if(usergroup=='Reseller'){ type=3; }else if(usergroup=='Sub-Reseller'){ type=4; }else if(usergroup=='Agent'){ type=5; }else if(usergroup=='Call Shop'){ type=100; }else if(usergroup=='Company'){ type=101; }else if(usergroup=='SMSAdmin'){ type=201; }else if(usergroup=='SMSReseller'){ type=202; }else if(usergroup=='Enterprise'){ type=6; }else if(usergroup=='Sub-Group'){ type=204; } return type; } function profitRoutingStatus(){ var profitRouting=false; $.ajax({ url: baseContext+'/generic/invoke', type: 'GET', dataType: 'json', loader: true, cache: false, async: false, data: { actionId: 'getProfitRoutingDetailsAsJSON', action_uri: 'profitRoutingProperties', }, success: function (data) { $.each(data.records,function(i,val){ if(val.enableprofitrouting != undefined && val.enableprofitrouting=="true"){ profitRouting=true; } }); } }); return profitRouting; } function getCGProperty(propertyName){ var propertyValue=null; $.each(commgenie.records,function(i,val){ if(val[propertyName]!=undefined){ propertyValue=val[propertyName]; return false; } }); return propertyValue; } function getBillingCycleNames(owner){ var cycles; $.ajax({ url: baseContext+'/generic/invoke', type: 'POST', dataType: 'json', loader: true, cache: false, async: false, data: { actionId: 'getBillingCycle', action_uri: 'getSubscriberDetails', subscriberId: user, billType: 'postpaid', serviceType:"admin", billingCycleUsage:"Both" }, success: function (data) { if (data.status != "success") { cycles = null; } else { cycles = data.cycle; console.log("value="+cycles); } } }); return cycles; } function changeSubscriberType(id,billingCycleType){ var htmlText; $(id).html(''); if(billingCycleType=='ALL' || billingCycleType=='All'){ htmlText = ''; htmlText += ''; htmlText += ''; htmlText += ''; htmlText += ''; }else if(billingCycleType=='Origination'){ htmlText = ''; htmlText += ''; htmlText += ''; htmlText += ''; }else if(billingCycleType=='Termination'){ htmlText = ''; }else{ htmlText = ''; htmlText += ''; htmlText += ''; htmlText += ''; } $(id).html(htmlText); } function scrollTop(){ $("#MainContainer").animate({ scrollTop: 0 }, "slow"); } function showPasswordMessage(numericFlag){ $('#growl-notify').jGrowl('close'); if(numericFlag==true){ var html="Criteria for Password"; html+="
Numeric value only allowed
"; }else{ var html="Criteria for Password Strength "; html+="
  • Minimum 8 Characters in Length
  • Should Contains Only Special Characters[!,@,#,$,%,^,&,*,?,_,~,-,(,]
  • Password Should Not have Consecutive 3 Letters in Username
  • Password Should Not have Consecutive 3 Numbers
  • "; } $('#growl-notify').jGrowl(html,{theme:'alert-info', sticky: true }); } function showNumericUserMessage(type){ $('#growl-notify').jGrowl('close'); var html="Criteria for "+type+""; html+="
    Numeric value only allowed
    "; $('#growl-notify').jGrowl(html,{theme:'alert-info', sticky: true }); } function hidePasswordMessage(){ $('#growl-notify').jGrowl('close'); } $.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name]) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; }; function encrypt(username,password){ return $.ajax({ url: '/generic/invoke', type: 'POST', dataType: 'json', loader:true, cache: false, data: {actionId : 'getKey',action_uri : 'key'}, /*success: function (data) { }*/ }).then(function(response){ return SHA256(username+':'+response.ip+':'+password); }); } function encryptChangePassword(username,oldPassword,newPassword){ return $.ajax({ url: '/generic/invoke', type: 'POST', dataType: 'json', loader:true, cache: false, data: {actionId : 'getKey',action_uri : 'key'}, /*success: function (data) { }*/ }).then(function(response){ var data={}; console.log(username+" == "+response.ip+" == "+oldPassword+" == "+response.key); data.oldPassword = SHA256(SHA256(username+':'+response.ip+':'+oldPassword)+':'+response.key); data.newPassword = SHA256(username+':'+response.ip+':'+newPassword); return data; }); } var globalCallId; var loadCallFlow = function(callId){ globalCallId = callId $(".callFlowBackBtn").hide(); $.ajax({ url: "/reports/callflow", type: 'GET', dataType: 'html', loader: true, cache: false, data: { callId: callId }, success: function (data) { var parser = new DOMParser(); var xmlDoc = parser.parseFromString(data,"text/xml"); var arr = [], l = xmlDoc.getElementsByTagName("a"); for(var i=0; i