mirror of
https://github.com/thelounge/thelounge
synced 2024-11-25 21:40:22 +00:00
Linkify urls in chat
This commit is contained in:
parent
8049e93703
commit
98331decd6
4 changed files with 2012 additions and 5 deletions
|
@ -100,7 +100,7 @@
|
|||
<div class="message {{type}}">
|
||||
<span class="time">{{time}}</span>
|
||||
<a href="{{user}}" class="user">{{mode}}{{user}}</a>
|
||||
<span class="text">{{type}} {{text}}</span>
|
||||
<span class="text">{{type}} {{{autoLink text}}}</span>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
@ -125,7 +125,7 @@
|
|||
<div class="message {{type}}">
|
||||
<span class="time">{{time}}</span>
|
||||
<a href="{{user}}" class="user">{{mode}}{{user}}</a>
|
||||
<span class="text">{{type}} {{text}}</span>
|
||||
<span class="text">{{type}} {{{autoLink text}}}</span>
|
||||
</div>
|
||||
{{/messages}}
|
||||
</script>
|
||||
|
@ -136,6 +136,7 @@
|
|||
<script src="/js/lib/jquery.cookie.js"></script>
|
||||
<script src="/js/lib/jquery.scrollGlue.js"></script>
|
||||
<script src="/js/lib/bootstrap.js"></script>
|
||||
<script src="/js/lib/URI.js"></script>
|
||||
<script src="/js/chat.js"></script>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -14,7 +14,7 @@ $(function() {
|
|||
tpl[id] = tpl[id] || Handlebars.compile($(id).html());
|
||||
return tpl[id](json);
|
||||
}
|
||||
|
||||
|
||||
function event(type, json) {
|
||||
switch (type) {
|
||||
|
||||
|
@ -213,4 +213,11 @@ $(function() {
|
|||
.removeClass("active")
|
||||
.end();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("autoLink", function(text) {
|
||||
var text = Handlebars.Utils.escapeExpression(text);
|
||||
return URI.withinString(text, function(url) {
|
||||
return "<a href='" + url + "' target='_blank'>" + url + "</a>";
|
||||
});
|
||||
});
|
||||
|
|
2000
client/js/lib/URI.js
Normal file
2000
client/js/lib/URI.js
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue