diff --git a/.eslintignore b/.eslintignore
index d0fef78b..83b83c3c 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,7 @@
+# built by tools
client/js/libs.min.js
-client/js/libs/**/*.js
client/js/lounge.templates.js
+
+# third party
+client/js/libs/jquery/*.js
+client/js/libs/*.js
diff --git a/client/js/libs/handlebars/diff.js b/client/js/libs/handlebars/diff.js
index 28693c1a..21ee523c 100644
--- a/client/js/libs/handlebars/diff.js
+++ b/client/js/libs/handlebars/diff.js
@@ -2,7 +2,7 @@ var diff;
Handlebars.registerHelper(
"diff", function(a, opt) {
- if (a != diff) {
+ if (a !== diff) {
diff = a;
return opt.fn(this);
} else {
diff --git a/client/js/libs/handlebars/equal.js b/client/js/libs/handlebars/equal.js
index 64c6771d..15fdc033 100644
--- a/client/js/libs/handlebars/equal.js
+++ b/client/js/libs/handlebars/equal.js
@@ -2,7 +2,7 @@ Handlebars.registerHelper(
"equal", function(a, b, opt) {
a = a.toString();
b = b.toString();
- if (a == b) {
+ if (a === b) {
return opt.fn(this);
} else {
return opt.inverse(this);
diff --git a/client/js/libs/handlebars/parse.js b/client/js/libs/handlebars/parse.js
index f73a2879..b7cf242b 100644
--- a/client/js/libs/handlebars/parse.js
+++ b/client/js/libs/handlebars/parse.js
@@ -9,7 +9,7 @@ Handlebars.registerHelper(
);
function uri(text) {
- return URI.withinString(text, function(url, start, end, source) {
+ return window.URI.withinString(text, function(url) {
if (url.indexOf("javascript:") === 0) {
return url;
}
@@ -43,77 +43,82 @@ function channels(text) {
* https://github.com/megawac/irc-style-parser/tree/shout
*/
var styleCheck_Re = /[\x00-\x1F]/,
- back_re = /^([0-9]{1,2})(,([0-9]{1,2}))?/,
- colourKey = "\x03",
- // breaks all open styles ^O (\x0F)
- styleBreak = "\x0F";
+ back_re = /^([0-9]{1,2})(,([0-9]{1,2}))?/,
+ colourKey = "\x03",
+ // breaks all open styles ^O (\x0F)
+ styleBreak = "\x0F";
function styleTemplate(settings) {
- return "" + settings.text + "";
+ return "" + settings.text + "";
}
var styles = [
- ["normal", "\x00", ""], ["underline", "\x1F"],
- ["bold", "\x02"], ["italic", "\x1D"]
+ ["normal", "\x00", ""], ["underline", "\x1F"],
+ ["bold", "\x02"], ["italic", "\x1D"]
].map(function(style) {
- var escaped = encodeURI(style[1]).replace("%", "\\x");
- return {
- name: style[0],
- style: style[2] != null ? style[2] : "irc-" + style[0],
- key: style[1],
- keyregex: new RegExp(escaped + "(.*?)(" + escaped + "|$)")
- };
+ var escaped = encodeURI(style[1]).replace("%", "\\x");
+ return {
+ name: style[0],
+ style: style[2] ? style[2] : "irc-" + style[0],
+ key: style[1],
+ keyregex: new RegExp(escaped + "(.*?)(" + escaped + "|$)")
+ };
});
function colors(line) {
- // http://www.mirc.com/colors.html
- // http://www.aviran.org/stripremove-irc-client-control-characters/
- // https://github.com/perl6/mu/blob/master/examples/rules/Grammar-IRC.pm
- // regexs are cruel to parse this thing
+ // http://www.mirc.com/colors.html
+ // http://www.aviran.org/stripremove-irc-client-control-characters/
+ // https://github.com/perl6/mu/blob/master/examples/rules/Grammar-IRC.pm
+ // regexs are cruel to parse this thing
- // already done?
- if (!styleCheck_Re.test(line)) return line;
+ // already done?
+ if (!styleCheck_Re.test(line)) {
+ return line;
+ }
- // split up by the irc style break character ^O
- if (line.indexOf(styleBreak) >= 0) {
- return line.split(styleBreak).map(colors).join("");
- }
+ // split up by the irc style break character ^O
+ if (line.indexOf(styleBreak) >= 0) {
+ return line.split(styleBreak).map(colors).join("");
+ }
- var result = line;
- var parseArr = result.split(colourKey);
- var text, match, colour, background = "";
- for (var i = 0; i < parseArr.length; i++) {
- text = parseArr[i];
- match = text.match(back_re);
- if (!match) {
- // ^C (no colour) ending. Escape current colour and carry on
- background = "";
- continue;
- }
+ var result = line;
+ var parseArr = result.split(colourKey);
+ var text, match, colour, background = "";
+ for (var i = 0; i < parseArr.length; i++) {
+ text = parseArr[i];
+ match = text.match(back_re);
+ if (!match) {
+ // ^C (no colour) ending. Escape current colour and carry on
+ background = "";
+ continue;
+ }
colour = "irc-fg" + +match[1];
// set the background colour
if (match[3]) {
background = " irc-bg" + +match[3];
}
- // update the parsed text result
- result = result.replace(colourKey + text, styleTemplate({
- style: colour + background,
- text: text.slice(match[0].length)
- }));
- }
+ // update the parsed text result
+ result = result.replace(colourKey + text, styleTemplate({
+ style: colour + background,
+ text: text.slice(match[0].length)
+ }));
+ }
- // Matching styles (italics/bold/underline)
- // if only colours were this easy...
- styles.forEach(function(style) {
- if (result.indexOf(style.key) < 0) return;
- result = result.replace(style.keyregex, function(match, text) {
- return styleTemplate({
- "style": style.style,
- "text": text
- });
- });
- });
+ // Matching styles (italics/bold/underline)
+ // if only colours were this easy...
+ styles.forEach(function(style) {
+ if (result.indexOf(style.key) < 0) {
+ return;
+ }
- return result;
+ result = result.replace(style.keyregex, function(match, text) {
+ return styleTemplate({
+ "style": style.style,
+ "text": text
+ });
+ });
+ });
+
+ return result;
}
diff --git a/client/js/libs/handlebars/stringcolor.js b/client/js/libs/handlebars/stringcolor.js
index 448f478d..0a91a781 100644
--- a/client/js/libs/handlebars/stringcolor.js
+++ b/client/js/libs/handlebars/stringcolor.js
@@ -1,5 +1,5 @@
Handlebars.registerHelper(
"stringcolor", function(str) {
- return stringcolor(str);
+ return window.stringcolor(str);
}
);
diff --git a/client/js/libs/handlebars/users.js b/client/js/libs/handlebars/users.js
index e761326f..1aa6ac08 100644
--- a/client/js/libs/handlebars/users.js
+++ b/client/js/libs/handlebars/users.js
@@ -1,5 +1,5 @@
Handlebars.registerHelper(
"users", function(count) {
- return count + " " + (count == 1 ? "user" : "users");
+ return count + " " + (count === 1 ? "user" : "users");
}
);