Skip to content

Instantly share code, notes, and snippets.

@fpillet
Forked from anonymous/MyBuffer.js
Created November 2, 2011 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fpillet/1333248 to your computer and use it in GitHub Desktop.
Save fpillet/1333248 to your computer and use it in GitHub Desktop.
Array to String
var MyModule = {
var self = {
buffer : "",
defaultSize : 20,
carriageReturn : "99"
},
setup : function() {
// we could remove this function if there is nothing to do
},
////////////////////////////////myModule methods///////////////////////////
//adds an item into the buffer with perameter: matchedstring from my regex
addItem : function(feedbackItem, matchedString) {
if (matchedString == self.carriageReturn) {
CF.setJoin("s55", self.buffer);
self.buffer = "";
} else {
self.buffer = self.buffer + String.fromCharCode(parseInt(matchedString, 10));
}
CF.log("new buffer element entered:" + matchedString);
},
getNoItems : function() {
return self.buffer.length;
},
//flushes the buffer
makeEmpty : function(){
self.buffer = "";
CF.log("Buffer has been flushed");
}
};
////////////////////////////////Main method///////////////////////////
CF.userMain = function() {
CF.watch(CF.FeedbackMatchedEvent, "GlobalCache", "My_IP", MyModule.addItem);
};
////////////////////////////////push module function///////////////////////////
CF.modules.push({
name : "My module",
setup : MyModule.setup,
object : MyModule
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment