Bug 954882 - Handle bad log files properly, r=florian.

This commit is contained in:
aleth 2012-09-20 17:59:17 +02:00
Родитель 2e827dd013
Коммит 5b383d5340
4 изменённых файлов: 68 добавлений и 6 удалений

Просмотреть файл

@ -32,6 +32,8 @@ var logWindow = {
let listbox = document.getElementById("logList");
logs.forEach(function (aLog) {
if (aLog.format == "invalid")
return;
let elt = document.createElement("listitem");
let logDate = new Date(aLog.time * 1000);
let localizedDateTimeString =
@ -67,8 +69,17 @@ var logWindow = {
let log = document.getElementById("logList").selectedItem.log;
let deck = document.getElementById("browserDeck");
let findbar = document.getElementById("findbar");
let conv = log.getConversation();
if (conv) {
if (log.format == "json") {
let conv = log.getConversation();
if (!conv) {
// Empty or completely broken json log file.
deck.selectedIndex = 2;
// Ensure the findbar has something to look at.
let browser = document.getElementById("text-browser");
findbar.browser = browser;
browser.loadURI("about:blank");
return;
}
deck.selectedIndex = 1;
let browser = document.getElementById("conv-browser");
findbar.browser = browser;
@ -131,16 +142,25 @@ var logWindow = {
},
contentLoaded: function lw_contentLoaded() {
let doc = document.getElementById("text-browser").contentDocument;
let browser = document.getElementById("text-browser");
if (browser.currentURI.spec == "about:blank")
return;
let doc = browser.contentDocument;
let link = doc.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = "data:text/css,pre{white-space: pre-wrap;word-wrap: break-word;}.ib-img-smile {vertical-align: text-bottom;}";
doc.getElementsByTagName("head")[0].appendChild(link);
let elt = doc.getElementsByTagName("pre")[0].firstChild;
if (!elt) {
// Text log file is empty.
document.getElementById("browserDeck").selectedIndex = 2;
return;
}
if (!("smileTextNode" in window))
Components.utils.import("resource:///modules/imSmileys.jsm");
smileTextNode(doc.getElementsByTagName("pre")[0].firstChild);
smileTextNode(elt);
}
};

Просмотреть файл

@ -107,6 +107,14 @@
context="contentAreaContextMenu"/>
<progressmeter id="browserProgress" hidden="true"/>
</vbox>
<vbox flex="1" id="corruptLogScreen" align="center" pack="center">
<hbox id="corruptLogBox">
<image id="corruptLogImage"/>
<vbox id="corruptLogInnerBox" align="center" pack="center" flex="1">
<description id="corruptLogDesc">&logsWindow.corruptlogfile;</description>
</vbox>
</hbox>
</vbox>
</deck>
<findbar id="findbar"/>
</vbox>

Просмотреть файл

@ -8,6 +8,7 @@
<!ENTITY logsWindow.title "Conversation logs - &brandShortName;">
<!ENTITY logsWindow.titlemodifiermenuseparator " - ">
<!ENTITY logsWindow.titlemodifier "&brandShortName;">
<!ENTITY logsWindow.corruptlogfile "Empty or corrupt log file.">
<!ENTITY file.menu "File">
<!ENTITY file.accesskey "F">
@ -57,9 +58,9 @@
<!ENTITY errorConsoleCmd.commandkey "j">
<!ENTITY preferencesCmd.label "Options…">
<!ENTITY preferencesCmd.accesskey "O">
<!ENTITY preferencesCmd.accesskey "O">
<!ENTITY preferencesCmdUnix.label "Preferences">
<!ENTITY preferencesCmdUnix.accesskey "n">
<!ENTITY preferencesCmdUnix.accesskey "n">
<!ENTITY textEnlarge.commandkey "+">
<!ENTITY textEnlarge.commandkey2 "=">

Просмотреть файл

@ -41,3 +41,36 @@ splitter:-moz-window-inactive {
}
%endif
%endif
#corruptLogScreen {
background-color: -moz-Dialog;
overflow: auto;
}
#corruptLogBox {
background-color: -moz-Field;
color: -moz-FieldText;
border: 1px solid ThreeDShadow;
border-radius: 10px;
padding: 1.1em;
-moz-padding-start: 20px;
margin-left: 1em;
margin-right: 1em;
}
#corruptLogImage {
%ifdef XP_MACOSX
list-style-image: url("chrome://global/skin/icons/error-large.png");
%else
list-style-image: url("chrome://global/skin/icons/error-48.png");
%endif
-moz-margin-end: 1em;
}
#corruptLogInnerBox {
max-width: 25em;
}
#corruptLogDesc {
font-size: large;
}