Created
February 13, 2013 14:48
-
-
Save kmod-midori/4945075 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
var sm=function(s){ | |
if(typeof s !='object'||s==null)var s=[]; | |
if(typeof s.length =='undefined')s=[s]; | |
return { | |
segments:s, | |
addText:function(text){ | |
this.segments.push({ | |
text:text, | |
type:'TEXT' | |
}); | |
}, | |
addMention:function(name,id){ | |
this.segments.push({ | |
text:'+'+name, | |
type:'USER_MENTION', | |
user:{ | |
name:name, | |
userId:id | |
} | |
}); | |
}, | |
pop:function(time){ | |
if(typeof time =='undefined')var time=1 | |
if(isNaN(parseInt(time)))time=1; | |
var i=0; | |
while(i<time){ | |
this.segments.pop(); | |
i++; | |
} | |
} | |
}; | |
}; | |
module.exports=sm; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment