Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Shortened getCategories

  • Loading branch information...
commit 2e482377f94af7336403ec0c92a3540cdc9544bc 1 parent 40d49e3
@fb55 fb55 authored
Showing with 14 additions and 22 deletions.
  1. +14 −22 lib/nodepie.js
View
36 lib/nodepie.js
@@ -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;
};
Please sign in to comment.
Something went wrong with that request. Please try again.