-
-
Save fpillet/1333248 to your computer and use it in GitHub Desktop.
Array to String
This file contains hidden or 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 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