Fix incorrect JSON file

The extension of the file modules/UI/side_pannels/chat/smileys.json
suggests that the format of the file is JSON. However, it contains
JavaScript RegExp instances which do not represent valid JSON. Such
discrepancies between file extension and format cause failures in
certain tools such as Webpack. Convert the file (both extension and
format) into a valid ES2015 module.
This commit is contained in:
Lyubomir Marinov 2016-09-19 12:48:38 -05:00
parent 2da3373e10
commit 2ff77676e2
4 changed files with 53 additions and 55 deletions

View File

@ -8,7 +8,7 @@ import VideoLayout from "../../videolayout/VideoLayout";
import UIUtil from '../../util/UIUtil';
import UIEvents from '../../../../service/UI/UIEvents';
var smileys = require("./smileys.json").smileys;
import { smileys } from './smileys';
var unreadMessages = 0;

View File

@ -1,5 +1,5 @@
/* jshint -W101 */
var Smileys = require("./smileys.json");
import { regexes } from './smileys';
/**
* Processes links and smileys in "body"
@ -29,7 +29,7 @@ export function linkify(inputText) {
replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" target="_blank">$2</a>');
//Change email addresses to mailto:: links.
//Change email addresses to mailto: links.
replacePattern3 = /(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;
replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');
@ -44,10 +44,9 @@ function smilify(body) {
return body;
}
var regexs = Smileys.regexs;
for(var smiley in regexs) {
if(regexs.hasOwnProperty(smiley)) {
body = body.replace(regexs[smiley],
for(var smiley in regexes) {
if(regexes.hasOwnProperty(smiley)) {
body = body.replace(regexes[smiley],
'<img class="smiley" src="images/smileys/' + smiley + '.svg">');
}
}

View File

@ -0,0 +1,47 @@
export const smileys = {
smiley1: ":)",
smiley2: ":(",
smiley3: ":D",
smiley4: "(y)",
smiley5: " :P",
smiley6: "(wave)",
smiley7: "(blush)",
smiley8: "(chuckle)",
smiley9: "(shocked)",
smiley10: ":*",
smiley11: "(n)",
smiley12: "(search)",
smiley13: " <3",
smiley14: "(oops)",
smiley15: "(angry)",
smiley16: "(angel)",
smiley17: "(sick)",
smiley18: ";(",
smiley19: "(bomb)",
smiley20: "(clap)",
smiley21: " ;)"
};
export const regexes = {
smiley2: /(:-\(\(|:-\(|:\(\(|:\(|\(sad\))/gi,
smiley3: /(:-\)\)|:\)\)|\(lol\)|:-D|:D)/gi,
smiley1: /(:-\)|:\))/gi,
smiley4: /(\(y\)|\(Y\)|\(ok\))/gi,
smiley5: /(:-P|:P|:-p|:p)/gi,
smiley6: /(\(wave\))/gi,
smiley7: /(\(blush\))/gi,
smiley8: /(\(chuckle\))/gi,
smiley9: /(:-0|\(shocked\))/gi,
smiley10: /(:-\*|:\*|\(kiss\))/gi,
smiley11: /(\(n\))/gi,
smiley12: /(\(search\))/g,
smiley13: /(<3|&lt;3|&amp;lt;3|\(L\)|\(l\)|\(H\)|\(h\))/gi,
smiley14: /(\(oops\))/gi,
smiley15: /(\(angry\))/gi,
smiley16: /(\(angel\))/gi,
smiley17: /(\(sick\))/gi,
smiley18: /(;-\(\(|;\(\(|;-\(|;\(|:"\(|:"-\(|:~-\(|:~\(|\(upset\))/gi,
smiley19: /(\(bomb\))/gi,
smiley20: /(\(clap\))/gi,
smiley21: /(;-\)|;\)|;-\)\)|;\)\)|;-D|;D|\(wink\))/gi
};

View File

@ -1,48 +0,0 @@
{
"smileys": {
"smiley1": ":)",
"smiley2": ":(",
"smiley3": ":D",
"smiley4": "(y)",
"smiley5": " :P",
"smiley6": "(wave)",
"smiley7": "(blush)",
"smiley8": "(chuckle)",
"smiley9": "(shocked)",
"smiley10": ":*",
"smiley11": "(n)",
"smiley12": "(search)",
"smiley13": " <3",
"smiley14": "(oops)",
"smiley15": "(angry)",
"smiley16": "(angel)",
"smiley17": "(sick)",
"smiley18": ";(",
"smiley19": "(bomb)",
"smiley20": "(clap)",
"smiley21": " ;)"
},
"regexs": {
"smiley2": /(:-\(\(|:-\(|:\(\(|:\(|\(sad\))/gi,
"smiley3": /(:-\)\)|:\)\)|\(lol\)|:-D|:D)/gi,
"smiley1": /(:-\)|:\))/gi,
"smiley4": /(\(y\)|\(Y\)|\(ok\))/gi,
"smiley5": /(:-P|:P|:-p|:p)/gi,
"smiley6": /(\(wave\))/gi,
"smiley7": /(\(blush\))/gi,
"smiley8": /(\(chuckle\))/gi,
"smiley9": /(:-0|\(shocked\))/gi,
"smiley10": /(:-\*|:\*|\(kiss\))/gi,
"smiley11": /(\(n\))/gi,
"smiley12": /(\(search\))/g,
"smiley13": /(<3|&lt;3|&amp;lt;3|\(L\)|\(l\)|\(H\)|\(h\))/gi,
"smiley14": /(\(oops\))/gi,
"smiley15": /(\(angry\))/gi,
"smiley16": /(\(angel\))/gi,
"smiley17": /(\(sick\))/gi,
"smiley18": /(;-\(\(|;\(\(|;-\(|;\(|:"\(|:"-\(|:~-\(|:~\(|\(upset\))/gi,
"smiley19": /(\(bomb\))/gi,
"smiley20": /(\(clap\))/gi,
"smiley21": /(;-\)|;\)|;-\)\)|;\)\)|;-D|;D|\(wink\))/gi
}
}