Created
September 8, 2010 08:56
-
-
Save siculars/569852 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
util = { | |
getTags: function() { | |
var ret = ["one","two","three"]; | |
return ret.sort(); | |
}, | |
//check a tag against the main tag list | |
checkSubmittedTag: function(submittedTag) { | |
sys.log('checking : ' + submittedTag); | |
var origTags = JSON.stringify(this.getTags()); | |
//ya ya i should do a loop but whatev | |
if ( origTags.search(submittedTag) > 0 ) return 1 ; | |
return 0 ; | |
}, | |
//return an array of tags | |
getFilterTags: function(req) { | |
var submittedTags = JSON.parse(qs.parse(url.parse(req.url).query).tags); | |
var vettedSubmittedTags = []; | |
sys.log("getfiltertags. submitted tags: " + submittedTags + " , " + submittedTags.length); | |
for (i = 0 ; i < submittedTags.length ; i++){ | |
if (this.checkSubmittedTag(submittedTags[i])) vettedSubmittedTags.push(submittedTags[i]) ; | |
} | |
sys.log('getfiltertags. vetted tags: ' + vettedSubmittedTags + ' , length : ' + vettedSubmittedTags.length); | |
return vettedSubmittedTags ; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment