SkyzohKeyseparate code
050b8e1 (parent 8a4abc3)7/25/2016, 3:44:32 PM
separate code
+ 24
- 21
app/controllers/renderer.js
@@ -9,30 +9,10 @@ const emojione = require('emojione');
 const dateformat = require('date-format');
 
 const ToxStatus = require('./ToxStatus.js');
+const stringHelper = require('../helpers/string.js');
 
 console.log("renderer", __dirname);
 
-/**
-* HTML escaping.
-**/
-String.prototype.escape = function() {
-  var tagsToReplace = {
-    '&': '&',
-    '<': '&lt;',
-    '>': '&gt;'
-  };
-  return this.replace(/[&<>]/g, function(tag) {
-    return tagsToReplace[tag] || tag;
-  });
-};
-/**
-* Newline (\r\n) to <br> or <br/> if xhtml.
-**/
-String.prototype.nl2br = function (is_xhtml) {
-  var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br ' + '/>' : '<br>';
-  return this.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
-};
-
 /**
 * Our Tox class.
 **/

new file
app/helpers/string.js
@@ -0,0 +1,23 @@
+(function () {
+/**
+* HTML escaping.
+**/
+String.prototype.escape = function() {
+  var tagsToReplace = {
+    '&': '&amp;',
+    '<': '&lt;',
+    '>': '&gt;'
+  };
+  return this.replace(/[&<>]/g, function(tag) {
+    return tagsToReplace[tag] || tag;
+  });
+};
+/**
+* Newline (\r\n) to <br> or <br/> if xhtml.
+**/
+String.prototype.nl2br = function (is_xhtml) {
+  var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br ' + '/>' : '<br>';
+  return this.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
+};
+
+})();