var webDomain = location.protocol+'//' + window.location.hostname; var relativeEvolveSite='/pr'; var evolveSite = webDomain + relativeEvolveSite; //evolveSite = evolveSite.substring(0, evolveSite.length - 1); var evolvePagesSite = webDomain + '/lib/pro'; var listId; var viewId; try { var sourceUrl = $().SPServices.SPGetQueryString()['Source'].toLowerCase(); } catch (e) { if (document.referrer.toLowerCase() === undefined) { var sourceUrl = evolveSite; } else { var sourceUrl = document.referrer.toLowerCase(); } } $.fn.SPServices.SPGetHashQueryString = function () { var i; var queryStringVals = {}; var qs = location.href.substring(location.href.indexOf("#") + 1); var args = qs.split("&"); for (i = 0; i < args.length; i++) { var rxQS = /^([^=]+)=(.*)/i, matches = rxQS.exec(args[i]); if (rxQS.test(location.href)) { if (matches !== null && matches.length > 2) { queryStringVals[matches[1]] = unescape(matches[2]).replace('+', ' '); } } } return queryStringVals; };// End of function SPGetQueryString //global vars with query strings var qString = $().SPServices.SPGetQueryString(); var hashString = $().SPServices.SPGetHashQueryString(); function getPages(next) { $(".footerImage.pageMySite").offset({top:0}); $(window).unbind("scroll"); var searchString = ''; //Show loading image $("#showMore").html(''); //empty results table if next is not set if (next == undefined) { $("#pages").html(''); } var caml = $("#hiddenFilterProcess").val(); //alert(caml); //get process value if set and get name of site. Set value on tab //alert(caml+'---'+evolveSite); if (caml != evolveSite) { searchString = searchString + 'Process=' + caml + '&'; if ($("input[name='level4Sites']:checked").val() == caml) { var filterVal = $("input[name='level4Sites']:checked").parent().next().text(); } else { if ($("input[name='level3Sites']:checked").val() == caml) { filterVal = $("input[name='level3Sites']:checked").parent().next().text(); } else { if ($("input[name='level2Sites']:checked").val() == caml) { filterVal = $("input[name='level2Sites']:checked").parent().next().text(); } else { if ($("input[name='level1Sites']:checked").val() == caml) { filterVal = $("input[name='level1Sites']:checked").parent().next().text(); //alert(filterVal); } } } } if (filterVal != undefined) { setItemsSelected('Process', filterVal); } } else { removeItemsSelected('Process'); } //alert(caml); caml = '' + caml + '' + caml + '/'; //alert(caml); if ($("#freeText").val() != '' && $("#freeText").val() != undefined) { var searchVal = $("#freeText").val().replace(/,/g, " "); var searchVal = searchVal.replace(/;/g, " "); var searchVal = searchVal.replace(/ /g, " "); var searchVal = searchVal.replace(/'/g, "’"); var searchQString = new Array(); searchQString = searchVal.split(' '); //var searchCaml=''+searchQString[0]+''+searchQString[0]+''+searchQString[0]+''; var searchCaml = '' + searchQString[0] + '' + searchQString[0] + '' + searchQString[0] + '' + searchQString[0] + ''; for (var i = 1; i < searchQString.length; i++) { searchCaml = '' + searchCaml + '' + searchQString[i] + '' + searchQString[i] + '' + searchQString[i] + ''; } //alert(searchCaml); caml = '' + caml + '' + searchCaml + ''; searchString = searchString + 'q=' + $("#freeText").val() + '&'; } //alert(caml); if ($("input[name='optionValContent_x0020_Sub_x0020_Type']:checked").val() != '' && $("input[name='optionValContent_x0020_Sub_x0020_Type']:checked").val() != undefined) { caml = '' + caml + '' + $("input[name='optionValContent_x0020_Sub_x0020_Type']:checked").val() + ''; setItemsSelected('Content_x0020_Sub_x0020_Type', $("input[name='optionValContent_x0020_Sub_x0020_Type']:checked").val()); searchString = searchString + 'Content_x0020_Sub_x0020_Type=' + $("input[name='optionValContent_x0020_Sub_x0020_Type']:checked").val() + '&'; } else { removeItemsSelected('Content_x0020_Sub_x0020_Type'); } if ($("input[name='optionValVariation']:checked").val() != '' && $("input[name='optionValVariation']:checked").val() != undefined) { caml = '' + caml + 'Global' + $("input[name='optionValVariation']:checked").val() + ''; setItemsSelected('Variation', $("input[name='optionValVariation']:checked").val()); searchString = searchString + 'Variation=' + $("input[name='optionValVariation']:checked").val() + '&'; } else { removeItemsSelected('Variation'); } if ($("input[name='optionValLan']:checked").val() != '' && $("input[name='optionValLan']:checked").val() != undefined) { caml = '' + caml + '' + $("input[name='optionValLan']:checked").val() + ''; setItemsSelected('Lan', $("input[name='optionValLan']:checked").val()); searchString = searchString + 'Lan=' + $("input[name='optionValLan']:checked").val() + '&'; } else { removeItemsSelected('Lan'); } //Set hash search string in url field if (searchString != '') { document.location.hash = searchString; } //alert(caml); try { next = next.replace(/&/g, '&').replace(/"/g, '"').replace(//g, '>'); } catch (e) { } //$("#debug").val(caml); //get results /*$("body").prepend(''); $("#asa").val(caml);*/ //alert(caml); $().SPServices({ webURL: evolvePagesSite, operation: "GetListItems", listName: 'Pages', CAMLViewFields: '', CAMLQuery: '' + caml + '', CAMLRowLimit: "20", CAMLQueryOptions: 'FALSE', // queryOptions completefunc: function (xData, Status) { //alert(xData.responseText); var evolveRowClass = 'evolveNormalRow'; //Show "Show More" link if more rows exist if ($(xData.responseXML).find("[nodeName='rs:data']").attr("ListItemCollectionPositionNext") != undefined) { //$("#showMore").html('Show More'); $(window).scroll(function () { var checkVal = $(document).height() - $(window).height() - 450; if ($(window).scrollTop() > checkVal) { $(window).unbind("scroll"); getPages($(xData.responseXML).find("[nodeName='rs:data']").attr("ListItemCollectionPositionNext")) return false; } }); } else { $(window).unbind("scroll"); } //Print Rows $(xData.responseXML).find("[nodeName='z:row']").each(function () { if ($(this).attr('ows_DocIcon') == 'aspx') { var docIcon = 'htm'; var relVal = 'rel=#overlay'; } else { var docIcon = $(this).attr('ows_DocIcon'); var contentUrl = $(this).attr('ows_ServerUrl'); } //Change link if type Evolve Link if ($(this).attr('ows_ContentType') == "EvolveLink"&&$(this).attr('ows_Content_x0020_Sub_x0020_Type')!="Process Overview") { var contentUrl = $(this).attr('ows_Link'); var newWindow = 'target="_blank"'; } else { var contentUrl = $(this).attr('ows_ServerUrl'); var newWindow = ''; } var docId = $(this).attr('ows_ID'); //alert($(this).attr('ows_TranslationOf')); $("#pages").append('' + $(this).attr('ows_Title') + '' + mdTrans($(this).attr('ows_Content_x0020_Sub_x0020_Type')) + '' + $(this).attr('ows_Lan').substring($(this).attr('ows_Lan').indexOf('#') + 1) + ''); if (evolveRowClass == 'evolveNormalRow') { evolveRowClass = 'evolveAlternativeRow'; } else { evolveRowClass = 'evolveNormalRow'; } }); $("#pages img[title]").tooltip({ tipClass: 'tooltipInfo', position: "center left", onBeforeShow: function () { //alert(this.getTrigger().parent().parent().text()); //alert(this.getTip().html()); var parentRow = this.getTrigger().parent().parent(); //alert(parentRow.find("td:first-child").html()); //Find Title if (parentRow.find("td:first-child").text() == '') { var infoTitle = parentRow.find("td:nth-child(2)").text(); } else { var infoTitle = parentRow.text(); } var infoHref = '/lib/Style Library/LOMFiles/RedirectInfo.aspx?ID=' + parentRow.find("a:nth-child(1)").attr("itemid"); this.getTip().html('' + infoTitle + ' | '+cpmfTrans.Properties+'

' + this.getTrigger().attr("rel")) + '

'; } }).dynamic({ left: {} }); //remove loading icon $("#showMore").html(''); } }); //return total results $().SPServices({ webURL: evolvePagesSite, operation: "GetListItems", listName: 'Pages', CAMLQuery: '' + caml + '', CAMLQueryOptions: 'FALSE', // queryOptions completefunc: function (xData, Status) { $("#countResults").text($(xData.responseXML).find("[nodeName='rs:data']").attr("ItemCount")); } }); } function getInitial(level, siteUrl, setByQueryString) { //reset all process levels above current if not first if (level != 1) { $("#hiddenFilterProcess").val(siteUrl); for (var i = level; i <= 4; i++) { $("#processLevel" + i).html(""); } } //Main LOM if (containsSting === undefined || containsSting == false) { try { if (hashString['Process'].toLowerCase().indexOf('/pr/') > 0 || hashString['Process'].toLowerCase() == '/pr') { var containsSting = true; } else { var containsString = false; } } catch (e) { var containsSting = false; } //alert(sourceUrl+'-'+level+'-'+siteUrl); if ((sourceUrl.indexOf('/pr/') > 0 || containsSting || sourceUrl == '' || sourceUrl == undefined) && (level == 1 || (level == 2 && siteUrl == relativeEvolveSite))) { siteUrl = '/pr'; $("#hiddenFilterProcess").val("/pr"); $("#level1Sites:first").val("/pr"); if (level == 2) { return; } } } //alert(siteUrl+'--'+evolveSite); //load sites if (siteUrl != evolveSite) { $().SPServices({ webURL: webDomain+''+siteUrl, operation: "GetWebCollection", completefunc: function (xData, Status) { var output = 'Processes
'; $("#loadingProcess").remove(); $(xData.responseXML).find("[nodeName='Web']").each(function () { var nextLevel = level + 1; var thisRelativeSite=$(this).attr('Url').substring(webDomain.length); //alert($(this).attr('Title') +': '+thisRelativeSite); $("#processLevel" + level).append('
'); }); //Set value from query string after all i tems printed if (hashString['Process'] != undefined && (level == 1 || setByQueryString != undefined)) { var queryStringVal = hashString['Process']; //alert(queryStringVal); /*alert(siteUrl); if (siteUrl.substring(0, 4) != 'http') { siteUrl = webDomain.toLowerCase() + siteUrl; }*/ //for(var i=level; var processes = queryStringVal.replace(siteUrl + '/', ''); //alert(processes); if (processes == queryStringVal) { nextSiteUrl = processes; } else { if (processes.indexOf('/') > 0) { var nextSiteUrl = siteUrl + '/' + processes.substring(0, processes.indexOf('/')); } else { if (processes != '') { var nextSiteUrl = siteUrl + '/' + processes; } } } //alert(nextSiteUrl); $("[name='level" + level + "Sites']").filter("[value='" + nextSiteUrl + "']").attr("checked", "checked"); //alert(queryStringVal.toLowerCase() +'!='+ siteUrl.toLowerCase() +' && '+ queryStringVal.toLowerCase() +'!='+webDomain.toLowerCase() + '' + siteUrl.toLowerCase()); if (queryStringVal.toLowerCase() != siteUrl.toLowerCase() && queryStringVal.toLowerCase() != webDomain.toLowerCase() + '' + siteUrl.toLowerCase()) { setItemsSelected('Process', $("input[name='level" + level + "Sites']:checked").parent().next().text()); //alert(queryStringVal.toLowerCase()+'--'+nextSiteUrl); getInitial(level + 1, nextSiteUrl, true); //alert(queryStringVal+'\n'+webDomain.toLowerCase()+'\n'+siteUrl); } else { loadWhenReady(); } //setItemsSelected('Process', queryStringVal); //var presetValue=hashString[internalName]; } else { loadWhenReady(); } } }); } } function getAjaxFilter(filterName, internalName) { //alert(hashString['qq']); //alert(escape(viewId)); //document.location.hash = $("input[name='optionValContent_x0020_Sub_x0020_Type']:checked").val(); //get unique values from filter.aspx $.ajax({ url: evolvePagesSite + '/_layouts/filter.aspx?ListId=' + escape(listId) + '&FieldInternalName=' + internalName + '&ViewId=' + escape(viewId) + '&FilterOnly=1&Filter=1', success: function (data) { //place content in the hiddenFilter div $('#hiddenFilter' + internalName).html(data); try { //count values to find where to change column var changeRow = Math.ceil($('#hiddenFilter' + internalName).find("SELECT").children('option').length / 4); var i = -1; var column = 1; //find values and set values in div $('#hiddenFilter' + internalName).find("option").each(function () { if ($(this).text() != 'Global' && $(this).text() != '(Empty)') { i++; //alert(changeRow); if (i == changeRow) { i = 0; column++; } //don't display values Global and Empty $("#" + internalName + "Level" + column).append('
'); } }); //Set value from query string after all items printed if (hashString[internalName] != undefined) { var queryStringVal = hashString[internalName]; //alert(queryStringVal); $("[name=optionVal" + internalName + "]").filter("[value='" + queryStringVal + "']").attr("checked", "checked"); setItemsSelected(internalName, queryStringVal); //alert(internalName); loadWhenReady(); //var presetValue=hashString[internalName]; } //If variation check and set initial value from country variation cookie if (internalName == 'Variation') { if ($.cookie('VariationCookie') == undefined) { //alert('Country not set. Go to a LOM page to automatically set'); } else { //Set by cookie if #-query string not already set //if(location.href.indexOf('#')<0){ if (hashString['Variation'] === undefined) { $("[name=optionValVariation]").filter("[value='" + $.cookie('VariationCookie') + "']").attr("checked", "checked"); setItemsSelected('Variation', $.cookie('VariationCookie')); //if initial ?-query string set do search and set results if ($().SPServices.SPGetQueryString()['q'] != undefined) { $("#freeText").val($().SPServices.SPGetQueryString()['q']); //getPages(); } loadWhenReady(); //hide rotating image $("#showMore").html(''); } } } } catch (e) { } /*try{ var queryStringVals = $().SPServices.SPGetQueryString(); $("#filterField"+internalName).val(unescape(queryStringVals[filterName].replace(/\+/g, ' '))); } catch(e){ }*/ } }); } function checkAllFiltersSet() { } function setItemsSelected(filterType, filterValue) { $("#tab" + filterType + " div:nth-child(2)").html('Remove ' + mdTrans(filterValue) + ''); } function removeItemsSelected(filterType) { $("#tab" + filterType + " div:nth-child(2)").html(' All'); } function removeFilter(filterType) { if (filterType == 'Process') { getInitial(2, relativeEvolveSite); getPages(); $("#hiddenFilterProcess").val(relativeEvolveSite); //$("[name='level1Sites']").filter("[value='"+evolveSite+"']").attr("checked","checked"); $("#level1Sites:first").attr("checked", "checked"); $("#level1Sites:first").attr("checked", ""); removeItemsSelected('Process'); } else { $("[name=optionVal" + filterType + "]").filter("[value='']").attr("checked", "checked"); getPages(); } } function toggleBrowseDiv(filterOption) { $("#tabContent_x0020_Sub_x0020_Type").removeClass('on'); $("#tabLan").removeClass('on'); $("#tabProcess").removeClass('on'); $("#tabVariation").removeClass('on'); $("#tab" + filterOption).addClass('on'); $("#optionContent_x0020_Sub_x0020_Type").hide(); $("#optionLan").hide(); $("#optionProcess").hide(); $("#optionVariation").hide(); $("#option" + filterOption).show(); } var asyncCalls = 0; function initCountArgs() { //if initial ?-query string set do search and set results var qs = location.href.substring(location.href.indexOf("#") + 1); var args = qs.split("&"); asyncCalls = args.length - 1; if (asyncCalls == 0 && qs.length > 0) { asyncCalls = 1; } //If Source is set but not process wait for one more asynch call if (qString['Source'] !== undefined && hashString['Process'] === undefined) { asyncCalls++; } //if Variaton is not set, wait for one more asynch call if (hashString['Variation'] === undefined) { asyncCalls++; } //alert(asyncCalls); //run a search if search string q is set after variation is set try { if (hashString['q'] != undefined) { //alert(asyncCalls); //asyncCalls++; $("#freeText").val(hashString['q']); loadWhenReady(); //getPages(); } } catch (e) { } } function loadWhenReady() { asyncCalls--; //alert(asyncCalls); if (asyncCalls == 0) { getPages(); } } function fullTextSearch() { var freeText = $("#freeText").val(); var drillDown = ''; if ($("input[name='optionValVariation']:checked").val() != '' && $("input[name='optionValVariation']:checked").val() != undefined) { drillDown += 'country%3D%22' + $("input[name='optionValVariation']:checked").val() + '%22' } if ($("input[name='optionValContent_x0020_Sub_x0020_Type']:checked").val() != '' && $("input[name='optionValContent_x0020_Sub_x0020_Type']:checked").val() != undefined) { drillDown += '%20type%3D%22' + $("input[name='optionValContent_x0020_Sub_x0020_Type']:checked").val() + '%22'; } if (drillDown != '') { drillDown = '&r=' + drillDown; } window.open('http://search.global.logica.com/Pages/results.aspx?k=' + freeText + '%20%28scope%3A%22LOM%22%29' + drillDown); //http://search.global.logica.com/Pages/results.aspx?k=test%20%28scope%3A%22LOM%22%29&r=country%3D%22Sweden%22%20type%3D%22Template%22 } //Dropdown translations function mdTrans(cstValue){ //if english language setting or if translation doesn't exist, use standard value if($("html").attr("lang").substring(0,2)=='en'||cpmfTrans["MD"+cstValue.replace(/ /g, '')]===undefined||cpmfTrans["MD"+cstValue.replace(/ /g, '')]==""){ return cstValue; } else{ return cpmfTrans["MD"+cstValue.replace(/ /g, '')]; } } function backToProcess(){ window.location=sourceUrl; } $(document).ready(function () { //set backbutton language $("#backbutton").val(cpmfTrans.Back); //fix padding in search result wp $("#evolveSearchResults").parent().css('padding', '0px 0px 0px 0px'); //set initial values //$("[name='level1Sites']").filter("[value='"+evolveSite+"']").attr("checked","checked"); //rotating image while loading $("#showMore").html(''); //French translation of web part header if($("html").attr("lang").substring(0,2)=='fr'&&cpmfTrans["Searchresults"]!==undefined){ $("#WebPartTitleWPQ4").find("span:first").text(cpmfTrans["Searchresults"]); console.log(cpmfTrans["Searchresults"]); } $("#level1Sites:first").attr("checked", "checked"); $("#hiddenFilterProcess").val(relativeEvolveSite); initCountArgs(); getInitial(1, relativeEvolveSite + ''); //get ListId and viewId used for the filter.aspx in getAjaxFilter $().SPServices({ webURL: evolvePagesSite, operation: "GetListAndView", listName: "Pages", completefunc: function (xData, Status) { listId = $(xData.responseXML).find("List").attr("ID"); viewId = $(xData.responseXML).find("View").attr("Name"); getAjaxFilter('Content Sub Type', 'Content_x0020_Sub_x0020_Type'); getAjaxFilter('Lan', 'Lan'); getAjaxFilter('Variation', 'Variation'); } }); });