[calendar] [mozilla 1.x] if native calendar app is available, and mozilla calendar there, show chrome to launch a native calendar, if specified by a pref. this "tasks" extension can be extended for other tasks. NOT PART OF THE BUILD r/sr/a=sspitzer git-svn-id: svn://10.0.0.236/trunk@150126 18797224-902f-48f8-a5cc-f745e15eee43
57 lines
1.2 KiB
JavaScript
57 lines
1.2 KiB
JavaScript
function getAppFile(aPrefName)
|
|
{
|
|
try
|
|
{
|
|
var prefs = Components.classes["@mozilla.org/preferences-service;1"];
|
|
prefs = prefs.getService(Components.interfaces.nsIPrefBranch);
|
|
var appFile = prefs.getComplexValue(aPrefName, Components.interfaces.nsILocalFile);
|
|
return appFile
|
|
}
|
|
catch (ex)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function openApp(aPrefName)
|
|
{
|
|
var appFile = getAppFile(aPrefName);
|
|
if (appFile)
|
|
{
|
|
try {
|
|
// this should cause the operating system to simulate double clicking
|
|
// on the location which should launch your calendar application.
|
|
appFile.launch();
|
|
}
|
|
catch (ex)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
|
|
function haveInternalCalendar()
|
|
{
|
|
return ("@mozilla.org/ical-container;1" in Components.classes);
|
|
}
|
|
|
|
function openOtherCal()
|
|
{
|
|
if (!haveInternalCalendar())
|
|
openApp("task.calendar.location");
|
|
}
|
|
|
|
function OtherTasksOnLoad()
|
|
{
|
|
var otherCalTaskBarIcon = document.getElementById("mini-other-cal");
|
|
var otherCalMenuItem = document.getElementById("tasksMenuOtherCal");
|
|
|
|
var appFile = getAppFile("task.calendar.location");
|
|
if (appFile && !haveInternalCalendar())
|
|
{
|
|
otherCalTaskBarIcon.hidden = false;
|
|
otherCalMenuItem.hidden = false;
|
|
}
|
|
}
|
|
|
|
addEventListener("load",OtherTasksOnLoad,true);
|