factor out (un)dasherize into utils
This commit is contained in:
@ -47,21 +47,13 @@ var R = require('ramda'),
|
|||||||
var challengeMapWithNames = utils.getChallengeMapWithNames();
|
var challengeMapWithNames = utils.getChallengeMapWithNames();
|
||||||
var challengeMapWithIds = utils.getChallengeMapWithIds();
|
var challengeMapWithIds = utils.getChallengeMapWithIds();
|
||||||
var challengeMapWithDashedNames = utils.getChallengeMapWithDashedNames();
|
var challengeMapWithDashedNames = utils.getChallengeMapWithDashedNames();
|
||||||
|
var challangesRegex = /^(bonfire|waypoint|zipline|basejump)/i;
|
||||||
|
|
||||||
|
var dasherize = utils.dasherize;
|
||||||
|
var unDasherize = utils.unDashedName;
|
||||||
|
|
||||||
var getMDNLinks = utils.getMDNLinks;
|
var getMDNLinks = utils.getMDNLinks;
|
||||||
|
|
||||||
var challangesRegex = /^(bonfire|waypoint|zipline|basejump)/i;
|
|
||||||
function dasherize(name) {
|
|
||||||
return ('' + name)
|
|
||||||
.toLowerCase()
|
|
||||||
.replace(/\s/g, '-')
|
|
||||||
.replace(/[^a-z0-9\-\.]/gi, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
function unDasherize(name) {
|
|
||||||
return ('' + name).replace(/\-/g, ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateUserProgress(user, challengeId, completedChallenge) {
|
function updateUserProgress(user, challengeId, completedChallenge) {
|
||||||
var index = user.uncompletedChallenges.indexOf(challengeId);
|
var index = user.uncompletedChallenges.indexOf(challengeId);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
|
@ -60,6 +60,17 @@ Array.zip = function(left, right, combinerFunction) {
|
|||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
dasherize: function dasherize(name) {
|
||||||
|
return ('' + name)
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/\s/g, '-')
|
||||||
|
.replace(/[^a-z0-9\-\.]/gi, '');
|
||||||
|
},
|
||||||
|
|
||||||
|
unDasherize: function unDasherize(name) {
|
||||||
|
return ('' + name).replace(/\-/g, ' ');
|
||||||
|
},
|
||||||
|
|
||||||
getChallengeMapForDisplay: function () {
|
getChallengeMapForDisplay: function () {
|
||||||
if (!challengeMapForDisplay) {
|
if (!challengeMapForDisplay) {
|
||||||
challengeMapForDisplay = {};
|
challengeMapForDisplay = {};
|
||||||
|
Reference in New Issue
Block a user