Break really long words

This commit is contained in:
Mattias Erming 2014-09-27 15:01:28 -07:00
parent 3a28afe408
commit e4f100a177
7 changed files with 64 additions and 41 deletions

View File

@ -533,7 +533,9 @@ button {
padding-left: 10px; padding-left: 10px;
padding-right: 6px; padding-right: 6px;
} }
#chat .wrap,
#chat .text a { #chat .text a {
font-style: normal;
word-break: break-all; word-break: break-all;
} }
#chat .self .text { #chat .self .text {

12
client/js/libs.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,53 @@
function escape(text) {
var e = {
"<": "&lt;",
">": "&gt;",
"'": "&#39;"
};
return text.replace(/[<>']/g, function (c) {
return e[c];
});
}
Handlebars.registerHelper(
"parse", function(text) {
text = uri(text);
text = wraplong(text);
return text;
}
);
function uri(text) {
var urls = [];
text = URI.withinString(text, function(url) {
urls.push(url);
return "$(" + (urls.length - 1) + ")";
});
text = escape(text);
for (var i in urls) {
var url = escape(urls[i]);
var replace = url;
if (url.indexOf("javascript:") !== 0) {
replace = "<a href='" + url.replace(/^www/, "//www") + "' target='_blank'>" + url + "</a>";
}
text = text.replace(
"$(" + i + ")", replace
);
}
return text;
}
function wraplong(text) {
var wrap = false;
var split = text.split(" ");
for (var i in split) {
if (split[i].length > 40) {
wrap = true;
}
}
if (wrap) {
return "<i class='wrap'>" + text + "</i>";
} else {
return text;
}
}

View File

@ -1,32 +0,0 @@
function escape(text) {
var e = {
"<": "&lt;",
">": "&gt;",
"'": "&#39;"
};
return text.replace(/[<>']/g, function (c) {
return e[c];
});
}
Handlebars.registerHelper(
"uri", function(text) {
var urls = [];
text = URI.withinString(text, function(url) {
urls.push(url);
return "$(" + (urls.length - 1) + ")";
});
text = escape(text);
for (var i in urls) {
var url = escape(urls[i]);
var replace = url;
if (url.indexOf("javascript:") !== 0) {
replace = "<a href='" + url.replace(/^www/, "//www") + "' target='_blank'>" + url + "</a>";
}
text = text.replace(
"$(" + i + ")", replace
);
}
return text;
}
);

View File

@ -101,7 +101,7 @@ templates['msg'] = template({"1":function(depth0,helpers,partials,data) {
+ "\" class=\"toggle-button\">···</button>\n </div>\n"; + "\" class=\"toggle-button\">···</button>\n </div>\n";
},"8":function(depth0,helpers,partials,data) { },"8":function(depth0,helpers,partials,data) {
var stack1, helperMissing=helpers.helperMissing, buffer = " "; var stack1, helperMissing=helpers.helperMissing, buffer = " ";
stack1 = ((helpers.uri || (depth0 && depth0.uri) || helperMissing).call(depth0, (depth0 != null ? depth0.text : depth0), {"name":"uri","hash":{},"data":data})); stack1 = ((helpers.parse || (depth0 && depth0.parse) || helperMissing).call(depth0, (depth0 != null ? depth0.text : depth0), {"name":"parse","hash":{},"data":data}));
if (stack1 != null) { buffer += stack1; } if (stack1 != null) { buffer += stack1; }
return buffer + "\n"; return buffer + "\n";
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {

View File

@ -15,7 +15,7 @@
<button id="toggle-{{id}}" class="toggle-button">···</button> <button id="toggle-{{id}}" class="toggle-button">···</button>
</div> </div>
{{else}} {{else}}
{{{uri text}}} {{{parse text}}}
{{/equal}} {{/equal}}
</span> </span>
</div> </div>

View File

@ -1,7 +1,7 @@
{ {
"name": "shout", "name": "shout",
"description": "The self-hosted web IRC client", "description": "The self-hosted web IRC client",
"version": "0.37.4", "version": "0.38.0",
"author": "Mattias Erming", "author": "Mattias Erming",
"preferGlobal": true, "preferGlobal": true,
"bin": { "bin": {