Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ch_room.js
- Room.prototype.parseFont = function(string) {
- var self = this;
- var all = string.split(string.match(/<font/i));
- all.shift();
- _.each(all, function(text){
- var color = text.match(/color="#(.*?)"/);
- color = color != undefined ? color[1] :self._settings.textColor;
- var size = text.match(/size="(.*?)"/);
- size = size != undefined ? size[1] :self._settings.textSize;
- var face = text.match(/face="(.*?)"/);
- face = face != undefined ? face[1] :self._settings.textFont;
- string = string.replace(/<font(.*?)>/, '<f x'+size+color+'="'+face+'">');
- string = string.replace(/<\/font>/g, '</f>');
- });
- return string;
- }
- Room.prototype.message = function(body) {
- if(this._writeLock || !body) return;
- var self = this;
- if(_.isArray(body)){
- //Multi-line message
- var output = _.reduce(body, function(output, msg, i){
- return output += self.font() + String(msg) + '</f></p>' + (i == body.length-1 ? '' : '<p>');
- }, '');
- output = output.replace(/(\n\r|\r\n|\n|\r|\0)/g, '<br/>');
- _.each(output.match(/.{1,2950}/gm), function(msg){
- self.write('bmsg', 'l33t', '<n'+self._settings.nameColor+'/>'+self.parseFont(msg));
- });
- }
- else{
- body = String(body).replace(/(\n\r|\r\n|\n|\r|\0)/g, '<br/>');
- _.each(body.match(/.{1,2950}/gm), function(msg){
- self.write('bmsg', 'l33t', '<n'+self._settings.nameColor+'/>' + self.font() + self.parseFont(msg));
- });
- }
- };
- ch_pm.js
- PM.prototype.message = function(name, body) {
- var self = this;
- if(this._writeLock || !name || !body) return;
- if(_.isArray(body)){
- var output = '';
- for(var i=0; i<body.length; i++){
- output += '<P>'+this.font()+body[i]+'</g></P>';
- }
- this.write(['msg', name, '<n'+this._settings.nameColor+'/><m v="1">'+self.parseFont(output)+'</m>']);
- console.log('[PM][WRITE]['+name+'] '+body.join('\n'));
- }else{
- this.write(['msg', name, '<n'+this._settings.nameColor+'/><m v="1">'+this.font()+self.parseFont(body)+'</g></m>']);
- console.log('[PM][WRITE]['+name+'] '+body);
- }
- };
- PM.prototype.parseFont = function(string) {
- var self = this;
- var all = string.split(string.match(/<font/i));
- all.shift();
- _.each(all, function(text){
- var color = text.match(/color="#(.*?)"/);
- color = color != undefined ? color[1] :self._settings.textColor;
- var size = text.match(/size="(.*?)"/);
- size = size != undefined ? size[1] :self._settings.textSize;
- var face = text.match(/face="(.*?)"/);
- face = face != undefined ? face[1] :self._settings.textFont;
- string = string.replace(/<font(.*?)>/, '<g x'+size+'s'+color+'="'+face+'">');
- string = string.replace(/<\/font>/g, '</g>');
- });
- return string;
- }
Advertisement
Add Comment
Please, Sign In to add comment