now only shows domain of url
This commit is contained in:
parent
fe09679b0a
commit
68f3b432ba
10
js/posts.js
10
js/posts.js
@ -15,8 +15,8 @@ socket.addEventListener("message", function (event) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
function urlify(text) {
|
function urlify(text) {
|
||||||
let textregex = /(([a-z]+:\/\/)?(([a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal|tk|ga))(:[0-9]{1,5})?(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(\s+|$)/gi
|
let textregex = /(([a-z]+:\/\/)(([a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal|tk|ga|xxx|to))(:[0-9]{1,5})?(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(\s+|$)/gi
|
||||||
return text.replace(textregex,'<a href="$1" target="_blank">$1</a> ')
|
return text.replace(textregex,'<a href="$1" target="_blank" class="insertedlink">$1</a> ')
|
||||||
}
|
}
|
||||||
|
|
||||||
function newlineify(text) {
|
function newlineify(text) {
|
||||||
@ -134,6 +134,12 @@ async function main(){
|
|||||||
last_10_posts.forEach((item, i) => {
|
last_10_posts.forEach((item, i) => {
|
||||||
createPost(item.post_user_name,item.post_text,item.post_time,item.post_special_text)
|
createPost(item.post_user_name,item.post_text,item.post_time,item.post_special_text)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let links = document.getElementsByClassName("insertedlink")
|
||||||
|
for (let i = 0; i < links.length; i++) {
|
||||||
|
links[i].innerText = links[i].innerText.split("\/\/")[1].split("\/")[0]
|
||||||
|
}
|
||||||
|
|
||||||
let mentions = document.getElementsByClassName("mention")
|
let mentions = document.getElementsByClassName("mention")
|
||||||
for (let i = 0; i < mentions.length; i++) {
|
for (let i = 0; i < mentions.length; i++) {
|
||||||
if(mentions[i]!=undefined && mentions[i].innerText == "@"+username) {
|
if(mentions[i]!=undefined && mentions[i].innerText == "@"+username) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user