Permalink
Browse files

Shortened getCategories

  • Loading branch information...
1 parent 40d49e3 commit 2e482377f94af7336403ec0c92a3540cdc9544bc @fb55 fb55 committed Sep 17, 2011
Showing with 14 additions and 22 deletions.
  1. +14 −22 lib/nodepie.js
View
@@ -876,41 +876,33 @@ NodePie.Item.prototype.getCategories = function(){
category = this.element.category || this.element[dcns+":subject"];
- if(!category){
- return false;
- }
+ if(!category){ }
- if(typeof category === "string"){
- category = category.trim();
- return category && [this._formatStr(category)];
- }
-
- if(typeof category === "object" && !Array.isArray(category)){
- category = category.term || category.$t;
- if(!category){
- return false;
- }
- category = category.trim();
- return category && [this._formatStr(category)];
+ else if(typeof category === "string"){
+ if(category = category.trim())
+ return [this._formatStr(category)];
}
- if(Array.isArray(category)){
+ else if(Array.isArray(category)){
for(var i=0, len = category.length; i<len; i++){
if(typeof category[i] === "string"){
- if(category[i].trim()){
+ if(category[i].trim())
categories.push(category[i].trim());
- }
- continue;
}
- if(typeof category[i] === "object"){
- if((category[i].term || category[i].$t || "").trim()){
+ else if(typeof category[i] === "object"){
+ if((category[i].term || category[i].$t || "").trim())
categories.push(this._formatStr((category[i].term || category[i].$t || "").trim()));
- }
}
}
return categories.length && categories;
}
+ else if(typeof category === "object"){
+ category = category.term || category.$t;
+ if(category && (category = category.trim()) )
+ return [this._formatStr(category)];
+ }
+
return false;
};

0 comments on commit 2e48237

Please sign in to comment.