(function (window) { $(document).ready(function () { try { if (typeof IsSmart2header != 'undefined' && IsSmart2header == 'True') { if (IsSmart2header == 'True') { sessionStorage.workspace2_Enabled = true; } var url = document.URL; var recentDocsHistoryLength = 20; var recentDocs = []; var currentDoc = {}; currentDoc['docType'] = -22; currentDoc['urlFormat'] = document.URL.replace(document.location.protocol + '//' + document.location.host, ''); if (currentDoc['urlFormat'].search('//') == 0 && currentDoc['urlFormat'].search('//') != -1) { currentDoc['urlFormat'] = currentDoc['urlFormat'].replace('//', '/') } if (typeof sessionStorage["recentDocuments"] == 'undefined' || sessionStorage["recentDocuments"] == '') { sessionStorage["recentDocuments"] = '[]'; } var parseData = JSON.parse(sessionStorage["recentDocuments"]) if (parseData.length > 0) { var previousDocIndex = parseData.length - 1; var previousDoc = parseData[previousDocIndex]; recentDocs = parseData; if (previousDoc.urlFormat != currentDoc['urlFormat']) { recentDocs.push(currentDoc); if (recentDocs.length > recentDocsHistoryLength) { recentDocs.shift(); } sessionStorage["recentDocuments"] = JSON.stringify(recentDocs); } } else { recentDocs.push(currentDoc); sessionStorage["recentDocuments"] = JSON.stringify(recentDocs); } setTimeout(function () { $('.backtopage').html(''); $('#backButton2').bind('click', goBack); }, 2000); } } catch (e) { console.log(e); } function goBack() { if (IsSmart2header == 'True') { if (typeof sessionStorage["recentDocuments"] != 'undefined') { var recentdocs = JSON.parse(sessionStorage["recentDocuments"]); if (recentdocs.length > 0) { if (recentdocs[recentdocs.length - 1].urlFormat.search("EstimatedSpendAndSaving/Index") > -1 || recentdocs[recentdocs.length - 1].urlFormat.search("Result/NegotiatedSavings") > -1 || recentdocs[recentdocs.length - 1].urlFormat.search("Project/TrackRealizedSaving") > -1 ) { var i; var counter = 0; for (i = recentdocs.length - 1 ; i >= 0; i--) { counter++; if (counter > 0) { if ((recentdocs[i].hasOwnProperty('docType')) && (recentdocs[i].docType == 21)) { var prevDoc = recentdocs[i]; recentdocs.splice(recentdocs.length - counter, recentdocs.length); sessionStorage.recentDocuments = JSON.stringify(recentdocs); if (prevDoc.urlFormat == "") { history.go(-1); } else { window.location.href = prevDoc.urlFormat; } return; } } } } var prevDoc = recentdocs[recentdocs.length - 2]; recentdocs.splice(recentdocs.length - 1, 1); sessionStorage.recentDocuments = JSON.stringify(recentdocs); if (prevDoc.urlFormat == "") { history.go(-1); } else { var docUrl = ''; if (typeof prevDoc.docType != 'undefined' && prevDoc.docType == -9) { docUrl = prevDoc.docCode; } else { docUrl = prevDoc.urlFormat; } if (docUrl.search('//') == 0 && docUrl.search('//') != -1) { docUrl = docUrl.replace('//', '/'); } window.location.href = docUrl; } } } } } }) }) (window); //Consent Popup (function (window) { var consentId = ''; var appUrl = ''; var buyerPartnerCode = ''; var encryptedBPC = $('#hdnEncryptedBuyerPartnerCode').val(); var description = ''; var showUserConsentPopUp = 'false'; var dialog; $(document).ready(function () { setTimeout(function () { if (typeof _companyLogoURL != 'undefined') { buyerPartnerCode = _companyLogoURL.substring(_companyLogoURL.lastIndexOf("/logo/") + 6, _companyLogoURL.lastIndexOf("_logo")); appUrl = SearchPanel.portalURL; if (SearchPanel.IsSupplier == 'True' && window.IsSupplierConsentEnabled == 'true' && sessionStorage.IsConsentAccepted != buyerPartnerCode + '_' + userContactCode) { var getConsentLog = function () { $.ajax({ url: appUrl + '/api/v1/workspaceconfig/GetUserConsentLog?oloc=586', type: 'GET', async: true, headers: { "UseCase": "Portal-Header1.0", "AppName": window.location.href, "TransactionId": 'transact-' + (new Date()).getTime() }, //Ajax events success: function (response) { if (!response.IsConsentProvided || response.IsConsentProvided == "false") { showUserConsentPopUp = true; getConsentDetail(); } else { sessionStorage.IsConsentAccepted = buyerPartnerCode + '_' + userContactCode; } }, error: function () { $('#errors').text("There was an error processing getConsentLog. Please try again.") }, cache: false, datatype: "json", contentType: "application/json" }); }; getConsentLog(); } } }, 50); }) var getConsentDetail = function () { var culturecode = ''; if ($('#hdnCultureCode').val() == undefined) { culturecode = 'en-US' } else { culturecode = $('#hdnCultureCode').val(); } $.ajax({ url: appUrl + '/api/v1/workspaceconfig/GetConsentDetailForLoggedInUser?oloc=586', type: 'POST', async: true, headers: { "UseCase": "Portal-Header1.0", "AppName": window.location.href, "TransactionId": 'transact-' + (new Date()).getTime() }, //Ajax events success: function (response) { if (typeof response.IsConsentAccepted == 'undefined') { userConsentObj = true; description = response.description; consentId = response._id; buildUserConsentPopup(); } }, data: {}, cache: false, datatype: "json", contentType: "application/json", crossDomain: true }); }; var buildUserConsentPopup = function () { var ConsentBody = '
'; $('body').append(ConsentBody); $('.userConsentCheckBoxCont input[type=checkbox]').on("click", function (e) { if ($('.userConsentCheckBoxCont input[type=checkbox]').is(':checked')) { dialog.dialog({ buttons: [{ text: Resources.cancelBtnConfig_Consent, click: function () { dialog.dialog("close"); logoutUserConsent(); } }, { text: Resources.acceptBtnConfig_Consent, click: function () { saveConsentLog(); } } ] }); dialog.dialog('option', 'buttons', buttons); }else { dialog.dialog({ buttons: [ { text: Resources.cancelBtnConfig_Consent, click: function () { dialog.dialog("close"); logoutUserConsent(); } } ] }); if (typeof buttons.Accept != 'undefined') { delete buttons.Accept; } dialog.dialog('option', 'buttons', buttons); } }); dialog = $("#consent-form").dialog({ autoOpen: false, modal: true, width: 500, closeOnEscape: false, open: function(event, ui) { $(".ui-dialog-titlebar-close", ui.dialog | ui).hide(); }, buttons: [ { text: Resources.cancelBtnConfig_Consent, click: function () { dialog.dialog("close"); logoutUserConsent(); } } ] }); dialog.dialog("open"); $('.ui-dialog').css("z-index", "1000001"); $('.ui-widget-overlay').css("z-index", "1000000"); } var saveConsentLog = function () { $.ajax({ url: appUrl + '/api/v1/workspaceconfig/SaveUserConsentLog?oloc=586', type: 'POST', async: true, headers: { "UseCase": "Portal-Header1.0", "AppName": window.location.href, "TransactionId": 'transact-' + (new Date()).getTime() }, //Ajax events success: function (response) { if (response == "true" || response) { sessionStorage.IsConsentAccepted = buyerPartnerCode + '_' + userContactCode; showUserConsentPopUp = false; dialog.dialog("close"); } }, data: JSON.stringify({ 'IsConsentProvided': true, 'ConsentDetailsId': consentId }), cache: false, datatype: "json", contentType: "application/json", crossDomain: true }); } var logoutUserConsent = function () { window.location.href = appUrl + 'Controls/headerbar/Logout?oloc=101&c=' + DOMPurify.sanitize( encryptedBPC ); } })(window); (function (window) { var Gep = typeof Gep !== 'undefined' ? Gep : {}; Gep.Utils = new (function () { "use strict"; var instance, infoGMapMarkerWin, infoWinForLocList, //----------------------------Start Code Section--------------------------------// updateCultureText = function () { //debugger; if (typeof (Resources) != "undefined") { if (typeof (Resources.error) == "undefined") { /// var dataName = $("[data-resourcekey]:not(input):not(textarea)"), attrVal, recVal, retObj, countDataName = dataName.length; for (var i = 0; i < countDataName; i++) { retObj = $(dataName[i]); retObj.html attrVal = retObj.attr("data-resourcekey"); $.each(Resources, function (Key, keyvalue) { recVal = keyvalue[attrVal]; if (recVal !== undefined) { retObj.html(recVal); } }); } } } }, updateCultureTitle = function () { //debugger; if (typeof (Resources) != "undefined") { if (typeof (Resources.error) == "undefined") { /// var dataName = $("[title-resourcekey]:not(input):not(textarea)"), attrVal, recVal, retObj, countDataName = dataName.length; for (var i = 0; i < countDataName; i++) { retObj = $(dataName[i]); attrVal = retObj.attr("title-resourcekey"); $.each(Resources, function (Key, keyvalue) { //debugger; recVal = keyvalue[attrVal]; if (recVal !== undefined) { retObj.attr("title", recVal); } }); } } } }, updateWatermark = function () { if (typeof (Resources) !== "undefined") { if (typeof (Resources.error) == "undefined") { var inputName = $("input[data-resourcekey], textarea[data-resourcekey]"), attrVal, recVal, retObj, countInputName = inputName.length; for (var i = 0; i < countInputName; i++) { retObj = $(inputName[i]); attrVal = retObj.attr("data-resourcekey"); recVal = Resources.gpn_index[attrVal]; if (recVal !== undefined) { retObj.attr('placeholder', recVal); retObj.watermark(); } } } } }, updateUIWithDefaultCultureText = function () { updateCultureText(); updateCultureTitle(); updateWatermark(); //TODO: Validate if required for all $(".watermark_container").addClass("floatL"); }, showMessage = function (message) { var msgDiv = document.createElement("DIV"); $(msgDiv).append(""); $("form").append($(msgDiv)); $(msgDiv).dialog({ modal: true, closeOnEscape: true, title: window.Resources.gpn_index.ModalDialogTitle, position: "center", create: function () { // $(this).parent().find(".ui-widget-header").hide(); }, buttons: { Ok: function () { $(this).dialog("destroy"); $(msgDiv).remove(); } } }); }, showConfirmation = function (message, okFn, cancelFn) { var msgDiv = document.createElement("DIV"); $(msgDiv).append(""); $("form").append($(msgDiv)); $(msgDiv).dialog({ modal: true, title: window.Resources.gpn_index.ModalDialogTitle, closeOnEscape: true, position: "center", buttons: { Ok: function () { $(this).dialog("close"); $(msgDiv).remove(); if (typeof (okFn) === "function") { okFn(); } }, Cancel: function () { $(this).dialog("close"); $(msgDiv).remove(); if (typeof (cancelFn) === "function") { cancelFn(); } } } }); }, applyKOValueBinding = function (vm, frm) { for (var name in vm) { if (vm.hasOwnProperty(name)) { var obj = null; if (frm !== undefined) obj = frm.find("[name='" + name + "']"); else obj = $("[name='" + name + "']"); if (obj != null && obj.length > 0) obj.attr("data-bind", "value:" + name); } } }, applyKOTextBinding = function (vm, frm) { for (var name in vm) { if (vm.hasOwnProperty(name)) { var obj = null; if (frm !== undefined) obj = frm.find("[name='" + name + "']"); else obj = $("[name='" + name + "']"); if (obj != null && obj.length > 0) obj.attr("data-bind", "text:" + name); } } }, updateUIWithCultureData = function (data, callback) { if (window.Resources.gpn_index !== undefined) { delete window.Resources.gpn_index; window.Resources.gpn_index = data; } updateCultureText(); updateWatermark(); if (typeof (callback) === "function") { callback(); } }, colorMapMarker = function colorMapMarker(markerDimensions) { if (typeof (google) === undefined) return; var colorMarkerObj = {}; var markerImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + markerDimensions.color, null, null, null, //new google.maps.Size(22, 38)); new google.maps.Size(markerDimensions.sizeX, markerDimensions.sizeY)); var markerShadow = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_shadow", null, null, //new google.maps.Point(22, 38), new google.maps.Point(markerDimensions.sizeX, markerDimensions.sizeY), //new google.maps.Size(66, 38)); new google.maps.Size(markerDimensions.sizeX * 3, markerDimensions.sizeY)); colorMarkerObj = { "markerImage": markerImage, "markerShadow": markerShadow } return colorMarkerObj; }, addInfoMarkerForLocationList = function (param) { if (typeof (google) === undefined) return; if (infoGMapMarkerWin !== undefined && infoGMapMarkerWin.open !== undefined) { infoGMapMarkerWin.close(); } var point = new google.maps.LatLng(param.Latitude, param.Longitude); infoWinForLocList = new google.maps.InfoWindow({ content: param.address, size: new google.maps.Size(100, 100), position: point }); if (openWindow != undefined && openWindow != '') openWindow.close(map); openWindow = infoWinForLocList; infoWinForLocList.open(map); //callBackExecute(returnInfoMarkerObj); }, addMarkerAtGMap = function (param, gMapObject, colorMarkerObj, callBackExcecute) { if (typeof (google) === undefined) return; if (infoGMapMarkerWin !== undefined && infoGMapMarkerWin.open !== undefined) { infoGMapMarkerWin.close(); } if (infoWinForLocList !== undefined && infoWinForLocList.open !== undefined) { infoWinForLocList.close(); } var geocoder = new google.maps.Geocoder(), returnGMapObject; geocoder.geocode({ 'address': param.address }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { var lat = 0; var lng = 0; map.setCenter(results[0].geometry.location); gMapObject = new google.maps.Marker({ icon: colorMarkerObj.markerImage, shadow: colorMarkerObj.markerShadow, position: results[0].geometry.location, title: param.infoMarkerAddress }); gMapObject.setMap(map); google.maps.event.addListener(gMapObject, "click", function (event) { if (infoGMapMarkerWin !== undefined && infoGMapMarkerWin.open !== undefined) { infoGMapMarkerWin.close(); } if (infoWinForLocList !== undefined && infoWinForLocList.open !== undefined) { infoWinForLocList.close(); } infoGMapMarkerWin = new google.maps.InfoWindow( { content: param.infoMarkerAddress, size: new google.maps.Size(100, 100), position: gMapObject.position }); infoGMapMarkerWin.open(map); }); if (map !== undefined) { var location = map.getCenter(); lat = location.lat(); lng = location.lng(); } returnGMapObject = { success: true, latitude: lat, longitude: lng, gMapObject: gMapObject, infoMarkerObj: infoGMapMarkerWin }; } else { // if (param.message !== undefined) { // $Utils.showMessage(param.message); // } returnGMapObject = { success: false, latitude: "0", longitude: "0", gMapObject: gMapObject }; } callBackExcecute(returnGMapObject); }); }, removeMarkerAtGMap = function removeMarkerAtGMap(item) { if (typeof (google) === undefined) return; var markerName = item.Addressline1(); for (var cntMarker = 0; cntMarker < markArr.length; cntMarker++) { if (markerName == markArr[cntMarker].title) { markArr[cntMarker].setMap(null); markArr.splice(cntMarker, 1); } } if (infoGMapMarkerWin !== undefined && infoGMapMarkerWin.open !== undefined) { infoGMapMarkerWin.close(); } if (infoWinForLocList !== undefined && infoWinForLocList.open !== undefined) { infoWinForLocList.close(); } }, mapInfoMarkerAddressFormatter = function mapInfoMarkerAddressFormatter(addressToFormatObj) { var formattedAddress = ''; for (var key in addressToFormatObj) { if (addressToFormatObj.hasOwnProperty(key)) { if (addressToFormatObj[key] != '' && !(addressToFormatObj[key].match(/,$/g, ""))) { formattedAddress += addressToFormatObj[key] + ','; } else { formattedAddress += addressToFormatObj[key]; } } } return formattedAddress.replace(/,$/g, ""); } , //----------------------------End Code Section--------------------------------// init = function () { return { variables: { USACountryId: "221", CanadaCountryId: "36", UKCountryId: "74" }, "applyKOValueBinding": applyKOValueBinding, "applyKOTextBinding": applyKOTextBinding, "updateUIWithDefaultCultureText": updateUIWithDefaultCultureText, "showMessage": showMessage, "showConfirmation": showConfirmation, "updateUIWithCultureData": updateUIWithCultureData, "colorMapMarker": colorMapMarker, "addMarkerAtGMap": addMarkerAtGMap, "removeMarkerAtGMap": removeMarkerAtGMap, "mapInfoMarkerAddressFormatter": mapInfoMarkerAddressFormatter, "addInfoMarkerForLocationList": addInfoMarkerForLocationList }; }; return { getInstance: function () { if (!instance) { instance = init(); } return instance; } } })(); Gep.Utils.version = "1.0.0"; window.$Utils = Gep.Utils.getInstance(); })(window); String.prototype.format = function () { var args = arguments; var newStr = this; for (i = 0; i < args.length; i++) { newStr = newStr.replace('[' + i + ']', args[i]); } return newStr; };