and finally, the modules folder. Now I can publish and take a break
This commit is contained in:
@@ -208,7 +208,18 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
|
||||
|
||||
for(var/I in targets)
|
||||
//Grab us a client if possible
|
||||
var/client/C = grab_client(I)
|
||||
var/client/C
|
||||
if (ismob(I))
|
||||
var/mob/M = I
|
||||
if(M.client)
|
||||
C = M.client
|
||||
else if(istype(I, /client))
|
||||
C = I
|
||||
else if(istype(I, /datum/mind))
|
||||
var/datum/mind/M = I
|
||||
if(M.current && M.current.client)
|
||||
C = M.current.client
|
||||
|
||||
|
||||
if (!C)
|
||||
continue
|
||||
@@ -226,15 +237,3 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic
|
||||
|
||||
// url_encode it TWICE, this way any UTF-8 characters are able to be decoded by the Javascript.
|
||||
C << output(url_encode(url_encode(message)), "browseroutput:output")
|
||||
|
||||
/proc/grab_client(target)
|
||||
if(istype(target, /client))
|
||||
return target
|
||||
else if(ismob(target))
|
||||
var/mob/M = target
|
||||
if(M.client)
|
||||
return M.client
|
||||
else if(istype(target, /datum/mind))
|
||||
var/datum/mind/M = target
|
||||
if(M.current && M.current.client)
|
||||
return M.current.client
|
||||
|
||||
@@ -95,8 +95,53 @@ if (typeof String.prototype.trim !== 'function') {
|
||||
};
|
||||
}
|
||||
|
||||
// Linkify the contents of a node, within its parent.
|
||||
function linkify(parent, insertBefore, text) {
|
||||
var start = 0;
|
||||
var match;
|
||||
var regex = /(?:(?:https?:\/\/)|(?:www\.))(?:[^ ]*?\.[^ ]*?)+[-A-Za-z0-9+&@#\/%?=~_|$!:,.;()]+/ig;
|
||||
while ((match = regex.exec(text)) !== null) {
|
||||
// add the unmatched text
|
||||
parent.insertBefore(document.createTextNode(text.substring(start, match.index)), insertBefore);
|
||||
|
||||
var href = match[0];
|
||||
if (!/^https?:\/\//i.test(match[0])) {
|
||||
href = "http://" + match[0];
|
||||
}
|
||||
|
||||
// add the link
|
||||
var link = document.createElement("a");
|
||||
link.href = href;
|
||||
link.textContent = match[0];
|
||||
parent.insertBefore(link, insertBefore);
|
||||
|
||||
start = regex.lastIndex;
|
||||
}
|
||||
if (start !== 0) {
|
||||
// add the remaining text and remove the original text node
|
||||
parent.insertBefore(document.createTextNode(text.substring(start)), insertBefore);
|
||||
parent.removeChild(insertBefore);
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively linkify the children of a given node.
|
||||
function linkify_node(node) {
|
||||
var children = node.childNodes;
|
||||
// work backwards to avoid the risk of looping forever on our own output
|
||||
for (var i = children.length - 1; i >= 0; --i) {
|
||||
var child = children[i];
|
||||
if (child.nodeType == Node.TEXT_NODE) {
|
||||
// text is to be linkified
|
||||
linkify(node, child, child.textContent);
|
||||
} else if (child.nodeName != "A" && child.nodeName != "a") {
|
||||
// do not linkify existing links
|
||||
linkify_node(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Shit fucking piece of crap that doesn't work god fuckin damn it
|
||||
function linkify(text) {
|
||||
function linkify_fallback(text) {
|
||||
var rex = /((?:<a|<iframe|<img)(?:.*?(?:src="|href=").*?))?(?:(?:https?:\/\/)|(?:www\.))+(?:[^ ]*?\.[^ ]*?)+[-A-Za-z0-9+&@#\/%?=~_|$!:,.;]+/ig;
|
||||
return text.replace(rex, function ($0, $1) {
|
||||
if(/^https?:\/\/.+/i.test($0)) {
|
||||
@@ -283,11 +328,6 @@ function output(message, flag) {
|
||||
}
|
||||
}
|
||||
|
||||
//Url stuff
|
||||
if (message.length && flag != 'preventLink') {
|
||||
message = linkify(message);
|
||||
}
|
||||
|
||||
opts.messageCount++;
|
||||
|
||||
//Pop the top message off if history limit reached
|
||||
@@ -340,6 +380,20 @@ function output(message, flag) {
|
||||
$last_message = trimmed_message;
|
||||
$messages[0].appendChild(entry);
|
||||
$(entry).find("img.icon").error(iconError);
|
||||
|
||||
var to_linkify = $(entry).find(".linkify");
|
||||
if (typeof Node === 'undefined') {
|
||||
// Linkify fallback for old IE
|
||||
for(var i = 0; i < to_linkify.length; ++i) {
|
||||
to_linkify[i].innerHTML = linkify_fallback(to_linkify[i].innerHTML);
|
||||
}
|
||||
} else {
|
||||
// Linkify for modern IE versions
|
||||
for(var i = 0; i < to_linkify.length; ++i) {
|
||||
linkify_node(to_linkify[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//Actually do the snap
|
||||
//Stuff we can do after the message shows can go here, in the interests of responsiveness
|
||||
if (opts.highlightTerms && opts.highlightTerms.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user