Last active
December 17, 2015 12:34
-
-
Save beckettkev/d562d697ad6a03db4510 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( function ( workspace, $ ) { | |
... | |
workspace.Mapping = { | |
... | |
/* | |
Meanwhile - underneath the community mapping | |
The Helper Methods (FindCategoryMatch and Category) to check our refinement managed property value against our array mappings (SPSiteURL) | |
*/ | |
FindCategoryMatch: function (arr, key, url, remember) { | |
var e = 0; | |
var valid = arr.some(function (regexp, index, array) { | |
e = index; | |
return regexp.test(url); | |
}); | |
var label = key !== 'Community' ? workspace.Mapping[key].Mappings[e].Label : workspace.Mapping[key].Mappings[0].Label; | |
var match = { 'Valid': valid, 'Index': e, 'Url': url, 'Name': valid ? label : '' }; | |
//add the new match into the refinement match array if a match is found | |
if (valid && remember) { | |
matches.push(match); | |
} | |
return match; | |
}, | |
Category: function (arr, key, url, remember) { | |
var match, num; | |
//check to see if we have any matches, if not gather this one and store it in our matches object (in case we need to use the info again) | |
if (matches.length === 0) { | |
match = workspace.Mapping.FindCategoryMatch(arr, key, url, remember); | |
} else { | |
//check if we have this information already and serve it up if we do (otherwise gather it) | |
if (matches.some(function (e, index, array) { num = index; return e.Url === url })) { | |
match = matches[num]; | |
} else { | |
match = workspace.Mapping.FindCategoryMatch(arr, key, url, remember); | |
} | |
} | |
return match; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment