mirror of
https://github.com/ianramzy/decentralized-video-chat.git
synced 2024-11-23 18:49:21 +08:00
auto link + remove vertical scrollbar from input
This commit is contained in:
parent
bba20c9533
commit
5df20e1b4c
@ -122,6 +122,7 @@
|
|||||||
|
|
||||||
<script src="/socket.io/socket.io.js"></script>
|
<script src="/socket.io/socket.io.js"></script>
|
||||||
<script src="../js/snackbar.js"></script>
|
<script src="../js/snackbar.js"></script>
|
||||||
|
<script src="../js/autolink.js"></script>
|
||||||
<script src="../js/chat.js"></script>
|
<script src="../js/chat.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -252,7 +252,7 @@ button:hover {
|
|||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
border: none;
|
border: none;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100%);
|
height: calc(100% - 5px);
|
||||||
resize: none;
|
resize: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
background-color: inherit;
|
background-color: inherit;
|
||||||
@ -341,4 +341,8 @@ button:hover {
|
|||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message a {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
/*simple chat*/
|
/*simple chat*/
|
||||||
|
42
public/js/autolink.js
Normal file
42
public/js/autolink.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Generated by CoffeeScript 1.10.0
|
||||||
|
(function () {
|
||||||
|
var autoLink,
|
||||||
|
slice = [].slice;
|
||||||
|
|
||||||
|
autoLink = function () {
|
||||||
|
var callback, k, linkAttributes, option, options, pattern, v;
|
||||||
|
options = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||||
|
pattern = /(^|[\s\n]|<[A-Za-z]*\/?>)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/gi;
|
||||||
|
if (!(options.length > 0)) {
|
||||||
|
return this.replace(pattern, "$1<a target='_blank' href='$2'>$2</a>");
|
||||||
|
}
|
||||||
|
option = options[0];
|
||||||
|
callback = option["callback"];
|
||||||
|
linkAttributes = (function () {
|
||||||
|
var results;
|
||||||
|
results = [];
|
||||||
|
for (k in option) {
|
||||||
|
v = option[k];
|
||||||
|
if (k !== "callback") {
|
||||||
|
results.push(" " + k + "='" + v + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
})().join("");
|
||||||
|
return this.replace(pattern, function (match, space, url) {
|
||||||
|
var link;
|
||||||
|
link =
|
||||||
|
(typeof callback === "function" ? callback(url) : void 0) ||
|
||||||
|
"<a target='_blank' href='" +
|
||||||
|
url +
|
||||||
|
"'" +
|
||||||
|
linkAttributes +
|
||||||
|
">" +
|
||||||
|
url +
|
||||||
|
"</a>";
|
||||||
|
return "" + space + link;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
String.prototype["autoLink"] = autoLink;
|
||||||
|
}.call(this));
|
@ -586,7 +586,7 @@ chatInput.addEventListener("keypress", function (event) {
|
|||||||
socket.emit("chat message", chatInput.value, roomHash);
|
socket.emit("chat message", chatInput.value, roomHash);
|
||||||
$(".chat-messages").append(
|
$(".chat-messages").append(
|
||||||
'<div class="message-item customer"><div class="message-bloc"><div class="message">' +
|
'<div class="message-item customer"><div class="message-bloc"><div class="message">' +
|
||||||
chatInput.value +
|
chatInput.value.autoLink() +
|
||||||
"</div></div></div>"
|
"</div></div></div>"
|
||||||
);
|
);
|
||||||
$("#chat-zone").scrollTop($("#chat-zone")[0].scrollHeight);
|
$("#chat-zone").scrollTop($("#chat-zone")[0].scrollHeight);
|
||||||
@ -597,7 +597,7 @@ chatInput.addEventListener("keypress", function (event) {
|
|||||||
socket.on("chat message", function (msg) {
|
socket.on("chat message", function (msg) {
|
||||||
$(".chat-messages").append(
|
$(".chat-messages").append(
|
||||||
'<div class="message-item moderator"><div class="message-bloc"><div class="message">' +
|
'<div class="message-item moderator"><div class="message-bloc"><div class="message">' +
|
||||||
msg +
|
msg.autoLink() +
|
||||||
"</div></div></div>"
|
"</div></div></div>"
|
||||||
);
|
);
|
||||||
$("#chat-zone").scrollTop($("#chat-zone")[0].scrollHeight);
|
$("#chat-zone").scrollTop($("#chat-zone")[0].scrollHeight);
|
||||||
|
Loading…
Reference in New Issue
Block a user