kamijoutouma

Untitled

Apr 28th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ch_room.js
  2. Room.prototype.parseFont = function(string) {
  3.     var self = this;
  4.     var all = string.split(string.match(/<font/i));
  5.     all.shift();
  6.     _.each(all, function(text){
  7.         var color = text.match(/color="#(.*?)"/);
  8.         color = color != undefined ? color[1] :self._settings.textColor;
  9.         var size = text.match(/size="(.*?)"/);
  10.         size = size != undefined ? size[1] :self._settings.textSize;
  11.         var face = text.match(/face="(.*?)"/);
  12.         face = face != undefined ? face[1] :self._settings.textFont;
  13.         string = string.replace(/<font(.*?)>/, '<f x'+size+color+'="'+face+'">');
  14.         string = string.replace(/<\/font>/g, '</f>');
  15.     });
  16.     return string;
  17. }
  18.  
  19. Room.prototype.message = function(body) {
  20.    
  21.     if(this._writeLock || !body) return;
  22.    
  23.     var self = this;
  24.    
  25.     if(_.isArray(body)){
  26.         //Multi-line message
  27.         var output = _.reduce(body, function(output, msg, i){
  28.             return output += self.font() + String(msg) + '</f></p>' + (i == body.length-1 ? '' : '<p>');
  29.         }, '');
  30.        
  31.         output = output.replace(/(\n\r|\r\n|\n|\r|\0)/g, '<br/>');
  32.         _.each(output.match(/.{1,2950}/gm), function(msg){
  33.             self.write('bmsg', 'l33t', '<n'+self._settings.nameColor+'/>'+self.parseFont(msg));
  34.         });
  35.     }
  36.     else{
  37.         body = String(body).replace(/(\n\r|\r\n|\n|\r|\0)/g, '<br/>');
  38.         _.each(body.match(/.{1,2950}/gm), function(msg){
  39.             self.write('bmsg', 'l33t', '<n'+self._settings.nameColor+'/>' + self.font() + self.parseFont(msg));
  40.         });
  41.     }
  42. };
  43.  
  44. ch_pm.js
  45. PM.prototype.message = function(name, body) {
  46.     var self = this;
  47.     if(this._writeLock || !name || !body) return;
  48.    
  49.     if(_.isArray(body)){
  50.         var output = '';
  51.         for(var i=0; i<body.length; i++){
  52.             output += '<P>'+this.font()+body[i]+'</g></P>';
  53.         }
  54.         this.write(['msg', name, '<n'+this._settings.nameColor+'/><m v="1">'+self.parseFont(output)+'</m>']);
  55.         console.log('[PM][WRITE]['+name+'] '+body.join('\n'));
  56.     }else{
  57.         this.write(['msg', name, '<n'+this._settings.nameColor+'/><m v="1">'+this.font()+self.parseFont(body)+'</g></m>']);
  58.         console.log('[PM][WRITE]['+name+'] '+body);
  59.     }
  60. };
  61.  
  62. PM.prototype.parseFont = function(string) {
  63.     var self = this;
  64.     var all = string.split(string.match(/<font/i));
  65.     all.shift();
  66.     _.each(all, function(text){
  67.         var color = text.match(/color="#(.*?)"/);
  68.         color = color != undefined ? color[1] :self._settings.textColor;
  69.         var size = text.match(/size="(.*?)"/);
  70.         size = size != undefined ? size[1] :self._settings.textSize;
  71.         var face = text.match(/face="(.*?)"/);
  72.         face = face != undefined ? face[1] :self._settings.textFont;
  73.         string = string.replace(/<font(.*?)>/, '<g x'+size+'s'+color+'="'+face+'">');
  74.         string = string.replace(/<\/font>/g, '</g>');
  75.     });
  76.     return string;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment