function activeSidebaarLink() { $(".sideMenuLink a").click(function () { $(".sideMenuLink a").removeClass("activeSideLink"); $(this).addClass("activeSideLink"); }); } //function to get date picker $.prototype.levydatepicker = function (options) { var dateObject = $(this).datepicker({ dateFormat: options.dateFormat, maxDate: +options.maxDate, minDate: options.minDate, beforeShowDay: options.beforeShowDay, onSelect: options.onSelect, changeMonth: options.changeMonth, changeYear: options.changeYear, yearRange: options.yearRange }); $(this).attr("readonly", "readonly"); if (options.defaultDate) { dateObject.val(options.defaultDate); } $("#ui-datepicker-div").hide(); } //function call on ajax request start $(document).ajaxStart(function (e) { // console.log("ajax request start"); showLoadingMessage("Loading..."); }); //function call on ajax request stop $(document).ajaxStop(function () { ////console.log("ajax request end."); hideLoadingMessage(); }); function showLoadingMessage(message) { var url = window.location.href; var arr = url.split("/"); var result = arr[0] + "//" + arr[2] + "/Content/css/images/eicher-logo-loading-image.gif"; if (!message) { message = "Loading.." } message = '
'; $("#divLoadingElement").html(message).show(); } //function to hide loading message from page function hideLoadingMessage() { $("#divLoadingElement").hide(); } //function call to get current time function getCurrentTime() { var currDate = new Date(); return currDate.getDay() + '' + currDate.getMonth() + '' + currDate.getYear() + '' + currDate.getHours() + '' + currDate.getMinutes() + '' + currDate.getSeconds() + '' + currDate.getMilliseconds(); } /* ================================Call for alive session================================*/ function aliveSession() { var currtime = getCurrentTime(); $.get("/Home/SessionTimeout/", { currtime: currtime }, function (result) { }); } //setInterval(function () { aliveSession(); }, 1000 * 60 * 10); /*========================================End============================================*/ /*==================================Time Picker==========================================*/ //function to set time picker in tracking function timePicker(startTimeId, endTimeId) { var id = "#" + startTimeId + ", #" + endTimeId; // Use default settings $(id).timePicker(); // Store time used by duration. var oldTime = $.timePicker("#" + startTimeId).getTime(); // Keep the duration between the two inputs. $("#" + startTimeId).change(function () { if ($("#" + endTimeId).val()) { // Only update when second input has a value. // Calculate duration. var duration = ($.timePicker("#" + endTimeId).getTime() - oldTime); var time = $.timePicker("#" + startTimeId).getTime(); // Calculate and update the time in the second input. $.timePicker("#" + endTimeId).setTime(new Date(new Date(time.getTime() + duration))); oldTime = time; } }); // Validate. $("#" + endTimeId).change(function () { if ($.timePicker("#" + startTimeId).getTime() > $.timePicker(this).getTime()) { $(this).addClass("error").removeClass('valid'); } else { $(this).removeClass("error"); } //changeSliderValue(); //call for slider value update }); } /*=====================================End===============================================*/ // Show title on kendo grid header function addTitleAttribute() { $.each($(".k-grid-header").find('tr th'), function (idx, th) { var a = $(th).attr('data-title'); if ($(th).attr('data-title')) { $(th).attr('title', $(th).attr('data-title')); } else { $(th).attr('title', $(th).attr('data-field')); } }); } // Call when data bound on the grid to add title attribute to each column header function onDataBound() { addTitleAttribute(); } //function to set pager and group bar of kendo grid function setPagerAndGroupBarWidth() { //console.log($('.k-grid-header tr')); var headersWidth = $('.k-grid-header tr').width(); // alert(headersWidth); $(".k-grid-pager").width(headersWidth); $(".k-grouping-header").width(headersWidth); addTitleAttribute(); } //function call to fit size of pager to grid function fitPagerToGrid() { var headersWidth = $('.k-grid-header tr').width(); //console.log(headersWidth); $(".k-grid-pager").width(headersWidth); } // open and close Right slider. function rightSlider() { /* right silder for text */ $(".button").click(function () { if ($(this).hasClass('open DD_close')) { $(".container").animate({ right: "-187px" }, 250, "linear", function () { $('.button').removeClass('open DD_close'); }); } else { $(".container").animate({ right: "0px" }, 250, "linear", function () { $('.button').addClass('open DD_close'); }); } }); } /** * Function to add kendo window * @method addKendoWindow * @param {String} divId The id of div * @param {String} titleText The name of window title * @param {String} width width of window * @param {String} left margin from left */ function addKendoWindow(divId, titleText, width, left, top) { $(divId).kendoWindow({ width: width, title: titleText, modal: true, resizable: false, draggable: true, position: { top: top, left: left } }); } //============================== query String functionality======================== // Get query string parameter function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } /** * Add Attributes (Href,target) to given anchor element. * @method addLinkValue */ function addLinkValue($eleParentHref, linkValue) { $eleParentHref.attr({ 'href': linkValue, 'target': '_blank' }).css("cursor", "pointer"); } /** * function which dynamically add Query parameter on given uri. * @method updateQueryStringParameter */ function updateQueryStringParameter(uri, key, value) { var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i"); var separator = uri.indexOf('?') !== -1 ? "&" : "?"; if (uri.match(re)) { return uri.replace(re, '$1' + key + "=" + value + '$2'); } else { return uri + separator + key + "=" + value; } } //============================== End of query String functionality======================== /** * Refresh kendo grid when resize coloum. * @method onColumnResize */ function onColumnResize(e) { var activeGridId = e.sender._cellId; var replaceString = "_active_cell"; var updatedId = (activeGridId.replace(replaceString, '')).trim(); $("#" + updatedId).data("kendoGrid").refresh(); } /** * Set numeric filter values as intger. * @method NumericFilter */ function NumericFilter(control) { $(control).kendoNumericTextBox({ "format": "n0", "decimals": 0 }); } // update grid with message if no result found. function displayNoResult(e) { var grid = e.sender; if (grid.dataSource.total() == 0) { var colCount = grid.columns.length; $(e.sender.wrapper) .find('tbody') .append('No data available!'); } } //function to decode html text function stringToDecode(encodedString, id) { var stringtodecode = encodedString; document.getElementById(id).innerHTML = stringtodecode; stringtodecode = document.getElementById(id).textContent; return stringtodecode; } function AllowSpecialCharacterForOwner(e, t) { var key; var keychar; if (window.event) key = window.event.keyCode; else if (e) key = e.which; else return true; keychar = String.fromCharCode(key); keychar = keychar.toLowerCase(); // control keys if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27)) return true; else if ((("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1)) return true; else return true; } /** * Function call on row bound of close tickets table * @param {String} divId The id of div * @method openKendoWindowInCenter */ function openKendoWindowInCenter(divId) { console.log(divId); var window = $(divId).data("kendoWindow"); window.center(); //window.open(); } //================== get state list on change region ======================// /** * Function to bind all cities on state change in drop down * @method LoadCityListOnStateChange * @for DropDownData */ function LoadStateListRegionWise(ddRegionId, ddStateId, ddCityId) { // empty Language dropdown $("#" + ddCityId).text(""); // by default add select text. $("#" + ddCityId).append($('').val("").html("-Select-")); var regionVal; regionVal = $("#" + ddRegionId).val(); var regionName = $("#" + ddRegionId).find('option:selected').text(); $("#" + ddStateId).val(''); if (regionVal != "-Select-") { regionVal = $("#" + ddRegionId).val(); } else { regionVal = 0; } if (regionVal != "") { $.ajax({ type: "GET", url: "/DropDownData/showStateRegionWise/", data: { regionVal: regionVal }, success: function (data) { console.log(data); // empty Language dropdown $("#" + ddStateId).text(""); // by default add select text. $("#" + ddStateId).append($('').val("").html("-Select-")); // add data to dropdown. if (data.list) { for (var counter = 0; counter < data.list.length; counter++) { $("#" + ddStateId).append( $('').val(data.list[counter].StateId).html(data.list[counter].StateAlias)); } } }, error: function (data) { console.log(data); } }); } } //-----------Cookie Get/Set ---------------------- function setCookie(cname, cvalue, exMin) { var d = new Date(); d.setTime(d.getTime() + (exMin * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + cvalue + "; " + expires; } //-----------Draw Static map ---------------------- var MAP_KEY = "AIzaSyD7b7tjg7pXb3fTaMZ55xe5eTLFSw1QlMY"; var CLIENT_ID = "gme-teramatrix"; function drawStaticMap_MarkersPath(id,width,height, sourceLatlong, destiLatLong) { $("#"+id).attr("src", ""); var sourceMarker = '/Scripts/map_api/icons/red_s.png'; //marker for source var destinationMarker = '/Scripts/map_api/icons/red_d.png'; $("#"+id).attr("src", "https://maps.googleapis.com/maps/api/staticmap?markers=icon:" + window.location.origin + sourceMarker + "|" + sourceLatlong + "&markers=icon:" + window.location.origin + destinationMarker + "|" + destiLatLong + "&path=" + sourceLatlong + "|" + destiLatLong + "&size="+width +"x"+ height +"&key=" + MAP_KEY) } function drawSticeMap(id, width,height) { $("#" + id).attr("src", ""); $("#" + id).attr("src", "https://maps.googleapis.com/maps/api/staticmap?center=26.9124,75.7873&zoom=12&size=" + width + "x" + height + "&key=" + MAP_KEY) }