зеркало из https://github.com/mozilla/pjs.git
Bug 376343 - Munger is losing all mIRC codes: color, bold and underline
r=silver@warwickcompsoc.co.uk (James Ross) ChatZilla Only.
This commit is contained in:
Родитель
36bcb49b27
Коммит
179742b379
|
@ -214,7 +214,7 @@ function insertLink(matchText, containerTag, data, mungerEntry)
|
|||
mungerEntry.enabled = true;
|
||||
containerTag.appendChild(anchor);
|
||||
if (trailing)
|
||||
insertHyphenatedWord(trailing, containerTag);
|
||||
insertHyphenatedWord(trailing, containerTag, data);
|
||||
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ function insertBugzillaLink (matchText, containerTag, eventData, mungerEntry)
|
|||
}
|
||||
}
|
||||
|
||||
function insertRheet (matchText, containerTag)
|
||||
function insertRheet (matchText, containerTag, data)
|
||||
{
|
||||
|
||||
var anchor = document.createElementNS("http://www.w3.org/1999/xhtml",
|
||||
|
@ -347,7 +347,7 @@ function insertRheet (matchText, containerTag)
|
|||
"http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/bonus-tracks/rheet.wav");
|
||||
anchor.setAttribute("class", "chatzilla-rheet chatzilla-link");
|
||||
//anchor.setAttribute ("target", "_content");
|
||||
insertHyphenatedWord(matchText, anchor);
|
||||
insertHyphenatedWord(matchText, anchor, data);
|
||||
containerTag.appendChild(anchor);
|
||||
}
|
||||
|
||||
|
@ -571,9 +571,13 @@ function showCtrlChar(c, containerTag)
|
|||
containerTag.appendChild (span);
|
||||
}
|
||||
|
||||
function insertHyphenatedWord (longWord, containerTag)
|
||||
function insertHyphenatedWord(longWord, containerTag, data)
|
||||
{
|
||||
var wordParts = splitLongWord (longWord, client.MAX_WORD_DISPLAY);
|
||||
var wordParts = splitLongWord(longWord, client.MAX_WORD_DISPLAY);
|
||||
var newClass = "";
|
||||
if (data && ("hasColorInfo" in data))
|
||||
newClass = calcClass(data);
|
||||
|
||||
for (var i = 0; i < wordParts.length; ++i)
|
||||
{
|
||||
if (i > 0)
|
||||
|
@ -582,7 +586,19 @@ function insertHyphenatedWord (longWord, containerTag)
|
|||
"html:wbr");
|
||||
containerTag.appendChild(wbr);
|
||||
}
|
||||
containerTag.appendChild (document.createTextNode (wordParts[i]));
|
||||
|
||||
if (newClass)
|
||||
{
|
||||
var newTag = document.createElementNS(NS_XHTML, "html:span");
|
||||
newTag.setAttribute("class", newClass);
|
||||
newTag.appendChild(document.createTextNode(wordParts[i]));
|
||||
containerTag.appendChild(newTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete data.hasColorInfo;
|
||||
containerTag.appendChild(document.createTextNode(wordParts[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -611,5 +627,20 @@ function insertInlineButton(text, containerTag, data)
|
|||
containerTag.appendChild(document.createTextNode("]"));
|
||||
}
|
||||
|
||||
|
||||
function calcClass(data)
|
||||
{
|
||||
var className = "";
|
||||
if ("hasColorInfo" in data)
|
||||
{
|
||||
if ("currFgColor" in data)
|
||||
className += " chatzilla-fg" + data.currFgColor;
|
||||
if ("currBgColor" in data)
|
||||
className += " chatzilla-bg" + data.currBgColor;
|
||||
if ("isBold" in data)
|
||||
className += " chatzilla-bold";
|
||||
if ("isUnderline" in data)
|
||||
className += " chatzilla-underline";
|
||||
}
|
||||
return className;
|
||||
}
|
||||
|
||||
|
|
|
@ -275,52 +275,9 @@ function mng_mungePriority(priority, text, containerTag, data)
|
|||
return null;
|
||||
}
|
||||
|
||||
//XXXgijs: this depends on our own data-structures, which are in
|
||||
// content/mungers.js, but we can't move this function out cause insertText
|
||||
// depends on it, and the rest of the munger depends on that. Sigh.
|
||||
function calcClass(data)
|
||||
{
|
||||
var className = "";
|
||||
if ("hasColorInfo" in data)
|
||||
{
|
||||
if ("currFgColor" in data)
|
||||
className += " chatzilla-fg" + data.currFgColor;
|
||||
if ("currBgColor" in data)
|
||||
className += " chatzilla-bg" + data.currBgColor;
|
||||
if ("isBold" in data)
|
||||
className += " chatzilla-bold";
|
||||
if ("isUnderline" in data)
|
||||
className += " chatzilla-underline";
|
||||
}
|
||||
return className;
|
||||
}
|
||||
|
||||
function insertText(text, containerTag, data)
|
||||
{
|
||||
var textNode = document.createTextNode(text);
|
||||
|
||||
if ("hasColorInfo" in data)
|
||||
{
|
||||
var newClass = calcClass(data);
|
||||
if (newClass)
|
||||
{
|
||||
var newTag = document.createElementNS(NS_XHTML, "html:span");
|
||||
newTag.setAttribute("class", newClass);
|
||||
newTag.appendChild(textNode);
|
||||
containerTag.appendChild(newTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete data.hasColorInfo;
|
||||
containerTag.appendChild(textNode);
|
||||
}
|
||||
|
||||
var wbr = document.createElementNS(NS_XHTML, "html:wbr");
|
||||
containerTag.appendChild(wbr);
|
||||
}
|
||||
else
|
||||
{
|
||||
containerTag.appendChild(textNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче