Thunderbird Lightning 扩展在左侧显示时间Week
和Day
视图,如下所示...
我希望时间显示 2 个不同的时区(例如本地时间和太平洋时间),如此处所示...
是否有配置参数来执行此操作?是否有另一个扩展可以调整这个?如果没有,我该如何破解 Thunderbird 扩展来做到这一点?
Thunderbird Lightning 扩展在左侧显示时间Week
和Day
视图,如下所示...
我希望时间显示 2 个不同的时区(例如本地时间和太平洋时间),如此处所示...
是否有配置参数来执行此操作?是否有另一个扩展可以调整这个?如果没有,我该如何破解 Thunderbird 扩展来做到这一点?
我没有解决一般情况下的问题。我只是让时间显示在当前时区和前一小时显示。就我而言,当前时区是美国山区时间,前一小时最终是美国太平洋时间。
calendar-multiday-view.xml
必须在 Thunderbird 未运行时编辑以下 jar 文件中的文件。
C:\Users\nreynold.ORADEV\AppData\Roaming\Thunderbird\Profiles\ profile \extensions\{e2fda1a4-762b-4020-b5ad-a41df1933103}\chrome.jar
该方法makeTimeBox()
必须按照注释所示进行更改:
function makeTimeBox(timestr, time2str, size) { // Add time2str parameter
var box = createXULElement("box");
box.setAttribute("orient", orient);
box.setAttribute("align", "left"); // Add
if (orient == "horizontal") {
box.setAttribute("width", size);
} else {
box.setAttribute("height", size);
}
var label = createXULElement("label");
label.setAttribute("class", "calendar-time-bar-label");
label.setAttribute("value", timestr);
label.setAttribute("style", "color: #4080C0; font-weight: bold;"); // Replace "align"
box.appendChild(label);
var label = createXULElement("label"); // Add
label.setAttribute("class", "calendar-time-bar-label"); // Add
label.setAttribute("value", time2str); // Add
box.appendChild(label); // Add
return box;
}
后添加以下方法makeTimeBox()
。
function makeTime(hour) {
var h = hour % 12;
if (h == 0)
h = 12;
var s = hour >= 12 ? " pm" : " am";
var result = h + s;
return result;
}
删除下面几行出现的以下行makeTimeBox()
var formatter = Components.classes["@mozilla.org/intl/scriptabledateformat;1"].
getService(Components.interfaces.nsIScriptableDateFormat);
更改以下行...
var timeString;
... 成为 ...
var timeString, time2String;
降低约 25 行,替换以下行...
timeString = formatter.FormatTime("",
Components.interfaces.nsIScriptableDateFormat.timeFormatNoSeconds,
theHour, 0, 0);
box = makeTimeBox(timeString, durPix);
... 成为 ...
timeString = makeTime(theHour) + " MT";
ptHour = theHour - 1;
ptHour += 23;
ptHour %= 24;
ptHour += 1;
time2String = makeTime(ptHour) + " PT";
box = makeTimeBox(timeString, time2String, durPix);
我不知道有任何现有的附加组件可以做到这一点,但我可以告诉你它是如何完成的。首先创建一个典型的骨架 Thunderbird 扩展,在 Firefox 世界中,如果您正在搜索文档,这称为“遗留”扩展。它应该包含一个 install.rdf 和一个 chrome.manifest。我假设您选择view-zones
作为 chrome.manifest 中的标识符。
接下来,您需要创建一个允许您覆盖calendar-time-bar
绑定的 CSS 文件。请注意,使用此方法只能有一个扩展覆盖绑定。内容将如下所示:
calendar-time-bar {
-moz-binding: url(chrome://view-zones/content/bindings.xml#calendar-time-bar) !important;
}
这将使用您将在bindings.xml
文件中创建的绑定覆盖时间栏。它扩展了内置时间栏,但在重新布局后添加了一些代码以添加这些额外的标签。CSS 文件需要在 chrome.manifest 文件中使用style
指令进行引用,并且可以扩展chrome://calendar/skin/calendar-views.css
. 然后您必须为以下内容创建 xml 文件chrome://view-zones/content/bindings.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings id="calendar-multiday-view-bindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="calendar-time-bar"
extends="chrome://calendar/content/calendar-multiday-view.xml#calendar-time-bar">
<implementation>
<method name="relayout">
<body><![CDATA[
this.__proto__.__proto__.relayout.call(this);
let XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
let topbox = document.getAnonymousElementByAttribute(this, "anonid", "topbox");
for (let box of topbox.childNodes) {
let timelabel = box.appendChild(document.createElementNS(XUL_NS, "label"));
timelabel.setAttribute("value", "10:00 PT");
}
]]></body>
</method>
</implementation>
</binding>
</bindings>
我暂时将标签保留为静态,但您可以考虑一些逻辑,"10:00 PT"
根据其他标签或实际方法中使用的相同算法将其更改为实际时间。您还可以添加类和样式以使其看起来不同。
也就是说,也许您有兴趣将此功能添加到核心 Lightning 中?我认为这将是一个很好的补充。我很确定我们为此打开了一个错误,但我目前找不到它,所以如果您有兴趣,也许您可以提交一个错误,我可以为您提供有关如何设置的更多信息。在这种情况下,只需更改绑定以显示多个标签并添加用户可见的首选项以便能够选择时区。