summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniko <niko>2012-10-01 22:54:16 (GMT)
committerniko <niko>2012-10-01 22:54:16 (GMT)
commit7b47175cd7c82f806b37d2fe2332cc3b6b8e105b (patch)
tree0b8e251df97fa99301e8909e1804b9adcaec81dc
parent9df93aa72d2e67afde9e4e6d515072720f98f9fc (diff)
downloadsynckolab-7b47175cd7c82f806b37d2fe2332cc3b6b8e105b.tar.gz
initial tests
-rw-r--r--build.xml92
-rw-r--r--src/chrome/content/synckolab/abWindow.xul4
-rw-r--r--src/chrome/content/synckolab/addressbook.js347
-rw-r--r--src/chrome/content/synckolab/addressbookTools.js370
-rw-r--r--src/chrome/content/synckolab/calendar.js358
-rw-r--r--src/chrome/content/synckolab/calendarTools.js229
-rw-r--r--src/chrome/content/synckolab/config.js199
-rw-r--r--src/chrome/content/synckolab/contactConflictDialog.xul10
-rw-r--r--src/chrome/content/synckolab/contactConflictDialogCode.js27
-rw-r--r--src/chrome/content/synckolab/contents.rdf2
-rw-r--r--src/chrome/content/synckolab/mainWindow.xul6
-rw-r--r--src/chrome/content/synckolab/synckolab.js835
-rw-r--r--src/chrome/content/synckolab/tools.js246
-rw-r--r--src/chrome/content/synckolab/tools/kolab.js11
-rw-r--r--src/chrome/content/synckolab/tools/sha1.js7
-rw-r--r--src/chrome/content/synckolab/tools/text.js36
-rw-r--r--src/chrome/content/synckolab/wndConfig.js295
-rw-r--r--src/chrome/content/synckolab/wndConfig.xul38
-rw-r--r--src/chrome/content/synckolab/wndNewConfigType.xul6
-rw-r--r--test/lib/env.rhino.1.2.js13989
-rw-r--r--test/lib/js.jarbin0 -> 1134765 bytes
-rw-r--r--test/lib/qunit-1.10.0.js1977
-rw-r--r--test/lib/testOverride.js40
-rw-r--r--test/suite.js54
-rw-r--r--test/synckolab/parser/kolab2/calendarTest.js0
-rw-r--r--test/synckolab/parser/kolab2/contactTest.js34
-rw-r--r--test/synckolab/parser/kolab2/json/contactFullTest.json1
-rw-r--r--test/synckolab/parser/kolab2/json/contactMinimalTest.json1
-rw-r--r--test/synckolab/parser/kolab2/raw/contactFullTest.xml71
-rw-r--r--test/synckolab/parser/kolab2/raw/contactMinimalTest.xml16
-rw-r--r--test/synckolab/parser/kolab3/raw/testContactMinimalFromXML.xml2
-rw-r--r--test/synckolab/parser/kolab3/raw/testcontact.xml61
-rw-r--r--test/synckolab/parser/kolab3/raw/testevent.xml81
-rw-r--r--test/synckolab/parser/kolab3/raw/testnote.xml18
-rw-r--r--test/synckolab/parser/kolab3/raw/xcalCalendar.xml142
-rw-r--r--test/synckolab/parser/kolab3/raw/xcalEvent.xml34
-rw-r--r--test/synckolab/tools/textTest.js37
-rw-r--r--test/synckolab/tools/toolsTest.js1
38 files changed, 18120 insertions, 1557 deletions
diff --git a/build.xml b/build.xml
index cba0499..b7d8f29 100644
--- a/build.xml
+++ b/build.xml
@@ -1,54 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
- Dec 21, 2009 5:30:28 PM
-
- SyncKolab
- Sync your contacts with imap
-
- gargan
- ====================================================================== -->
+ SyncKolab: Sync your contacts with imap
+ Author: Niko Berger
+ ====================================================================== -->
<project name="SyncKolab" default="default">
- <description>
- Sync your contacts with imap
- </description>
- <property name="version" value="2.0.3"/>
+ <description>
+ Sync your contacts with imap
+ </description>
+ <property name="version" value="2.0.3" />
- <!-- =================================
- target: default
- ================================= -->
- <target name="default" depends="depends" description="Sync your contacts with imap">
- <delete>
- <fileset dir="build">
- <include name="**/*.*"/>
- </fileset>
- </delete>
- <copy todir="build">
- <fileset dir="src">
- <include name="**/*.*"/>
- <exclude name="**/*.orig"/>
- </fileset>
- </copy>
- <zip destfile="build/chrome/synckolab.jar" basedir="build/chrome"/>
- <zip destfile="synckolab-${version}.xpi" basedir="build"/>
- </target>
+ <!-- ================================= target: default ================================= -->
+ <target name="default" depends="depends" description="Sync your contacts with imap">
+ <delete>
+ <fileset dir="build">
+ <include name="**/*.*" />
+ </fileset>
+ </delete>
+ <copy todir="build">
+ <fileset dir="src">
+ <include name="**/*.*" />
+ <exclude name="**/*.orig" />
+ </fileset>
+ </copy>
+ <zip destfile="build/chrome/synckolab.jar" basedir="build/chrome" />
+ <zip destfile="synckolab-${version}.xpi" basedir="build" />
+ </target>
<target name="nightly" description="nighlty build">
-
- <copy todir="build">
- <fileset dir="src">
- <include name="**/*.*"/>
- </fileset>
- </copy>
+
+ <copy todir="build">
+ <fileset dir="src">
+ <include name="**/*.*" />
+ </fileset>
+ </copy>
<replace dir="build" value="http://www.gargan.org/extensions/update.rdf">
- <include name="**/*.*"/>
+ <include name="**/*.*" />
</replace>
-
- <zip destfile="synckolab-AMO-${version}.xpi"/>
+
+ <zip destfile="synckolab-AMO-${version}.xpi" />
+ </target>
+ <!-- - - - - - - - - - - - - - - - - -
+ target: depends
+ - - - - - - - - - - - - - - - - - -->
+ <target name="depends">
</target>
- <!-- - - - - - - - - - - - - - - - - -
- target: depends
- - - - - - - - - - - - - - - - - - -->
- <target name="depends">
- </target>
+ <!-- Run QUnit -->
+ <target name="test" description="run qunit tests">
+ <java dir="." fork="true" classname="org.mozilla.javascript.tools.shell.Main">
+ <classpath>
+ <fileset dir="test/lib"><include name="js.jar"/></fileset>
+ </classpath>
+ <arg value="-opt"/>
+ <arg value="-1"/>
+ <arg value="-debug"/>
+ <arg value="test/suite.js"/>
+ </java>
+ </target>
</project>
diff --git a/src/chrome/content/synckolab/abWindow.xul b/src/chrome/content/synckolab/abWindow.xul
index d8971d9..1c807e1 100644
--- a/src/chrome/content/synckolab/abWindow.xul
+++ b/src/chrome/content/synckolab/abWindow.xul
@@ -44,14 +44,14 @@
<menupopup id="taskPopup">
<menuseparator/>
- <menuitem id="SyncKolab-Sync" oncommand="com.synckolab.main.sync('manual');" label="&synckolab.syncMenu.label;"/>
+ <menuitem id="SyncKolab-Sync" oncommand="synckolab.main.sync('manual');" label="&synckolab.syncMenu.label;"/>
<menuitem id="SyncKolab-Options"
oncommand="window.openDialog('chrome://synckolab/content/wndConfig.xul', 'options', 'chrome=yes,resizable=yes,modal=yes');"
label="&synckolab.optionMenu.label;"/>
</menupopup>
<toolbarpalette id="AddressBookToolbarPalette">
- <toolbarbutton id="SyncKolab-button-ab" oncommand="com.synckolab.main.sync('manual');" class="toolbarbutton-1" label="&synckolab.sync.label;"/>
+ <toolbarbutton id="SyncKolab-button-ab" oncommand="synckolab.main.sync('manual');" class="toolbarbutton-1" label="&synckolab.sync.label;"/>
</toolbarpalette>
</overlay>
diff --git a/src/chrome/content/synckolab/addressbook.js b/src/chrome/content/synckolab/addressbook.js
index d3110df..cec3d95 100644
--- a/src/chrome/content/synckolab/addressbook.js
+++ b/src/chrome/content/synckolab/addressbook.js
@@ -34,8 +34,7 @@
***** END LICENSE BLOCK ***** */
"use strict";
-if(!com) var com={};
-if(!com.synckolab) com.synckolab={};
+if(!synckolab) var synckolab={};
/*
* A kinda "provider" class for syncing the address book.
@@ -44,7 +43,7 @@ if(!com.synckolab) com.synckolab={};
* body) to generate add/update contacts in the address book.
*
*/
-com.synckolab.AddressBook = {
+synckolab.AddressBook = {
gConfig: null, // remember the configuration name
gCurUID: '', // save the last checked uid - for external use
@@ -72,21 +71,21 @@ com.synckolab.AddressBook = {
* @param pref a nsIPrefBranch for reading of the configuration
*/
readConfig: function(config, pref) {
- com.synckolab.tools.logMessage("Reading Configuration:" + config.name, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Reading Configuration:" + config.name, synckolab.global.LOG_DEBUG);
// get the rdf for the Addresbook list
// the addressbook type nsIAbDirectory
- var cn = com.synckolab.addressbookTools.getABDirectory(!config.syncListener?null:{
+ var cn = synckolab.addressbookTools.getABDirectory(!config.syncListener?null:{
getConfig: function(addressBokName) {
// search through the configs
- for(var j = 0; j < com.synckolab.main.syncConfigs.length; j++) {
- if(com.synckolab.main.syncConfigs[j] && com.synckolab.main.syncConfigs[j].type === "contact") {
- var curConfig = com.synckolab.main.syncConfigs[j];
- //com.synckolab.tools.logMessage("checking " + curConfig.contact.folderMsgURI + " vs. " + folder, com.synckolab.global.LOG_DEBUG);
+ for(var j = 0; j < synckolab.main.syncConfigs.length; j++) {
+ if(synckolab.main.syncConfigs[j] && synckolab.main.syncConfigs[j].type === "contact") {
+ var curConfig = synckolab.main.syncConfigs[j];
+ //synckolab.tools.logMessage("checking " + curConfig.contact.folderMsgURI + " vs. " + folder, synckolab.global.LOG_DEBUG);
if(curConfig.enabled && curConfig.syncListener) {
- if(curConfig.source === addressBokName || com.synckolab.tools.text.fixNameToMiniCharset(curConfig.source) === com.synckolab.tools.text.fixNameToMiniCharset(addressBokName))
+ if(curConfig.source === addressBokName || synckolab.tools.text.fixNameToMiniCharset(curConfig.source) === synckolab.tools.text.fixNameToMiniCharset(addressBokName))
{
return curConfig;
}
@@ -103,8 +102,8 @@ com.synckolab.AddressBook = {
OnStopRunningUrl: function ( url, exitCode )
{
- com.synckolab.tools.logMessage("Finished trigger", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
- com.synckolab.global.triggerRunning = false;
+ synckolab.tools.logMessage("Finished trigger", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
+ synckolab.global.triggerRunning = false;
}
}, msgWindow);
},
@@ -114,7 +113,7 @@ com.synckolab.AddressBook = {
return;
}
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
@@ -124,55 +123,55 @@ com.synckolab.AddressBook = {
}
newCard = newCard.QueryInterface(Components.interfaces.nsIAbCard);
- com.synckolab.tools.logMessage("trigger new card", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("trigger new card", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
// get the dbfile from the local disk
var cUID = null;
- cUID = com.synckolab.addressbookTools.getUID(newCard);
+ cUID = synckolab.addressbookTools.getUID(newCard);
if (!cUID) {
// generate a unique id (will random be enough for the future?)
- cUID = "sk-vc-" + com.synckolab.tools.text.randomVcardId();
- com.synckolab.addressbookTools.setUID(newCard, cUID);
+ cUID = "sk-vc-" + synckolab.tools.text.randomVcardId();
+ synckolab.addressbookTools.setUID(newCard, cUID);
// avoid loop
- com.synckolab.global.triggerRunning = true;
+ synckolab.global.triggerRunning = true;
cConfig.addressBook.modifyCard(newCard);
- com.synckolab.global.triggerRunning = false;
+ synckolab.global.triggerRunning = false;
}
// remember that we just worked with this one
- if(com.synckolab.config.checkIdProcessed(cConfig, cUID)) {
- com.synckolab.tools.logMessage("skipping because recently processed", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ if(synckolab.config.checkIdProcessed(cConfig, cUID)) {
+ synckolab.tools.logMessage("skipping because recently processed", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return;
}
if (newCard.isMailList) {
- com.synckolab.tools.logMessage("adding unsaved list: " + cUID, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("adding unsaved list: " + cUID, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
} else {
- com.synckolab.tools.logMessage("adding unsaved card: " + cUID, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("adding unsaved card: " + cUID, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
}
// and write the message
- var abcontent = com.synckolab.addressbookTools.card2Message(newCard, cConfig.email, cConfig.format);
- com.synckolab.tools.logMessage("New Card " + abcontent, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ var abcontent = synckolab.addressbookTools.card2Message(newCard, cConfig.email, cConfig.format);
+ synckolab.tools.logMessage("New Card " + abcontent, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// get the dbfile from the local disk
- var idxEntry = com.synckolab.tools.file.getSyncDbFile(cConfig, cUID);
+ var idxEntry = synckolab.tools.file.getSyncDbFile(cConfig, cUID);
// write the current content in the sync-db file (parse to json object first)
- com.synckolab.tools.writeSyncDBFile(idxEntry, com.synckolab.addressbookTools.parseMessageContent(com.synckolab.tools.stripMailHeader(abcontent)));
+ synckolab.tools.writeSyncDBFile(idxEntry, synckolab.addressbookTools.parseMessageContent(synckolab.tools.stripMailHeader(abcontent)));
- com.synckolab.tools.logMessage("Writing card to imap" , com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Writing card to imap" , synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
- com.synckolab.global.triggerRunning = true;
+ synckolab.global.triggerRunning = true;
var listener = this;
- com.synckolab.main.writeImapMessage(abcontent, cConfig,
+ synckolab.main.writeImapMessage(abcontent, cConfig,
{
OnProgress: function (progress, progressMax) {},
OnStartCopy: function () { },
SetMessageKey: function (key) {},
OnStopCopy: function (status) {
// update folder information from imap and make sure we got everything
- com.synckolab.tools.logMessage("Finished writing contact entry to imap - compacting", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Finished writing contact entry to imap - compacting", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
listener.finishMsgfolderChange(cConfig.folder);
}
});
@@ -183,7 +182,7 @@ com.synckolab.AddressBook = {
return;
}
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
@@ -192,24 +191,24 @@ com.synckolab.AddressBook = {
return;
}
- var cUID = com.synckolab.addressbookTools.getUID(item);
+ var cUID = synckolab.addressbookTools.getUID(item);
// the item doesnt have an uuid - skip
if(!cUID) {
return;
}
// remember that we just worked with this one
- if(com.synckolab.config.checkIdProcessed(cConfig, cUID)) {
- com.synckolab.tools.logMessage("skipping because recently processed", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ if(synckolab.config.checkIdProcessed(cConfig, cUID)) {
+ synckolab.tools.logMessage("skipping because recently processed", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return;
}
// find the correct message to the given uid
if(cConfig.msgList.length() === 0) {
- com.synckolab.tools.fillMessageLookup(cConfig.msgList, config, com.synckolab.addressbookTools.parseMessageContent);
+ synckolab.tools.fillMessageLookup(cConfig.msgList, config, synckolab.addressbookTools.parseMessageContent);
}
- com.synckolab.global.triggerRunning = true;
+ synckolab.global.triggerRunning = true;
// get and delete the message
var msg = cConfig.msgList.get(cUID);
@@ -217,12 +216,12 @@ com.synckolab.AddressBook = {
var list = null;
// use mutablearray
list = Components.classes["@mozilla.org/array;1"].createInstance(Components.interfaces.nsIMutableArray);
- com.synckolab.tools.logMessage("deleting [" + cUID + "]");
+ synckolab.tools.logMessage("deleting [" + cUID + "]");
list.appendElement(msg, false);
cConfig.folder.deleteMessages(list, msgWindow, true, false, null, true);
// also remove sync db file
- var idxEntry = com.synckolab.tools.file.getSyncDbFile(cConfig, cUID);
+ var idxEntry = synckolab.tools.file.getSyncDbFile(cConfig, cUID);
idxEntry.remove(false);
}
@@ -231,14 +230,14 @@ com.synckolab.AddressBook = {
},
onItemPropertyChanged: function(item, prop, oldval, newval) {
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
var dirName = item.directoryId.substring(item.directoryId.lastIndexOf("&")+1);
// local change triggers a full sync
- com.synckolab.tools.logMessage("item changed in "+ dirName, com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("item changed in "+ dirName, synckolab.global.LOG_INFO);
// get the right config for this address book
var cConfig = this.getConfig(dirName);
@@ -246,43 +245,43 @@ com.synckolab.AddressBook = {
return;
}
- var cUID = com.synckolab.addressbookTools.getUID(item);
+ var cUID = synckolab.addressbookTools.getUID(item);
// the item doesnt have an uuid - create one
if(!cUID) {
- com.synckolab.addressbookTools.setUID(item, "sk-vc-" + com.synckolab.tools.text.randomVcardId());
+ synckolab.addressbookTools.setUID(item, "sk-vc-" + synckolab.tools.text.randomVcardId());
this.gConfig.addressBook.modifyCard(item);
if (item.isMailList) {
- com.synckolab.tools.logMessage("adding unsaved list: " + cUID, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("adding unsaved list: " + cUID, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
} else {
- com.synckolab.tools.logMessage("adding unsaved card: " + cUID, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("adding unsaved card: " + cUID, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
}
- cUID = com.synckolab.addressbookTools.getUID(item);
+ cUID = synckolab.addressbookTools.getUID(item);
}
// remember that we just worked with this one
- if(com.synckolab.config.checkIdProcessed(cConfig, cUID)) {
- com.synckolab.tools.logMessage("skipping because recently processed", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ if(synckolab.config.checkIdProcessed(cConfig, cUID)) {
+ synckolab.tools.logMessage("skipping because recently processed", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return;
}
// and write the message
- var abcontent = com.synckolab.addressbookTools.card2Message(item, cConfig.email, cConfig.format);
- com.synckolab.tools.logMessage("Updated Card " + cUID, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ var abcontent = synckolab.addressbookTools.card2Message(item, cConfig.email, cConfig.format);
+ synckolab.tools.logMessage("Updated Card " + cUID, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
- com.synckolab.tools.logMessage("looking for message", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("looking for message", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// finally update imap
// find the correct message to the given uid
if(cConfig.msgList.length() === 0) {
- com.synckolab.tools.fillMessageLookup(cConfig.msgList, config, com.synckolab.addressbookTools.parseMessageContent);
+ synckolab.tools.fillMessageLookup(cConfig.msgList, config, synckolab.addressbookTools.parseMessageContent);
}
- com.synckolab.global.triggerRunning = true;
+ synckolab.global.triggerRunning = true;
// get the dbfile from the local disk
- var idxEntry = com.synckolab.tools.file.getSyncDbFile(cConfig, cUID);
+ var idxEntry = synckolab.tools.file.getSyncDbFile(cConfig, cUID);
// get and delete the message
var msg = cConfig.msgList.get(cUID);
@@ -290,29 +289,29 @@ com.synckolab.AddressBook = {
var list = null;
// use mutablearray
list = Components.classes["@mozilla.org/array;1"].createInstance(Components.interfaces.nsIMutableArray);
- com.synckolab.tools.logMessage("deleting [" + cUID + "]");
+ synckolab.tools.logMessage("deleting [" + cUID + "]");
list.appendElement(msg, false);
cConfig.folder.deleteMessages(list, msgWindow, true, false, null, true);
idxEntry.remove(false);
}
// add new
- com.synckolab.tools.logMessage("Writing card to imap" , com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Writing card to imap" , synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// remember that we just added this one
cConfig.recentProcessed.push(cUID);
// write the current content in the sync-db file (parse to json object first)
- com.synckolab.tools.writeSyncDBFile(idxEntry, com.synckolab.addressbookTools.parseMessageContent(com.synckolab.tools.stripMailHeader(abcontent)));
+ synckolab.tools.writeSyncDBFile(idxEntry, synckolab.addressbookTools.parseMessageContent(synckolab.tools.stripMailHeader(abcontent)));
var listener = this;
- com.synckolab.main.writeImapMessage(abcontent, cConfig,
+ synckolab.main.writeImapMessage(abcontent, cConfig,
{
OnProgress: function (progress, progressMax) {},
OnStartCopy: function () { },
SetMessageKey: function (key) {},
OnStopCopy: function (status) {
- com.synckolab.tools.logMessage("Finished writing contact entry to imap", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Finished writing contact entry to imap", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
listener.finishMsgfolderChange(cConfig.folder);
}
});
@@ -325,7 +324,7 @@ com.synckolab.AddressBook = {
{
var cur = ABook.QueryInterface(Components.interfaces.nsIAbDirectory);
if (cur.dirName === config.addressBookName ||
- com.synckolab.tools.text.fixNameToMiniCharset(config.source) === com.synckolab.tools.text.fixNameToMiniCharset(cur.dirName)
+ synckolab.tools.text.fixNameToMiniCharset(config.source) === synckolab.tools.text.fixNameToMiniCharset(cur.dirName)
)
{
config.addressBook = cur;
@@ -344,12 +343,12 @@ com.synckolab.AddressBook = {
// the current sync database filen (a file with uid:size:date:localfile)
// uid -> filename database - main functions needs to know the name
- config.dbFile = com.synckolab.tools.file.getHashDataBaseFile(config);
+ config.dbFile = synckolab.tools.file.getHashDataBaseFile(config);
},
init: function (config, itemList, document) {
// shortcuts for some common used utils
- this.tools = com.synckolab.addressbookTools;
+ this.tools = synckolab.addressbookTools;
this.itemList = itemList;
this.doc = document;
@@ -369,11 +368,11 @@ com.synckolab.AddressBook = {
this.gConfig.recentProcessed = [];
// a hashmap remembering all the cards - for faster use
- this.gCardDB = new com.synckolab.hashMap();
+ this.gCardDB = new synckolab.hashMap();
// shouldnt happen, since we have a config...
if(this.gConfig.type !== "contact") {
- com.synckolab.tools.logMessage("address book missing, please restart or try again", com.synckolab.global.LOG_ERROR + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("address book missing, please restart or try again", synckolab.global.LOG_ERROR + synckolab.global.LOG_AB);
return null;
}
@@ -392,7 +391,7 @@ com.synckolab.AddressBook = {
var cUID = this.tools.getUID(card);
if (cUID === null || cUID === "")
{
- cUID = "sk-vc-" + com.synckolab.tools.text.randomVcardId();
+ cUID = "sk-vc-" + synckolab.tools.text.randomVcardId();
this.tools.setUID(card, cUID);
this.gConfig.addressBook.modifyCard(card);
}
@@ -407,16 +406,16 @@ com.synckolab.AddressBook = {
*/
triggerParseAddMessage: function(message) {
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
// parse the new message content
- var newCard = com.synckolab.addressbookTools.parseMessageContent(message.fileContent);
+ var newCard = synckolab.addressbookTools.parseMessageContent(message.fileContent);
// get the dbfile from the local disk
- var cUid = com.synckolab.addressbookTools.getUID(newCard);
- var idxEntry = com.synckolab.tools.file.getSyncDbFile(message.config, cUid);
+ var cUid = synckolab.addressbookTools.getUID(newCard);
+ var idxEntry = synckolab.tools.file.getSyncDbFile(message.config, cUid);
// check if the entry is in the address book
var curCard = null;
@@ -424,7 +423,7 @@ com.synckolab.AddressBook = {
while (cards.hasMoreElements())
{
var cCard = cards.getNext().QueryInterface(Components.interfaces.nsIAbCard);
- if(com.synckolab.addressbookTools.getUID(cCard) === cUid) {
+ if(synckolab.addressbookTools.getUID(cCard) === cUid) {
curCard = cCard;
break;
}
@@ -441,22 +440,22 @@ com.synckolab.AddressBook = {
}
catch (e)
{
- com.synckolab.tools.logMessage("unable to delete card: " + curCard.uid, com.synckolab.global.LOG_ERROR + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("unable to delete card: " + curCard.uid, synckolab.global.LOG_ERROR + synckolab.global.LOG_AB);
return;
}
}
// write the pojo into a file for faster comparison in later sync
- com.synckolab.tools.writeSyncDBFile(idxEntry, newCard);
+ synckolab.tools.writeSyncDBFile(idxEntry, newCard);
- com.synckolab.tools.logMessage("card is new, add to address book: " + cUid, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("card is new, add to address book: " + cUid, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// convert to a thunderbird object and add to the address book
if (newCard.type === "maillist")
{
// add mailing lists - add list of currently added cards
if(!message.config.cardDb) {
- message.config.cardDb = new com.synckolab.hashMap();
+ message.config.cardDb = new synckolab.hashMap();
var lCards = message.config.addressBook.childCards;
var card = null;
// read all cards
@@ -466,34 +465,34 @@ com.synckolab.AddressBook = {
card = card.QueryInterface(Components.interfaces.nsIAbCard);
// create a UUID if it does not exist!
- var cUID = com.synckolab.addressbookTools.getUID(card);
+ var cUID = synckolab.addressbookTools.getUID(card);
if (cUID === null || cUID === "")
{
- cUID = "sk-vc-" + com.synckolab.tools.text.randomVcardId();
- com.synckolab.addressbookTools.setUID(card, cUID);
+ cUID = "sk-vc-" + synckolab.tools.text.randomVcardId();
+ synckolab.addressbookTools.setUID(card, cUID);
message.config.addressBook.modifyCard(card);
}
message.config.cardDb.put(cUID, card);
}
}
- message.config.addressBook.addMailList(com.synckolab.addressbookTools.createTBirdObject(newCard, message.config.cardDb));
+ message.config.addressBook.addMailList(synckolab.addressbookTools.createTBirdObject(newCard, message.config.cardDb));
// also add to the hash-database
//this.gCardDB.put(this.tools.getUID(newCard), newCard);
}
else
{
// also copy the image
- var pNameA = com.synckolab.addressbookTools.getCardProperty(newCard, "PhotoName");
+ var pNameA = synckolab.addressbookTools.getCardProperty(newCard, "PhotoName");
if (pNameA && pNameA !== "" && pNameA !== "null")
{
// in case the copy failed - clear the photoname
- if (com.synckolab.addressbookTools.copyImage(pNameA) === false) {
- com.synckolab.addressbookTools.setCardProperty(newCard, "PhotoName", "");
+ if (synckolab.addressbookTools.copyImage(pNameA) === false) {
+ synckolab.addressbookTools.setCardProperty(newCard, "PhotoName", "");
}
}
- message.config.addressBook.addCard(com.synckolab.addressbookTools.createTBirdObject(newCard));
+ message.config.addressBook.addCard(synckolab.addressbookTools.createTBirdObject(newCard));
// clean out old cardDb
message.config.cardDb = null;
}
@@ -506,22 +505,22 @@ com.synckolab.AddressBook = {
*/
triggerParseDeleteMessage: function(message) {
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
// parse the new message content
- var newCard = com.synckolab.addressbookTools.parseMessageContent(message.fileContent);
+ var newCard = synckolab.addressbookTools.parseMessageContent(message.fileContent);
// find the entry in the address book and remove it
- var cId = com.synckolab.addressbookTools.getUID(newCard);
+ var cId = synckolab.addressbookTools.getUID(newCard);
var cards = message.config.addressBook.childCards;
var deleteList = Components.classes["@mozilla.org/array;1"].createInstance(Components.interfaces.nsIMutableArray);
while (cards.hasMoreElements())
{
var cCard = cards.getNext().QueryInterface(Components.interfaces.nsIAbCard);
- if(com.synckolab.addressbookTools.getUID(cCard) === cId) {
- com.synckolab.tools.logMessage("found card to delete: " + cId, com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ if(synckolab.addressbookTools.getUID(cCard) === cId) {
+ synckolab.tools.logMessage("found card to delete: " + cId, synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
deleteList.appendElement(cCard, false);
break;
}
@@ -533,19 +532,19 @@ com.synckolab.AddressBook = {
}
catch (e)
{
- com.synckolab.tools.logMessage("unable to delete card: " + cId, com.synckolab.global.LOG_ERROR + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("unable to delete card: " + cId, synckolab.global.LOG_ERROR + synckolab.global.LOG_AB);
return;
}
// get the dbfile from the local disk
- var idxEntry = com.synckolab.tools.file.getSyncDbFile(message.config, cId);
+ var idxEntry = synckolab.tools.file.getSyncDbFile(message.config, cId);
if (idxEntry.exists()) {
idxEntry.remove(true);
}
// also delete image
- var pNameA = com.synckolab.addressbookTools.getCardProperty(newCard, "PhotoName");
+ var pNameA = synckolab.addressbookTools.getCardProperty(newCard, "PhotoName");
if (pNameA && pNameA !== "" && pNameA !== "null")
{
// delete actual image
@@ -566,7 +565,7 @@ com.synckolab.AddressBook = {
}
}
- com.synckolab.tools.logMessage("deleting card: " + cId, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("deleting card: " + cId, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
},
@@ -615,9 +614,9 @@ com.synckolab.AddressBook = {
this.curItemInListId = this.doc.createElement("treecell");
this.curItemInListStatus = this.doc.createElement("treecell");
this.curItemInListContent = this.doc.createElement("treecell");
- this.curItemInListId.setAttribute("label", com.synckolab.global.strBundle.getString("unknown"));
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("parsing"));
- this.curItemInListContent.setAttribute("label", com.synckolab.global.strBundle.getString("unknown"));
+ this.curItemInListId.setAttribute("label", synckolab.global.strBundle.getString("unknown"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("parsing"));
+ this.curItemInListContent.setAttribute("label", synckolab.global.strBundle.getString("unknown"));
this.curItemInList.appendChild(this.curItemInListId);
this.curItemInList.appendChild(this.curItemInListStatus);
@@ -628,7 +627,7 @@ com.synckolab.AddressBook = {
var curListItem = this.doc.createElement("treeitem");
curListItem.appendChild(this.curItemInList);
this.itemList.appendChild(curListItem);
- com.synckolab.tools.scrollToBottom(this.itemList);
+ synckolab.tools.scrollToBottom(this.itemList);
}
// parse the new item
@@ -636,15 +635,15 @@ com.synckolab.AddressBook = {
if (newCard && newCard.isMailList)
{
- com.synckolab.tools.logMessage("got mailing list " + this.tools.getUID(newCard), com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("got mailing list " + this.tools.getUID(newCard), synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
}
/*
if (newCard && newCard.isMailList)
{
// skip mailing lists
- this.curItemInListContent.setAttribute("label", com.synckolab.global.strBundle.getString("mailingList") + " " + this.tools.getUID(newCard));
- this.curItemInListId.setAttribute("label", com.synckolab.global.strBundle.getString("noChange"));
- com.synckolab.tools.logMessage("skipping mailing lists!", com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ this.curItemInListContent.setAttribute("label", synckolab.global.strBundle.getString("mailingList") + " " + this.tools.getUID(newCard));
+ this.curItemInListId.setAttribute("label", synckolab.global.strBundle.getString("noChange"));
+ synckolab.tools.logMessage("skipping mailing lists!", synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
return null;
}
*/
@@ -655,15 +654,15 @@ com.synckolab.AddressBook = {
// remember that we did this uid already
this.folderMessageUids.push(this.gCurUID);
- com.synckolab.tools.logMessage("got card from message: " + this.gCurUID, com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("got card from message: " + this.gCurUID, synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
// update list item
this.curItemInListId.setAttribute("label", this.gCurUID);
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("checking"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("checking"));
// since we disabled mailing list - wont come here
if (newCard.type === "maillist") {
- this.curItemInListContent.setAttribute("label", com.synckolab.global.strBundle.getString("mailingList") + " " + this.tools.getCardProperty(newCard, "Name"));
+ this.curItemInListContent.setAttribute("label", synckolab.global.strBundle.getString("mailingList") + " " + this.tools.getCardProperty(newCard, "Name"));
} else if (this.tools.getCardProperty(newCard, "DisplayName") !== "") {
this.curItemInListContent.setAttribute("label", this.tools.getCardProperty(newCard, "DisplayName") +
" <" + this.tools.getCardProperty(newCard, "PrimaryEmail","---") + ">");
@@ -677,8 +676,8 @@ com.synckolab.AddressBook = {
var foundCard = this.gCardDB.get(this.gCurUID);
// get the dbfile from the local disk
- var idxEntry = com.synckolab.tools.file.getSyncDbFile(this.gConfig, this.tools.getUID(newCard));
- com.synckolab.tools.logMessage("got entry from db: " + foundCard, com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ var idxEntry = synckolab.tools.file.getSyncDbFile(this.gConfig, this.tools.getUID(newCard));
+ synckolab.tools.logMessage("got entry from db: " + foundCard, synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
// a new card or locally deleted
if (foundCard === null)
@@ -689,20 +688,20 @@ com.synckolab.AddressBook = {
if (!idxEntry.exists() || this.forceLocalCopy)
{
// write the pojo into a file for faster comparison in later sync
- com.synckolab.tools.writeSyncDBFile(idxEntry, newCard);
+ synckolab.tools.writeSyncDBFile(idxEntry, newCard);
// convert to a thunderbird object and add to the address book
if (newCard.type === "maillist")
{
- com.synckolab.tools.logMessage("list is new, add to address book: " + this.tools.getUID(newCard), com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("list is new, add to address book: " + this.tools.getUID(newCard), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// add mailing lists- pass the gCardDB with its nsIAbCard
- this.gConfig.addressBook.addMailList(com.synckolab.addressbookTools.createTBirdObject(newCard, this.gCardDB));
+ this.gConfig.addressBook.addMailList(synckolab.addressbookTools.createTBirdObject(newCard, this.gCardDB));
// also add to the hash-database
this.gCardDB.put(this.tools.getUID(newCard), newCard);
}
else
{
- com.synckolab.tools.logMessage("card is new, add to address book: " + this.tools.getUID(newCard), com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("card is new, add to address book: " + this.tools.getUID(newCard), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// also copy the image
var pNameA = this.tools.getCardProperty(newCard, "PhotoName");
if (pNameA && pNameA !== "" && pNameA !== "null")
@@ -713,23 +712,23 @@ com.synckolab.AddressBook = {
}
}
- var abCard = com.synckolab.addressbookTools.createTBirdObject(newCard);
+ var abCard = synckolab.addressbookTools.createTBirdObject(newCard);
this.gConfig.addressBook.addCard(abCard);
// also add to the hash-database
this.gCardDB.put(this.tools.getUID(newCard), abCard);
}
//update list item
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("localAdd"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("localAdd"));
// new card added - we are done
return null;
}
else
{
- com.synckolab.tools.logMessage("card deleted locally: " + this.tools.getUID(newCard), com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("card deleted locally: " + this.tools.getUID(newCard), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
//update list item
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("deleteOnServer"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("deleteOnServer"));
try
{
@@ -748,49 +747,49 @@ com.synckolab.AddressBook = {
// this card is already in the address book
{
// read the current card from the sync db (might be null)
- var cCard = com.synckolab.tools.readSyncDBFile(idxEntry);
+ var cCard = synckolab.tools.readSyncDBFile(idxEntry);
var cCard_equals_foundCard = false, cCard_equals_newCard = false, foundCard_equals_newCard = false;
// Streamline card comparisons
if (cCard && this.tools.equalsContact(cCard, foundCard)) {
cCard_equals_foundCard = true;
- com.synckolab.tools.logMessage("In parse Message in addressbook.js cCard equals foundCard", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message in addressbook.js cCard equals foundCard", synckolab.global.LOG_DEBUG);
} else {
cCard_equals_foundCard = false;
- com.synckolab.tools.logMessage("In parse Message in addressbook.js cCard NOT EQUALS foundCard\n ", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message in addressbook.js cCard NOT EQUALS foundCard\n ", synckolab.global.LOG_DEBUG);
}
if (cCard && this.tools.equalsContact(cCard, newCard)) {
cCard_equals_newCard = true;
- com.synckolab.tools.logMessage("In parse Message in addressbook.js cCard equals newCard", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message in addressbook.js cCard equals newCard", synckolab.global.LOG_DEBUG);
} else {
cCard_equals_newCard = false;
- com.synckolab.tools.logMessage("In parse Message in addressbook.js cCard DOES NOT equal newCard", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message in addressbook.js cCard DOES NOT equal newCard", synckolab.global.LOG_DEBUG);
}
if (this.tools.equalsContact(foundCard, newCard)) {
foundCard_equals_newCard = true;
- com.synckolab.tools.logMessage("In parse Message in addressbook.js foundCard equals newCard", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message in addressbook.js foundCard equals newCard", synckolab.global.LOG_DEBUG);
} else {
foundCard_equals_newCard = false;
- com.synckolab.tools.logMessage("In parse Message in addressbook.js foundCard DOES NOT equal newCard", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message in addressbook.js foundCard DOES NOT equal newCard", synckolab.global.LOG_DEBUG);
}
// compare each card with each other
if ((idxEntry.exists() && !cCard_equals_foundCard && !cCard_equals_newCard) || (!idxEntry.exists() && !foundCard_equals_newCard))
{
//local and server were both updated, ut oh, what do we want to do?
- com.synckolab.tools.logMessage("Conflicts detected, testing for autoresolve.", com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Conflicts detected, testing for autoresolve.", synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
// This function returns an array on conflicting fields
- var conflicts = com.synckolab.addressbookTools.contactConflictTest(newCard, foundCard);
+ var conflicts = synckolab.addressbookTools.contactConflictTest(newCard, foundCard);
var bUpdateLocal = false;
var bUpdateServer = false;
//If there were no conflicts found, skip dialog and update the local copy (Changes to the way the SHA are calculated could cause this)
if (conflicts.length > 0) {
- com.synckolab.tools.logMessage("Conflicts length is greater than 0.", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Conflicts length is greater than 0.", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
//Holds the users response, must be an object so that we can pass by reference
var conflictResolution = {};
@@ -821,17 +820,17 @@ com.synckolab.AddressBook = {
switch (conflictResolution.result) {
case 0 :
//User clicked Cancel or X, we move to next record and user can deal with this issue on next sync
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("conflict") + ": skipped");
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("conflict") + ": skipped");
break;
case 1 :
//User chose to keep all server values
bUpdateLocal = true;
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("conflict") + ": " + com.synckolab.global.strBundle.getString("localUpdate"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("conflict") + ": " + synckolab.global.strBundle.getString("localUpdate"));
break;
case 2 :
//User chose to keep all local values
bUpdateServer = true;
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("conflict") + ": " + com.synckolab.global.strBundle.getString("updateOnServer"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("conflict") + ": " + synckolab.global.strBundle.getString("updateOnServer"));
break;
case 3 :
//User chose a mix of values, therefore, both local and server need updating
@@ -839,16 +838,16 @@ com.synckolab.AddressBook = {
//newCard and foundCard both already contain the new values
bUpdateLocal = true;
bUpdateServer = true;
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("conflict") + ": both updated");
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("conflict") + ": both updated");
break;
}
} else {
//cards values are different, however, no apparent differences
//Changes to the way the SHA (code revisions) are calculated could cause this
- com.synckolab.tools.logMessage("Contacts differ, however, assumed no change, update local" + this.tools.getUID(newCard), com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Contacts differ, however, assumed no change, update local" + this.tools.getUID(newCard), synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
bUpdateLocal = true;
- this.curItemInListStatus.setAttribute("label", "Auto Conflict Resolved : " + com.synckolab.global.strBundle.getString("localUpdate"));
+ this.curItemInListStatus.setAttribute("label", "Auto Conflict Resolved : " + synckolab.global.strBundle.getString("localUpdate"));
}
if (bUpdateLocal) {
@@ -873,15 +872,15 @@ com.synckolab.AddressBook = {
}
// add the new one
- this.gConfig.addressBook.addCard(com.synckolab.addressbookTools.createTBirdObject(newCard));
+ this.gConfig.addressBook.addCard(synckolab.addressbookTools.createTBirdObject(newCard));
}
catch (de)
{
- com.synckolab.tools.logMessage("problem with local update for - skipping" + this.tools.getUID(foundCard), com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("problem with local update for - skipping" + this.tools.getUID(foundCard), synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
}
// write the current content in the sync-db file
- com.synckolab.tools.writeSyncDBFile(idxEntry, newCard);
+ synckolab.tools.writeSyncDBFile(idxEntry, newCard);
}
if (bUpdateServer) {
@@ -889,7 +888,7 @@ com.synckolab.AddressBook = {
abcontent = this.tools.card2Message(foundCard, this.gConfig.email, this.gConfig.format);
// write the current content in the sync-db file
- com.synckolab.tools.writeSyncDBFile(idxEntry, this.tools.parseMessageContent(com.synckolab.tools.stripMailHeader(abcontent)));
+ synckolab.tools.writeSyncDBFile(idxEntry, this.tools.parseMessageContent(synckolab.tools.stripMailHeader(abcontent)));
return abcontent;
}
return null; // Return null, we either updated nothing or updated only local
@@ -899,13 +898,13 @@ com.synckolab.AddressBook = {
if (!idxEntry.exists() || (cCard_equals_foundCard && !cCard_equals_newCard))
{
if (!idxEntry.exists()) {
- com.synckolab.tools.logMessage("In parse Message in addressbook.js idxEntry does not exist", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message in addressbook.js idxEntry does not exist", synckolab.global.LOG_DEBUG);
}
if(foundCard_equals_newCard){
- com.synckolab.tools.logMessage("no change, but sync file missing: " + this.tools.getUID(foundCard), com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("no change, but sync file missing: " + this.tools.getUID(foundCard), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
} else {
- com.synckolab.tools.logMessage("server changed: " + this.tools.getUID(foundCard), com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("server changed: " + this.tools.getUID(foundCard), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
}
// server changed - update local
@@ -918,10 +917,10 @@ com.synckolab.AddressBook = {
//delMailListlist.appendElement(foundCard, false);
//this.gConfig.addressBook.deleteCards(delMailListlist);
this.gConfig.addressBook.deleteDirectory(foundCard);
- this.gConfig.addressBook.addMailList(com.synckolab.addressbookTools.createTBirdObject(newCard, this.gCardDB));
+ this.gConfig.addressBook.addMailList(synckolab.addressbookTools.createTBirdObject(newCard, this.gCardDB));
} catch (delMailList)
{
- com.synckolab.tools.logMessage("problem with local update for - skipping" + this.tools.getUID(foundCard), com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("problem with local update for - skipping" + this.tools.getUID(foundCard), synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
}
}
else
@@ -944,26 +943,26 @@ com.synckolab.AddressBook = {
}
}
- this.gConfig.addressBook.addCard(com.synckolab.addressbookTools.createTBirdObject(newCard));
+ this.gConfig.addressBook.addCard(synckolab.addressbookTools.createTBirdObject(newCard));
}
catch (delocalUpdate)
{
- com.synckolab.tools.logMessage("problem with local update for - skipping" + this.tools.getUID(foundCard), com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("problem with local update for - skipping" + this.tools.getUID(foundCard), synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
}
}
- com.synckolab.tools.logMessage("write sync db " + this.tools.getUID(foundCard), com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("write sync db " + this.tools.getUID(foundCard), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// write the current content in the sync-db file
- com.synckolab.tools.writeSyncDBFile(idxEntry, newCard);
+ synckolab.tools.writeSyncDBFile(idxEntry, newCard);
// update list item
if(foundCard_equals_newCard){
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("noChange"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("noChange"));
}
else {
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("localUpdate"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("localUpdate"));
}
return null;
}
@@ -971,26 +970,26 @@ com.synckolab.AddressBook = {
// is the db file equals server, but not local.. we got a local change
if (idxEntry.exists() && !cCard_equals_foundCard && cCard_equals_newCard)
{
- com.synckolab.tools.logMessage("client changed " + this.tools.getUID(foundCard) + " - " + cCard.primaryEmail, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("client changed " + this.tools.getUID(foundCard) + " - " + cCard.primaryEmail, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// update list item
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("updateOnServer"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("updateOnServer"));
// remember this message for update - generate mail message (incl. extra fields)
abcontent = this.tools.card2Message(foundCard, this.gConfig.email, this.gConfig.format);
// write the current content in the sync-db file
- com.synckolab.tools.writeSyncDBFile(idxEntry, this.tools.parseMessageContent(com.synckolab.tools.stripMailHeader(abcontent)));
+ synckolab.tools.writeSyncDBFile(idxEntry, this.tools.parseMessageContent(synckolab.tools.stripMailHeader(abcontent)));
return abcontent;
}
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("noChange"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("noChange"));
}
}
else
{
- this.curItemInListId.setAttribute("label", com.synckolab.global.strBundle.getString("unparseable"));
- com.synckolab.tools.logMessage("unable to parse message, skipping", com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ this.curItemInListId.setAttribute("label", synckolab.global.strBundle.getString("unparseable"));
+ synckolab.tools.logMessage("unable to parse message, skipping", synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
}
return null;
@@ -1013,7 +1012,7 @@ com.synckolab.AddressBook = {
if (!this.gCards.hasMoreElements())
{
// we are done
- com.synckolab.tools.logMessage("Finished syncing adress book", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Finished syncing adress book", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return "done";
}
@@ -1024,7 +1023,7 @@ com.synckolab.AddressBook = {
catch (ext)
{
// we are done
- com.synckolab.tools.logMessage("Bad - Finished syncing adress book", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Bad - Finished syncing adress book", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return "done";
}
@@ -1036,7 +1035,7 @@ com.synckolab.AddressBook = {
if (cur.isMailList)
{
- com.synckolab.tools.logMessage("Convert Mailing list to nsIABDirectory", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Convert Mailing list to nsIABDirectory", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
curItem = Components.classes["@mozilla.org/abmanager;1"].getService(Components.interfaces.nsIAbManager).getDirectory(cur.mailListURI);
}
@@ -1062,11 +1061,11 @@ com.synckolab.AddressBook = {
// look at new card
// generate a unique id (will random be enough for the future?)
- com.synckolab.addressbookTools.setUID(curItem, "sk-vc-" + com.synckolab.tools.text.randomVcardId());
+ synckolab.addressbookTools.setUID(curItem, "sk-vc-" + synckolab.tools.text.randomVcardId());
if (cur.isMailList) {
- com.synckolab.tools.logMessage("adding unsaved list: " + this.tools.getUID(curItem), com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("adding unsaved list: " + this.tools.getUID(curItem), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
} else {
- com.synckolab.tools.logMessage("adding unsaved card: " + this.tools.getUID(curItem), com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("adding unsaved card: " + this.tools.getUID(curItem), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
}
this.gConfig.addressBook.modifyCard(cur);
@@ -1077,9 +1076,9 @@ com.synckolab.AddressBook = {
this.curItemInListStatus = this.doc.createElement("treecell");
this.curItemInListContent = this.doc.createElement("treecell");
this.curItemInListId.setAttribute("label", this.tools.getUID(curItem));
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("addToServer"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("addToServer"));
if (curItem.isMailList) {
- this.curItemInListContent.setAttribute("label", com.synckolab.global.strBundle.getString("mailingList") + " " + this.tools.getCardProperty(curItem, "Name"));
+ this.curItemInListContent.setAttribute("label", synckolab.global.strBundle.getString("mailingList") + " " + this.tools.getCardProperty(curItem, "Name"));
} else {
this.curItemInListContent.setAttribute("label", cur.firstName + " " + curItem.lastName + " <" + curItem.primaryEmail + ">");
}
@@ -1093,17 +1092,17 @@ com.synckolab.AddressBook = {
var curListItem = this.doc.createElement("treeitem");
curListItem.appendChild(this.curItemInList);
this.itemList.appendChild(curListItem);
- com.synckolab.tools.scrollToBottom(this.itemList);
+ synckolab.tools.scrollToBottom(this.itemList);
}
// and write the message
- abcontent = com.synckolab.addressbookTools.card2Message(curItem, this.gConfig.email, this.gConfig.format);
- com.synckolab.tools.logMessage("New Card " + this.tools.getUID(curItem), com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ abcontent = synckolab.addressbookTools.card2Message(curItem, this.gConfig.email, this.gConfig.format);
+ synckolab.tools.logMessage("New Card " + this.tools.getUID(curItem), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// get the dbfile from the local disk
- idxEntry = com.synckolab.tools.file.getSyncDbFile(this.gConfig, this.tools.getUID(curItem));
+ idxEntry = synckolab.tools.file.getSyncDbFile(this.gConfig, this.tools.getUID(curItem));
// write the current content in the sync-db file (parse to json object first)
- com.synckolab.tools.writeSyncDBFile(idxEntry, this.tools.parseMessageContent(com.synckolab.tools.stripMailHeader(abcontent)));
+ synckolab.tools.writeSyncDBFile(idxEntry, this.tools.parseMessageContent(synckolab.tools.stripMailHeader(abcontent)));
}
else
{
@@ -1114,7 +1113,7 @@ com.synckolab.AddressBook = {
{
if (this.tools.getUID(curItem) === this.folderMessageUids[i] && this.tools.getUID(curItem))
{
- com.synckolab.tools.logMessage("we got this contact already: " + this.tools.getUID(curItem), com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("we got this contact already: " + this.tools.getUID(curItem), synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
alreadyProcessed = true;
break;
}
@@ -1126,7 +1125,7 @@ com.synckolab.AddressBook = {
if (!alreadyProcessed)
{
// get the dbfile from the local disk
- idxEntry = com.synckolab.tools.file.getSyncDbFile(this.gConfig, this.tools.getUID(curItem));
+ idxEntry = synckolab.tools.file.getSyncDbFile(this.gConfig, this.tools.getUID(curItem));
if (this.tools.getUID(curItem) === null)
{
alert("UID is NULL???" + curItem.custom4);
@@ -1154,9 +1153,9 @@ com.synckolab.AddressBook = {
this.curItemInListStatus = this.doc.createElement("treecell");
this.curItemInListContent = this.doc.createElement("treecell");
this.curItemInListId.setAttribute("label", this.tools.getUID(curItem));
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("localDelete"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("localDelete"));
if (curItem.isMailList) {
- this.curItemInListContent.setAttribute("label", com.synckolab.global.strBundle.getString("mailingList") + " " + this.tools.getUID(curItem));
+ this.curItemInListContent.setAttribute("label", synckolab.global.strBundle.getString("mailingList") + " " + this.tools.getUID(curItem));
} else {
this.curItemInListContent.setAttribute("label", curItem.firstName + " " + curItem.lastName + " <" + curItem.primaryEmail + ">");
}
@@ -1170,7 +1169,7 @@ com.synckolab.AddressBook = {
var curListItem = this.doc.createElement("treeitem");
curListItem.appendChild(this.curItemInList);
this.itemList.appendChild(curListItem);
- com.synckolab.tools.scrollToBottom(this.itemList);
+ synckolab.tools.scrollToBottom(this.itemList);
}
// also remove the local db file since we deleted the contact on the server
@@ -1187,9 +1186,9 @@ com.synckolab.AddressBook = {
this.curItemInListStatus = this.doc.createElement("treecell");
this.curItemInListContent = this.doc.createElement("treecell");
this.curItemInListId.setAttribute("label", this.tools.getUID(curItem));
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("addToServer"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("addToServer"));
if (curItem.isMailList) {
- this.curItemInListContent.setAttribute("label", com.synckolab.global.strBundle.getString("mailingList") + " " + this.tools.getUID(curItem));
+ this.curItemInListContent.setAttribute("label", synckolab.global.strBundle.getString("mailingList") + " " + this.tools.getUID(curItem));
} else {
this.curItemInListContent.setAttribute("label", curItem.firstName + " " + curItem.lastName + " <" + curItem.primaryEmail + ">");
}
@@ -1203,17 +1202,17 @@ com.synckolab.AddressBook = {
var curListItem = this.doc.createElement("treeitem");
curListItem.appendChild(this.curItemInList);
this.itemList.appendChild(curListItem);
- com.synckolab.tools.scrollToBottom(this.itemList);
+ synckolab.tools.scrollToBottom(this.itemList);
}
// and write the message
- abcontent = com.synckolab.addressbookTools.card2Message(curItem, this.gConfig.email, this.gConfig.format);
- com.synckolab.tools.logMessage("New Card " + this.tools.getUID(curItem), com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ abcontent = synckolab.addressbookTools.card2Message(curItem, this.gConfig.email, this.gConfig.format);
+ synckolab.tools.logMessage("New Card " + this.tools.getUID(curItem), synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// get the dbfile from the local disk
- idxEntry = com.synckolab.tools.file.getSyncDbFile(this.gConfig, this.tools.getUID(curItem));
+ idxEntry = synckolab.tools.file.getSyncDbFile(this.gConfig, this.tools.getUID(curItem));
// write the current content in the sync-db file
- com.synckolab.tools.writeSyncDBFile(idxEntry, this.tools.parseMessageContent(com.synckolab.tools.stripMailHeader(abcontent)));
+ synckolab.tools.writeSyncDBFile(idxEntry, this.tools.parseMessageContent(synckolab.tools.stripMailHeader(abcontent)));
}
}
}
diff --git a/src/chrome/content/synckolab/addressbookTools.js b/src/chrome/content/synckolab/addressbookTools.js
index 693aee8..6cdbaf7 100644
--- a/src/chrome/content/synckolab/addressbookTools.js
+++ b/src/chrome/content/synckolab/addressbookTools.js
@@ -31,17 +31,14 @@
* ***** END LICENSE BLOCK ***** */
"use strict";
-if (!com)
- var com = {};
-if (!com.synckolab)
- com.synckolab = {};
+if (!synckolab) var synckolab = {};
/* ----- general functions to access calendar and events ----- */
-com.synckolab.addressbookTools = {
+synckolab.addressbookTools = {
// package shortcuts:
- global : com.synckolab.global,
- tools : com.synckolab.tools,
+ global : synckolab.global,
+ tools : synckolab.tools,
// make sure the listener is only registered ONCE
listenerRegistered: false,
@@ -105,7 +102,7 @@ com.synckolab.addressbookTools = {
case "description":
break;
default:
- com.synckolab.tools.logMessage("ERROR getting " + prop + " from list", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("ERROR getting " + prop + " from list", synckolab.global.LOG_DEBUG);
}
return card[prop] || def;
@@ -242,14 +239,14 @@ com.synckolab.addressbookTools = {
case "AllowRemoteContent":
return card.allowRemoteContent;
default:
- com.synckolab.tools.logMessage("Unable to get property: " + prop, com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Unable to get property: " + prop, synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
return def;
}
}
},
haveCardProperty : function (card, prop) {
- return (com.synckolab.tools.text.checkExist(this.getCardProperty(card, prop)));
+ return (synckolab.tools.text.checkExist(this.getCardProperty(card, prop)));
},
/**
@@ -266,12 +263,12 @@ com.synckolab.addressbookTools = {
try {
// sk always uses dirName
if (card.synckolab) {
- return com.synckolab.tools.text.fixNameToMiniCharset(this.getCardProperty(card, "DisplayName"));
+ return synckolab.tools.text.fixNameToMiniCharset(this.getCardProperty(card, "DisplayName"));
}
// tbird is more creative
- return com.synckolab.tools.text.fixNameToMiniCharset(this.getCardProperty(card, "Name"));
+ return synckolab.tools.text.fixNameToMiniCharset(this.getCardProperty(card, "Name"));
} catch (err) {
- com.synckolab.tools.logMessage("Error in getUID. ListNickName: '" + card.listNickName + "'\n\nStack:\n" + err.stack, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Error in getUID. ListNickName: '" + card.listNickName + "'\n\nStack:\n" + err.stack, synckolab.global.LOG_DEBUG);
throw err;
}
}
@@ -303,21 +300,21 @@ com.synckolab.addressbookTools = {
* get the address books form the address-book provider
* @return a collection of address books
*/
-com.synckolab.addressbookTools.getABDirectory = function (listener) {
+synckolab.addressbookTools.getABDirectory = function (listener) {
// tbird >= 7
try {
var abManager = Components.classes["@mozilla.org/abmanager;1"].getService(Components.interfaces.nsIAbManager);
/* - ignore ab listener: if you change something locally - sync manual! */
- if (listener && !com.synckolab.addressbookTools.listenerRegistered) {
+ if (listener && !synckolab.addressbookTools.listenerRegistered) {
abManager.addAddressBookListener(listener, 0xFFFFFFFF); // all
- com.synckolab.addressbookTools.listenerRegistered = true;
+ synckolab.addressbookTools.listenerRegistered = true;
}
return abManager.directories;
} catch (ex) {
// tbird < 7
- var directory = com.synckolab.global.rdf.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
+ var directory = synckolab.global.rdf.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
return directory.childNodes;
}
};
@@ -327,7 +324,7 @@ com.synckolab.addressbookTools.getABDirectory = function (listener) {
* @prop the name of the property (String)
* @value the value to set the property to, null will be changed to an empty string ("")
*/
-com.synckolab.addressbookTools.setCardProperty = function (card, prop, value, extra) {
+synckolab.addressbookTools.setCardProperty = function (card, prop, value, extra) {
if (card === null) {
throw ("Unable to process null-card: " + prop);
}
@@ -519,7 +516,7 @@ com.synckolab.addressbookTools.setCardProperty = function (card, prop, value, ex
case "Custom4":
break; // ignore
default:
- com.synckolab.tools.logMessage("Unable to set property: " + prop + " (reason: not found): " + value, com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Unable to set property: " + prop + " (reason: not found): " + value, synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
return;
}
}
@@ -530,7 +527,7 @@ com.synckolab.addressbookTools.setCardProperty = function (card, prop, value, ex
* @param cards childCards - the list of cards
* @param vId string - the custom4 field (card id)
*/
-com.synckolab.addressbookTools.findCard = function (cards, vId, directory) {
+synckolab.addressbookTools.findCard = function (cards, vId, directory) {
// nothing found - try mailing lists
var card = cards.get(vId);
if (card) {
@@ -559,29 +556,40 @@ com.synckolab.addressbookTools.findCard = function (cards, vId, directory) {
* @param xml a dom node of a card or a string with the xml
* @param card the card object to update
*/
-com.synckolab.addressbookTools.xml2Card = function (xml, card) {
+synckolab.addressbookTools.xml2Card = function (xml, card) {
var cur;
// if xml has a nodeType attribute - its already a node
if (xml.indexOf && !xml.nodeName) {
- com.synckolab.tools.logMessage("parsing the XML content into card", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("parsing the XML content into card", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
// check if we have to decode quoted printable
if (xml.indexOf(" version=3D") !== -1) {
// we know from the version
- xml = com.synckolab.tools.text.quoted.decode(xml);
+ xml = synckolab.tools.text.quoted.decode(xml);
}
- xml = com.synckolab.tools.text.utf8.decode(xml);
+ //xml = synckolab.tools.text.utf8.decode(xml);
// potential fix: .replace(/&/g, "&amp;")
// convert the string to xml
- var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"].getService(Components.interfaces.nsIDOMParser);
- var doc = parser.parseFromString(xml, "text/xml");
+ var doc = synckolab.tools.parseXml(xml);
+
+ if (doc === null) {
+ // so this message has no valid XML part :-(
+ synckolab.tools.logMessage("Error parsing the XML content of this message.\n" + xml, synckolab.global.LOG_ERROR + synckolab.global.LOG_AB);
+ return null;
+ }
var topNode = doc.firstChild;
+
+ // workaround for parsers that create a node for whitespace
+ if(topNode.nodeType === Node.TEXT_NODE) {
+ topNode = topNode.nextSibling;
+ }
+
if (topNode.nodeName === "parsererror") {
// so this message has no valid XML part :-(
- com.synckolab.tools.logMessage("Error parsing the XML content of this message.\n" + xml, com.synckolab.global.LOG_ERROR + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Error parsing the XML content of this message.\n" + xml, synckolab.global.LOG_ERROR + synckolab.global.LOG_AB);
return null;
}
if ((topNode.nodeType !== Node.ELEMENT_NODE) || (topNode.nodeName.toUpperCase() !== "CONTACT")) {
@@ -590,14 +598,14 @@ com.synckolab.addressbookTools.xml2Card = function (xml, card) {
return this.Xml2List(topNode, card);
}
// this can't be an event in Kolab XML format
- com.synckolab.tools.logMessage("This message doesn't contain a contact in Kolab XML format (" + topNode.nodeName + ").\n" + xml, com.synckolab.global.LOG_ERROR + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("This message doesn't contain a contact in Kolab XML format (" + topNode.nodeName + ").\n" + xml, synckolab.global.LOG_ERROR + synckolab.global.LOG_AB);
return null;
}
-
- cur = new com.synckolab.Node(doc.firstChild.firstChild);
+
+ cur = new synckolab.Node(topNode.firstChild);
} else {
- com.synckolab.tools.logMessage("parsing dom tree into card.", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
- cur = new com.synckolab.Node(xml.firstChild);
+ synckolab.tools.logMessage("parsing dom tree into card.", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
+ cur = new synckolab.Node(xml.firstChild);
}
var found = false;
@@ -645,20 +653,20 @@ com.synckolab.addressbookTools.xml2Card = function (xml, card) {
// 1: plaintext
// 2: html
var format = cur.getFirstData().toUpperCase();
- this.setCardProperty(card, "PreferMailFormat", com.synckolab.addressbookTools.MAIL_FORMAT_UNKNOWN);
+ this.setCardProperty(card, "PreferMailFormat", synckolab.addressbookTools.MAIL_FORMAT_UNKNOWN);
switch (format) {
case 'PLAINTEXT':
case 'TEXT':
case 'TXT':
case 'PLAIN':
case '1':
- this.setCardProperty(card, "PreferMailFormat", com.synckolab.addressbookTools.MAIL_FORMAT_PLAINTEXT);
+ this.setCardProperty(card, "PreferMailFormat", synckolab.addressbookTools.MAIL_FORMAT_PLAINTEXT);
break;
case 'HTML':
case 'RICHTEXT':
case 'RICH':
case '2':
- this.setCardProperty(card, "PreferMailFormat", com.synckolab.addressbookTools.MAIL_FORMAT_HTML);
+ this.setCardProperty(card, "PreferMailFormat", synckolab.addressbookTools.MAIL_FORMAT_HTML);
}
break;
@@ -680,7 +688,7 @@ com.synckolab.addressbookTools.xml2Card = function (xml, card) {
case "SMTP-ADDRESS":
case "EMAIL":
- //com.synckolab.tools.logMessage("email: " + email + " - " + cur.getXmlResult("SMTP-ADDRESS", ""), com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ //synckolab.tools.logMessage("email: " + email + " - " + cur.getXmlResult("SMTP-ADDRESS", ""), synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
switch (email) {
case 0:
this.setCardProperty(card, "PrimaryEmail", cur.getXmlResult("SMTP-ADDRESS", ""));
@@ -827,7 +835,7 @@ com.synckolab.addressbookTools.xml2Card = function (xml, card) {
var cnotes = cur.getFirstData();
this.setCardProperty(card, "Notes", cnotes.replace(/\\n/g, "\n"));
- com.synckolab.tools.logMessage("cur.firstchild.data.length=" + cur.firstChild.data.length + " - cnotes=" + cnotes.length + " - card.notes=" + this.getCardProperty(card, "Notes").length, com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("cur.firstchild.data.length=" + cur.firstChild.data.length + " - cnotes=" + cnotes.length + " - card.notes=" + this.getCardProperty(card, "Notes").length, synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
found = true;
break;
case "DEPARTMENT":
@@ -907,7 +915,7 @@ com.synckolab.addressbookTools.xml2Card = function (xml, card) {
}
if (cur.nodeName !== "product-id" && cur.nodeName !== "sensitivity") {
// remember other fields
- com.synckolab.tools.logMessage("FIELD not found: " + cur.nodeName + "=" + cur.getFirstData(), com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("FIELD not found: " + cur.nodeName + "=" + cur.getFirstData(), synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
this.setCardProperty(card, cur.nodeName, cur.getFirstData(), true);
}
break;
@@ -925,9 +933,9 @@ com.synckolab.addressbookTools.xml2Card = function (xml, card) {
return null;
};
-com.synckolab.addressbookTools.list2Pojo = function (card) {
+synckolab.addressbookTools.list2Pojo = function (card) {
var pojo = {
- synckolab : com.synckolab.config.version, // synckolab version
+ synckolab : synckolab.config.version, // synckolab version
type : "maillist", // a contact
isMailList : true,
ts : new Date().getTime(), // the current time
@@ -958,7 +966,7 @@ com.synckolab.addressbookTools.list2Pojo = function (card) {
pojo.contacts.push(cardObj);
}
} else {
- com.synckolab.tools.logMessage("lists not supported ", com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("lists not supported ", synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
return null;
}
@@ -971,27 +979,27 @@ com.synckolab.addressbookTools.list2Pojo = function (card) {
* @param card nsIAbCard: the adress book list card
* @param fields Array: all the fields not being held in the default card
*/
-com.synckolab.addressbookTools.list2Xml = function (card, fields) {
+synckolab.addressbookTools.list2Xml = function (card, fields) {
var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
xml += "<distribution-list version=\"1.0\" >\n";
xml += " <product-id>SyncKolab, Kolab resource</product-id>\n";
xml += " <uid>" + this.getUID(card) + "</uid>\n";
- xml += " <creation-date>" + com.synckolab.tools.text.date2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "T" + com.synckolab.tools.text.time2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "Z</creation-date>\n";
- xml += " <last-modification-date>" + com.synckolab.tools.text.date2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "T" + com.synckolab.tools.text.time2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "Z</last-modification-date>\n";
+ xml += " <creation-date>" + synckolab.tools.text.date2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "T" + synckolab.tools.text.time2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "Z</creation-date>\n";
+ xml += " <last-modification-date>" + synckolab.tools.text.date2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "T" + synckolab.tools.text.time2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "Z</last-modification-date>\n";
// default: public - tbird doesnt know of other types of list like private
xml += " <sensitivity>public</sensitivity>\n";
- xml += " <name>" + com.synckolab.tools.text.encode4XML(this.getCardProperty(card, "DisplayName")) + "</name>\n";
+ xml += " <name>" + synckolab.tools.text.encode4XML(this.getCardProperty(card, "DisplayName")) + "</name>\n";
if (this.haveCardProperty(card, "Notes")) {
- xml += " <body>" + com.synckolab.tools.text.encode4XML(this.getCardProperty(card, "Notes")) + "</body>\n";
+ xml += " <body>" + synckolab.tools.text.encode4XML(this.getCardProperty(card, "Notes")) + "</body>\n";
}
if (this.haveCardProperty(card, "NickName")) {
- xml += " <nickname>" + com.synckolab.tools.text.encode4XML(this.getCardProperty(card, "NickName")) + "</nickname>\n";
+ xml += " <nickname>" + synckolab.tools.text.encode4XML(this.getCardProperty(card, "NickName")) + "</nickname>\n";
}
- com.synckolab.tools.logMessage("going through child cards", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("going through child cards", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
var cList = this.abListObject(card);
var lCards = cList.childCards;
if (lCards) {
@@ -1003,36 +1011,36 @@ com.synckolab.addressbookTools.list2Xml = function (card, fields) {
// get the uid or generate it
var uid = this.getUID(cur);
if (!uid) {
- uid = "sk-vc-" + com.synckolab.tools.text.randomVcardId();
- com.synckolab.addressbookTools.setUID(cur, uid);
+ uid = "sk-vc-" + synckolab.tools.text.randomVcardId();
+ synckolab.addressbookTools.setUID(cur, uid);
}
xml += " <member>\n";
if (this.haveCardProperty(cur, "DisplayName")) {
- xml += " " + com.synckolab.tools.text.nodeWithContent("display-name", this.getCardProperty(cur, "DisplayName"), false);
+ xml += " " + synckolab.tools.text.nodeWithContent("display-name", this.getCardProperty(cur, "DisplayName"), false);
}
if (this.haveCardProperty(cur, "PrimaryEmail")) {
- xml += " " + com.synckolab.tools.text.nodeWithContent("smtp-address", this.getCardProperty(cur, "PrimaryEmail"), false);
+ xml += " " + synckolab.tools.text.nodeWithContent("smtp-address", this.getCardProperty(cur, "PrimaryEmail"), false);
} else if (this.haveCardProperty(cur, "SecondEmail")) {
- xml += " " + com.synckolab.tools.text.nodeWithContent("smtp-address", this.getCardProperty(cur, "SecondEmail"), false);
+ xml += " " + synckolab.tools.text.nodeWithContent("smtp-address", this.getCardProperty(cur, "SecondEmail"), false);
} else {
- com.synckolab.tools.logMessage("List entry without an email!" + this.getUID(cur), com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("List entry without an email!" + this.getUID(cur), synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
}
- xml += " " + com.synckolab.tools.text.nodeWithContent("uid", uid, false);
+ xml += " " + synckolab.tools.text.nodeWithContent("uid", uid, false);
xml += " </member>\n";
}
} else {
- com.synckolab.tools.logMessage("lists not supported " + xml, com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("lists not supported " + xml, synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
return null;
}
} else {
- com.synckolab.tools.logMessage("lists not supported " + xml, com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("lists not supported " + xml, synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
return null;
}
xml += "</distribution-list>\n";
- com.synckolab.tools.logMessage("list: " + xml, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("list: " + xml, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return xml;
};
@@ -1043,27 +1051,27 @@ com.synckolab.addressbookTools.list2Xml = function (card, fields) {
* @param card nsIAbCard: the adress book list card
* @param fields Array: all the fields not being held in the default card
*/
-com.synckolab.addressbookTools.list2Vcard = function (card, fields) {
+synckolab.addressbookTools.list2Vcard = function (card, fields) {
// save the date in microseconds
// Date: Fri, 17 Dec 2004 15:06:42 +0100
var cdate = new Date(this.getCardProperty(card, "LastModifiedDate") * 1000);
var sTime = (cdate.getHours() < 10 ? "0" : "") + cdate.getHours() + ":" + (cdate.getMinutes() < 10 ? "0" : "") + cdate.getMinutes() + ":" + (cdate.getSeconds() < 10 ? "0" : "") + cdate.getSeconds();
- var sdate = "DATE: " + com.synckolab.tools.text.getDayString(cdate.getDay()) + ", " +
- cdate.getDate() + " " + com.synckolab.tools.text.getMonthString(cdate.getMonth()) + " " +
+ var sdate = "DATE: " + synckolab.tools.text.getDayString(cdate.getDay()) + ", " +
+ cdate.getDate() + " " + synckolab.tools.text.getMonthString(cdate.getMonth()) + " " +
cdate.getFullYear() + " " + sTime + " " + (((cdate.getTimezoneOffset() / 60) < 0) ? "-" : "+") +
(((cdate.getTimezoneOffset() / 60) < 10) ? "0" : "") + cdate.getTimezoneOffset() + "\n";
var msg = "BEGIN:VCARD\n";
msg += "UID:" + this.getUID(card) + "\n";
- msg += "FN:" + com.synckolab.tools.text.quoted.encode(card.displayName) + "\n";
+ msg += "FN:" + synckolab.tools.text.quoted.encode(card.displayName) + "\n";
if (this.haveCardProperty(card, "Notes")) {
- msg += 'NOTE:' + com.synckolab.tools.text.quoted.encode(this.getCardProperty(card, "Notes")) + "\n";
+ msg += 'NOTE:' + synckolab.tools.text.quoted.encode(this.getCardProperty(card, "Notes")) + "\n";
}
if (this.haveCardProperty(card, "NickName")) {
- msg += "NICK:" + com.synckolab.tools.text.quoted.encode(this.getCardProperty(card, "NickName")) + "\n";
+ msg += "NICK:" + synckolab.tools.text.quoted.encode(this.getCardProperty(card, "NickName")) + "\n";
}
var uidList = "";
@@ -1071,7 +1079,7 @@ com.synckolab.addressbookTools.list2Vcard = function (card, fields) {
var cList = card;
if (cList.addressLists) {
var total = cList.addressLists.length;
- com.synckolab.tools.logMessage("List has " + total + " contacts", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("List has " + total + " contacts", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
if (!total || total === 0) {
return null; // do not add a list without members
}
@@ -1099,7 +1107,7 @@ com.synckolab.addressbookTools.list2Vcard = function (card, fields) {
/**
* moves the temp image stored in /tmp/synckolab.img to its final position
*/
-com.synckolab.addressbookTools.copyImage = function (newName) {
+synckolab.addressbookTools.copyImage = function (newName) {
// wrong name - forget it
if (newName === null || newName === "" || newName === "null") {
return;
@@ -1126,7 +1134,7 @@ com.synckolab.addressbookTools.copyImage = function (newName) {
try {
file.moveTo(fileTo, newName);
} catch (ex) {
- com.synckolab.tools.logMessage("Unable to move file " + newName + "\n" + ex, com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Unable to move file " + newName + "\n" + ex, synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
}
// check if the file exists
@@ -1140,10 +1148,10 @@ com.synckolab.addressbookTools.copyImage = function (newName) {
* @param card nsIAbCard: the adress book card
* @param fields Array: all the fields not being held in the default card
*/
-com.synckolab.addressbookTools.card2Xml = function (card, fields) {
+synckolab.addressbookTools.card2Xml = function (card, fields) {
// translate the card: base64xml, xml, vcard
- //com.synckolab.tools.logMessage ("XML: \n" + card.translateTo("xml"), com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB); - dont work is actually a HTML
- //com.synckolab.tools.logMessage ("VCARD: \n" + card.translateTo("vcard"), com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB); // converts a little too much and ignores uuid
+ //synckolab.tools.logMessage ("XML: \n" + card.translateTo("xml"), synckolab.global.LOG_WARNING + synckolab.global.LOG_AB); - dont work is actually a HTML
+ //synckolab.tools.logMessage ("VCARD: \n" + card.translateTo("vcard"), synckolab.global.LOG_WARNING + synckolab.global.LOG_AB); // converts a little too much and ignores uuid
// debug for photo:
@@ -1151,53 +1159,53 @@ com.synckolab.addressbookTools.card2Xml = function (card, fields) {
var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
xml += "<contact version=\"1.0\" >\n";
xml += " <product-id>SyncKolab, Kolab resource</product-id>\n";
- xml += " <uid>" + com.synckolab.tools.text.encode4XML(this.getUID(card)) + "</uid>\n";
- xml += com.synckolab.tools.text.nodeWithContent("categories", this.getCardProperty(card, "Category"), false);
- //xml += " <creation-date>"+com.synckolab.tools.text.date2String(new Date(this.getCardProperty(card, "LastModifiedDate")*1000))+"T"+com.synckolab.tools.text.time2String(new Date(this.getCardProperty(card, "LastModifiedDate")*1000))+"Z</creation-date>\n";
- xml += " <last-modification-date>" + com.synckolab.tools.text.date2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "T" + com.synckolab.tools.text.time2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "Z</last-modification-date>\n";
+ xml += " <uid>" + synckolab.tools.text.encode4XML(this.getUID(card)) + "</uid>\n";
+ xml += synckolab.tools.text.nodeWithContent("categories", this.getCardProperty(card, "Category"), false);
+ //xml += " <creation-date>"+synckolab.tools.text.date2String(new Date(this.getCardProperty(card, "LastModifiedDate")*1000))+"T"+synckolab.tools.text.time2String(new Date(this.getCardProperty(card, "LastModifiedDate")*1000))+"Z</creation-date>\n";
+ xml += " <last-modification-date>" + synckolab.tools.text.date2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "T" + synckolab.tools.text.time2String(new Date(this.getCardProperty(card, "LastModifiedDate") * 1000)) + "Z</last-modification-date>\n";
// ??
xml += " <sensitivity>public</sensitivity>\n";
if (this.haveCardProperty(card, "Notes")) {
- xml += " <body>" + com.synckolab.tools.text.encode4XML(this.getCardProperty(card, "Notes")) + "</body>\n";
+ xml += " <body>" + synckolab.tools.text.encode4XML(this.getCardProperty(card, "Notes")) + "</body>\n";
}
if (this.haveCardProperty(card, "FirstName") || this.haveCardProperty(card, "LastName") || this.haveCardProperty(card, "DisplayName") || this.haveCardProperty(card, "NickName")) {
xml += " <name>\n";
if (this.haveCardProperty(card, "FirstName")) {
- xml += " <given-name>" + com.synckolab.tools.text.encode4XML(this.getCardProperty(card, "FirstName")) + "</given-name>\n";
+ xml += " <given-name>" + synckolab.tools.text.encode4XML(this.getCardProperty(card, "FirstName")) + "</given-name>\n";
}
// xml += " <middle-names>"+this.getCardProperty(card, "NickName")+"</middle-names>\n"; // not really correct...
if (this.haveCardProperty(card, "LastName")) {
- xml += " <last-name>" + com.synckolab.tools.text.encode4XML(this.getCardProperty(card, "LastName")) + "</last-name>\n";
+ xml += " <last-name>" + synckolab.tools.text.encode4XML(this.getCardProperty(card, "LastName")) + "</last-name>\n";
}
if (this.haveCardProperty(card, "DisplayName")) {
- xml += " <full-name>" + com.synckolab.tools.text.encode4XML(this.getCardProperty(card, "DisplayName")) + "</full-name>\n";
+ xml += " <full-name>" + synckolab.tools.text.encode4XML(this.getCardProperty(card, "DisplayName")) + "</full-name>\n";
displayName = this.getCardProperty(card, "DisplayName");
} else if (this.haveCardProperty(card, "FirstName") || this.haveCardProperty(card, "LastName")) {
displayName = this.getCardProperty(card, "FirstName") + " " + this.getCardProperty(card, "LastName");
- xml += com.synckolab.tools.text.nodeWithContent("full-name", displayName);
+ xml += synckolab.tools.text.nodeWithContent("full-name", displayName);
}
xml += " </name>\n";
}
- xml += com.synckolab.tools.text.nodeWithContent("organization", this.getCardProperty(card, "Company"), false);
- xml += com.synckolab.tools.text.nodeWithContent("web-page", this.getCardProperty(card, "WebPage1"), false);
+ xml += synckolab.tools.text.nodeWithContent("organization", this.getCardProperty(card, "Company"), false);
+ xml += synckolab.tools.text.nodeWithContent("web-page", this.getCardProperty(card, "WebPage1"), false);
// not really kolab.. but we need that somewhere
- xml += com.synckolab.tools.text.nodeWithContent("business-web-page", this.getCardProperty(card, "WebPage2"), false);
- xml += com.synckolab.tools.text.nodeWithContent("im-address", this.getCardProperty(card, "AimScreenName"), false);
- xml += com.synckolab.tools.text.nodeWithContent("department", this.getCardProperty(card, "Department"), false);
+ xml += synckolab.tools.text.nodeWithContent("business-web-page", this.getCardProperty(card, "WebPage2"), false);
+ xml += synckolab.tools.text.nodeWithContent("im-address", this.getCardProperty(card, "AimScreenName"), false);
+ xml += synckolab.tools.text.nodeWithContent("department", this.getCardProperty(card, "Department"), false);
//" <office-location>zuhaus</office-location>\n";
//" <profession>programmierer</profession>\n";
- xml += com.synckolab.tools.text.nodeWithContent("job-title", this.getCardProperty(card, "JobTitle"), false);
- xml += com.synckolab.tools.text.nodeWithContent("nick-name", this.getCardProperty(card, "NickName"), false);
+ xml += synckolab.tools.text.nodeWithContent("job-title", this.getCardProperty(card, "JobTitle"), false);
+ xml += synckolab.tools.text.nodeWithContent("nick-name", this.getCardProperty(card, "NickName"), false);
var adate;
if (this.haveCardProperty(card, "BirthYear") && this.haveCardProperty(card, "BirthMonth") && this.haveCardProperty(card, "BirthDay")) {
adate = this.getCardProperty(card, "BirthYear") + "-" + this.getCardProperty(card, "BirthMonth") + "-" + this.getCardProperty(card, "BirthDay");
- xml += com.synckolab.tools.text.nodeWithContent("birthday", adate, false);
+ xml += synckolab.tools.text.nodeWithContent("birthday", adate, false);
}
if (this.haveCardProperty(card, "AnniversaryYear") && this.haveCardProperty(card, "AnniversaryMonth") && this.haveCardProperty(card, "AnniversaryDay")) {
adate = this.getCardProperty(card, "AnniversaryYear") + "-" + this.getCardProperty(card, "AnniversaryMonth") + "-" + this.getCardProperty(card, "AnniversaryDay");
- xml += com.synckolab.tools.text.nodeWithContent("anniversary", adate, false);
+ xml += synckolab.tools.text.nodeWithContent("anniversary", adate, false);
}
if (this.haveCardProperty(card, "HomePhone")) {
xml += " <phone>\n";
@@ -1232,53 +1240,53 @@ com.synckolab.addressbookTools.card2Xml = function (card, fields) {
if (this.haveCardProperty(card, "PrimaryEmail")) {
xml += " <email type=\"primary\">\n";
- xml += " <display-name>" + com.synckolab.tools.text.encode4XML(displayName) + "</display-name>\n";
- xml += " <smtp-address>" + com.synckolab.tools.text.encode4XML(this.getCardProperty(card, "PrimaryEmail")) + "</smtp-address>\n";
+ xml += " <display-name>" + synckolab.tools.text.encode4XML(displayName) + "</display-name>\n";
+ xml += " <smtp-address>" + synckolab.tools.text.encode4XML(this.getCardProperty(card, "PrimaryEmail")) + "</smtp-address>\n";
xml += " </email>\n";
}
if (this.haveCardProperty(card, "SecondEmail")) {
xml += " <email>\n";
- xml += " <display-name>" + com.synckolab.tools.text.encode4XML(displayName) + "</display-name>\n";
- xml += " <smtp-address>" + com.synckolab.tools.text.encode4XML(this.getCardProperty(card, "SecondEmail")) + "</smtp-address>\n";
+ xml += " <display-name>" + synckolab.tools.text.encode4XML(displayName) + "</display-name>\n";
+ xml += " <smtp-address>" + synckolab.tools.text.encode4XML(this.getCardProperty(card, "SecondEmail")) + "</smtp-address>\n";
xml += " </email>\n";
}
// if the mail format is set...
- if (this.getCardProperty(card, "PreferMailFormat") && this.getCardProperty(card, "PreferMailFormat") !== com.synckolab.addressbookTools.MAIL_FORMAT_UNKNOWN) {
+ if (this.getCardProperty(card, "PreferMailFormat") && this.getCardProperty(card, "PreferMailFormat") !== synckolab.addressbookTools.MAIL_FORMAT_UNKNOWN) {
if (Number(this.getCardProperty(card, "PreferMailFormat")) === this.MAIL_FORMAT_PLAINTEXT) {
- xml += com.synckolab.tools.text.nodeWithContent("prefer-mail-format", "text", false);
+ xml += synckolab.tools.text.nodeWithContent("prefer-mail-format", "text", false);
} else if (Number(this.getCardProperty(card, "PreferMailFormat")) === this.MAIL_FORMAT_HTML) {
- xml += com.synckolab.tools.text.nodeWithContent("prefer-mail-format", "html", false);
+ xml += synckolab.tools.text.nodeWithContent("prefer-mail-format", "html", false);
}
}
if (this.haveCardProperty(card, "HomeAddress") || this.haveCardProperty(card, "HomeAddress2") || this.haveCardProperty(card, "HomeCity") || this.haveCardProperty(card, "HomeState") || this.haveCardProperty(card, "HomeZipCode") || this.haveCardProperty(card, "HomeCountry")) {
xml += " <address>\n";
xml += " <type>home</type>\n";
- xml += com.synckolab.tools.text.nodeWithContent("street", this.getCardProperty(card, "HomeAddress"), false);
- xml += com.synckolab.tools.text.nodeWithContent("street2", this.getCardProperty(card, "HomeAddress2"), false);
- xml += com.synckolab.tools.text.nodeWithContent("locality", this.getCardProperty(card, "HomeCity"), false);
- xml += com.synckolab.tools.text.nodeWithContent("region", this.getCardProperty(card, "HomeState"), false);
- xml += com.synckolab.tools.text.nodeWithContent("postal-code", this.getCardProperty(card, "HomeZipCode"), false);
- xml += com.synckolab.tools.text.nodeWithContent("country", this.getCardProperty(card, "HomeCountry"), false);
+ xml += synckolab.tools.text.nodeWithContent("street", this.getCardProperty(card, "HomeAddress"), false);
+ xml += synckolab.tools.text.nodeWithContent("street2", this.getCardProperty(card, "HomeAddress2"), false);
+ xml += synckolab.tools.text.nodeWithContent("locality", this.getCardProperty(card, "HomeCity"), false);
+ xml += synckolab.tools.text.nodeWithContent("region", this.getCardProperty(card, "HomeState"), false);
+ xml += synckolab.tools.text.nodeWithContent("postal-code", this.getCardProperty(card, "HomeZipCode"), false);
+ xml += synckolab.tools.text.nodeWithContent("country", this.getCardProperty(card, "HomeCountry"), false);
xml += " </address>\n";
}
if (this.haveCardProperty(card, "WorkAddress") || this.haveCardProperty(card, "WorkAddress2") || this.haveCardProperty(card, "WorkCity") || this.haveCardProperty(card, "WorkState") || this.haveCardProperty(card, "WorkZipCode") || this.haveCardProperty(card, "WorkCountry")) {
xml += " <address>\n";
xml += " <type>business</type>\n";
- xml += com.synckolab.tools.text.nodeWithContent("street", this.getCardProperty(card, "WorkAddress"), false);
- xml += com.synckolab.tools.text.nodeWithContent("street2", this.getCardProperty(card, "WorkAddress2"), false);
- xml += com.synckolab.tools.text.nodeWithContent("locality", this.getCardProperty(card, "WorkCity"), false);
- xml += com.synckolab.tools.text.nodeWithContent("region", this.getCardProperty(card, "WorkState"), false);
- xml += com.synckolab.tools.text.nodeWithContent("postal-code", this.getCardProperty(card, "WorkZipCode"), false);
- xml += com.synckolab.tools.text.nodeWithContent("country", this.getCardProperty(card, "WorkCountry"), false);
+ xml += synckolab.tools.text.nodeWithContent("street", this.getCardProperty(card, "WorkAddress"), false);
+ xml += synckolab.tools.text.nodeWithContent("street2", this.getCardProperty(card, "WorkAddress2"), false);
+ xml += synckolab.tools.text.nodeWithContent("locality", this.getCardProperty(card, "WorkCity"), false);
+ xml += synckolab.tools.text.nodeWithContent("region", this.getCardProperty(card, "WorkState"), false);
+ xml += synckolab.tools.text.nodeWithContent("postal-code", this.getCardProperty(card, "WorkZipCode"), false);
+ xml += synckolab.tools.text.nodeWithContent("country", this.getCardProperty(card, "WorkCountry"), false);
xml += " </address>\n";
}
// photo name = photo - this is an attachment (handled outside)
- xml += com.synckolab.tools.text.nodeWithContent("picture", this.getCardProperty(card, "PhotoName"), false);
+ xml += synckolab.tools.text.nodeWithContent("picture", this.getCardProperty(card, "PhotoName"), false);
// we can probably ignore that
var ptype = this.getCardProperty(card, "PhotoType");
@@ -1288,18 +1296,18 @@ com.synckolab.addressbookTools.card2Xml = function (card, fields) {
* found in ~profil/Photos/FILENAME
* 2. create an attachment name FILENAME with the content (base64 encoded)
*/
- xml += com.synckolab.tools.text.nodeWithContent("picture-uri", this.getCardProperty(card, "PhotoURI"), false); // we can distinguish between file: and http: anyways
+ xml += synckolab.tools.text.nodeWithContent("picture-uri", this.getCardProperty(card, "PhotoURI"), false); // we can distinguish between file: and http: anyways
}
- //xml += com.synckolab.tools.text.nodeWithContent("preferred-address", this.getCardProperty(card, "DefaultAddress"), false); @deprecated
- xml += com.synckolab.tools.text.nodeWithContent("custom1", this.getCardProperty(card, "Custom1"), false);
- xml += com.synckolab.tools.text.nodeWithContent("custom2", this.getCardProperty(card, "Custom2"), false);
- xml += com.synckolab.tools.text.nodeWithContent("custom3", this.getCardProperty(card, "Custom3"), false);
- xml += com.synckolab.tools.text.nodeWithContent("custom4", this.getCardProperty(card, "Custom4"), false);
+ //xml += synckolab.tools.text.nodeWithContent("preferred-address", this.getCardProperty(card, "DefaultAddress"), false); @deprecated
+ xml += synckolab.tools.text.nodeWithContent("custom1", this.getCardProperty(card, "Custom1"), false);
+ xml += synckolab.tools.text.nodeWithContent("custom2", this.getCardProperty(card, "Custom2"), false);
+ xml += synckolab.tools.text.nodeWithContent("custom3", this.getCardProperty(card, "Custom3"), false);
+ xml += synckolab.tools.text.nodeWithContent("custom4", this.getCardProperty(card, "Custom4"), false);
if (this.getCardProperty(card, "AllowRemoteContent")) {
- xml += com.synckolab.tools.text.nodeWithContent("allow-remote-content", "true", false);
+ xml += synckolab.tools.text.nodeWithContent("allow-remote-content", "true", false);
} else {
- xml += com.synckolab.tools.text.nodeWithContent("allow-remote-content", "false", false);
+ xml += synckolab.tools.text.nodeWithContent("allow-remote-content", "false", false);
}
// add extra/missing fields
@@ -1315,8 +1323,8 @@ com.synckolab.addressbookTools.card2Xml = function (card, fields) {
/**
* Generate a sha1 key out of a vcard - used for database
*/
-com.synckolab.addressbookTools.genConSha1 = function (card) {
- return com.synckolab.tools.sha1.hex_sha1(this.getCardProperty(card, "AimScreenName") + ":" + this.getCardProperty(card, "AnniversaryDay") + ":" + this.getCardProperty(card, "AnniversaryMonth") + ":" + this.getCardProperty(card, "AnniversaryYear") + ":" + this.getCardProperty(card, "BirthDay") +
+synckolab.addressbookTools.genConSha1 = function (card) {
+ return synckolab.tools.sha1.hex_sha1(this.getCardProperty(card, "AimScreenName") + ":" + this.getCardProperty(card, "AnniversaryDay") + ":" + this.getCardProperty(card, "AnniversaryMonth") + ":" + this.getCardProperty(card, "AnniversaryYear") + ":" + this.getCardProperty(card, "BirthDay") +
":" + this.getCardProperty(card, "BirthMonth") + ":" + this.getCardProperty(card, "BirthYear") + ":" + this.getCardProperty(card, "CardType") + ":" + this.getCardProperty(card, "Category") + ":" + this.getCardProperty(card, "CellularNumber") +
":" + this.getCardProperty(card, "CellularNumberType") + ":" + this.getCardProperty(card, "Company") + ":" + this.getCardProperty(card, "Custom1") + ":" + this.getCardProperty(card, "Custom2") + ":" + this.getCardProperty(card, "Custom3") + ":" + this.getCardProperty(card, "Custom4") + ":" +
//this.getCardProperty(card, "DefaultAddress") + ":" + @deprecated
@@ -1336,7 +1344,7 @@ com.synckolab.addressbookTools.genConSha1 = function (card) {
* It takes note of most fields (except custom4)
*
*/
-com.synckolab.addressbookTools.equalsContact = function (a, b) {
+synckolab.addressbookTools.equalsContact = function (a, b) {
//Fields to look for
var fieldsArray;
// remember the numeric field
@@ -1344,12 +1352,12 @@ com.synckolab.addressbookTools.equalsContact = function (a, b) {
// if one does not exist - they are definitely different!
if (!a || !b) {
- com.synckolab.tools.logMessage("not equals: " + (a?"a":"b") + " does not exist" , com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("not equals: " + (a?"a":"b") + " does not exist" , synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return false;
}
if (a.isMailList !== b.isMailList) {
- com.synckolab.tools.logMessage("not equals isMailList: '" + (a.isMailList ? "true" : "false") + "' vs. '" + (b.isMailList ? "true" : "false") + "'", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("not equals isMailList: '" + (a.isMailList ? "true" : "false") + "' vs. '" + (b.isMailList ? "true" : "false") + "'", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
return false;
}
@@ -1394,7 +1402,7 @@ com.synckolab.addressbookTools.equalsContact = function (a, b) {
if (sa === null && sb === null) {
continue;
} else {
- com.synckolab.tools.logMessage("not equals " + fieldsArray[i] + " '" + sa + "' vs. '" + sb + "'", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("not equals " + fieldsArray[i] + " '" + sa + "' vs. '" + sb + "'", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return false;
}
}
@@ -1409,28 +1417,28 @@ com.synckolab.addressbookTools.equalsContact = function (a, b) {
}
}
- com.synckolab.tools.logMessage("not equals " + fieldsArray[i] + " '" + sa + "' vs. '" + sb + "'", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("not equals " + fieldsArray[i] + " '" + sa + "' vs. '" + sb + "'", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return false;
}
}
if (a.isMailList) {
- com.synckolab.tools.logMessage("start comparing mailing lists!", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("start comparing mailing lists!", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
// convert lists to simple object
if (!a.synckolab) {
- a = com.synckolab.addressbookTools.list2Pojo(a);
+ a = synckolab.addressbookTools.list2Pojo(a);
}
if (!b.synckolab) {
- b = com.synckolab.addressbookTools.list2Pojo(b);
+ b = synckolab.addressbookTools.list2Pojo(b);
}
- com.synckolab.tools.logMessage(a.toSource() + " vs. " + b.toSource(), com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage(a.toSource() + " vs. " + b.toSource(), synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
// length needs to be equal
if (a.contacts && b.contacts && a.contacts.length !== b.contacts.length) {
- com.synckolab.tools.logMessage("different amount of contacts in each list", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("different amount of contacts in each list", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
return false;
}
@@ -1449,7 +1457,7 @@ com.synckolab.addressbookTools.equalsContact = function (a, b) {
}
if(aContacts.length !== bContacts.length) {
- com.synckolab.tools.logMessage("different amount of contacts in each list (a:"+aContacts.length +" b: " + bContacts.length+")", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("different amount of contacts in each list (a:"+aContacts.length +" b: " + bContacts.length+")", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
return false;
}
@@ -1465,14 +1473,14 @@ com.synckolab.addressbookTools.equalsContact = function (a, b) {
}
// break at the first contact that has not been found
if (!found) {
- com.synckolab.tools.logMessage("contact: " + bContacts[i].UUID + " not in both lists!", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("contact: " + bContacts[i].UUID + " not in both lists!", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
return false;
}
}
// if there are any childcards left - return
if (aContacts.length > 0) {
- com.synckolab.tools.logMessage("still " + aContacts.length + " contacts in a", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("still " + aContacts.length + " contacts in a", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
return false;
}
// listst are equals
@@ -1482,7 +1490,7 @@ com.synckolab.addressbookTools.equalsContact = function (a, b) {
return true;
};
-com.synckolab.addressbookTools.vList2Card = function (uids, lines, card, cards) {
+synckolab.addressbookTools.vList2Card = function (uids, lines, card, cards) {
var beginVCard = false;
card.type = "maillist";
@@ -1504,7 +1512,7 @@ com.synckolab.addressbookTools.vList2Card = function (uids, lines, card, cards)
tok[1] += ":" + tok[j];
}
- com.synckolab.tools.logMessage("parsing: " + lines[i], com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("parsing: " + lines[i], synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
var found;
switch (tok[0].toUpperCase()) {
case "DATE":
@@ -1555,9 +1563,9 @@ com.synckolab.addressbookTools.vList2Card = function (uids, lines, card, cards)
}
}
var newCard = Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance(Components.interfaces.nsIAbCard);
- com.synckolab.addressbookTools.message2Card(lines, newCard, null, cStart, i);
+ synckolab.addressbookTools.message2Card(lines, newCard, null, cStart, i);
// check if we know this card already :) - ONLY cards
- var gotCard = com.synckolab.addressbookTools.findCard(cards, this.getUID(newCard), null);
+ var gotCard = synckolab.addressbookTools.findCard(cards, this.getUID(newCard), null);
if (gotCard) {
card.addressLists.appendElement(gotCard);
} else {
@@ -1572,7 +1580,7 @@ com.synckolab.addressbookTools.vList2Card = function (uids, lines, card, cards)
break;
default:
- com.synckolab.tools.logMessage("VL FIELD not found: " + tok[0] + ":" + tok[1], com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("VL FIELD not found: " + tok[0] + ":" + tok[1], synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
//extraFields.addField(tok[0], tok[1]);
break;
} // end switch
@@ -1586,11 +1594,11 @@ com.synckolab.addressbookTools.vList2Card = function (uids, lines, card, cards)
* @param topNode the node to parse
* @param card the card object
*/
-com.synckolab.addressbookTools.Xml2List = function (topNode, card) {
+synckolab.addressbookTools.Xml2List = function (topNode, card) {
card.type = "maillist";
card.isMailList = true;
- var cur = new com.synckolab.Node(topNode.firstChild);
+ var cur = new synckolab.Node(topNode.firstChild);
var found = false;
var email = 0;
@@ -1643,7 +1651,7 @@ com.synckolab.addressbookTools.Xml2List = function (topNode, card) {
card.contacts = [];
}
var member = {
- synckolab : com.synckolab.config.version, // synckolab version
+ synckolab : synckolab.config.version, // synckolab version
listMember : true,
type : "contact", // a contact
isMailList : false,
@@ -1651,8 +1659,8 @@ com.synckolab.addressbookTools.Xml2List = function (topNode, card) {
// the current time
};
// parse the whole card
- com.synckolab.addressbookTools.xml2Card(cur, member);
- com.synckolab.tools.logMessage("FOUND CARD: " + member.toSource(), com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.addressbookTools.xml2Card(cur, member);
+ synckolab.tools.logMessage("FOUND CARD: " + member.toSource(), synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
card.contacts.push(member);
// parse the member - take as much as we wan
@@ -1664,7 +1672,7 @@ com.synckolab.addressbookTools.Xml2List = function (topNode, card) {
// ignore
break;
default:
- com.synckolab.tools.logMessage("Ignoring XML list FIELD not found: " + cur.nodeName, com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Ignoring XML list FIELD not found: " + cur.nodeName, synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
break;
}
@@ -1676,7 +1684,7 @@ com.synckolab.addressbookTools.Xml2List = function (topNode, card) {
if (!found) {
return null;
}
- com.synckolab.tools.logMessage("finished parsing list: " + this.getUID(card) + "\n" + card.toSource(), com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("finished parsing list: " + this.getUID(card) + "\n" + card.toSource(), synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
return card;
};
@@ -1684,19 +1692,19 @@ com.synckolab.addressbookTools.Xml2List = function (topNode, card) {
/**
* @return true if the message contains a list instead of a card
*/
-com.synckolab.addressbookTools.isMailList = function (message) {
+synckolab.addressbookTools.isMailList = function (message) {
if(message.synckolab) {
return message.type === "maillist";
}
if (message.indexOf("<?xml") !== -1 || message.indexOf("<?XML") !== -1) {
if (message.indexOf("<distribution-list") !== -1 || message.indexOf("<DISTRIBUTION-LIST") !== -1) {
- com.synckolab.tools.logMessage("is mail list returning true", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("is mail list returning true", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
return true;
}
}
if (message.indexOf("X-LIST") !== -1 || message.indexOf("x-list") !== -1) {
- com.synckolab.tools.logMessage("is mail list returning true", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("is mail list returning true", synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
return true;
}
@@ -1714,10 +1722,10 @@ com.synckolab.addressbookTools.isMailList = function (message) {
* @param message string - a string with the vcard (make sure its trimmed from whitespace)
* @return the filled object or null if not parseable
*/
-com.synckolab.addressbookTools.parseMessageContent = function (message) {
+synckolab.addressbookTools.parseMessageContent = function (message) {
// fix for bug #16766: message has no properties
if (message === null) {
- return false;
+ return null;
}
// if fileContent contains a synckolab field its already parsed
@@ -1727,7 +1735,7 @@ com.synckolab.addressbookTools.parseMessageContent = function (message) {
// the pojo contains the synckolab version - this is used to identify the content
var card = {
- synckolab : com.synckolab.config.version, // synckolab version
+ synckolab : synckolab.config.version, // synckolab version
type : "contact", // a contact
isMailList : false,
ts : new Date().getTime()
@@ -1737,23 +1745,23 @@ com.synckolab.addressbookTools.parseMessageContent = function (message) {
// check for xml style
if (message.indexOf("<?xml") !== -1 || message.indexOf("<?XML") !== -1) {
if (this.xml2Card(message, card)) {
- card.sha1 = com.synckolab.addressbookTools.genConSha1(card);
+ card.sha1 = synckolab.addressbookTools.genConSha1(card);
return card;
}
} else {
- com.synckolab.tools.logMessage("VCARD/VLIST!", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("VCARD/VLIST!", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
}
// decode utf8
- message = com.synckolab.tools.text.utf8.decode(message);
+ message = synckolab.tools.text.utf8.decode(message);
// check for errors in the decoded message
if (message.indexOf("TYPE=3D") !== -1) {
- message = com.synckolab.tools.text.quoted.decode(message);
+ message = synckolab.tools.text.quoted.decode(message);
} else
// that still looks double decoded
if (message.indexOf("=C3=") !== -1) {
- message = com.synckolab.tools.text.utf8.decode(com.synckolab.tools.text.quoted.decode(message));
+ message = synckolab.tools.text.utf8.decode(synckolab.tools.text.quoted.decode(message));
}
// make an array of all lines for easier parsing
@@ -1762,7 +1770,7 @@ com.synckolab.addressbookTools.parseMessageContent = function (message) {
// check if we got a list
for ( var i = 0; i < lines.length; i++) {
if (lines[i].toUpperCase().indexOf("X-LIST") !== -1) {
- com.synckolab.tools.logMessage("parsing a list: " + message, com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("parsing a list: " + message, synckolab.global.LOG_DEBUG + synckolab.global.LOG_AB);
if (!this.vList2Card(lines[i], lines, card)) {
return null;
}
@@ -1770,12 +1778,12 @@ com.synckolab.addressbookTools.parseMessageContent = function (message) {
}
}
- if (!com.synckolab.addressbookTools.message2Card(lines, card, 0, lines.length)) {
- com.synckolab.tools.logMessage("unparseable: " + message, com.synckolab.global.LOG_ERROR + com.synckolab.global.LOG_AB);
+ if (!synckolab.addressbookTools.message2Card(lines, card, 0, lines.length)) {
+ synckolab.tools.logMessage("unparseable: " + message, synckolab.global.LOG_ERROR + synckolab.global.LOG_AB);
return null;
}
- card.sha1 = com.synckolab.addressbookTools.genConSha1(card);
+ card.sha1 = synckolab.addressbookTools.genConSha1(card);
return card;
};
@@ -1784,7 +1792,7 @@ com.synckolab.addressbookTools.parseMessageContent = function (message) {
* @param base the base json object
* @return a thunderbird object (either nsIABCard or nsIAbDirectory)
*/
-com.synckolab.addressbookTools.createTBirdObject = function (base, cards) {
+synckolab.addressbookTools.createTBirdObject = function (base, cards) {
var card = null;
if (base.type === "contact") {
card = Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance(Components.interfaces.nsIAbCard);
@@ -1834,7 +1842,7 @@ com.synckolab.addressbookTools.createTBirdObject = function (base, cards) {
* @param fields Array - extra fields to save with the card (may be null)
*
*/
-com.synckolab.addressbookTools.message2Card = function (lines, card, startI, endI) {
+synckolab.addressbookTools.message2Card = function (lines, card, startI, endI) {
// reset the card
this.setCardProperty(card, "AimScreenName", "");
this.setCardProperty(card, "AnniversaryDay", "");
@@ -2000,7 +2008,7 @@ com.synckolab.addressbookTools.message2Card = function (lines, card, startI, end
this.setCardProperty(card, "SecondEmail", tok[1]);
gotEmailSecondary = true;
} else {
- com.synckolab.tools.logMessage("additional email found: " + tok[1], com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("additional email found: " + tok[1], synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
this.setCardProperty(card, tok[0], tok[1], true);
}
@@ -2189,7 +2197,7 @@ com.synckolab.addressbookTools.message2Card = function (lines, card, startI, end
break;
default:
- com.synckolab.tools.logMessage("VC FIELD not found: " + tok[0] + ":" + tok[1], com.synckolab.global.LOG_WARNING + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("VC FIELD not found: " + tok[0] + ":" + tok[1], synckolab.global.LOG_WARNING + synckolab.global.LOG_AB);
this.setCardProperty(card, tok[0], tok[1], true);
} // end switch
}
@@ -2197,13 +2205,13 @@ com.synckolab.addressbookTools.message2Card = function (lines, card, startI, end
// invalid VCARD: no uid:
if (this.getUID(card) === null) {
// generate one
- this.setUID(card, "vc-" + com.synckolab.tools.text.randomVcardId());
+ this.setUID(card, "vc-" + synckolab.tools.text.randomVcardId());
}
return found;
};
-com.synckolab.addressbookTools.list2Human = function (card) {
+synckolab.addressbookTools.list2Human = function (card) {
var msg = "";
msg += "Name: " + this.getCardProperty(card, "DisplayName") + "\n";
if (this.haveCardProperty(card, "Notes")) {
@@ -2231,17 +2239,17 @@ com.synckolab.addressbookTools.list2Human = function (card) {
* If this is a card, it will use the uri and return the directory
* @return nsiABDirectory
*/
-com.synckolab.addressbookTools.abListObject = function (card) {
+synckolab.addressbookTools.abListObject = function (card) {
// nsiABDirectory has childCards
if (!card.mailListURI) {
return card;
}
- com.synckolab.tools.logMessage("getting list from manager:" + card.mailListURI, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("getting list from manager:" + card.mailListURI, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return Components.classes["@mozilla.org/abmanager;1"].getService(Components.interfaces.nsIAbManager).getDirectory(card.mailListURI);
};
-com.synckolab.addressbookTools.card2Human = function (card) {
+synckolab.addressbookTools.card2Human = function (card) {
var msg = "";
if (this.haveCardProperty(card, "FirstName") || this.haveCardProperty(card, "LastName")) {
@@ -2366,13 +2374,13 @@ com.synckolab.addressbookTools.card2Human = function (card) {
/**
* this returns a quoted encoded vcard
*/
-com.synckolab.addressbookTools.card2Vcard = function (card, fields) {
+synckolab.addressbookTools.card2Vcard = function (card, fields) {
// save the date in microseconds
// Date: Fri, 17 Dec 2004 15:06:42 +0100
var cdate = new Date(this.getCardProperty(card, "LastModifiedDate") * 1000);
var sTime = (cdate.getHours() < 10 ? "0" : "") + cdate.getHours() + ":" + (cdate.getMinutes() < 10 ? "0" : "") + cdate.getMinutes() + ":" + (cdate.getSeconds() < 10 ? "0" : "") + cdate.getSeconds();
- var sdate = "DATE: " + com.synckolab.tools.text.getDayString(cdate.getDay()) + ", " +
- cdate.getDate() + " " + com.synckolab.tools.text.getMonthString(cdate.getMonth()) + " " +
+ var sdate = "DATE: " + synckolab.tools.text.getDayString(cdate.getDay()) + ", " +
+ cdate.getDate() + " " + synckolab.tools.text.getMonthString(cdate.getMonth()) + " " +
cdate.getFullYear() + " " +
sTime + " " + (((cdate.getTimezoneOffset() / 60) < 0) ? "-" : "+") +
(((cdate.getTimezoneOffset() / 60) < 10) ? "0" : "") + cdate.getTimezoneOffset() + "\n";
@@ -2532,34 +2540,34 @@ com.synckolab.addressbookTools.card2Vcard = function (card, fields) {
* @param card nsIAbCard - the adress book card
* @param email String - the email of the current account
* @param format String - the format to use (Xml|VCard)
- * @param fields com.synckolab.database - a hashmap holding all the extra fields not in the card structure
+ * @param fields synckolab.database - a hashmap holding all the extra fields not in the card structure
*/
-com.synckolab.addressbookTools.card2Message = function (card, email, format, fields) {
+synckolab.addressbookTools.card2Message = function (card, email, format, fields) {
// it may be we do not have a uid - skip it then
if (this.getUID(card) === null || this.getUID(card).length < 2) {
return null;
}
- com.synckolab.tools.logMessage("creating message out of card... ", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("creating message out of card... ", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// for the kolab xml format
if (format === "Xml") {
// mailing list
if (card.isMailList) {
- return com.synckolab.tools.generateMail(this.getUID(card), email, "", "application/x-vnd.kolab.contact.distlist", true, com.synckolab.tools.text.utf8.encode(this.list2Xml(card, fields)), this.list2Human(card));
+ return synckolab.tools.generateMail(this.getUID(card), email, "", "application/x-vnd.kolab.contact.distlist", true, synckolab.tools.text.utf8.encode(this.list2Xml(card, fields)), this.list2Human(card));
} else {
- return com.synckolab.tools.generateMail(this.getUID(card), email, "", "application/x-vnd.kolab.contact", true, com.synckolab.tools.text.utf8.encode(this.card2Xml(card, fields)), this.card2Human(card), this.getCardProperty(card, "PhotoName"));
+ return synckolab.tools.generateMail(this.getUID(card), email, "", "application/x-vnd.kolab.contact", true, synckolab.tools.text.utf8.encode(this.card2Xml(card, fields)), this.card2Human(card), this.getCardProperty(card, "PhotoName"));
}
}
if (card.isMailList) {
- return com.synckolab.tools.generateMail(this.getUID(card), email, "vCard", "text/x-vcard.list", false, com.synckolab.tools.text.utf8.encode(this.list2Vcard(card, fields)), null);
+ return synckolab.tools.generateMail(this.getUID(card), email, "vCard", "text/x-vcard.list", false, synckolab.tools.text.utf8.encode(this.list2Vcard(card, fields)), null);
}
- return com.synckolab.tools.generateMail(this.getUID(card), email, "vCard", "text/vcard", false, com.synckolab.tools.text.utf8.encode(this.card2Vcard(card, fields)), null);
+ return synckolab.tools.generateMail(this.getUID(card), email, "vCard", "text/vcard", false, synckolab.tools.text.utf8.encode(this.card2Vcard(card, fields)), null);
/*
- return com.synckolab.tools.generateMail(this.getUID(card), email, "vCard", "text/vcard",
+ return synckolab.tools.generateMail(this.getUID(card), email, "vCard", "text/vcard",
false, decodeURIComponent(card.translateTo("vcard")), null);
- this works kinda... some fields ar emissing and others are wrong named in order to be compatible with kolab
*/
@@ -2569,7 +2577,7 @@ com.synckolab.addressbookTools.card2Message = function (card, email, format, fie
/*
* Replaces any ; or : with their equivalent char codes since these are reserved characters in vcard spec
*/
-com.synckolab.addressbookTools.encodeCardField = function (fieldValue) {
+synckolab.addressbookTools.encodeCardField = function (fieldValue) {
var safeStr;
safeStr = fieldValue.replace(/\=/g, "=3D");
safeStr = fieldValue.replace(/:/g, "=3A");
@@ -2579,7 +2587,7 @@ com.synckolab.addressbookTools.encodeCardField = function (fieldValue) {
/*
* Decodes a string encoded by encodeCardField
*/
-com.synckolab.addressbookTools.decodeCardField = function (fieldValue) {
+synckolab.addressbookTools.decodeCardField = function (fieldValue) {
var unsafeStr;
unsafeStr = fieldValue.replace(/\=3A/g, ":");
unsafeStr = fieldValue.replace(/\=3D/g, "=");
@@ -2587,7 +2595,7 @@ com.synckolab.addressbookTools.decodeCardField = function (fieldValue) {
};
//Returns an array of fields that are in conflict
-com.synckolab.addressbookTools.contactConflictTest = function (serverCard, localCard) {
+synckolab.addressbookTools.contactConflictTest = function (serverCard, localCard) {
var conflictArray = []; //conflictArray.length
//Fields to look for
diff --git a/src/chrome/content/synckolab/calendar.js b/src/chrome/content/synckolab/calendar.js
index 6335b58..fd1b323 100644
--- a/src/chrome/content/synckolab/calendar.js
+++ b/src/chrome/content/synckolab/calendar.js
@@ -45,12 +45,10 @@
*/
"use strict";
-if (!com)
- var com = {};
-if (!com.synckolab)
- com.synckolab = {};
+if (!synckolab)
+ var synckolab = {};
-com.synckolab.Calendar = {
+synckolab.Calendar = {
gConfig : null, // remember the configuration name
gCurUID : '', // save the last checked uid - for external use
@@ -77,18 +75,18 @@ com.synckolab.Calendar = {
* @param pref a nsIPrefBranch for reading of the configuration
*/
readConfig: function(config, pref) {
- if (!com.synckolab.calendarTools.isCalendarAvailable() || !config.enabled) {
+ if (!synckolab.calendarTools.isCalendarAvailable() || !config.enabled) {
return;
}
// uid -> filename database - main functions needs to know the name
// the current sync database filen (a file with uid:size:date:localfile)
- config.dbFile = com.synckolab.tools.file.getHashDataBaseFile(config);
+ config.dbFile = synckolab.tools.file.getHashDataBaseFile(config);
// get the correct calendar instance
- var calendars = com.synckolab.calendarTools.getCalendars();
+ var calendars = synckolab.calendarTools.getCalendars();
for ( var i = 0; i < calendars.length; i++) {
- if (calendars[i].name === config.source || com.synckolab.tools.text.fixNameToMiniCharset(calendars[i].name) === com.synckolab.tools.text.fixNameToMiniCharset(config.source)) {
+ if (calendars[i].name === config.source || synckolab.tools.text.fixNameToMiniCharset(calendars[i].name) === synckolab.tools.text.fixNameToMiniCharset(config.source)) {
config.calendar = calendars[i];
break;
}
@@ -97,7 +95,7 @@ com.synckolab.Calendar = {
// check if we want to add an observer to this calendar
if(config.calendar && config.syncListener) {
//add an calIObserver http://doxygen.db48x.net/mozilla-full/html/de/d2d/interfacecalIObserver.html
- com.synckolab.calendarTools.registerListener(config.calendar, {
+ synckolab.calendarTools.registerListener(config.calendar, {
onStartBatch: function() {},
onEndBatch: function() {},
onLoad: function() {},
@@ -110,15 +108,15 @@ com.synckolab.Calendar = {
*/
getConfig: function(name, isCal) {
// search through the configs
- for(var j = 0; j < com.synckolab.main.syncConfigs.length; j++) {
- if(com.synckolab.main.syncConfigs[j] &&
- (isCal && com.synckolab.main.syncConfigs[j].type === "calendar") ||
- (!isCal && com.synckolab.main.syncConfigs[j].type === "task")) {
- var curConfig = com.synckolab.main.syncConfigs[j];
- //com.synckolab.tools.logMessage("checking " + curConfig.contact.folderMsgURI + " vs. " + folder, com.synckolab.global.LOG_DEBUG);
+ for(var j = 0; j < synckolab.main.syncConfigs.length; j++) {
+ if(synckolab.main.syncConfigs[j] &&
+ (isCal && synckolab.main.syncConfigs[j].type === "calendar") ||
+ (!isCal && synckolab.main.syncConfigs[j].type === "task")) {
+ var curConfig = synckolab.main.syncConfigs[j];
+ //synckolab.tools.logMessage("checking " + curConfig.contact.folderMsgURI + " vs. " + folder, synckolab.global.LOG_DEBUG);
if(curConfig.enabled && curConfig.syncListener) {
- if(curConfig.source === name || com.synckolab.tools.text.fixNameToMiniCharset(curConfig.source) === com.synckolab.tools.text.fixNameToMiniCharset(name))
+ if(curConfig.source === name || synckolab.tools.text.fixNameToMiniCharset(curConfig.source) === synckolab.tools.text.fixNameToMiniCharset(name))
{
return curConfig;
}
@@ -136,8 +134,8 @@ com.synckolab.Calendar = {
OnStopRunningUrl: function ( url, exitCode )
{
- com.synckolab.tools.logMessage("Finished trigger", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
- com.synckolab.global.triggerRunning = false;
+ synckolab.tools.logMessage("Finished trigger", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
+ synckolab.global.triggerRunning = false;
}
}, msgWindow);
},
@@ -146,18 +144,18 @@ com.synckolab.Calendar = {
*/
onAddItem: function(cur) {
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
- var cConfig = this.getConfig(cur.calendar.name, com.synckolab.tools.instanceOf(cur, Components.interfaces.calIEvent));
+ var cConfig = this.getConfig(cur.calendar.name, synckolab.tools.instanceOf(cur, Components.interfaces.calIEvent));
if(!cConfig) {
return;
}
- com.synckolab.tools.logMessage("Calendar listener: added " + cur.id, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_CAL);
+ synckolab.tools.logMessage("Calendar listener: added " + cur.id, synckolab.global.LOG_INFO + synckolab.global.LOG_CAL);
- var cEntry = com.synckolab.tools.file.getSyncDbFile(cConfig, cur.id);
+ var cEntry = synckolab.tools.file.getSyncDbFile(cConfig, cur.id);
// skip if we have this one already
if (cEntry.exists() && !this.forceServerCopy) {
@@ -165,19 +163,19 @@ com.synckolab.Calendar = {
}
// remember that we just worked with this one
- if(com.synckolab.config.checkIdProcessed(cConfig, cur.id)) {
- com.synckolab.tools.logMessage("skipping because recently processed", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ if(synckolab.config.checkIdProcessed(cConfig, cur.id)) {
+ synckolab.tools.logMessage("skipping because recently processed", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return;
}
- com.synckolab.tools.logMessage("nextUpdate really writes event:" + cur.id, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("nextUpdate really writes event:" + cur.id, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// and now really write the message
var msg = null;
var clonedEvent = cur;
- clonedEvent = com.synckolab.calendarTools.event2json(cur, cConfig.type === "task");
+ clonedEvent = synckolab.calendarTools.event2json(cur, cConfig.type === "task");
if (cConfig.format === "Xml") {
- msg = com.synckolab.calendarTools.event2kolabXmlMsg(clonedEvent, cConfig.email, cConfig.type === "task");
+ msg = synckolab.calendarTools.event2kolabXmlMsg(clonedEvent, cConfig.email, cConfig.type === "task");
} else {
var calComp = Components.classes["@mozilla.org/calendar/ics-service;1"].getService(Components.interfaces.calIICSService).createIcalComponent("VCALENDAR");
calComp.version = "2.0";
@@ -185,30 +183,30 @@ com.synckolab.Calendar = {
calComp.addSubcomponent(cur.icalComponent);
if (cConfig.type === "task") {
- msg = com.synckolab.tools.generateMail(cur.id, cConfig.email, "iCal", "text/todo", false, com.synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
+ msg = synckolab.tools.generateMail(cur.id, cConfig.email, "iCal", "text/todo", false, synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
} else {
- msg = com.synckolab.tools.generateMail(cur.id, cConfig.email, "iCal", "text/calendar", false, com.synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
+ msg = synckolab.tools.generateMail(cur.id, cConfig.email, "iCal", "text/calendar", false, synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
}
}
- com.synckolab.tools.logMessage("New event:\n" + msg, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("New event:\n" + msg, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// add the new event into the db
- cEntry = com.synckolab.tools.file.getSyncDbFile(cConfig, cur.id);
- com.synckolab.tools.writeSyncDBFile(cEntry, clonedEvent);
+ cEntry = synckolab.tools.file.getSyncDbFile(cConfig, cur.id);
+ synckolab.tools.writeSyncDBFile(cEntry, clonedEvent);
- com.synckolab.tools.logMessage("Writing entry to imap" , com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Writing entry to imap" , synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
- com.synckolab.global.triggerRunning = true;
+ synckolab.global.triggerRunning = true;
var listener = this;
- com.synckolab.main.writeImapMessage(msg, cConfig,
+ synckolab.main.writeImapMessage(msg, cConfig,
{
OnProgress: function (progress, progressMax) {},
OnStartCopy: function () { },
SetMessageKey: function (key) {},
OnStopCopy: function (status) {
// update folder information from imap and make sure we got everything
- com.synckolab.tools.logMessage("Finished writing contact entry to imap - compacting", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Finished writing contact entry to imap - compacting", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
listener.finishMsgfolderChange(cConfig.folder);
}
});
@@ -219,20 +217,20 @@ com.synckolab.Calendar = {
*/
onModifyItem: function(cur, aOldItem) {
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
- var cConfig = this.getConfig(cur.calendar.name, com.synckolab.tools.instanceOf(cur, Components.interfaces.calIEvent));
+ var cConfig = this.getConfig(cur.calendar.name, synckolab.tools.instanceOf(cur, Components.interfaces.calIEvent));
if(!cConfig) {
return;
}
- com.synckolab.tools.logMessage("Calendar listener: modified " + aOldItem.id + " with " + cur.id, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_CAL);
+ synckolab.tools.logMessage("Calendar listener: modified " + aOldItem.id + " with " + cur.id, synckolab.global.LOG_INFO + synckolab.global.LOG_CAL);
// remember that we just worked with this one
- if(com.synckolab.config.checkIdProcessed(cConfig, cur.id)) {
- com.synckolab.tools.logMessage("skipping because recently processed", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ if(synckolab.config.checkIdProcessed(cConfig, cur.id)) {
+ synckolab.tools.logMessage("skipping because recently processed", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return;
}
@@ -241,10 +239,10 @@ com.synckolab.Calendar = {
// and now really write the message
var msg = null;
var clonedEvent = cur;
- clonedEvent = com.synckolab.calendarTools.event2json(cur, cConfig.type === "task");
+ clonedEvent = synckolab.calendarTools.event2json(cur, cConfig.type === "task");
if (cConfig.format === "Xml") {
- msg = com.synckolab.calendarTools.event2kolabXmlMsg(clonedEvent, cConfig.email, cConfig.type === "task");
+ msg = synckolab.calendarTools.event2kolabXmlMsg(clonedEvent, cConfig.email, cConfig.type === "task");
} else {
var calComp = Components.classes["@mozilla.org/calendar/ics-service;1"].getService(Components.interfaces.calIICSService).createIcalComponent("VCALENDAR");
calComp.version = "2.0";
@@ -252,9 +250,9 @@ com.synckolab.Calendar = {
calComp.addSubcomponent(cur.icalComponent);
if (cConfig.type === "task") {
- msg = com.synckolab.tools.generateMail(cur.id, cConfig.email, "iCal", "text/todo", false, com.synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
+ msg = synckolab.tools.generateMail(cur.id, cConfig.email, "iCal", "text/todo", false, synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
} else {
- msg = com.synckolab.tools.generateMail(cur.id, cConfig.email, "iCal", "text/calendar", false, com.synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
+ msg = synckolab.tools.generateMail(cur.id, cConfig.email, "iCal", "text/calendar", false, synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
}
}
@@ -264,10 +262,10 @@ com.synckolab.Calendar = {
// finally update imap
// find the correct message to the given uid
if(cConfig.msgList.length() === 0) {
- com.synckolab.tools.fillMessageLookup(cConfig.msgList, config, com.synckolab.addressbookTools.parseMessageContent);
+ synckolab.tools.fillMessageLookup(cConfig.msgList, config, synckolab.addressbookTools.parseMessageContent);
}
- var cEntry = com.synckolab.tools.file.getSyncDbFile(cConfig, cur.id);
+ var cEntry = synckolab.tools.file.getSyncDbFile(cConfig, cur.id);
// get and delete the message
var cmsg = cConfig.msgList.get(cUID);
@@ -275,28 +273,28 @@ com.synckolab.Calendar = {
var list = null;
// use mutablearray
list = Components.classes["@mozilla.org/array;1"].createInstance(Components.interfaces.nsIMutableArray);
- com.synckolab.tools.logMessage("deleting [" + cUID + "]");
+ synckolab.tools.logMessage("deleting [" + cUID + "]");
list.appendElement(cmsg, false);
cConfig.folder.deleteMessages(list, msgWindow, true, false, null, true);
cEntry.remove(false);
}
- com.synckolab.tools.logMessage("New event:\n" + msg, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("New event:\n" + msg, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// add the new event into the db
- com.synckolab.tools.writeSyncDBFile(cEntry, clonedEvent);
+ synckolab.tools.writeSyncDBFile(cEntry, clonedEvent);
- com.synckolab.tools.logMessage("Writing entry to imap" , com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
- com.synckolab.global.triggerRunning = true;
+ synckolab.tools.logMessage("Writing entry to imap" , synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
+ synckolab.global.triggerRunning = true;
var listener = this;
- com.synckolab.main.writeImapMessage(msg, cConfig,
+ synckolab.main.writeImapMessage(msg, cConfig,
{
OnProgress: function (progress, progressMax) {},
OnStartCopy: function () { },
SetMessageKey: function (key) {},
OnStopCopy: function (status) {
// update folder information from imap and make sure we got everything
- com.synckolab.tools.logMessage("Finished writing contact entry to imap - compacting", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("Finished writing contact entry to imap - compacting", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
listener.finishMsgfolderChange(cConfig.folder);
}
});
@@ -306,30 +304,30 @@ com.synckolab.Calendar = {
*/
onDeleteItem: function(cur) {
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
- var cConfig = this.getConfig(cur.calendar.name, com.synckolab.tools.instanceOf(cur, Components.interfaces.calIEvent));
+ var cConfig = this.getConfig(cur.calendar.name, synckolab.tools.instanceOf(cur, Components.interfaces.calIEvent));
if(!cConfig) {
return;
}
var cUID = cur.id;
- com.synckolab.tools.logMessage("Calendar listener: deleted " + cur.id, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_CAL);
+ synckolab.tools.logMessage("Calendar listener: deleted " + cur.id, synckolab.global.LOG_INFO + synckolab.global.LOG_CAL);
// remember that we just worked with this one
- if(com.synckolab.config.checkIdProcessed(cConfig, cur.id)) {
- com.synckolab.tools.logMessage("skipping because recently processed", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ if(synckolab.config.checkIdProcessed(cConfig, cur.id)) {
+ synckolab.tools.logMessage("skipping because recently processed", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
return;
}
// find the correct message to the given uid
if(cConfig.msgList.length() === 0) {
- com.synckolab.tools.fillMessageLookup(cConfig.msgList, config, com.synckolab.addressbookTools.parseMessageContent);
+ synckolab.tools.fillMessageLookup(cConfig.msgList, config, synckolab.addressbookTools.parseMessageContent);
}
- com.synckolab.global.triggerRunning = true;
+ synckolab.global.triggerRunning = true;
// remember that we just added this one
cConfig.recentProcessed.push(cur.id);
@@ -340,12 +338,12 @@ com.synckolab.Calendar = {
var list = null;
// use mutablearray
list = Components.classes["@mozilla.org/array;1"].createInstance(Components.interfaces.nsIMutableArray);
- com.synckolab.tools.logMessage("deleting [" + cUID + "]");
+ synckolab.tools.logMessage("deleting [" + cUID + "]");
list.appendElement(msg, false);
cConfig.folder.deleteMessages(list, msgWindow, true, false, null, true);
// also remove sync db file
- var idxEntry = com.synckolab.tools.file.getSyncDbFile(cConfig, cUID);
+ var idxEntry = synckolab.tools.file.getSyncDbFile(cConfig, cUID);
idxEntry.remove(false);
}
@@ -363,9 +361,9 @@ com.synckolab.Calendar = {
*/
init : function (config, itemList, document) {
// package shortcuts:
- com.synckolab.global = com.synckolab.global;
- this.tools = com.synckolab.tools;
- this.calTools = com.synckolab.calendarTools;
+ synckolab.global = synckolab.global;
+ this.tools = synckolab.tools;
+ this.calTools = synckolab.calendarTools;
// ui stuff
this.itemList = itemList;
@@ -375,7 +373,7 @@ com.synckolab.Calendar = {
// clean out recently processed - we are in manual mode
this.gConfig.recentProcessed = [];
- com.synckolab.tools.logMessage("Initialising calendar config: " + this.gConfig.name, com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Initialising calendar config: " + this.gConfig.name, synckolab.global.LOG_INFO);
this.forceServerCopy = false;
this.forceLocalCopy = false;
@@ -383,7 +381,7 @@ com.synckolab.Calendar = {
this.folderMessageUids = []; // the checked uids - for better sync
// remember all the items we already worked with
- this.gCalDB = new com.synckolab.hashMap();
+ this.gCalDB = new synckolab.hashMap();
// make sure its up-to date: call refresh
this.gConfig.calendar.refresh();
@@ -391,7 +389,7 @@ com.synckolab.Calendar = {
init2 : function (nextFunc, sync) {
- com.synckolab.tools.logMessage("Init2 for " + this.gConfig.type, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Init2 for " + this.gConfig.type, synckolab.global.LOG_DEBUG);
// get ALL the items from calendar - when done call nextfunc
this.gEvents.nextFunc = nextFunc;
this.gEvents.events = [];
@@ -424,14 +422,14 @@ com.synckolab.Calendar = {
sync : '',
ready : false,
onOperationComplete : function (aCalendar, aStatus, aOperator, aId, aDetail) {
- com.synckolab.tools.logMessage("operation " + com.synckolab.Calendar.gConfig.type + ": status=" + aStatus + " Op=" + aOperator + " Detail=" + aDetail, com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_CAL);
+ synckolab.tools.logMessage("operation " + synckolab.Calendar.gConfig.type + ": status=" + aStatus + " Op=" + aOperator + " Detail=" + aDetail, synckolab.global.LOG_DEBUG + synckolab.global.LOG_CAL);
if (aStatus === 2152333316) {
- com.synckolab.tools.logMessage(com.synckolab.Calendar.gConfig.type + ": duplicate id - for additem", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_CAL);
+ synckolab.tools.logMessage(synckolab.Calendar.gConfig.type + ": duplicate id - for additem", synckolab.global.LOG_INFO + synckolab.global.LOG_CAL);
}
this.ready = true;
},
onGetResult : function (aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
- com.synckolab.tools.logMessage("got results: " + aCount + " items", com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_CAL);
+ synckolab.tools.logMessage("got results: " + aCount + " items", synckolab.global.LOG_DEBUG + synckolab.global.LOG_CAL);
for ( var i = 0; i < aCount; i++) {
this.events.push(aItems[i]);
}
@@ -443,25 +441,25 @@ com.synckolab.Calendar = {
*/
triggerParseAddMessage: function(message) {
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
// parse the content
- var newEvent = com.synckolab.calendarTools.message2json(message.fileContent, message.config.type === "task");
+ var newEvent = synckolab.calendarTools.message2json(message.fileContent, message.config.type === "task");
// get the dbfile from the local disk
var cUid = newEvent.uid;
- var cEntry = com.synckolab.tools.file.getSyncDbFile(message.config, cUid);
+ var cEntry = synckolab.tools.file.getSyncDbFile(message.config, cUid);
// write the pojo into a file for faster comparison in later sync
- com.synckolab.tools.writeSyncDBFile(cEntry, newEvent);
+ synckolab.tools.writeSyncDBFile(cEntry, newEvent);
- com.synckolab.tools.logMessage("event is new, add to calendar: " + cUid, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("event is new, add to calendar: " + cUid, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// add the new event
try {
- var tmpEventObj = com.synckolab.calendarTools.json2event(newEvent, message.config.calendar);
+ var tmpEventObj = synckolab.calendarTools.json2event(newEvent, message.config.calendar);
// update the newEvent timestamp so it wont display a window
var lastAckTime = Components.classes["@mozilla.org/calendar/datetime;1"].createInstance(Components.interfaces.calIDateTime);
lastAckTime.jsDate = new Date();
@@ -476,9 +474,9 @@ com.synckolab.Calendar = {
message.config.calendar.addItem(tmpEventObj, null);
message.config.calendar.refresh();
- com.synckolab.tools.logMessage("added locally:" + cUid, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("added locally:" + cUid, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
} catch (addEx) {
- com.synckolab.tools.logMessage("unable to add item:" + cUid + "\n" + addEx, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERR);
+ synckolab.tools.logMessage("unable to add item:" + cUid + "\n" + addEx, synckolab.global.LOG_CAL + synckolab.global.LOG_ERR);
}
},
@@ -487,20 +485,20 @@ com.synckolab.Calendar = {
*/
triggerParseDeleteMessage: function(message) {
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
- var messageFields = new com.synckolab.dataBase();
+ var messageFields = new synckolab.dataBase();
// parse the content
- var newEvent = com.synckolab.calendarTools.message2json(message.fileContent, message.config.type === "task");
+ var newEvent = synckolab.calendarTools.message2json(message.fileContent, message.config.type === "task");
// remember current uid
var cUID = newEvent.uid;
// get the dbfile from the local disk
- var cEntry = com.synckolab.tools.file.getSyncDbFile(message.config, cUID);
+ var cEntry = synckolab.tools.file.getSyncDbFile(message.config, cUID);
// this might actually be a duplicate clean - make sure no second message with that uid exists
var filter = 0;
@@ -516,13 +514,13 @@ com.synckolab.Calendar = {
eventId: cUID,
calObj: message.config.calendar,
onOperationComplete : function (aCalendar, aStatus, aOperator, aId, aDetail) {
- com.synckolab.tools.logMessage("operation " + com.synckolab.Calendar.gConfig.type + ": status=" + aStatus + " Op=" + aOperator + " Detail=" + aDetail, com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_CAL);
+ synckolab.tools.logMessage("operation " + synckolab.Calendar.gConfig.type + ": status=" + aStatus + " Op=" + aOperator + " Detail=" + aDetail, synckolab.global.LOG_DEBUG + synckolab.global.LOG_CAL);
if (aStatus === 2152333316) {
- com.synckolab.tools.logMessage(com.synckolab.Calendar.gConfig.type + ": duplicate id - for additem", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_CAL);
+ synckolab.tools.logMessage(synckolab.Calendar.gConfig.type + ": duplicate id - for additem", synckolab.global.LOG_INFO + synckolab.global.LOG_CAL);
}
},
onGetResult : function (aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
- com.synckolab.tools.logMessage("got results: " + aCount + " items - looking for "+ this.eventId, com.synckolab.global.LOG_DEBUG + com.synckolab.global.LOG_CAL);
+ synckolab.tools.logMessage("got results: " + aCount + " items - looking for "+ this.eventId, synckolab.global.LOG_DEBUG + synckolab.global.LOG_CAL);
var workItem;
for ( var i = 0; i < aCount; i++) {
if(aItems[i].id === this.eventId) {
@@ -557,9 +555,9 @@ com.synckolab.Calendar = {
for ( var i = 0; i < this.gEvents.events.length; i++) {
this.gCalDB.put(this.gEvents.events[i].id, this.gEvents.events[i]);
}
- com.synckolab.tools.logMessage("Indexed " + this.gCalDB.length() + " Entries", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Indexed " + this.gCalDB.length() + " Entries", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
- com.synckolab.tools.logMessage("Getting items for " + this.gConfig.type, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Getting items for " + this.gConfig.type, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
return true;
},
@@ -582,9 +580,9 @@ com.synckolab.Calendar = {
this.curItemInListId = this.doc.createElement("treecell");
this.curItemInListStatus = this.doc.createElement("treecell");
this.curItemInListContent = this.doc.createElement("treecell");
- this.curItemInListId.setAttribute("label", com.synckolab.global.strBundle.getString("unknown"));
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("parsing"));
- this.curItemInListContent.setAttribute("label", com.synckolab.global.strBundle.getString("unknown"));
+ this.curItemInListId.setAttribute("label", synckolab.global.strBundle.getString("unknown"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("parsing"));
+ this.curItemInListContent.setAttribute("label", synckolab.global.strBundle.getString("unknown"));
this.curItemInList.appendChild(this.curItemInListId);
this.curItemInList.appendChild(this.curItemInListStatus);
@@ -595,7 +593,7 @@ com.synckolab.Calendar = {
var curListItem = this.doc.createElement("treeitem");
curListItem.appendChild(this.curItemInList);
this.itemList.appendChild(curListItem);
- com.synckolab.tools.scrollToBottom(this.itemList);
+ synckolab.tools.scrollToBottom(this.itemList);
}
// parse the content
@@ -603,11 +601,11 @@ com.synckolab.Calendar = {
// if we didnt get a valid event (emtpy or without uid) - skip
if (newEvent === null || !newEvent.uid) {
- this.curItemInListId.setAttribute("label", com.synckolab.global.strBundle.getString("unparseable"));
+ this.curItemInListId.setAttribute("label", synckolab.global.strBundle.getString("unparseable"));
return null;
}
- com.synckolab.tools.logMessage("parsed event (message2Event) \n" + newEvent.toSource(), com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("parsed event (message2Event) \n" + newEvent.toSource(), synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
var tmpEventObj;
@@ -616,7 +614,7 @@ com.synckolab.Calendar = {
// update list item
this.curItemInListId.setAttribute("label", newEvent.uid);
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("checking"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("checking"));
var info = newEvent.title;
var i;
var msg;
@@ -631,8 +629,8 @@ com.synckolab.Calendar = {
// check for duplicate events
for (i = 0; i < this.folderMessageUids.length; i++) {
if (newEvent.uid === this.folderMessageUids[i]) {
- com.synckolab.tools.logMessage("event is is already parsed.. deleting duplicate: " + newEvent.uid, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("deleteOnServer"));
+ synckolab.tools.logMessage("event is is already parsed.. deleting duplicate: " + newEvent.uid, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("deleteOnServer"));
return "DELETEME";
}
}
@@ -641,26 +639,26 @@ com.synckolab.Calendar = {
this.folderMessageUids.push(newEvent.uid);
// get event from calendar based on the uid - and convert to json
- foundEvent = com.synckolab.calendarTools.event2json(this.calTools.findEvent(this.gCalDB, newEvent.uid), this.gConfig.type === "task");
+ foundEvent = synckolab.calendarTools.event2json(this.calTools.findEvent(this.gCalDB, newEvent.uid), this.gConfig.type === "task");
- com.synckolab.tools.logMessage("findevent returned :" + foundEvent + "(" + (foundEvent === null ? 'null' : foundEvent.uid) + ") for " + newEvent.uid + " caching " + this.gCalDB.length() + " events", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("findevent returned :" + foundEvent + "(" + (foundEvent === null ? 'null' : foundEvent.uid) + ") for " + newEvent.uid + " caching " + this.gCalDB.length() + " events", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// get the dbfile from the local disk
- var idxEntry = com.synckolab.tools.file.getSyncDbFile(this.gConfig, newEvent.uid);
+ var idxEntry = synckolab.tools.file.getSyncDbFile(this.gConfig, newEvent.uid);
- com.synckolab.tools.logMessage("idxEntry:" + idxEntry, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("idxEntry:" + idxEntry, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// always add if the forceLocalCopy flag is set (happens when you change the configuration)
if (foundEvent === null || this.forceLocalCopy) {
// a new event
- com.synckolab.tools.logMessage("a new event, locally unknown:" + newEvent.uid, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("a new event, locally unknown:" + newEvent.uid, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
if (!idxEntry.exists() || !this.calTools.allowSyncEvent(foundEvent, newEvent, this)) {
// write the pojo into a file for faster comparison in later sync
- com.synckolab.tools.writeSyncDBFile(idxEntry, newEvent);
+ synckolab.tools.writeSyncDBFile(idxEntry, newEvent);
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("localAdd"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("localAdd"));
- tmpEventObj = com.synckolab.calendarTools.json2event(newEvent, this.gConfig.calendar);
+ tmpEventObj = synckolab.calendarTools.json2event(newEvent, this.gConfig.calendar);
// update the newEvent timestamp so it wont display a window
var lastAckTime = Components.classes["@mozilla.org/calendar/datetime;1"].createInstance(Components.interfaces.calIDateTime);
@@ -676,20 +674,20 @@ com.synckolab.Calendar = {
// add the new event
try {
- com.synckolab.tools.logMessage("adding obj with startdate:" + tmpEventObj.startDate, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("adding obj with startdate:" + tmpEventObj.startDate, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
this.gConfig.calendar.addItem(tmpEventObj, this.gEvents);
// also add to the hash-database
this.gCalDB.put(newEvent.uid, newEvent);
- com.synckolab.tools.logMessage("added locally:" + newEvent.uid, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("added locally:" + newEvent.uid, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
} catch (addEx) {
- com.synckolab.tools.logMessage("unable to add item:" + newEvent.uid + "\n" + addEx, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERR);
+ synckolab.tools.logMessage("unable to add item:" + newEvent.uid + "\n" + addEx, synckolab.global.LOG_CAL + synckolab.global.LOG_ERR);
this.curItemInListStatus.setAttribute("label", "ERROR");
}
} else {
// now this should be deleted, since it was in the db already
- com.synckolab.tools.logMessage("Delete event on server and in db: " + newEvent.uid, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("deleteOnServer"));
+ synckolab.tools.logMessage("Delete event on server and in db: " + newEvent.uid, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("deleteOnServer"));
// also remove the local db file since we deleted the contact
if (idxEntry.exists()) {
@@ -700,50 +698,50 @@ com.synckolab.Calendar = {
}
} else {
// event exists in local calendar
- com.synckolab.tools.logMessage("Event exists local: " + newEvent.uid, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Event exists local: " + newEvent.uid, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
- var cEvent = com.synckolab.tools.readSyncDBFile(idxEntry);
+ var cEvent = synckolab.tools.readSyncDBFile(idxEntry);
var cEvent_equals_foundEvent, cEvent_equals_newEvent, foundEvent_equals_newEvent;
if(cEvent === null) {
- com.synckolab.tools.logMessage("cEvent is null!", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("cEvent is null!", synckolab.global.LOG_DEBUG);
}
if(foundEvent === null) {
- com.synckolab.tools.logMessage("foundEvent is null!", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("foundEvent is null!", synckolab.global.LOG_DEBUG);
}
if(newEvent === null) {
- com.synckolab.tools.logMessage("newEvent is null!", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("newEvent is null!", synckolab.global.LOG_DEBUG);
}
// Streamline card comparisons
- if (com.synckolab.calendarTools.equalsEvent(cEvent, foundEvent)) {
+ if (synckolab.calendarTools.equalsEvent(cEvent, foundEvent)) {
cEvent_equals_foundEvent = true;
- com.synckolab.tools.logMessage("In parse Message cEvent equals foundEvent", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message cEvent equals foundEvent", synckolab.global.LOG_DEBUG);
} else {
cEvent_equals_foundEvent = false;
- com.synckolab.tools.logMessage("In parse Message cEvent DOES NOT EQUALS foundEvent\n ", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message cEvent DOES NOT EQUALS foundEvent\n ", synckolab.global.LOG_DEBUG);
}
- if (com.synckolab.calendarTools.equalsEvent(cEvent, newEvent)) {
+ if (synckolab.calendarTools.equalsEvent(cEvent, newEvent)) {
cEvent_equals_newEvent = true;
- com.synckolab.tools.logMessage("In parse Message cEvent equals newEvent", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message cEvent equals newEvent", synckolab.global.LOG_DEBUG);
} else {
cEvent_equals_newEvent = false;
- com.synckolab.tools.logMessage("In parse Message cEvent DOES NOT equal newEvent", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message cEvent DOES NOT equal newEvent", synckolab.global.LOG_DEBUG);
}
- if (com.synckolab.calendarTools.equalsEvent(foundEvent, newEvent)) {
+ if (synckolab.calendarTools.equalsEvent(foundEvent, newEvent)) {
foundEvent_equals_newEvent = true;
- com.synckolab.tools.logMessage("In parse Message foundEvent equals newEvent", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message foundEvent equals newEvent", synckolab.global.LOG_DEBUG);
} else {
foundEvent_equals_newEvent = false;
- com.synckolab.tools.logMessage("In parse Message foundEvent DOES NOT equal newEvent", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message foundEvent DOES NOT equal newEvent", synckolab.global.LOG_DEBUG);
}
// change for conflict
if ((idxEntry.exists() && !cEvent_equals_foundEvent && !cEvent_equals_newEvent) || (!idxEntry.exists() && !foundEvent_equals_newEvent))
{
// changed locally and on server side
- com.synckolab.tools.logMessage("Changed on server and local: " + newEvent.uid, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Changed on server and local: " + newEvent.uid, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
//Holds the users response, must be an object so that we can pass by reference
var conflictResolution = {};
@@ -756,7 +754,7 @@ com.synckolab.Calendar = {
conflictResolution.result = 2;
} else
// display a dialog asking for whats going on
- if (window.confirm(com.synckolab.global.strBundle.getFormattedString("calConflictUseServer", [ foundEvent.title, foundEvent.uid, newEvent.title, newEvent.uid ]))) {
+ if (window.confirm(synckolab.global.strBundle.getFormattedString("calConflictUseServer", [ foundEvent.title, foundEvent.uid, newEvent.title, newEvent.uid ]))) {
conflictResolution.result = 1;
} else {
conflictResolution.result = 2;
@@ -764,13 +762,13 @@ com.synckolab.Calendar = {
if (conflictResolution.result === 1) {
// take event from server
- com.synckolab.tools.logMessage("Take event from server: " + newEvent.uid, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Take event from server: " + newEvent.uid, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
- com.synckolab.tools.writeSyncDBFile(idxEntry, newEvent);
+ synckolab.tools.writeSyncDBFile(idxEntry, newEvent);
for (i = 0; i < this.gEvents.events.length; i++) {
if (this.gEvents.events[i].id === newEvent.uid) {
- tmpEventObj = com.synckolab.calendarTools.json2event(newEvent, this.gConfig.calendar);
+ tmpEventObj = synckolab.calendarTools.json2event(newEvent, this.gConfig.calendar);
// set the calendar
tmpEventObj.calendar = this.gConfig.calendar;
@@ -784,17 +782,17 @@ com.synckolab.Calendar = {
// because they will break the sync process
this.gConfig.calendar.modifyItem(tmpEventObj, this.gEvents.events[i], this.gEvents);
} catch (e) {
- com.synckolab.tools.logMessage("gCalendar.modifyItem() failed: " + e, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_WARNING);
+ synckolab.tools.logMessage("gCalendar.modifyItem() failed: " + e, synckolab.global.LOG_CAL + synckolab.global.LOG_WARNING);
}
//update list item
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("localUpdate"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("localUpdate"));
return null;
}
}
} else {
// local change to server
- com.synckolab.tools.logMessage("put event on server: " + newEvent.uid, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("put event on server: " + newEvent.uid, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
// first check privacy info
//foundEvent = this.calTools.checkEventOnDeletion(foundEvent, newEvent, this);
@@ -807,7 +805,7 @@ com.synckolab.Calendar = {
if (this.gConfig.format === "Xml") {
msg = this.calTools.event2kolabXmlMsg(foundEvent, this.gConfig.email, this.gConfig.type === "task");
} else {
- tmpEventObj = com.synckolab.calendarTools.json2event(newEvent);
+ tmpEventObj = synckolab.calendarTools.json2event(newEvent);
calComp = Components.classes["@mozilla.org/calendar/ics-service;1"].getService(Components.interfaces.calIICSService).createIcalComponent("VCALENDAR");
calComp.version = "2.0";
@@ -815,16 +813,16 @@ com.synckolab.Calendar = {
calComp.addSubcomponent(tmpEventObj.icalComponent);
if (this.gConfig.type === "task") {
- msg = com.synckolab.tools.generateMail(newEvent.uid, this.gConfig.email, "iCal", "text/todo", false, com.synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
+ msg = synckolab.tools.generateMail(newEvent.uid, this.gConfig.email, "iCal", "text/todo", false, synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
} else {
- msg = com.synckolab.tools.generateMail(newEvent.uid, this.gConfig.email, "iCal", "text/calendar", false, com.synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
+ msg = synckolab.tools.generateMail(newEvent.uid, this.gConfig.email, "iCal", "text/calendar", false, synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
}
}
- com.synckolab.tools.writeSyncDBFile(idxEntry, foundEvent);
+ synckolab.tools.writeSyncDBFile(idxEntry, foundEvent);
// update list item
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("updateOnServer"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("updateOnServer"));
// remember this message for update
return msg;
@@ -834,69 +832,69 @@ com.synckolab.Calendar = {
if (!idxEntry.exists() || (cEvent_equals_foundEvent && !cEvent_equals_newEvent))
{
if (!idxEntry.exists()) {
- com.synckolab.tools.logMessage("In parse Message idxEntry does not exist", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In parse Message idxEntry does not exist", synckolab.global.LOG_DEBUG);
}
if(foundEvent_equals_newEvent){
- com.synckolab.tools.logMessage("no change, but sync file missing: " + foundEvent.uid, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("no change, but sync file missing: " + foundEvent.uid, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
} else {
- com.synckolab.tools.logMessage("server changed: " + foundEvent.uid, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("server changed: " + foundEvent.uid, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
}
// server changed - update local
for (i = 0; i < this.gEvents.events.length; i++) {
if (this.gEvents.events[i].id === newEvent.uid) {
- tmpEventObj = com.synckolab.calendarTools.json2event(newEvent, this.gConfig.calendar);
+ tmpEventObj = synckolab.calendarTools.json2event(newEvent, this.gConfig.calendar);
// if we change a local event make sure to set alarmLastAck
if (this.gEvents.events[i].alarmLastAck) {
tmpEventObj.alarmLastAck = this.gEvents.events[i].alarmLastAck.clone();
}
- com.synckolab.tools.logMessage("start modify item", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("start modify item", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
try {
// modify the item - catch exceptions due to triggered alarms
// because they will break the sync process
this.gConfig.calendar.modifyItem(tmpEventObj, this.gEvents.events[i], this.gEvents);
} catch (e1) {
- com.synckolab.tools.logMessage("gCalendar.modifyItem() failed: " + e1, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_WARNING);
+ synckolab.tools.logMessage("gCalendar.modifyItem() failed: " + e1, synckolab.global.LOG_CAL + synckolab.global.LOG_WARNING);
}
- com.synckolab.tools.logMessage("event modified", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("event modified", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
break;
}
}
- com.synckolab.tools.logMessage("write sync db " + foundEvent.uid, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("write sync db " + foundEvent.uid, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// write the current content in the sync-db file
- com.synckolab.tools.writeSyncDBFile(idxEntry, newEvent);
+ synckolab.tools.writeSyncDBFile(idxEntry, newEvent);
// update list item
if(foundEvent_equals_newEvent){
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("noChange"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("noChange"));
}
else {
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("localUpdate"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("localUpdate"));
}
return null;
}
// is the db file equals server, but not local.. we got a local change
else if (idxEntry.exists() && !cEvent_equals_foundEvent && cEvent_equals_newEvent)
{
- com.synckolab.tools.logMessage("client changed " + foundEvent.uid + " - " + cEvent.primaryEmail, com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("client changed " + foundEvent.uid + " - " + cEvent.primaryEmail, synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
// update list item
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("updateOnServer"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("updateOnServer"));
// remember this message for update - generate mail message (incl. extra fields)
msg = null;
if (this.gConfig.format === "Xml") {
msg = this.calTools.event2kolabXmlMsg(foundEvent, this.gConfig.email, this.gConfig.type === "task");
} else {
- tmpEventObj = com.synckolab.calendarTools.json2event(foundEvent);
+ tmpEventObj = synckolab.calendarTools.json2event(foundEvent);
calComp = Components.classes["@mozilla.org/calendar/ics-service;1"].getService(Components.interfaces.calIICSService).createIcalComponent("VCALENDAR");
calComp.version = "2.0";
@@ -904,19 +902,19 @@ com.synckolab.Calendar = {
calComp.addSubcomponent(tmpEventObj.icalComponent);
if (this.gConfig.type === "task") {
- msg = com.synckolab.tools.generateMail(newEvent.uid, this.gConfig.email, "iCal", "text/todo", false, com.synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
+ msg = synckolab.tools.generateMail(newEvent.uid, this.gConfig.email, "iCal", "text/todo", false, synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
} else {
- msg = com.synckolab.tools.generateMail(newEvent.uid, this.gConfig.email, "iCal", "text/calendar", false, com.synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
+ msg = synckolab.tools.generateMail(newEvent.uid, this.gConfig.email, "iCal", "text/calendar", false, synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
}
}
// write the current content in the sync-db file
- com.synckolab.tools.writeSyncDBFile(idxEntry, foundEvent);
+ synckolab.tools.writeSyncDBFile(idxEntry, foundEvent);
return msg;
}
else {
- com.synckolab.tools.logMessage("events are equals", com.synckolab.global.LOG_INFO + com.synckolab.global.LOG_AB);
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("noChange"));
+ synckolab.tools.logMessage("events are equals", synckolab.global.LOG_INFO + synckolab.global.LOG_AB);
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("noChange"));
}
}
@@ -934,14 +932,14 @@ com.synckolab.Calendar = {
* @return "done" to specify that the sync is finished
*/
nextUpdate : function () {
- com.synckolab.tools.logMessage("next update...", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("next update...", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// if there happens an exception, we are done
if ((this.gEvents === null || this.gCurEvent >= this.gEvents.events.length)) {
- com.synckolab.tools.logMessage("done update...", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("done update...", synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
// we are done
return "done";
}
- com.synckolab.tools.logMessage("get event ( " + this.gCurEvent + " of " + this.gEvents.events.length + ")", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("get event ( " + this.gCurEvent + " of " + this.gEvents.events.length + ")", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
var msg = null;
var cEntry;
@@ -950,10 +948,10 @@ com.synckolab.Calendar = {
var writeCur = true;
msg = null;
- com.synckolab.tools.logMessage("nextUpdate for " + (this.gConfig.type === "task" ? "task" : "event") + ":" + cur.id, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("nextUpdate for " + (this.gConfig.type === "task" ? "task" : "event") + ":" + cur.id, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
if (cur.id === null) {
- com.synckolab.tools.logMessage("no id found for this element! skipping.", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_WARNING);
+ synckolab.tools.logMessage("no id found for this element! skipping.", synckolab.global.LOG_CAL + synckolab.global.LOG_WARNING);
return null;
}
@@ -961,23 +959,23 @@ com.synckolab.Calendar = {
var endDate = this.calTools.getEndDate(cur, this.gConfig.type === "task");
if (endDate && this.gConfig.timeFrame > 0 && (endDate.getTime() + (this.gConfig.timeFrame * 86400000) < (new Date()).getTime())) {
- com.synckolab.tools.logMessage("skipping event because its too old: " + cur.id, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("skipping event because its too old: " + cur.id, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
return null;
}
/* skip if event is PRIVATE */
if (this.calTools.isPrivateEvent(cur)) {
- com.synckolab.tools.logMessage("skipping event because it is marked as PRIVATE: " + cur.id, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("skipping event because it is marked as PRIVATE: " + cur.id, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
return null;
}
- com.synckolab.tools.logMessage("processing event", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("processing event", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// check if we have this uid in the messages, skip it if it
// has been processed already when reading the IMAP msgs
for ( var i = 0; i < this.folderMessageUids.length; i++) {
if (cur.id === this.folderMessageUids[i]) {
- com.synckolab.tools.logMessage("event is known from IMAP lookup: " + cur.id, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("event is known from IMAP lookup: " + cur.id, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
writeCur = false;
break;
}
@@ -989,13 +987,13 @@ com.synckolab.Calendar = {
if (writeCur) {
var curListItem;
- com.synckolab.tools.logMessage("nextUpdate decided to write event:" + cur.id, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("nextUpdate decided to write event:" + cur.id, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
- cEntry = com.synckolab.tools.file.getSyncDbFile(this.gConfig, cur.id);
+ cEntry = synckolab.tools.file.getSyncDbFile(this.gConfig, cur.id);
if (cEntry.exists() && !this.forceServerCopy) {
// we have it in our database - don't write back to server but delete locally
- com.synckolab.tools.logMessage("nextUpdate assumes 'delete on server', better don't write event:" + cur.id, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("nextUpdate assumes 'delete on server', better don't write event:" + cur.id, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
writeCur = false;
this.gConfig.calendar.deleteItem(cur, this.gEvents);
@@ -1011,7 +1009,7 @@ com.synckolab.Calendar = {
this.curItemInListStatus = this.doc.createElement("treecell");
this.curItemInListContent = this.doc.createElement("treecell");
this.curItemInListId.setAttribute("label", cur.id);
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("localDelete"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("localDelete"));
this.curItemInListContent.setAttribute("label", cur.title);
this.curItemInList.appendChild(this.curItemInListId);
@@ -1023,7 +1021,7 @@ com.synckolab.Calendar = {
curListItem = this.doc.createElement("treeitem");
curListItem.appendChild(this.curItemInList);
this.itemList.appendChild(curListItem);
- com.synckolab.tools.scrollToBottom(this.itemList);
+ synckolab.tools.scrollToBottom(this.itemList);
}
} else {
@@ -1033,7 +1031,7 @@ com.synckolab.Calendar = {
this.curItemInListStatus = this.doc.createElement("treecell");
this.curItemInListContent = this.doc.createElement("treecell");
this.curItemInListId.setAttribute("label", cur.id);
- this.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("addToServer"));
+ this.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("addToServer"));
this.curItemInListContent.setAttribute("label", cur.title);
this.curItemInList.appendChild(this.curItemInListId);
@@ -1045,13 +1043,13 @@ com.synckolab.Calendar = {
curListItem = this.doc.createElement("treeitem");
curListItem.appendChild(this.curItemInList);
this.itemList.appendChild(curListItem);
- com.synckolab.tools.scrollToBottom(this.itemList);
+ synckolab.tools.scrollToBottom(this.itemList);
}
}
}
if (writeCur) {
- com.synckolab.tools.logMessage("nextUpdate really writes event:" + cur.id, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("nextUpdate really writes event:" + cur.id, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// and now really write the message
msg = null;
var clonedEvent = cur;
@@ -1066,17 +1064,17 @@ com.synckolab.Calendar = {
calComp.addSubcomponent(cur.icalComponent);
if (this.gConfig.type === "task") {
- msg = com.synckolab.tools.generateMail(cur.id, this.gConfig.email, "iCal", "text/todo", false, com.synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
+ msg = synckolab.tools.generateMail(cur.id, this.gConfig.email, "iCal", "text/todo", false, synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
} else {
- msg = com.synckolab.tools.generateMail(cur.id, this.gConfig.email, "iCal", "text/calendar", false, com.synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
+ msg = synckolab.tools.generateMail(cur.id, this.gConfig.email, "iCal", "text/calendar", false, synckolab.tools.text.quoted.encode(calComp.serializeToICS()), null);
}
}
- com.synckolab.tools.logMessage("New event:\n" + msg, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("New event:\n" + msg, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// add the new event into the db
- cEntry = com.synckolab.tools.file.getSyncDbFile(this.gConfig, cur.id);
- com.synckolab.tools.writeSyncDBFile(cEntry, clonedEvent);
+ cEntry = synckolab.tools.file.getSyncDbFile(this.gConfig, cur.id);
+ synckolab.tools.writeSyncDBFile(cEntry, clonedEvent);
}
}
diff --git a/src/chrome/content/synckolab/calendarTools.js b/src/chrome/content/synckolab/calendarTools.js
index 2162c1a..ba660da 100644
--- a/src/chrome/content/synckolab/calendarTools.js
+++ b/src/chrome/content/synckolab/calendarTools.js
@@ -38,12 +38,11 @@ try {
// ignore exception if lightning is not installed
}
-if(!com) var com={};
-if(!com.synckolab) com.synckolab={};
+if(!synckolab) var synckolab={};
/* ----- general functions to access calendar and events ----- */
-com.synckolab.calendarTools = {
+synckolab.calendarTools = {
activeCalendarManager: null,
// make sure the listener is only registered ONCE
@@ -88,7 +87,7 @@ com.synckolab.calendarTools = {
return syncCalManager.getCalendars({});
}
catch (e) {
- com.synckolab.tools.logMessage("Error getting calendars: " + e, com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("Error getting calendars: " + e, synckolab.global.LOG_ERROR);
return null;
}
},
@@ -97,9 +96,9 @@ com.synckolab.calendarTools = {
* add a listener to a calendar. This makes sure a listener is not double-added.
*/
registerListener: function(calendar, listener) {
- if(listener && !com.synckolab.calendarTools.listenerRegistered[calendar.id]) {
+ if(listener && !synckolab.calendarTools.listenerRegistered[calendar.id]) {
calendar.addObserver(listener);
- com.synckolab.calendarTools.listenerRegistered[calendar.id] = true;
+ synckolab.calendarTools.listenerRegistered[calendar.id] = true;
}
},
@@ -146,7 +145,7 @@ com.synckolab.calendarTools = {
* This is taken from the lightning extension (calendar-event-dialog.js#938ff setItemProperty)
*/
setKolabItemProperty: function (item, propertyName, value) {
- //com.synckolab.tools.logMessage("setting property: " + propertyName + " with value " + value, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ //synckolab.tools.logMessage("setting property: " + propertyName + " with value " + value, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
try
{
switch(propertyName) {
@@ -172,7 +171,7 @@ com.synckolab.calendarTools = {
item.isCompleted = value;
break;
case "status":
- item.status = com.synckolab.calendarTools.getTaskStatus(value,false);
+ item.status = synckolab.calendarTools.getTaskStatus(value,false);
break;
case "title":
item.title = value;
@@ -203,7 +202,7 @@ com.synckolab.calendarTools = {
}
}
catch (ex){
- com.synckolab.tools.logMessage("unable to set property: " + propertyName + " with value " + value, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("unable to set property: " + propertyName + " with value " + value, synckolab.global.LOG_CAL + synckolab.global.LOG_ERROR);
}
},
@@ -266,7 +265,7 @@ com.synckolab.calendarTools = {
rorgmail = revent.organizer.mail;
}
var org2mail = (config.email === rorgmail);
- com.synckolab.tools.logMessage("allowSyncEvent: " + org2mail + ":" + lpublic + ":" + rpublic, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG );
+ synckolab.tools.logMessage("allowSyncEvent: " + org2mail + ":" + lpublic + ":" + rpublic, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG );
return org2mail;
},
@@ -276,8 +275,8 @@ com.synckolab.calendarTools = {
checkEventBeforeSync: function (fevent, revent, lsyncCalendar) {
var rc = this.allowSyncEvent(fevent, revent, lsyncCalendar);
if (!rc) {
- com.synckolab.tools.logMessage("Update local event with server one : " + revent.id, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG );
- lsyncCalendar.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("localUpdate"));
+ synckolab.tools.logMessage("Update local event with server one : " + revent.id, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG );
+ lsyncCalendar.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("localUpdate"));
lsyncCalendar.gConfig.calendar.modifyItem(revent, fevent, lsyncCalendar.gEvents);
}
return rc;
@@ -299,11 +298,11 @@ com.synckolab.calendarTools = {
if (!this.checkEventServerDeletion(fevent, pevent, lsyncCalendar)) {
return false;
}
- var eventry = com.synckolab.tools.file.getSyncDbFile(lsyncCalendar.gConfig, fevent.id);
+ var eventry = synckolab.tools.file.getSyncDbFile(lsyncCalendar.gConfig, fevent.id);
if (eventry.exists()) {
eventry.remove(false);
}
- lsyncCalendar.curItemInListStatus.setAttribute("label", com.synckolab.global.strBundle.getString("deleteOnServer"));
+ lsyncCalendar.curItemInListStatus.setAttribute("label", synckolab.global.strBundle.getString("deleteOnServer"));
return true;
},
@@ -351,8 +350,8 @@ com.synckolab.calendarTools = {
/**
* This functions checks if two event json objects are equals
*/
-com.synckolab.calendarTools.equalsEvent = function (a, b) {
- return com.synckolab.tools.equalsObject(a, b);
+synckolab.calendarTools.equalsEvent = function (a, b) {
+ return synckolab.tools.equalsObject(a, b);
};
/**
@@ -361,7 +360,7 @@ com.synckolab.calendarTools.equalsEvent = function (a, b) {
* @param syncTasks true if we sync tasks
* @returns a parsed json object
*/
-com.synckolab.calendarTools.message2json = function (fileContent, syncTasks) {
+synckolab.calendarTools.message2json = function (fileContent, syncTasks) {
if (fileContent === null) {
return null;
}
@@ -373,7 +372,7 @@ com.synckolab.calendarTools.message2json = function (fileContent, syncTasks) {
// fileContent should be a string - with indexOf
if(!fileContent.indexOf) {
- com.synckolab.tools.logMessage("Unknown fileContent: " + fileContent.toSource(), com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_WARNING);
+ synckolab.tools.logMessage("Unknown fileContent: " + fileContent.toSource(), synckolab.global.LOG_CAL + synckolab.global.LOG_WARNING);
return null;
}
@@ -385,7 +384,7 @@ com.synckolab.calendarTools.message2json = function (fileContent, syncTasks) {
// for ical - use the way through the lightning decoder to json
var parsedEvent = null;
if(fileContent.indexOf("=3D") !== -1) {
- fileContent = com.synckolab.tools.text.quoted.decode(fileContent);
+ fileContent = synckolab.tools.text.quoted.decode(fileContent);
}
// sepcial fix for Europe bug
if (fileContent.indexOf("TZIDID=rope")) {
@@ -399,15 +398,15 @@ com.synckolab.calendarTools.message2json = function (fileContent, syncTasks) {
}
// check type
- if (syncTasks === true && com.synckolab.tools.instanceOf(parsedEvent, Components.interfaces.calIEvent))
+ if (syncTasks === true && synckolab.tools.instanceOf(parsedEvent, Components.interfaces.calIEvent))
{
- com.synckolab.tools.logMessage("There is an event in the task folder! skipping.", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_WARNING);
+ synckolab.tools.logMessage("There is an event in the task folder! skipping.", synckolab.global.LOG_CAL + synckolab.global.LOG_WARNING);
return null;
}
- if (syncTasks === false && !com.synckolab.tools.instanceOf(parsedEvent, Components.interfaces.calIEvent))
+ if (syncTasks === false && !synckolab.tools.instanceOf(parsedEvent, Components.interfaces.calIEvent))
{
- com.synckolab.tools.logMessage("There is a task in the calendar folder! skipping.", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_WARNING);
+ synckolab.tools.logMessage("There is a task in the calendar folder! skipping.", synckolab.global.LOG_CAL + synckolab.global.LOG_WARNING);
return null;
}
@@ -420,14 +419,14 @@ com.synckolab.calendarTools.message2json = function (fileContent, syncTasks) {
* @param syncTasks true if this is a task
* @return a json object
*/
-com.synckolab.calendarTools.event2json = function (event, syncTasks) {
- com.synckolab.tools.logMessage("Event To JSON", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+synckolab.calendarTools.event2json = function (event, syncTasks) {
+ synckolab.tools.logMessage("Event To JSON", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// no event given
if(!event) {
return null;
}
var jobj = {
- synckolab : com.synckolab.config.version, // synckolab version
+ synckolab : synckolab.config.version, // synckolab version
type : "calendar"
};
@@ -439,7 +438,7 @@ com.synckolab.calendarTools.event2json = function (event, syncTasks) {
// - yearly recurrence
var isAllDay = syncTasks?false:(event.startDate?event.startDate.isDate:false);
- var endDate = com.synckolab.calendarTools.getEndDate(event, syncTasks);
+ var endDate = synckolab.calendarTools.getEndDate(event, syncTasks);
var i, minutes;
var dayindex, daynumber;
@@ -466,12 +465,12 @@ com.synckolab.calendarTools.event2json = function (event, syncTasks) {
if (syncTasks === true)
{
if(event.entryDate) {
- jobj.startDate = com.synckolab.tools.text.calDateTime2String(event.entryDate, isAllDay);
+ jobj.startDate = synckolab.tools.text.calDateTime2String(event.entryDate, isAllDay);
}
if(endDate) {
- jobj.endDate = com.synckolab.tools.text.calDateTime2String(endDate, isAllDay);
+ jobj.endDate = synckolab.tools.text.calDateTime2String(endDate, isAllDay);
}
- // jobj.completedDate = com.synckolab.tools.text.calDateTime2String(completedDate, true);
+ // jobj.completedDate = synckolab.tools.text.calDateTime2String(completedDate, true);
if(event.priority && event.priority !== null && event.priority !== "") {
jobj.priority = event.priority;
}
@@ -482,20 +481,20 @@ com.synckolab.calendarTools.event2json = function (event, syncTasks) {
jobj.status = "completed";
}
else {
- jobj.status = com.synckolab.calendarTools.getTaskStatus(event.status, true);
+ jobj.status = synckolab.calendarTools.getTaskStatus(event.status, true);
jobj.completed = event.percentComplete;
}
} else {
- jobj.startDate = com.synckolab.tools.text.calDateTime2String(event.startDate, isAllDay);
- jobj.endDate = com.synckolab.tools.text.calDateTime2String(endDate, isAllDay);
+ jobj.startDate = synckolab.tools.text.calDateTime2String(event.startDate, isAllDay);
+ jobj.endDate = synckolab.tools.text.calDateTime2String(endDate, isAllDay);
}
jobj.uid = event.id;
jobj.title = event.title;
jobj.body = event.getProperty("DESCRIPTION");
jobj.sensitivity = event.getProperty("CLASS")?event.getProperty("CLASS").toLowerCase():"public";
- // xml += " <creation-date>" + com.synckolab.tools.text.calDateTime2String(event.getProperty("CREATED"), false) + "</creation-date>\n";
- // xml += " <last-modification-date>" + com.synckolab.tools.text.calDateTime2String(event.getProperty("LAST-MODIFIED"), false) + "</last-modification-date>\n";
+ // xml += " <creation-date>" + synckolab.tools.text.calDateTime2String(event.getProperty("CREATED"), false) + "</creation-date>\n";
+ // xml += " <last-modification-date>" + synckolab.tools.text.calDateTime2String(event.getProperty("LAST-MODIFIED"), false) + "</last-modification-date>\n";
if (event.getProperty("LOCATION")) {
jobj.location = event.getProperty("LOCATION");
@@ -533,7 +532,7 @@ com.synckolab.calendarTools.event2json = function (event, syncTasks) {
calarms.push(tmpobj);
// TODO lightning has some other attributes which we should take care of
- com.synckolab.tools.copyFields(alarm, tmpobj, ["description", "summary", "action"], true);
+ synckolab.tools.copyFields(alarm, tmpobj, ["description", "summary", "action"], true);
}
// only create if there are alarms
@@ -601,7 +600,7 @@ com.synckolab.calendarTools.event2json = function (event, syncTasks) {
if (curDay && curDay.length > 0 ) {
// multiple recurrence possible
for(var recweekdays = 0; recweekdays < curDay.length; recweekdays ++) {
- jobj.recurrence.days.push(com.synckolab.tools.kolab.getXmlDayName(curDay[recweekdays]));
+ jobj.recurrence.days.push(synckolab.tools.kolab.getXmlDayName(curDay[recweekdays]));
}
}
break;
@@ -624,7 +623,7 @@ com.synckolab.calendarTools.event2json = function (event, syncTasks) {
dayindex = days[0] % 8;
daynumber = (days[0] - dayindex) / 8;
jobj.recurrence.daynumber = daynumber;
- jobj.recurrence.weekday = com.synckolab.tools.kolab.getXmlDayName(dayindex);
+ jobj.recurrence.weekday = synckolab.tools.kolab.getXmlDayName(dayindex);
}
}
break;
@@ -674,7 +673,7 @@ com.synckolab.calendarTools.event2json = function (event, syncTasks) {
}
if (endDate) {
- jobj.recurrence.untilDate = com.synckolab.tools.text.date2String(endDate.jsDate);
+ jobj.recurrence.untilDate = synckolab.tools.text.date2String(endDate.jsDate);
}
}
@@ -685,7 +684,7 @@ com.synckolab.calendarTools.event2json = function (event, syncTasks) {
{
var item = items[i];
if (item.isNegative) {
- jobj.recurrence.exclusion.push(com.synckolab.tools.text.calDateTime2String(item.date, true));
+ jobj.recurrence.exclusion.push(synckolab.tools.text.calDateTime2String(item.date, true));
}
}
}
@@ -764,17 +763,17 @@ com.synckolab.calendarTools.event2json = function (event, syncTasks) {
* @param json the json object to read
* @param calendar an optional calendar to set
*/
-com.synckolab.calendarTools.json2event = function (jobj, calendar) {
+synckolab.calendarTools.json2event = function (jobj, calendar) {
var syncTasks = (jobj.type === "task");
var event;
if (syncTasks === true)
{
- com.synckolab.tools.logMessage("creating task/todo.", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("creating task/todo.", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
event = Components.classes["@mozilla.org/calendar/todo;1"].createInstance(Components.interfaces.calITodo);
}
else {
- com.synckolab.tools.logMessage("creating event.", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("creating event.", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
event = Components.classes["@mozilla.org/calendar/event;1"].createInstance(Components.interfaces.calIEvent);
}
// set the correct calendar
@@ -790,19 +789,19 @@ com.synckolab.calendarTools.json2event = function (jobj, calendar) {
if(jobj.startDate) {
if (jobj.startDate.indexOf(":") === -1) {
// entry date and start date can be handled the same way
- com.synckolab.tools.logMessage("setting all day: " + (syncTasks?"entryDate":"startDate"), com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
- this.setKolabItemProperty(event, syncTasks?"entryDate":"startDate", com.synckolab.tools.text.string2CalDate(jobj.startDate));
+ synckolab.tools.logMessage("setting all day: " + (syncTasks?"entryDate":"startDate"), synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
+ this.setKolabItemProperty(event, syncTasks?"entryDate":"startDate", synckolab.tools.text.string2CalDate(jobj.startDate));
} else {
// entry date and start date can be handled the same way
- com.synckolab.tools.logMessage("setting: " + (syncTasks?"entryDate":"startDate"), com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
- this.setKolabItemProperty(event, syncTasks?"entryDate":"startDate", com.synckolab.tools.text.string2CalDateTime(jobj.startDate, true));
+ synckolab.tools.logMessage("setting: " + (syncTasks?"entryDate":"startDate"), synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
+ this.setKolabItemProperty(event, syncTasks?"entryDate":"startDate", synckolab.tools.text.string2CalDateTime(jobj.startDate, true));
}
}
// full day
if(jobj.endDate) {
if (jobj.endDate.indexOf(":") === -1) {
- cDate = com.synckolab.tools.text.string2CalDate(jobj.endDate);
+ cDate = synckolab.tools.text.string2CalDate(jobj.endDate);
// Kolab uses for 1-day-event:
// startdate = day_x, enddate = day_x
// Sunbird uses for 1-day-event:
@@ -815,18 +814,18 @@ com.synckolab.calendarTools.json2event = function (jobj, calendar) {
this.setKolabItemProperty(event, syncTasks?"dueDate":"endDate", cDate);
} else {
// due date and end date can be handled the same way
- this.setKolabItemProperty(event, syncTasks?"dueDate":"endDate", com.synckolab.tools.text.string2CalDateTime(jobj.endDate, true));
+ this.setKolabItemProperty(event, syncTasks?"dueDate":"endDate", synckolab.tools.text.string2CalDateTime(jobj.endDate, true));
}
}
// 2005-03-30T15:28:52Z
if(jobj.creationDate) {
- this.setKolabItemProperty(event, "CREATED", com.synckolab.tools.text.string2CalDateTime(jobj.creationDate, true));
+ this.setKolabItemProperty(event, "CREATED", synckolab.tools.text.string2CalDateTime(jobj.creationDate, true));
}
// 2005-03-30T15:28:52Z
if(jobj.lastModified) {
- this.setKolabItemProperty(event, "LAST-MODIFIED", com.synckolab.tools.text.string2CalDateTime(jobj.lastModified, true));
+ this.setKolabItemProperty(event, "LAST-MODIFIED", synckolab.tools.text.string2CalDateTime(jobj.lastModified, true));
}
// special fields for tasks
@@ -864,15 +863,15 @@ com.synckolab.calendarTools.json2event = function (jobj, calendar) {
var alarm = Components.classes["@mozilla.org/calendar/alarm;1"].createInstance(Components.interfaces.calIAlarm);
alarm.related = 1; // 1: related to startdate - 2: related to enddate
// fix for #24507 make sure the alarm is BEFORE the event not after
- alarm.offset = com.synckolab.tools.text.createDuration(-1 * Number(jobj.alarms[i].offset));
+ alarm.offset = synckolab.tools.text.createDuration(-1 * Number(jobj.alarms[i].offset));
// TODO lightning has some other attributes which we should take care of
- com.synckolab.tools.copyFields(jobj.alarms[i], alarm, ["description", "summary", "action"], true);
+ synckolab.tools.copyFields(jobj.alarms[i], alarm, ["description", "summary", "action"], true);
event.addAlarm(alarm);
}
else {
- event.alarmOffset = com.synckolab.tools.text.createDuration(-1 * Number(jobj.alarms[i].offset));
+ event.alarmOffset = synckolab.tools.text.createDuration(-1 * Number(jobj.alarms[i].offset));
}
}
}
@@ -887,7 +886,7 @@ com.synckolab.calendarTools.json2event = function (jobj, calendar) {
}
if(jobj.recurrence) {
- com.synckolab.tools.logMessage("recurring event", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("recurring event", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
var recInfo = Components.classes["@mozilla.org/calendar/recurrence-info;1"].createInstance(Components.interfaces.calIRecurrenceInfo);
recInfo.item = event;
@@ -904,7 +903,7 @@ com.synckolab.calendarTools.json2event = function (jobj, calendar) {
//alert(recRule.icalProperty.icalString);
var weeklyRecurrence = [];
for(var recdays = 0; recdays < jobj.recurrence.days.length; recdays++) {
- weeklyRecurrence.push(com.synckolab.tools.kolab.getDayIndex(jobj.recurrence.days[recdays]));
+ weeklyRecurrence.push(synckolab.tools.kolab.getDayIndex(jobj.recurrence.days[recdays]));
}
recRule.setComponent("BYDAY", weeklyRecurrence.length, weeklyRecurrence);
}
@@ -918,7 +917,7 @@ com.synckolab.calendarTools.json2event = function (jobj, calendar) {
recRule.setComponent("BYMONTHDAY", 1, [jobj.recurrence.daynumber]);
}
} else {
- var dayindex = com.synckolab.tools.kolab.getDayIndex(jobj.recurrence.weekday);
+ var dayindex = synckolab.tools.kolab.getDayIndex(jobj.recurrence.weekday);
if(jobj.recurrence.daynumber === -1) {
recRule.setComponent("BYDAY", 1, [(-1)*(8+dayindex)]);
} else {
@@ -939,17 +938,17 @@ com.synckolab.calendarTools.json2event = function (jobj, calendar) {
if(jobj.recurrence.untilDate) {
if (recRule.endDate) {
- recRule.endDate = com.synckolab.tools.text.string2CalDate(jobj.recurrence.untilDate);
+ recRule.endDate = synckolab.tools.text.string2CalDate(jobj.recurrence.untilDate);
} else {
// new lighnting
- recRule.untilDate = com.synckolab.tools.text.string2CalDate(jobj.recurrence.untilDate);
+ recRule.untilDate = synckolab.tools.text.string2CalDate(jobj.recurrence.untilDate);
}
}
recInfo.insertRecurrenceItemAt(recRule, 0);
if(jobj.recurrence.exclusion && jobj.recurrence.exclusion.length > 0) {
for(i=0; i < jobj.recurrence.exclusion.length; i++) {
- var exclusionDate = com.synckolab.tools.text.string2CalDate(jobj.recurrence.exclusion[i]);
+ var exclusionDate = synckolab.tools.text.string2CalDate(jobj.recurrence.exclusion[i]);
recInfo.removeOccurrenceAt(exclusionDate);
var exclusion = recInfo.getOccurrenceFor(exclusionDate,true);
recInfo.modifyException(exclusion, true);
@@ -1010,10 +1009,10 @@ com.synckolab.calendarTools.json2event = function (jobj, calendar) {
*
* @return true, if this event actually existed
*/
-com.synckolab.calendarTools.xml2json = function (xml, syncTasks)
+synckolab.calendarTools.xml2json = function (xml, syncTasks)
{
var jobj = {
- synckolab : com.synckolab.config.version, // synckolab version
+ synckolab : synckolab.config.version, // synckolab version
type : "calendar"
};
@@ -1024,16 +1023,16 @@ com.synckolab.calendarTools.xml2json = function (xml, syncTasks)
// check if we have to decode quoted printable
if (xml.indexOf(" version=3D") !== -1) { // we know from the version
- xml = com.synckolab.tools.text.quoted.decode(xml);
+ xml = synckolab.tools.text.quoted.decode(xml);
}
- com.synckolab.tools.logMessage("Parsing an XML event:\n" + xml, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Parsing an XML event:\n" + xml, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
// TODO improve recurrence settings
// not working ATM:
// - yearly recurrence
// decode utf chars and make sure an & is an &amp; (otherwise this is unparseable)
- xml = com.synckolab.tools.text.utf8.decode(xml);
+ xml = synckolab.tools.text.utf8.decode(xml);
// temporary fixes:
// - attribute: "summary= ; "action=
// TODO: remove for non-nightly!!!
@@ -1052,28 +1051,28 @@ com.synckolab.calendarTools.xml2json = function (xml, syncTasks)
if (topNode.nodeName === "parsererror")
{
// so this message has no valid XML part :-(
- com.synckolab.tools.logMessage("Error parsing the XML content of this message.\n" + xml, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("Error parsing the XML content of this message.\n" + xml, synckolab.global.LOG_CAL + synckolab.global.LOG_ERROR);
return false;
}
if ((topNode.nodeType !== Node.ELEMENT_NODE) || ((topNode.nodeName.toUpperCase() !== "EVENT") && (topNode.nodeName.toUpperCase() !== "TASK") ))
{
// this can't be an event in Kolab XML format
- com.synckolab.tools.logMessage("This message doesn't contain an event in Kolab XML format.\n" + xml, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("This message doesn't contain an event in Kolab XML format.\n" + xml, synckolab.global.LOG_CAL + synckolab.global.LOG_ERROR);
return false;
}
// check for task
if(syncTasks !== true && topNode.nodeName.toUpperCase() === "TASK") {
- com.synckolab.tools.logMessage("Skipping task in event sync", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("Skipping task in event sync", synckolab.global.LOG_CAL + synckolab.global.LOG_ERROR);
return null;
}
if(syncTasks === true && topNode.nodeName.toUpperCase() !== "TASK") {
- com.synckolab.tools.logMessage("Skipping event in task sync", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("Skipping event in task sync", synckolab.global.LOG_CAL + synckolab.global.LOG_ERROR);
return null;
}
- var cur = new com.synckolab.Node(topNode.firstChild);
+ var cur = new synckolab.Node(topNode.firstChild);
var s, tmpobj;
var cDate;
// iterate over the DOM tree of the XML structure of the event
@@ -1385,7 +1384,7 @@ com.synckolab.calendarTools.xml2json = function (xml, syncTasks)
jobj.recurrence.interval = Number(cur.getXmlResult("INTERVAL", 1));
jobj.recurrence.count = 0;
- var node = new com.synckolab.Node(cur.getChildNode("RANGE"));
+ var node = new synckolab.Node(cur.getChildNode("RANGE"));
if (node)
{
// read the "type" attribute of the range
@@ -1490,7 +1489,7 @@ com.synckolab.calendarTools.xml2json = function (xml, syncTasks)
cur = cur.nextSibling;
} // end while
- com.synckolab.tools.logMessage("Parsed event in XML", com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Parsed event in XML", synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
return jobj;
};
@@ -1499,7 +1498,7 @@ com.synckolab.calendarTools.xml2json = function (xml, syncTasks)
* Kolabs "deferred" will be Lightning "CANCELLED"
*/
/* return the task status */
-com.synckolab.calendarTools.getTaskStatus = function (tstatus, xmlvalue) {
+synckolab.calendarTools.getTaskStatus = function (tstatus, xmlvalue) {
var arrstatus = [];
arrstatus["IN-PROCESS"] = "in-progress";
arrstatus["IN-PROGRESS"] = "in-progress";
@@ -1543,7 +1542,7 @@ com.synckolab.calendarTools.getTaskStatus = function (tstatus, xmlvalue) {
* @param skipVolatiles skips problematic fields for hash creation
* @return XML string in Kolab 2 format
*/
-com.synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
+synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
// TODO not working ATM:
// - yearly recurrence
@@ -1556,35 +1555,35 @@ com.synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
xml += '<event version='+'"'+'1.0" >\n';
}
- xml += " <product-id>Synckolab " + com.synckolab.config.version + ", Calendar Sync</product-id>\n";
- xml += com.synckolab.tools.text.nodeWithContent("uid", jobj.uid, false);
+ xml += " <product-id>Synckolab " + synckolab.config.version + ", Calendar Sync</product-id>\n";
+ xml += synckolab.tools.text.nodeWithContent("uid", jobj.uid, false);
if(syncTasks === true)
{
// tasks have a status
- xml += com.synckolab.tools.text.nodeWithContent("status", jobj.status, false);
- xml += com.synckolab.tools.text.nodeWithContent("completed", jobj.completed, false);
- xml += com.synckolab.tools.text.nodeWithContent("start-date", jobj.startDate, false);
- xml += com.synckolab.tools.text.nodeWithContent("due-date", jobj.endDate, false);
- xml += com.synckolab.tools.text.nodeWithContent("priority", jobj.priority, false);
+ xml += synckolab.tools.text.nodeWithContent("status", jobj.status, false);
+ xml += synckolab.tools.text.nodeWithContent("completed", jobj.completed, false);
+ xml += synckolab.tools.text.nodeWithContent("start-date", jobj.startDate, false);
+ xml += synckolab.tools.text.nodeWithContent("due-date", jobj.endDate, false);
+ xml += synckolab.tools.text.nodeWithContent("priority", jobj.priority, false);
- // xml += " <completed-date>" + com.synckolab.tools.text.calDateTime2String(completedDate, true) + "</completed-date>\n";
+ // xml += " <completed-date>" + synckolab.tools.text.calDateTime2String(completedDate, true) + "</completed-date>\n";
}
else
{
- xml += com.synckolab.tools.text.nodeWithContent("start-date", jobj.startDate, false);
- xml += com.synckolab.tools.text.nodeWithContent("end-date", jobj.endDate, false);
+ xml += synckolab.tools.text.nodeWithContent("start-date", jobj.startDate, false);
+ xml += synckolab.tools.text.nodeWithContent("end-date", jobj.endDate, false);
}
- xml += com.synckolab.tools.text.nodeWithContent("summary", jobj.title, false);
- xml += com.synckolab.tools.text.nodeWithContent("body", jobj.body, false);
- xml += com.synckolab.tools.text.nodeWithContent("sensitivity", jobj.sensitivity, false);
+ xml += synckolab.tools.text.nodeWithContent("summary", jobj.title, false);
+ xml += synckolab.tools.text.nodeWithContent("body", jobj.body, false);
+ xml += synckolab.tools.text.nodeWithContent("sensitivity", jobj.sensitivity, false);
// xml += " <creation-date>" + jobj.createdDate + "</creation-date>\n";
// xml += " <last-modification-date>" + jobj.lastModificationDate + "</last-modification-date>\n";
- xml += com.synckolab.tools.text.nodeWithContent("location", jobj.location, false);
- xml += com.synckolab.tools.text.nodeWithContent("show-time-as", jobj.showTimeAs, false);
- xml += com.synckolab.tools.text.nodeWithContent("color-label", jobj.colorLabel, false);
+ xml += synckolab.tools.text.nodeWithContent("location", jobj.location, false);
+ xml += synckolab.tools.text.nodeWithContent("show-time-as", jobj.showTimeAs, false);
+ xml += synckolab.tools.text.nodeWithContent("color-label", jobj.colorLabel, false);
var i;
if(jobj.alarms) {
@@ -1604,7 +1603,7 @@ com.synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
}
}
- xml += com.synckolab.tools.text.nodeWithContent("categories", jobj.categories, false);
+ xml += synckolab.tools.text.nodeWithContent("categories", jobj.categories, false);
if(jobj.recurrence) {
switch(jobj.recurrence.cycle) {
case "daily":
@@ -1613,7 +1612,7 @@ com.synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
case "weekly":
xml += " <recurrence cycle=\"weekly\">\n";
for(i=0; i < jobj.recurrence.days.length; i++) {
- xml += com.synckolab.tools.text.nodeWithContent("day", jobj.recurrence.days[i], false);
+ xml += synckolab.tools.text.nodeWithContent("day", jobj.recurrence.days[i], false);
}
break;
case "monthly":
@@ -1622,7 +1621,7 @@ com.synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
} else if(jobj.recurrence.days) {
xml += " <recurrence cycle=\"monthly\" type=\"daynumber\">\n";
for(i=0; i < jobj.recurrence.days.length; i++) {
- xml += com.synckolab.tools.text.nodeWithContent("daynumber", jobj.recurrence.days[i], false);
+ xml += synckolab.tools.text.nodeWithContent("daynumber", jobj.recurrence.days[i], false);
}
} else if(!jobj.recurrence.weekday) {
xml += " <recurrence cycle=\"monthly\" type=\"daynumber\">\n";
@@ -1655,7 +1654,7 @@ com.synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
break;
}
- xml += com.synckolab.tools.text.nodeWithContent("interval", jobj.recurrence.interval, true);
+ xml += synckolab.tools.text.nodeWithContent("interval", jobj.recurrence.interval, true);
if(jobj.recurrence.count && jobj.recurrence.count > 0) {
xml += " <range type=\"number\">" + jobj.recurrence.count + "</range>\n";
} else if(jobj.recurrence.untilDate) {
@@ -1666,7 +1665,7 @@ com.synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
if(jobj.recurrence.exclusion) {
for(i=0; i < jobj.recurrence.exclusion.length; i++) {
- xml += com.synckolab.tools.text.nodeWithContent("exclusion", jobj.recurrence.exclusion[i], true);
+ xml += synckolab.tools.text.nodeWithContent("exclusion", jobj.recurrence.exclusion[i], true);
}
}
@@ -1676,11 +1675,11 @@ com.synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
if(jobj.attendees) {
for(i=0; i < jobj.attendees.length; i++) {
xml += " <attendee>\n";
- xml += com.synckolab.tools.text.nodeWithContent("display-name", jobj.attendees[i].displayName, false);
- xml += com.synckolab.tools.text.nodeWithContent("smtp-address", jobj.attendees[i].email, false);
- xml += com.synckolab.tools.text.nodeWithContent("status", jobj.attendees[i].status, false);
- xml += com.synckolab.tools.text.nodeWithContent("request-response", jobj.attendees[i].rsvp ? "true" : "false", false);
- xml += com.synckolab.tools.text.nodeWithContent("role", jobj.attendees[i].role, false);
+ xml += synckolab.tools.text.nodeWithContent("display-name", jobj.attendees[i].displayName, false);
+ xml += synckolab.tools.text.nodeWithContent("smtp-address", jobj.attendees[i].email, false);
+ xml += synckolab.tools.text.nodeWithContent("status", jobj.attendees[i].status, false);
+ xml += synckolab.tools.text.nodeWithContent("request-response", jobj.attendees[i].rsvp ? "true" : "false", false);
+ xml += synckolab.tools.text.nodeWithContent("role", jobj.attendees[i].role, false);
xml += " </attendee>\n";
}
}
@@ -1689,16 +1688,16 @@ com.synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
if (jobj.organizer)
{
xml += " <organizer>\n";
- xml += com.synckolab.tools.text.nodeWithContent("display-name", jobj.organizer.displayName, false);
- xml += com.synckolab.tools.text.nodeWithContent("smtp-address", jobj.organizer.email, false);
+ xml += synckolab.tools.text.nodeWithContent("display-name", jobj.organizer.displayName, false);
+ xml += synckolab.tools.text.nodeWithContent("smtp-address", jobj.organizer.email, false);
xml += " </organizer>\n";
}
if (jobj.creator)
{
xml += " <creator>\n";
- xml += com.synckolab.tools.text.nodeWithContent("display-name", jobj.creator.displayName, false);
- xml += com.synckolab.tools.text.nodeWithContent("smtp-address", jobj.creator.email, false);
+ xml += synckolab.tools.text.nodeWithContent("display-name", jobj.creator.displayName, false);
+ xml += synckolab.tools.text.nodeWithContent("smtp-address", jobj.creator.email, false);
xml += " </creator>\n";
}
@@ -1712,14 +1711,14 @@ com.synckolab.calendarTools.json2xml = function (jobj, syncTasks, email) {
xml += "</event>\n";
}
- //com.synckolab.tools.logMessage("Created XML event structure:\n=============================\n" + xml, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ //synckolab.tools.logMessage("Created XML event structure:\n=============================\n" + xml, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
return xml;
};
/**
* Write an event into human readable form
*/
-com.synckolab.calendarTools.json2Human = function (jobj)
+synckolab.calendarTools.json2Human = function (jobj)
{
var txt = "";
if (jobj.title) {
@@ -1750,12 +1749,12 @@ com.synckolab.calendarTools.json2Human = function (jobj)
*
* @return a message in Kolab 2 format
*/
-com.synckolab.calendarTools.event2kolabXmlMsg = function (event, email)
+synckolab.calendarTools.event2kolabXmlMsg = function (event, email)
{
var syncTasks = (event.type === "task");
var xml = this.json2xml(event, syncTasks);
- return com.synckolab.tools.generateMail(event.uid, email, "", syncTasks?"application/x-vnd.kolab.task":"application/x-vnd.kolab.event",
- true, com.synckolab.tools.text.utf8.encode(xml), this.json2Human(event, syncTasks));
+ return synckolab.tools.generateMail(event.uid, email, "", syncTasks?"application/x-vnd.kolab.task":"application/x-vnd.kolab.event",
+ true, synckolab.tools.text.utf8.encode(xml), this.json2Human(event, syncTasks));
};
@@ -1763,7 +1762,7 @@ com.synckolab.calendarTools.event2kolabXmlMsg = function (event, email)
/**
* functions to handle the iCal event format
*/
-com.synckolab.calendarTools.ical2event = function (content, todo)
+synckolab.calendarTools.ical2event = function (content, todo)
{
var event;
var icssrv = Components.classes["@mozilla.org/calendar/ics-service;1"]
@@ -1775,7 +1774,7 @@ com.synckolab.calendarTools.ical2event = function (content, todo)
rootComp = icssrv.parseICS(content, null);
}
catch (ex) {
- com.synckolab.tools.logMessage("unable to parse ical: " + content, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("unable to parse ical: " + content, synckolab.global.LOG_CAL + synckolab.global.LOG_ERROR);
return null;
}
@@ -1803,24 +1802,24 @@ com.synckolab.calendarTools.ical2event = function (content, todo)
.createInstance(Components.interfaces.calITodo);
break;
} else if (subComp.componentType !== "VTIMEZONE") {
- com.synckolab.tools.logMessage("unable to parse event 2: " + content, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("unable to parse event 2: " + content, synckolab.global.LOG_CAL + synckolab.global.LOG_ERROR);
return null;
}
subComp = event.getNextSubcomponent("ANY");
}
if (!subComp ) {
- com.synckolab.tools.logMessage("unable to parse event 3: " + content, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("unable to parse event 3: " + content, synckolab.global.LOG_CAL + synckolab.global.LOG_ERROR);
return null;
}
try {
event.icalComponent = subComp;
- com.synckolab.tools.logMessage("parsed event: " + event + ":" + event.id, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("parsed event: " + event + ":" + event.id, synckolab.global.LOG_CAL + synckolab.global.LOG_INFO);
}
catch (exc) {
- com.synckolab.tools.logMessage("unable to parse event: \n" + content, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("unable to parse event: \n" + content, synckolab.global.LOG_CAL + synckolab.global.LOG_ERROR);
return null;
}
return event;
diff --git a/src/chrome/content/synckolab/config.js b/src/chrome/content/synckolab/config.js
index 31cefbd..4eef754 100644
--- a/src/chrome/content/synckolab/config.js
+++ b/src/chrome/content/synckolab/config.js
@@ -32,11 +32,10 @@
***** END LICENSE BLOCK ***** */
"use strict";
-if(!com) var com={};
-if(!com.synckolab) com.synckolab={};
+if(!synckolab) var synckolab={};
-com.synckolab.config = {
- version: "2.0.3",
+synckolab.config = {
+ version: "3.0.0",
DEBUG_SYNCKOLAB: true,
SWITCH_TIME: 20, //wait 20ms (enough so tbird wont get unresponsive)
@@ -55,27 +54,27 @@ com.synckolab.config = {
// definition of settings that are the same for each part (contact/calendar/task)
baseSetting: {
// the address book / calendar
- source: {type: com.synckolab.tools.CONFIG_TYPE_CHAR, def: null },
+ source: {type: synckolab.tools.CONFIG_TYPE_CHAR, def: null },
// the imap folder path
- folderPath: {type: com.synckolab.tools.CONFIG_TYPE_CHAR, def: null },
+ folderPath: {type: synckolab.tools.CONFIG_TYPE_CHAR, def: null },
// true if the config is enabled
- enabled: {type: com.synckolab.tools.CONFIG_TYPE_BOOL, def: true },
+ enabled: {type: synckolab.tools.CONFIG_TYPE_BOOL, def: true },
// save changes to imap (vs. read only)
- saveToImap: {type: com.synckolab.tools.CONFIG_TYPE_BOOL, def: true },
+ saveToImap: {type: synckolab.tools.CONFIG_TYPE_BOOL, def: true },
// automatically sync every X minutes (0 = disable)
- //@deprecated syncInterval: {type: com.synckolab.tools.CONFIG_TYPE_INT, def: 0 },
+ //@deprecated syncInterval: {type: synckolab.tools.CONFIG_TYPE_INT, def: 0 },
// format to use: xml|vcard
- format: {type: com.synckolab.tools.CONFIG_TYPE_CHAR, def: "xml" },
+ format: {type: synckolab.tools.CONFIG_TYPE_CHAR, def: "xml" },
// timeframe to sync in (don't sync entries with an older start-date)
- timeFrame: {type: com.synckolab.tools.CONFIG_TYPE_INT, def: 180},
+ timeFrame: {type: synckolab.tools.CONFIG_TYPE_INT, def: 180},
// enable the sync listener
- syncListener: {type: com.synckolab.tools.CONFIG_TYPE_BOOL, def: false },
+ syncListener: {type: synckolab.tools.CONFIG_TYPE_BOOL, def: false },
// what to do with conflicts
- defaultResolve: {type: com.synckolab.tools.CONFIG_TYPE_CHAR, def: "ask" }
+ defaultResolve: {type: synckolab.tools.CONFIG_TYPE_CHAR, def: "ask" }
}
};
-com.synckolab.global = {
+synckolab.global = {
// log settings
LOG_ERROR: 0,
LOG_WARNING: 1,
@@ -107,24 +106,24 @@ com.synckolab.global = {
* @param pref the preference service (optional)
* @returns a configuration object
*/
-com.synckolab.config.loadConfiguration = function(pref) {
+synckolab.config.loadConfiguration = function(pref) {
if(!pref) {
pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
}
var config = {
- version: com.synckolab.tools.getConfigValue(pref, "configVersion", com.synckolab.tools.CONFIG_TYPE_INT, 0),
- debugLevel: com.synckolab.tools.getConfigValue(pref, "debugLevel", com.synckolab.tools.CONFIG_TYPE_INT, com.synckolab.global.LOG_WARNING),
+ version: synckolab.tools.getConfigValue(pref, "configVersion", synckolab.tools.CONFIG_TYPE_INT, 0),
+ debugLevel: synckolab.tools.getConfigValue(pref, "debugLevel", synckolab.tools.CONFIG_TYPE_INT, synckolab.global.LOG_WARNING),
// hide folder
- hideFolder: com.synckolab.tools.getConfigValue(pref, "hideFolder", com.synckolab.tools.CONFIG_TYPE_BOOL, false),
+ hideFolder: synckolab.tools.getConfigValue(pref, "hideFolder", synckolab.tools.CONFIG_TYPE_BOOL, false),
// close window when done
- closeWindow: com.synckolab.tools.getConfigValue(pref, "closeWindow", com.synckolab.tools.CONFIG_TYPE_BOOL, false),
+ closeWindow: synckolab.tools.getConfigValue(pref, "closeWindow", synckolab.tools.CONFIG_TYPE_BOOL, false),
// sync automatically once on start
- syncOnStart: com.synckolab.tools.getConfigValue(pref, "syncOnStart", com.synckolab.tools.CONFIG_TYPE_BOOL, false),
+ syncOnStart: synckolab.tools.getConfigValue(pref, "syncOnStart", synckolab.tools.CONFIG_TYPE_BOOL, false),
accounts: []
};
- var sAcct = com.synckolab.tools.getConfigValue(pref, "accounts.list");
+ var sAcct = synckolab.tools.getConfigValue(pref, "accounts.list");
if (sAcct) {
var sAccts = sAcct.split(';');
for(var i = 0; i < sAccts.length; i++) {
@@ -140,7 +139,7 @@ com.synckolab.config.loadConfiguration = function(pref) {
};
config.accounts.push(acct);
- com.synckolab.config.loadAccountConfig(pref, acct);
+ synckolab.config.loadAccountConfig(pref, acct);
}
}
@@ -152,13 +151,13 @@ com.synckolab.config.loadConfiguration = function(pref) {
* read the account configuration into an object
* @param acct the account object to read the configuration into (name has to be existent)
*/
-com.synckolab.config.loadAccountConfig = function (pref, acct) {
+synckolab.config.loadAccountConfig = function (pref, acct) {
var sConf, sConfs, i;
for(var type in acct) {
// skip volatiles/non-arrays
if(type !== "name" && acct[type].push) {
- sConf = com.synckolab.tools.getConfigValue(pref, "accounts." + acct.name+"." + type + ".list");
+ sConf = synckolab.tools.getConfigValue(pref, "accounts." + acct.name+"." + type + ".list");
sConfs = sConf.split(';');
if(sConfs) {
for(i = 0; i < sConfs.length; i++) {
@@ -172,12 +171,12 @@ com.synckolab.config.loadAccountConfig = function (pref, acct) {
acct[type].push(cConf);
// read all the base settings
- for(var n in com.synckolab.config.baseSetting) {
+ for(var n in synckolab.config.baseSetting) {
// skip unwanted prototypes (without type)
- if(com.synckolab.config.baseSetting[n].type >= 0) {
- cConf[n] = com.synckolab.tools.getConfigValue(pref, "accounts." + acct.name+"." + type + ".configs." + cConf.name + "." + n,
- com.synckolab.config.baseSetting[n].type,
- com.synckolab.config.baseSetting[n].def);
+ if(synckolab.config.baseSetting[n].type >= 0) {
+ cConf[n] = synckolab.tools.getConfigValue(pref, "accounts." + acct.name+"." + type + ".configs." + cConf.name + "." + n,
+ synckolab.config.baseSetting[n].type,
+ synckolab.config.baseSetting[n].def);
}
}
}
@@ -196,36 +195,36 @@ com.synckolab.config.loadAccountConfig = function (pref, acct) {
* <li>the folder listener
* </ul>
*/
-com.synckolab.config.readConfiguration = function() {
+synckolab.config.readConfiguration = function() {
var i,j;
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
- var curVersion = com.synckolab.tools.getConfigValue(pref, "configVersion", com.synckolab.tools.CONFIG_TYPE_INT, 0);
- com.synckolab.tools.logMessage("Checking configuration ("+com.synckolab.config.VERSION+" - "+curVersion+")", com.synckolab.global.LOG_DEBUG);
+ var curVersion = synckolab.tools.getConfigValue(pref, "configVersion", synckolab.tools.CONFIG_TYPE_INT, 0);
+ synckolab.tools.logMessage("Checking configuration ("+synckolab.config.VERSION+" - "+curVersion+")", synckolab.global.LOG_DEBUG);
- if(curVersion === com.synckolab.config.VERSION) {
+ if(curVersion === synckolab.config.VERSION) {
// nothing changed and we have an active config
return;
}
// load the configuration (use existing pref service)
- var config = com.synckolab.config.loadConfiguration(pref);
+ var config = synckolab.config.loadConfiguration(pref);
// set the debug level
- com.synckolab.config.DEBUG_SYNCKOLAB_LEVEL = com.synckolab.global.LOG_ALL + config.debugLevel;
+ synckolab.config.DEBUG_SYNCKOLAB_LEVEL = synckolab.global.LOG_ALL + config.debugLevel;
- com.synckolab.tools.logMessage("Config Version has changed. ("+com.synckolab.config.VERSION+" - "+curVersion+") - LogLevel " + com.synckolab.config.DEBUG_SYNCKOLAB_LEVEL, com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Config Version has changed. ("+synckolab.config.VERSION+" - "+curVersion+") - LogLevel " + synckolab.config.DEBUG_SYNCKOLAB_LEVEL, synckolab.global.LOG_INFO);
// remember the config version
- com.synckolab.config.VERSION = curVersion;
+ synckolab.config.VERSION = curVersion;
- com.synckolab.main.config = config;
+ synckolab.main.config = config;
// hide folder
- com.synckolab.main.hideFolder = config.hideFolder;
+ synckolab.main.hideFolder = config.hideFolder;
// create an object for each configuration
- com.synckolab.main.syncConfigs = [];
+ synckolab.main.syncConfigs = [];
// hide window
- com.synckolab.main.doHideWindow = config.hiddenWindow;
+ synckolab.main.doHideWindow = config.hiddenWindow;
// check for listener or autorun
@@ -235,43 +234,43 @@ com.synckolab.config.readConfiguration = function() {
// read the messagefolder and save the object in the config
for(j = 0; j < account.contact.length; j++) {
account.contact[j].serverKey = account.name;
- com.synckolab.config.prepareConfig(account.contact[j], "contact");
+ synckolab.config.prepareConfig(account.contact[j], "contact");
if(account.contact[j].enabled) {
- com.synckolab.tools.logMessage("Adding contact account " + account.contact[j].name, com.synckolab.global.LOG_INFO);
- com.synckolab.main.syncConfigs.push(account.contact[j]);
+ synckolab.tools.logMessage("Adding contact account " + account.contact[j].name, synckolab.global.LOG_INFO);
+ synckolab.main.syncConfigs.push(account.contact[j]);
}
}
if(account.calendar) {
for(j = 0; j < account.calendar.length; j++) {
- com.synckolab.tools.logMessage("checking calendar " + account.calendar[j].name, com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("checking calendar " + account.calendar[j].name, synckolab.global.LOG_INFO);
account.calendar[j].serverKey = account.name;
- com.synckolab.config.prepareConfig(account.calendar[j], "calendar");
- com.synckolab.tools.logMessage("checking calendar " + account.calendar[j].name + " enabled? " + account.calendar[j].enabled, com.synckolab.global.LOG_INFO);
+ synckolab.config.prepareConfig(account.calendar[j], "calendar");
+ synckolab.tools.logMessage("checking calendar " + account.calendar[j].name + " enabled? " + account.calendar[j].enabled, synckolab.global.LOG_INFO);
if(account.calendar[j].enabled) {
- com.synckolab.tools.logMessage("Adding calendar account " + account.calendar[j].name, com.synckolab.global.LOG_INFO);
- com.synckolab.main.syncConfigs.push(account.calendar[j]);
+ synckolab.tools.logMessage("Adding calendar account " + account.calendar[j].name, synckolab.global.LOG_INFO);
+ synckolab.main.syncConfigs.push(account.calendar[j]);
}
}
}
if(account.task) {
for(j = 0; j < account.task.length; j++) {
- com.synckolab.tools.logMessage("checking task " + account.calendar[j].name, com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("checking task " + account.calendar[j].name, synckolab.global.LOG_INFO);
account.task[j].serverKey = account.name;
- com.synckolab.config.prepareConfig(account.task[j], "task");
+ synckolab.config.prepareConfig(account.task[j], "task");
if(account.task[j].enabled) {
- com.synckolab.tools.logMessage("Adding task account " + account.task[j].name, com.synckolab.global.LOG_INFO);
- com.synckolab.main.syncConfigs.push(account.task[j]);
+ synckolab.tools.logMessage("Adding task account " + account.task[j].name, synckolab.global.LOG_INFO);
+ synckolab.main.syncConfigs.push(account.task[j]);
}
}
}
}
var msgNotificationService = Components.classes["@mozilla.org/messenger/msgnotificationservice;1"].getService(Components.interfaces.nsIMsgFolderNotificationService);
- msgNotificationService.addListener(com.synckolab.config.folderListener, msgNotificationService.msgAdded | msgNotificationService.msgsDeleted | msgNotificationService.msgsMoveCopyCompleted);
+ msgNotificationService.addListener(synckolab.config.folderListener, msgNotificationService.msgAdded | msgNotificationService.msgsDeleted | msgNotificationService.msgsMoveCopyCompleted);
};
-com.synckolab.config.checkIdProcessed = function(baseConfig, id) {
+synckolab.config.checkIdProcessed = function(baseConfig, id) {
for(var i = 0; i < baseConfig.recentProcessed.length; i++) {
if(id === baseConfig.recentProcessed[i]) {
baseConfig.recentProcessed.splice(i, 1);
@@ -285,28 +284,28 @@ com.synckolab.config.checkIdProcessed = function(baseConfig, id) {
/**
* creates an empty config object
*/
-com.synckolab.config.prepareConfig = function(baseConfig, confType) {
+synckolab.config.prepareConfig = function(baseConfig, confType) {
// if we dont wnat to - dont initialize it
if(!baseConfig.enabled) {
- com.synckolab.tools.logMessage("config " + baseConfig.name +"/"+confType + " is disabled!", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("config " + baseConfig.name +"/"+confType + " is disabled!", synckolab.global.LOG_INFO);
return;
}
// no folder - not enabled
if(!baseConfig.folderPath || baseConfig.folderPath.length < 5) {
- com.synckolab.tools.logMessage("disabling " + baseConfig.name +"/"+confType + "- no folderpath found", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("disabling " + baseConfig.name +"/"+confType + "- no folderpath found", synckolab.global.LOG_INFO);
baseConfig.enabled = false;
return;
}
// no source - not enabled
if(!baseConfig.source) {
- com.synckolab.tools.logMessage("disabling " + baseConfig.name +"/"+confType + "- no source found", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("disabling " + baseConfig.name +"/"+confType + "- no source found", synckolab.global.LOG_INFO);
baseConfig.enabled = false;
return;
}
// keep a lookup of ALL messages in the folder for local trigger
- baseConfig.msgList = new com.synckolab.hashMap();
+ baseConfig.msgList = new synckolab.hashMap();
// keep a list of all IDs recently processed - this avoids double checking
baseConfig.recentProcessed = [];
@@ -316,65 +315,65 @@ com.synckolab.config.prepareConfig = function(baseConfig, confType) {
// trigger handler
if(confType === "contact") {
- baseConfig.triggerParseAddMessage = com.synckolab.AddressBook.triggerParseAddMessage;
- baseConfig.triggerParseDeleteMessage = com.synckolab.AddressBook.triggerParseDeleteMessage;
- baseConfig.init = com.synckolab.AddressBook.init;
- baseConfig.syncClass = com.synckolab.AddressBook;
+ baseConfig.triggerParseAddMessage = synckolab.AddressBook.triggerParseAddMessage;
+ baseConfig.triggerParseDeleteMessage = synckolab.AddressBook.triggerParseDeleteMessage;
+ baseConfig.init = synckolab.AddressBook.init;
+ baseConfig.syncClass = synckolab.AddressBook;
// add some custom contact related stuff
- com.synckolab.AddressBook.readConfig(baseConfig);
+ synckolab.AddressBook.readConfig(baseConfig);
} else {
// tasks and events are handled by calendar
- baseConfig.triggerParseAddMessage = com.synckolab.Calendar.triggerParseAddMessage;
- baseConfig.triggerParseDeleteMessage = com.synckolab.Calendar.triggerParseDeleteMessage;
- baseConfig.init = com.synckolab.Calendar.init;
- baseConfig.syncClass = com.synckolab.Calendar;
+ baseConfig.triggerParseAddMessage = synckolab.Calendar.triggerParseAddMessage;
+ baseConfig.triggerParseDeleteMessage = synckolab.Calendar.triggerParseDeleteMessage;
+ baseConfig.init = synckolab.Calendar.init;
+ baseConfig.syncClass = synckolab.Calendar;
// add some custom contact related stuff
- com.synckolab.Calendar.readConfig(baseConfig);
+ synckolab.Calendar.readConfig(baseConfig);
}
// get and set the message folder
- baseConfig.folder = com.synckolab.tools.getMsgFolder(baseConfig.serverKey, baseConfig.folderPath);
+ baseConfig.folder = synckolab.tools.getMsgFolder(baseConfig.serverKey, baseConfig.folderPath);
// disable config if it doesnt exist
if(!baseConfig.folder) {
- com.synckolab.tools.logMessage("disabling " + baseConfig.name +"/"+confType + " - baseFolder missing " + baseConfig.folderPath, com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("disabling " + baseConfig.name +"/"+confType + " - baseFolder missing " + baseConfig.folderPath, synckolab.global.LOG_INFO);
baseConfig.enabled = false;
return;
}
baseConfig.folderMsgURI = baseConfig.folder.baseMessageURI;
- baseConfig.email = com.synckolab.tools.getAccountEMail(baseConfig.serverKey);
- baseConfig.mailname = com.synckolab.tools.getAccountName(baseConfig.serverKey);
+ baseConfig.email = synckolab.tools.getAccountEMail(baseConfig.serverKey);
+ baseConfig.mailname = synckolab.tools.getAccountName(baseConfig.serverKey);
- com.synckolab.tools.logMessage(baseConfig.name +"/"+confType + ": check listener for "+ baseConfig.folderMsgURI, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage(baseConfig.name +"/"+confType + ": check listener for "+ baseConfig.folderMsgURI, synckolab.global.LOG_DEBUG);
if(baseConfig.addListener) {
- com.synckolab.tools.logMessage("adding listener for "+ baseConfig.folderMsgURI, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("adding listener for "+ baseConfig.folderMsgURI, synckolab.global.LOG_DEBUG);
}
- com.synckolab.tools.logMessage(baseConfig.name +"/"+confType + ": check sync on start", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage(baseConfig.name +"/"+confType + ": check sync on start", synckolab.global.LOG_DEBUG);
baseConfig.startOnce = false;
if(baseConfig.syncOnStart)
{
- com.synckolab.tools.logMessage("Run on Startup for "+ baseConfig.name, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Run on Startup for "+ baseConfig.name, synckolab.global.LOG_DEBUG);
// run the config
- com.synckolab.main.forceConfig = baseConfig;
- com.synckolab.main.sync("timer");
+ synckolab.main.forceConfig = baseConfig;
+ synckolab.main.sync("timer");
}
- com.synckolab.tools.logMessage(baseConfig.name +"/"+confType + ": done ("+baseConfig.enabled+")", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage(baseConfig.name +"/"+confType + ": done ("+baseConfig.enabled+")", synckolab.global.LOG_DEBUG);
};
-com.synckolab.config.folderListener = {
+synckolab.config.folderListener = {
findConfig: function(folder) {
// fixup folder: image:// vs. imap-message://
folder = "imap-message" + folder.substring(4);
// search through the configs
- for(var j = 0; j < com.synckolab.main.syncConfigs.length; j++) {
- if(com.synckolab.main.syncConfigs[j]) {
- var curConfig = com.synckolab.main.syncConfigs[j];
- com.synckolab.tools.logMessage("checking " + curConfig.folderMsgURI + " vs. " + folder, com.synckolab.global.LOG_DEBUG);
+ for(var j = 0; j < synckolab.main.syncConfigs.length; j++) {
+ if(synckolab.main.syncConfigs[j]) {
+ var curConfig = synckolab.main.syncConfigs[j];
+ synckolab.tools.logMessage("checking " + curConfig.folderMsgURI + " vs. " + folder, synckolab.global.LOG_DEBUG);
if(curConfig.syncListener && curConfig.folderMsgURI === folder)
{
@@ -386,24 +385,24 @@ com.synckolab.config.folderListener = {
},
msgAdded: function(aMsg) {
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
var msg = aMsg.QueryInterface(Components.interfaces.nsIMsgDBHdr);
//nsIMsgDBHdr - check folder
- com.synckolab.tools.logMessage("ADDED to " + msg.folder.folderURL, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("ADDED to " + msg.folder.folderURL, synckolab.global.LOG_DEBUG);
// lets see if we have this folde rin the list
var curConfig = this.findConfig(msg.folder.folderURL);
if(curConfig) {
// check if this one hasnt been just added
- if(com.synckolab.config.checkIdProcessed(curConfig, msg.mime2DecodedSubject)) {
- com.synckolab.tools.logMessage("message recently processed - ignore", com.synckolab.global.LOG_DEBUG);
+ if(synckolab.config.checkIdProcessed(curConfig, msg.mime2DecodedSubject)) {
+ synckolab.tools.logMessage("message recently processed - ignore", synckolab.global.LOG_DEBUG);
return;
}
- com.synckolab.tools.logMessage("Found configuration for folder... calling", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Found configuration for folder... calling", synckolab.global.LOG_DEBUG);
var content = {
message: "imap-message" + msg.folder.folderURL.substring(4) +"#"+msg.messageKey,
fileContent: "",
@@ -411,7 +410,7 @@ com.synckolab.config.folderListener = {
config: curConfig,
nextFunc: curConfig.triggerParseAddMessage
};
- com.synckolab.main.getMessageIntoContent(content);
+ synckolab.main.getMessageIntoContent(content);
}
},
msgsClassified: function(aMsgs, aJunkProcessed, aTraitProcessed) {
@@ -419,21 +418,21 @@ com.synckolab.config.folderListener = {
},
msgsDeleted: function(aMsgs) {
// make sure not to parse messages while a full sync is running
- if(com.synckolab.global.running || com.synckolab.global.triggerRunning) {
+ if(synckolab.global.running || synckolab.global.triggerRunning) {
return;
}
//nsiArray<nsIMsgDBHdr> - check folder
- com.synckolab.tools.logMessage("GOT DELETE...", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("GOT DELETE...", synckolab.global.LOG_DEBUG);
var e = aMsgs.enumerate();
while(e.hasMoreElements()) {
var msg = e.getNext().QueryInterface(Components.interfaces.nsIMsgDBHdr);
- com.synckolab.tools.logMessage("DELETED from " + msg.folder.folderURL, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("DELETED from " + msg.folder.folderURL, synckolab.global.LOG_DEBUG);
var curConfig = this.findConfig(msg.folder.folderURL);
if(curConfig) {
// check if this one hasnt been just removed
- if(com.synckolab.config.checkIdProcessed(curConfig, msg.mime2DecodedSubject)) {
- com.synckolab.tools.logMessage("message recently processed - ignore", com.synckolab.global.LOG_DEBUG);
+ if(synckolab.config.checkIdProcessed(curConfig, msg.mime2DecodedSubject)) {
+ synckolab.tools.logMessage("message recently processed - ignore", synckolab.global.LOG_DEBUG);
return;
}
@@ -444,7 +443,7 @@ com.synckolab.config.folderListener = {
config: curConfig,
nextFunc: curConfig.triggerParseDeleteMessage
};
- com.synckolab.main.getMessageIntoContent(content);
+ synckolab.main.getMessageIntoContent(content);
}
}
},
@@ -453,7 +452,7 @@ com.synckolab.config.folderListener = {
*/
msgsMoveCopyCompleted: function(aMove, aSrcMsgs, aDestFolder) {
//nsiArray<nsIMsgDBHdr> - check folder
- com.synckolab.tools.logMessage("MOVE: " + aMove, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("MOVE: " + aMove, synckolab.global.LOG_DEBUG);
if(aMove) {
this.msgsDeleted(aSrcMsgs);
}
@@ -474,7 +473,7 @@ com.synckolab.config.folderListener = {
// ignore
},
itemEvent: function(aItem, aEvent, aData) {
- com.synckolab.tools.logMessage("EVENT", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("EVENT", synckolab.global.LOG_DEBUG);
}
};
diff --git a/src/chrome/content/synckolab/contactConflictDialog.xul b/src/chrome/content/synckolab/contactConflictDialog.xul
index df752ad..6bf5580 100644
--- a/src/chrome/content/synckolab/contactConflictDialog.xul
+++ b/src/chrome/content/synckolab/contactConflictDialog.xul
@@ -13,10 +13,10 @@
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="contactConfligGldWindow"
buttons="accept,cancel"
- ondialogaccept="return com.synckolab.contactConflict.doOK();"
- ondialogcancel="return com.synckolab.contactConflict.doCancel();"
+ ondialogaccept="return synckolab.contactConflict.doOK();"
+ ondialogcancel="return synckolab.contactConflict.doCancel();"
buttonlabelcancel="Skip"
- onload="com.synckolab.contactConflict.init();"
+ onload="synckolab.contactConflict.init();"
persist="screenX screenY"
title="&synckolab.contactConflict.dialogTitle;">
@@ -250,8 +250,8 @@
</scrollbox>
<box align="left">
- <button label="Keep Server" oncommand="com.synckolab.contactConflict.keepServer(); return false;"/>
- <button label="Keep Local" oncommand="com.synckolab.contactConflict.keepLocal(); return false;"/>
+ <button label="Keep Server" oncommand="synckolab.contactConflict.keepServer(); return false;"/>
+ <button label="Keep Local" oncommand="synckolab.contactConflict.keepLocal(); return false;"/>
</box>
</dialog>
diff --git a/src/chrome/content/synckolab/contactConflictDialogCode.js b/src/chrome/content/synckolab/contactConflictDialogCode.js
index d054fea..2ce9637 100644
--- a/src/chrome/content/synckolab/contactConflictDialogCode.js
+++ b/src/chrome/content/synckolab/contactConflictDialogCode.js
@@ -30,10 +30,9 @@
*
***** END LICENSE BLOCK ***** */
"use strict";
-if(!com) var com={};
-if(!com.synckolab) com.synckolab={};
+if(!synckolab) var synckolab={};
-com.synckolab.contactConflict = {
+synckolab.contactConflict = {
localCard:null,
serverCard: null,
@@ -61,12 +60,12 @@ com.synckolab.contactConflict = {
} else {
//Updating both copies with new values
for ( i=0 ; i < this.conflictsArray.length ; i++ ) {
- var serverValue = com.synckolab.addressbookTools.getCardProperty(this.serverCard, this.conflictsArray[i]);
- var localValue = com.synckolab.addressbookTools.getCardProperty(this.localCard, this.conflictsArray[i]);
+ var serverValue = synckolab.addressbookTools.getCardProperty(this.serverCard, this.conflictsArray[i]);
+ var localValue = synckolab.addressbookTools.getCardProperty(this.localCard, this.conflictsArray[i]);
if (document.getElementById(this.conflictsArray[i]).selectedIndex === 0) {
- com.synckolab.addressbookTools.setCardProperty(this.localCard, this.conflictsArray[i], serverValue);
+ synckolab.addressbookTools.setCardProperty(this.localCard, this.conflictsArray[i], serverValue);
} else {
- com.synckolab.addressbookTools.setCardProperty(this.serverCard, this.conflictsArray[i], localValue);
+ synckolab.addressbookTools.setCardProperty(this.serverCard, this.conflictsArray[i], localValue);
}
}
this.conflictResolution.result = 3;
@@ -88,7 +87,7 @@ com.synckolab.contactConflict = {
document.getElementById(this.conflictsArray[i]).selectedIndex = 0;
}
else {
- com.synckolab.tools.logMessage("unable to find element for conflict " + this.conflictsArray[i], com.synckolab.global.LOG_ERROR + com.synckolab.global.LOG_AB);
+ synckolab.tools.logMessage("unable to find element for conflict " + this.conflictsArray[i], synckolab.global.LOG_ERROR + synckolab.global.LOG_AB);
}
}
return false;
@@ -113,18 +112,18 @@ com.synckolab.contactConflict = {
this.localCard = window.arguments[3];
//Show static elements for the following so that we always know who's record we are looking at
- document.getElementById("firstNameStatic").value = com.synckolab.addressbookTools.getCardProperty(this.localCard, 'FirstName');
- document.getElementById("lastNameStatic").value = com.synckolab.addressbookTools.getCardProperty(this.localCard, 'LastName');
- document.getElementById("displayNameStatic").value = com.synckolab.addressbookTools.getCardProperty(this.localCard, 'DisplayName');
- document.getElementById("nickNameStatic").value = com.synckolab.addressbookTools.getCardProperty(this.localCard, 'NickName');
+ document.getElementById("firstNameStatic").value = synckolab.addressbookTools.getCardProperty(this.localCard, 'FirstName');
+ document.getElementById("lastNameStatic").value = synckolab.addressbookTools.getCardProperty(this.localCard, 'LastName');
+ document.getElementById("displayNameStatic").value = synckolab.addressbookTools.getCardProperty(this.localCard, 'DisplayName');
+ document.getElementById("nickNameStatic").value = synckolab.addressbookTools.getCardProperty(this.localCard, 'NickName');
var serverValue;
var localValue;
//Loop through the conflicted fields, set their current values, unhide from the dialog
for (var i=0 ; i < this.conflictsArray.length ; i++ ) {
- serverValue = com.synckolab.addressbookTools.getCardProperty(this.serverCard, this.conflictsArray[i]);
- localValue = com.synckolab.addressbookTools.getCardProperty(this.localCard, this.conflictsArray[i]);
+ serverValue = synckolab.addressbookTools.getCardProperty(this.serverCard, this.conflictsArray[i]);
+ localValue = synckolab.addressbookTools.getCardProperty(this.localCard, this.conflictsArray[i]);
if (serverValue === 0 || serverValue === null || serverValue === "0" || serverValue === "null")
serverValue = "";
diff --git a/src/chrome/content/synckolab/contents.rdf b/src/chrome/content/synckolab/contents.rdf
index 3fabf0f..3773fc5 100644
--- a/src/chrome/content/synckolab/contents.rdf
+++ b/src/chrome/content/synckolab/contents.rdf
@@ -8,7 +8,7 @@
<!-- package information -->
<RDF:Description about="urn:mozilla:package:synckolab"
- chrome:displayName="SyncKolab 2.0.3"
+ chrome:displayName="SyncKolab 3.0.0"
chrome:author="Niko Berger"
chrome:name="synckolab"
chrome:description="Synchronize an IMAP Folder with the mozilla Address Book and Calendar "
diff --git a/src/chrome/content/synckolab/mainWindow.xul b/src/chrome/content/synckolab/mainWindow.xul
index baddfdf..23435cd 100644
--- a/src/chrome/content/synckolab/mainWindow.xul
+++ b/src/chrome/content/synckolab/mainWindow.xul
@@ -17,7 +17,7 @@
<commandset id="mailCommands">
<command id="cmd_synckolab_sync"
tooltiptext="&synckolab.sync.tip;"
- oncommand="com.synckolab.main.sync('manual');"/>
+ oncommand="synckolab.main.sync('manual');"/>
<command id="cmd_synckolab_options"
oncommand="window.openDialog('chrome://synckolab/content/wndConfig.xul', 'options', 'chrome=yes,resizable=yes,modal=yes');"/>
</commandset>
@@ -50,9 +50,9 @@
window.addEventListener("load", function load(event) {
window.removeEventListener("load", load, false); //remove listener, no longer needed
// init the timer
- com.synckolab.main.syncKolabTimer();
+ synckolab.main.syncKolabTimer();
// init the groupware
- com.synckolab.main.initGroupwareActions();
+ synckolab.main.initGroupwareActions();
}, false);
// calendar fix
diff --git a/src/chrome/content/synckolab/synckolab.js b/src/chrome/content/synckolab/synckolab.js
index f7a0054..5cb3b82 100644
--- a/src/chrome/content/synckolab/synckolab.js
+++ b/src/chrome/content/synckolab/synckolab.js
@@ -29,12 +29,11 @@
*
* ***** END LICENSE BLOCK ***** */
"use strict";
-if(!com) var com={};
-if(!com.synckolab) com.synckolab={};
+if(!synckolab) var synckolab={};
//synckolab interface
-com.synckolab.main = {
+synckolab.main = {
timer: Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer),
backgroundTimer: Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer),
/************************
@@ -58,21 +57,21 @@ com.synckolab.main = {
/**
* runs periodically and checks if there is anything to do
*/
-com.synckolab.main.syncKolabTimer = function () {
- com.synckolab.tools.logMessage("sync timer starting", com.synckolab.global.LOG_DEBUG);
- com.synckolab.config.readConfiguration();
+synckolab.main.syncKolabTimer = function () {
+ synckolab.tools.logMessage("sync timer starting", synckolab.global.LOG_DEBUG);
+ synckolab.config.readConfiguration();
/*@deprecated: listener works better
var i;
// check and load config
// only continue timer if nothing is running right now and if we have any configs!
- if (com.synckolab.main.forceConfig === null && com.synckolab.main.syncConfigs)
+ if (synckolab.main.forceConfig === null && synckolab.main.syncConfigs)
{
// go through all configs
- for (i=0; i < com.synckolab.main.syncConfigs.length; i++)
+ for (i=0; i < synckolab.main.syncConfigs.length; i++)
{
- var curConfig = com.synckolab.main.syncConfigs[i];
+ var curConfig = synckolab.main.syncConfigs[i];
// skip all configurations which dont have autorun
if (!curConfig || curConfig.autoRun === 0)
@@ -80,19 +79,19 @@ com.synckolab.main.syncKolabTimer = function () {
continue;
}
- com.synckolab.tools.logMessage("synctimer: checking: "+curConfig.name+" ("+com.synckolab.main.syncConfigs[i].gAutoRun+")....", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("synctimer: checking: "+curConfig.name+" ("+synckolab.main.syncConfigs[i].gAutoRun+")....", synckolab.global.LOG_DEBUG);
curConfig.syncTimer++;
// lets start (make sure no other auto config is running right now)
if (curConfig.syncTimer >= curConfig.autoRun)
{
- com.synckolab.tools.logMessage("running syncKolab configuration "+curConfig.name+" ("+curConfig.autoRun+")", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("running syncKolab configuration "+curConfig.name+" ("+curConfig.autoRun+")", synckolab.global.LOG_INFO);
curConfig.syncTimer = 0;
// hide the window
- com.synckolab.main.doHideWindow = curConfig.autoHideWindow;
- com.synckolab.main.forceConfig = curConfig.name;
- com.synckolab.main.sync("timer");
+ synckolab.main.doHideWindow = curConfig.autoHideWindow;
+ synckolab.main.forceConfig = curConfig.name;
+ synckolab.main.sync("timer");
// make sure, that we do not start another config right now
break;
@@ -101,24 +100,24 @@ com.synckolab.main.syncKolabTimer = function () {
}
}
else {
- com.synckolab.tools.logMessage("sync with config "+com.synckolab.main.forceConfig +" is still running...", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("sync with config "+synckolab.main.forceConfig +" is still running...", synckolab.global.LOG_DEBUG);
}
*/
// refresh all mail folders configured to trigger auto-sync
- if(com.synckolab.main.syncConfigs) {
- for(var j = 0; j < com.synckolab.main.syncConfigs.length; j++) {
- if(com.synckolab.main.syncConfigs[j]) {
- var curConfig = com.synckolab.main.syncConfigs[j];
- com.synckolab.tools.logMessage("sync timer: checking config " + curConfig.name, com.synckolab.global.LOG_DEBUG);
+ if(synckolab.main.syncConfigs) {
+ for(var j = 0; j < synckolab.main.syncConfigs.length; j++) {
+ if(synckolab.main.syncConfigs[j]) {
+ var curConfig = synckolab.main.syncConfigs[j];
+ synckolab.tools.logMessage("sync timer: checking config " + curConfig.name, synckolab.global.LOG_DEBUG);
if(curConfig.syncListener && curConfig.folder)
{
- com.synckolab.tools.logMessage("refreshing " + curConfig.folderMsgURI + "...", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("refreshing " + curConfig.folderMsgURI + "...", synckolab.global.LOG_DEBUG);
try {
curConfig.folder.updateFolder(null);
} catch (ex) {
- com.synckolab.tools.logMessage("unable to refresh " + curConfig.folderMsgURI + ": " + ex, com.synckolab.global.LOG_WARNING);
+ synckolab.tools.logMessage("unable to refresh " + curConfig.folderMsgURI + ": " + ex, synckolab.global.LOG_WARNING);
}
}
}
@@ -126,17 +125,17 @@ com.synckolab.main.syncKolabTimer = function () {
}
// wait a minute
- com.synckolab.tools.logMessage("sync timer: sleep for 30s minute", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("sync timer: sleep for 30s minute", synckolab.global.LOG_INFO);
- com.synckolab.main.backgroundTimer.initWithCallback({
+ synckolab.main.backgroundTimer.initWithCallback({
notify:
function () {
- com.synckolab.main.syncKolabTimer();
+ synckolab.main.syncKolabTimer();
}
}, 30000, 0);
};
-com.synckolab.main.initGroupwareActions = function() {
+synckolab.main.initGroupwareActions = function() {
// detect and disable event listener for seamonkey
try {
if((Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULAppInfo)).name === "SeaMonkey")
@@ -146,32 +145,32 @@ com.synckolab.main.initGroupwareActions = function() {
} catch (ex) { /* ignore */ }
// make sure configuration is already available
- com.synckolab.config.readConfiguration();
+ synckolab.config.readConfiguration();
- com.synckolab.main.timer.initWithCallback({
+ synckolab.main.timer.initWithCallback({
notify:
function (){
- window.document.getElementById('folderTree').addEventListener("click", com.synckolab.main.groupwareActions, true);
+ window.document.getElementById('folderTree').addEventListener("click", synckolab.main.groupwareActions, true);
}
- }, com.synckolab.config.SWITCH_TIME, 0);
+ }, synckolab.config.SWITCH_TIME, 0);
};
/**
* Executed when the user clicks on a folder.
* This checks the config if we want to hide that folder and open the address book or calendar view instead.
*/
-com.synckolab.main.groupwareActions = function () {
+synckolab.main.groupwareActions = function () {
// make sure we have an up to date and valid configuration
- com.synckolab.config.readConfiguration();
+ synckolab.config.readConfiguration();
// only do that if we really have to
- if(!com.synckolab.main.config.hideFolder)
+ if(!synckolab.main.config.hideFolder)
{
return;
}
- com.synckolab.tools.logMessage("Starting groupware Actions function", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Starting groupware Actions function", synckolab.global.LOG_DEBUG);
// Grab the selected folder and figure out what the INBOX is so we can switch to that later
var selected_foldername = gFolderDisplay.displayedFolder.URI; // gFolderDisplay is defined in messenger
@@ -183,11 +182,11 @@ com.synckolab.main.groupwareActions = function () {
var i;
- com.synckolab.tools.logMessage("In groupware Actions function folder name is " + selected_foldername, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In groupware Actions function folder name is " + selected_foldername, synckolab.global.LOG_DEBUG);
- for (i=0; i < com.synckolab.main.syncConfigs.length; i++)
+ for (i=0; i < synckolab.main.syncConfigs.length; i++)
{
- var curConfig = com.synckolab.main.syncConfigs[i];
+ var curConfig = synckolab.main.syncConfigs[i];
if(!curConfig)
{
continue;
@@ -197,14 +196,14 @@ com.synckolab.main.groupwareActions = function () {
switch(curConfig.type) {
case "calendar":
- com.synckolab.tools.logMessage("In groupware Actions selected Calendar folder", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In groupware Actions selected Calendar folder", synckolab.global.LOG_DEBUG);
if (versionChecker.compare(Application.version, "3.0b4") >= 0) {
document.getElementById('tabmail').openTab('calendar', { title: document.getElementById('calendar-tab-button').getAttribute('tooltiptext') });
SelectFolder(inbox);
}
break;
case "task":
- com.synckolab.tools.logMessage("In groupware Actions selected Task folder", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In groupware Actions selected Task folder", synckolab.global.LOG_DEBUG);
if (versionChecker.compare(Application.version, "3.0b4") >= 0) {
document.getElementById('tabmail').openTab('tasks', { title: document.getElementById('task-tab-button').getAttribute('tooltiptext') });
@@ -212,7 +211,7 @@ com.synckolab.main.groupwareActions = function () {
}
break;
case "contact":
- com.synckolab.tools.logMessage("In groupware Actions selected Contacts folder", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("In groupware Actions selected Contacts folder", synckolab.global.LOG_DEBUG);
if (versionChecker.compare(Application.version, "3.0b4") >= 0) {
document.getElementById('tabmail').openTab('contentTab', {contentPage: 'chrome://messenger/content/addressbook/addressbook.xul'});
SelectFolder(inbox);
@@ -225,79 +224,79 @@ com.synckolab.main.groupwareActions = function () {
};
//progress variables
-com.synckolab.main.curStep = 0;
+synckolab.main.curStep = 0;
//hold window elements
-com.synckolab.main.processMsg = null; //process message
-com.synckolab.main.curCounter = null; // counter
-com.synckolab.main.meter = null; // the progress meter
-com.synckolab.main.totalMeter = null; // the total progress meter
-com.synckolab.main.statusMsg = null; // the status message
-com.synckolab.main.itemList = null; // display all processed items
+synckolab.main.processMsg = null; //process message
+synckolab.main.curCounter = null; // counter
+synckolab.main.meter = null; // the progress meter
+synckolab.main.totalMeter = null; // the total progress meter
+synckolab.main.statusMsg = null; // the status message
+synckolab.main.itemList = null; // display all processed items
-com.synckolab.main.fileContent = null; // holds the file content
+synckolab.main.fileContent = null; // holds the file content
// sync message db
-com.synckolab.main.syncMessageDb = null;
-com.synckolab.main.gSyncFileKey = null;
-com.synckolab.main.gSyncKeyInfo = null;
-com.synckolab.main.gLastMessageDBHdr = null; // save last message header
+synckolab.main.syncMessageDb = null;
+synckolab.main.gSyncFileKey = null;
+synckolab.main.gSyncKeyInfo = null;
+synckolab.main.gLastMessageDBHdr = null; // save last message header
/**
* Start a sync.
* @param event containing the type of sync (i.e. "timer")
* @param syncconfig an optional configuration to sync directly (i.e. for "trigger")
*/
-com.synckolab.main.sync = function (event, syncconfig)
+synckolab.main.sync = function (event, syncconfig)
{
- com.synckolab.global.consoleService.logStringMessage("running SyncKolab "+com.synckolab.config.version+" with debug level " + com.synckolab.config.DEBUG_SYNCKOLAB_LEVEL + " in " + event + " mode (hideWindow: " + com.synckolab.main.doHideWindow +")");
+ synckolab.global.consoleService.logStringMessage("running SyncKolab "+synckolab.config.version+" with debug level " + synckolab.config.DEBUG_SYNCKOLAB_LEVEL + " in " + event + " mode (hideWindow: " + synckolab.main.doHideWindow +")");
// avoid race condition with manual switch (only timer has a this.forceConfig)
- if (com.synckolab.global.running === true)
+ if (synckolab.global.running === true)
{
- com.synckolab.tools.logMessage("Ignoring run - there is already an instance!", com.synckolab.global.LOG_WARNING);
+ synckolab.tools.logMessage("Ignoring run - there is already an instance!", synckolab.global.LOG_WARNING);
return;
}
- com.synckolab.global.running = true;
+ synckolab.global.running = true;
// in case this wasnt called via timer - its a manual sync
if (event !== "timer" && event !== "trigger")
{
- com.synckolab.main.forceConfig = "MANUAL-SYNC";
- com.synckolab.main.forceConfigType = null;
+ synckolab.main.forceConfig = "MANUAL-SYNC";
+ synckolab.main.forceConfigType = null;
}
- com.synckolab.global.strBundle = document.getElementById("synckolabBundle");
+ synckolab.global.strBundle = document.getElementById("synckolabBundle");
- if (com.synckolab.main.doHideWindow) {
- com.synckolab.global.wnd = null;
+ if (synckolab.main.doHideWindow) {
+ synckolab.global.wnd = null;
} else {
- com.synckolab.global.wnd = window.openDialog("chrome://synckolab/content/progressWindow.xul", "bmarks", "chrome,width=500,height=350,resizable=yes,alwaysRaised=yes,dependent=yes,modal=no");
+ synckolab.global.wnd = window.openDialog("chrome://synckolab/content/progressWindow.xul", "bmarks", "chrome,width=500,height=350,resizable=yes,alwaysRaised=yes,dependent=yes,modal=no");
}
// reset variables
- com.synckolab.main.totalMessages = 0;
- com.synckolab.main.curMessage = null;
- com.synckolab.main.currentMessage = null;
- com.synckolab.main.updateMessages = null;
- com.synckolab.main.updateMessagesContent = null;
- com.synckolab.main.writeDone = false;
+ synckolab.main.totalMessages = 0;
+ synckolab.main.curMessage = null;
+ synckolab.main.currentMessage = null;
+ synckolab.main.updateMessages = null;
+ synckolab.main.updateMessagesContent = null;
+ synckolab.main.writeDone = false;
- com.synckolab.main.gMessages = null;
- com.synckolab.main.gSync = null;
+ synckolab.main.gMessages = null;
+ synckolab.main.gSync = null;
- com.synckolab.main.gLaterMessages = null; // for lists - we have to wait until we got everything - then start
+ synckolab.main.gLaterMessages = null; // for lists - we have to wait until we got everything - then start
// wait until loaded
- com.synckolab.main.timer.initWithCallback({
+ synckolab.main.timer.initWithCallback({
notify:
function (){
- com.synckolab.main.goWindow(com.synckolab.global.wnd);
+ synckolab.main.goWindow(synckolab.global.wnd);
}
- }, com.synckolab.config.SWITCH_TIME, 0);
+ }, synckolab.config.SWITCH_TIME, 0);
};
-com.synckolab.main.goWindow = function(wnd)
+synckolab.main.goWindow = function(wnd)
{
// wait until the window is loaded (might need a little)
if (wnd)
@@ -305,7 +304,7 @@ com.synckolab.main.goWindow = function(wnd)
var statusMsg1 = wnd.document.getElementById('current-action');
if (statusMsg1 === null || !statusMsg1)
{
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.goWindow(wnd);}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.goWindow(wnd);}}, synckolab.config.SWITCH_TIME, 0);
return;
}
}
@@ -313,12 +312,12 @@ com.synckolab.main.goWindow = function(wnd)
if (wnd)
{
// some window elements for displaying the status
- com.synckolab.main.meter = wnd.document.getElementById('progress');
- com.synckolab.main.totalMeter = wnd.document.getElementById('totalProgress');
- com.synckolab.main.statusMsg = wnd.document.getElementById('current-action');
- com.synckolab.main.processMsg = wnd.document.getElementById('current-process');
- com.synckolab.main.curCounter = wnd.document.getElementById('current-counter');
- com.synckolab.main.itemList = wnd.document.getElementById('itemList');
+ synckolab.main.meter = wnd.document.getElementById('progress');
+ synckolab.main.totalMeter = wnd.document.getElementById('totalProgress');
+ synckolab.main.statusMsg = wnd.document.getElementById('current-action');
+ synckolab.main.processMsg = wnd.document.getElementById('current-process');
+ synckolab.main.curCounter = wnd.document.getElementById('current-counter');
+ synckolab.main.itemList = wnd.document.getElementById('itemList');
}
else
{
@@ -328,200 +327,200 @@ com.synckolab.main.goWindow = function(wnd)
wnd.gStopSync = false;
wnd.gPauseSync = false;
}
- com.synckolab.main.statusMsg = document.getElementById('current-action-sk');
- if (com.synckolab.main.statusMsg === null) {
- com.synckolab.main.statusMsg = document.createElement("statusbarpanel");
- com.synckolab.main.statusMsg.setAttribute("id", "current-action-sk");
- sb.appendChild(com.synckolab.main.statusMsg);
+ synckolab.main.statusMsg = document.getElementById('current-action-sk');
+ if (synckolab.main.statusMsg === null) {
+ synckolab.main.statusMsg = document.createElement("statusbarpanel");
+ synckolab.main.statusMsg.setAttribute("id", "current-action-sk");
+ sb.appendChild(synckolab.main.statusMsg);
}
- com.synckolab.main.meter = document.getElementById('progress');
- if (com.synckolab.main.meter === null) {
- com.synckolab.main.meter = document.createElement("progressmeter");
- sb.appendChild(com.synckolab.main.meter);
- com.synckolab.main.meter.setAttribute("id", "progress-sk");
+ synckolab.main.meter = document.getElementById('progress');
+ if (synckolab.main.meter === null) {
+ synckolab.main.meter = document.createElement("progressmeter");
+ sb.appendChild(synckolab.main.meter);
+ synckolab.main.meter.setAttribute("id", "progress-sk");
}
- com.synckolab.main.meter.setAttribute("mode", "determined");
- com.synckolab.main.meter.setAttribute("value", "0");
- com.synckolab.main.meter.setAttribute("style", "width:100px");
+ synckolab.main.meter.setAttribute("mode", "determined");
+ synckolab.main.meter.setAttribute("value", "0");
+ synckolab.main.meter.setAttribute("style", "width:100px");
- com.synckolab.main.curCounter = document.getElementById('current-counter-sk');
- if (com.synckolab.main.curCounter === null) {
- com.synckolab.main.curCounter = document.createElement("statusbarpanel");
- com.synckolab.main.curCounter.setAttribute("id", "current-counter-sk");
- sb.appendChild(com.synckolab.main.curCounter);
+ synckolab.main.curCounter = document.getElementById('current-counter-sk');
+ if (synckolab.main.curCounter === null) {
+ synckolab.main.curCounter = document.createElement("statusbarpanel");
+ synckolab.main.curCounter.setAttribute("id", "current-counter-sk");
+ sb.appendChild(synckolab.main.curCounter);
}
- com.synckolab.main.curCounter.setAttribute("label", "-/-");
+ synckolab.main.curCounter.setAttribute("label", "-/-");
- com.synckolab.main.processMsg = null;
- com.synckolab.main.totalMeter = null;
- com.synckolab.main.itemList = null;
+ synckolab.main.processMsg = null;
+ synckolab.main.totalMeter = null;
+ synckolab.main.itemList = null;
}
- if (com.synckolab.calendarTools.isCalendarAvailable())
+ if (synckolab.calendarTools.isCalendarAvailable())
{
- com.synckolab.tools.logMessage("Calendar available", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Calendar available", synckolab.global.LOG_INFO);
}
else {
- com.synckolab.tools.logMessage("Calendar not available - disabling", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Calendar not available - disabling", synckolab.global.LOG_INFO);
}
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.startSync();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.startSync();}}, synckolab.config.SWITCH_TIME, 0);
};
-com.synckolab.main.startSync = function(event) {
- com.synckolab.main.meter.setAttribute("value", "0%");
- if (com.synckolab.global.wnd) {
- com.synckolab.main.totalMeter.setAttribute("value", "0%");
+synckolab.main.startSync = function(event) {
+ synckolab.main.meter.setAttribute("value", "0%");
+ if (synckolab.global.wnd) {
+ synckolab.main.totalMeter.setAttribute("value", "0%");
}
// get temp file
var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
file.append("syncKolab.tmp");
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 600);
- com.synckolab.main.gTmpFile = file.path;
+ synckolab.main.gTmpFile = file.path;
// check if the configuration is available and up to date
- com.synckolab.config.readConfiguration();
+ synckolab.config.readConfiguration();
- if(com.synckolab.main.syncConfigs) {
- com.synckolab.tools.logMessage("Starting sync with " + com.synckolab.main.syncConfigs.length + " configurations.", com.synckolab.global.LOG_DEBUG);
+ if(synckolab.main.syncConfigs) {
+ synckolab.tools.logMessage("Starting sync with " + synckolab.main.syncConfigs.length + " configurations.", synckolab.global.LOG_DEBUG);
}
// reset the config counter
- com.synckolab.main.curConfig = 0;
+ synckolab.main.curConfig = 0;
// all initialized, lets run
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.nextSync();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.nextSync();}}, synckolab.config.SWITCH_TIME, 0);
};
/**
* Start a new sync loop. This will iterate through all configurations and sync accordingly.
* Calls prepareContent or itself.
*/
-com.synckolab.main.nextSync = function()
+synckolab.main.nextSync = function()
{
// remember the current configuation
var curConfig = null;
- if (com.synckolab.global.wnd) {
- com.synckolab.main.totalMeter.setAttribute("value", ((com.synckolab.main.curConfig*100)/(com.synckolab.main.syncConfigs.length)) +"%");
+ if (synckolab.global.wnd) {
+ synckolab.main.totalMeter.setAttribute("value", ((synckolab.main.curConfig*100)/(synckolab.main.syncConfigs.length)) +"%");
}
- if (com.synckolab.main.curConfig < com.synckolab.main.syncConfigs.length)
+ if (synckolab.main.curConfig < synckolab.main.syncConfigs.length)
{
// empty or invalid config
- if(!com.synckolab.main.syncConfigs[com.synckolab.main.curConfig]) {
- com.synckolab.main.curConfig++;
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.nextSync();}}, com.synckolab.config.SWITCH_TIME, 0);
+ if(!synckolab.main.syncConfigs[synckolab.main.curConfig]) {
+ synckolab.main.curConfig++;
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.nextSync();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
// contact config
- curConfig = com.synckolab.main.syncConfigs[com.synckolab.main.curConfig];
+ curConfig = synckolab.main.syncConfigs[synckolab.main.curConfig];
// skip problematic configs or if we don't want to sync this
if (!curConfig || !curConfig.enabled)
{
- com.synckolab.main.curConfig++;
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.nextSync();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.curConfig++;
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.nextSync();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
// if we were called from timer - forceConfig defines one config which is loaded - skip the rest then
- if (com.synckolab.main.forceConfig && com.synckolab.main.forceConfig !== "MANUAL-SYNC") {
+ if (synckolab.main.forceConfig && synckolab.main.forceConfig !== "MANUAL-SYNC") {
// check if we skip that: name and type must match
- if (com.synckolab.main.forceConfig !== curConfig.name ||
- (com.synckolab.main.forceConfigType && com.synckolab.main.forceConfigType !== "contact"))
+ if (synckolab.main.forceConfig !== curConfig.name ||
+ (synckolab.main.forceConfigType && synckolab.main.forceConfigType !== "contact"))
{
- com.synckolab.main.curConfig++;
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.nextSync();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.curConfig++;
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.nextSync();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
}
- com.synckolab.main.gConfig = curConfig;
- com.synckolab.tools.logMessage("Trying configuration " + curConfig.name, com.synckolab.global.LOG_DEBUG);
+ synckolab.main.gConfig = curConfig;
+ synckolab.tools.logMessage("Trying configuration " + curConfig.name, synckolab.global.LOG_DEBUG);
- if (com.synckolab.main.processMsg) {
- com.synckolab.main.processMsg.value ="Configuration " + curConfig.name;
+ if (synckolab.main.processMsg) {
+ synckolab.main.processMsg.value ="Configuration " + curConfig.name;
}
// run the init callback
- com.synckolab.main.curConfig++;
+ synckolab.main.curConfig++;
// remember the sync class
- com.synckolab.main.gSync = curConfig.syncClass;
+ synckolab.main.gSync = curConfig.syncClass;
// display stuff
- if (com.synckolab.global.wnd)
+ if (synckolab.global.wnd)
{
- curConfig.syncClass.init(curConfig, com.synckolab.main.itemList, com.synckolab.global.wnd.document);
+ curConfig.syncClass.init(curConfig, synckolab.main.itemList, synckolab.global.wnd.document);
}
else
{
curConfig.syncClass.init(curConfig, null, document);
}
- com.synckolab.tools.logMessage("got folder: " + curConfig.folder.URI +
- "\nMessage Folder: " + curConfig.folderMsgURI, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("got folder: " + curConfig.folder.URI +
+ "\nMessage Folder: " + curConfig.folderMsgURI, synckolab.global.LOG_DEBUG);
// the init2 does the goon for us
if(curConfig.syncClass.init2) {
- com.synckolab.tools.logMessage("runnint init2 on " + curConfig.name, com.synckolab.global.LOG_DEBUG);
- curConfig.syncClass.init2(com.synckolab.main.prepareContent, curConfig.syncClass);
+ synckolab.tools.logMessage("runnint init2 on " + curConfig.name, synckolab.global.LOG_DEBUG);
+ curConfig.syncClass.init2(synckolab.main.prepareContent, curConfig.syncClass);
}
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.prepareContent();}}, com.synckolab.config.SWITCH_TIME, 0);
- //com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.prepareContent(com.synckolab.Calendar);}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.prepareContent();}}, synckolab.config.SWITCH_TIME, 0);
+ //synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.prepareContent(synckolab.Calendar);}}, synckolab.config.SWITCH_TIME, 0);
}
else //done
{
- com.synckolab.tools.logMessage("Done syncing resetting ui." , com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Done syncing resetting ui." , synckolab.global.LOG_DEBUG);
- if(com.synckolab.global.wnd && !com.synckolab.global.wnd.document) {
- com.synckolab.global.wnd = null;
+ if(synckolab.global.wnd && !synckolab.global.wnd.document) {
+ synckolab.global.wnd = null;
}
- if (com.synckolab.global.wnd) {
- com.synckolab.main.totalMeter.setAttribute("value", "100%");
+ if (synckolab.global.wnd) {
+ synckolab.main.totalMeter.setAttribute("value", "100%");
}
- com.synckolab.main.meter.setAttribute("value", "100%");
- if (com.synckolab.global.wnd) {
- com.synckolab.main.statusMsg.value = com.synckolab.global.strBundle.getString("syncfinished");
+ synckolab.main.meter.setAttribute("value", "100%");
+ if (synckolab.global.wnd) {
+ synckolab.main.statusMsg.value = synckolab.global.strBundle.getString("syncfinished");
} else {
- com.synckolab.main.statusMsg.setAttribute("label", com.synckolab.global.strBundle.getString("syncfinished"));
+ synckolab.main.statusMsg.setAttribute("label", synckolab.global.strBundle.getString("syncfinished"));
}
- if (com.synckolab.global.wnd) {
- com.synckolab.global.wnd.document.getElementById('cancel-button').label = com.synckolab.global.strBundle.getString("close");
+ if (synckolab.global.wnd) {
+ synckolab.global.wnd.document.getElementById('cancel-button').label = synckolab.global.strBundle.getString("close");
}
// delete the temp file
var sfile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
- sfile.initWithPath(com.synckolab.main.gTmpFile);
+ sfile.initWithPath(synckolab.main.gTmpFile);
if (sfile.exists()) {
sfile.remove(true);
}
// close the status window
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
- if (com.synckolab.tools.getConfigValue(pref, "closeWindow", com.synckolab.tools.CONFIG_TYPE_BOOL, false) && com.synckolab.global.wnd) {
- com.synckolab.global.wnd.close();
+ if (synckolab.tools.getConfigValue(pref, "closeWindow", synckolab.tools.CONFIG_TYPE_BOOL, false) && synckolab.global.wnd) {
+ synckolab.global.wnd.close();
}
// remove all status bar elements
try {
- if (com.synckolab.global.wnd === null)
+ if (synckolab.global.wnd === null)
{
var sb = document.getElementById("status-bar");
if(sb) {
- sb.removeChild(com.synckolab.main.meter);
- sb.removeChild(com.synckolab.main.statusMsg);
- sb.removeChild(com.synckolab.main.curCounter);
+ sb.removeChild(synckolab.main.meter);
+ sb.removeChild(synckolab.main.statusMsg);
+ sb.removeChild(synckolab.main.curCounter);
}
}
} catch (sbEx) {
@@ -529,74 +528,74 @@ com.synckolab.main.nextSync = function()
}
// done autorun
- if (com.synckolab.main.forceConfig)
+ if (synckolab.main.forceConfig)
{
- com.synckolab.tools.logMessage("finished autorun of config " + com.synckolab.main.forceConfig, com.synckolab.global.LOG_INFO);
- com.synckolab.main.forceConfig = null;
- com.synckolab.main.doHideWindow = false;
+ synckolab.tools.logMessage("finished autorun of config " + synckolab.main.forceConfig, synckolab.global.LOG_INFO);
+ synckolab.main.forceConfig = null;
+ synckolab.main.doHideWindow = false;
}
// set running state to done
- com.synckolab.global.running = false;
+ synckolab.global.running = false;
return;
}
// Step 3
- if (com.synckolab.global.wnd)
+ if (synckolab.global.wnd)
{
- com.synckolab.main.statusMsg.value = com.synckolab.global.strBundle.getString("getContent");
+ synckolab.main.statusMsg.value = synckolab.global.strBundle.getString("getContent");
}
else
{
- com.synckolab.main.statusMsg.setAttribute("label", com.synckolab.global.strBundle.getString("getContent"));
+ synckolab.main.statusMsg.setAttribute("label", synckolab.global.strBundle.getString("getContent"));
}
- com.synckolab.main.meter.setAttribute("value", "5%");
+ synckolab.main.meter.setAttribute("value", "5%");
};
/**
* this function is being called just before the content parsing starts
* its sole purpose is to make sure all messages/contacts are downloaded and refreshed
*/
-com.synckolab.main.prepareContent = function() {
+synckolab.main.prepareContent = function() {
// wait for the data (special case for calendar - they need a time to init)
- if (com.synckolab.main.gSync.dataReady() === false)
+ if (synckolab.main.gSync.dataReady() === false)
{
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.prepareContent();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.prepareContent();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
// update folder information from imap and make sure we got everything
- com.synckolab.main.gConfig.folder.updateFolder(msgWindow);
+ synckolab.main.gConfig.folder.updateFolder(msgWindow);
// my UrlListener calls getContent
- com.synckolab.main.gConfig.folder.compact({
+ synckolab.main.gConfig.folder.compact({
OnStartRunningUrl: function ( url )
{
},
OnStopRunningUrl: function ( url, exitCode )
{
- com.synckolab.tools.logMessage("Finished folder frefresh; ONSTOP="+exitCode+" : " + url, com.synckolab.global.LOG_DEBUG );
- com.synckolab.main.getContent();
+ synckolab.tools.logMessage("Finished folder frefresh; ONSTOP="+exitCode+" : " + url, synckolab.global.LOG_DEBUG );
+ synckolab.main.getContent();
}
}, msgWindow); // this should take care of refreshes
};
-com.synckolab.main.syncKolabCompact = function() {
+synckolab.main.syncKolabCompact = function() {
// update folder and compact - this prevents event triggereing
- com.synckolab.main.gConfig.folder.updateFolder(msgWindow);
+ synckolab.main.gConfig.folder.updateFolder(msgWindow);
// compact folder
try {
- com.synckolab.main.gConfig.folder.compact(null, null);
+ synckolab.main.gConfig.folder.compact(null, null);
} catch(e) {
- com.synckolab.tools.logMessage("ERROR: Running compact: " + e, com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("ERROR: Running compact: " + e, synckolab.global.LOG_ERROR);
}
- com.synckolab.main.gSync.doneParsing();
- com.synckolab.tools.logMessage("nextSync", com.synckolab.global.LOG_INFO);
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.nextSync();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.gSync.doneParsing();
+ synckolab.tools.logMessage("nextSync", synckolab.global.LOG_INFO);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.nextSync();}}, synckolab.config.SWITCH_TIME, 0);
};
@@ -604,92 +603,92 @@ com.synckolab.main.syncKolabCompact = function() {
* start with the sync with the sync class
* saves the contact folder into fileContent
*/
-com.synckolab.main.getContent = function()
+synckolab.main.getContent = function()
{
// check if folder REALLY exists
- com.synckolab.main.gConfig.folder.clearNewMessages();
+ synckolab.main.gConfig.folder.clearNewMessages();
// get the number of messages to go through
- com.synckolab.main.totalMessages = com.synckolab.main.gConfig.folder.getTotalMessages(false);
- com.synckolab.tools.logMessage("Have to sync " + com.synckolab.main.totalMessages + " messages for the folder.", com.synckolab.global.LOG_INFO);
+ synckolab.main.totalMessages = synckolab.main.gConfig.folder.getTotalMessages(false);
+ synckolab.tools.logMessage("Have to sync " + synckolab.main.totalMessages + " messages for the folder.", synckolab.global.LOG_INFO);
// fix bug #16848 and ask before deleting everything :P
- if (com.synckolab.main.totalMessages === 0 && com.synckolab.main.gSync.itemCount() > 0)
+ if (synckolab.main.totalMessages === 0 && synckolab.main.gSync.itemCount() > 0)
{
- if (window.confirm(com.synckolab.global.strBundle.getString("syncCopyToServer"))) {
- com.synckolab.main.gSync.forceServerCopy = true;
+ if (window.confirm(synckolab.global.strBundle.getString("syncCopyToServer"))) {
+ synckolab.main.gSync.forceServerCopy = true;
}
}
- else if (com.synckolab.main.totalMessages > 0 && com.synckolab.main.gSync.itemCount() === 0)
+ else if (synckolab.main.totalMessages > 0 && synckolab.main.gSync.itemCount() === 0)
{
- if (window.confirm(com.synckolab.global.strBundle.getString("syncCopyToClient"))) {
- com.synckolab.main.gSync.forceLocalCopy = true;
+ if (window.confirm(synckolab.global.strBundle.getString("syncCopyToClient"))) {
+ synckolab.main.gSync.forceLocalCopy = true;
}
}
// prepare empty later list
- com.synckolab.main.gLaterMessages = {
+ synckolab.main.gLaterMessages = {
msgs: [],
pointer: 0
};
// get the message keys
- if (com.synckolab.main.gConfig.folder.getMessages) {
- com.synckolab.main.gMessages = com.synckolab.main.gConfig.folder.getMessages(null); // dont need the msgWindow use null
+ if (synckolab.main.gConfig.folder.getMessages) {
+ synckolab.main.gMessages = synckolab.main.gConfig.folder.getMessages(null); // dont need the msgWindow use null
} else {
- com.synckolab.main.gMessages = com.synckolab.main.gConfig.folder.messages; // tbird 3 uses an enumerator property instead of a function
+ synckolab.main.gMessages = synckolab.main.gConfig.folder.messages; // tbird 3 uses an enumerator property instead of a function
}
// get the message database (a file with uid:size:date:localfile)
- com.synckolab.main.syncMessageDb = new com.synckolab.dataBase(com.synckolab.main.gConfig.dbFile);
+ synckolab.main.syncMessageDb = new synckolab.dataBase(synckolab.main.gConfig.dbFile);
- com.synckolab.main.curMessage = 0;
- com.synckolab.main.updateMessages = []; // saves the the message url to delete
- com.synckolab.main.updateMessagesContent = []; // saves the card to use to update
+ synckolab.main.curMessage = 0;
+ synckolab.main.updateMessages = []; // saves the the message url to delete
+ synckolab.main.updateMessagesContent = []; // saves the card to use to update
- if (com.synckolab.global.wnd) {
- com.synckolab.main.statusMsg.value = com.synckolab.global.strBundle.getString("syncEntries");
+ if (synckolab.global.wnd) {
+ synckolab.main.statusMsg.value = synckolab.global.strBundle.getString("syncEntries");
} else {
- com.synckolab.main.statusMsg.setAttribute("label", com.synckolab.global.strBundle.getString("syncEntries"));
+ synckolab.main.statusMsg.setAttribute("label", synckolab.global.strBundle.getString("syncEntries"));
}
- com.synckolab.main.meter.setAttribute("value", "5%");
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.getMessage();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.meter.setAttribute("value", "5%");
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.getMessage();}}, synckolab.config.SWITCH_TIME, 0);
};
/**
* Get the current message into a string and then go to parseMessageRunner
*/
-com.synckolab.main.getMessage = function()
+synckolab.main.getMessage = function()
{
// pause sync...
- if (com.synckolab.global.wnd && com.synckolab.global.wnd.gPauseSync)
+ if (synckolab.global.wnd && synckolab.global.wnd.gPauseSync)
{
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.getMessage();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.getMessage();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
- if (com.synckolab.global.wnd && (com.synckolab.global.wnd.document === null || com.synckolab.global.wnd.gStopSync === true))
+ if (synckolab.global.wnd && (synckolab.global.wnd.document === null || synckolab.global.wnd.gStopSync === true))
{
alert("Stopped SyncKolab...");
- com.synckolab.global.running = false;
+ synckolab.global.running = false;
return;
}
var cur = null;
// still in first run...
- if(com.synckolab.main.gLaterMessages.pointer === 0) {
+ if(synckolab.main.gLaterMessages.pointer === 0) {
try
{
- if (com.synckolab.main.gMessages.hasMoreElements()) {
- cur = com.synckolab.main.gMessages.getNext().QueryInterface(Components.interfaces.nsIMsgDBHdr);
+ if (synckolab.main.gMessages.hasMoreElements()) {
+ cur = synckolab.main.gMessages.getNext().QueryInterface(Components.interfaces.nsIMsgDBHdr);
}
}
catch (ex)
{
- com.synckolab.tools.logMessage("skipping read of messages - since there are none :)", com.synckolab.global.LOG_INFO);
- com.synckolab.main.updateContentAfterSave();
+ synckolab.tools.logMessage("skipping read of messages - since there are none :)", synckolab.global.LOG_INFO);
+ synckolab.main.updateContentAfterSave();
return;
}
}
@@ -700,49 +699,49 @@ com.synckolab.main.getMessage = function()
if (!cur)
{
// done with the second run
- if (com.synckolab.main.gLaterMessages.pointer >= com.synckolab.main.gLaterMessages.msgs.length)
+ if (synckolab.main.gLaterMessages.pointer >= synckolab.main.gLaterMessages.msgs.length)
{
- com.synckolab.main.gLaterMessages.msgs = [];
+ synckolab.main.gLaterMessages.msgs = [];
// done with messages go on...
- com.synckolab.main.parseFolderToAddressFinish();
+ synckolab.main.parseFolderToAddressFinish();
return;
}
//process later message
- com.synckolab.tools.logMessage("second round process message: message " + com.synckolab.main.gLaterMessages.pointer + " of " + com.synckolab.main.gLaterMessages.msgs.length, com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("second round process message: message " + synckolab.main.gLaterMessages.pointer + " of " + synckolab.main.gLaterMessages.msgs.length, synckolab.global.LOG_INFO);
- laterMsg = com.synckolab.main.gLaterMessages.msgs[com.synckolab.main.gLaterMessages.pointer++];
+ laterMsg = synckolab.main.gLaterMessages.msgs[synckolab.main.gLaterMessages.pointer++];
cur = laterMsg.hdr;
}
else
{
// check message flags (based on mailnews\base\public\nsMsgMessageFlags.h -> deleted=0x200000
- com.synckolab.tools.logMessage("Message " + cur.mime2DecodedSubject + " (dateInSeconds: " + cur.dateInSeconds + ") has flags: " + cur.flags + " flag imap_deleted? " + (cur.flags&0x200000), com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Message " + cur.mime2DecodedSubject + " (dateInSeconds: " + cur.dateInSeconds + ") has flags: " + cur.flags + " flag imap_deleted? " + (cur.flags&0x200000), synckolab.global.LOG_DEBUG);
var skipCMessage = false;
if (cur.flags&0x200000)
{
- com.synckolab.tools.logMessage("Message " + cur.mime2DecodedSubject + " has been DELETED on imap!", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Message " + cur.mime2DecodedSubject + " has been DELETED on imap!", synckolab.global.LOG_INFO);
// skip current and process next nessage
skipCMessage = true;
}
if(!cur.mime2DecodedSubject || cur.mime2DecodedSubject.length < 3) {
- com.synckolab.tools.logMessage("Message '" + cur.mime2DecodedSubject + "' has an invalid subject!", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Message '" + cur.mime2DecodedSubject + "' has an invalid subject!", synckolab.global.LOG_INFO);
// skip current and process next nessage
skipCMessage = true;
}
// check if we can ignore this message because its too old (0=take all into accout)
- if(com.synckolab.main.gConfig.type !== "contact" && com.synckolab.main.gConfig.timeFrame && com.synckolab.main.gConfig.timeFrame > 0 && skipCMessage !== true)
+ if(synckolab.main.gConfig.type !== "contact" && synckolab.main.gConfig.timeFrame && synckolab.main.gConfig.timeFrame > 0 && skipCMessage !== true)
{
- com.synckolab.tools.logMessage("Checking if message might be too old for now " + (new Date()).getTime(), com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Checking if message might be too old for now " + (new Date()).getTime(), synckolab.global.LOG_DEBUG);
// now get the correct startdate (convert in milliseconds)
- if ((cur.dateInSeconds + (com.synckolab.main.gConfig.timeFrame * 86400))*1000 < (new Date()).getTime())
+ if ((cur.dateInSeconds + (synckolab.main.gConfig.timeFrame * 86400))*1000 < (new Date()).getTime())
{
- com.synckolab.tools.logMessage("Message " + cur.mime2DecodedSubject + " will be ignored (too old) Now: " + (new Date()).getTime(), com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Message " + cur.mime2DecodedSubject + " will be ignored (too old) Now: " + (new Date()).getTime(), synckolab.global.LOG_INFO);
// skip current and process next nessage
skipCMessage = true;
}
@@ -750,23 +749,23 @@ com.synckolab.main.getMessage = function()
if (skipCMessage === true)
{
- com.synckolab.main.curMessage++;
- if (com.synckolab.main.curMessage <= com.synckolab.main.totalMessages)
+ synckolab.main.curMessage++;
+ if (synckolab.main.curMessage <= synckolab.main.totalMessages)
{
- var curpointer = 5 + (55*(com.synckolab.main.curMessage/com.synckolab.main.totalMessages));
- com.synckolab.main.meter.setAttribute("value", curpointer + "%");
- if (com.synckolab.global.wnd) {
- com.synckolab.main.curCounter.setAttribute("value", com.synckolab.main.curMessage + "/" + com.synckolab.main.totalMessages);
+ var curpointer = 5 + (55*(synckolab.main.curMessage/synckolab.main.totalMessages));
+ synckolab.main.meter.setAttribute("value", curpointer + "%");
+ if (synckolab.global.wnd) {
+ synckolab.main.curCounter.setAttribute("value", synckolab.main.curMessage + "/" + synckolab.main.totalMessages);
} else {
- com.synckolab.main.curCounter.setAttribute("label", com.synckolab.main.curMessage + "/" + com.synckolab.main.totalMessages);
+ synckolab.main.curCounter.setAttribute("label", synckolab.main.curMessage + "/" + synckolab.main.totalMessages);
}
// next message
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.getMessage();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.getMessage();}}, synckolab.config.SWITCH_TIME, 0);
}
else
{
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.parseFolderToAddressFinish();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.parseFolderToAddressFinish();}}, synckolab.config.SWITCH_TIME, 0);
}
return;
}
@@ -785,101 +784,101 @@ com.synckolab.main.getMessage = function()
cur.messageSize
cur.date (PRTime) ?
*/
- com.synckolab.main.gLastMessageDBHdr = cur;
- com.synckolab.tools.logMessage("checking for synckey in local db: " + com.synckolab.tools.getUidFromHeader(cur.mime2DecodedSubject), com.synckolab.global.LOG_DEBUG);
- com.synckolab.main.gSyncKeyInfo = com.synckolab.tools.getUidFromHeader(cur.mime2DecodedSubject);
- com.synckolab.main.gSyncFileKey = com.synckolab.main.syncMessageDb.get(com.synckolab.main.gSyncKeyInfo);
+ synckolab.main.gLastMessageDBHdr = cur;
+ synckolab.tools.logMessage("checking for synckey in local db: " + synckolab.tools.getUidFromHeader(cur.mime2DecodedSubject), synckolab.global.LOG_DEBUG);
+ synckolab.main.gSyncKeyInfo = synckolab.tools.getUidFromHeader(cur.mime2DecodedSubject);
+ synckolab.main.gSyncFileKey = synckolab.main.syncMessageDb.get(synckolab.main.gSyncKeyInfo);
if (laterMsg) {
- com.synckolab.tools.logMessage("taking " + com.synckolab.main.gSyncKeyInfo + " from fist round...", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("taking " + synckolab.main.gSyncKeyInfo + " from fist round...", synckolab.global.LOG_DEBUG);
// get the message content into fileContent
// parseMessageRunner is called when we got the message
- com.synckolab.main.currentMessage = {
- message: com.synckolab.main.gConfig.folderMsgURI +"#"+cur.messageKey,
+ synckolab.main.currentMessage = {
+ message: synckolab.main.gConfig.folderMsgURI +"#"+cur.messageKey,
fileContent: laterMsg.content,
- nextFunc: com.synckolab.main.parseMessageRunner
+ nextFunc: synckolab.main.parseMessageRunner
};
- com.synckolab.main.gSyncFileKey = laterMsg.fileKey;
- com.synckolab.main.parseMessageRunner();
+ synckolab.main.gSyncFileKey = laterMsg.fileKey;
+ synckolab.main.parseMessageRunner();
return;
}
else {
- if (com.synckolab.main.gSyncFileKey)
+ if (synckolab.main.gSyncFileKey)
{
- com.synckolab.tools.logMessage("we have " + com.synckolab.main.gSyncKeyInfo + " already locally...", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("we have " + synckolab.main.gSyncKeyInfo + " already locally...", synckolab.global.LOG_DEBUG);
// check if the message has changed
- if (cur.messageSize === Number(com.synckolab.main.gSyncFileKey[1]) && cur.date === Number(com.synckolab.main.gSyncFileKey[2]))
+ if (cur.messageSize === Number(synckolab.main.gSyncFileKey[1]) && cur.date === Number(synckolab.main.gSyncFileKey[2]))
{
// get the content from the cached file and ignore the imap
- com.synckolab.tools.logMessage("taking content from: " + com.synckolab.main.gSyncFileKey[3] + "/" + com.synckolab.main.gSyncFileKey[4], com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("taking content from: " + synckolab.main.gSyncFileKey[3] + "/" + synckolab.main.gSyncFileKey[4], synckolab.global.LOG_DEBUG);
- var cachedFile = com.synckolab.tools.readSyncDBFile(com.synckolab.tools.file.getSyncDbFile(com.synckolab.main.gConfig, com.synckolab.main.gSyncFileKey[4]));
+ var cachedFile = synckolab.tools.readSyncDBFile(synckolab.tools.file.getSyncDbFile(synckolab.main.gConfig, synckolab.main.gSyncFileKey[4]));
// make sure we dont read an empty file
if (cachedFile && cachedFile !== "" && cachedFile.synckolab)
{
- com.synckolab.tools.logMessage("read cached file", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("read cached file", synckolab.global.LOG_DEBUG);
// parse the json
- com.synckolab.main.currentMessage = {
+ synckolab.main.currentMessage = {
fileContent: cachedFile
};
- com.synckolab.main.parseMessageRunner();
+ synckolab.main.parseMessageRunner();
return;
} else {
- com.synckolab.tools.logMessage("unable to read read cached file", com.synckolab.global.LOG_DEBUG);
- com.synckolab.main.syncMessageDb.remove(com.synckolab.main.gSyncFileKey);
+ synckolab.tools.logMessage("unable to read read cached file", synckolab.global.LOG_DEBUG);
+ synckolab.main.syncMessageDb.remove(synckolab.main.gSyncFileKey);
// new netry
// remember the info
- com.synckolab.main.gSyncFileKey = {}; // we not yet know the id
- com.synckolab.main.gSyncFileKey[0] = '';
- com.synckolab.main.gSyncFileKey[1] = cur.messageSize;
- com.synckolab.main.gSyncFileKey[2] = cur.date;
+ synckolab.main.gSyncFileKey = {}; // we not yet know the id
+ synckolab.main.gSyncFileKey[0] = '';
+ synckolab.main.gSyncFileKey[1] = cur.messageSize;
+ synckolab.main.gSyncFileKey[2] = cur.date;
}
}
else
{
// some change happened... remove this entry (+ some update :P )
- com.synckolab.tools.logMessage("Cached message does not match - skipping cache read", com.synckolab.global.LOG_DEBUG);
- com.synckolab.main.syncMessageDb.remove(com.synckolab.main.gSyncFileKey);
+ synckolab.tools.logMessage("Cached message does not match - skipping cache read", synckolab.global.LOG_DEBUG);
+ synckolab.main.syncMessageDb.remove(synckolab.main.gSyncFileKey);
// new netry
// remember the info
- com.synckolab.main.gSyncFileKey = {}; // we not yet know the id
- com.synckolab.main.gSyncFileKey[0] = '';
- com.synckolab.main.gSyncFileKey[1] = cur.messageSize;
- com.synckolab.main.gSyncFileKey[2] = cur.date;
+ synckolab.main.gSyncFileKey = {}; // we not yet know the id
+ synckolab.main.gSyncFileKey[0] = '';
+ synckolab.main.gSyncFileKey[1] = cur.messageSize;
+ synckolab.main.gSyncFileKey[2] = cur.date;
}
}
else
{
// remember the info
- com.synckolab.main.gSyncFileKey = {}; // we not yet know the id
- com.synckolab.main.gSyncFileKey[0] = '';
- com.synckolab.main.gSyncFileKey[1] = cur.messageSize;
- com.synckolab.main.gSyncFileKey[2] = cur.date;
+ synckolab.main.gSyncFileKey = {}; // we not yet know the id
+ synckolab.main.gSyncFileKey[0] = '';
+ synckolab.main.gSyncFileKey[1] = cur.messageSize;
+ synckolab.main.gSyncFileKey[2] = cur.date;
}
}
// get the message content into fileContent
// parseMessageRunner is called when we got the message
- com.synckolab.main.currentMessage = {
- message: com.synckolab.main.gConfig.folderMsgURI +"#"+cur.messageKey,
+ synckolab.main.currentMessage = {
+ message: synckolab.main.gConfig.folderMsgURI +"#"+cur.messageKey,
fileContent: "",
- nextFunc: com.synckolab.main.parseMessageRunner
+ nextFunc: synckolab.main.parseMessageRunner
};
- com.synckolab.main.getMessageIntoContent(com.synckolab.main.currentMessage);
+ synckolab.main.getMessageIntoContent(synckolab.main.currentMessage);
};
/**
*
* @param content the content structure contianing the message key and the buffer for the content
*/
-com.synckolab.main.getMessageIntoContent = function(content) {
+synckolab.main.getMessageIntoContent = function(content) {
var aurl = {};
- com.synckolab.global.messageService.CopyMessage(
+ synckolab.global.messageService.CopyMessage(
content.message,
/* nsIStreamListener */
{
@@ -898,15 +897,15 @@ com.synckolab.main.getMessageIntoContent = function(content) {
onStartRequest: function (request, context) {
},
onStopRequest: function (aRequest, aContext, aStatusCode) {
- com.synckolab.tools.logMessage("got Message [" + content.message + "]:\n" + content.fileContent, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("got Message [" + content.message + "]:\n" + content.fileContent, synckolab.global.LOG_DEBUG);
// remove the header of the content
- content.fileContent = com.synckolab.tools.stripMailHeader(content.fileContent);
+ content.fileContent = synckolab.tools.stripMailHeader(content.fileContent);
// make sure we dont come into an endless loop here
- com.synckolab.global.triggerRunning = true;
+ synckolab.global.triggerRunning = true;
content.nextFunc(content);
- com.synckolab.global.triggerRunning = false;
+ synckolab.global.triggerRunning = false;
}
}, false, null, msgWindow, aurl
);
@@ -919,7 +918,7 @@ com.synckolab.main.getMessageIntoContent = function(content) {
* fileName string - the file to copy(+path)
* folderUri string - the Uri/Url of the folder we want this in
*/
-com.synckolab.main.copyToFolder = function(fileName, folderUri, listener)
+synckolab.main.copyToFolder = function(fileName, folderUri, listener)
{
var mailFolder = folderUri;
var fileSpec;
@@ -955,145 +954,145 @@ com.synckolab.main.copyToFolder = function(fileName, folderUri, listener)
/**
* we now got the message content. this needs to parsed and checked
*/
-com.synckolab.main.parseMessageRunner = function()
+synckolab.main.parseMessageRunner = function()
{
// pause sync...
- if (com.synckolab.global.wnd && com.synckolab.global.wnd.gPauseSync)
+ if (synckolab.global.wnd && synckolab.global.wnd.gPauseSync)
{
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.parseMessageRunner();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.parseMessageRunner();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
- if (com.synckolab.global.wnd && (com.synckolab.global.wnd.document === null || com.synckolab.global.wnd.gStopSync === true))
+ if (synckolab.global.wnd && (synckolab.global.wnd.document === null || synckolab.global.wnd.gStopSync === true))
{
alert("Stopped SyncKolab...");
- com.synckolab.global.running = false;
+ synckolab.global.running = false;
return;
}
var skcontent = null;
// unparsable message... content is null and so it will skip
- if(com.synckolab.main.currentMessage && com.synckolab.main.currentMessage.fileContent) {
- com.synckolab.tools.logMessage("parsing message... ", com.synckolab.global.LOG_DEBUG);
+ if(synckolab.main.currentMessage && synckolab.main.currentMessage.fileContent) {
+ synckolab.tools.logMessage("parsing message... ", synckolab.global.LOG_DEBUG);
// fix the message for line truncs (last char in line is =)
// content might be a preparsed json
- if(!com.synckolab.main.currentMessage.fileContent.synckolab) {
- com.synckolab.main.currentMessage.fileContent = com.synckolab.main.currentMessage.fileContent.replace(/\=\n(\S)/g, "$1");
+ if(!synckolab.main.currentMessage.fileContent.synckolab) {
+ synckolab.main.currentMessage.fileContent = synckolab.main.currentMessage.fileContent.replace(/\=\n(\S)/g, "$1");
}
- skcontent = com.synckolab.main.gSync.parseMessage(com.synckolab.main.currentMessage.fileContent, com.synckolab.main.updateMessagesContent, (com.synckolab.main.gLaterMessages.pointer === 0));
+ skcontent = synckolab.main.gSync.parseMessage(synckolab.main.currentMessage.fileContent, synckolab.main.updateMessagesContent, (synckolab.main.gLaterMessages.pointer === 0));
}
if (skcontent === "LATER") {
- com.synckolab.tools.logMessage("keeping message for later (possible a mailing list): #" + com.synckolab.main.gLaterMessages.msgs.length, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("keeping message for later (possible a mailing list): #" + synckolab.main.gLaterMessages.msgs.length, synckolab.global.LOG_DEBUG);
var cMsg = {};
- cMsg.content = com.synckolab.main.currentMessage.fileContent;
- cMsg.hdr = com.synckolab.main.gLastMessageDBHdr;
- cMsg.fileKey = com.synckolab.main.gSyncFileKey;
- com.synckolab.main.gLaterMessages.msgs.push(cMsg);
+ cMsg.content = synckolab.main.currentMessage.fileContent;
+ cMsg.hdr = synckolab.main.gLastMessageDBHdr;
+ cMsg.fileKey = synckolab.main.gSyncFileKey;
+ synckolab.main.gLaterMessages.msgs.push(cMsg);
}
else {
// just to make sure there REALLY isnt any content left :)
- com.synckolab.main.currentMessage.fileContent = null;
+ synckolab.main.currentMessage.fileContent = null;
if (skcontent)
{
if (skcontent === "DELETEME") {
- com.synckolab.tools.logMessage("deleting [" + com.synckolab.main.currentMessage.message + "]", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("deleting [" + synckolab.main.currentMessage.message + "]", synckolab.global.LOG_INFO);
} else {
- com.synckolab.tools.logMessage("updating [" + com.synckolab.main.currentMessage.message + "]", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("updating [" + synckolab.main.currentMessage.message + "]", synckolab.global.LOG_INFO);
}
- // adding message to list of to-delete messages - com.synckolab.main.gConfig.folderMsgURI +"#"+
- com.synckolab.main.updateMessages.push(com.synckolab.main.gLastMessageDBHdr);
- com.synckolab.main.updateMessagesContent.push(skcontent);
- com.synckolab.tools.logMessage("changed msg #" + com.synckolab.main.updateMessages.length, com.synckolab.global.LOG_INFO);
+ // adding message to list of to-delete messages - synckolab.main.gConfig.folderMsgURI +"#"+
+ synckolab.main.updateMessages.push(synckolab.main.gLastMessageDBHdr);
+ synckolab.main.updateMessagesContent.push(skcontent);
+ synckolab.tools.logMessage("changed msg #" + synckolab.main.updateMessages.length, synckolab.global.LOG_INFO);
}
// no change... remember that :)
else
{
// fill info about the file and re-add it
- com.synckolab.main.gSyncFileKey[0] = com.synckolab.main.gSyncKeyInfo;
- com.synckolab.main.gSyncFileKey[3] = com.synckolab.main.gSync.gConfig.name;
- com.synckolab.main.gSyncFileKey[4] = com.synckolab.main.gSyncKeyInfo; //gSync.gCurUID;
+ synckolab.main.gSyncFileKey[0] = synckolab.main.gSyncKeyInfo;
+ synckolab.main.gSyncFileKey[3] = synckolab.main.gSync.gConfig.name;
+ synckolab.main.gSyncFileKey[4] = synckolab.main.gSyncKeyInfo; //gSync.gCurUID;
// Add the key
- com.synckolab.main.syncMessageDb.add(com.synckolab.main.gSyncFileKey);
+ synckolab.main.syncMessageDb.add(synckolab.main.gSyncFileKey);
}
}
// process next nessage
- com.synckolab.main.curMessage++;
- if (com.synckolab.main.curMessage <= com.synckolab.main.totalMessages || com.synckolab.main.gLaterMessages.pointer < com.synckolab.main.gLaterMessages.msgs.length)
+ synckolab.main.curMessage++;
+ if (synckolab.main.curMessage <= synckolab.main.totalMessages || synckolab.main.gLaterMessages.pointer < synckolab.main.gLaterMessages.msgs.length)
{
- var curpointer = 5 + (55*((com.synckolab.main.curMessage + com.synckolab.main.gLaterMessages.pointer)/(com.synckolab.main.totalMessages + com.synckolab.main.gLaterMessages.msgs.length)));
- com.synckolab.main.meter.setAttribute("value", curpointer + "%");
+ var curpointer = 5 + (55*((synckolab.main.curMessage + synckolab.main.gLaterMessages.pointer)/(synckolab.main.totalMessages + synckolab.main.gLaterMessages.msgs.length)));
+ synckolab.main.meter.setAttribute("value", curpointer + "%");
- com.synckolab.main.curCounter.setAttribute((com.synckolab.global.wnd)?"value":"label", (com.synckolab.main.curMessage + com.synckolab.main.gLaterMessages.pointer) + "/" + (com.synckolab.main.totalMessages + com.synckolab.main.gLaterMessages.msgs.length));
+ synckolab.main.curCounter.setAttribute((synckolab.global.wnd)?"value":"label", (synckolab.main.curMessage + synckolab.main.gLaterMessages.pointer) + "/" + (synckolab.main.totalMessages + synckolab.main.gLaterMessages.msgs.length));
- if (com.synckolab.main.curMessage%20 === 0)
+ if (synckolab.main.curMessage%20 === 0)
{
// save the sync db file every 20 messages.. should speed up sync if canceled
- com.synckolab.tools.logMessage("Writing message snyc-db", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Writing message snyc-db", synckolab.global.LOG_DEBUG);
// write the db file back
- com.synckolab.main.syncMessageDb.write();
+ synckolab.main.syncMessageDb.write();
}
// next message
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.getMessage();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.getMessage();}}, synckolab.config.SWITCH_TIME, 0);
}
else
{
- com.synckolab.tools.logMessage("Done parsing " + (com.synckolab.main.totalMessages+com.synckolab.main.gLaterMessages.msgs.length), com.synckolab.global.LOG_DEBUG);
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.parseFolderToAddressFinish();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.tools.logMessage("Done parsing " + (synckolab.main.totalMessages+synckolab.main.gLaterMessages.msgs.length), synckolab.global.LOG_DEBUG);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.parseFolderToAddressFinish();}}, synckolab.config.SWITCH_TIME, 0);
}
};
//Step 6 10%
//write everything thats not yet in the message folder but is in the local db
-com.synckolab.main.writeContent = function()
+synckolab.main.writeContent = function()
{
// pause sync...
- if (com.synckolab.global.wnd && com.synckolab.global.wnd.gPauseSync)
+ if (synckolab.global.wnd && synckolab.global.wnd.gPauseSync)
{
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.writeContent();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.writeContent();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
- if (com.synckolab.global.wnd && (com.synckolab.global.wnd.document === null || com.synckolab.global.wnd.gStopSync === true))
+ if (synckolab.global.wnd && (synckolab.global.wnd.document === null || synckolab.global.wnd.gStopSync === true))
{
alert("Stopped SyncKolab...");
- com.synckolab.global.running = false;
+ synckolab.global.running = false;
return;
}
// if there happens an exception, we are done
- var skcontent = com.synckolab.main.gSync.nextUpdate();
+ var skcontent = synckolab.main.gSync.nextUpdate();
if (skcontent === "done")
{
- com.synckolab.tools.logMessage("content is 'done'", com.synckolab.global.LOG_INFO);
- com.synckolab.main.writeContentAfterSave();
+ synckolab.tools.logMessage("content is 'done'", synckolab.global.LOG_INFO);
+ synckolab.main.writeContentAfterSave();
return;
}
if (skcontent === null)
{
- com.synckolab.tools.logMessage("content is null - continue", com.synckolab.global.LOG_WARNING);
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.writeContent();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.tools.logMessage("content is null - continue", synckolab.global.LOG_WARNING);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.writeContent();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
- if (com.synckolab.main.gConfig.saveToImap)
+ if (synckolab.main.gConfig.saveToImap)
{
// write the temp file back to the original directory
- com.synckolab.tools.logMessage("WriteContent Writing...", com.synckolab.global.LOG_INFO);
- com.synckolab.main.writeImapMessage(skcontent, com.synckolab.main.gConfig, com.synckolab.main.kolabCopyServiceListener);
+ synckolab.tools.logMessage("WriteContent Writing...", synckolab.global.LOG_INFO);
+ synckolab.main.writeImapMessage(skcontent, synckolab.main.gConfig, synckolab.main.kolabCopyServiceListener);
}
else {
- com.synckolab.tools.logMessage("Skipping write to imap because of read only config...", com.synckolab.global.LOG_INFO);
- com.synckolab.main.writeContentAfterSave();
+ synckolab.tools.logMessage("Skipping write to imap because of read only config...", synckolab.global.LOG_INFO);
+ synckolab.main.writeContentAfterSave();
}
};
-com.synckolab.main.kolabCopyServiceListener = {
+synckolab.main.kolabCopyServiceListener = {
OnProgress: function (progress, progressMax) {
},
OnStartCopy: function () {
@@ -1101,11 +1100,11 @@ com.synckolab.main.kolabCopyServiceListener = {
SetMessageKey: function (key) {
},
OnStopCopy: function (status) {
- if (com.synckolab.main.curStep === 5) {
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.updateContentWrite();}}, com.synckolab.config.SWITCH_TIME, 0);
+ if (synckolab.main.curStep === 5) {
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.updateContentWrite();}}, synckolab.config.SWITCH_TIME, 0);
}
- if (com.synckolab.main.curStep === 6) {
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.writeContent();}}, com.synckolab.config.SWITCH_TIME, 0);
+ if (synckolab.main.curStep === 6) {
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.writeContent();}}, synckolab.config.SWITCH_TIME, 0);
}
}
};
@@ -1116,17 +1115,17 @@ com.synckolab.main.kolabCopyServiceListener = {
* @param config the config to use (for the correct folder)
* @param listener this is a callback that is used when the copy has been finished/failed
*/
-com.synckolab.main.writeImapMessage = function(skcontent, config, listener) {
+synckolab.main.writeImapMessage = function(skcontent, config, listener) {
// get temp file (might not yet be initialized)
var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
file.append("syncKolab.tmp");
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 600);
- com.synckolab.main.gTmpFile = file.path;
+ synckolab.main.gTmpFile = file.path;
// write the message in the temp file
var sfile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
// temp path
- sfile.initWithPath(com.synckolab.main.gTmpFile);
+ sfile.initWithPath(synckolab.main.gTmpFile);
if (sfile.exists()) {
sfile.remove(true);
}
@@ -1141,190 +1140,190 @@ com.synckolab.main.writeImapMessage = function(skcontent, config, listener) {
stream.write(skcontent, skcontent.length);
stream.close();
- com.synckolab.tools.logMessage("Copy Message to Folder", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Copy Message to Folder", synckolab.global.LOG_DEBUG);
- com.synckolab.main.copyToFolder(com.synckolab.main.gTmpFile, config.folder, listener);
+ synckolab.main.copyToFolder(synckolab.main.gTmpFile, config.folder, listener);
};
//done this time
-com.synckolab.main.writeContentAfterSave = function()
+synckolab.main.writeContentAfterSave = function()
{
// pause sync...
- if (com.synckolab.global.wnd && com.synckolab.global.wnd.gPauseSync)
+ if (synckolab.global.wnd && synckolab.global.wnd.gPauseSync)
{
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.writeContentAfterSave();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.writeContentAfterSave();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
- if (com.synckolab.global.wnd && (com.synckolab.global.wnd.document === null || com.synckolab.global.wnd.gStopSync === true))
+ if (synckolab.global.wnd && (synckolab.global.wnd.document === null || synckolab.global.wnd.gStopSync === true))
{
alert("Stopped SyncKolab...");
- com.synckolab.global.running = false;
+ synckolab.global.running = false;
return;
}
- com.synckolab.tools.logMessage("Setting all messages to read...", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Setting all messages to read...", synckolab.global.LOG_INFO);
// before done, set all unread messages to read in the sync folder
- com.synckolab.main.gMessages = com.synckolab.main.gConfig.folder.messages; // tbird 3 uses an enumerator property instead of a function
+ synckolab.main.gMessages = synckolab.main.gConfig.folder.messages; // tbird 3 uses an enumerator property instead of a function
- while (com.synckolab.main.gMessages.hasMoreElements())
+ while (synckolab.main.gMessages.hasMoreElements())
{
- var cur = com.synckolab.main.gMessages.getNext().QueryInterface(Components.interfaces.nsIMsgDBHdr);
+ var cur = synckolab.main.gMessages.getNext().QueryInterface(Components.interfaces.nsIMsgDBHdr);
if (!cur.isRead)
{
cur.markRead(true);
}
}
- com.synckolab.main.gMessages = null;
+ synckolab.main.gMessages = null;
- com.synckolab.tools.logMessage("Running compact", com.synckolab.global.LOG_INFO);
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.syncKolabCompact();}}, 2000, 0); // wait for a second or two
+ synckolab.tools.logMessage("Running compact", synckolab.global.LOG_INFO);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.syncKolabCompact();}}, 2000, 0); // wait for a second or two
};
-com.synckolab.main.parseFolderToAddressFinish = function()
+synckolab.main.parseFolderToAddressFinish = function()
{
// do step 5
- com.synckolab.main.curStep = 5;
- com.synckolab.main.writeDone = false;
- com.synckolab.tools.logMessage("parseFolderToAddressFinish (Writing message db)", com.synckolab.global.LOG_DEBUG);
+ synckolab.main.curStep = 5;
+ synckolab.main.writeDone = false;
+ synckolab.tools.logMessage("parseFolderToAddressFinish (Writing message db)", synckolab.global.LOG_DEBUG);
// write the db file back
- com.synckolab.main.syncMessageDb.write();
+ synckolab.main.syncMessageDb.write();
- com.synckolab.main.meter.setAttribute("value", "60%");
- if (com.synckolab.global.wnd)
+ synckolab.main.meter.setAttribute("value", "60%");
+ if (synckolab.global.wnd)
{
- com.synckolab.main.statusMsg.value = com.synckolab.global.strBundle.getString("writeChangedEntries");
- com.synckolab.main.curCounter.setAttribute("value", "0/0");
+ synckolab.main.statusMsg.value = synckolab.global.strBundle.getString("writeChangedEntries");
+ synckolab.main.curCounter.setAttribute("value", "0/0");
}
else
{
- com.synckolab.main.statusMsg.setAttribute("label", com.synckolab.global.strBundle.getString("writeChangedEntries"));
- com.synckolab.main.curCounter.setAttribute("label", "0/0");
+ synckolab.main.statusMsg.setAttribute("label", synckolab.global.strBundle.getString("writeChangedEntries"));
+ synckolab.main.curCounter.setAttribute("label", "0/0");
}
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.updateContent();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.updateContent();}}, synckolab.config.SWITCH_TIME, 0);
};
/* Remove all messages which needs to be updated or deleted.
* The replacement messages are created in updateContentWrite().
*/
-com.synckolab.main.updateContent = function()
+synckolab.main.updateContent = function()
{
// pause sync...
- if (com.synckolab.global.wnd && com.synckolab.global.wnd.gPauseSync)
+ if (synckolab.global.wnd && synckolab.global.wnd.gPauseSync)
{
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.updateContent();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.updateContent();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
- if (com.synckolab.global.wnd && (com.synckolab.global.wnd.document === null || com.synckolab.global.wnd.gStopSync === true))
+ if (synckolab.global.wnd && (synckolab.global.wnd.document === null || synckolab.global.wnd.gStopSync === true))
{
alert("Stopped SyncKolab...");
- com.synckolab.global.running = false;
+ synckolab.global.running = false;
return;
}
- com.synckolab.tools.logMessage("updating content:", com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("updating content:", synckolab.global.LOG_DEBUG);
var i;
// first lets delete the old messages
- if (com.synckolab.main.gConfig.saveToImap && com.synckolab.main.updateMessages.length > 0)
+ if (synckolab.main.gConfig.saveToImap && synckolab.main.updateMessages.length > 0)
{
try
{
- com.synckolab.tools.logMessage("deleting changed messages..", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("deleting changed messages..", synckolab.global.LOG_INFO);
var list = null;
// use mutablearray
list = Components.classes["@mozilla.org/array;1"].createInstance(Components.interfaces.nsIMutableArray);
- for (i = 0; i < com.synckolab.main.updateMessages.length; i++)
+ for (i = 0; i < synckolab.main.updateMessages.length; i++)
{
- com.synckolab.tools.logMessage("deleting [" + com.synckolab.main.updateMessages[i] + "]");
- //var hdr = com.synckolab.global.messageService.messageURIToMsgHdr(com.synckolab.main.updateMessages[i]);
- list.appendElement(com.synckolab.main.updateMessages[i], false);
+ synckolab.tools.logMessage("deleting [" + synckolab.main.updateMessages[i] + "]");
+ //var hdr = synckolab.global.messageService.messageURIToMsgHdr(synckolab.main.updateMessages[i]);
+ list.appendElement(synckolab.main.updateMessages[i], false);
}
- com.synckolab.main.gConfig.folder.deleteMessages(list, msgWindow, true, false, null, true);
+ synckolab.main.gConfig.folder.deleteMessages(list, msgWindow, true, false, null, true);
}
catch (ex)
{
- com.synckolab.tools.logMessage("Exception while deleting - skipping: " + ex, com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("Exception while deleting - skipping: " + ex, synckolab.global.LOG_ERROR);
}
}
- com.synckolab.main.curMessage = -1;
+ synckolab.main.curMessage = -1;
// now write the new ones
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.updateContentWrite();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.updateContentWrite();}}, synckolab.config.SWITCH_TIME, 0);
};
/* Write all changed messages back to the folder. Skip
* the messages which were to be deleted from the server.
*/
-com.synckolab.main.updateContentWrite = function()
+synckolab.main.updateContentWrite = function()
{
// pause sync...
- if (com.synckolab.global.wnd && com.synckolab.global.wnd.gPauseSync)
+ if (synckolab.global.wnd && synckolab.global.wnd.gPauseSync)
{
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.updateContentWrite();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.updateContentWrite();}}, synckolab.config.SWITCH_TIME, 0);
return;
}
- if (com.synckolab.global.wnd && (com.synckolab.global.wnd.document === null || com.synckolab.global.wnd.gStopSync === true))
+ if (synckolab.global.wnd && (synckolab.global.wnd.document === null || synckolab.global.wnd.gStopSync === true))
{
alert("Stopped SyncKolab...");
- com.synckolab.global.running = false;
+ synckolab.global.running = false;
return;
}
- com.synckolab.main.curCounter.setAttribute("value", com.synckolab.main.curMessage + "/" + com.synckolab.main.updateMessagesContent.length);
+ synckolab.main.curCounter.setAttribute("value", synckolab.main.curMessage + "/" + synckolab.main.updateMessagesContent.length);
- com.synckolab.main.curMessage++;
- if (com.synckolab.main.curMessage < com.synckolab.main.updateMessagesContent.length)
+ synckolab.main.curMessage++;
+ if (synckolab.main.curMessage < synckolab.main.updateMessagesContent.length)
{
- var skcontent = com.synckolab.main.updateMessagesContent[com.synckolab.main.curMessage];
+ var skcontent = synckolab.main.updateMessagesContent[synckolab.main.curMessage];
// write the message
- if (com.synckolab.main.gConfig.saveToImap && skcontent !== "DELETEME" && skcontent!== null && skcontent.length > 1)
+ if (synckolab.main.gConfig.saveToImap && skcontent !== "DELETEME" && skcontent!== null && skcontent.length > 1)
{
- com.synckolab.tools.logMessage("adding [" + skcontent + "] to messages", com.synckolab.global.LOG_DEBUG);
- com.synckolab.main.writeImapMessage(skcontent, com.synckolab.main.gConfig, com.synckolab.main.kolabCopyServiceListener);
+ synckolab.tools.logMessage("adding [" + skcontent + "] to messages", synckolab.global.LOG_DEBUG);
+ synckolab.main.writeImapMessage(skcontent, synckolab.main.gConfig, synckolab.main.kolabCopyServiceListener);
}
else {
- com.synckolab.main.updateContentWrite();
+ synckolab.main.updateContentWrite();
}
}
else {
- com.synckolab.main.updateContentAfterSave();
+ synckolab.main.updateContentAfterSave();
}
};
-com.synckolab.main.updateContentAfterSave =function ()
+synckolab.main.updateContentAfterSave =function ()
{
- com.synckolab.tools.logMessage("starting update content...", com.synckolab.global.LOG_INFO);
- com.synckolab.main.curStep = 6;
- com.synckolab.main.writeDone = false;
+ synckolab.tools.logMessage("starting update content...", synckolab.global.LOG_INFO);
+ synckolab.main.curStep = 6;
+ synckolab.main.writeDone = false;
- if (!com.synckolab.main.gSync.initUpdate())
+ if (!synckolab.main.gSync.initUpdate())
{
- com.synckolab.tools.logMessage("Nothing there to update...", com.synckolab.global.LOG_INFO);
- com.synckolab.main.writeContentAfterSave();
+ synckolab.tools.logMessage("Nothing there to update...", synckolab.global.LOG_INFO);
+ synckolab.main.writeContentAfterSave();
}
- com.synckolab.main.meter.setAttribute("value", "80%");
- if (com.synckolab.global.wnd)
+ synckolab.main.meter.setAttribute("value", "80%");
+ if (synckolab.global.wnd)
{
- com.synckolab.main.statusMsg.value = com.synckolab.global.strBundle.getString("writeNewEntries");
- com.synckolab.main.curCounter.setAttribute("value", "...");
+ synckolab.main.statusMsg.value = synckolab.global.strBundle.getString("writeNewEntries");
+ synckolab.main.curCounter.setAttribute("value", "...");
}
else
{
- com.synckolab.main.statusMsg.setAttribute("label", com.synckolab.global.strBundle.getString("writeNewEntries"));
- com.synckolab.main.curCounter.setAttribute("label", "...");
+ synckolab.main.statusMsg.setAttribute("label", synckolab.global.strBundle.getString("writeNewEntries"));
+ synckolab.main.curCounter.setAttribute("label", "...");
}
- com.synckolab.main.timer.initWithCallback({notify:function (){com.synckolab.main.writeContent();}}, com.synckolab.config.SWITCH_TIME, 0);
+ synckolab.main.timer.initWithCallback({notify:function (){synckolab.main.writeContent();}}, synckolab.config.SWITCH_TIME, 0);
};
diff --git a/src/chrome/content/synckolab/tools.js b/src/chrome/content/synckolab/tools.js
index 676972f..bbcfbb3 100644
--- a/src/chrome/content/synckolab/tools.js
+++ b/src/chrome/content/synckolab/tools.js
@@ -32,9 +32,7 @@
//////////////////////////////////HELP FUNCTIONS /////////////////////////////////////////
"use strict";
-if(!com) var com={};
-if(!com.synckolab) com.synckolab={};
-if(!com.synckolab.tools) com.synckolab.tools={};
+if(!synckolab) var synckolab={};
try {
Components.utils.import("resource://calendar/modules/calUtils.jsm");
@@ -43,7 +41,7 @@ try {
// ignore exception if lightning is not installed
}
-com.synckolab.tools = {
+synckolab.tools = {
logStart: -1,
lastmsg: -1,
@@ -54,11 +52,11 @@ com.synckolab.tools = {
*/
logMessage: function (msg, level) {
if (!level) {
- level = com.synckolab.global.LOG_INFO;
+ level = synckolab.global.LOG_INFO;
}
- var infolvl = com.synckolab.config.DEBUG_SYNCKOLAB_LEVEL%4;
- var infostate = com.synckolab.config.DEBUG_SYNCKOLAB_LEVEL - infolvl;
+ var infolvl = synckolab.config.DEBUG_SYNCKOLAB_LEVEL%4;
+ var infostate = synckolab.config.DEBUG_SYNCKOLAB_LEVEL - infolvl;
var clvl = level%4;
var cstate = level - clvl;
@@ -69,14 +67,14 @@ logMessage: function (msg, level) {
// now lets see if we want the same type of error NORMAL|CALENDAR|ADRESSBOOK|ALL
- // if the two states are diffeent and infostate !== com.synckolab.global.LOG_ALL we want outta here
- if (infostate !== cstate && infostate !== com.synckolab.global.LOG_ALL) {
+ // if the two states are diffeent and infostate !== synckolab.global.LOG_ALL we want outta here
+ if (infostate !== cstate && infostate !== synckolab.global.LOG_ALL) {
return;
}
- if (com.synckolab.config.DEBUG_SYNCKOLAB || clvl === com.synckolab.global.LOG_ERROR)
+ if (synckolab.config.DEBUG_SYNCKOLAB || clvl === synckolab.global.LOG_ERROR)
{
- if (com.synckolab.config.PERFLOG_SYNCKOLAB === true)
+ if (synckolab.config.PERFLOG_SYNCKOLAB === true)
{
if (this.logStart === -1)
{
@@ -91,30 +89,30 @@ logMessage: function (msg, level) {
}
}
// report errors as error
- if (clvl === com.synckolab.global.LOG_ERROR && Components.utils.reportError) {
+ if (clvl === synckolab.global.LOG_ERROR && Components.utils.reportError) {
var err = new Error("" + msg);
Components.utils.reportError("" + msg + err.stack);
} else
- if (clvl === com.synckolab.global.LOG_ERROR) {
- com.synckolab.global.consoleService.logStringMessage("" + msg + new Error("" + msg).stack);
+ if (clvl === synckolab.global.LOG_ERROR) {
+ synckolab.global.consoleService.logStringMessage("" + msg + new Error("" + msg).stack);
} else {
- com.synckolab.global.consoleService.logStringMessage(msg);
+ synckolab.global.consoleService.logStringMessage(msg);
}
}
// pause the sync on error if defined by globals
- if (com.synckolab.config.PAUSE_ON_ERROR && clvl === com.synckolab.global.LOG_ERROR) {
+ if (synckolab.config.PAUSE_ON_ERROR && clvl === synckolab.global.LOG_ERROR) {
// TODO this will NOT work...
- if (typeof com.synckolab !== "undefined" && com.synckolab.global.wnd && com.synckolab.global.wnd.pauseSync) {
- com.synckolab.global.wnd.pauseSync();
+ if (typeof synckolab !== "undefined" && synckolab.global.wnd && synckolab.global.wnd.pauseSync) {
+ synckolab.global.wnd.pauseSync();
}
}
},
scrollToBottom : function (itemList)
{
- if (!itemList && com.synckolab.global.wnd && com.synckolab.global.document) {
- itemList = com.synckolab.global.wnd.document.getElementById('itemList');
+ if (!itemList && synckolab.global.wnd && synckolab.global.document) {
+ itemList = synckolab.global.wnd.document.getElementById('itemList');
}
if (itemList)
{
@@ -124,6 +122,10 @@ scrollToBottom : function (itemList)
}
},
+parseXml: function(content) {
+ var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"].getService(Components.interfaces.nsIDOMParser);
+ return parser.parseFromString(content, "text/xml");
+},
/**
* Return a boolean value telling whether
@@ -176,24 +178,24 @@ equalsObject: function(a, b)
var p;
for(p in a) {
- if(p !== "synckolab" && typeof(b[p]) === 'undefined' && a[p] !== null && a[p] !== "") {
+ if(p !== "ts" && p !== "sha1" && p !== "synckolab" && typeof(b[p]) === 'undefined' && a[p] !== null && a[p] !== "") {
// 0 == undefined
if((a[p] === "0" || a[p] === 0) && !b[p])
{
continue;
}
- com.synckolab.tools.logMessage("not equals: " + p + " a: " + a[p] + " b: " + b[p], com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("not equals: " + p + " a: " + a[p] + " b: " + b[p], synckolab.global.LOG_DEBUG);
return false;
}
}
for(p in a) {
- if (p !== "synckolab") {
+ if (p !== "ts" && p !== "sha1" && p !== "synckolab") {
if (a[p]) {
switch(typeof(a[p])) {
case 'object':
if (!this.equalsObject(a[p], b[p])) {
- com.synckolab.tools.logMessage("not equals: " + p + " a: " + a[p] + " b: " + b[p], com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("not equals: " + p + " a: " + a[p] + " b: " + b[p], synckolab.global.LOG_DEBUG);
return false;
}
break;
@@ -201,13 +203,13 @@ equalsObject: function(a, b)
break;
default:
if (a[p] !== b[p] && Number(a[p]) !== Number(b[p])) {
- com.synckolab.tools.logMessage("not equals: : " + p + " a: " + a[p] + " b: " + b[p], com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("not equals: : " + p + " a: " + a[p] + " b: " + b[p], synckolab.global.LOG_DEBUG);
return false;
}
}
} else {
if (b[p]) {
- com.synckolab.tools.logMessage("not equals: " + p + " a: not found b: " + b[p], com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("not equals: " + p + " a: not found b: " + b[p], synckolab.global.LOG_DEBUG);
return false;
}
}
@@ -215,8 +217,8 @@ equalsObject: function(a, b)
}
for(p in b) {
- if(p !== "synckolab" && p !== "type" && (!a || typeof(a[p]) === 'undefined') && b[p] !== null && b[p] !== "") {
- com.synckolab.tools.logMessage("not equals: " + p + " a: " + (a?a[p]:'is null') + " b: " + b[p], com.synckolab.global.LOG_DEBUG);
+ if(p !== "ts" && p !== "sha1" && p !== "synckolab" && p !== "type" && (!a || typeof(a[p]) === 'undefined') && b[p] !== null && b[p] !== "") {
+ synckolab.tools.logMessage("not equals: " + p + " a: " + (a?a[p]:'is null') + " b: " + b[p], synckolab.global.LOG_DEBUG);
return false;
}
}
@@ -250,20 +252,20 @@ stripMailHeader: function (skcontent) {
}
isQP = skcontent.search(/Content-Transfer-Encoding:[ \t\r\n]+quoted-printable/i);
- this.logMessage("Stripping header from Message (QP=" + isQP + ")", com.synckolab.global.LOG_DEBUG);
+ this.logMessage("Stripping header from Message (QP=" + isQP + ")", synckolab.global.LOG_DEBUG);
if(isQP !== -1 || skcontent.indexOf("=3D") !== -1)
{
- skcontent = com.synckolab.tools.text.quoted.decode(skcontent.substring(startPos, skcontent.length));
- this.logMessage("unquoted content: " + skcontent, com.synckolab.global.LOG_DEBUG);
+ skcontent = synckolab.tools.text.quoted.decode(skcontent.substring(startPos, skcontent.length));
+ this.logMessage("unquoted content: " + skcontent, synckolab.global.LOG_DEBUG);
} else {
skcontent = skcontent.substring(startPos, skcontent.length);
}
- return com.synckolab.tools.text.trim(skcontent);
+ return synckolab.tools.text.trim(skcontent);
}
- this.logMessage("Stripping header from multipart message", com.synckolab.global.LOG_DEBUG);
+ this.logMessage("Stripping header from multipart message", synckolab.global.LOG_DEBUG);
// we got a multipart message - strip it apart
@@ -272,7 +274,7 @@ stripMailHeader: function (skcontent) {
boundary = skcontent.substring(skcontent.search(/boundary=/)+9);
// lets trim boundary (in case we have whitespace after the =
- boundary = com.synckolab.tools.text.trim(boundary);
+ boundary = synckolab.tools.text.trim(boundary);
// if the boundary string starts with "... we look for an end
if (boundary.charAt(0) === '"')
@@ -339,7 +341,7 @@ stripMailHeader: function (skcontent) {
}
catch (ex) {
// still continue
- this.logMessage("Error while handling image: " + ex + "\nStream:\n" + imgC, com.synckolab.global.LOG_INFO);
+ this.logMessage("Error while handling image: " + ex + "\nStream:\n" + imgC, synckolab.global.LOG_INFO);
}
fileIO.close();
@@ -405,7 +407,7 @@ stripMailHeader: function (skcontent) {
if (isBase64 !== -1)
{
- this.logMessage("Base64 Decoding message. (Boundary: "+boundary+")", com.synckolab.global.LOG_INFO);
+ this.logMessage("Base64 Decoding message. (Boundary: "+boundary+")", synckolab.global.LOG_INFO);
// get rid of the header
skcontent = skcontent.substring(isBase64, skcontent.length);
startPos = skcontent.indexOf("\r\n\r\n");
@@ -422,7 +424,7 @@ stripMailHeader: function (skcontent) {
skcontent = skcontent.substring(startPos, endPos).replace(/[\r\n \t]+/g, "");
- this.logMessage("Base64 message: " + skcontent, com.synckolab.global.LOG_DEBUG);
+ this.logMessage("Base64 message: " + skcontent, synckolab.global.LOG_DEBUG);
// for base64 we use a two storied approach
// first: use atob
@@ -434,13 +436,13 @@ stripMailHeader: function (skcontent) {
// out of memory error... this can be handled :)
if (e.result === Components.results.NS_ERROR_OUT_OF_MEMORY)
{
- skcontent = com.synckolab.text.base64.decode(skcontent);
- this.logMessage("decoded base64: " + skcontent, com.synckolab.global.LOG_DEBUG);
+ skcontent = synckolab.text.base64.decode(skcontent);
+ this.logMessage("decoded base64: " + skcontent, synckolab.global.LOG_DEBUG);
}
else
{
- this.logMessage("Error decoding base64 (" + e + "): " + skcontent, com.synckolab.global.LOG_ERROR);
+ this.logMessage("Error decoding base64 (" + e + "): " + skcontent, synckolab.global.LOG_ERROR);
return null;
}
}
@@ -451,7 +453,7 @@ stripMailHeader: function (skcontent) {
if (isQP !== -1)
{
skcontent = skcontent.substring(isQP, skcontent.length);
- skcontent = com.synckolab.tools.text.quoted.decode(skcontent);
+ skcontent = synckolab.tools.text.quoted.decode(skcontent);
}
@@ -459,7 +461,7 @@ stripMailHeader: function (skcontent) {
if (isQP === -1 && isBase64 === -1)
{
// so this message has no <xml>something</xml> area
- this.logMessage("Error parsing this message: no xml segment found\n" + skcontent, com.synckolab.global.LOG_ERROR);
+ this.logMessage("Error parsing this message: no xml segment found\n" + skcontent, synckolab.global.LOG_ERROR);
return null;
}
@@ -487,11 +489,11 @@ stripMailHeader: function (skcontent) {
// check if we have to decode quoted printable
if (skcontent.indexOf(" version=3D") !== -1 || skcontent.indexOf("TZID=3D")) // we know from the version (or in case of citadel from the tzid)
{
- this.logMessage("Message is quoted", com.synckolab.global.LOG_INFO);
- skcontent = com.synckolab.tools.text.quoted.decode(skcontent);
+ this.logMessage("Message is quoted", synckolab.global.LOG_INFO);
+ skcontent = synckolab.tools.text.quoted.decode(skcontent);
}
- return com.synckolab.tools.text.trim(skcontent);
+ return synckolab.tools.text.trim(skcontent);
},
/**
@@ -512,12 +514,12 @@ generateMail: function (cid, mail, adsubject, mime, part, skcontent, hr, image){
}
var msg = "";
- var bound = com.synckolab.tools.text.randomVcardId();
+ var bound = synckolab.tools.text.randomVcardId();
var cdate = new Date();
var sTime = (cdate.getHours()<10?"0":"") + cdate.getHours() + ":" + (cdate.getMinutes()<10?"0":"") + cdate.getMinutes() + ":" +
(cdate.getSeconds()<10?"0":"") + cdate.getSeconds();
- var sdate = "Date: " + com.synckolab.tools.text.getDayString(cdate.getDay()) + ", " + cdate.getDate() + " " +
- com.synckolab.tools.text.getMonthString(cdate.getMonth()) + " " + cdate.getFullYear() + " " + sTime +
+ var sdate = "Date: " + synckolab.tools.text.getDayString(cdate.getDay()) + ", " + cdate.getDate() + " " +
+ synckolab.tools.text.getMonthString(cdate.getMonth()) + " " + cdate.getFullYear() + " " + sTime +
" " + ((cdate.getTimezoneOffset() < 0)?"+":"-") +
(Math.abs(cdate.getTimezoneOffset()/60)<10?"0":"") + Math.abs(cdate.getTimezoneOffset()/60) +"00\n";
@@ -542,7 +544,7 @@ generateMail: function (cid, mail, adsubject, mime, part, skcontent, hr, image){
if (!part) {
msg += "Content-Transfer-Encoding: quoted-printable\n";
}
- msg += "User-Agent: SyncKolab " + com.synckolab.config.version + "\n";
+ msg += "User-Agent: SyncKolab " + synckolab.config.version + "\n";
if (part) {
msg += "X-Kolab-Type: "+mime+"\n";
}
@@ -626,7 +628,7 @@ generateMail: function (cid, mail, adsubject, mime, part, skcontent, hr, image){
fileIO.close();
istream.close();
- this.logMessage("got " + fileContent.length + " bytes", com.synckolab.global.LOG_WARNING);
+ this.logMessage("got " + fileContent.length + " bytes", synckolab.global.LOG_WARNING);
// now we got the image into fileContent - lets attach
@@ -639,7 +641,7 @@ generateMail: function (cid, mail, adsubject, mime, part, skcontent, hr, image){
}
catch (ex)
{
- this.logMessage("Unable to read image: "+image+"\n" + ex, com.synckolab.global.LOG_WARNING);
+ this.logMessage("Unable to read image: "+image+"\n" + ex, synckolab.global.LOG_WARNING);
return null;
}
@@ -677,8 +679,8 @@ getAccountName: function (accountKey) {
for (var i = 0; i < accountManager.allServers.Count(); i++)
{
var account = accountManager.allServers.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
- if (account.rootMsgFolder.baseMessageURI === accountKey || com.synckolab.tools.text.fixNameToMiniCharset(account.rootMsgFolder.baseMessageURI) === accountKey ||
- com.synckolab.tools.text.fixNameToMiniCharset(account.prettyName) === accountKey)
+ if (account.rootMsgFolder.baseMessageURI === accountKey || synckolab.tools.text.fixNameToMiniCharset(account.rootMsgFolder.baseMessageURI) === accountKey ||
+ synckolab.tools.text.fixNameToMiniCharset(account.prettyName) === accountKey)
{
return accountManager.getFirstIdentityForServer(account).fullName;
}
@@ -696,8 +698,8 @@ getAccountEMail: function (accountKey) {
for (var i = 0; i < accountManager.allServers.Count(); i++)
{
var account = accountManager.allServers.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
- if (account.rootMsgFolder.baseMessageURI === accountKey || com.synckolab.tools.text.fixNameToMiniCharset(account.rootMsgFolder.baseMessageURI) === accountKey ||
- com.synckolab.tools.text.fixNameToMiniCharset(account.prettyName) === accountKey)
+ if (account.rootMsgFolder.baseMessageURI === accountKey || synckolab.tools.text.fixNameToMiniCharset(account.rootMsgFolder.baseMessageURI) === accountKey ||
+ synckolab.tools.text.fixNameToMiniCharset(account.prettyName) === accountKey)
{
return accountManager.getFirstIdentityForServer(account).email;
}
@@ -713,15 +715,15 @@ getAccountEMail: function (accountKey) {
getMsgFolder: function (accountKey, path)
{
- this.logMessage("trying to get folder: '" + path + "' for account " + accountKey, com.synckolab.global.LOG_DEBUG);
+ this.logMessage("trying to get folder: '" + path + "' for account " + accountKey, synckolab.global.LOG_DEBUG);
var accountManager = Components.classes['@mozilla.org/messenger/account-manager;1'].getService(Components.interfaces.nsIMsgAccountManager);
var gInc = null;
for (var i = 0; i < accountManager.allServers.Count(); i++)
{
var account = accountManager.allServers.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
- if (account.rootMsgFolder.baseMessageURI === accountKey || com.synckolab.tools.text.fixNameToMiniCharset(account.rootMsgFolder.baseMessageURI) === accountKey||
- com.synckolab.tools.text.fixNameToMiniCharset(account.prettyName) === accountKey)
+ if (account.rootMsgFolder.baseMessageURI === accountKey || synckolab.tools.text.fixNameToMiniCharset(account.rootMsgFolder.baseMessageURI) === accountKey||
+ synckolab.tools.text.fixNameToMiniCharset(account.prettyName) === accountKey)
{
gInc = account;
}
@@ -773,7 +775,7 @@ getMsgFolder: function (accountKey, path)
// we found it
if (path === cur.URI)
{
- this.logMessage("we found our path!!!: " + cur.URI, com.synckolab.global.LOG_DEBUG);
+ this.logMessage("we found our path!!!: " + cur.URI, synckolab.global.LOG_DEBUG);
return cur;
}
@@ -782,7 +784,7 @@ getMsgFolder: function (accountKey, path)
if (cp === cur.URI)
{
- this.logMessage("got subpath: " + cur.URI, com.synckolab.global.LOG_DEBUG);
+ this.logMessage("got subpath: " + cur.URI, synckolab.global.LOG_DEBUG);
cFolder = cur;
break;
@@ -824,7 +826,7 @@ getMsgFolder: function (accountKey, path)
};
-com.synckolab.tools.file = {
+synckolab.tools.file = {
/**
* Copies a local file into any mail folder.
* In order to be displayed correct, make sure to create a complete message file!!!
@@ -833,7 +835,7 @@ com.synckolab.tools.file = {
*/
copyToLocalFolder: function (fileName, folderUri)
{
- var mailFolder = com.synckolab.global.rdf.GetResource(folderUri).QueryInterface(Components.interfaces.nsIMsgFolder);
+ var mailFolder = synckolab.global.rdf.GetResource(folderUri).QueryInterface(Components.interfaces.nsIMsgFolder);
// ok give out the folder info
// ok now get the filespec
@@ -852,11 +854,11 @@ com.synckolab.tools.file = {
getSyncDbFile: function (config, id) {
if (id === null)
{
- com.synckolab.tools.logMessage("Error: entry has no id (" +config.name + ": " + config.type + ")", com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("Error: entry has no id (" +config.name + ": " + config.type + ")", synckolab.global.LOG_ERROR);
return null;
}
- com.synckolab.tools.logMessage("syncDbFile: (" +com.synckolab.tools.text.fixNameToMiniCharset(config.serverKey) + "/" + config.type + "_" + config.name + "/" + id + ")", com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("syncDbFile: (" +synckolab.tools.text.fixNameToMiniCharset(config.serverKey) + "/" + config.type + "_" + config.name + "/" + id + ")", synckolab.global.LOG_ERROR);
id = id.replace(/[ :.;$\\\/]\#\@/g, "_");
var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
@@ -866,7 +868,7 @@ com.synckolab.tools.file = {
file.create(1, parseInt("0775", 8));
}
- file.append(com.synckolab.tools.text.fixNameToMiniCharset(config.serverKey));
+ file.append(synckolab.tools.text.fixNameToMiniCharset(config.serverKey));
if (!file.exists()) {
file.create(1, parseInt("0775", 8));
}
@@ -881,7 +883,7 @@ com.synckolab.tools.file = {
}
catch (ex)
{
- com.synckolab.tools.logMessage("Problem with getting syncDbFile: (" +com.synckolab.tools.text.fixNameToMiniCharset(config.serverKey) + "/" + config.name + ": " + config.type + ": " + id + ")\n" + ex, com.synckolab.global.LOG_ERROR);
+ synckolab.tools.logMessage("Problem with getting syncDbFile: (" +synckolab.tools.text.fixNameToMiniCharset(config.serverKey) + "/" + config.name + ": " + config.type + ": " + id + ")\n" + ex, synckolab.global.LOG_ERROR);
return null;
}
return file;
@@ -895,7 +897,7 @@ com.synckolab.tools.file = {
* @param data the data object that will be converted to json and written
* @param direct do not use json, write content as is
*/
-com.synckolab.tools.writeSyncDBFile = function (file, data, direct)
+synckolab.tools.writeSyncDBFile = function (file, data, direct)
{
if (data === null) {
return;
@@ -933,11 +935,11 @@ com.synckolab.tools.writeSyncDBFile = function (file, data, direct)
* @param direct do not use json, write content as is
* @returns the json object from the file
*/
-com.synckolab.tools.readSyncDBFile = function (file, direct)
+synckolab.tools.readSyncDBFile = function (file, direct)
{
if (file === null)
{
- com.synckolab.tools.logMessage("readSyncDBFile ERROR: file is null");
+ synckolab.tools.logMessage("readSyncDBFile ERROR: file is null");
return null;
}
@@ -975,7 +977,7 @@ com.synckolab.tools.readSyncDBFile = function (file, direct)
}
catch (ex)
{
- com.synckolab.tools.logMessage("readSyncDBFile ERROR while reading file" + ex);
+ synckolab.tools.logMessage("readSyncDBFile ERROR while reading file" + ex);
}
return null;
};
@@ -984,10 +986,10 @@ com.synckolab.tools.readSyncDBFile = function (file, direct)
* Retrieves a file in the user profile dir which includes the config database
* make sure to add .cal, .con or .task at the config so there are no duplicate names
*/
-com.synckolab.tools.file.getHashDataBaseFile = function (config)
+synckolab.tools.file.getHashDataBaseFile = function (config)
{
var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
- file.append("synckolab." + com.synckolab.tools.text.fixNameToMiniCharset(config.serverKey) + "." + config.name + "." + config.type+".hdb");
+ file.append("synckolab." + synckolab.tools.text.fixNameToMiniCharset(config.serverKey) + "." + config.name + "." + config.type+".hdb");
return file;
};
@@ -996,10 +998,10 @@ com.synckolab.tools.file.getHashDataBaseFile = function (config)
* Database class: read a file into a hashmap
* @param file the file to read/write the data to/from
*/
-com.synckolab.dataBase = function (file) {
+synckolab.dataBase = function (file) {
// the database file
this.dbf = file;
- this.db = new com.synckolab.hashMap();
+ this.db = new synckolab.hashMap();
// no file specified - memory only
if(!file) {
@@ -1008,7 +1010,7 @@ com.synckolab.dataBase = function (file) {
// if the file is not readable - dont bother
if (!file.exists() || !file.isReadable()) {
- com.synckolab.tools.logMessage("File not readable: " + file, com.synckolab.global.LOG_WARNING);
+ synckolab.tools.logMessage("File not readable: " + file, synckolab.global.LOG_WARNING);
return;
}
@@ -1040,7 +1042,7 @@ com.synckolab.dataBase = function (file) {
fv = fv.replace(/\\\\/g, "\\");
}
// split now
- fv = com.synckolab.tools.text.trim(fv).split(":");
+ fv = synckolab.tools.text.trim(fv).split(":");
for (var j =0; j < fv.length; j++)
{
if (fv[j].replace) {
@@ -1058,11 +1060,11 @@ com.synckolab.dataBase = function (file) {
/**
* returns the position of this entry in the db
*/
-com.synckolab.dataBase.prototype.get = function (key) {
+synckolab.dataBase.prototype.get = function (key) {
return this.db.get(key);
};
-com.synckolab.dataBase.prototype.remove = function (entry) {
+synckolab.dataBase.prototype.remove = function (entry) {
this.db.remove(entry[0]);
};
@@ -1070,7 +1072,7 @@ com.synckolab.dataBase.prototype.remove = function (entry) {
* add an array - the first entry is the key!
* @param entry
*/
-com.synckolab.dataBase.prototype.add = function (entry) {
+synckolab.dataBase.prototype.add = function (entry) {
this.db.put(entry[0], entry);
};
@@ -1079,7 +1081,7 @@ com.synckolab.dataBase.prototype.add = function (entry) {
* @param entry
* @return
*/
-com.synckolab.dataBase.prototype.addField = function (name, value) {
+synckolab.dataBase.prototype.addField = function (name, value) {
// ignore errornous fields!
if (name === null || value === null) {
return;
@@ -1088,11 +1090,11 @@ com.synckolab.dataBase.prototype.addField = function (name, value) {
this.db.put(entry[0], entry);
};
-com.synckolab.dataBase.prototype.length = function () {
+synckolab.dataBase.prototype.length = function () {
return this.db.length();
};
-com.synckolab.dataBase.prototype.toString = function () {
+synckolab.dataBase.prototype.toString = function () {
this.db.iterate();
var cur;
var str = "";
@@ -1103,13 +1105,13 @@ com.synckolab.dataBase.prototype.toString = function () {
return str;
};
-com.synckolab.dataBase.prototype.toXmlString = function () {
+synckolab.dataBase.prototype.toXmlString = function () {
this.db.iterate();
var cur;
var str = "";
while ((cur = this.db.next()))
{
- str += com.synckolab.tools.text.nodeWithContent(cur[0], cur[1], false);
+ str += synckolab.tools.text.nodeWithContent(cur[0], cur[1], false);
}
return str;
};
@@ -1117,7 +1119,7 @@ com.synckolab.dataBase.prototype.toXmlString = function () {
* writes a database file (key:hashvalue:h2)
* @param file an optional new filename to write into
*/
-com.synckolab.dataBase.prototype.write = function (file) {
+synckolab.dataBase.prototype.write = function (file) {
if (!file && !this.dbf) {
return;
}
@@ -1156,7 +1158,7 @@ com.synckolab.dataBase.prototype.write = function (file) {
s += ":" + fv;
}
s += "\n";
- com.synckolab.tools.logMessage("writing " + s, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("writing " + s, synckolab.global.LOG_DEBUG);
stream.write(s, s.length);
}
// write newlines at the end
@@ -1170,7 +1172,7 @@ com.synckolab.dataBase.prototype.write = function (file) {
/**
* Initial prime number used as seed: 521
*/
-com.synckolab.hashMap = function ()
+synckolab.hashMap = function ()
{
this.len = 0;
this.seed = 521;
@@ -1182,7 +1184,7 @@ com.synckolab.hashMap = function ()
};
// starts an iteration
-com.synckolab.hashMap.prototype.iterate = function () {
+synckolab.hashMap.prototype.iterate = function () {
this.hashIdx = 0;
this.idx = 0;
};
@@ -1190,7 +1192,7 @@ com.synckolab.hashMap.prototype.iterate = function () {
/**
* gets the next element or null
*/
-com.synckolab.hashMap.prototype.next = function () {
+synckolab.hashMap.prototype.next = function () {
// check if we still have room in the current hash
this.idx++;
while (this.idx >= this.array[this.hashIdx].length)
@@ -1211,14 +1213,14 @@ com.synckolab.hashMap.prototype.next = function () {
/**
* HashMap class to speed up searches
*/
-com.synckolab.hashMap.entry = function ( key, value )
+synckolab.hashMap.entry = function ( key, value )
{
this.key = key;
this.value = value;
};
-com.synckolab.hashMap.prototype.getIKey = function (key)
+synckolab.hashMap.prototype.getIKey = function (key)
{
if(!key) {
var err = new Error("");
@@ -1233,7 +1235,7 @@ com.synckolab.hashMap.prototype.getIKey = function (key)
return sum;
};
-com.synckolab.hashMap.prototype.put = function ( key, value )
+synckolab.hashMap.prototype.put = function ( key, value )
{
if(!key) {
var err = new Error("");
@@ -1252,11 +1254,11 @@ com.synckolab.hashMap.prototype.put = function ( key, value )
return;
}
}
- car[car.length] = new com.synckolab.hashMap.entry( key, value );
+ car[car.length] = new synckolab.hashMap.entry( key, value );
this.len++;
};
-com.synckolab.hashMap.prototype.clear = function ()
+synckolab.hashMap.prototype.clear = function ()
{
for (var k = 0; k < this.seed; k++) {
this.array[k] = [];
@@ -1264,7 +1266,7 @@ com.synckolab.hashMap.prototype.clear = function ()
this.len = 0;
};
-com.synckolab.hashMap.prototype.remove = function ( key )
+synckolab.hashMap.prototype.remove = function ( key )
{
// get a key
var ikey = this.getIKey(key) % this.seed;
@@ -1281,7 +1283,7 @@ com.synckolab.hashMap.prototype.remove = function ( key )
return false;
};
-com.synckolab.hashMap.prototype.get = function ( key )
+synckolab.hashMap.prototype.get = function ( key )
{
// get a key
var ikey = this.getIKey(key) % this.seed;
@@ -1296,7 +1298,7 @@ com.synckolab.hashMap.prototype.get = function ( key )
return null;
};
-com.synckolab.hashMap.prototype.length = function ()
+synckolab.hashMap.prototype.length = function ()
{
return this.len;
};
@@ -1304,7 +1306,7 @@ com.synckolab.hashMap.prototype.length = function ()
/**
* synckolab node (standard node with a twist)
*/
-com.synckolab.Node = function (node) {
+synckolab.Node = function (node) {
if (node === null) {
return null;
}
@@ -1312,21 +1314,21 @@ com.synckolab.Node = function (node) {
this.nodeName = node.nodeName;
this.nodeType = node.nodeType;
this.firstChild = node.firstChild;
- this.nextSibling = new com.synckolab.Node(node.nextSibling);
+ this.nextSibling = new synckolab.Node(node.nextSibling);
};
-com.synckolab.Node.prototype.getFirstData = function () {
+synckolab.Node.prototype.getFirstData = function () {
if (!this.node.firstChild) {
return null;
}
- return com.synckolab.tools.text.decode4XML(this.node.firstChild.data);
+ return synckolab.tools.text.decode4XML(this.node.firstChild.data);
};
/**
* return the content of a child node with name "name" of the node "node"
* or the given default "def" if no such node exists
*/
-com.synckolab.Node.prototype.getXmlResult = function (name, def)
+synckolab.Node.prototype.getXmlResult = function (name, def)
{
var cur = this.node.firstChild;
while(cur)
@@ -1338,7 +1340,7 @@ com.synckolab.Node.prototype.getXmlResult = function (name, def)
var value = cur.firstChild.nodeValue;
// decode the value
if (value) {
- return com.synckolab.tools.text.decode4XML(value);
+ return synckolab.tools.text.decode4XML(value);
}
}
}
@@ -1351,7 +1353,7 @@ com.synckolab.Node.prototype.getXmlResult = function (name, def)
/**
* return a direct child node with the name "name" of the node "node"
*/
-com.synckolab.Node.prototype.getChildNode = function (name)
+synckolab.Node.prototype.getChildNode = function (name)
{
var cur = this.node.firstChild;
while(cur)
@@ -1369,7 +1371,7 @@ com.synckolab.Node.prototype.getChildNode = function (name)
* return the value of the attribute with name "attrName" of the node "node"
* or null, if no attribute with that name exists
*/
-com.synckolab.Node.prototype.getAttribute = function (attrName)
+synckolab.Node.prototype.getAttribute = function (attrName)
{
if (!this.node) {
return null;
@@ -1395,7 +1397,7 @@ com.synckolab.Node.prototype.getAttribute = function (attrName)
* This function falla back to using QueryInterface to check whether the interface
* is implemented.
*/
-com.synckolab.tools.instanceOf = function (aObject, aInterface) {
+synckolab.tools.instanceOf = function (aObject, aInterface) {
// We first try instanceof which is assumed to be faster than querying the object:
if (!(aObject instanceof aInterface)) {
// if the passed object in not wrapped (but a plain implementation),
@@ -1417,7 +1419,7 @@ com.synckolab.tools.instanceOf = function (aObject, aInterface) {
* @param config the config (to read the right folder)
* @param parseFunc a function that parses the messages into objects
*/
-com.synckolab.tools.fillMessageLookup = function(map, config, parseFunc) {
+synckolab.tools.fillMessageLookup = function(map, config, parseFunc) {
var messages;
// get the message keys
if (config.folder.getMessages) {
@@ -1432,31 +1434,31 @@ com.synckolab.tools.fillMessageLookup = function(map, config, parseFunc) {
}
};
-com.synckolab.tools.CONFIG_TYPE_BOOL = 0;
-com.synckolab.tools.CONFIG_TYPE_CHAR = 1;
-com.synckolab.tools.CONFIG_TYPE_INT = 2;
+synckolab.tools.CONFIG_TYPE_BOOL = 0;
+synckolab.tools.CONFIG_TYPE_CHAR = 1;
+synckolab.tools.CONFIG_TYPE_INT = 2;
/**
*
* @param pref the preference service (Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);)
* @param name the name of the configuration to get (every value is prefixed with SyncKolab.)
- * @param type the type (see com.synckolab.tools.CONFIG_TYPE_*)
+ * @param type the type (see synckolab.tools.CONFIG_TYPE_*)
* @param def an optional default value
* @return the configuration value in the given type or the default value
*/
-com.synckolab.tools.getConfigValue = function(pref, name, type, def) {
+synckolab.tools.getConfigValue = function(pref, name, type, def) {
try {
- if(type === com.synckolab.tools.CONFIG_TYPE_BOOL) {
+ if(type === synckolab.tools.CONFIG_TYPE_BOOL) {
return pref.getBoolPref("SyncKolab." + name);
}
- if(type === com.synckolab.tools.CONFIG_TYPE_INT) {
+ if(type === synckolab.tools.CONFIG_TYPE_INT) {
return pref.getIntPref("SyncKolab." + name);
}
// default use char pref
return pref.getCharPref("SyncKolab." + name);
}
catch (ex) {
- com.synckolab.tools.logMessage("SyncKolab."+name+" does not exist(yet).", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("SyncKolab."+name+" does not exist(yet).", synckolab.global.LOG_INFO);
return def;
}
};
@@ -1464,16 +1466,16 @@ com.synckolab.tools.getConfigValue = function(pref, name, type, def) {
/**
* @param pref the preference service (Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);)
* @param name the name of the configuration to get (every value is prefixed with SyncKolab.)
- * @param type the type (see com.synckolab.tools.CONFIG_TYPE_*)
+ * @param type the type (see synckolab.tools.CONFIG_TYPE_*)
* @param value the value to write
* @return true when the value has been written
*/
-com.synckolab.tools.setConfigValue = function(pref, name, type, value) {
+synckolab.tools.setConfigValue = function(pref, name, type, value) {
try {
- if(type === com.synckolab.tools.CONFIG_TYPE_BOOL) {
+ if(type === synckolab.tools.CONFIG_TYPE_BOOL) {
pref.setBoolPref("SyncKolab." + name, value);
}
- if(type === com.synckolab.tools.CONFIG_TYPE_INT) {
+ if(type === synckolab.tools.CONFIG_TYPE_INT) {
pref.setIntPref("SyncKolab." + name, value);
}
// default use char pref
@@ -1492,7 +1494,7 @@ com.synckolab.tools.setConfigValue = function(pref, name, type, value) {
* @param name the name of the configuration to get (every value is prefixed with SyncKolab.)
* @return true when the value has been written
*/
-com.synckolab.tools.removeConfig = function(pref, name) {
+synckolab.tools.removeConfig = function(pref, name) {
try {
pref.clearUserPref("SyncKolab." + name);
}
@@ -1507,14 +1509,14 @@ com.synckolab.tools.removeConfig = function(pref, name) {
* opens a browser window with a given url
* @param aURL the external url to load
*/
-com.synckolab.tools.launchUrl = function(aURL) {
+synckolab.tools.launchUrl = function(aURL) {
var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance();
messenger = messenger.QueryInterface(Components.interfaces.nsIMessenger);
messenger.launchExternalURL(aURL);
};
-com.synckolab.tools.getUidFromHeader = function (header) {
+synckolab.tools.getUidFromHeader = function (header) {
if(!header) {
return header;
}
diff --git a/src/chrome/content/synckolab/tools/kolab.js b/src/chrome/content/synckolab/tools/kolab.js
index c7f9889..2294cb2 100644
--- a/src/chrome/content/synckolab/tools/kolab.js
+++ b/src/chrome/content/synckolab/tools/kolab.js
@@ -30,11 +30,10 @@
* ***** END LICENSE BLOCK ***** */
"use strict";
-if(!com) var com={};
-if(!com.synckolab) com.synckolab={};
-if(!com.synckolab.tools) com.synckolab.tools={};
+if(!synckolab) var synckolab={};
+if(!synckolab.tools) synckolab.tools={};
-com.synckolab.tools.kolab={
+synckolab.tools.kolab={
/**
* return the name of the week day like it is expected
* by the Kolab 2 XML format
@@ -43,7 +42,7 @@ com.synckolab.tools.kolab={
* @return a string with the name of the week day
*/
getXmlDayName: function(index) {
- com.synckolab.tools.logMessage("converting " + index, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("converting " + index, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
var name = "sunday";
switch (index)
{
@@ -81,7 +80,7 @@ com.synckolab.tools.kolab={
*/
getDayIndex: function (name)
{
- com.synckolab.tools.logMessage("converting " + name, com.synckolab.global.LOG_CAL + com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("converting " + name, synckolab.global.LOG_CAL + synckolab.global.LOG_DEBUG);
var index = 1;
switch (name.toLowerCase())
{
diff --git a/src/chrome/content/synckolab/tools/sha1.js b/src/chrome/content/synckolab/tools/sha1.js
index d9cc453..2b85960 100644
--- a/src/chrome/content/synckolab/tools/sha1.js
+++ b/src/chrome/content/synckolab/tools/sha1.js
@@ -9,11 +9,10 @@
*/
"use strict";
-if(!com) var com={};
-if(!com.synckolab) com.synckolab={};
-if(!com.synckolab.tools) {com.synckolab.tools={};}
+if(!synckolab) var synckolab={};
+if(!synckolab.tools) {synckolab.tools={};}
-com.synckolab.tools.sha1 = {
+synckolab.tools.sha1 = {
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
diff --git a/src/chrome/content/synckolab/tools/text.js b/src/chrome/content/synckolab/tools/text.js
index 2a03856..eda4649 100644
--- a/src/chrome/content/synckolab/tools/text.js
+++ b/src/chrome/content/synckolab/tools/text.js
@@ -30,7 +30,7 @@
* ***** END LICENSE BLOCK ***** */
/**
- * Package: com.synckolab.tools.text
+ * Package: synckolab.tools.text
*
* Text handling:
* * fixToMiniCharset()
@@ -42,17 +42,15 @@
*/
"use strict";
-if (!com)
- var com = {};
-if (!com.synckolab)
- com.synckolab = {};
-if (!com.synckolab.tools)
- com.synckolab.tools = {};
+if (!synckolab)
+ var synckolab = {};
+if (!synckolab.tools)
+ synckolab.tools = {};
/**
* Basic text stuff
*/
-com.synckolab.tools.text = {
+synckolab.tools.text = {
nodeWithContent : function (nodeName, nodeValue, createNonExist) {
if (!createNonExist && !this.checkExist(nodeValue)) {
return "";
@@ -62,7 +60,7 @@ com.synckolab.tools.text = {
},
checkExist : function (value) {
- return value && value !== "";
+ return value !== null && typeof value !== 'undefined' && value !== "" && value !== " ";
},
trim : function (s) {
@@ -74,7 +72,7 @@ com.synckolab.tools.text = {
*/
fixNameToMiniCharset : function (name) {
if (typeof name === 'undefined' || !name.length) {
- com.synckolab.global.consoleService.logStringMessage("undefined string " + new Error("s").stack);
+ synckolab.global.consoleService.logStringMessage("undefined string " + new Error("s").stack);
}
var ret = "";
@@ -433,7 +431,7 @@ com.synckolab.tools.text = {
}
if(!s) {
- com.synckolab.global.consoleService.logStringMessage("undefined string " + new Error("s").stack);
+ synckolab.global.consoleService.logStringMessage("undefined string " + new Error("s").stack);
}
if (!s.replace) {
@@ -496,9 +494,9 @@ com.synckolab.tools.text = {
/**
* UTF-8 en/decoder
* Usage:
- * result = com.synckolab.text.utf8.decode(String); / encode(String);
+ * result = synckolab.text.utf8.decode(String); / encode(String);
*/
-com.synckolab.tools.text.utf8 = {
+synckolab.tools.text.utf8 = {
decode : function (utftext) {
var plaintext = "";
var i = 0;
@@ -594,9 +592,9 @@ com.synckolab.tools.text.utf8 = {
/**
* UTF-16 en/decoder
* Usage:
- * result = com.synckolab.text.utf16.decode(String); / encode(String);
+ * result = synckolab.text.utf16.decode(String); / encode(String);
*/
-com.synckolab.tools.text.utf16 = {
+synckolab.tools.text.utf16 = {
decode : function (str) {
var out, i, len, c;
var char2, char3;
@@ -660,9 +658,9 @@ com.synckolab.tools.text.utf16 = {
/**
* QuotedPrintable en/decoder
* Usage:
- * result = com.synckolab.text.quoted.decode(String); / encode(String);
+ * result = synckolab.text.quoted.decode(String); / encode(String);
*/
-com.synckolab.tools.text.quoted = {
+synckolab.tools.text.quoted = {
encode : function (str) {
// + original by: Theriault
@@ -743,9 +741,9 @@ com.synckolab.tools.text.quoted = {
/**
* Base 64 decoder
* Usage:
- * result = com.synckolab.text.base64.decode(String); / encode(String);
+ * result = synckolab.text.base64.decode(String); / encode(String);
*/
-com.synckolab.tools.text.base64 = {
+synckolab.tools.text.base64 = {
base64 : ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9', '*', '/'],
diff --git a/src/chrome/content/synckolab/wndConfig.js b/src/chrome/content/synckolab/wndConfig.js
index c6c3106..2c5f6db 100644
--- a/src/chrome/content/synckolab/wndConfig.js
+++ b/src/chrome/content/synckolab/wndConfig.js
@@ -30,10 +30,9 @@
* ***** END LICENSE BLOCK ***** */
"use strict";
-if(!com) var com={};
-if(!com.synckolab) com.synckolab={};
+if(!synckolab) var synckolab={};
-com.synckolab.settings = {
+synckolab.settings = {
// string bundle use: strBundle.getString("KEYNAME")
strBundle: null,
// account types
@@ -44,19 +43,19 @@ com.synckolab.settings = {
-com.synckolab.settings.savePrefs = function () {
+synckolab.settings.savePrefs = function () {
// get base info back from ui
- com.synckolab.tools.logMessage("Saving preferences.", com.synckolab.global.LOG_DEBUG);
- com.synckolab.settings.getBaseInfo();
- com.synckolab.tools.logMessage("Getting info.", com.synckolab.global.LOG_DEBUG);
- com.synckolab.settings.getInfo();
+ synckolab.tools.logMessage("Saving preferences.", synckolab.global.LOG_DEBUG);
+ synckolab.settings.getBaseInfo();
+ synckolab.tools.logMessage("Getting info.", synckolab.global.LOG_DEBUG);
+ synckolab.settings.getInfo();
- com.synckolab.tools.logMessage("Write the configuration: " + com.synckolab.settings.config.toSource(), com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Write the configuration: " + synckolab.settings.config.toSource(), synckolab.global.LOG_DEBUG);
// write the configuration
- com.synckolab.settings.writeConfiguration(com.synckolab.settings.config);
- com.synckolab.tools.logMessage("done saving.", com.synckolab.global.LOG_DEBUG);
+ synckolab.settings.writeConfiguration(synckolab.settings.config);
+ synckolab.tools.logMessage("done saving.", synckolab.global.LOG_DEBUG);
return true;
};
@@ -68,16 +67,16 @@ com.synckolab.settings.savePrefs = function () {
* @param conf the configuration to write
* @return true if everything went ok
*/
-com.synckolab.settings.writeConfiguration = function(config) {
- var orig = com.synckolab.config.loadConfiguration();
+synckolab.settings.writeConfiguration = function(config) {
+ var orig = synckolab.config.loadConfiguration();
// now we can start writing
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
- com.synckolab.tools.setConfigValue(pref, "configVersion", com.synckolab.tools.CONFIG_TYPE_INT, config.version + 1);
- com.synckolab.tools.setConfigValue(pref, "debugLevel", com.synckolab.tools.CONFIG_TYPE_INT, config.debugLevel);
- com.synckolab.tools.setConfigValue(pref, "hideFolder", com.synckolab.tools.CONFIG_TYPE_BOOL, config.hideFolder);
- com.synckolab.tools.setConfigValue(pref, "closeWindow", com.synckolab.tools.CONFIG_TYPE_BOOL, config.closeWindow);
- com.synckolab.tools.setConfigValue(pref, "syncOnStart", com.synckolab.tools.CONFIG_TYPE_BOOL, config.syncOnStart);
+ synckolab.tools.setConfigValue(pref, "configVersion", synckolab.tools.CONFIG_TYPE_INT, config.version + 1);
+ synckolab.tools.setConfigValue(pref, "debugLevel", synckolab.tools.CONFIG_TYPE_INT, config.debugLevel);
+ synckolab.tools.setConfigValue(pref, "hideFolder", synckolab.tools.CONFIG_TYPE_BOOL, config.hideFolder);
+ synckolab.tools.setConfigValue(pref, "closeWindow", synckolab.tools.CONFIG_TYPE_BOOL, config.closeWindow);
+ synckolab.tools.setConfigValue(pref, "syncOnStart", synckolab.tools.CONFIG_TYPE_BOOL, config.syncOnStart);
// check if an account has been removed
var i,j,found;
@@ -91,7 +90,7 @@ com.synckolab.settings.writeConfiguration = function(config) {
}
}
if(!found) {
- com.synckolab.tools.logMessage("resetting " + orig.accounts[i].name, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("resetting " + orig.accounts[i].name, synckolab.global.LOG_DEBUG);
pref.resetBranch("SyncKolab." + orig.accounts[i].name);
}
}
@@ -116,12 +115,12 @@ com.synckolab.settings.writeConfiguration = function(config) {
}
// write per account
- com.synckolab.settings.writeAccountConfig(pref, config.accounts[i], origAcct);
+ synckolab.settings.writeAccountConfig(pref, config.accounts[i], origAcct);
acctList += config.accounts[i].name + ";";
}
// write the acctList back
- com.synckolab.tools.setConfigValue(pref, "accounts.list", com.synckolab.tools.CONFIG_TYPE_CHAR, acctList);
+ synckolab.tools.setConfigValue(pref, "accounts.list", synckolab.tools.CONFIG_TYPE_CHAR, acctList);
return true;
};
@@ -130,7 +129,7 @@ com.synckolab.settings.writeConfiguration = function(config) {
* read the account configuration into an object
* @param acct the account object to read the configuration into (name has to be existent)
*/
-com.synckolab.settings.writeAccountConfig = function (pref, acct, orig) {
+synckolab.settings.writeAccountConfig = function (pref, acct, orig) {
var configs, i, j, k, found;
for(var type in acct) {
// skip volatiles/non-arrays
@@ -148,7 +147,7 @@ com.synckolab.settings.writeAccountConfig = function (pref, acct, orig) {
// get rid of the deleted configuration branches
if(!found) {
try {
- com.synckolab.settings.resetConfiguration(acct.name, type, orig[type][i].name);
+ synckolab.settings.resetConfiguration(acct.name, type, orig[type][i].name);
pref.resetBranch("SyncKolab.accounts." + acct.name + "." + type + ".configs." + orig[type][i].name);
} catch (ex) {
@@ -163,7 +162,7 @@ com.synckolab.settings.writeAccountConfig = function (pref, acct, orig) {
continue;
}
- com.synckolab.tools.logMessage("checking " + type + "- " + acct[type][i].name, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("checking " + type + "- " + acct[type][i].name, synckolab.global.LOG_DEBUG);
// if some values change - the cache needs to reset
if(orig && orig[type]) {
@@ -173,9 +172,9 @@ com.synckolab.settings.writeAccountConfig = function (pref, acct, orig) {
for(k=0; k < resetTriggers.length; k++) {
var trigger = resetTriggers[k];
if(acct[type][i][trigger] !== orig[type][j][trigger]) {
- com.synckolab.tools.logMessage("found change trigger - reset config", com.synckolab.global.LOG_DEBUG);
- com.synckolab.settings.resetConfiguration(acct.name, type, acct[type][i].name);
- com.synckolab.tools.logMessage("finished reset for " + acct.name + " " + type, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("found change trigger - reset config", synckolab.global.LOG_DEBUG);
+ synckolab.settings.resetConfiguration(acct.name, type, acct[type][i].name);
+ synckolab.tools.logMessage("finished reset for " + acct.name + " " + type, synckolab.global.LOG_DEBUG);
break;
}
}
@@ -185,12 +184,12 @@ com.synckolab.settings.writeAccountConfig = function (pref, acct, orig) {
}
// write all the base settings
- for(var n in com.synckolab.config.baseSetting) {
+ for(var n in synckolab.config.baseSetting) {
// skip unwanted prototypes (without type)
- if(com.synckolab.config.baseSetting[n].type >= 0) {
- com.synckolab.tools.setConfigValue(pref,
+ if(synckolab.config.baseSetting[n].type >= 0) {
+ synckolab.tools.setConfigValue(pref,
"accounts." + acct.name+"." + type + ".configs." + acct[type][i].name + "." + n,
- com.synckolab.config.baseSetting[n].type,
+ synckolab.config.baseSetting[n].type,
acct[type][i][n]);
}
}
@@ -199,7 +198,7 @@ com.synckolab.settings.writeAccountConfig = function (pref, acct, orig) {
}
// write the configList back
- com.synckolab.tools.setConfigValue(pref, "accounts." + acct.name + "." + type + ".list", com.synckolab.tools.CONFIG_TYPE_CHAR, configs);
+ synckolab.tools.setConfigValue(pref, "accounts." + acct.name + "." + type + ".list", synckolab.tools.CONFIG_TYPE_CHAR, configs);
}
}
};
@@ -208,17 +207,17 @@ com.synckolab.settings.writeAccountConfig = function (pref, acct, orig) {
* Init function. This is called when the configuration dialog or wizard is started.
* This will read the current configuration and the window elements.
*/
-com.synckolab.settings.init = function () {
+synckolab.settings.init = function () {
var i = 0, j;
- com.synckolab.settings.checkOldConfig();
+ synckolab.settings.checkOldConfig();
// load the string bundle for translation
- com.synckolab.settings.strBundle = document.getElementById("synckolabBundle");
+ synckolab.settings.strBundle = document.getElementById("synckolabBundle");
// check if calendar is available
- com.synckolab.settings.isCalendar = com.synckolab.calendarTools.isCalendarAvailable();
+ synckolab.settings.isCalendar = synckolab.calendarTools.isCalendarAvailable();
// read the current configuration
- com.synckolab.settings.config = com.synckolab.config.loadConfiguration();
+ synckolab.settings.config = synckolab.config.loadConfiguration();
// the format selection boxes:
var abList = document.getElementById("contactFormat");
@@ -271,7 +270,7 @@ com.synckolab.settings.init = function () {
// the adress book list
// fill the contact selection
- var cn = com.synckolab.addressbookTools.getABDirectory();
+ var cn = synckolab.addressbookTools.getABDirectory();
var ABook = cn.getNext();
// we only have ONE address book - means a fresh install - notify the user
@@ -285,9 +284,9 @@ com.synckolab.settings.init = function () {
// the calendar
// if we do not have a calendar, we can easily skip this
- if (com.synckolab.settings.isCalendar)
+ if (synckolab.settings.isCalendar)
{
- var calendars = com.synckolab.calendarTools.getCalendars();
+ var calendars = synckolab.calendarTools.getCalendars();
abList = document.getElementById("calendarURL");
abpopup = document.createElement("menupopup");
abList.appendChild(abpopup);
@@ -303,23 +302,23 @@ com.synckolab.settings.init = function () {
abchild = document.createElement("menuitem");
abpopup.appendChild(abchild);
abchild.setAttribute("label", calendars[i].name);
- abchild.setAttribute("value", com.synckolab.tools.text.fixNameToMiniCharset(calendars[i].name));
+ abchild.setAttribute("value", synckolab.tools.text.fixNameToMiniCharset(calendars[i].name));
if (i === 0)
{
abchild.setAttribute("selected", "true");
abList.setAttribute("label", calendars[i].name);
- abList.setAttribute("value", com.synckolab.tools.text.fixNameToMiniCharset(calendars[i].name));
+ abList.setAttribute("value", synckolab.tools.text.fixNameToMiniCharset(calendars[i].name));
}
abchild = document.createElement("menuitem");
taskpopup.appendChild(abchild);
abchild.setAttribute("label", calendars[i].name);
- abchild.setAttribute("value", com.synckolab.tools.text.fixNameToMiniCharset(calendars[i].name));
+ abchild.setAttribute("value", synckolab.tools.text.fixNameToMiniCharset(calendars[i].name));
if (i === 0)
{
abchild.setAttribute("selected", "true");
taskList.setAttribute("label", calendars[i].name);
- taskList.setAttribute("value", com.synckolab.tools.text.fixNameToMiniCharset(calendars[i].name));
+ taskList.setAttribute("value", synckolab.tools.text.fixNameToMiniCharset(calendars[i].name));
}
}
}
@@ -365,14 +364,14 @@ com.synckolab.settings.init = function () {
for (i = 0; i < gAccountManager.allServers.Count(); i++)
{
var account = gAccountManager.allServers.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
- com.synckolab.tools.logMessage("Account found: " + account.rootMsgFolder.baseMessageURI, com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("Account found: " + account.rootMsgFolder.baseMessageURI, synckolab.global.LOG_DEBUG);
if (account.rootMsgFolder.baseMessageURI.toLowerCase().indexOf("imap") === -1)
{
- com.synckolab.tools.logMessage("Account " + account.rootMsgFolder.baseMessageURI + " is not an imap account - skipping!", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Account " + account.rootMsgFolder.baseMessageURI + " is not an imap account - skipping!", synckolab.global.LOG_INFO);
continue;
}
- var acctName = com.synckolab.tools.text.fixNameToMiniCharset(account.prettyName);
+ var acctName = synckolab.tools.text.fixNameToMiniCharset(account.prettyName);
tItem = document.createElement("treeitem");
tItem.setAttribute("container", "true");
@@ -390,7 +389,7 @@ com.synckolab.settings.init = function () {
var tChildren = document.createElement("treechildren");
tItem.appendChild(tChildren);
- for (j = 0; j < com.synckolab.settings.baseTypes.length;j++) {
+ for (j = 0; j < synckolab.settings.baseTypes.length;j++) {
// fill in the childs with the configs
tItem = document.createElement("treeitem");
@@ -401,44 +400,44 @@ com.synckolab.settings.init = function () {
tItem.appendChild(tRow);
tCell = document.createElement("treecell");
tRow.appendChild(tCell);
- tItem.setAttribute("id", "tab-"+com.synckolab.settings.baseTypes[j]+"-" + acctName);
- tCell.setAttribute("label", this.strBundle.getString(com.synckolab.settings.baseTypes[j]));
- tCell.setAttribute("value", "tab-"+com.synckolab.settings.baseTypes[j]+"-" + acctName);
+ tItem.setAttribute("id", "tab-"+synckolab.settings.baseTypes[j]+"-" + acctName);
+ tCell.setAttribute("label", this.strBundle.getString(synckolab.settings.baseTypes[j]));
+ tCell.setAttribute("value", "tab-"+synckolab.settings.baseTypes[j]+"-" + acctName);
}
}
- com.synckolab.settings.fillBaseInfo();
- com.synckolab.settings.repaintConfigTree();
+ synckolab.settings.fillBaseInfo();
+ synckolab.settings.repaintConfigTree();
};
/**
* read the current configuration and see if its "old" style
*/
-com.synckolab.settings.checkOldConfig = function() {
+synckolab.settings.checkOldConfig = function() {
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
- var configString = com.synckolab.tools.getConfigValue(pref, "Configs");
+ var configString = synckolab.tools.getConfigValue(pref, "Configs");
// no configs - no old config
if(!configString || configString.length === 0) {
return;
}
/*
- if(!confirm( com.synckolab.global.strBundle.getString("config.convert"))) {
+ if(!confirm( synckolab.global.strBundle.getString("config.convert"))) {
pref.resetBranch("SyncKolab");
return;
}
configs = configString.split(';');
var curConfig = {
- version: com.synckolab.tools.getConfigValue(pref, "configVersion", com.synckolab.tools.CONFIG_TYPE_INT, 0),
- debugLevel: com.synckolab.tools.getConfigValue(pref, "debugLevel", com.synckolab.tools.CONFIG_TYPE_INT, com.synckolab.global.LOG_WARNING),
+ version: synckolab.tools.getConfigValue(pref, "configVersion", synckolab.tools.CONFIG_TYPE_INT, 0),
+ debugLevel: synckolab.tools.getConfigValue(pref, "debugLevel", synckolab.tools.CONFIG_TYPE_INT, synckolab.global.LOG_WARNING),
// hide folder
- hideFolder: com.synckolab.tools.getConfigValue(pref, "hideFolder", com.synckolab.tools.CONFIG_TYPE_BOOL, false),
+ hideFolder: synckolab.tools.getConfigValue(pref, "hideFolder", synckolab.tools.CONFIG_TYPE_BOOL, false),
// hide the window while sync
- closeWindow: com.synckolab.tools.getConfigValue(pref, "closeWindow", com.synckolab.tools.CONFIG_TYPE_BOOL, false),
+ closeWindow: synckolab.tools.getConfigValue(pref, "closeWindow", synckolab.tools.CONFIG_TYPE_BOOL, false),
// sync automatically once on start
- syncOnStart: com.synckolab.tools.getConfigValue(pref, "syncOnStart", com.synckolab.tools.CONFIG_TYPE_BOOL, false),
+ syncOnStart: synckolab.tools.getConfigValue(pref, "syncOnStart", synckolab.tools.CONFIG_TYPE_BOOL, false),
accounts: []
};
@@ -449,7 +448,7 @@ com.synckolab.settings.checkOldConfig = function() {
continue;
}
- act = com.synckolab.tools.text.fixNameToMiniCharset(act);
+ act = synckolab.tools.text.fixNameToMiniCharset(act);
var acct = null;
var j;
@@ -468,7 +467,7 @@ com.synckolab.settings.checkOldConfig = function() {
}
}
- sConf = com.synckolab.tools.getConfigValue(pref, "accounts." + acct.name+"." + type + ".list");
+ sConf = synckolab.tools.getConfigValue(pref, "accounts." + acct.name+"." + type + ".list");
}
*/
@@ -477,11 +476,11 @@ com.synckolab.settings.checkOldConfig = function() {
/**
* re-create the config tree,
*/
-com.synckolab.settings.repaintConfigTree = function() {
+synckolab.settings.repaintConfigTree = function() {
// remove all nodes under tab-account-[cal|con|task]
- var conf = com.synckolab.settings.config;
+ var conf = synckolab.settings.config;
- com.synckolab.settings.batch = true;
+ synckolab.settings.batch = true;
// sorter for configuration names
var configSorter = function(a,b) {
@@ -496,8 +495,8 @@ com.synckolab.settings.repaintConfigTree = function() {
for(var i = 0; i < conf.accounts.length; i++) {
var acctName = conf.accounts[i].name;
- for (var j = 0; j < com.synckolab.settings.baseTypes.length;j++) {
- var cType = com.synckolab.settings.baseTypes[j];
+ for (var j = 0; j < synckolab.settings.baseTypes.length;j++) {
+ var cType = synckolab.settings.baseTypes[j];
var tItem = document.getElementById("tab-" + cType +"-" + acctName);
// delete the treechildren if exist
var cnode = tItem.firstChild;
@@ -537,7 +536,7 @@ com.synckolab.settings.repaintConfigTree = function() {
}
}
- com.synckolab.settings.batch = false;
+ synckolab.settings.batch = false;
};
/**
@@ -545,7 +544,7 @@ com.synckolab.settings.repaintConfigTree = function() {
* @param cn the abook cn
* @param ABook the address book to use
*/
-com.synckolab.settings.fillAddressBook = function (cn, ABook) {
+synckolab.settings.fillAddressBook = function (cn, ABook) {
var abList = document.getElementById("contactURL");
// delete the childs of the list
var cnode = abList.firstChild;
@@ -615,7 +614,7 @@ com.synckolab.settings.fillAddressBook = function (cn, ABook) {
/**
* set all folders after an account change
*/
-com.synckolab.settings.setFolders = function (act) {
+synckolab.settings.setFolders = function (act) {
this.updateFolder(act, [{
prefix: "contact",
@@ -634,7 +633,7 @@ com.synckolab.settings.setFolders = function (act) {
* @param act the account to search for
* @param sets an array of prefix/node object for each element to fill
*/
-com.synckolab.settings.updateFolder = function (act, sets) {
+synckolab.settings.updateFolder = function (act, sets) {
// dynamically read this...
var gAccountManager = Components.classes['@mozilla.org/messenger/account-manager;1'].getService(Components.interfaces.nsIMsgAccountManager);
for (var i = 0; i < gAccountManager.allServers.Count(); i++)
@@ -642,7 +641,7 @@ com.synckolab.settings.updateFolder = function (act, sets) {
try
{
var account = gAccountManager.allServers.GetElementAt(i).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
- if (account.rootMsgFolder.baseMessageURI === act || com.synckolab.tools.text.fixNameToMiniCharset(account.prettyName) === act)
+ if (account.rootMsgFolder.baseMessageURI === act || synckolab.tools.text.fixNameToMiniCharset(account.prettyName) === act)
{
for(var j = 0; j < sets.length; j++) {
var cfold = sets[j].node;
@@ -663,7 +662,7 @@ com.synckolab.settings.updateFolder = function (act, sets) {
cfold.appendChild(tChildren);
sets[j].node = tChildren;
}
- com.synckolab.settings.updateFolderElements(account.rootFolder, sets, "");
+ synckolab.settings.updateFolderElements(account.rootFolder, sets, "");
return;
}
@@ -680,7 +679,7 @@ com.synckolab.settings.updateFolder = function (act, sets) {
* @param msgFolder the current folder
* @param root the current dom root
*/
-com.synckolab.settings.updateFolderElements = function (msgFolder, origSets)
+synckolab.settings.updateFolderElements = function (msgFolder, origSets)
{
var j, tItem, tRow, tCell, tChildren;
var sets = [];
@@ -780,7 +779,7 @@ com.synckolab.settings.updateFolderElements = function (msgFolder, origSets)
return (sa < sb) ? -1 : 1;
});
for(var i = 0; i < folders.length; i++) {
- com.synckolab.settings.updateFolderElements(folders[i], sets);
+ synckolab.settings.updateFolderElements(folders[i], sets);
}
}
@@ -796,7 +795,7 @@ com.synckolab.settings.updateFolderElements = function (msgFolder, origSets)
* </ul>
* @param viewname the item selected
*/
-com.synckolab.settings.setSyncPrefView = function(viewName) {
+synckolab.settings.setSyncPrefView = function(viewName) {
if (viewName.indexOf("-") === -1)
{
alert("Fatal ERROR - unable to get view - Pleasere install!");
@@ -804,7 +803,7 @@ com.synckolab.settings.setSyncPrefView = function(viewName) {
}
// skip this if we update the tree
- if (com.synckolab.settings.batch) {
+ if (synckolab.settings.batch) {
return;
}
@@ -818,14 +817,14 @@ com.synckolab.settings.setSyncPrefView = function(viewName) {
var tabs = document.getElementById("tabs");
// save changes if contact/cal or task was open before
- com.synckolab.settings.getInfo();
+ synckolab.settings.getInfo();
// remember the type
- com.synckolab.settings.activeType = opts[1];
+ synckolab.settings.activeType = opts[1];
if(opts.length > 2) {
- if(com.synckolab.settings.activeAccount !== opts[2]) {
- com.synckolab.settings.activeAccount = opts[2];
- com.synckolab.settings.setFolders(com.synckolab.settings.activeAccount);
+ if(synckolab.settings.activeAccount !== opts[2]) {
+ synckolab.settings.activeAccount = opts[2];
+ synckolab.settings.setFolders(synckolab.settings.activeAccount);
}
}
switch (opts[1])
@@ -836,13 +835,13 @@ com.synckolab.settings.setSyncPrefView = function(viewName) {
return;
case "Acct":
tabs.selectedPanel = document.getElementById("accountTab");
- com.synckolab.settings.fillAccountInfo(opts[2]);
+ synckolab.settings.fillAccountInfo(opts[2]);
document.getElementById("loadConfig").setAttribute("disabled", false);
break;
case "contact":
if(opts.length > 3) {
tabs.selectedPanel = document.getElementById("contactTab");
- com.synckolab.settings.fillInfo("contact", opts[2],opts[3]);
+ synckolab.settings.fillInfo("contact", opts[2],opts[3]);
document.getElementById("delConfig").setAttribute("disabled", false);
} else {
document.getElementById("newConfig").setAttribute("disabled", false);
@@ -851,7 +850,7 @@ com.synckolab.settings.setSyncPrefView = function(viewName) {
case "calendar":
if (this.isCalendar && opts.length > 3) {
tabs.selectedPanel = document.getElementById("calTab");
- com.synckolab.settings.fillInfo("calendar", opts[2],opts[3]);
+ synckolab.settings.fillInfo("calendar", opts[2],opts[3]);
document.getElementById("delConfig").setAttribute("disabled", false);
} else {
document.getElementById("newConfig").setAttribute("disabled", false);
@@ -860,7 +859,7 @@ com.synckolab.settings.setSyncPrefView = function(viewName) {
case "task":
if (this.isCalendar && opts.length > 3) {
tabs.selectedPanel = document.getElementById("taskTab");
- com.synckolab.settings.fillInfo("task", opts[2],opts[3]);
+ synckolab.settings.fillInfo("task", opts[2],opts[3]);
document.getElementById("delConfig").setAttribute("disabled", false);
} else {
document.getElementById("newConfig").setAttribute("disabled", false);
@@ -873,9 +872,9 @@ com.synckolab.settings.setSyncPrefView = function(viewName) {
/**
* fills the base info dialog from the current active config
*/
-com.synckolab.settings.fillBaseInfo = function() {
+synckolab.settings.fillBaseInfo = function() {
- var conf = com.synckolab.settings.config;
+ var conf = synckolab.settings.config;
document.getElementById("hideFolder").checked = conf.hideFolder;
document.getElementById("closeWindow").checked = conf.closeWindow;
document.getElementById("syncOnStart").checked = conf.syncOnStart;
@@ -894,7 +893,7 @@ com.synckolab.settings.fillBaseInfo = function() {
if (cLabel !== null) {
debugEle.setAttribute("label", cLabel.getAttribute("label"));
} else {
- com.synckolab.tools.logMessage("WARNING: could not find Label " + sCLabel, com.synckolab.global.LOG_WARNING);
+ synckolab.tools.logMessage("WARNING: could not find Label " + sCLabel, synckolab.global.LOG_WARNING);
}
}
@@ -903,7 +902,7 @@ com.synckolab.settings.fillBaseInfo = function() {
/**
* Enables/disables the controls on the page
*/
-com.synckolab.settings.setControlState = function (type, active)
+synckolab.settings.setControlState = function (type, active)
{
var fieldsArray = [
"URL",
@@ -926,7 +925,7 @@ com.synckolab.settings.setControlState = function (type, active)
* @param create set to true to create the account object if it doesnt exist
* @returns the account object and possibly null if create is false
*/
-com.synckolab.settings.getAccount = function(config, name, create) {
+synckolab.settings.getAccount = function(config, name, create) {
for(var i = 0; i < config.accounts.length; i++) {
if(config.accounts[i].name === name) {
return config.accounts[i];
@@ -952,7 +951,7 @@ com.synckolab.settings.getAccount = function(config, name, create) {
* @param create set to true to create the account object if it doesnt exist
* @returns the account object and possibly null if create is false
*/
-com.synckolab.settings.getAccountIdx = function(config, name) {
+synckolab.settings.getAccountIdx = function(config, name) {
for(var i = 0; i < config.accounts.length; i++) {
if(config.accounts[i].name === name) {
return i;
@@ -964,8 +963,8 @@ com.synckolab.settings.getAccountIdx = function(config, name) {
/**
* set the base information from the ui in the current conig object
*/
-com.synckolab.settings.getBaseInfo = function() {
- var conf = com.synckolab.settings.config;
+synckolab.settings.getBaseInfo = function() {
+ var conf = synckolab.settings.config;
conf.hideFolder = document.getElementById("hideFolder").checked;
conf.debugLevel = document.getElementById("debugLevel").value;
conf.closeWindow = document.getElementById("closeWindow").checked;
@@ -978,26 +977,26 @@ com.synckolab.settings.getBaseInfo = function() {
* It is based on Account+Type+Config name
* @returns null if not found, otherwise the config sub-object
*/
-com.synckolab.settings.getActiveConfig = function() {
+synckolab.settings.getActiveConfig = function() {
// nothing to save back
- if(!com.synckolab.settings.activeType || !com.synckolab.settings.activeAccount || !com.synckolab.settings.activeConfig) {
+ if(!synckolab.settings.activeType || !synckolab.settings.activeAccount || !synckolab.settings.activeConfig) {
return null;
}
// get the right tree in the configuration object
- var conf = com.synckolab.settings.config;
- var account = com.synckolab.settings.getAccount(conf, com.synckolab.settings.activeAccount, true);
+ var conf = synckolab.settings.config;
+ var account = synckolab.settings.getAccount(conf, synckolab.settings.activeAccount, true);
var config = null;
- for (var i=0; i < account[com.synckolab.settings.activeType].length; i++) {
- if(account[com.synckolab.settings.activeType][i].name === com.synckolab.settings.activeConfig) {
- config = account[com.synckolab.settings.activeType][i];
+ for (var i=0; i < account[synckolab.settings.activeType].length; i++) {
+ if(account[synckolab.settings.activeType][i].name === synckolab.settings.activeConfig) {
+ config = account[synckolab.settings.activeType][i];
break;
}
}
if(config === null) {
- config = { name: com.synckolab.settings.activeConfig };
- account[com.synckolab.settings.activeType].push(config);
+ config = { name: synckolab.settings.activeConfig };
+ account[synckolab.settings.activeType].push(config);
}
return config;
@@ -1006,21 +1005,21 @@ com.synckolab.settings.getActiveConfig = function() {
/**
* set the configuration of the open contact/calendar/task info
*/
-com.synckolab.settings.getInfo = function() {
+synckolab.settings.getInfo = function() {
// nothing to save back
- if(!com.synckolab.settings.activeType || !com.synckolab.settings.activeAccount || !com.synckolab.settings.activeConfig) {
+ if(!synckolab.settings.activeType || !synckolab.settings.activeAccount || !synckolab.settings.activeConfig) {
return;
}
- if(com.synckolab.settings.activeType !== "contact" && com.synckolab.settings.activeType !== "calendar" && com.synckolab.settings.activeType !== "task") {
+ if(synckolab.settings.activeType !== "contact" && synckolab.settings.activeType !== "calendar" && synckolab.settings.activeType !== "task") {
return;
}
- var config = com.synckolab.settings.getActiveConfig();
+ var config = synckolab.settings.getActiveConfig();
// fill all fields
- var prefix = com.synckolab.settings.activeType;
+ var prefix = synckolab.settings.activeType;
// the address book / calendar
config.source = document.getElementById(prefix + "URL").value;
@@ -1048,8 +1047,8 @@ com.synckolab.settings.getInfo = function() {
* function for the folder listing. once a folder is selected this is called and sets the new folder in
* the active config.
*/
-com.synckolab.settings.setFolder = function (uri) {
- var config = com.synckolab.settings.getActiveConfig();
+synckolab.settings.setFolder = function (uri) {
+ var config = synckolab.settings.getActiveConfig();
if (config === null)
{
return;
@@ -1057,7 +1056,7 @@ com.synckolab.settings.setFolder = function (uri) {
config.folderPath = uri;
};
-com.synckolab.settings.fillAccountInfo = function(acctName) {
+synckolab.settings.fillAccountInfo = function(acctName) {
};
@@ -1067,13 +1066,13 @@ com.synckolab.settings.fillAccountInfo = function(acctName) {
* @param acctName the account name
* @param confName the configuration name
*/
-com.synckolab.settings.fillInfo = function(type, acctName, confName) {
- com.synckolab.settings.activeType = type;
- com.synckolab.settings.activeAccount = acctName;
- com.synckolab.settings.activeConfig = confName;
+synckolab.settings.fillInfo = function(type, acctName, confName) {
+ synckolab.settings.activeType = type;
+ synckolab.settings.activeAccount = acctName;
+ synckolab.settings.activeConfig = confName;
- var config = com.synckolab.settings.getActiveConfig();
- var prefix = com.synckolab.settings.activeType;
+ var config = synckolab.settings.getActiveConfig();
+ var prefix = synckolab.settings.activeType;
var sCurFolder = config.folderPath;
if (sCurFolder !== null && sCurFolder !== "")
@@ -1163,24 +1162,24 @@ com.synckolab.settings.fillInfo = function(type, acctName, confName) {
/**
* adds a new configuration to an account
*/
-com.synckolab.settings.addConfig = function() {
- switch(com.synckolab.settings.activeType) {
+synckolab.settings.addConfig = function() {
+ switch(synckolab.settings.activeType) {
case "contact":
case "calendar":
case "task":
// make sure active config is NOT set (we are creating here)
- com.synckolab.settings.activeConfig = null;
+ synckolab.settings.activeConfig = null;
var retVals = { name: null };
var res = window.openDialog("chrome://synckolab/content/wndNewConfigType.xul",
"newCfg",
- "modal,width=360,height=200,resizable=0", retVals, com.synckolab.settings.activeType, com.synckolab.settings.config);
+ "modal,width=360,height=200,resizable=0", retVals, synckolab.settings.activeType, synckolab.settings.config);
if(retVals.name !== null && retVals.name.length > 2) {
- var acct = com.synckolab.settings.getAccount(com.synckolab.settings.config, com.synckolab.settings.activeAccount, true);
+ var acct = synckolab.settings.getAccount(synckolab.settings.config, synckolab.settings.activeAccount, true);
// check the configs
- for(var i = 0; i < acct[com.synckolab.settings.activeType].length; i++) {
+ for(var i = 0; i < acct[synckolab.settings.activeType].length; i++) {
// already go the configuration
- if(retVals.name === acct[com.synckolab.settings.activeType][i].name) {
+ if(retVals.name === acct[synckolab.settings.activeType][i].name) {
return;
}
}
@@ -1190,18 +1189,18 @@ com.synckolab.settings.addConfig = function() {
};
// read all the base settings
- for(var n in com.synckolab.config.baseSetting) {
+ for(var n in synckolab.config.baseSetting) {
// skip unwanted prototypes (without type)
- if(com.synckolab.config.baseSetting[n].type >= 0) {
- cConf[n] = com.synckolab.config.baseSetting[n].def;
+ if(synckolab.config.baseSetting[n].type >= 0) {
+ cConf[n] = synckolab.config.baseSetting[n].def;
}
}
- acct[com.synckolab.settings.activeType].push(cConf);
+ acct[synckolab.settings.activeType].push(cConf);
- com.synckolab.tools.logMessage("New config: " + com.synckolab.settings.config.toSource(), com.synckolab.global.LOG_DEBUG);
+ synckolab.tools.logMessage("New config: " + synckolab.settings.config.toSource(), synckolab.global.LOG_DEBUG);
// repaint the tree and select the newly created node
- com.synckolab.settings.repaintConfigTree("tab-"+com.synckolab.settings.activeType+"-" + com.synckolab.settings.activeAccount + "-" + retVals.name);
+ synckolab.settings.repaintConfigTree("tab-"+synckolab.settings.activeType+"-" + synckolab.settings.activeAccount + "-" + retVals.name);
}
}
};
@@ -1209,33 +1208,33 @@ com.synckolab.settings.addConfig = function() {
/**
* adds a new configuration to an account
*/
-com.synckolab.settings.delConfig = function() {
- switch(com.synckolab.settings.activeType) {
+synckolab.settings.delConfig = function() {
+ switch(synckolab.settings.activeType) {
case "contact":
case "calendar":
case "task":
- if (confirm(this.strBundle.getFormattedString("configDelete", [com.synckolab.settings.activeConfig]))) {
+ if (confirm(this.strBundle.getFormattedString("configDelete", [synckolab.settings.activeConfig]))) {
- var acctIdx = com.synckolab.settings.getAccountIdx(com.synckolab.settings.config, com.synckolab.settings.activeAccount);
- var acct = com.synckolab.settings.config.accounts[acctIdx];
+ var acctIdx = synckolab.settings.getAccountIdx(synckolab.settings.config, synckolab.settings.activeAccount);
+ var acct = synckolab.settings.config.accounts[acctIdx];
// update the configs
var configs = [];
- for(var i = 0; i < acct[com.synckolab.settings.activeType].length; i++) {
+ for(var i = 0; i < acct[synckolab.settings.activeType].length; i++) {
// already go the configuration
- if(com.synckolab.settings.activeConfig !== acct[com.synckolab.settings.activeType][i].name) {
- configs.push(acct[com.synckolab.settings.activeType][i]);
+ if(synckolab.settings.activeConfig !== acct[synckolab.settings.activeType][i].name) {
+ configs.push(acct[synckolab.settings.activeType][i]);
}
}
- acct[com.synckolab.settings.activeType] = configs;
+ acct[synckolab.settings.activeType] = configs;
- com.synckolab.settings.activeConfig = null;
- com.synckolab.settings.activeType = null;
+ synckolab.settings.activeConfig = null;
+ synckolab.settings.activeType = null;
// repaint the tree and select the parent
- com.synckolab.settings.repaintConfigTree();
+ synckolab.settings.repaintConfigTree();
// select root
- com.synckolab.settings.setSyncPrefView("Welcome-Welcome");
+ synckolab.settings.setSyncPrefView("Welcome-Welcome");
return;
@@ -1248,12 +1247,12 @@ com.synckolab.settings.delConfig = function() {
* @param config the config name
* @param type CALENDAR|TASK|CONTACT + FOLDER
*/
-com.synckolab.settings.resetConfiguration = function (account, type, config)
+synckolab.settings.resetConfiguration = function (account, type, config)
{
- com.synckolab.tools.logMessage("Resetting " + account + "!", com.synckolab.global.LOG_INFO);
+ synckolab.tools.logMessage("Resetting " + account + "!", synckolab.global.LOG_INFO);
var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
- file.append("synckolab." + com.synckolab.tools.text.fixNameToMiniCharset(account) + "." + type + "." + config + ".hdb");
+ file.append("synckolab." + synckolab.tools.text.fixNameToMiniCharset(account) + "." + type + "." + config + ".hdb");
if (file.exists()) {
file.remove(true);
}
@@ -1265,7 +1264,7 @@ com.synckolab.settings.resetConfiguration = function (account, type, config)
return;
}
- file.append(com.synckolab.tools.text.fixNameToMiniCharset(account));
+ file.append(synckolab.tools.text.fixNameToMiniCharset(account));
if (file.exists())
{
file.append(type + "_" + config);
diff --git a/src/chrome/content/synckolab/wndConfig.xul b/src/chrome/content/synckolab/wndConfig.xul
index 354897f..4491cff 100644
--- a/src/chrome/content/synckolab/wndConfig.xul
+++ b/src/chrome/content/synckolab/wndConfig.xul
@@ -4,7 +4,7 @@
<!DOCTYPE loc SYSTEM "chrome://synckolab/locale/synckolab.dtd">
-<dialog id="syncKolabConfigDlg" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="com.synckolab.settings.init();" buttons="accept,cancel" ondialogaccept="return com.synckolab.settings.savePrefs();" persist="screenX screenY" width="0" title="SyncKolab 2.0.3">
+<dialog id="syncKolabConfigDlg" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="synckolab.settings.init();" buttons="accept,cancel" ondialogaccept="return synckolab.settings.savePrefs();" persist="screenX screenY" width="0" title="SyncKolab 2.0.3">
<script type="application/x-javascript" src="chrome://synckolab/content/calendarTools.js" />
<script type="application/x-javascript" src="chrome://synckolab/content/addressbookTools.js"/>
@@ -23,7 +23,7 @@
<hbox flex="1">
<vbox flex="1">
<!-- Tree with all configurations -->
- <tree class="synckolab" hidecolumnpicker="true" id="configTree" flex="1" onselect="com.synckolab.settings.setSyncPrefView(this.view.getItemAtIndex(this.currentIndex).firstChild.firstChild.getAttribute('value'));" width="150">
+ <tree class="synckolab" hidecolumnpicker="true" id="configTree" flex="1" onselect="synckolab.settings.setSyncPrefView(this.view.getItemAtIndex(this.currentIndex).firstChild.firstChild.getAttribute('value'));" width="150">
<treecols>
<treecol id="name" flex="1" primary="true" />
</treecols>
@@ -32,9 +32,9 @@
</treechildren>
</tree>
<hbox>
- <button id="newConfig" label="&synckolab.settings.add;" orient="vertical" oncommand="com.synckolab.settings.addConfig();" />
- <button id="loadConfig" label="&synckolab.settings.load;" orient="vertical" oncommand="com.synckolab.settings.loadConfig();" />
- <button id="delConfig" label="&synckolab.settings.del;" orient="vertical" oncommand="com.synckolab.settings.delConfig();" />
+ <button id="newConfig" label="&synckolab.settings.add;" orient="vertical" oncommand="synckolab.settings.addConfig();" />
+ <button id="loadConfig" label="&synckolab.settings.load;" orient="vertical" oncommand="synckolab.settings.loadConfig();" />
+ <button id="delConfig" label="&synckolab.settings.del;" orient="vertical" oncommand="synckolab.settings.delConfig();" />
</hbox>
</vbox>
<splitter collapse="before" resizeafter="farthest">
@@ -54,19 +54,19 @@
</description>
<hbox>
<label value="&synckolab.settings.Updates;" />
- <label class="text-link" onclick="com.synckolab.tools.launchUrl('http://www.gargan.org')">www.gargan.org</label>
+ <label class="text-link" onclick="synckolab.tools.launchUrl('http://www.gargan.org')">www.gargan.org</label>
</hbox>
<description style="width: 300px">
&synckolab.settings.DescKolabServer;
</description>
- <label class="text-link" onclick="com.synckolab.tools.launchUrl('http://www.kolab.org')">www.kolab.org</label>
+ <label class="text-link" onclick="synckolab.tools.launchUrl('http://www.kolab.org')">www.kolab.org</label>
<description style="width: 300px" flex="1">&synckolab.settings.DescOtherClients;</description>
- <label class="text-link" onclick="com.synckolab.tools.launchUrl('http://www.kontact.org')">KDE Client (Kontact) (GPL)</label>
- <label class="text-link" onclick="com.synckolab.tools.launchUrl('http://www.horde.org')">Horde Webmail (GPL)</label>
- <label class="text-link" onclick="com.synckolab.tools.launchUrl('http://code.google.com/p/kolab-android/')">Kolab Android</label>
+ <label class="text-link" onclick="synckolab.tools.launchUrl('http://www.kontact.org')">KDE Client (Kontact) (GPL)</label>
+ <label class="text-link" onclick="synckolab.tools.launchUrl('http://www.horde.org')">Horde Webmail (GPL)</label>
+ <label class="text-link" onclick="synckolab.tools.launchUrl('http://code.google.com/p/kolab-android/')">Kolab Android</label>
<separator class="thin" />
<hbox>
@@ -86,7 +86,7 @@
<checkbox id="hideFolder" style="width: 300px" label="&synckolab.settings.hideFolder;"/>
<checkbox id="closeWindow" style="width: 300px" label="&synckolab.settings.CloseWindow;" />
- <button label="&synckolab.settings.saveAll;" oncommand="com.synckolab.settings.saveAllConfig();" />
+ <button label="&synckolab.settings.saveAll;" oncommand="synckolab.settings.saveAllConfig();" />
</vbox>
</tabpanel>
<tabpanel id="accountTab" style="border:0px solid #000" flex="1">
@@ -95,7 +95,7 @@
<label value="&synckolab.settings.SyncKolabHeader;" style="font-size: 16pt;" />
</hbox>
<label value="&synckolab.settings.Updates;" />
- <label class="text-link" onclick="com.synckolab.tools.launchUrl('http://www.gargan.org')">www.gargan.org</label>
+ <label class="text-link" onclick="synckolab.tools.launchUrl('http://www.gargan.org')">www.gargan.org</label>
<separator class="thin" />
</vbox>
</tabpanel>
@@ -108,7 +108,7 @@
</menulist>
<separator class="thin" />
- <tree class="synckolab" flex="7" id="contactImapFolder" rows="7" height="150" width="250" hidecolumnpicker="true" seltype="single" onselect="com.synckolab.settings.setFolder(this.view.getItemAtIndex(this.currentIndex).firstChild.firstChild.getAttribute('value'));">
+ <tree class="synckolab" flex="7" id="contactImapFolder" rows="7" height="150" width="250" hidecolumnpicker="true" seltype="single" onselect="synckolab.settings.setFolder(this.view.getItemAtIndex(this.currentIndex).firstChild.firstChild.getAttribute('value'));">
<treecols>
<treecol id="conFolder" label="&synckolab.settings.ContactFolder;" primary="true" flex="1" />
</treecols>
@@ -121,7 +121,7 @@
</menulist>
</hbox>
- <checkbox id="contactSync" label="&synckolab.settings.SyncContacts;" tooltiptext="&synckolab.settings.SyncContactsTip;" oncommand="com.synckolab.settings.setControlState('contact', this.checked)" />
+ <checkbox id="contactSync" label="&synckolab.settings.SyncContacts;" tooltiptext="&synckolab.settings.SyncContactsTip;" oncommand="synckolab.settings.setControlState('contact', this.checked)" />
<checkbox id="contactSyncListenerImap" label="&synckolab.settings.SyncListener;"/>
<checkbox id="contactSaveToImap" label="&synckolab.settings.SaveToImap;" tooltiptext="&synckolab.settings.SaveToImapTip;" />
@@ -145,7 +145,7 @@
<!-- <textbox id="contactSyncInterval" maxlength="5" style="width: 50px" /> -->
<!-- <label value="&synckolab.settings.SyncIntervalMinutes;" /> -->
<!-- </hbox> -->
- <button label="&synckolab.settings.saveSingle;" oncommand="com.synckolab.settings.saveSingleConfig();" />
+ <button label="&synckolab.settings.saveSingle;" oncommand="synckolab.settings.saveSingleConfig();" />
</vbox>
@@ -161,7 +161,7 @@
<separator class="thin" />
- <tree class="synckolab" flex="7" id="calendarImapFolder" rows="7" height="150" width="250" hidecolumnpicker="true" seltype="single" onselect="com.synckolab.settings.setFolder(this.view.getItemAtIndex(this.currentIndex).firstChild.firstChild.getAttribute('value'));">
+ <tree class="synckolab" flex="7" id="calendarImapFolder" rows="7" height="150" width="250" hidecolumnpicker="true" seltype="single" onselect="synckolab.settings.setFolder(this.view.getItemAtIndex(this.currentIndex).firstChild.firstChild.getAttribute('value'));">
<treecols>
<treecol id="calFolder" label="&synckolab.settings.CalendarFolder;" primary="true" flex="1" />
</treecols>
@@ -176,7 +176,7 @@
<textbox id="calendarSyncTimeframe" maxlength="4" style="width: 30px" />
<label value="&synckolab.settings.TimeframeSyncDays;" />
</hbox>
- <checkbox id="calendarSync" label="&synckolab.settings.SyncCalendar;" tooltiptext="&synckolab.settings.SyncCalendarTip;" oncommand="com.synckolab.settings.setControlState('calendar', this.checked)" />
+ <checkbox id="calendarSync" label="&synckolab.settings.SyncCalendar;" tooltiptext="&synckolab.settings.SyncCalendarTip;" oncommand="synckolab.settings.setControlState('calendar', this.checked)" />
<checkbox id="calendarSyncListenerImap" label="&synckolab.settings.SyncListener;"/>
<checkbox id="calendarSaveToImap" label="&synckolab.settings.SaveToImap;" tooltiptext="&synckolab.settings.SaveToImapTip;" />
@@ -213,7 +213,7 @@
<separator class="thin" />
- <tree class="synckolab" flex="7" id="taskImapFolder" rows="7" height="150" width="250" hidecolumnpicker="true" seltype="single" onselect="com.synckolab.settings.setFolder(this.view.getItemAtIndex(this.currentIndex).firstChild.firstChild.getAttribute('value'));">
+ <tree class="synckolab" flex="7" id="taskImapFolder" rows="7" height="150" width="250" hidecolumnpicker="true" seltype="single" onselect="synckolab.settings.setFolder(this.view.getItemAtIndex(this.currentIndex).firstChild.firstChild.getAttribute('value'));">
<treecols>
<treecol id="taskFolder" label="&synckolab.settings.TaskFolder;" primary="true" flex="1" />
</treecols>
@@ -229,7 +229,7 @@
<textbox id="taskSyncTimeframe" maxlength="4" style="width: 30px" />
<label value="&synckolab.settings.TimeframeSyncDays;" />
</hbox>
- <checkbox id="taskSync" label="&synckolab.settings.SyncTasks;" tooltiptext="&synckolab.settings.SyncTasksTip;" oncommand="com.synckolab.settings.setControlState('task', this.checked)" />
+ <checkbox id="taskSync" label="&synckolab.settings.SyncTasks;" tooltiptext="&synckolab.settings.SyncTasksTip;" oncommand="synckolab.settings.setControlState('task', this.checked)" />
<checkbox id="taskSyncListenerImap" label="&synckolab.settings.SyncListener;"/>
<checkbox id="taskSaveToImap" label="&synckolab.settings.SaveToImap;" tooltiptext="&synckolab.settings.SaveToImapTip;" />
diff --git a/src/chrome/content/synckolab/wndNewConfigType.xul b/src/chrome/content/synckolab/wndNewConfigType.xul
index 42659be..b08e786 100644
--- a/src/chrome/content/synckolab/wndNewConfigType.xul
+++ b/src/chrome/content/synckolab/wndNewConfigType.xul
@@ -12,8 +12,8 @@
<script>
function checkConfigName(name)
{
- if(name !== com.synckolab.tools.text.fixNameToMiniCharset(name)) {
- document.getElementById("configName").value = com.synckolab.tools.text.fixNameToMiniCharset(name);
+ if(name !== synckolab.tools.text.fixNameToMiniCharset(name)) {
+ document.getElementById("configName").value = synckolab.tools.text.fixNameToMiniCharset(name);
}
}
@@ -25,7 +25,7 @@
return false;
}
- if(name !== com.synckolab.tools.text.fixNameToMiniCharset(name)) {
+ if(name !== synckolab.tools.text.fixNameToMiniCharset(name)) {
return false;
}
var retVals = window.arguments[0];
diff --git a/test/lib/env.rhino.1.2.js b/test/lib/env.rhino.1.2.js
new file mode 100644
index 0000000..2351d01
--- /dev/null
+++ b/test/lib/env.rhino.1.2.js
@@ -0,0 +1,13989 @@
+/*
+ * Envjs core-env.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+var Envjs = function(){
+ var i,
+ name,
+ override = function(){
+ for(i=0;i<arguments.length;i++){
+ for ( name in arguments[i] ) {
+ var g = arguments[i].__lookupGetter__(name),
+ s = arguments[i].__lookupSetter__(name);
+ if ( g || s ) {
+ if ( g ) { Envjs.__defineGetter__(name, g); }
+ if ( s ) { Envjs.__defineSetter__(name, s); }
+ } else {
+ Envjs[name] = arguments[i][name];
+ }
+ }
+ }
+ };
+ if(arguments.length === 1 && typeof(arguments[0]) == 'string'){
+ window.location = arguments[0];
+ }else if (arguments.length === 1 && typeof(arguments[0]) == "object"){
+ override(arguments[0]);
+ }else if(arguments.length === 2 && typeof(arguments[0]) == 'string'){
+ override(arguments[1]);
+ window.location = arguments[0];
+ }
+ return;
+},
+__this__ = this;
+
+//eg "Mozilla"
+Envjs.appCodeName = "Envjs";
+
+//eg "Gecko/20070309 Firefox/2.0.0.3"
+Envjs.appName = "Resig/20070309 PilotFish/1.2.13";
+
+Envjs.version = "1.6";//?
+Envjs.revision = '';
+/*
+ * Envjs core-env.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+//CLOSURE_START
+(function(){
+
+
+
+
+
+/**
+ * @author john resig
+ */
+// Helper method for extending one object with another.
+function __extend__(a,b) {
+ for ( var i in b ) {
+ var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
+ if ( g || s ) {
+ if ( g ) { a.__defineGetter__(i, g); }
+ if ( s ) { a.__defineSetter__(i, s); }
+ } else {
+ a[i] = b[i];
+ }
+ } return a;
+}
+
+/**
+ * Writes message to system out
+ * @param {String} message
+ */
+Envjs.log = function(message){};
+
+/**
+ * Constants providing enumerated levels for logging in modules
+ */
+Envjs.DEBUG = 1;
+Envjs.INFO = 2;
+Envjs.WARN = 3;
+Envjs.ERROR = 3;
+Envjs.NONE = 3;
+
+/**
+ * Writes error info out to console
+ * @param {Error} e
+ */
+Envjs.lineSource = function(e){};
+
+
+/**
+ * TODO: used in ./event/eventtarget.js
+ * @param {Object} event
+ */
+Envjs.defaultEventBehaviors = {};
+
+
+/**
+ * describes which script src values will trigger Envjs to load
+ * the script like a browser would
+ */
+Envjs.scriptTypes = {
+ "text/javascript" :false,
+ "text/envjs" :true
+};
+
+/**
+ * will be called when loading a script throws an error
+ * @param {Object} script
+ * @param {Object} e
+ */
+Envjs.onScriptLoadError = function(script, e){
+ console.log('error loading script %s %s', script, e);
+};
+
+
+/**
+ * load and execute script tag text content
+ * @param {Object} script
+ */
+Envjs.loadInlineScript = function(script){
+ var tmpFile;
+ tmpFile = Envjs.writeToTempFile(script.text, 'js') ;
+ load(tmpFile);
+};
+
+/**
+ * Should evaluate script in some context
+ * @param {Object} context
+ * @param {Object} source
+ * @param {Object} name
+ */
+Envjs.eval = function(context, source, name){};
+
+
+/**
+ * Executes a script tag
+ * @param {Object} script
+ * @param {Object} parser
+ */
+Envjs.loadLocalScript = function(script){
+ //console.log("loading script %s", script);
+ var types,
+ src,
+ i,
+ base,
+ filename,
+ xhr;
+
+ if(script.type){
+ types = script.type.split(";");
+ for(i=0;i<types.length;i++){
+ if(Envjs.scriptTypes[types[i]]){
+ //ok this script type is allowed
+ break;
+ }
+ if(i+1 == types.length){
+ //console.log('wont load script type %s', script.type);
+ return false;
+ }
+ }
+ }
+
+ try{
+ //console.log('handling inline scripts');
+ if(!script.src.length){
+ Envjs.loadInlineScript(script);
+ return true;
+ }
+ }catch(e){
+ //Envjs.error("Error loading script.", e);
+ Envjs.onScriptLoadError(script, e);
+ return false;
+ }
+
+
+ //console.log("loading allowed external script %s", script.src);
+
+ //lets you register a function to execute
+ //before the script is loaded
+ if(Envjs.beforeScriptLoad){
+ for(src in Envjs.beforeScriptLoad){
+ if(script.src.match(src)){
+ Envjs.beforeScriptLoad[src](script);
+ }
+ }
+ }
+ base = "" + script.ownerDocument.location;
+ //filename = Envjs.uri(script.src.match(/([^\?#]*)/)[1], base );
+ //console.log('loading script from base %s', base);
+ filename = Envjs.uri(script.src, base);
+ try {
+ xhr = new XMLHttpRequest();
+ xhr.open("GET", filename, false/*syncronous*/);
+ //console.log("loading external script %s", filename);
+ xhr.onreadystatechange = function(){
+ //console.log("readyState %s", xhr.readyState);
+ if(xhr.readyState === 4){
+ Envjs.eval(
+ script.ownerDocument.ownerWindow,
+ xhr.responseText,
+ filename
+ );
+ }
+ };
+ xhr.send(null, false);
+ } catch(e) {
+ console.log("could not load script %s \n %s", filename, e );
+ Envjs.onScriptLoadError(script, e);
+ return false;
+ }
+ //lets you register a function to execute
+ //after the script is loaded
+ if(Envjs.afterScriptLoad){
+ for(src in Envjs.afterScriptLoad){
+ if(script.src.match(src)){
+ Envjs.afterScriptLoad[src](script);
+ }
+ }
+ }
+ return true;
+};
+
+
+/**
+ * An 'image' was requested by the document.
+ *
+ * - During inital parse of a <link>
+ * - Via an innerHTML parse of a <link>
+ * - A modificiation of the 'src' attribute of an Image/HTMLImageElement
+ *
+ * NOTE: this is optional API. If this doesn't exist then the default
+ * 'loaded' event occurs.
+ *
+ * @param node {Object} the <img> node
+ * @param node the src value
+ * @return 'true' to indicate the 'load' succeed, false otherwise
+ */
+Envjs.loadImage = function(node, src) {
+ return true;
+};
+
+
+/**
+ * A 'link' was requested by the document. Typically this occurs when:
+ * - During inital parse of a <link>
+ * - Via an innerHTML parse of a <link>
+ * - A modificiation of the 'href' attribute on a <link> node in the tree
+ *
+ * @param node {Object} is the link node in question
+ * @param href {String} is the href.
+ *
+ * Return 'true' to indicate that the 'load' was successful, or false
+ * otherwise. The appropriate event is then triggered.
+ *
+ * NOTE: this is optional API. If this doesn't exist then the default
+ * 'loaded' event occurs
+ */
+Envjs.loadLink = function(node, href) {
+ return true;
+};
+
+(function(){
+
+
+/*
+ * cookie handling
+ * Private internal helper class used to save/retreive cookies
+ */
+
+/**
+ * Specifies the location of the cookie file
+ */
+Envjs.cookieFile = function(){
+ return 'file://'+Envjs.homedir+'/.cookies';
+};
+
+/**
+ * saves cookies to a local file
+ * @param {Object} htmldoc
+ */
+Envjs.saveCookies = function(){
+ var cookiejson = JSON.stringify(Envjs.cookies.peristent,null,'\t');
+ //console.log('persisting cookies %s', cookiejson);
+ Envjs.writeToFile(cookiejson, Envjs.cookieFile());
+};
+
+/**
+ * loads cookies from a local file
+ * @param {Object} htmldoc
+ */
+Envjs.loadCookies = function(){
+ var cookiejson,
+ js;
+ try{
+ cookiejson = Envjs.readFromFile(Envjs.cookieFile())
+ js = JSON.parse(cookiejson, null, '\t');
+ }catch(e){
+ //console.log('failed to load cookies %s', e);
+ js = {};
+ }
+ return js;
+};
+
+Envjs.cookies = {
+ persistent:{
+ //domain - key on domain name {
+ //path - key on path {
+ //name - key on name {
+ //value : cookie value
+ //other cookie properties
+ //}
+ //}
+ //}
+ //expire - provides a timestamp for expiring the cookie
+ //cookie - the cookie!
+ },
+ temporary:{//transient is a reserved word :(
+ //like above
+ }
+};
+
+var __cookies__;
+
+//HTMLDocument cookie
+Envjs.setCookie = function(url, cookie){
+ var i,
+ index,
+ name,
+ value,
+ properties = {},
+ attr,
+ attrs;
+ url = Envjs.urlsplit(url);
+ if(cookie)
+ attrs = cookie.split(";");
+ else
+ return;
+
+ //for now the strategy is to simply create a json object
+ //and post it to a file in the .cookies.js file. I hate parsing
+ //dates so I decided not to implement support for 'expires'
+ //(which is deprecated) and instead focus on the easier 'max-age'
+ //(which succeeds 'expires')
+ cookie = {};//keyword properties of the cookie
+ cookie['domain'] = url.hostname;
+ cookie['path'] = url.path||'/';
+ for(i=0;i<attrs.length;i++){
+ index = attrs[i].indexOf("=");
+ if(index > -1){
+ name = __trim__(attrs[i].slice(0,index));
+ value = __trim__(attrs[i].slice(index+1));
+ if(name=='max-age'){
+ //we'll have to when to check these
+ //and garbage collect expired cookies
+ cookie[name] = parseInt(value, 10);
+ } else if( name == 'domain' ){
+ if(__domainValid__(url, value)){
+ cookie['domain'] = value;
+ }
+ } else if( name == 'path' ){
+ //not sure of any special logic for path
+ cookie['path'] = value;
+ } else {
+ //its not a cookie keyword so store it in our array of properties
+ //and we'll serialize individually in a moment
+ properties[name] = value;
+ }
+ }else{
+ if( attrs[i] == 'secure' ){
+ cookie[attrs[i]] = true;
+ }
+ }
+ }
+ if(!('max-age' in cookie)){
+ //it's a transient cookie so it only lasts as long as
+ //the window.location remains the same (ie in-memory cookie)
+ __mergeCookie__(Envjs.cookies.temporary, cookie, properties);
+ }else{
+ //the cookie is persistent
+ __mergeCookie__(Envjs.cookies.persistent, cookie, properties);
+ Envjs.saveCookies();
+ }
+};
+
+function __domainValid__(url, value){
+ var i,
+ domainParts = url.hostname.split('.').reverse(),
+ newDomainParts = value.split('.').reverse();
+ if(newDomainParts.length > 1){
+ for(i=0;i<newDomainParts.length;i++){
+ if(!(newDomainParts[i] == domainParts[i])){
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+};
+
+Envjs.getCookies = function(url){
+ //The cookies that are returned must belong to the same domain
+ //and be at or below the current window.location.path. Also
+ //we must check to see if the cookie was set to 'secure' in which
+ //case we must check our current location.protocol to make sure it's
+ //https:
+ var persisted;
+ url = Envjs.urlsplit(url);
+ if(!__cookies__){
+ try{
+ __cookies__ = true;
+ try{
+ persisted = Envjs.loadCookies();
+ }catch(e){
+ //fail gracefully
+ //console.log('%s', e);
+ }
+ if(persisted){
+ __extend__(Envjs.cookies.persistent, persisted);
+ }
+ //console.log('set cookies for doc %s', doc.baseURI);
+ }catch(e){
+ console.log('cookies not loaded %s', e)
+ };
+ }
+ var temporary = __cookieString__(Envjs.cookies.temporary, url),
+ persistent = __cookieString__(Envjs.cookies.persistent, url);
+ //console.log('temporary cookies: %s', temporary);
+ //console.log('persistent cookies: %s', persistent);
+ return temporary + persistent;
+};
+
+function __cookieString__(cookies, url) {
+ var cookieString = "",
+ domain,
+ path,
+ name,
+ i=0;
+ for (domain in cookies) {
+ // check if the cookie is in the current domain (if domain is set)
+ // console.log('cookie domain %s', domain);
+ if (domain == "" || domain == url.hostname) {
+ for (path in cookies[domain]) {
+ // console.log('cookie domain path %s', path);
+ // make sure path is at or below the window location path
+ if (path == "/" || url.path.indexOf(path) > -1) {
+ for (name in cookies[domain][path]) {
+ // console.log('cookie domain path name %s', name);
+ cookieString +=
+ ((i++ > 0)?'; ':'') +
+ name + "=" +
+ cookies[domain][path][name].value;
+ }
+ }
+ }
+ }
+ }
+ return cookieString;
+};
+
+function __mergeCookie__(target, cookie, properties){
+ var name, now;
+ if(!target[cookie.domain]){
+ target[cookie.domain] = {};
+ }
+ if(!target[cookie.domain][cookie.path]){
+ target[cookie.domain][cookie.path] = {};
+ }
+ for(name in properties){
+ now = new Date().getTime();
+ target[cookie.domain][cookie.path][name] = {
+ "value":properties[name],
+ "secure":cookie.secure,
+ "max-age":cookie['max-age'],
+ "date-created":now,
+ "expiration":(cookie['max-age']===0) ?
+ 0 :
+ now + cookie['max-age']
+ };
+ //console.log('cookie is %o',target[cookie.domain][cookie.path][name]);
+ }
+};
+
+})();//end cookies
+/*
+ http://www.JSON.org/json2.js
+ 2008-07-15
+
+ Public Domain.
+
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+ See http://www.JSON.org/js.html
+
+
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
+
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
+*/
+try{ JSON; }catch(e){
+JSON = function () {
+
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ Date.prototype.toJSON = function (key) {
+
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
+
+ String.prototype.toJSON = function (key) {
+ return String(this);
+ };
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapeable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+
+ escapeable.lastIndex = 0;
+ return escapeable.test(string) ?
+ '"' + string.replace(escapeable, function (a) {
+ var c = meta[a];
+ if (typeof c === 'string') {
+ return c;
+ }
+ return '\\u' + ('0000' +
+ (+(a.charCodeAt(0))).toString(16)).slice(-4);
+ }) + '"' :
+ '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+
+ return String(value);
+
+ case 'object':
+
+ if (!value) {
+ return 'null';
+ }
+ gap += indent;
+ partial = [];
+
+ if (typeof value.length === 'number' &&
+ !(value.propertyIsEnumerable('length'))) {
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+ v = partial.length === 0 ? '[]' :
+ gap ? '[\n' + gap +
+ partial.join(',\n' + gap) + '\n' +
+ mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ k = rep[i];
+ if (typeof k === 'string') {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+
+ for (k in value) {
+ if (Object.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+ v = partial.length === 0 ? '{}' :
+ gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
+ mind + '}' : '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+ return {
+ stringify: function (value, replacer, space) {
+
+ var i;
+ gap = '';
+ indent = '';
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+ return str('', {'': value});
+ },
+
+
+ parse: function (text, reviver) {
+ var j;
+ function walk(holder, key) {
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }
+
+ cx.lastIndex = 0;
+ if (cx.test(text)) {
+ text = text.replace(cx, function (a) {
+ return '\\u' + ('0000' +
+ (+(a.charCodeAt(0))).toString(16)).slice(-4);
+ });
+ }
+
+
+ if (/^[\],:{}\s]*$/.
+test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
+replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
+replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+ j = eval('(' + text + ')');
+
+ return typeof reviver === 'function' ?
+ walk({'': j}, '') : j;
+ }
+
+ throw new SyntaxError('JSON.parse');
+ }
+ };
+}();
+
+}
+
+/**
+ * synchronizes thread modifications
+ * @param {Function} fn
+ */
+Envjs.sync = function(fn){};
+
+/**
+ * sleep thread for specified duration
+ * @param {Object} millseconds
+ */
+Envjs.sleep = function(millseconds){};
+
+/**
+ * Interval to wait on event loop when nothing is happening
+ */
+Envjs.WAIT_INTERVAL = 20;//milliseconds
+
+/*
+ * Copyright (c) 2010 Nick Galbreath
+ * http://code.google.com/p/stringencoders/source/browse/#svn/trunk/javascript
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * url processing in the spirit of python's urlparse module
+ * see `pydoc urlparse` or
+ * http://docs.python.org/library/urlparse.html
+ *
+ * urlsplit: break apart a URL into components
+ * urlunsplit: reconsistute a URL from componets
+ * urljoin: join an absolute and another URL
+ * urldefrag: remove the fragment from a URL
+ *
+ * Take a look at the tests in urlparse-test.html
+ *
+ * On URL Normalization:
+ *
+ * urlsplit only does minor normalization the components Only scheme
+ * and hostname are lowercased urljoin does a bit more, normalizing
+ * paths with "." and "..".
+
+ * urlnormalize adds additional normalization
+ *
+ * * removes default port numbers
+ * http://abc.com:80/ -> http://abc.com/, etc
+ * * normalizes path
+ * http://abc.com -> http://abc.com/
+ * and other "." and ".." cleanups
+ * * if file, remove query and fragment
+ *
+ * It does not do:
+ * * normalizes escaped hex values
+ * http://abc.com/%7efoo -> http://abc.com/%7Efoo
+ * * normalize '+' <--> '%20'
+ *
+ * Differences with Python
+ *
+ * The javascript urlsplit returns a normal object with the following
+ * properties: scheme, netloc, hostname, port, path, query, fragment.
+ * All properties are read-write.
+ *
+ * In python, the resulting object is not a dict, but a specialized,
+ * read-only, and has alternative tuple interface (e.g. obj[0] ==
+ * obj.scheme). It's not clear why such a simple function requires
+ * a unique datastructure.
+ *
+ * urlunsplit in javascript takes an duck-typed object,
+ * { scheme: 'http', netloc: 'abc.com', ...}
+ * while in * python it takes a list-like object.
+ * ['http', 'abc.com'... ]
+ *
+ * For all functions, the javascript version use
+ * hostname+port if netloc is missing. In python
+ * hostname+port were always ignored.
+ *
+ * Similar functionality in different languages:
+ *
+ * http://php.net/manual/en/function.parse-url.php
+ * returns assocative array but cannot handle relative URL
+ *
+ * TODO: test allowfragments more
+ * TODO: test netloc missing, but hostname present
+ */
+
+var urlparse = {};
+
+// Unlike to be useful standalone
+//
+// NORMALIZE PATH with "../" and "./"
+// http://en.wikipedia.org/wiki/URL_normalization
+// http://tools.ietf.org/html/rfc3986#section-5.2.3
+//
+urlparse.normalizepath = function(path)
+{
+ if (!path || path === '/') {
+ return '/';
+ }
+
+ var parts = path.split('/');
+
+ var newparts = [];
+ // make sure path always starts with '/'
+ if (parts[0]) {
+ newparts.push('');
+ }
+
+ for (var i = 0; i < parts.length; ++i) {
+ if (parts[i] === '..') {
+ if (newparts.length > 1) {
+ newparts.pop();
+ } else {
+ newparts.push(parts[i]);
+ }
+ } else if (parts[i] != '.') {
+ newparts.push(parts[i]);
+ }
+ }
+
+ path = newparts.join('/');
+ if (!path) {
+ path = '/';
+ }
+ return path;
+};
+
+//
+// Does many of the normalizations that the stock
+// python urlsplit/urlunsplit/urljoin neglects
+//
+// Doesn't do hex-escape normalization on path or query
+// %7e -> %7E
+// Nor, '+' <--> %20 translation
+//
+urlparse.urlnormalize = function(url)
+{
+ var parts = urlparse.urlsplit(url);
+ switch (parts.scheme) {
+ case 'file':
+ // files can't have query strings
+ // and we don't bother with fragments
+ parts.query = '';
+ parts.fragment = '';
+ break;
+ case 'http':
+ case 'https':
+ // remove default port
+ if ((parts.scheme === 'http' && parts.port == 80) ||
+ (parts.scheme === 'https' && parts.port == 443)) {
+ parts.port = null;
+ // hostname is already lower case
+ parts.netloc = parts.hostname;
+ }
+ break;
+ default:
+ // if we don't have specific normalizations for this
+ // scheme, return the original url unmolested
+ return url;
+ }
+
+ // for [file|http|https]. Not sure about other schemes
+ parts.path = urlparse.normalizepath(parts.path);
+
+ return urlparse.urlunsplit(parts);
+};
+
+urlparse.urldefrag = function(url)
+{
+ var idx = url.indexOf('#');
+ if (idx == -1) {
+ return [ url, '' ];
+ } else {
+ return [ url.substr(0,idx), url.substr(idx+1) ];
+ }
+};
+
+urlparse.urlsplit = function(url, default_scheme, allow_fragments)
+{
+ var leftover;
+
+ if (typeof allow_fragments === 'undefined') {
+ allow_fragments = true;
+ }
+
+ // scheme (optional), host, port
+ var fullurl = /^([A-Za-z]+)?(:?\/\/)([0-9.\-A-Za-z]*)(?::(\d+))?(.*)$/;
+ // path, query, fragment
+ var parse_leftovers = /([^?#]*)?(?:\?([^#]*))?(?:#(.*))?$/;
+
+ var o = {};
+
+ var parts = url.match(fullurl);
+ if (parts) {
+ o.scheme = parts[1] || default_scheme || '';
+ o.hostname = parts[3].toLowerCase() || '';
+ o.port = parseInt(parts[4],10) || '';
+ // Probably should grab the netloc from regexp
+ // and then parse again for hostname/port
+
+ o.netloc = parts[3];
+ if (parts[4]) {
+ o.netloc += ':' + parts[4];
+ }
+
+ leftover = parts[5];
+ } else {
+ o.scheme = default_scheme || '';
+ o.netloc = '';
+ o.hostname = '';
+ leftover = url;
+ }
+ o.scheme = o.scheme.toLowerCase();
+
+ parts = leftover.match(parse_leftovers);
+
+ o.path = parts[1] || '';
+ o.query = parts[2] || '';
+
+ if (allow_fragments) {
+ o.fragment = parts[3] || '';
+ } else {
+ o.fragment = '';
+ }
+
+ return o;
+};
+
+urlparse.urlunsplit = function(o) {
+ var s = '';
+ if (o.scheme) {
+ s += o.scheme + '://';
+ }
+
+ if (o.netloc) {
+ if (s == '') {
+ s += '//';
+ }
+ s += o.netloc;
+ } else if (o.hostname) {
+ // extension. Python only uses netloc
+ if (s == '') {
+ s += '//';
+ }
+ s += o.hostname;
+ if (o.port) {
+ s += ':' + o.port;
+ }
+ }
+
+ if (o.path) {
+ s += o.path;
+ }
+
+ if (o.query) {
+ s += '?' + o.query;
+ }
+ if (o.fragment) {
+ s += '#' + o.fragment;
+ }
+ return s;
+};
+
+urlparse.urljoin = function(base, url, allow_fragments)
+{
+ if (typeof allow_fragments === 'undefined') {
+ allow_fragments = true;
+ }
+
+ var url_parts = urlparse.urlsplit(url);
+
+ // if url parts has a scheme (i.e. absolute)
+ // then nothing to do
+ if (url_parts.scheme) {
+ if (! allow_fragments) {
+ return url;
+ } else {
+ return urlparse.urldefrag(url)[0];
+ }
+ }
+ var base_parts = urlparse.urlsplit(base);
+
+ // copy base, only if not present
+ if (!base_parts.scheme) {
+ base_parts.scheme = url_parts.scheme;
+ }
+
+ // copy netloc, only if not present
+ if (!base_parts.netloc || !base_parts.hostname) {
+ base_parts.netloc = url_parts.netloc;
+ base_parts.hostname = url_parts.hostname;
+ base_parts.port = url_parts.port;
+ }
+
+ // paths
+ if (url_parts.path.length > 0) {
+ if (url_parts.path.charAt(0) == '/') {
+ base_parts.path = url_parts.path;
+ } else {
+ // relative path.. get rid of "current filename" and
+ // replace. Same as var parts =
+ // base_parts.path.split('/'); parts[parts.length-1] =
+ // url_parts.path; base_parts.path = parts.join('/');
+ var idx = base_parts.path.lastIndexOf('/');
+ if (idx == -1) {
+ base_parts.path = url_parts.path;
+ } else {
+ base_parts.path = base_parts.path.substr(0,idx) + '/' +
+ url_parts.path;
+ }
+ }
+ }
+
+ // clean up path
+ base_parts.path = urlparse.normalizepath(base_parts.path);
+
+ // copy query string
+ base_parts.query = url_parts.query;
+
+ // copy fragments
+ if (allow_fragments) {
+ base_parts.fragment = url_parts.fragment;
+ } else {
+ base_parts.fragment = '';
+ }
+
+ return urlparse.urlunsplit(base_parts);
+};
+
+/**
+ * getcwd - named after posix call of same name (see 'man 2 getcwd')
+ *
+ */
+Envjs.getcwd = function() {
+ return '.';
+};
+
+/**
+ * resolves location relative to doc location
+ *
+ * @param {Object} path Relative or absolute URL
+ * @param {Object} base (semi-optional) The base url used in resolving "path" above
+ */
+Envjs.uri = function(path, base) {
+ //console.log('constructing uri from path %s and base %s', path, base);
+
+ // Semi-common trick is to make an iframe with src='javascript:false'
+ // (or some equivalent). By returning '', the load is skipped
+ if (path.indexOf('javascript') === 0) {
+ return '';
+ }
+
+ // if path is absolute, then just normalize and return
+ if (path.match('^[a-zA-Z]+://')) {
+ return urlparse.urlnormalize(path);
+ }
+
+ // interesting special case, a few very large websites use
+ // '//foo/bar/' to mean 'http://foo/bar'
+ if (path.match('^//')) {
+ path = 'http:' + path;
+ }
+
+ // if base not passed in, try to get it from document
+ // Ideally I would like the caller to pass in document.baseURI to
+ // make this more self-sufficient and testable
+ if (!base && document) {
+ base = document.baseURI;
+ }
+
+ // about:blank doesn't count
+ if (base === 'about:blank'){
+ base = '';
+ }
+
+ // if base is still empty, then we are in QA mode loading local
+ // files. Get current working directory
+ if (!base) {
+ base = 'file://' + Envjs.getcwd() + '/';
+ }
+ // handles all cases if path is abosulte or relative to base
+ // 3rd arg is "false" --> remove fragments
+ var newurl = urlparse.urlnormalize(urlparse.urljoin(base, path, false));
+
+ return newurl;
+};
+
+
+
+/**
+ * Used in the XMLHttpRquest implementation to run a
+ * request in a seperate thread
+ * @param {Object} fn
+ */
+Envjs.runAsync = function(fn){};
+
+
+/**
+ * Used to write to a local file
+ * @param {Object} text
+ * @param {Object} url
+ */
+Envjs.writeToFile = function(text, url){};
+
+
+/**
+ * Used to write to a local file
+ * @param {Object} text
+ * @param {Object} suffix
+ */
+Envjs.writeToTempFile = function(text, suffix){};
+
+/**
+ * Used to read the contents of a local file
+ * @param {Object} url
+ */
+Envjs.readFromFile = function(url){};
+
+/**
+ * Used to delete a local file
+ * @param {Object} url
+ */
+Envjs.deleteFile = function(url){};
+
+/**
+ * establishes connection and calls responsehandler
+ * @param {Object} xhr
+ * @param {Object} responseHandler
+ * @param {Object} data
+ */
+Envjs.connection = function(xhr, responseHandler, data){};
+
+
+__extend__(Envjs, urlparse);
+
+/**
+ * Makes an object window-like by proxying object accessors
+ * @param {Object} scope
+ * @param {Object} parent
+ */
+Envjs.proxy = function(scope, parent, aliasList){};
+
+Envjs.javaEnabled = false;
+
+Envjs.homedir = '';
+Envjs.tmpdir = '';
+Envjs.os_name = '';
+Envjs.os_arch = '';
+Envjs.os_version = '';
+Envjs.lang = '';
+Envjs.platform = '';
+
+/**
+ *
+ * @param {Object} frameElement
+ * @param {Object} url
+ */
+Envjs.loadFrame = function(frame, url){
+ try {
+ if(frame.contentWindow){
+ //mark for garbage collection
+ frame.contentWindow = null;
+ }
+
+ //create a new scope for the window proxy
+ //platforms will need to override this function
+ //to make sure the scope is global-like
+ frame.contentWindow = (function(){return this;})();
+ new Window(frame.contentWindow, window);
+
+ //I dont think frames load asynchronously in firefox
+ //and I think the tests have verified this but for
+ //some reason I'm less than confident... Are there cases?
+ frame.contentDocument = frame.contentWindow.document;
+ frame.contentDocument.async = false;
+ if(url){
+ //console.log('envjs.loadFrame async %s', frame.contentDocument.async);
+ frame.contentWindow.location = url;
+ }
+ } catch(e) {
+ console.log("failed to load frame content: from %s %s", url, e);
+ }
+};
+
+
+// The following are in rhino/window.js
+// TODO: Envjs.unloadFrame
+// TODO: Envjs.proxy
+
+/**
+ * @author john resig & the envjs team
+ * @uri http://www.envjs.com/
+ * @copyright 2008-2010
+ * @license MIT
+ */
+//CLOSURE_END
+}());
+/*
+ * Envjs rhino-env.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+var __context__ = Packages.org.mozilla.javascript.Context.getCurrentContext();
+
+Envjs.platform = "Rhino";
+Envjs.revision = "1.7.0.rc2";
+
+/*
+ * Envjs rhino-env.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+//CLOSURE_START
+(function(){
+
+
+
+
+
+/**
+ * @author john resig
+ */
+// Helper method for extending one object with another.
+function __extend__(a,b) {
+ for ( var i in b ) {
+ var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
+ if ( g || s ) {
+ if ( g ) { a.__defineGetter__(i, g); }
+ if ( s ) { a.__defineSetter__(i, s); }
+ } else {
+ a[i] = b[i];
+ }
+ } return a;
+}
+
+/**
+ * Writes message to system out.
+ *
+ * Some sites redefine 'print' as in 'window.print', so instead of
+ * printing to stdout, you are popping open a new window, which might
+ * call print, etc, etc,etc This can cause infinite loops and can
+ * exhausing all memory.
+ *
+ * By defining this upfront now, Envjs.log will always call the native 'print'
+ * function
+ *
+ * @param {Object} message
+ */
+Envjs.log = print;
+
+Envjs.lineSource = function(e){
+ return e&&e.rhinoException?e.rhinoException.lineSource():"(line ?)";
+};
+/**
+ * load and execute script tag text content
+ * @param {Object} script
+ */
+Envjs.loadInlineScript = function(script){
+ if(script.ownerDocument.ownerWindow){
+ Envjs.eval(
+ script.ownerDocument.ownerWindow,
+ script.text,
+ 'eval('+script.text.substring(0,16)+'...):'+new Date().getTime()
+ );
+ }else{
+ Envjs.eval(
+ __this__,
+ script.text,
+ 'eval('+script.text.substring(0,16)+'...):'+new Date().getTime()
+ );
+ }
+ //console.log('evaluated at scope %s \n%s',
+ // script.ownerDocument.ownerWindow.guid, script.text);
+};
+
+
+Envjs.eval = function(context, source, name){
+ __context__.evaluateString(
+ context,
+ source,
+ name,
+ 0,
+ null
+ );
+};
+
+//Temporary patch for parser module
+Packages.org.mozilla.javascript.Context.
+ getCurrentContext().setOptimizationLevel(-1);
+
+/**
+ * Rhino provides a very succinct 'sync'
+ * @param {Function} fn
+ */
+try{
+ Envjs.sync = sync;
+ Envjs.spawn = spawn;
+} catch(e){
+ //sync unavailable on AppEngine
+ Envjs.sync = function(fn){
+ //console.log('Threadless platform, sync is safe');
+ return fn;
+ };
+
+ Envjs.spawn = function(fn){
+ //console.log('Threadless platform, spawn shares main thread.');
+ return fn();
+ };
+}
+
+/**
+ * sleep thread for specified duration
+ * @param {Object} millseconds
+ */
+Envjs.sleep = function(millseconds){
+ try{
+ java.lang.Thread.currentThread().sleep(millseconds);
+ }catch(e){
+ console.log('Threadless platform, cannot sleep.');
+ }
+};
+
+/**
+ * provides callback hook for when the system exits
+ */
+Envjs.onExit = function(callback){
+ var rhino = Packages.org.mozilla.javascript,
+ contextFactory = __context__.getFactory(),
+ listener = new rhino.ContextFactory.Listener({
+ contextReleased: function(context){
+ if(context === __context__)
+ console.log('context released', context);
+ contextFactory.removeListener(this);
+ if(callback)
+ callback();
+ }
+ });
+ contextFactory.addListener(listener);
+};
+
+/**
+ * Get 'Current Working Directory'
+ */
+Envjs.getcwd = function() {
+ return java.lang.System.getProperty('user.dir');
+}
+
+/**
+ *
+ * @param {Object} fn
+ * @param {Object} onInterupt
+ */
+Envjs.runAsync = function(fn, onInterupt){
+ ////Envjs.debug("running async");
+ var running = true,
+ run;
+
+ try{
+ run = Envjs.sync(function(){
+ fn();
+ Envjs.wait();
+ });
+ Envjs.spawn(run);
+ }catch(e){
+ console.log("error while running async operation", e);
+ try{if(onInterrupt)onInterrupt(e)}catch(ee){};
+ }
+};
+
+/**
+ * Used to write to a local file
+ * @param {Object} text
+ * @param {Object} url
+ */
+Envjs.writeToFile = function(text, url){
+ //Envjs.debug("writing text to url : " + url);
+ var out = new java.io.FileWriter(
+ new java.io.File(
+ new java.net.URI(url.toString())));
+ out.write( text, 0, text.length );
+ out.flush();
+ out.close();
+};
+
+/**
+ * Used to write to a local file
+ * @param {Object} text
+ * @param {Object} suffix
+ */
+Envjs.writeToTempFile = function(text, suffix){
+ //Envjs.debug("writing text to temp url : " + suffix);
+ // Create temp file.
+ var temp = java.io.File.createTempFile("envjs-tmp", suffix);
+
+ // Delete temp file when program exits.
+ temp.deleteOnExit();
+
+ // Write to temp file
+ var out = new java.io.FileWriter(temp);
+ out.write(text, 0, text.length);
+ out.close();
+ return temp.getAbsolutePath().toString()+'';
+};
+
+
+/**
+ * Used to read the contents of a local file
+ * @param {Object} url
+ */
+Envjs.readFromFile = function( url ){
+ var fileReader = new java.io.FileReader(
+ new java.io.File(
+ new java.net.URI( url )));
+
+ var stringwriter = new java.io.StringWriter(),
+ buffer = java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 1024),
+ length;
+
+ while ((length = fileReader.read(buffer, 0, 1024)) != -1) {
+ stringwriter.write(buffer, 0, length);
+ }
+
+ stringwriter.close();
+ return stringwriter.toString()+"";
+};
+
+
+/**
+ * Used to delete a local file
+ * @param {Object} url
+ */
+Envjs.deleteFile = function(url){
+ var file = new java.io.File( new java.net.URI( url ) );
+ file["delete"]();
+};
+
+/**
+ * establishes connection and calls responsehandler
+ * @param {Object} xhr
+ * @param {Object} responseHandler
+ * @param {Object} data
+ */
+Envjs.connection = function(xhr, responseHandler, data){
+ var url = java.net.URL(xhr.url),
+ connection,
+ header,
+ outstream,
+ buffer,
+ length,
+ binary = false,
+ name, value,
+ contentEncoding,
+ instream,
+ responseXML,
+ i;
+ if ( /^file\:/.test(url) ) {
+ try{
+ if ( "PUT" == xhr.method || "POST" == xhr.method ) {
+ data = data || "" ;
+ Envjs.writeToFile(data, url);
+ xhr.readyState = 4;
+ //could be improved, I just cant recall the correct http codes
+ xhr.status = 200;
+ xhr.statusText = "";
+ } else if ( xhr.method == "DELETE" ) {
+ Envjs.deleteFile(url);
+ xhr.readyState = 4;
+ //could be improved, I just cant recall the correct http codes
+ xhr.status = 200;
+ xhr.statusText = "";
+ } else {
+ connection = url.openConnection();
+ connection.connect();
+ //try to add some canned headers that make sense
+
+ try{
+ if(xhr.url.match(/html$/)){
+ xhr.responseHeaders["Content-Type"] = 'text/html';
+ }else if(xhr.url.match(/.xml$/)){
+ xhr.responseHeaders["Content-Type"] = 'text/xml';
+ }else if(xhr.url.match(/.js$/)){
+ xhr.responseHeaders["Content-Type"] = 'text/javascript';
+ }else if(xhr.url.match(/.json$/)){
+ xhr.responseHeaders["Content-Type"] = 'application/json';
+ }else{
+ xhr.responseHeaders["Content-Type"] = 'text/plain';
+ }
+ //xhr.responseHeaders['Last-Modified'] = connection.getLastModified();
+ //xhr.responseHeaders['Content-Length'] = headerValue+'';
+ //xhr.responseHeaders['Date'] = new Date()+'';*/
+ }catch(e){
+ console.log('failed to load response headers',e);
+ }
+ }
+ }catch(e){
+ console.log('failed to open file %s %s', url, e);
+ connection = null;
+ xhr.readyState = 4;
+ xhr.statusText = "Local File Protocol Error";
+ xhr.responseText = "<html><head/><body><p>"+ e+ "</p></body></html>";
+ }
+ } else {
+ connection = url.openConnection();
+ connection.setRequestMethod( xhr.method );
+
+ // Add headers to Java connection
+ for (header in xhr.headers){
+ connection.addRequestProperty(header+'', xhr.headers[header]+'');
+ }
+
+ //write data to output stream if required
+ if(data){
+ if(data instanceof Document){
+ if ( xhr.method == "PUT" || xhr.method == "POST" ) {
+ connection.setDoOutput(true);
+ outstream = connection.getOutputStream(),
+ xml = (new XMLSerializer()).serializeToString(data);
+ buffer = new java.lang.String(xml).getBytes('UTF-8');
+ outstream.write(buffer, 0, buffer.length);
+ outstream.close();
+ }
+ }else if(data.length&&data.length>0){
+ if ( xhr.method == "PUT" || xhr.method == "POST" ) {
+ connection.setDoOutput(true);
+ outstream = connection.getOutputStream();
+ buffer = new java.lang.String(data).getBytes('UTF-8');
+ outstream.write(buffer, 0, buffer.length);
+ outstream.close();
+ }
+ }
+ connection.connect();
+ }else{
+ connection.connect();
+ }
+ }
+
+ if(connection){
+ try{
+ length = connection.getHeaderFields().size();
+ // Stick the response headers into responseHeaders
+ for (i = 0; i < length; i++) {
+ name = connection.getHeaderFieldKey(i);
+ value = connection.getHeaderField(i);
+ if (name)
+ xhr.responseHeaders[name+''] = value+'';
+ }
+ }catch(e){
+ console.log('failed to load response headers \n%s',e);
+ }
+
+ xhr.readyState = 4;
+ xhr.status = parseInt(connection.responseCode,10) || undefined;
+ xhr.statusText = connection.responseMessage || "";
+
+ contentEncoding = connection.getContentEncoding() || "utf-8";
+ instream = null;
+ responseXML = null;
+
+ try{
+ //console.log('contentEncoding %s', contentEncoding);
+ if( contentEncoding.equalsIgnoreCase("gzip") ||
+ contentEncoding.equalsIgnoreCase("decompress")){
+ //zipped content
+ binary = true;
+ outstream = new java.io.ByteArrayOutputStream();
+ buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024);
+ instream = new java.util.zip.GZIPInputStream(connection.getInputStream())
+ }else{
+ //this is a text file
+ outstream = new java.io.StringWriter();
+ buffer = java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 1024);
+ instream = new java.io.InputStreamReader(connection.getInputStream());
+ }
+ }catch(e){
+ if (connection.getResponseCode() == 404){
+ console.log('failed to open connection stream \n %s %s',
+ e.toString(), e);
+ }else{
+ console.log('failed to open connection stream \n %s %s',
+ e.toString(), e);
+ }
+ instream = connection.getErrorStream();
+ }
+
+ while ((length = instream.read(buffer, 0, 1024)) != -1) {
+ outstream.write(buffer, 0, length);
+ }
+
+ outstream.close();
+ instream.close();
+
+ if(binary){
+ xhr.responseText = new String(outstream.toByteArray(), 'UTF-8') + '';
+ }else{
+ xhr.responseText = outstream.toString() + '';
+ }
+
+ }
+ if(responseHandler){
+ //Envjs.debug('calling ajax response handler');
+ responseHandler();
+ }
+};
+
+//Since we're running in rhino I guess we can safely assume
+//java is 'enabled'. I'm sure this requires more thought
+//than I've given it here
+Envjs.javaEnabled = true;
+
+Envjs.homedir = java.lang.System.getProperty("user.home");
+Envjs.tmpdir = java.lang.System.getProperty("java.io.tmpdir");
+Envjs.os_name = java.lang.System.getProperty("os.name");
+Envjs.os_arch = java.lang.System.getProperty("os.arch");
+Envjs.os_version = java.lang.System.getProperty("os.version");
+Envjs.lang = java.lang.System.getProperty("user.lang");
+
+
+/**
+ *
+ * @param {Object} frameElement
+ * @param {Object} url
+ */
+Envjs.loadFrame = function(frame, url){
+ try {
+ if(frame.contentWindow){
+ //mark for garbage collection
+ frame.contentWindow = null;
+ }
+
+ //create a new scope for the window proxy
+ frame.contentWindow = Envjs.proxy();
+ new Window(frame.contentWindow, window);
+
+ //I dont think frames load asynchronously in firefox
+ //and I think the tests have verified this but for
+ //some reason I'm less than confident... Are there cases?
+ frame.contentDocument = frame.contentWindow.document;
+ frame.contentDocument.async = false;
+ if(url){
+ //console.log('envjs.loadFrame async %s', frame.contentDocument.async);
+ frame.contentWindow.location = url;
+ }
+ } catch(e) {
+ console.log("failed to load frame content: from %s %s", url, e);
+ }
+};
+
+/**
+ * unloadFrame
+ * @param {Object} frame
+ */
+Envjs.unloadFrame = function(frame){
+ var all, length, i;
+ try{
+ //TODO: probably self-referencing structures within a document tree
+ //preventing it from being entirely garbage collected once orphaned.
+ //Should have code to walk tree and break all links between contained
+ //objects.
+ frame.contentDocument = null;
+ if(frame.contentWindow){
+ frame.contentWindow.close();
+ }
+ gc();
+ }catch(e){
+ console.log(e);
+ }
+};
+
+/**
+ * Makes an object window-like by proxying object accessors
+ * @param {Object} scope
+ * @param {Object} parent
+ */
+Envjs.proxy = function(scope, parent) {
+ try{
+ if(scope+'' == '[object global]'){
+ return scope
+ }else{
+ return __context__.initStandardObjects();
+ }
+ }catch(e){
+ console.log('failed to init standard objects %s %s \n%s', scope, parent, e);
+ }
+
+};
+
+/**
+ * @author john resig & the envjs team
+ * @uri http://www.envjs.com/
+ * @copyright 2008-2010
+ * @license MIT
+ */
+//CLOSURE_END
+}());
+
+/**
+ * @author envjs team
+ */
+var Console,
+ console;
+
+/*
+ * Envjs console.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+//CLOSURE_START
+(function(){
+
+
+
+
+
+/**
+ * @author envjs team
+ * borrowed 99%-ish with love from firebug-lite
+ *
+ * http://wiki.commonjs.org/wiki/Console
+ */
+Console = function(module){
+ var $level,
+ $logger,
+ $null = function(){};
+
+
+ if(Envjs[module] && Envjs[module].loglevel){
+ $level = Envjs.module.loglevel;
+ $logger = {
+ log: function(level){
+ logFormatted(arguments, (module)+" ");
+ },
+ debug: $level>1 ? $null: function() {
+ logFormatted(arguments, (module)+" debug");
+ },
+ info: $level>2 ? $null:function(){
+ logFormatted(arguments, (module)+" info");
+ },
+ warn: $level>3 ? $null:function(){
+ logFormatted(arguments, (module)+" warning");
+ },
+ error: $level>4 ? $null:function(){
+ logFormatted(arguments, (module)+" error");
+ }
+ };
+ } else {
+ $logger = {
+ log: function(level){
+ logFormatted(arguments, "");
+ },
+ debug: $null,
+ info: $null,
+ warn: $null,
+ error: $null
+ };
+ }
+
+ return $logger;
+};
+
+console = new Console("console",1);
+
+function logFormatted(objects, className)
+{
+ var html = [];
+
+ var format = objects[0];
+ var objIndex = 0;
+
+ if (typeof(format) != "string")
+ {
+ format = "";
+ objIndex = -1;
+ }
+
+ var parts = parseFormat(format);
+ for (var i = 0; i < parts.length; ++i)
+ {
+ var part = parts[i];
+ if (part && typeof(part) == "object")
+ {
+ var object = objects[++objIndex];
+ part.appender(object, html);
+ }
+ else {
+ appendText(part, html);
+ }
+ }
+
+ for (var i = objIndex+1; i < objects.length; ++i)
+ {
+ appendText(" ", html);
+
+ var object = objects[i];
+ if (typeof(object) == "string") {
+ appendText(object, html);
+ } else {
+ appendObject(object, html);
+ }
+ }
+
+ Envjs.log(html.join(' '));
+}
+
+function parseFormat(format)
+{
+ var parts = [];
+
+ var reg = /((^%|[^\\]%)(\d+)?(\.)([a-zA-Z]))|((^%|[^\\]%)([a-zA-Z]))/;
+ var appenderMap = {s: appendText, d: appendInteger, i: appendInteger, f: appendFloat};
+
+ for (var m = reg.exec(format); m; m = reg.exec(format))
+ {
+ var type = m[8] ? m[8] : m[5];
+ var appender = type in appenderMap ? appenderMap[type] : appendObject;
+ var precision = m[3] ? parseInt(m[3]) : (m[4] == "." ? -1 : 0);
+
+ parts.push(format.substr(0, m[0][0] == "%" ? m.index : m.index+1));
+ parts.push({appender: appender, precision: precision});
+
+ format = format.substr(m.index+m[0].length);
+ }
+
+ parts.push(format);
+
+ return parts;
+}
+
+function escapeHTML(value)
+{
+ return value;
+}
+
+function objectToString(object)
+{
+ try
+ {
+ return object+"";
+ }
+ catch (exc)
+ {
+ return null;
+ }
+}
+
+// ********************************************************************************************
+
+function appendText(object, html)
+{
+ html.push(escapeHTML(objectToString(object)));
+}
+
+function appendNull(object, html)
+{
+ html.push(escapeHTML(objectToString(object)));
+}
+
+function appendString(object, html)
+{
+ html.push(escapeHTML(objectToString(object)));
+}
+
+function appendInteger(object, html)
+{
+ html.push(escapeHTML(objectToString(object)));
+}
+
+function appendFloat(object, html)
+{
+ html.push(escapeHTML(objectToString(object)));
+}
+
+function appendFunction(object, html)
+{
+ var reName = /function ?(.*?)\(/;
+ var m = reName.exec(objectToString(object));
+ var name = m ? m[1] : "function";
+ html.push(escapeHTML(name));
+}
+
+function appendObject(object, html)
+{
+ try
+ {
+ if (object == undefined) {
+ appendNull("undefined", html);
+ } else if (object == null) {
+ appendNull("null", html);
+ } else if (typeof object == "string") {
+ appendString(object, html);
+ } else if (typeof object == "number") {
+ appendInteger(object, html);
+ } else if (typeof object == "function") {
+ appendFunction(object, html);
+ } else if (object.nodeType == 1) {
+ appendSelector(object, html);
+ } else if (typeof object == "object") {
+ appendObjectFormatted(object, html);
+ } else {
+ appendText(object, html);
+ }
+ }
+ catch (exc)
+ {
+ }
+}
+
+function appendObjectFormatted(object, html)
+{
+ var text = objectToString(object);
+ var reObject = /\[object (.*?)\]/;
+
+ var m = reObject.exec(text);
+ html.push( m ? m[1] : text);
+}
+
+function appendSelector(object, html)
+{
+
+ html.push(escapeHTML(object.nodeName.toLowerCase()));
+ if (object.id) {
+ html.push(escapeHTML(object.id));
+ }
+ if (object.className) {
+ html.push(escapeHTML(object.className));
+ }
+}
+
+function appendNode(node, html)
+{
+ if (node.nodeType == 1)
+ {
+ html.push( node.nodeName.toLowerCase());
+
+ for (var i = 0; i < node.attributes.length; ++i)
+ {
+ var attr = node.attributes[i];
+ if (!attr.specified) {
+ continue;
+ }
+
+ html.push( attr.nodeName.toLowerCase(),escapeHTML(attr.nodeValue));
+ }
+
+ if (node.firstChild)
+ {
+ for (var child = node.firstChild; child; child = child.nextSibling) {
+ appendNode(child, html);
+ }
+
+ html.push( node.nodeName.toLowerCase());
+ }
+ }
+ else if (node.nodeType === 3)
+ {
+ html.push(escapeHTML(node.nodeValue));
+ }
+};
+
+/**
+ * @author john resig & the envjs team
+ * @uri http://www.envjs.com/
+ * @copyright 2008-2010
+ * @license MIT
+ */
+//CLOSURE_END
+}());
+/*
+ * Envjs dom.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ *
+ * Parts of the implementation were originally written by:\
+ * and Jon van Noort (jon@webarcana.com.au) \
+ * and David Joham (djoham@yahoo.com)",\
+ * and Scott Severtson
+ *
+ * This file simply provides the global definitions we need to \
+ * be able to correctly implement to core browser DOM interfaces."
+ */
+
+var Attr,
+ CDATASection,
+ CharacterData,
+ Comment,
+ Document,
+ DocumentFragment,
+ DocumentType,
+ DOMException,
+ DOMImplementation,
+ Element,
+ Entity,
+ EntityReference,
+ NamedNodeMap,
+ Namespace,
+ Node,
+ NodeList,
+ Notation,
+ ProcessingInstruction,
+ Text,
+ Range,
+ XMLSerializer,
+ DOMParser;
+
+
+
+/*
+ * Envjs dom.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+//CLOSURE_START
+(function(){
+
+
+
+
+
+/**
+ * @author john resig
+ */
+// Helper method for extending one object with another.
+function __extend__(a,b) {
+ for ( var i in b ) {
+ var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
+ if ( g || s ) {
+ if ( g ) { a.__defineGetter__(i, g); }
+ if ( s ) { a.__defineSetter__(i, s); }
+ } else {
+ a[i] = b[i];
+ }
+ } return a;
+}
+
+/**
+ * @author john resig
+ */
+//from jQuery
+function __setArray__( target, array ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ target.length = 0;
+ Array.prototype.push.apply( target, array );
+}
+
+/**
+ * @class NodeList -
+ * provides the abstraction of an ordered collection of nodes
+ *
+ * @param ownerDocument : Document - the ownerDocument
+ * @param parentNode : Node - the node that the NodeList is attached to (or null)
+ */
+NodeList = function(ownerDocument, parentNode) {
+ this.length = 0;
+ this.parentNode = parentNode;
+ this.ownerDocument = ownerDocument;
+ this._readonly = false;
+ __setArray__(this, []);
+};
+
+__extend__(NodeList.prototype, {
+ item : function(index) {
+ var ret = null;
+ if ((index >= 0) && (index < this.length)) {
+ // bounds check
+ ret = this[index];
+ }
+ // if the index is out of bounds, default value null is returned
+ return ret;
+ },
+ get xml() {
+ var ret = "",
+ i;
+
+ // create string containing the concatenation of the string values of each child
+ for (i=0; i < this.length; i++) {
+ if(this[i]){
+ if(this[i].nodeType == Node.TEXT_NODE && i>0 &&
+ this[i-1].nodeType == Node.TEXT_NODE){
+ //add a single space between adjacent text nodes
+ ret += " "+this[i].xml;
+ }else{
+ ret += this[i].xml;
+ }
+ }
+ }
+ return ret;
+ },
+ toArray: function () {
+ var children = [],
+ i;
+ for ( i=0; i < this.length; i++) {
+ children.push (this[i]);
+ }
+ return children;
+ },
+ toString: function(){
+ return "[object NodeList]";
+ }
+});
+
+
+/**
+ * @method __findItemIndex__
+ * find the item index of the node
+ * @author Jon van Noort (jon@webarcana.com.au)
+ * @param node : Node
+ * @return : int
+ */
+var __findItemIndex__ = function (nodelist, node) {
+ var ret = -1, i;
+ for (i=0; i<nodelist.length; i++) {
+ // compare id to each node's _id
+ if (nodelist[i] === node) {
+ // found it!
+ ret = i;
+ break;
+ }
+ }
+ // if node is not found, default value -1 is returned
+ return ret;
+};
+
+/**
+ * @method __insertBefore__
+ * insert the specified Node into the NodeList before the specified index
+ * Used by Node.insertBefore(). Note: Node.insertBefore() is responsible
+ * for Node Pointer surgery __insertBefore__ simply modifies the internal
+ * data structure (Array).
+ * @param newChild : Node - the Node to be inserted
+ * @param refChildIndex : int - the array index to insert the Node before
+ */
+var __insertBefore__ = function(nodelist, newChild, refChildIndex) {
+ if ((refChildIndex >= 0) && (refChildIndex <= nodelist.length)) {
+ // bounds check
+ if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
+ // node is a DocumentFragment
+ // append the children of DocumentFragment
+ Array.prototype.splice.apply(nodelist,
+ [refChildIndex, 0].concat(newChild.childNodes.toArray()));
+ }
+ else {
+ // append the newChild
+ Array.prototype.splice.apply(nodelist,[refChildIndex, 0, newChild]);
+ }
+ }
+};
+
+/**
+ * @method __replaceChild__
+ * replace the specified Node in the NodeList at the specified index
+ * Used by Node.replaceChild(). Note: Node.replaceChild() is responsible
+ * for Node Pointer surgery __replaceChild__ simply modifies the internal
+ * data structure (Array).
+ *
+ * @param newChild : Node - the Node to be inserted
+ * @param refChildIndex : int - the array index to hold the Node
+ */
+var __replaceChild__ = function(nodelist, newChild, refChildIndex) {
+ var ret = null;
+
+ // bounds check
+ if ((refChildIndex >= 0) && (refChildIndex < nodelist.length)) {
+ // preserve old child for return
+ ret = nodelist[refChildIndex];
+
+ if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
+ // node is a DocumentFragment
+ // get array containing children prior to refChild
+ Array.prototype.splice.apply(nodelist,
+ [refChildIndex, 1].concat(newChild.childNodes.toArray()));
+ }
+ else {
+ // simply replace node in array (links between Nodes are
+ // made at higher level)
+ nodelist[refChildIndex] = newChild;
+ }
+ }
+ // return replaced node
+ return ret;
+};
+
+/**
+ * @method __removeChild__
+ * remove the specified Node in the NodeList at the specified index
+ * Used by Node.removeChild(). Note: Node.removeChild() is responsible
+ * for Node Pointer surgery __removeChild__ simply modifies the internal
+ * data structure (Array).
+ * @param refChildIndex : int - the array index holding the Node to be removed
+ */
+var __removeChild__ = function(nodelist, refChildIndex) {
+ var ret = null;
+
+ if (refChildIndex > -1) {
+ // found it!
+ // return removed node
+ ret = nodelist[refChildIndex];
+
+ // rebuild array without removed child
+ Array.prototype.splice.apply(nodelist,[refChildIndex, 1]);
+ }
+ // return removed node
+ return ret;
+};
+
+/**
+ * @method __appendChild__
+ * append the specified Node to the NodeList. Used by Node.appendChild().
+ * Note: Node.appendChild() is responsible for Node Pointer surgery
+ * __appendChild__ simply modifies the internal data structure (Array).
+ * @param newChild : Node - the Node to be inserted
+ */
+var __appendChild__ = function(nodelist, newChild) {
+ if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
+ // node is a DocumentFragment
+ // append the children of DocumentFragment
+ Array.prototype.push.apply(nodelist, newChild.childNodes.toArray() );
+ } else {
+ // simply add node to array (links between Nodes are made at higher level)
+ Array.prototype.push.apply(nodelist, [newChild]);
+ }
+
+};
+
+/**
+ * @method __cloneNodes__ -
+ * Returns a NodeList containing clones of the Nodes in this NodeList
+ * @param deep : boolean -
+ * If true, recursively clone the subtree under each of the nodes;
+ * if false, clone only the nodes themselves (and their attributes,
+ * if it is an Element).
+ * @param parentNode : Node - the new parent of the cloned NodeList
+ * @return : NodeList - NodeList containing clones of the Nodes in this NodeList
+ */
+var __cloneNodes__ = function(nodelist, deep, parentNode) {
+ var cloneNodeList = new NodeList(nodelist.ownerDocument, parentNode);
+
+ // create list containing clones of each child
+ for (var i=0; i < nodelist.length; i++) {
+ __appendChild__(cloneNodeList, nodelist[i].cloneNode(deep));
+ }
+
+ return cloneNodeList;
+};
+
+
+var __ownerDocument__ = function(node){
+ return (node.nodeType == Node.DOCUMENT_NODE)?node:node.ownerDocument;
+};
+
+/**
+ * @class Node -
+ * The Node interface is the primary datatype for the entire
+ * Document Object Model. It represents a single node in the
+ * document tree.
+ * @param ownerDocument : Document - The Document object associated with this node.
+ */
+
+Node = function(ownerDocument) {
+ this.baseURI = 'about:blank';
+ this.namespaceURI = null;
+ this.nodeName = "";
+ this.nodeValue = null;
+
+ // A NodeList that contains all children of this node. If there are no
+ // children, this is a NodeList containing no nodes. The content of the
+ // returned NodeList is "live" in the sense that, for instance, changes to
+ // the children of the node object that it was created from are immediately
+ // reflected in the nodes returned by the NodeList accessors; it is not a
+ // static snapshot of the content of the node. This is true for every
+ // NodeList, including the ones returned by the getElementsByTagName method.
+ this.childNodes = new NodeList(ownerDocument, this);
+
+ // The first child of this node. If there is no such node, this is null
+ this.firstChild = null;
+ // The last child of this node. If there is no such node, this is null.
+ this.lastChild = null;
+ // The node immediately preceding this node. If there is no such node,
+ // this is null.
+ this.previousSibling = null;
+ // The node immediately following this node. If there is no such node,
+ // this is null.
+ this.nextSibling = null;
+
+ this.attributes = null;
+ // The namespaces in scope for this node
+ this._namespaces = new NamespaceNodeMap(ownerDocument, this);
+ this._readonly = false;
+
+ //IMPORTANT: These must come last so rhino will not iterate parent
+ // properties before child properties. (qunit.equiv issue)
+
+ // The parent of this node. All nodes, except Document, DocumentFragment,
+ // and Attr may have a parent. However, if a node has just been created
+ // and not yet added to the tree, or if it has been removed from the tree,
+ // this is null
+ this.parentNode = null;
+ // The Document object associated with this node
+ this.ownerDocument = ownerDocument;
+
+};
+
+// nodeType constants
+Node.ELEMENT_NODE = 1;
+Node.ATTRIBUTE_NODE = 2;
+Node.TEXT_NODE = 3;
+Node.CDATA_SECTION_NODE = 4;
+Node.ENTITY_REFERENCE_NODE = 5;
+Node.ENTITY_NODE = 6;
+Node.PROCESSING_INSTRUCTION_NODE = 7;
+Node.COMMENT_NODE = 8;
+Node.DOCUMENT_NODE = 9;
+Node.DOCUMENT_TYPE_NODE = 10;
+Node.DOCUMENT_FRAGMENT_NODE = 11;
+Node.NOTATION_NODE = 12;
+Node.NAMESPACE_NODE = 13;
+
+Node.DOCUMENT_POSITION_EQUAL = 0x00;
+Node.DOCUMENT_POSITION_DISCONNECTED = 0x01;
+Node.DOCUMENT_POSITION_PRECEDING = 0x02;
+Node.DOCUMENT_POSITION_FOLLOWING = 0x04;
+Node.DOCUMENT_POSITION_CONTAINS = 0x08;
+Node.DOCUMENT_POSITION_CONTAINED_BY = 0x10;
+Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
+
+
+__extend__(Node.prototype, {
+ get localName(){
+ return this.prefix?
+ this.nodeName.substring(this.prefix.length+1, this.nodeName.length):
+ this.nodeName;
+ },
+ get prefix(){
+ return this.nodeName.split(':').length>1?
+ this.nodeName.split(':')[0]:
+ null;
+ },
+ set prefix(value){
+ if(value === null){
+ this.nodeName = this.localName;
+ }else{
+ this.nodeName = value+':'+this.localName;
+ }
+ },
+ hasAttributes : function() {
+ if (this.attributes.length == 0) {
+ return false;
+ }else{
+ return true;
+ }
+ },
+ get textContent(){
+ return __recursivelyGatherText__(this);
+ },
+ set textContent(newText){
+ while(this.firstChild != null){
+ this.removeChild( this.firstChild );
+ }
+ var text = this.ownerDocument.createTextNode(newText);
+ this.appendChild(text);
+ },
+ insertBefore : function(newChild, refChild) {
+ var prevNode;
+
+ if(newChild==null){
+ return newChild;
+ }
+ if(refChild==null){
+ this.appendChild(newChild);
+ return this.newChild;
+ }
+
+ // test for exceptions
+ if (__ownerDocument__(this).implementation.errorChecking) {
+ // throw Exception if Node is readonly
+ if (this._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // throw Exception if newChild was not created by this Document
+ if (__ownerDocument__(this) != __ownerDocument__(newChild)) {
+ throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR));
+ }
+
+ // throw Exception if the node is an ancestor
+ if (__isAncestor__(this, newChild)) {
+ throw(new DOMException(DOMException.HIERARCHY_REQUEST_ERR));
+ }
+ }
+
+ // if refChild is specified, insert before it
+ if (refChild) {
+ // find index of refChild
+ var itemIndex = __findItemIndex__(this.childNodes, refChild);
+ // throw Exception if there is no child node with this id
+ if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) {
+ throw(new DOMException(DOMException.NOT_FOUND_ERR));
+ }
+
+ // if the newChild is already in the tree,
+ var newChildParent = newChild.parentNode;
+ if (newChildParent) {
+ // remove it
+ newChildParent.removeChild(newChild);
+ }
+
+ // insert newChild into childNodes
+ __insertBefore__(this.childNodes, newChild, itemIndex);
+
+ // do node pointer surgery
+ prevNode = refChild.previousSibling;
+
+ // handle DocumentFragment
+ if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
+ if (newChild.childNodes.length > 0) {
+ // set the parentNode of DocumentFragment's children
+ for (var ind = 0; ind < newChild.childNodes.length; ind++) {
+ newChild.childNodes[ind].parentNode = this;
+ }
+
+ // link refChild to last child of DocumentFragment
+ refChild.previousSibling = newChild.childNodes[newChild.childNodes.length-1];
+ }
+ }else {
+ // set the parentNode of the newChild
+ newChild.parentNode = this;
+ // link refChild to newChild
+ refChild.previousSibling = newChild;
+ }
+
+ }else {
+ // otherwise, append to end
+ prevNode = this.lastChild;
+ this.appendChild(newChild);
+ }
+
+ if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
+ // do node pointer surgery for DocumentFragment
+ if (newChild.childNodes.length > 0) {
+ if (prevNode) {
+ prevNode.nextSibling = newChild.childNodes[0];
+ }else {
+ // this is the first child in the list
+ this.firstChild = newChild.childNodes[0];
+ }
+ newChild.childNodes[0].previousSibling = prevNode;
+ newChild.childNodes[newChild.childNodes.length-1].nextSibling = refChild;
+ }
+ }else {
+ // do node pointer surgery for newChild
+ if (prevNode) {
+ prevNode.nextSibling = newChild;
+ }else {
+ // this is the first child in the list
+ this.firstChild = newChild;
+ }
+ newChild.previousSibling = prevNode;
+ newChild.nextSibling = refChild;
+ }
+
+ return newChild;
+ },
+ replaceChild : function(newChild, oldChild) {
+ var ret = null;
+
+ if(newChild==null || oldChild==null){
+ return oldChild;
+ }
+
+ // test for exceptions
+ if (__ownerDocument__(this).implementation.errorChecking) {
+ // throw Exception if Node is readonly
+ if (this._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // throw Exception if newChild was not created by this Document
+ if (__ownerDocument__(this) != __ownerDocument__(newChild)) {
+ throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR));
+ }
+
+ // throw Exception if the node is an ancestor
+ if (__isAncestor__(this, newChild)) {
+ throw(new DOMException(DOMException.HIERARCHY_REQUEST_ERR));
+ }
+ }
+
+ // get index of oldChild
+ var index = __findItemIndex__(this.childNodes, oldChild);
+
+ // throw Exception if there is no child node with this id
+ if (__ownerDocument__(this).implementation.errorChecking && (index < 0)) {
+ throw(new DOMException(DOMException.NOT_FOUND_ERR));
+ }
+
+ // if the newChild is already in the tree,
+ var newChildParent = newChild.parentNode;
+ if (newChildParent) {
+ // remove it
+ newChildParent.removeChild(newChild);
+ }
+
+ // add newChild to childNodes
+ ret = __replaceChild__(this.childNodes,newChild, index);
+
+
+ if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
+ // do node pointer surgery for Document Fragment
+ if (newChild.childNodes.length > 0) {
+ for (var ind = 0; ind < newChild.childNodes.length; ind++) {
+ newChild.childNodes[ind].parentNode = this;
+ }
+
+ if (oldChild.previousSibling) {
+ oldChild.previousSibling.nextSibling = newChild.childNodes[0];
+ } else {
+ this.firstChild = newChild.childNodes[0];
+ }
+
+ if (oldChild.nextSibling) {
+ oldChild.nextSibling.previousSibling = newChild;
+ } else {
+ this.lastChild = newChild.childNodes[newChild.childNodes.length-1];
+ }
+
+ newChild.childNodes[0].previousSibling = oldChild.previousSibling;
+ newChild.childNodes[newChild.childNodes.length-1].nextSibling = oldChild.nextSibling;
+ }
+ } else {
+ // do node pointer surgery for newChild
+ newChild.parentNode = this;
+
+ if (oldChild.previousSibling) {
+ oldChild.previousSibling.nextSibling = newChild;
+ }else{
+ this.firstChild = newChild;
+ }
+ if (oldChild.nextSibling) {
+ oldChild.nextSibling.previousSibling = newChild;
+ }else{
+ this.lastChild = newChild;
+ }
+ newChild.previousSibling = oldChild.previousSibling;
+ newChild.nextSibling = oldChild.nextSibling;
+ }
+
+ return ret;
+ },
+ removeChild : function(oldChild) {
+ if(!oldChild){
+ return null;
+ }
+ // throw Exception if NamedNodeMap is readonly
+ if (__ownerDocument__(this).implementation.errorChecking &&
+ (this._readonly || oldChild._readonly)) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // get index of oldChild
+ var itemIndex = __findItemIndex__(this.childNodes, oldChild);
+
+ // throw Exception if there is no child node with this id
+ if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) {
+ throw(new DOMException(DOMException.NOT_FOUND_ERR));
+ }
+
+ // remove oldChild from childNodes
+ __removeChild__(this.childNodes, itemIndex);
+
+ // do node pointer surgery
+ oldChild.parentNode = null;
+
+ if (oldChild.previousSibling) {
+ oldChild.previousSibling.nextSibling = oldChild.nextSibling;
+ }else {
+ this.firstChild = oldChild.nextSibling;
+ }
+ if (oldChild.nextSibling) {
+ oldChild.nextSibling.previousSibling = oldChild.previousSibling;
+ }else {
+ this.lastChild = oldChild.previousSibling;
+ }
+
+ oldChild.previousSibling = null;
+ oldChild.nextSibling = null;
+
+ return oldChild;
+ },
+ appendChild : function(newChild) {
+ if(!newChild){
+ return null;
+ }
+ // test for exceptions
+ if (__ownerDocument__(this).implementation.errorChecking) {
+ // throw Exception if Node is readonly
+ if (this._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // throw Exception if arg was not created by this Document
+ if (__ownerDocument__(this) != __ownerDocument__(this)) {
+ throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR));
+ }
+
+ // throw Exception if the node is an ancestor
+ if (__isAncestor__(this, newChild)) {
+ throw(new DOMException(DOMException.HIERARCHY_REQUEST_ERR));
+ }
+ }
+
+ // if the newChild is already in the tree,
+ var newChildParent = newChild.parentNode;
+ if (newChildParent) {
+ // remove it
+ //console.debug('removing node %s', newChild);
+ newChildParent.removeChild(newChild);
+ }
+
+ // add newChild to childNodes
+ __appendChild__(this.childNodes, newChild);
+
+ if (newChild.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
+ // do node pointer surgery for DocumentFragment
+ if (newChild.childNodes.length > 0) {
+ for (var ind = 0; ind < newChild.childNodes.length; ind++) {
+ newChild.childNodes[ind].parentNode = this;
+ }
+
+ if (this.lastChild) {
+ this.lastChild.nextSibling = newChild.childNodes[0];
+ newChild.childNodes[0].previousSibling = this.lastChild;
+ this.lastChild = newChild.childNodes[newChild.childNodes.length-1];
+ } else {
+ this.lastChild = newChild.childNodes[newChild.childNodes.length-1];
+ this.firstChild = newChild.childNodes[0];
+ }
+ }
+ } else {
+ // do node pointer surgery for newChild
+ newChild.parentNode = this;
+ if (this.lastChild) {
+ this.lastChild.nextSibling = newChild;
+ newChild.previousSibling = this.lastChild;
+ this.lastChild = newChild;
+ } else {
+ this.lastChild = newChild;
+ this.firstChild = newChild;
+ }
+ }
+ return newChild;
+ },
+ hasChildNodes : function() {
+ return (this.childNodes.length > 0);
+ },
+ cloneNode: function(deep) {
+ // use importNode to clone this Node
+ //do not throw any exceptions
+ try {
+ return __ownerDocument__(this).importNode(this, deep);
+ } catch (e) {
+ //there shouldn't be any exceptions, but if there are, return null
+ // may want to warn: $debug("could not clone node: "+e.code);
+ return null;
+ }
+ },
+ normalize : function() {
+ var i;
+ var inode;
+ var nodesToRemove = new NodeList();
+
+ if (this.nodeType == Node.ELEMENT_NODE || this.nodeType == Node.DOCUMENT_NODE) {
+ var adjacentTextNode = null;
+
+ // loop through all childNodes
+ for(i = 0; i < this.childNodes.length; i++) {
+ inode = this.childNodes.item(i);
+
+ if (inode.nodeType == Node.TEXT_NODE) {
+ // this node is a text node
+ if (inode.length < 1) {
+ // this text node is empty
+ // add this node to the list of nodes to be remove
+ __appendChild__(nodesToRemove, inode);
+ }else {
+ if (adjacentTextNode) {
+ // previous node was also text
+ adjacentTextNode.appendData(inode.data);
+ // merge the data in adjacent text nodes
+ // add this node to the list of nodes to be removed
+ __appendChild__(nodesToRemove, inode);
+ } else {
+ // remember this node for next cycle
+ adjacentTextNode = inode;
+ }
+ }
+ } else {
+ // (soon to be) previous node is not a text node
+ adjacentTextNode = null;
+ // normalize non Text childNodes
+ inode.normalize();
+ }
+ }
+
+ // remove redundant Text Nodes
+ for(i = 0; i < nodesToRemove.length; i++) {
+ inode = nodesToRemove.item(i);
+ inode.parentNode.removeChild(inode);
+ }
+ }
+ },
+ isSupported : function(feature, version) {
+ // use Implementation.hasFeature to determine if this feature is supported
+ return __ownerDocument__(this).implementation.hasFeature(feature, version);
+ },
+ getElementsByTagName : function(tagname) {
+ // delegate to _getElementsByTagNameRecursive
+ // recurse childNodes
+ var nodelist = new NodeList(__ownerDocument__(this));
+ for (var i = 0; i < this.childNodes.length; i++) {
+ __getElementsByTagNameRecursive__(this.childNodes.item(i),
+ tagname,
+ nodelist);
+ }
+ return nodelist;
+ },
+ getElementsByTagNameNS : function(namespaceURI, localName) {
+ // delegate to _getElementsByTagNameNSRecursive
+ return __getElementsByTagNameNSRecursive__(this, namespaceURI, localName,
+ new NodeList(__ownerDocument__(this)));
+ },
+ importNode : function(importedNode, deep) {
+ var i;
+ var importNode;
+
+ //there is no need to perform namespace checks since everything has already gone through them
+ //in order to have gotten into the DOM in the first place. The following line
+ //turns namespace checking off in ._isValidNamespace
+ __ownerDocument__(this).importing = true;
+
+ if (importedNode.nodeType == Node.ELEMENT_NODE) {
+ if (!__ownerDocument__(this).implementation.namespaceAware) {
+ // create a local Element (with the name of the importedNode)
+ importNode = __ownerDocument__(this).createElement(importedNode.tagName);
+
+ // create attributes matching those of the importedNode
+ for(i = 0; i < importedNode.attributes.length; i++) {
+ importNode.setAttribute(importedNode.attributes.item(i).name, importedNode.attributes.item(i).value);
+ }
+ } else {
+ // create a local Element (with the name & namespaceURI of the importedNode)
+ importNode = __ownerDocument__(this).createElementNS(importedNode.namespaceURI, importedNode.nodeName);
+
+ // create attributes matching those of the importedNode
+ for(i = 0; i < importedNode.attributes.length; i++) {
+ importNode.setAttributeNS(importedNode.attributes.item(i).namespaceURI,
+ importedNode.attributes.item(i).name, importedNode.attributes.item(i).value);
+ }
+
+ // create namespace definitions matching those of the importedNode
+ for(i = 0; i < importedNode._namespaces.length; i++) {
+ importNode._namespaces[i] = __ownerDocument__(this).createNamespace(importedNode._namespaces.item(i).localName);
+ importNode._namespaces[i].value = importedNode._namespaces.item(i).value;
+ }
+ }
+ } else if (importedNode.nodeType == Node.ATTRIBUTE_NODE) {
+ if (!__ownerDocument__(this).implementation.namespaceAware) {
+ // create a local Attribute (with the name of the importedAttribute)
+ importNode = __ownerDocument__(this).createAttribute(importedNode.name);
+ } else {
+ // create a local Attribute (with the name & namespaceURI of the importedAttribute)
+ importNode = __ownerDocument__(this).createAttributeNS(importedNode.namespaceURI, importedNode.nodeName);
+
+ // create namespace definitions matching those of the importedAttribute
+ for(i = 0; i < importedNode._namespaces.length; i++) {
+ importNode._namespaces[i] = __ownerDocument__(this).createNamespace(importedNode._namespaces.item(i).localName);
+ importNode._namespaces[i].value = importedNode._namespaces.item(i).value;
+ }
+ }
+
+ // set the value of the local Attribute to match that of the importedAttribute
+ importNode.value = importedNode.value;
+
+ } else if (importedNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
+ // create a local DocumentFragment
+ importNode = __ownerDocument__(this).createDocumentFragment();
+ } else if (importedNode.nodeType == Node.NAMESPACE_NODE) {
+ // create a local NamespaceNode (with the same name & value as the importedNode)
+ importNode = __ownerDocument__(this).createNamespace(importedNode.nodeName);
+ importNode.value = importedNode.value;
+ } else if (importedNode.nodeType == Node.TEXT_NODE) {
+ // create a local TextNode (with the same data as the importedNode)
+ importNode = __ownerDocument__(this).createTextNode(importedNode.data);
+ } else if (importedNode.nodeType == Node.CDATA_SECTION_NODE) {
+ // create a local CDATANode (with the same data as the importedNode)
+ importNode = __ownerDocument__(this).createCDATASection(importedNode.data);
+ } else if (importedNode.nodeType == Node.PROCESSING_INSTRUCTION_NODE) {
+ // create a local ProcessingInstruction (with the same target & data as the importedNode)
+ importNode = __ownerDocument__(this).createProcessingInstruction(importedNode.target, importedNode.data);
+ } else if (importedNode.nodeType == Node.COMMENT_NODE) {
+ // create a local Comment (with the same data as the importedNode)
+ importNode = __ownerDocument__(this).createComment(importedNode.data);
+ } else { // throw Exception if nodeType is not supported
+ throw(new DOMException(DOMException.NOT_SUPPORTED_ERR));
+ }
+
+ if (deep) {
+ // recurse childNodes
+ for(i = 0; i < importedNode.childNodes.length; i++) {
+ importNode.appendChild(__ownerDocument__(this).importNode(importedNode.childNodes.item(i), true));
+ }
+ }
+
+ //reset importing
+ __ownerDocument__(this).importing = false;
+ return importNode;
+
+ },
+ contains : function(node){
+ while(node && node != this ){
+ node = node.parentNode;
+ }
+ return !!node;
+ },
+ compareDocumentPosition : function(b){
+ //console.log("comparing document position %s %s", this, b);
+ var i,
+ length,
+ a = this,
+ parent,
+ aparents,
+ bparents;
+ //handle a couple simpler case first
+ if(a === b) {
+ return Node.DOCUMENT_POSITION_EQUAL;
+ }
+ if(a.ownerDocument !== b.ownerDocument) {
+ return Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|
+ Node.DOCUMENT_POSITION_FOLLOWING|
+ Node.DOCUMENT_POSITION_DISCONNECTED;
+ }
+ if(a.parentNode === b.parentNode){
+ length = a.parentNode.childNodes.length;
+ for(i=0;i<length;i++){
+ if(a.parentNode.childNodes[i] === a){
+ return Node.DOCUMENT_POSITION_FOLLOWING;
+ }else if(a.parentNode.childNodes[i] === b){
+ return Node.DOCUMENT_POSITION_PRECEDING;
+ }
+ }
+ }
+
+ if(a.contains(b)) {
+ return Node.DOCUMENT_POSITION_CONTAINED_BY|
+ Node.DOCUMENT_POSITION_FOLLOWING;
+ }
+ if(b.contains(a)) {
+ return Node.DOCUMENT_POSITION_CONTAINS|
+ Node.DOCUMENT_POSITION_PRECEDING;
+ }
+ aparents = [];
+ parent = a.parentNode;
+ while(parent){
+ aparents[aparents.length] = parent;
+ parent = parent.parentNode;
+ }
+
+ bparents = [];
+ parent = b.parentNode;
+ while(parent){
+ i = aparents.indexOf(parent);
+ if(i < 0){
+ bparents[bparents.length] = parent;
+ parent = parent.parentNode;
+ }else{
+ //i cant be 0 since we already checked for equal parentNode
+ if(bparents.length > aparents.length){
+ return Node.DOCUMENT_POSITION_FOLLOWING;
+ }else if(bparents.length < aparents.length){
+ return Node.DOCUMENT_POSITION_PRECEDING;
+ }else{
+ //common ancestor diverge point
+ if (i === 0) {
+ return Node.DOCUMENT_POSITION_FOLLOWING;
+ } else {
+ parent = aparents[i-1];
+ }
+ return parent.compareDocumentPosition(bparents.pop());
+ }
+ }
+ }
+
+ return Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|
+ Node.DOCUMENT_POSITION_DISCONNECTED;
+
+ },
+ toString : function() {
+ return '[object Node]';
+ }
+
+});
+
+
+
+/**
+ * @method __getElementsByTagNameRecursive__ - implements getElementsByTagName()
+ * @param elem : Element - The element which are checking and then recursing into
+ * @param tagname : string - The name of the tag to match on. The special value "*" matches all tags
+ * @param nodeList : NodeList - The accumulating list of matching nodes
+ *
+ * @return : NodeList
+ */
+var __getElementsByTagNameRecursive__ = function (elem, tagname, nodeList) {
+
+ if (elem.nodeType == Node.ELEMENT_NODE || elem.nodeType == Node.DOCUMENT_NODE) {
+
+ if(elem.nodeType !== Node.DOCUMENT_NODE &&
+ ((elem.nodeName.toUpperCase() == tagname.toUpperCase()) ||
+ (tagname == "*")) ){
+ // add matching node to nodeList
+ __appendChild__(nodeList, elem);
+ }
+
+ // recurse childNodes
+ for(var i = 0; i < elem.childNodes.length; i++) {
+ nodeList = __getElementsByTagNameRecursive__(elem.childNodes.item(i), tagname, nodeList);
+ }
+ }
+
+ return nodeList;
+};
+
+/**
+ * @method __getElementsByTagNameNSRecursive__
+ * implements getElementsByTagName()
+ *
+ * @param elem : Element - The element which are checking and then recursing into
+ * @param namespaceURI : string - the namespace URI of the required node
+ * @param localName : string - the local name of the required node
+ * @param nodeList : NodeList - The accumulating list of matching nodes
+ *
+ * @return : NodeList
+ */
+var __getElementsByTagNameNSRecursive__ = function(elem, namespaceURI, localName, nodeList) {
+ if (elem.nodeType == Node.ELEMENT_NODE || elem.nodeType == Node.DOCUMENT_NODE) {
+
+ if (((elem.namespaceURI == namespaceURI) || (namespaceURI == "*")) &&
+ ((elem.localName == localName) || (localName == "*"))) {
+ // add matching node to nodeList
+ __appendChild__(nodeList, elem);
+ }
+
+ // recurse childNodes
+ for(var i = 0; i < elem.childNodes.length; i++) {
+ nodeList = __getElementsByTagNameNSRecursive__(
+ elem.childNodes.item(i), namespaceURI, localName, nodeList);
+ }
+ }
+
+ return nodeList;
+};
+
+/**
+ * @method __isAncestor__ - returns true if node is ancestor of target
+ * @param target : Node - The node we are using as context
+ * @param node : Node - The candidate ancestor node
+ * @return : boolean
+ */
+var __isAncestor__ = function(target, node) {
+ // if this node matches, return true,
+ // otherwise recurse up (if there is a parentNode)
+ return ((target == node) || ((target.parentNode) && (__isAncestor__(target.parentNode, node))));
+};
+
+
+
+var __recursivelyGatherText__ = function(aNode) {
+ var accumulateText = "",
+ idx,
+ node;
+ for (idx=0;idx < aNode.childNodes.length;idx++){
+ node = aNode.childNodes.item(idx);
+ if(node.nodeType == Node.TEXT_NODE)
+ accumulateText += node.data;
+ else
+ accumulateText += __recursivelyGatherText__(node);
+ }
+ return accumulateText;
+};
+
+/**
+ * function __escapeXML__
+ * @param str : string - The string to be escaped
+ * @return : string - The escaped string
+ */
+var escAmpRegEx = /&(?!(amp;|lt;|gt;|quot|apos;))/g;
+var escLtRegEx = /</g;
+var escGtRegEx = />/g;
+var quotRegEx = /"/g;
+var aposRegEx = /'/g;
+
+function __escapeXML__(str) {
+ str = str.replace(escAmpRegEx, "&amp;").
+ replace(escLtRegEx, "&lt;").
+ replace(escGtRegEx, "&gt;").
+ replace(quotRegEx, "&quot;").
+ replace(aposRegEx, "&apos;");
+
+ return str;
+};
+
+/*
+function __escapeHTML5__(str) {
+ str = str.replace(escAmpRegEx, "&amp;").
+ replace(escLtRegEx, "&lt;").
+ replace(escGtRegEx, "&gt;");
+
+ return str;
+};
+function __escapeHTML5Atribute__(str) {
+ str = str.replace(escAmpRegEx, "&amp;").
+ replace(escLtRegEx, "&lt;").
+ replace(escGtRegEx, "&gt;").
+ replace(quotRegEx, "&quot;").
+ replace(aposRegEx, "&apos;");
+
+ return str;
+};
+*/
+
+/**
+ * function __unescapeXML__
+ * @param str : string - The string to be unescaped
+ * @return : string - The unescaped string
+ */
+var unescAmpRegEx = /&amp;/g;
+var unescLtRegEx = /&lt;/g;
+var unescGtRegEx = /&gt;/g;
+var unquotRegEx = /&quot;/g;
+var unaposRegEx = /&apos;/g;
+function __unescapeXML__(str) {
+ str = str.replace(unescAmpRegEx, "&").
+ replace(unescLtRegEx, "<").
+ replace(unescGtRegEx, ">").
+ replace(unquotRegEx, "\"").
+ replace(unaposRegEx, "'");
+
+ return str;
+};
+
+/**
+ * @class NamedNodeMap -
+ * used to represent collections of nodes that can be accessed by name
+ * typically a set of Element attributes
+ *
+ * @extends NodeList -
+ * note W3C spec says that this is not the case, but we need an item()
+ * method identical to NodeList's, so why not?
+ * @param ownerDocument : Document - the ownerDocument
+ * @param parentNode : Node - the node that the NamedNodeMap is attached to (or null)
+ */
+NamedNodeMap = function(ownerDocument, parentNode) {
+ NodeList.apply(this, arguments);
+ __setArray__(this, []);
+};
+NamedNodeMap.prototype = new NodeList();
+__extend__(NamedNodeMap.prototype, {
+ add: function(name){
+ this[this.length] = name;
+ },
+ getNamedItem : function(name) {
+ var ret = null;
+ //console.log('NamedNodeMap getNamedItem %s', name);
+ // test that Named Node exists
+ var itemIndex = __findNamedItemIndex__(this, name);
+
+ if (itemIndex > -1) {
+ // found it!
+ ret = this[itemIndex];
+ }
+ // if node is not found, default value null is returned
+ return ret;
+ },
+ setNamedItem : function(arg) {
+ //console.log('setNamedItem %s', arg);
+ // test for exceptions
+ if (__ownerDocument__(this).implementation.errorChecking) {
+ // throw Exception if arg was not created by this Document
+ if (this.ownerDocument != arg.ownerDocument) {
+ throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR));
+ }
+
+ // throw Exception if DOMNamedNodeMap is readonly
+ if (this._readonly || (this.parentNode && this.parentNode._readonly)) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // throw Exception if arg is already an attribute of another Element object
+ if (arg.ownerElement && (arg.ownerElement != this.parentNode)) {
+ throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR));
+ }
+ }
+
+ //console.log('setNamedItem __findNamedItemIndex__ ');
+ // get item index
+ var itemIndex = __findNamedItemIndex__(this, arg.name);
+ var ret = null;
+
+ //console.log('setNamedItem __findNamedItemIndex__ %s', itemIndex);
+ if (itemIndex > -1) { // found it!
+ ret = this[itemIndex]; // use existing Attribute
+
+ // throw Exception if DOMAttr is readonly
+ if (__ownerDocument__(this).implementation.errorChecking && ret._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ } else {
+ this[itemIndex] = arg; // over-write existing NamedNode
+ this[arg.name.toLowerCase()] = arg;
+ }
+ } else {
+ // add new NamedNode
+ //console.log('setNamedItem add new named node map (by index)');
+ Array.prototype.push.apply(this, [arg]);
+ //console.log('setNamedItem add new named node map (by name) %s %s', arg, arg.name);
+ this[arg.name] = arg;
+ //console.log('finsished setNamedItem add new named node map (by name) %s', arg.name);
+
+ }
+
+ //console.log('setNamedItem parentNode');
+ arg.ownerElement = this.parentNode; // update ownerElement
+ // return old node or new node
+ //console.log('setNamedItem exit');
+ return ret;
+ },
+ removeNamedItem : function(name) {
+ var ret = null;
+ // test for exceptions
+ // throw Exception if NamedNodeMap is readonly
+ if (__ownerDocument__(this).implementation.errorChecking &&
+ (this._readonly || (this.parentNode && this.parentNode._readonly))) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // get item index
+ var itemIndex = __findNamedItemIndex__(this, name);
+
+ // throw Exception if there is no node named name in this map
+ if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) {
+ throw(new DOMException(DOMException.NOT_FOUND_ERR));
+ }
+
+ // get Node
+ var oldNode = this[itemIndex];
+ //this[oldNode.name] = undefined;
+
+ // throw Exception if Node is readonly
+ if (__ownerDocument__(this).implementation.errorChecking && oldNode._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // return removed node
+ return __removeChild__(this, itemIndex);
+ },
+ getNamedItemNS : function(namespaceURI, localName) {
+ var ret = null;
+
+ // test that Named Node exists
+ var itemIndex = __findNamedItemNSIndex__(this, namespaceURI, localName);
+
+ if (itemIndex > -1) {
+ // found it! return NamedNode
+ ret = this[itemIndex];
+ }
+ // if node is not found, default value null is returned
+ return ret;
+ },
+ setNamedItemNS : function(arg) {
+ //console.log('setNamedItemNS %s', arg);
+ // test for exceptions
+ if (__ownerDocument__(this).implementation.errorChecking) {
+ // throw Exception if NamedNodeMap is readonly
+ if (this._readonly || (this.parentNode && this.parentNode._readonly)) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // throw Exception if arg was not created by this Document
+ if (__ownerDocument__(this) != __ownerDocument__(arg)) {
+ throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR));
+ }
+
+ // throw Exception if arg is already an attribute of another Element object
+ if (arg.ownerElement && (arg.ownerElement != this.parentNode)) {
+ throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR));
+ }
+ }
+
+ // get item index
+ var itemIndex = __findNamedItemNSIndex__(this, arg.namespaceURI, arg.localName);
+ var ret = null;
+
+ if (itemIndex > -1) {
+ // found it!
+ // use existing Attribute
+ ret = this[itemIndex];
+ // throw Exception if Attr is readonly
+ if (__ownerDocument__(this).implementation.errorChecking && ret._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ } else {
+ // over-write existing NamedNode
+ this[itemIndex] = arg;
+ }
+ }else {
+ // add new NamedNode
+ Array.prototype.push.apply(this, [arg]);
+ }
+ arg.ownerElement = this.parentNode;
+
+ // return old node or null
+ return ret;
+ //console.log('finished setNamedItemNS %s', arg);
+ },
+ removeNamedItemNS : function(namespaceURI, localName) {
+ var ret = null;
+
+ // test for exceptions
+ // throw Exception if NamedNodeMap is readonly
+ if (__ownerDocument__(this).implementation.errorChecking && (this._readonly || (this.parentNode && this.parentNode._readonly))) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // get item index
+ var itemIndex = __findNamedItemNSIndex__(this, namespaceURI, localName);
+
+ // throw Exception if there is no matching node in this map
+ if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) {
+ throw(new DOMException(DOMException.NOT_FOUND_ERR));
+ }
+
+ // get Node
+ var oldNode = this[itemIndex];
+
+ // throw Exception if Node is readonly
+ if (__ownerDocument__(this).implementation.errorChecking && oldNode._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ return __removeChild__(this, itemIndex); // return removed node
+ },
+ get xml() {
+ var ret = "";
+
+ // create string containing concatenation of all (but last) Attribute string values (separated by spaces)
+ for (var i=0; i < this.length -1; i++) {
+ ret += this[i].xml +" ";
+ }
+
+ // add last Attribute to string (without trailing space)
+ if (this.length > 0) {
+ ret += this[this.length -1].xml;
+ }
+
+ return ret;
+ },
+ toString : function(){
+ return "[object NamedNodeMap]";
+ }
+
+});
+
+/**
+ * @method __findNamedItemIndex__
+ * find the item index of the node with the specified name
+ *
+ * @param name : string - the name of the required node
+ * @param isnsmap : if its a NamespaceNodeMap
+ * @return : int
+ */
+var __findNamedItemIndex__ = function(namednodemap, name, isnsmap) {
+ var ret = -1;
+ // loop through all nodes
+ for (var i=0; i<namednodemap.length; i++) {
+ // compare name to each node's nodeName
+ if(namednodemap[i].localName && name && isnsmap){
+ if (namednodemap[i].localName.toLowerCase() == name.toLowerCase()) {
+ // found it!
+ ret = i;
+ break;
+ }
+ }else{
+ if(namednodemap[i].name && name){
+ if (namednodemap[i].name.toLowerCase() == name.toLowerCase()) {
+ // found it!
+ ret = i;
+ break;
+ }
+ }
+ }
+ }
+ // if node is not found, default value -1 is returned
+ return ret;
+};
+
+/**
+ * @method __findNamedItemNSIndex__
+ * find the item index of the node with the specified
+ * namespaceURI and localName
+ *
+ * @param namespaceURI : string - the namespace URI of the required node
+ * @param localName : string - the local name of the required node
+ * @return : int
+ */
+var __findNamedItemNSIndex__ = function(namednodemap, namespaceURI, localName) {
+ var ret = -1;
+ // test that localName is not null
+ if (localName) {
+ // loop through all nodes
+ for (var i=0; i<namednodemap.length; i++) {
+ if(namednodemap[i].namespaceURI && namednodemap[i].localName){
+ // compare name to each node's namespaceURI and localName
+ if ((namednodemap[i].namespaceURI.toLowerCase() == namespaceURI.toLowerCase()) &&
+ (namednodemap[i].localName.toLowerCase() == localName.toLowerCase())) {
+ // found it!
+ ret = i;
+ break;
+ }
+ }
+ }
+ }
+ // if node is not found, default value -1 is returned
+ return ret;
+};
+
+/**
+ * @method __hasAttribute__
+ * Returns true if specified node exists
+ *
+ * @param name : string - the name of the required node
+ * @return : boolean
+ */
+var __hasAttribute__ = function(namednodemap, name) {
+ var ret = false;
+ // test that Named Node exists
+ var itemIndex = __findNamedItemIndex__(namednodemap, name);
+ if (itemIndex > -1) {
+ // found it!
+ ret = true;
+ }
+ // if node is not found, default value false is returned
+ return ret;
+}
+
+/**
+ * @method __hasAttributeNS__
+ * Returns true if specified node exists
+ *
+ * @param namespaceURI : string - the namespace URI of the required node
+ * @param localName : string - the local name of the required node
+ * @return : boolean
+ */
+var __hasAttributeNS__ = function(namednodemap, namespaceURI, localName) {
+ var ret = false;
+ // test that Named Node exists
+ var itemIndex = __findNamedItemNSIndex__(namednodemap, namespaceURI, localName);
+ if (itemIndex > -1) {
+ // found it!
+ ret = true;
+ }
+ // if node is not found, default value false is returned
+ return ret;
+}
+
+/**
+ * @method __cloneNamedNodes__
+ * Returns a NamedNodeMap containing clones of the Nodes in this NamedNodeMap
+ *
+ * @param parentNode : Node - the new parent of the cloned NodeList
+ * @param isnsmap : bool - is this a NamespaceNodeMap
+ * @return NamedNodeMap containing clones of the Nodes in this NamedNodeMap
+ */
+var __cloneNamedNodes__ = function(namednodemap, parentNode, isnsmap) {
+ var cloneNamedNodeMap = isnsmap?
+ new NamespaceNodeMap(namednodemap.ownerDocument, parentNode):
+ new NamedNodeMap(namednodemap.ownerDocument, parentNode);
+
+ // create list containing clones of all children
+ for (var i=0; i < namednodemap.length; i++) {
+ __appendChild__(cloneNamedNodeMap, namednodemap[i].cloneNode(false));
+ }
+
+ return cloneNamedNodeMap;
+};
+
+
+/**
+ * @class NamespaceNodeMap -
+ * used to represent collections of namespace nodes that can be
+ * accessed by name typically a set of Element attributes
+ *
+ * @extends NamedNodeMap
+ *
+ * @param ownerDocument : Document - the ownerDocument
+ * @param parentNode : Node - the node that the NamespaceNodeMap is attached to (or null)
+ */
+var NamespaceNodeMap = function(ownerDocument, parentNode) {
+ this.NamedNodeMap = NamedNodeMap;
+ this.NamedNodeMap(ownerDocument, parentNode);
+ __setArray__(this, []);
+};
+NamespaceNodeMap.prototype = new NamedNodeMap();
+__extend__(NamespaceNodeMap.prototype, {
+ get xml() {
+ var ret = "",
+ ns,
+ ind;
+ // identify namespaces declared local to this Element (ie, not inherited)
+ for (ind = 0; ind < this.length; ind++) {
+ // if namespace declaration does not exist in the containing node's, parentNode's namespaces
+ ns = null;
+ try {
+ var ns = this.parentNode.parentNode._namespaces.
+ getNamedItem(this[ind].localName);
+ }catch (e) {
+ //breaking to prevent default namespace being inserted into return value
+ break;
+ }
+ if (!(ns && (""+ ns.nodeValue == ""+ this[ind].nodeValue))) {
+ // display the namespace declaration
+ ret += this[ind].xml +" ";
+ }
+ }
+ return ret;
+ }
+});
+
+/**
+ * @class Namespace -
+ * The Namespace interface represents an namespace in an Element object
+ *
+ * @param ownerDocument : The Document object associated with this node.
+ */
+Namespace = function(ownerDocument) {
+ Node.apply(this, arguments);
+ // the name of this attribute
+ this.name = "";
+
+ // If this attribute was explicitly given a value in the original document,
+ // this is true; otherwise, it is false.
+ // Note that the implementation is in charge of this attribute, not the user.
+ // If the user changes the value of the attribute (even if it ends up having
+ // the same value as the default value) then the specified flag is
+ // automatically flipped to true
+ this.specified = false;
+};
+Namespace.prototype = new Node();
+__extend__(Namespace.prototype, {
+ get value(){
+ // the value of the attribute is returned as a string
+ return this.nodeValue;
+ },
+ set value(value){
+ this.nodeValue = value+'';
+ },
+ get nodeType(){
+ return Node.NAMESPACE_NODE;
+ },
+ get xml(){
+ var ret = "";
+
+ // serialize Namespace Declaration
+ if (this.nodeName != "") {
+ ret += this.nodeName +"=\""+ __escapeXML__(this.nodeValue) +"\"";
+ }
+ else { // handle default namespace
+ ret += "xmlns=\""+ __escapeXML__(this.nodeValue) +"\"";
+ }
+
+ return ret;
+ },
+ toString: function(){
+ return '[object Namespace]';
+ }
+});
+
+
+/**
+ * @class CharacterData - parent abstract class for Text and Comment
+ * @extends Node
+ * @param ownerDocument : The Document object associated with this node.
+ */
+CharacterData = function(ownerDocument) {
+ Node.apply(this, arguments);
+};
+CharacterData.prototype = new Node();
+__extend__(CharacterData.prototype,{
+ get data(){
+ return this.nodeValue;
+ },
+ set data(data){
+ this.nodeValue = data;
+ },
+ get textContent(){
+ return this.nodeValue;
+ },
+ set textContent(newText){
+ this.nodeValue = newText;
+ },
+ get length(){return this.nodeValue.length;},
+ appendData: function(arg){
+ // throw Exception if CharacterData is readonly
+ if (__ownerDocument__(this).implementation.errorChecking && this._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+ // append data
+ this.data = "" + this.data + arg;
+ },
+ deleteData: function(offset, count){
+ // throw Exception if CharacterData is readonly
+ if (__ownerDocument__(this).implementation.errorChecking && this._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+ if (this.data) {
+ // throw Exception if offset is negative or greater than the data length,
+ if (__ownerDocument__(this).implementation.errorChecking &&
+ ((offset < 0) || (offset > this.data.length) || (count < 0))) {
+ throw(new DOMException(DOMException.INDEX_SIZE_ERR));
+ }
+
+ // delete data
+ if(!count || (offset + count) > this.data.length) {
+ this.data = this.data.substring(0, offset);
+ }else {
+ this.data = this.data.substring(0, offset).
+ concat(this.data.substring(offset + count));
+ }
+ }
+ },
+ insertData: function(offset, arg){
+ // throw Exception if CharacterData is readonly
+ if(__ownerDocument__(this).implementation.errorChecking && this._readonly){
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ if(this.data){
+ // throw Exception if offset is negative or greater than the data length,
+ if (__ownerDocument__(this).implementation.errorChecking &&
+ ((offset < 0) || (offset > this.data.length))) {
+ throw(new DOMException(DOMException.INDEX_SIZE_ERR));
+ }
+
+ // insert data
+ this.data = this.data.substring(0, offset).concat(arg, this.data.substring(offset));
+ }else {
+ // throw Exception if offset is negative or greater than the data length,
+ if (__ownerDocument__(this).implementation.errorChecking && (offset !== 0)) {
+ throw(new DOMException(DOMException.INDEX_SIZE_ERR));
+ }
+
+ // set data
+ this.data = arg;
+ }
+ },
+ replaceData: function(offset, count, arg){
+ // throw Exception if CharacterData is readonly
+ if (__ownerDocument__(this).implementation.errorChecking && this._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ if (this.data) {
+ // throw Exception if offset is negative or greater than the data length,
+ if (__ownerDocument__(this).implementation.errorChecking &&
+ ((offset < 0) || (offset > this.data.length) || (count < 0))) {
+ throw(new DOMException(DOMException.INDEX_SIZE_ERR));
+ }
+
+ // replace data
+ this.data = this.data.substring(0, offset).
+ concat(arg, this.data.substring(offset + count));
+ }else {
+ // set data
+ this.data = arg;
+ }
+ },
+ substringData: function(offset, count){
+ var ret = null;
+ if (this.data) {
+ // throw Exception if offset is negative or greater than the data length,
+ // or the count is negative
+ if (__ownerDocument__(this).implementation.errorChecking &&
+ ((offset < 0) || (offset > this.data.length) || (count < 0))) {
+ throw(new DOMException(DOMException.INDEX_SIZE_ERR));
+ }
+ // if count is not specified
+ if (!count) {
+ ret = this.data.substring(offset); // default to 'end of string'
+ }else{
+ ret = this.data.substring(offset, offset + count);
+ }
+ }
+ return ret;
+ },
+ toString : function(){
+ return "[object CharacterData]";
+ }
+});
+
+/**
+ * @class Text
+ * The Text interface represents the textual content (termed
+ * character data in XML) of an Element or Attr.
+ * If there is no markup inside an element's content, the text is
+ * contained in a single object implementing the Text interface that
+ * is the only child of the element. If there is markup, it is
+ * parsed into a list of elements and Text nodes that form the
+ * list of children of the element.
+ * @extends CharacterData
+ * @param ownerDocument The Document object associated with this node.
+ */
+Text = function(ownerDocument) {
+ CharacterData.apply(this, arguments);
+ this.nodeName = "#text";
+};
+Text.prototype = new CharacterData();
+__extend__(Text.prototype,{
+ get localName(){
+ return null;
+ },
+ // Breaks this Text node into two Text nodes at the specified offset,
+ // keeping both in the tree as siblings. This node then only contains
+ // all the content up to the offset point. And a new Text node, which
+ // is inserted as the next sibling of this node, contains all the
+ // content at and after the offset point.
+ splitText : function(offset) {
+ var data,
+ inode;
+ // test for exceptions
+ if (__ownerDocument__(this).implementation.errorChecking) {
+ // throw Exception if Node is readonly
+ if (this._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+ // throw Exception if offset is negative or greater than the data length,
+ if ((offset < 0) || (offset > this.data.length)) {
+ throw(new DOMException(DOMException.INDEX_SIZE_ERR));
+ }
+ }
+ if (this.parentNode) {
+ // get remaining string (after offset)
+ data = this.substringData(offset);
+ // create new TextNode with remaining string
+ inode = __ownerDocument__(this).createTextNode(data);
+ // attach new TextNode
+ if (this.nextSibling) {
+ this.parentNode.insertBefore(inode, this.nextSibling);
+ } else {
+ this.parentNode.appendChild(inode);
+ }
+ // remove remaining string from original TextNode
+ this.deleteData(offset);
+ }
+ return inode;
+ },
+ get nodeType(){
+ return Node.TEXT_NODE;
+ },
+ get xml(){
+ return __escapeXML__(""+ this.nodeValue);
+ },
+ toString: function(){
+ return "[object Text]";
+ }
+});
+
+/**
+ * @class CDATASection
+ * CDATA sections are used to escape blocks of text containing
+ * characters that would otherwise be regarded as markup.
+ * The only delimiter that is recognized in a CDATA section is
+ * the "\]\]\>" string that ends the CDATA section
+ * @extends Text
+ * @param ownerDocument : The Document object associated with this node.
+ */
+CDATASection = function(ownerDocument) {
+ Text.apply(this, arguments);
+ this.nodeName = '#cdata-section';
+};
+CDATASection.prototype = new Text();
+__extend__(CDATASection.prototype,{
+ get nodeType(){
+ return Node.CDATA_SECTION_NODE;
+ },
+ get xml(){
+ return "<![CDATA[" + this.nodeValue + "]]>";
+ },
+ toString : function(){
+ return "[object CDATASection]";
+ }
+});
+/**
+ * @class Comment
+ * This represents the content of a comment, i.e., all the
+ * characters between the starting '<!--' and ending '-->'
+ * @extends CharacterData
+ * @param ownerDocument : The Document object associated with this node.
+ */
+Comment = function(ownerDocument) {
+ CharacterData.apply(this, arguments);
+ this.nodeName = "#comment";
+};
+Comment.prototype = new CharacterData();
+__extend__(Comment.prototype, {
+ get localName(){
+ return null;
+ },
+ get nodeType(){
+ return Node.COMMENT_NODE;
+ },
+ get xml(){
+ return "<!--" + this.nodeValue + "-->";
+ },
+ toString : function(){
+ return "[object Comment]";
+ }
+});
+
+
+/**
+ * @author envjs team
+ * @param {Document} onwnerDocument
+ */
+DocumentType = function(ownerDocument) {
+ Node.apply(this, arguments);
+ this.systemId = null;
+ this.publicId = null;
+};
+DocumentType.prototype = new Node();
+__extend__({
+ get name(){
+ return this.nodeName;
+ },
+ get entities(){
+ return null;
+ },
+ get internalSubsets(){
+ return null;
+ },
+ get notations(){
+ return null;
+ },
+ toString : function(){
+ return "[object DocumentType]";
+ }
+});
+
+/**
+ * @class Attr
+ * The Attr interface represents an attribute in an Element object
+ * @extends Node
+ * @param ownerDocument : The Document object associated with this node.
+ */
+Attr = function(ownerDocument) {
+ Node.apply(this, arguments);
+ // set when Attr is added to NamedNodeMap
+ this.ownerElement = null;
+ //TODO: our implementation of Attr is incorrect because we don't
+ // treat the value of the attribute as a child text node.
+};
+Attr.prototype = new Node();
+__extend__(Attr.prototype, {
+ // the name of this attribute
+ get name(){
+ return this.nodeName;
+ },
+ // the value of the attribute is returned as a string
+ get value(){
+ return this.nodeValue||'';
+ },
+ set value(value){
+ // throw Exception if Attribute is readonly
+ if (__ownerDocument__(this).implementation.errorChecking && this._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+ // delegate to node
+ this.nodeValue = value;
+ },
+ get textContent(){
+ return this.nodeValue;
+ },
+ set textContent(newText){
+ this.nodeValue = newText;
+ },
+ get specified(){
+ return (this !== null && this !== undefined);
+ },
+ get nodeType(){
+ return Node.ATTRIBUTE_NODE;
+ },
+ get xml() {
+ if (this.nodeValue) {
+ return __escapeXML__(this.nodeValue+"");
+ } else {
+ return '';
+ }
+ },
+ toString : function() {
+ return '[object Attr]';
+ }
+});
+
+
+/**
+ * @class Element -
+ * By far the vast majority of objects (apart from text)
+ * that authors encounter when traversing a document are
+ * Element nodes.
+ * @extends Node
+ * @param ownerDocument : The Document object associated with this node.
+ */
+Element = function(ownerDocument) {
+ Node.apply(this, arguments);
+ this.attributes = new NamedNodeMap(this.ownerDocument, this);
+};
+Element.prototype = new Node();
+__extend__(Element.prototype, {
+ // The name of the element.
+ get tagName(){
+ return this.nodeName;
+ },
+
+ getAttribute: function(name) {
+ var ret = null;
+ // if attribute exists, use it
+ var attr = this.attributes.getNamedItem(name);
+ if (attr) {
+ ret = attr.value;
+ }
+ // if Attribute exists, return its value, otherwise, return null
+ return ret;
+ },
+ setAttribute : function (name, value) {
+ // if attribute exists, use it
+ var attr = this.attributes.getNamedItem(name);
+ //console.log('attr %s', attr);
+ //I had to add this check because as the script initializes
+ //the id may be set in the constructor, and the html element
+ //overrides the id property with a getter/setter.
+ if(__ownerDocument__(this)){
+ if (attr===null||attr===undefined) {
+ // otherwise create it
+ attr = __ownerDocument__(this).createAttribute(name);
+ //console.log('attr %s', attr);
+ }
+
+
+ // test for exceptions
+ if (__ownerDocument__(this).implementation.errorChecking) {
+ // throw Exception if Attribute is readonly
+ if (attr._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // throw Exception if the value string contains an illegal character
+ if (!__isValidString__(value+'')) {
+ throw(new DOMException(DOMException.INVALID_CHARACTER_ERR));
+ }
+ }
+
+ // assign values to properties (and aliases)
+ attr.value = value + '';
+
+ // add/replace Attribute in NamedNodeMap
+ this.attributes.setNamedItem(attr);
+ //console.log('element setNamedItem %s', attr);
+ }else{
+ console.warn('Element has no owner document '+this.tagName+
+ '\n\t cant set attribute ' + name + ' = '+value );
+ }
+ },
+ removeAttribute : function removeAttribute(name) {
+ // delegate to NamedNodeMap.removeNamedItem
+ return this.attributes.removeNamedItem(name);
+ },
+ getAttributeNode : function getAttributeNode(name) {
+ // delegate to NamedNodeMap.getNamedItem
+ return this.attributes.getNamedItem(name);
+ },
+ setAttributeNode: function(newAttr) {
+ // if this Attribute is an ID
+ if (__isIdDeclaration__(newAttr.name)) {
+ this.id = newAttr.value; // cache ID for getElementById()
+ }
+ // delegate to NamedNodeMap.setNamedItem
+ return this.attributes.setNamedItem(newAttr);
+ },
+ removeAttributeNode: function(oldAttr) {
+ // throw Exception if Attribute is readonly
+ if (__ownerDocument__(this).implementation.errorChecking && oldAttr._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // get item index
+ var itemIndex = this.attributes._findItemIndex(oldAttr._id);
+
+ // throw Exception if node does not exist in this map
+ if (__ownerDocument__(this).implementation.errorChecking && (itemIndex < 0)) {
+ throw(new DOMException(DOMException.NOT_FOUND_ERR));
+ }
+
+ return this.attributes._removeChild(itemIndex);
+ },
+ getAttributeNS : function(namespaceURI, localName) {
+ var ret = "";
+ // delegate to NAmedNodeMap.getNamedItemNS
+ var attr = this.attributes.getNamedItemNS(namespaceURI, localName);
+ if (attr) {
+ ret = attr.value;
+ }
+ return ret; // if Attribute exists, return its value, otherwise return ""
+ },
+ setAttributeNS : function(namespaceURI, qualifiedName, value) {
+ // call NamedNodeMap.getNamedItem
+ //console.log('setAttributeNS %s %s %s', namespaceURI, qualifiedName, value);
+ var attr = this.attributes.getNamedItem(namespaceURI, qualifiedName);
+
+ if (!attr) { // if Attribute exists, use it
+ // otherwise create it
+ attr = __ownerDocument__(this).createAttributeNS(namespaceURI, qualifiedName);
+ }
+
+ value = '' + value;
+
+ // test for exceptions
+ if (__ownerDocument__(this).implementation.errorChecking) {
+ // throw Exception if Attribute is readonly
+ if (attr._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+
+ // throw Exception if the Namespace is invalid
+ if (!__isValidNamespace__(this.ownerDocument, namespaceURI, qualifiedName, true)) {
+ throw(new DOMException(DOMException.NAMESPACE_ERR));
+ }
+
+ // throw Exception if the value string contains an illegal character
+ if (!__isValidString__(value)) {
+ throw(new DOMException(DOMException.INVALID_CHARACTER_ERR));
+ }
+ }
+
+ // if this Attribute is an ID
+ //if (__isIdDeclaration__(name)) {
+ // this.id = value;
+ //}
+
+ // assign values to properties (and aliases)
+ attr.value = value;
+ attr.nodeValue = value;
+
+ // delegate to NamedNodeMap.setNamedItem
+ this.attributes.setNamedItemNS(attr);
+ },
+ removeAttributeNS : function(namespaceURI, localName) {
+ // delegate to NamedNodeMap.removeNamedItemNS
+ return this.attributes.removeNamedItemNS(namespaceURI, localName);
+ },
+ getAttributeNodeNS : function(namespaceURI, localName) {
+ // delegate to NamedNodeMap.getNamedItemNS
+ return this.attributes.getNamedItemNS(namespaceURI, localName);
+ },
+ setAttributeNodeNS : function(newAttr) {
+ // if this Attribute is an ID
+ if ((newAttr.prefix == "") && __isIdDeclaration__(newAttr.name)) {
+ this.id = newAttr.value+''; // cache ID for getElementById()
+ }
+
+ // delegate to NamedNodeMap.setNamedItemNS
+ return this.attributes.setNamedItemNS(newAttr);
+ },
+ hasAttribute : function(name) {
+ // delegate to NamedNodeMap._hasAttribute
+ return __hasAttribute__(this.attributes,name);
+ },
+ hasAttributeNS : function(namespaceURI, localName) {
+ // delegate to NamedNodeMap._hasAttributeNS
+ return __hasAttributeNS__(this.attributes, namespaceURI, localName);
+ },
+ get nodeType(){
+ return Node.ELEMENT_NODE;
+ },
+ get xml() {
+ var ret = "",
+ ns = "",
+ attrs,
+ attrstring,
+ i;
+
+ // serialize namespace declarations
+ if (this.namespaceURI ){
+ if((this === this.ownerDocument.documentElement) ||
+ (!this.parentNode)||
+ (this.parentNode && (this.parentNode.namespaceURI !== this.namespaceURI))) {
+ ns = ' xmlns' + (this.prefix?(':'+this.prefix):'') +
+ '="' + this.namespaceURI + '"';
+ }
+ }
+
+ // serialize Attribute declarations
+ attrs = this.attributes;
+ attrstring = "";
+ for(i=0;i< attrs.length;i++){
+ if(attrs[i].name.match('xmlns:')) {
+ attrstring += " "+attrs[i].name+'="'+attrs[i].xml+'"';
+ }
+ }
+ for(i=0;i< attrs.length;i++){
+ if(!attrs[i].name.match('xmlns:')) {
+ attrstring += " "+attrs[i].name+'="'+attrs[i].xml+'"';
+ }
+ }
+
+ if(this.hasChildNodes()){
+ // serialize this Element
+ ret += "<" + this.tagName + ns + attrstring +">";
+ ret += this.childNodes.xml;
+ ret += "</" + this.tagName + ">";
+ }else{
+ ret += "<" + this.tagName + ns + attrstring +"/>";
+ }
+
+ return ret;
+ },
+ toString : function(){
+ return '[object Element]';
+ }
+});
+/**
+ * @class DOMException - raised when an operation is impossible to perform
+ * @author Jon van Noort (jon@webarcana.com.au)
+ * @param code : int - the exception code (one of the DOMException constants)
+ */
+DOMException = function(code) {
+ this.code = code;
+};
+
+// DOMException constants
+// Introduced in DOM Level 1:
+DOMException.INDEX_SIZE_ERR = 1;
+DOMException.DOMSTRING_SIZE_ERR = 2;
+DOMException.HIERARCHY_REQUEST_ERR = 3;
+DOMException.WRONG_DOCUMENT_ERR = 4;
+DOMException.INVALID_CHARACTER_ERR = 5;
+DOMException.NO_DATA_ALLOWED_ERR = 6;
+DOMException.NO_MODIFICATION_ALLOWED_ERR = 7;
+DOMException.NOT_FOUND_ERR = 8;
+DOMException.NOT_SUPPORTED_ERR = 9;
+DOMException.INUSE_ATTRIBUTE_ERR = 10;
+
+// Introduced in DOM Level 2:
+DOMException.INVALID_STATE_ERR = 11;
+DOMException.SYNTAX_ERR = 12;
+DOMException.INVALID_MODIFICATION_ERR = 13;
+DOMException.NAMESPACE_ERR = 14;
+DOMException.INVALID_ACCESS_ERR = 15;
+
+/**
+ * @class DocumentFragment -
+ * DocumentFragment is a "lightweight" or "minimal" Document object.
+ * @extends Node
+ * @param ownerDocument : The Document object associated with this node.
+ */
+DocumentFragment = function(ownerDocument) {
+ Node.apply(this, arguments);
+ this.nodeName = "#document-fragment";
+};
+DocumentFragment.prototype = new Node();
+__extend__(DocumentFragment.prototype,{
+ get nodeType(){
+ return Node.DOCUMENT_FRAGMENT_NODE;
+ },
+ get xml(){
+ var xml = "",
+ count = this.childNodes.length;
+
+ // create string concatenating the serialized ChildNodes
+ for (var i = 0; i < count; i++) {
+ xml += this.childNodes.item(i).xml;
+ }
+
+ return xml;
+ },
+ toString : function(){
+ return "[object DocumentFragment]";
+ },
+ get localName(){
+ return null;
+ }
+});
+
+
+/**
+ * @class ProcessingInstruction -
+ * The ProcessingInstruction interface represents a
+ * "processing instruction", used in XML as a way to
+ * keep processor-specific information in the text of
+ * the document
+ * @extends Node
+ * @author Jon van Noort (jon@webarcana.com.au)
+ * @param ownerDocument : The Document object associated with this node.
+ */
+ProcessingInstruction = function(ownerDocument) {
+ Node.apply(this, arguments);
+};
+ProcessingInstruction.prototype = new Node();
+__extend__(ProcessingInstruction.prototype, {
+ get data(){
+ return this.nodeValue;
+ },
+ set data(data){
+ // throw Exception if Node is readonly
+ if (__ownerDocument__(this).errorChecking && this._readonly) {
+ throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
+ }
+ this.nodeValue = data;
+ },
+ get textContent(){
+ return this.data;
+ },
+ get localName(){
+ return null;
+ },
+ get target(){
+ // The target of this processing instruction.
+ // XML defines this as being the first token following the markup that begins the processing instruction.
+ // The content of this processing instruction.
+ return this.nodeName;
+ },
+ set target(value){
+ // The target of this processing instruction.
+ // XML defines this as being the first token following the markup that begins the processing instruction.
+ // The content of this processing instruction.
+ this.nodeName = value;
+ },
+ get nodeType(){
+ return Node.PROCESSING_INSTRUCTION_NODE;
+ },
+ get xml(){
+ return "<?" + this.nodeName +" "+ this.nodeValue + "?>";
+ },
+ toString : function(){
+ return "[object ProcessingInstruction]";
+ }
+});
+
+
+/**
+ * @author envjs team
+ */
+
+Entity = function() {
+ throw new Error("Entity Not Implemented" );
+};
+
+Entity.constants = {
+ // content taken from W3C "HTML 4.01 Specification"
+ // "W3C Recommendation 24 December 1999"
+
+ nbsp: "\u00A0",
+ iexcl: "\u00A1",
+ cent: "\u00A2",
+ pound: "\u00A3",
+ curren: "\u00A4",
+ yen: "\u00A5",
+ brvbar: "\u00A6",
+ sect: "\u00A7",
+ uml: "\u00A8",
+ copy: "\u00A9",
+ ordf: "\u00AA",
+ laquo: "\u00AB",
+ not: "\u00AC",
+ shy: "\u00AD",
+ reg: "\u00AE",
+ macr: "\u00AF",
+ deg: "\u00B0",
+ plusmn: "\u00B1",
+ sup2: "\u00B2",
+ sup3: "\u00B3",
+ acute: "\u00B4",
+ micro: "\u00B5",
+ para: "\u00B6",
+ middot: "\u00B7",
+ cedil: "\u00B8",
+ sup1: "\u00B9",
+ ordm: "\u00BA",
+ raquo: "\u00BB",
+ frac14: "\u00BC",
+ frac12: "\u00BD",
+ frac34: "\u00BE",
+ iquest: "\u00BF",
+ Agrave: "\u00C0",
+ Aacute: "\u00C1",
+ Acirc: "\u00C2",
+ Atilde: "\u00C3",
+ Auml: "\u00C4",
+ Aring: "\u00C5",
+ AElig: "\u00C6",
+ Ccedil: "\u00C7",
+ Egrave: "\u00C8",
+ Eacute: "\u00C9",
+ Ecirc: "\u00CA",
+ Euml: "\u00CB",
+ Igrave: "\u00CC",
+ Iacute: "\u00CD",
+ Icirc: "\u00CE",
+ Iuml: "\u00CF",
+ ETH: "\u00D0",
+ Ntilde: "\u00D1",
+ Ograve: "\u00D2",
+ Oacute: "\u00D3",
+ Ocirc: "\u00D4",
+ Otilde: "\u00D5",
+ Ouml: "\u00D6",
+ times: "\u00D7",
+ Oslash: "\u00D8",
+ Ugrave: "\u00D9",
+ Uacute: "\u00DA",
+ Ucirc: "\u00DB",
+ Uuml: "\u00DC",
+ Yacute: "\u00DD",
+ THORN: "\u00DE",
+ szlig: "\u00DF",
+ agrave: "\u00E0",
+ aacute: "\u00E1",
+ acirc: "\u00E2",
+ atilde: "\u00E3",
+ auml: "\u00E4",
+ aring: "\u00E5",
+ aelig: "\u00E6",
+ ccedil: "\u00E7",
+ egrave: "\u00E8",
+ eacute: "\u00E9",
+ ecirc: "\u00EA",
+ euml: "\u00EB",
+ igrave: "\u00EC",
+ iacute: "\u00ED",
+ icirc: "\u00EE",
+ iuml: "\u00EF",
+ eth: "\u00F0",
+ ntilde: "\u00F1",
+ ograve: "\u00F2",
+ oacute: "\u00F3",
+ ocirc: "\u00F4",
+ otilde: "\u00F5",
+ ouml: "\u00F6",
+ divide: "\u00F7",
+ oslash: "\u00F8",
+ ugrave: "\u00F9",
+ uacute: "\u00FA",
+ ucirc: "\u00FB",
+ uuml: "\u00FC",
+ yacute: "\u00FD",
+ thorn: "\u00FE",
+ yuml: "\u00FF",
+ fnof: "\u0192",
+ Alpha: "\u0391",
+ Beta: "\u0392",
+ Gamma: "\u0393",
+ Delta: "\u0394",
+ Epsilon: "\u0395",
+ Zeta: "\u0396",
+ Eta: "\u0397",
+ Theta: "\u0398",
+ Iota: "\u0399",
+ Kappa: "\u039A",
+ Lambda: "\u039B",
+ Mu: "\u039C",
+ Nu: "\u039D",
+ Xi: "\u039E",
+ Omicron: "\u039F",
+ Pi: "\u03A0",
+ Rho: "\u03A1",
+ Sigma: "\u03A3",
+ Tau: "\u03A4",
+ Upsilon: "\u03A5",
+ Phi: "\u03A6",
+ Chi: "\u03A7",
+ Psi: "\u03A8",
+ Omega: "\u03A9",
+ alpha: "\u03B1",
+ beta: "\u03B2",
+ gamma: "\u03B3",
+ delta: "\u03B4",
+ epsilon: "\u03B5",
+ zeta: "\u03B6",
+ eta: "\u03B7",
+ theta: "\u03B8",
+ iota: "\u03B9",
+ kappa: "\u03BA",
+ lambda: "\u03BB",
+ mu: "\u03BC",
+ nu: "\u03BD",
+ xi: "\u03BE",
+ omicron: "\u03BF",
+ pi: "\u03C0",
+ rho: "\u03C1",
+ sigmaf: "\u03C2",
+ sigma: "\u03C3",
+ tau: "\u03C4",
+ upsilon: "\u03C5",
+ phi: "\u03C6",
+ chi: "\u03C7",
+ psi: "\u03C8",
+ omega: "\u03C9",
+ thetasym: "\u03D1",
+ upsih: "\u03D2",
+ piv: "\u03D6",
+ bull: "\u2022",
+ hellip: "\u2026",
+ prime: "\u2032",
+ Prime: "\u2033",
+ oline: "\u203E",
+ frasl: "\u2044",
+ weierp: "\u2118",
+ image: "\u2111",
+ real: "\u211C",
+ trade: "\u2122",
+ alefsym: "\u2135",
+ larr: "\u2190",
+ uarr: "\u2191",
+ rarr: "\u2192",
+ darr: "\u2193",
+ harr: "\u2194",
+ crarr: "\u21B5",
+ lArr: "\u21D0",
+ uArr: "\u21D1",
+ rArr: "\u21D2",
+ dArr: "\u21D3",
+ hArr: "\u21D4",
+ forall: "\u2200",
+ part: "\u2202",
+ exist: "\u2203",
+ empty: "\u2205",
+ nabla: "\u2207",
+ isin: "\u2208",
+ notin: "\u2209",
+ ni: "\u220B",
+ prod: "\u220F",
+ sum: "\u2211",
+ minus: "\u2212",
+ lowast: "\u2217",
+ radic: "\u221A",
+ prop: "\u221D",
+ infin: "\u221E",
+ ang: "\u2220",
+ and: "\u2227",
+ or: "\u2228",
+ cap: "\u2229",
+ cup: "\u222A",
+ intXX: "\u222B",
+ there4: "\u2234",
+ sim: "\u223C",
+ cong: "\u2245",
+ asymp: "\u2248",
+ ne: "\u2260",
+ equiv: "\u2261",
+ le: "\u2264",
+ ge: "\u2265",
+ sub: "\u2282",
+ sup: "\u2283",
+ nsub: "\u2284",
+ sube: "\u2286",
+ supe: "\u2287",
+ oplus: "\u2295",
+ otimes: "\u2297",
+ perp: "\u22A5",
+ sdot: "\u22C5",
+ lceil: "\u2308",
+ rceil: "\u2309",
+ lfloor: "\u230A",
+ rfloor: "\u230B",
+ lang: "\u2329",
+ rang: "\u232A",
+ loz: "\u25CA",
+ spades: "\u2660",
+ clubs: "\u2663",
+ hearts: "\u2665",
+ diams: "\u2666",
+ quot: "\u0022",
+ amp: "\u0026",
+ lt: "\u003C",
+ gt: "\u003E",
+ OElig: "\u0152",
+ oelig: "\u0153",
+ Scaron: "\u0160",
+ scaron: "\u0161",
+ Yuml: "\u0178",
+ circ: "\u02C6",
+ tilde: "\u02DC",
+ ensp: "\u2002",
+ emsp: "\u2003",
+ thinsp: "\u2009",
+ zwnj: "\u200C",
+ zwj: "\u200D",
+ lrm: "\u200E",
+ rlm: "\u200F",
+ ndash: "\u2013",
+ mdash: "\u2014",
+ lsquo: "\u2018",
+ rsquo: "\u2019",
+ sbquo: "\u201A",
+ ldquo: "\u201C",
+ rdquo: "\u201D",
+ bdquo: "\u201E",
+ dagger: "\u2020",
+ Dagger: "\u2021",
+ permil: "\u2030",
+ lsaquo: "\u2039",
+ rsaquo: "\u203A",
+ euro: "\u20AC",
+
+ // non-standard entities
+ apos: "'"
+};
+
+/**
+ * @author envjs team
+ */
+
+EntityReference = function() {
+ throw new Error("EntityReference Not Implemented" );
+};
+
+/**
+ * @class DOMImplementation -
+ * provides a number of methods for performing operations
+ * that are independent of any particular instance of the
+ * document object model.
+ *
+ * @author Jon van Noort (jon@webarcana.com.au)
+ */
+DOMImplementation = function() {
+ this.preserveWhiteSpace = false; // by default, ignore whitespace
+ this.namespaceAware = true; // by default, handle namespaces
+ this.errorChecking = true; // by default, test for exceptions
+};
+
+__extend__(DOMImplementation.prototype,{
+ // @param feature : string - The package name of the feature to test.
+ // the legal only values are "XML" and "CORE" (case-insensitive).
+ // @param version : string - This is the version number of the package
+ // name to test. In Level 1, this is the string "1.0".*
+ // @return : boolean
+ hasFeature : function(feature, version) {
+ var ret = false;
+ if (feature.toLowerCase() == "xml") {
+ ret = (!version || (version == "1.0") || (version == "2.0"));
+ }
+ else if (feature.toLowerCase() == "core") {
+ ret = (!version || (version == "2.0"));
+ }
+ else if (feature == "http://www.w3.org/TR/SVG11/feature#BasicStructure") {
+ ret = (version == "1.1");
+ }
+ return ret;
+ },
+ createDocumentType : function(qname, publicId, systemId){
+ var doctype = new DocumentType();
+ doctype.nodeName = qname?qname.toUpperCase():null;
+ doctype.publicId = publicId?publicId:null;
+ doctype.systemId = systemId?systemId:null;
+ return doctype;
+ },
+ createDocument : function(nsuri, qname, doctype){
+
+ var doc = null, documentElement;
+
+ doc = new Document(this, null);
+ if(doctype){
+ doc.doctype = doctype;
+ }
+
+ if(nsuri && qname){
+ documentElement = doc.createElementNS(nsuri, qname);
+ }else if(qname){
+ documentElement = doc.createElement(qname);
+ }
+ if(documentElement){
+ doc.appendChild(documentElement);
+ }
+ return doc;
+ },
+ createHTMLDocument : function(title){
+ var doc = new HTMLDocument($implementation, null, "");
+ var html = doc.createElement("html"); doc.appendChild(html);
+ var head = doc.createElement("head"); html.appendChild(head);
+ var body = doc.createElement("body"); html.appendChild(body);
+ var t = doc.createElement("title"); head.appendChild(t);
+ if( title) {
+ t.appendChild(doc.createTextNode(title));
+ }
+ return doc;
+ },
+ translateErrCode : function(code) {
+ //convert DOMException Code to human readable error message;
+ var msg = "";
+
+ switch (code) {
+ case DOMException.INDEX_SIZE_ERR : // 1
+ msg = "INDEX_SIZE_ERR: Index out of bounds";
+ break;
+
+ case DOMException.DOMSTRING_SIZE_ERR : // 2
+ msg = "DOMSTRING_SIZE_ERR: The resulting string is too long to fit in a DOMString";
+ break;
+
+ case DOMException.HIERARCHY_REQUEST_ERR : // 3
+ msg = "HIERARCHY_REQUEST_ERR: The Node can not be inserted at this location";
+ break;
+
+ case DOMException.WRONG_DOCUMENT_ERR : // 4
+ msg = "WRONG_DOCUMENT_ERR: The source and the destination Documents are not the same";
+ break;
+
+ case DOMException.INVALID_CHARACTER_ERR : // 5
+ msg = "INVALID_CHARACTER_ERR: The string contains an invalid character";
+ break;
+
+ case DOMException.NO_DATA_ALLOWED_ERR : // 6
+ msg = "NO_DATA_ALLOWED_ERR: This Node / NodeList does not support data";
+ break;
+
+ case DOMException.NO_MODIFICATION_ALLOWED_ERR : // 7
+ msg = "NO_MODIFICATION_ALLOWED_ERR: This object cannot be modified";
+ break;
+
+ case DOMException.NOT_FOUND_ERR : // 8
+ msg = "NOT_FOUND_ERR: The item cannot be found";
+ break;
+
+ case DOMException.NOT_SUPPORTED_ERR : // 9
+ msg = "NOT_SUPPORTED_ERR: This implementation does not support function";
+ break;
+
+ case DOMException.INUSE_ATTRIBUTE_ERR : // 10
+ msg = "INUSE_ATTRIBUTE_ERR: The Attribute has already been assigned to another Element";
+ break;
+
+ // Introduced in DOM Level 2:
+ case DOMException.INVALID_STATE_ERR : // 11
+ msg = "INVALID_STATE_ERR: The object is no longer usable";
+ break;
+
+ case DOMException.SYNTAX_ERR : // 12
+ msg = "SYNTAX_ERR: Syntax error";
+ break;
+
+ case DOMException.INVALID_MODIFICATION_ERR : // 13
+ msg = "INVALID_MODIFICATION_ERR: Cannot change the type of the object";
+ break;
+
+ case DOMException.NAMESPACE_ERR : // 14
+ msg = "NAMESPACE_ERR: The namespace declaration is incorrect";
+ break;
+
+ case DOMException.INVALID_ACCESS_ERR : // 15
+ msg = "INVALID_ACCESS_ERR: The object does not support this function";
+ break;
+
+ default :
+ msg = "UNKNOWN: Unknown Exception Code ("+ code +")";
+ }
+
+ return msg;
+ },
+ toString : function(){
+ return "[object DOMImplementation]";
+ }
+});
+
+
+
+/**
+ * @method DOMImplementation._isNamespaceDeclaration - Return true, if attributeName is a namespace declaration
+ * @author Jon van Noort (jon@webarcana.com.au)
+ * @param attributeName : string - the attribute name
+ * @return : boolean
+ */
+function __isNamespaceDeclaration__(attributeName) {
+ // test if attributeName is 'xmlns'
+ return (attributeName.indexOf('xmlns') > -1);
+}
+
+/**
+ * @method DOMImplementation._isIdDeclaration - Return true, if attributeName is an id declaration
+ * @author Jon van Noort (jon@webarcana.com.au)
+ * @param attributeName : string - the attribute name
+ * @return : boolean
+ */
+function __isIdDeclaration__(attributeName) {
+ // test if attributeName is 'id' (case insensitive)
+ return attributeName?(attributeName.toLowerCase() == 'id'):false;
+}
+
+/**
+ * @method DOMImplementation._isValidName - Return true,
+ * if name contains no invalid characters
+ * @author Jon van Noort (jon@webarcana.com.au)
+ * @param name : string - the candidate name
+ * @return : boolean
+ */
+function __isValidName__(name) {
+ // test if name contains only valid characters
+ return name.match(re_validName);
+}
+var re_validName = /^[a-zA-Z_:][a-zA-Z0-9\.\-_:]*$/;
+
+/**
+ * @method DOMImplementation._isValidString - Return true, if string does not contain any illegal chars
+ * All of the characters 0 through 31 and character 127 are nonprinting control characters.
+ * With the exception of characters 09, 10, and 13, (Ox09, Ox0A, and Ox0D)
+ * Note: different from _isValidName in that ValidStrings may contain spaces
+ * @author Jon van Noort (jon@webarcana.com.au)
+ * @param name : string - the candidate string
+ * @return : boolean
+ */
+function __isValidString__(name) {
+ // test that string does not contains invalid characters
+ return (name.search(re_invalidStringChars) < 0);
+}
+var re_invalidStringChars = /\x01|\x02|\x03|\x04|\x05|\x06|\x07|\x08|\x0B|\x0C|\x0E|\x0F|\x10|\x11|\x12|\x13|\x14|\x15|\x16|\x17|\x18|\x19|\x1A|\x1B|\x1C|\x1D|\x1E|\x1F|\x7F/;
+
+/**
+ * @method DOMImplementation._parseNSName - parse the namespace name.
+ * if there is no colon, the
+ * @author Jon van Noort (jon@webarcana.com.au)
+ * @param qualifiedName : string - The qualified name
+ * @return : NSName - [
+ .prefix : string - The prefix part of the qname
+ .namespaceName : string - The namespaceURI part of the qname
+ ]
+ */
+function __parseNSName__(qualifiedName) {
+ var resultNSName = {};
+ // unless the qname has a namespaceName, the prefix is the entire String
+ resultNSName.prefix = qualifiedName;
+ resultNSName.namespaceName = "";
+ // split on ':'
+ var delimPos = qualifiedName.indexOf(':');
+ if (delimPos > -1) {
+ // get prefix
+ resultNSName.prefix = qualifiedName.substring(0, delimPos);
+ // get namespaceName
+ resultNSName.namespaceName = qualifiedName.substring(delimPos +1, qualifiedName.length);
+ }
+ return resultNSName;
+}
+
+/**
+ * @method DOMImplementation._parseQName - parse the qualified name
+ * @author Jon van Noort (jon@webarcana.com.au)
+ * @param qualifiedName : string - The qualified name
+ * @return : QName
+ */
+function __parseQName__(qualifiedName) {
+ var resultQName = {};
+ // unless the qname has a prefix, the local name is the entire String
+ resultQName.localName = qualifiedName;
+ resultQName.prefix = "";
+ // split on ':'
+ var delimPos = qualifiedName.indexOf(':');
+ if (delimPos > -1) {
+ // get prefix
+ resultQName.prefix = qualifiedName.substring(0, delimPos);
+ // get localName
+ resultQName.localName = qualifiedName.substring(delimPos +1, qualifiedName.length);
+ }
+ return resultQName;
+}
+/**
+ * @author envjs team
+ */
+Notation = function() {
+ throw new Error("Notation Not Implemented" );
+};/**
+ * @author thatcher
+ */
+Range = function(){
+
+};
+
+__extend__(Range.prototype, {
+ get startContainer(){
+
+ },
+ get endContainer(){
+
+ },
+ get startOffset(){
+
+ },
+ get endOffset(){
+
+ },
+ get collapsed(){
+
+ },
+ get commonAncestorContainer(){
+
+ },
+ setStart: function(refNode, offset){//throws RangeException
+
+ },
+ setEnd: function(refNode, offset){//throws RangeException
+
+ },
+ setStartBefore: function(refNode){//throws RangeException
+
+ },
+ setStartAfter: function(refNode){//throws RangeException
+
+ },
+ setEndBefore: function(refNode){//throws RangeException
+
+ },
+ setEndAfter: function(refNode){//throws RangeException
+
+ },
+ collapse: function(toStart){//throws RangeException
+
+ },
+ selectNode: function(refNode){//throws RangeException
+
+ },
+ selectNodeContents: function(refNode){//throws RangeException
+
+ },
+ compareBoundaryPoints: function(how, sourceRange){
+
+ },
+ deleteContents: function(){
+
+ },
+ extractContents: function(){
+
+ },
+ cloneContents: function(){
+
+ },
+ insertNode: function(newNode){
+
+ },
+ surroundContents: function(newParent){
+
+ },
+ cloneRange: function(){
+
+ },
+ toString: function(){
+ return '[object Range]';
+ },
+ detach: function(){
+
+ }
+});
+
+
+ // CompareHow
+Range.START_TO_START = 0;
+Range.START_TO_END = 1;
+Range.END_TO_END = 2;
+Range.END_TO_START = 3;
+
+/*
+ * Forward declarations
+ */
+var __isValidNamespace__;
+
+/**
+ * @class Document - The Document interface represents the entire HTML
+ * or XML document. Conceptually, it is the root of the document tree,
+ * and provides the primary access to the document's data.
+ *
+ * @extends Node
+ * @param implementation : DOMImplementation - the creator Implementation
+ */
+Document = function(implementation, docParentWindow) {
+ Node.apply(this, arguments);
+
+ //TODO: Temporary!!! Cnage back to true!!!
+ this.async = true;
+ // The Document Type Declaration (see DocumentType) associated with this document
+ this.doctype = null;
+ // The DOMImplementation object that handles this document.
+ this.implementation = implementation;
+
+ this.nodeName = "#document";
+ // initially false, set to true by parser
+ this.parsing = false;
+ this.baseURI = 'about:blank';
+
+ this.ownerDocument = null;
+
+ this.importing = false;
+};
+
+Document.prototype = new Node();
+__extend__(Document.prototype,{
+ get localName(){
+ return null;
+ },
+ get textContent(){
+ return null;
+ },
+ get all(){
+ return this.getElementsByTagName("*");
+ },
+ get documentElement(){
+ var i, length = this.childNodes?this.childNodes.length:0;
+ for(i=0;i<length;i++){
+ if(this.childNodes[i].nodeType === Node.ELEMENT_NODE){
+ return this.childNodes[i];
+ }
+ }
+ return null;
+ },
+ get documentURI(){
+ return this.baseURI;
+ },
+ createExpression: function(xpath, nsuriMap){
+ return new XPathExpression(xpath, nsuriMap);
+ },
+ createDocumentFragment: function() {
+ var node = new DocumentFragment(this);
+ return node;
+ },
+ createTextNode: function(data) {
+ var node = new Text(this);
+ node.data = data;
+ return node;
+ },
+ createComment: function(data) {
+ var node = new Comment(this);
+ node.data = data;
+ return node;
+ },
+ createCDATASection : function(data) {
+ var node = new CDATASection(this);
+ node.data = data;
+ return node;
+ },
+ createProcessingInstruction: function(target, data) {
+ // throw Exception if the target string contains an illegal character
+ if (__ownerDocument__(this).implementation.errorChecking &&
+ (!__isValidName__(target))) {
+ throw(new DOMException(DOMException.INVALID_CHARACTER_ERR));
+ }
+
+ var node = new ProcessingInstruction(this);
+ node.target = target;
+ node.data = data;
+ return node;
+ },
+ createElement: function(tagName) {
+ // throw Exception if the tagName string contains an illegal character
+ if (__ownerDocument__(this).implementation.errorChecking &&
+ (!__isValidName__(tagName))) {
+ throw(new DOMException(DOMException.INVALID_CHARACTER_ERR));
+ }
+ var node = new Element(this);
+ node.nodeName = tagName;
+ return node;
+ },
+ createElementNS : function(namespaceURI, qualifiedName) {
+ //we use this as a parser flag to ignore the xhtml
+ //namespace assumed by the parser
+ //console.log('creating element %s %s', namespaceURI, qualifiedName);
+ if(this.baseURI === 'http://envjs.com/xml' &&
+ namespaceURI === 'http://www.w3.org/1999/xhtml'){
+ return this.createElement(qualifiedName);
+ }
+ //console.log('createElementNS %s %s', namespaceURI, qualifiedName);
+ if (__ownerDocument__(this).implementation.errorChecking) {
+ // throw Exception if the Namespace is invalid
+ if (!__isValidNamespace__(this, namespaceURI, qualifiedName)) {
+ throw(new DOMException(DOMException.NAMESPACE_ERR));
+ }
+
+ // throw Exception if the qualifiedName string contains an illegal character
+ if (!__isValidName__(qualifiedName)) {
+ throw(new DOMException(DOMException.INVALID_CHARACTER_ERR));
+ }
+ }
+ var node = new Element(this);
+ var qname = __parseQName__(qualifiedName);
+ node.namespaceURI = namespaceURI;
+ node.prefix = qname.prefix;
+ node.nodeName = qualifiedName;
+
+ //console.log('created element %s %s', namespaceURI, qualifiedName);
+ return node;
+ },
+ createAttribute : function(name) {
+ //console.log('createAttribute %s ', name);
+ // throw Exception if the name string contains an illegal character
+ if (__ownerDocument__(this).implementation.errorChecking &&
+ (!__isValidName__(name))) {
+ throw(new DOMException(DOMException.INVALID_CHARACTER_ERR));
+ }
+ var node = new Attr(this);
+ node.nodeName = name;
+ return node;
+ },
+ createAttributeNS : function(namespaceURI, qualifiedName) {
+ //we use this as a parser flag to ignore the xhtml
+ //namespace assumed by the parser
+ if(this.baseURI === 'http://envjs.com/xml' &&
+ namespaceURI === 'http://www.w3.org/1999/xhtml'){
+ return this.createAttribute(qualifiedName);
+ }
+ //console.log('createAttributeNS %s %s', namespaceURI, qualifiedName);
+ // test for exceptions
+ if (this.implementation.errorChecking) {
+ // throw Exception if the Namespace is invalid
+ if (!__isValidNamespace__(this, namespaceURI, qualifiedName, true)) {
+ throw(new DOMException(DOMException.NAMESPACE_ERR));
+ }
+
+ // throw Exception if the qualifiedName string contains an illegal character
+ if (!__isValidName__(qualifiedName)) {
+ throw(new DOMException(DOMException.INVALID_CHARACTER_ERR));
+ }
+ }
+ var node = new Attr(this);
+ var qname = __parseQName__(qualifiedName);
+ node.namespaceURI = namespaceURI === '' ? null : namespaceURI;
+ node.prefix = qname.prefix;
+ node.nodeName = qualifiedName;
+ node.nodeValue = "";
+ //console.log('attribute %s %s %s', node.namespaceURI, node.prefix, node.nodeName);
+ return node;
+ },
+ createNamespace : function(qualifiedName) {
+ //console.log('createNamespace %s', qualifiedName);
+ // create Namespace specifying 'this' as ownerDocument
+ var node = new Namespace(this);
+ var qname = __parseQName__(qualifiedName);
+
+ // assign values to properties (and aliases)
+ node.prefix = qname.prefix;
+ node.localName = qname.localName;
+ node.name = qualifiedName;
+ node.nodeValue = "";
+
+ return node;
+ },
+
+ createRange: function(){
+ return new Range();
+ },
+
+ evaluate: function(xpathText, contextNode, nsuriMapper, resultType, result){
+ //return new XPathExpression().evaluate();
+ throw Error('Document.evaluate not supported yet!');
+ },
+
+ getElementById : function(elementId) {
+ var retNode = null,
+ node;
+ // loop through all Elements
+ var all = this.getElementsByTagName('*');
+ for (var i=0; i < all.length; i++) {
+ node = all[i];
+ // if id matches
+ if (node.id == elementId) {
+ //found the node
+ retNode = node;
+ break;
+ }
+ }
+ return retNode;
+ },
+ normalizeDocument: function(){
+ this.normalize();
+ },
+ get nodeType(){
+ return Node.DOCUMENT_NODE;
+ },
+ get xml(){
+ return this.documentElement.xml;
+ },
+ toString: function(){
+ return "[object XMLDocument]";
+ },
+ get defaultView(){
+ return { getComputedStyle: function(elem){
+ return window.getComputedStyle(elem);
+ }};
+ },
+});
+
+/*
+ * Helper function
+ *
+ */
+__isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribute) {
+
+ if (doc.importing === true) {
+ //we're doing an importNode operation (or a cloneNode) - in both cases, there
+ //is no need to perform any namespace checking since the nodes have to have been valid
+ //to have gotten into the DOM in the first place
+ return true;
+ }
+
+ var valid = true;
+ // parse QName
+ var qName = __parseQName__(qualifiedName);
+
+
+ //only check for namespaces if we're finished parsing
+ if (this.parsing === false) {
+
+ // if the qualifiedName is malformed
+ if (qName.localName.indexOf(":") > -1 ){
+ valid = false;
+ }
+
+ if ((valid) && (!isAttribute)) {
+ // if the namespaceURI is not null
+ if (!namespaceURI) {
+ valid = false;
+ }
+ }
+
+ // if the qualifiedName has a prefix
+ if ((valid) && (qName.prefix === "")) {
+ valid = false;
+ }
+ }
+
+ // if the qualifiedName has a prefix that is "xml" and the namespaceURI is
+ // different from "http://www.w3.org/XML/1998/namespace" [Namespaces].
+ if ((valid) && (qName.prefix === "xml") && (namespaceURI !== "http://www.w3.org/XML/1998/namespace")) {
+ valid = false;
+ }
+
+ return valid;
+};
+/**
+ *
+ * This file only handles XML parser.
+ * It is extended by parser/domparser.js (and parser/htmlparser.js)
+ *
+ * This depends on e4x, which some engines may not have.
+ *
+ * @author thatcher
+ */
+DOMParser = function(principle, documentURI, baseURI) {
+ // TODO: why/what should these 3 args do?
+};
+__extend__(DOMParser.prototype,{
+ parseFromString: function(xmlstring, mimetype){
+ var doc = new Document(new DOMImplementation()),
+ e4;
+
+ // The following are e4x directives.
+ // Full spec is here:
+ // http://www.ecma-international.org/publications/standards/Ecma-357.htm
+ //
+ // that is pretty gross, so checkout this summary
+ // http://rephrase.net/days/07/06/e4x
+ //
+ // also see the Mozilla Developer Center:
+ // https://developer.mozilla.org/en/E4X
+ //
+ XML.ignoreComments = false;
+ XML.ignoreProcessingInstructions = false;
+ XML.ignoreWhitespace = false;
+
+ // for some reason e4x can't handle initial xml declarations
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=336551
+ // The official workaround is the big regexp below
+ // but simpler one seems to be ok
+ // xmlstring = xmlstring.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, "");
+ //
+ xmlstring = xmlstring.replace(/<\?xml.*\?>/);
+
+ e4 = new XMLList(xmlstring);
+
+ __toDomNode__(e4, doc, doc);
+
+ //console.log('xml \n %s', doc.documentElement.xml);
+ return doc;
+ }
+});
+
+var __toDomNode__ = function(e4, parent, doc){
+ var xnode,
+ domnode,
+ children,
+ target,
+ value,
+ length,
+ element,
+ kind,
+ item;
+ //console.log('converting e4x node list \n %s', e4)
+
+ // not using the for each(item in e4) since some engines can't
+ // handle the syntax (i.e. says syntax error)
+ //
+ // for each(xnode in e4) {
+ for (item in e4) {
+ // NO do not do this if (e4.hasOwnProperty(item)) {
+ // breaks spidermonkey
+ xnode = e4[item];
+
+ kind = xnode.nodeKind();
+ //console.log('treating node kind %s', kind);
+ switch(kind){
+ case 'element':
+ // add node
+ //console.log('creating element %s %s', xnode.localName(), xnode.namespace());
+ if(xnode.namespace() && (xnode.namespace()+'') !== ''){
+ //console.log('createElementNS %s %s',xnode.namespace()+'', xnode.localName() );
+ domnode = doc.createElementNS(xnode.namespace()+'', xnode.localName());
+ }else{
+ domnode = doc.createElement(xnode.name()+'');
+ }
+ parent.appendChild(domnode);
+
+ // add attributes
+ __toDomNode__(xnode.attributes(), domnode, doc);
+
+ // add children
+ children = xnode.children();
+ length = children.length();
+ //console.log('recursing? %s', length ? 'yes' : 'no');
+ if (length > 0) {
+ __toDomNode__(children, domnode, doc);
+ }
+ break;
+ case 'attribute':
+ // console.log('setting attribute %s %s %s',
+ // xnode.localName(), xnode.namespace(), xnode.valueOf());
+
+ //
+ // cross-platform alert. The original code used
+ // xnode.text() to get the attribute value
+ // This worked in Rhino, but did not in Spidermonkey
+ // valueOf seemed to work in both
+ //
+ if(xnode.namespace() && xnode.namespace().prefix){
+ //console.log("%s", xnode.namespace().prefix);
+ parent.setAttributeNS(xnode.namespace()+'',
+ xnode.namespace().prefix+':'+xnode.localName(),
+ xnode.valueOf());
+ }else if((xnode.name()+'').match('http://www.w3.org/2000/xmlns/::')){
+ if(xnode.localName()!=='xmlns'){
+ parent.setAttributeNS('http://www.w3.org/2000/xmlns/',
+ 'xmlns:'+xnode.localName(),
+ xnode.valueOf());
+ }
+ }else{
+ parent.setAttribute(xnode.localName()+'', xnode.valueOf());
+ }
+ break;
+ case 'text':
+ //console.log('creating text node : %s', xnode);
+ domnode = doc.createTextNode(xnode+'');
+ parent.appendChild(domnode);
+ break;
+ case 'comment':
+ //console.log('creating comment node : %s', xnode);
+ value = xnode+'';
+ domnode = doc.createComment(value.substring(4,value.length-3));
+ parent.appendChild(domnode);
+ break;
+ case 'processing-instruction':
+ //console.log('creating processing-instruction node : %s', xnode);
+ value = xnode+'';
+ target = value.split(' ')[0].substring(2);
+ value = value.split(' ').splice(1).join(' ').replace('?>','');
+ //console.log('creating processing-instruction data : %s', value);
+ domnode = doc.createProcessingInstruction(target, value);
+ parent.appendChild(domnode);
+ break;
+ default:
+ console.log('e4x DOM ERROR');
+ throw new Error("Assertion failed in xml parser");
+ }
+ }
+};
+/**
+ * @author envjs team
+ * @class XMLSerializer
+ */
+
+XMLSerializer = function() {};
+
+__extend__(XMLSerializer.prototype, {
+ serializeToString: function(node){
+ return node.xml;
+ },
+ toString : function(){
+ return "[object XMLSerializer]";
+ }
+});
+
+/**
+ * @author john resig & the envjs team
+ * @uri http://www.envjs.com/
+ * @copyright 2008-2010
+ * @license MIT
+ */
+//CLOSURE_END
+}());
+/*
+ * Envjs event.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ *
+ * This file simply provides the global definitions we need to
+ * be able to correctly implement to core browser DOM Event interfaces.
+ */
+var Event,
+ MouseEvent,
+ UIEvent,
+ KeyboardEvent,
+ MutationEvent,
+ DocumentEvent,
+ EventTarget,
+ EventException,
+ //nonstandard but very useful for implementing mutation events
+ //among other things like general profiling
+ Aspect;
+/*
+ * Envjs event.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+//CLOSURE_START
+(function(){
+
+
+
+
+
+/**
+ * @author john resig
+ */
+// Helper method for extending one object with another.
+function __extend__(a,b) {
+ for ( var i in b ) {
+ var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
+ if ( g || s ) {
+ if ( g ) { a.__defineGetter__(i, g); }
+ if ( s ) { a.__defineSetter__(i, s); }
+ } else {
+ a[i] = b[i];
+ }
+ } return a;
+}
+
+/**
+ * @author john resig
+ */
+//from jQuery
+function __setArray__( target, array ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ target.length = 0;
+ Array.prototype.push.apply( target, array );
+}
+/**
+ * Borrowed with love from:
+ *
+ * jQuery AOP - jQuery plugin to add features of aspect-oriented programming (AOP) to jQuery.
+ * http://jquery-aop.googlecode.com/
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * Version: 1.1
+ */
+(function() {
+
+ var _after = 1;
+ var _before = 2;
+ var _around = 3;
+ var _intro = 4;
+ var _regexEnabled = true;
+
+ /**
+ * Private weaving function.
+ */
+ var weaveOne = function(source, method, advice) {
+
+ var old = source[method];
+
+ var aspect;
+ if (advice.type == _after)
+ aspect = function() {
+ var returnValue = old.apply(this, arguments);
+ return advice.value.apply(this, [returnValue, method]);
+ };
+ else if (advice.type == _before)
+ aspect = function() {
+ advice.value.apply(this, [arguments, method]);
+ return old.apply(this, arguments);
+ };
+ else if (advice.type == _intro)
+ aspect = function() {
+ return advice.value.apply(this, arguments);
+ };
+ else if (advice.type == _around) {
+ aspect = function() {
+ var invocation = { object: this, args: arguments };
+ return advice.value.apply(invocation.object, [{ arguments: invocation.args, method: method, proceed :
+ function() {
+ return old.apply(invocation.object, invocation.args);
+ }
+ }] );
+ };
+ }
+
+ aspect.unweave = function() {
+ source[method] = old;
+ pointcut = source = aspect = old = null;
+ };
+
+ source[method] = aspect;
+
+ return aspect;
+
+ };
+
+
+ /**
+ * Private weaver and pointcut parser.
+ */
+ var weave = function(pointcut, advice)
+ {
+
+ var source = (typeof(pointcut.target.prototype) != 'undefined') ? pointcut.target.prototype : pointcut.target;
+ var advices = [];
+
+ // If it's not an introduction and no method was found, try with regex...
+ if (advice.type != _intro && typeof(source[pointcut.method]) == 'undefined')
+ {
+
+ for (var method in source)
+ {
+ if (source[method] != null && source[method] instanceof Function && method.match(pointcut.method))
+ {
+ advices[advices.length] = weaveOne(source, method, advice);
+ }
+ }
+
+ if (advices.length == 0)
+ throw 'No method: ' + pointcut.method;
+
+ }
+ else
+ {
+ // Return as an array of one element
+ advices[0] = weaveOne(source, pointcut.method, advice);
+ }
+
+ return _regexEnabled ? advices : advices[0];
+
+ };
+
+ Aspect =
+ {
+ /**
+ * Creates an advice after the defined point-cut. The advice will be executed after the point-cut method
+ * has completed execution successfully, and will receive one parameter with the result of the execution.
+ * This function returns an array of weaved aspects (Function).
+ *
+ * @example jQuery.aop.after( {target: window, method: 'MyGlobalMethod'}, function(result) { alert('Returned: ' + result); } );
+ * @result Array<Function>
+ *
+ * @example jQuery.aop.after( {target: String, method: 'indexOf'}, function(index) { alert('Result found at: ' + index + ' on:' + this); } );
+ * @result Array<Function>
+ *
+ * @name after
+ * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved.
+ * @option Object target Target object to be weaved.
+ * @option String method Name of the function to be weaved. Regex are supported, but not on built-in objects.
+ * @param Function advice Function containing the code that will get called after the execution of the point-cut. It receives one parameter
+ * with the result of the point-cut's execution.
+ *
+ * @type Array<Function>
+ * @cat Plugins/General
+ */
+ after : function(pointcut, advice)
+ {
+ return weave( pointcut, { type: _after, value: advice } );
+ },
+
+ /**
+ * Creates an advice before the defined point-cut. The advice will be executed before the point-cut method
+ * but cannot modify the behavior of the method, or prevent its execution.
+ * This function returns an array of weaved aspects (Function).
+ *
+ * @example jQuery.aop.before( {target: window, method: 'MyGlobalMethod'}, function() { alert('About to execute MyGlobalMethod'); } );
+ * @result Array<Function>
+ *
+ * @example jQuery.aop.before( {target: String, method: 'indexOf'}, function(index) { alert('About to execute String.indexOf on: ' + this); } );
+ * @result Array<Function>
+ *
+ * @name before
+ * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved.
+ * @option Object target Target object to be weaved.
+ * @option String method Name of the function to be weaved. Regex are supported, but not on built-in objects.
+ * @param Function advice Function containing the code that will get called before the execution of the point-cut.
+ *
+ * @type Array<Function>
+ * @cat Plugins/General
+ */
+ before : function(pointcut, advice)
+ {
+ return weave( pointcut, { type: _before, value: advice } );
+ },
+
+
+ /**
+ * Creates an advice 'around' the defined point-cut. This type of advice can control the point-cut method execution by calling
+ * the functions '.proceed()' on the 'invocation' object, and also, can modify the arguments collection before sending them to the function call.
+ * This function returns an array of weaved aspects (Function).
+ *
+ * @example jQuery.aop.around( {target: window, method: 'MyGlobalMethod'}, function(invocation) {
+ * alert('# of Arguments: ' + invocation.arguments.length);
+ * return invocation.proceed();
+ * } );
+ * @result Array<Function>
+ *
+ * @example jQuery.aop.around( {target: String, method: 'indexOf'}, function(invocation) {
+ * alert('Searching: ' + invocation.arguments[0] + ' on: ' + this);
+ * return invocation.proceed();
+ * } );
+ * @result Array<Function>
+ *
+ * @example jQuery.aop.around( {target: window, method: /Get(\d+)/}, function(invocation) {
+ * alert('Executing ' + invocation.method);
+ * return invocation.proceed();
+ * } );
+ * @desc Matches all global methods starting with 'Get' and followed by a number.
+ * @result Array<Function>
+ *
+ *
+ * @name around
+ * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved.
+ * @option Object target Target object to be weaved.
+ * @option String method Name of the function to be weaved. Regex are supported, but not on built-in objects.
+ * @param Function advice Function containing the code that will get called around the execution of the point-cut. This advice will be called with one
+ * argument containing one function '.proceed()', the collection of arguments '.arguments', and the matched method name '.method'.
+ *
+ * @type Array<Function>
+ * @cat Plugins/General
+ */
+ around : function(pointcut, advice)
+ {
+ return weave( pointcut, { type: _around, value: advice } );
+ },
+
+ /**
+ * Creates an introduction on the defined point-cut. This type of advice replaces any existing methods with the same
+ * name. To restore them, just unweave it.
+ * This function returns an array with only one weaved aspect (Function).
+ *
+ * @example jQuery.aop.introduction( {target: window, method: 'MyGlobalMethod'}, function(result) { alert('Returned: ' + result); } );
+ * @result Array<Function>
+ *
+ * @example jQuery.aop.introduction( {target: String, method: 'log'}, function() { alert('Console: ' + this); } );
+ * @result Array<Function>
+ *
+ * @name introduction
+ * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved.
+ * @option Object target Target object to be weaved.
+ * @option String method Name of the function to be weaved.
+ * @param Function advice Function containing the code that will be executed on the point-cut.
+ *
+ * @type Array<Function>
+ * @cat Plugins/General
+ */
+ introduction : function(pointcut, advice)
+ {
+ return weave( pointcut, { type: _intro, value: advice } );
+ },
+
+ /**
+ * Configures global options.
+ *
+ * @name setup
+ * @param Map settings Configuration options.
+ * @option Boolean regexMatch Enables/disables regex matching of method names.
+ *
+ * @example jQuery.aop.setup( { regexMatch: false } );
+ * @desc Disable regex matching.
+ *
+ * @type Void
+ * @cat Plugins/General
+ */
+ setup: function(settings)
+ {
+ _regexEnabled = settings.regexMatch;
+ }
+ };
+
+})();
+
+
+
+
+/**
+ * @name EventTarget
+ * @w3c:domlevel 2
+ * @uri -//TODO: paste dom event level 2 w3c spc uri here
+ */
+EventTarget = function(){};
+EventTarget.prototype.addEventListener = function(type, fn, phase){
+ __addEventListener__(this, type, fn, phase);
+};
+EventTarget.prototype.removeEventListener = function(type, fn){
+ __removeEventListener__(this, type, fn);
+};
+EventTarget.prototype.dispatchEvent = function(event, bubbles){
+ __dispatchEvent__(this, event, bubbles);
+};
+
+__extend__(Node.prototype, EventTarget.prototype);
+
+
+var $events = [{}];
+
+function __addEventListener__(target, type, fn, phase){
+ phase = !!phase?"CAPTURING":"BUBBLING";
+ if ( !target.uuid ) {
+ //console.log('event uuid %s %s', target, target.uuid);
+ target.uuid = $events.length+'';
+ }
+ if ( !$events[target.uuid] ) {
+ //console.log('creating listener for target: %s %s', target, target.uuid);
+ $events[target.uuid] = {};
+ }
+ if ( !$events[target.uuid][type] ){
+ //console.log('creating listener for type: %s %s %s', target, target.uuid, type);
+ $events[target.uuid][type] = {
+ CAPTURING:[],
+ BUBBLING:[]
+ };
+ }
+ if ( $events[target.uuid][type][phase].indexOf( fn ) < 0 ){
+ //console.log('adding event listener %s %s %s %s %s %s', target, target.uuid, type, phase,
+ // $events[target.uuid][type][phase].length, $events[target.uuid][type][phase].indexOf( fn ));
+ //console.log('creating listener for function: %s %s %s', target, target.uuid, phase);
+ $events[target.uuid][type][phase].push( fn );
+ //console.log('adding event listener %s %s %s %s %s %s', target, target.uuid, type, phase,
+ // $events[target.uuid][type][phase].length, $events[target.uuid][type][phase].indexOf( fn ));
+ }
+ //console.log('registered event listeners %s', $events.length);
+}
+
+function __removeEventListener__(target, type, fn, phase){
+
+ phase = !!phase?"CAPTURING":"BUBBLING";
+ if ( !target.uuid ) {
+ return;
+ }
+ if ( !$events[target.uuid] ) {
+ return;
+ }
+ if(type == '*'){
+ //used to clean all event listeners for a given node
+ //console.log('cleaning all event listeners for node %s %s',target, target.uuid);
+ delete $events[target.uuid];
+ return;
+ }else if ( !$events[target.uuid][type] ){
+ return;
+ }
+ $events[target.uuid][type][phase] =
+ $events[target.uuid][type][phase].filter(function(f){
+ //console.log('removing event listener %s %s %s %s', target, type, phase, fn);
+ return f != fn;
+ });
+}
+
+var __eventuuid__ = 0;
+function __dispatchEvent__(target, event, bubbles){
+
+ if (!event.uuid) {
+ event.uuid = __eventuuid__++;
+ }
+ //the window scope defines the $event object, for IE(^^^) compatibility;
+ //$event = event;
+ //console.log('dispatching event %s', event.uuid);
+ if (bubbles === undefined || bubbles === null) {
+ bubbles = true;
+ }
+
+ if (!event.target) {
+ event.target = target;
+ }
+
+ //console.log('dispatching? %s %s %s', target, event.type, bubbles);
+ if ( event.type && (target.nodeType || target === window )) {
+
+ //console.log('dispatching event %s %s %s', target, event.type, bubbles);
+ __captureEvent__(target, event);
+
+ event.eventPhase = Event.AT_TARGET;
+ if ( target.uuid && $events[target.uuid] && $events[target.uuid][event.type] ) {
+ event.currentTarget = target;
+ //console.log('dispatching %s %s %s %s', target, event.type,
+ // $events[target.uuid][event.type]['CAPTURING'].length);
+ $events[target.uuid][event.type].CAPTURING.forEach(function(fn){
+ //console.log('AT_TARGET (CAPTURING) event %s', fn);
+ var returnValue = fn( event );
+ //console.log('AT_TARGET (CAPTURING) return value %s', returnValue);
+ if(returnValue === false){
+ event.stopPropagation();
+ }
+ });
+ //console.log('dispatching %s %s %s %s', target, event.type,
+ // $events[target.uuid][event.type]['BUBBLING'].length);
+ $events[target.uuid][event.type].BUBBLING.forEach(function(fn){
+ //console.log('AT_TARGET (BUBBLING) event %s', fn);
+ var returnValue = fn( event );
+ //console.log('AT_TARGET (BUBBLING) return value %s', returnValue);
+ if(returnValue === false){
+ event.stopPropagation();
+ }
+ });
+ }
+ if (target["on" + event.type]) {
+ target["on" + event.type](event);
+ }
+ if (bubbles && !event.cancelled){
+ __bubbleEvent__(target, event);
+ }
+ if(!event._preventDefault){
+ //At this point I'm guessing that just HTMLEvents are concerned
+ //with default behavior being executed in a browser but I could be
+ //wrong as usual. The goal is much more to filter at this point
+ //what events have no need to be handled
+ //console.log('triggering default behavior for %s', event.type);
+ if(event.type in Envjs.defaultEventBehaviors){
+ Envjs.defaultEventBehaviors[event.type](event);
+ }
+ }
+ //console.log('deleting event %s', event.uuid);
+ event.target = null;
+ event = null;
+ }else{
+ throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR);
+ }
+}
+
+function __captureEvent__(target, event){
+ var ancestorStack = [],
+ parent = target.parentNode;
+
+ event.eventPhase = Event.CAPTURING_PHASE;
+ while(parent){
+ if(parent.uuid && $events[parent.uuid] && $events[parent.uuid][event.type]){
+ ancestorStack.push(parent);
+ }
+ parent = parent.parentNode;
+ }
+ while(ancestorStack.length && !event.cancelled){
+ event.currentTarget = ancestorStack.pop();
+ if($events[event.currentTarget.uuid] && $events[event.currentTarget.uuid][event.type]){
+ $events[event.currentTarget.uuid][event.type].CAPTURING.forEach(function(fn){
+ var returnValue = fn( event );
+ if(returnValue === false){
+ event.stopPropagation();
+ }
+ });
+ }
+ }
+}
+
+function __bubbleEvent__(target, event){
+ var parent = target.parentNode;
+ event.eventPhase = Event.BUBBLING_PHASE;
+ while(parent){
+ if(parent.uuid && $events[parent.uuid] && $events[parent.uuid][event.type] ){
+ event.currentTarget = parent;
+ $events[event.currentTarget.uuid][event.type].BUBBLING.forEach(function(fn){
+ var returnValue = fn( event );
+ if(returnValue === false){
+ event.stopPropagation();
+ }
+ });
+ }
+ parent = parent.parentNode;
+ }
+}
+
+/**
+ * @class Event
+ */
+Event = function(options){
+ // event state is kept read-only by forcing
+ // a new object for each event. This may not
+ // be appropriate in the long run and we'll
+ // have to decide if we simply dont adhere to
+ // the read-only restriction of the specification
+ this._bubbles = true;
+ this._cancelable = true;
+ this._cancelled = false;
+ this._currentTarget = null;
+ this._target = null;
+ this._eventPhase = Event.AT_TARGET;
+ this._timeStamp = new Date().getTime();
+ this._preventDefault = false;
+ this._stopPropogation = false;
+};
+
+__extend__(Event.prototype,{
+ get bubbles(){return this._bubbles;},
+ get cancelable(){return this._cancelable;},
+ get currentTarget(){return this._currentTarget;},
+ set currentTarget(currentTarget){ this._currentTarget = currentTarget; },
+ get eventPhase(){return this._eventPhase;},
+ set eventPhase(eventPhase){this._eventPhase = eventPhase;},
+ get target(){return this._target;},
+ set target(target){ this._target = target;},
+ get timeStamp(){return this._timeStamp;},
+ get type(){return this._type;},
+ initEvent: function(type, bubbles, cancelable){
+ this._type=type?type:'';
+ this._bubbles=!!bubbles;
+ this._cancelable=!!cancelable;
+ },
+ preventDefault: function(){
+ this._preventDefault = true;
+ },
+ stopPropagation: function(){
+ if(this._cancelable){
+ this._cancelled = true;
+ this._bubbles = false;
+ }
+ },
+ get cancelled(){
+ return this._cancelled;
+ },
+ toString: function(){
+ return '[object Event]';
+ }
+});
+
+__extend__(Event,{
+ CAPTURING_PHASE : 1,
+ AT_TARGET : 2,
+ BUBBLING_PHASE : 3
+});
+
+
+
+/**
+ * @name UIEvent
+ * @param {Object} options
+ */
+UIEvent = function(options) {
+ this._view = null;
+ this._detail = 0;
+};
+
+UIEvent.prototype = new Event();
+__extend__(UIEvent.prototype,{
+ get view(){
+ return this._view;
+ },
+ get detail(){
+ return this._detail;
+ },
+ initUIEvent: function(type, bubbles, cancelable, windowObject, detail){
+ this.initEvent(type, bubbles, cancelable);
+ this._detail = 0;
+ this._view = windowObject;
+ }
+});
+
+var $onblur,
+ $onfocus,
+ $onresize;
+
+
+/**
+ * @name MouseEvent
+ * @w3c:domlevel 2
+ * @uri http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html
+ */
+MouseEvent = function(options) {
+ this._screenX= 0;
+ this._screenY= 0;
+ this._clientX= 0;
+ this._clientY= 0;
+ this._ctrlKey= false;
+ this._metaKey= false;
+ this._altKey= false;
+ this._button= null;
+ this._relatedTarget= null;
+};
+MouseEvent.prototype = new UIEvent();
+__extend__(MouseEvent.prototype,{
+ get screenX(){
+ return this._screenX;
+ },
+ get screenY(){
+ return this._screenY;
+ },
+ get clientX(){
+ return this._clientX;
+ },
+ get clientY(){
+ return this._clientY;
+ },
+ get ctrlKey(){
+ return this._ctrlKey;
+ },
+ get altKey(){
+ return this._altKey;
+ },
+ get shiftKey(){
+ return this._shiftKey;
+ },
+ get metaKey(){
+ return this._metaKey;
+ },
+ get button(){
+ return this._button;
+ },
+ get relatedTarget(){
+ return this._relatedTarget;
+ },
+ initMouseEvent: function(type, bubbles, cancelable, windowObject, detail,
+ screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey,
+ metaKey, button, relatedTarget){
+ this.initUIEvent(type, bubbles, cancelable, windowObject, detail);
+ this._screenX = screenX;
+ this._screenY = screenY;
+ this._clientX = clientX;
+ this._clientY = clientY;
+ this._ctrlKey = ctrlKey;
+ this._altKey = altKey;
+ this._shiftKey = shiftKey;
+ this._metaKey = metaKey;
+ this._button = button;
+ this._relatedTarget = relatedTarget;
+ }
+});
+
+/**
+ * Interface KeyboardEvent (introduced in DOM Level 3)
+ */
+KeyboardEvent = function(options) {
+ this._keyIdentifier = 0;
+ this._keyLocation = 0;
+ this._ctrlKey = false;
+ this._metaKey = false;
+ this._altKey = false;
+ this._metaKey = false;
+};
+KeyboardEvent.prototype = new UIEvent();
+
+__extend__(KeyboardEvent.prototype,{
+
+ get ctrlKey(){
+ return this._ctrlKey;
+ },
+ get altKey(){
+ return this._altKey;
+ },
+ get shiftKey(){
+ return this._shiftKey;
+ },
+ get metaKey(){
+ return this._metaKey;
+ },
+ get button(){
+ return this._button;
+ },
+ get relatedTarget(){
+ return this._relatedTarget;
+ },
+ getModifiersState: function(keyIdentifier){
+
+ },
+ initMouseEvent: function(type, bubbles, cancelable, windowObject,
+ keyIdentifier, keyLocation, modifiersList, repeat){
+ this.initUIEvent(type, bubbles, cancelable, windowObject, 0);
+ this._keyIdentifier = keyIdentifier;
+ this._keyLocation = keyLocation;
+ this._modifiersList = modifiersList;
+ this._repeat = repeat;
+ }
+});
+
+KeyboardEvent.DOM_KEY_LOCATION_STANDARD = 0;
+KeyboardEvent.DOM_KEY_LOCATION_LEFT = 1;
+KeyboardEvent.DOM_KEY_LOCATION_RIGHT = 2;
+KeyboardEvent.DOM_KEY_LOCATION_NUMPAD = 3;
+KeyboardEvent.DOM_KEY_LOCATION_MOBILE = 4;
+KeyboardEvent.DOM_KEY_LOCATION_JOYSTICK = 5;
+
+
+
+//We dont fire mutation events until someone has registered for them
+var __supportedMutations__ = /DOMSubtreeModified|DOMNodeInserted|DOMNodeRemoved|DOMAttrModified|DOMCharacterDataModified/;
+
+var __fireMutationEvents__ = Aspect.before({
+ target: EventTarget,
+ method: 'addEventListener'
+}, function(target, type){
+ if(type && type.match(__supportedMutations__)){
+ //unweaving removes the __addEventListener__ aspect
+ __fireMutationEvents__.unweave();
+ // These two methods are enough to cover all dom 2 manipulations
+ Aspect.around({
+ target: Node,
+ method:"removeChild"
+ }, function(invocation){
+ var event,
+ node = invocation.arguments[0];
+ event = node.ownerDocument.createEvent('MutationEvents');
+ event.initEvent('DOMNodeRemoved', true, false, node.parentNode, null, null, null, null);
+ node.dispatchEvent(event, false);
+ return invocation.proceed();
+
+ });
+ Aspect.around({
+ target: Node,
+ method:"appendChild"
+ }, function(invocation) {
+ var event,
+ node = invocation.proceed();
+ event = node.ownerDocument.createEvent('MutationEvents');
+ event.initEvent('DOMNodeInserted', true, false, node.parentNode, null, null, null, null);
+ node.dispatchEvent(event, false);
+ return node;
+ });
+ }
+});
+
+/**
+ * @name MutationEvent
+ * @param {Object} options
+ */
+MutationEvent = function(options) {
+ this._cancelable = false;
+ this._timeStamp = 0;
+};
+
+MutationEvent.prototype = new Event();
+__extend__(MutationEvent.prototype,{
+ get relatedNode(){
+ return this._relatedNode;
+ },
+ get prevValue(){
+ return this._prevValue;
+ },
+ get newValue(){
+ return this._newValue;
+ },
+ get attrName(){
+ return this._attrName;
+ },
+ get attrChange(){
+ return this._attrChange;
+ },
+ initMutationEvent: function( type, bubbles, cancelable,
+ relatedNode, prevValue, newValue, attrName, attrChange ){
+ this._relatedNode = relatedNode;
+ this._prevValue = prevValue;
+ this._newValue = newValue;
+ this._attrName = attrName;
+ this._attrChange = attrChange;
+ switch(type){
+ case "DOMSubtreeModified":
+ this.initEvent(type, true, false);
+ break;
+ case "DOMNodeInserted":
+ this.initEvent(type, true, false);
+ break;
+ case "DOMNodeRemoved":
+ this.initEvent(type, true, false);
+ break;
+ case "DOMNodeRemovedFromDocument":
+ this.initEvent(type, false, false);
+ break;
+ case "DOMNodeInsertedIntoDocument":
+ this.initEvent(type, false, false);
+ break;
+ case "DOMAttrModified":
+ this.initEvent(type, true, false);
+ break;
+ case "DOMCharacterDataModified":
+ this.initEvent(type, true, false);
+ break;
+ default:
+ this.initEvent(type, bubbles, cancelable);
+ }
+ }
+});
+
+// constants
+MutationEvent.ADDITION = 0;
+MutationEvent.MODIFICATION = 1;
+MutationEvent.REMOVAL = 2;
+
+
+/**
+ * @name EventException
+ */
+EventException = function(code) {
+ this.code = code;
+};
+EventException.UNSPECIFIED_EVENT_TYPE_ERR = 0;
+/**
+ *
+ * DOM Level 2: http://www.w3.org/TR/DOM-Level-2-Events/events.html
+ * DOM Level 3: http://www.w3.org/TR/DOM-Level-3-Events/
+ *
+ * interface DocumentEvent {
+ * Event createEvent (in DOMString eventType)
+ * raises (DOMException);
+ * };
+ *
+ * Firefox (3.6) exposes DocumentEvent
+ * Safari (4) does NOT.
+ */
+
+/**
+ * TODO: Not sure we need a full prototype. We not just an regular object?
+ */
+DocumentEvent = function(){};
+DocumentEvent.prototype.__EventMap__ = {
+ // Safari4: singular and plural forms accepted
+ // Firefox3.6: singular and plural forms accepted
+ 'Event' : Event,
+ 'Events' : Event,
+ 'UIEvent' : UIEvent,
+ 'UIEvents' : UIEvent,
+ 'MouseEvent' : MouseEvent,
+ 'MouseEvents' : MouseEvent,
+ 'MutationEvent' : MutationEvent,
+ 'MutationEvents' : MutationEvent,
+
+ // Safari4: accepts HTMLEvents, but not HTMLEvent
+ // Firefox3.6: accepts HTMLEvents, but not HTMLEvent
+ 'HTMLEvent' : Event,
+ 'HTMLEvents' : Event,
+
+ // Safari4: both not accepted
+ // Firefox3.6, only KeyEvents is accepted
+ 'KeyEvent' : KeyboardEvent,
+ 'KeyEvents' : KeyboardEvent,
+
+ // Safari4: both accepted
+ // Firefox3.6: none accepted
+ 'KeyboardEvent' : KeyboardEvent,
+ 'KeyboardEvents' : KeyboardEvent
+};
+
+DocumentEvent.prototype.createEvent = function(eventType) {
+ var Clazz = this.__EventMap__[eventType];
+ if (Clazz) {
+ return new Clazz();
+ }
+ throw(new DOMException(DOMException.NOT_SUPPORTED_ERR));
+};
+
+__extend__(Document.prototype, DocumentEvent.prototype);
+
+/**
+ * @author john resig & the envjs team
+ * @uri http://www.envjs.com/
+ * @copyright 2008-2010
+ * @license MIT
+ */
+//CLOSURE_END
+}());
+
+/*
+ * Envjs timer.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ *
+ * Parts of the implementation were originally written by:\
+ * Steven Parkes
+ *
+ * requires Envjs.wait, Envjs.sleep, Envjs.WAIT_INTERVAL
+ */
+var setTimeout,
+ clearTimeout,
+ setInterval,
+ clearInterval;
+
+/*
+ * Envjs timer.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+//CLOSURE_START
+(function(){
+
+
+
+
+/*
+* timer.js
+* implementation provided by Steven Parkes
+*/
+
+//private
+var $timers = [],
+ EVENT_LOOP_RUNNING = false;
+
+$timers.lock = function(fn){
+ Envjs.sync(fn)();
+};
+
+//private internal class
+var Timer = function(fn, interval){
+ this.fn = fn;
+ this.interval = interval;
+ this.at = Date.now() + interval;
+ // allows for calling wait() from callbacks
+ this.running = false;
+};
+
+Timer.prototype.start = function(){};
+Timer.prototype.stop = function(){};
+
+//static
+Timer.normalize = function(time) {
+ time = time*1;
+ if ( isNaN(time) || time < 0 ) {
+ time = 0;
+ }
+
+ if ( EVENT_LOOP_RUNNING && time < Timer.MIN_TIME ) {
+ time = Timer.MIN_TIME;
+ }
+ return time;
+};
+// html5 says this should be at least 4, but the parser is using
+// a setTimeout for the SAX stuff which messes up the world
+Timer.MIN_TIME = /* 4 */ 0;
+
+/**
+ * @function setTimeout
+ * @param {Object} fn
+ * @param {Object} time
+ */
+setTimeout = function(fn, time){
+ var num;
+ time = Timer.normalize(time);
+ $timers.lock(function(){
+ num = $timers.length+1;
+ var tfn;
+ if (typeof fn == 'string') {
+ tfn = function() {
+ try {
+ // eval in global scope
+ eval(fn, null);
+ } catch (e) {
+ console.log('timer error %s %s', fn, e);
+ } finally {
+ clearInterval(num);
+ }
+ };
+ } else {
+ tfn = function() {
+ try {
+ fn();
+ } catch (e) {
+ console.log('timer error %s %s', fn, e);
+ } finally {
+ clearInterval(num);
+ }
+ };
+ }
+ //console.log("Creating timer number %s", num);
+ $timers[num] = new Timer(tfn, time);
+ $timers[num].start();
+ });
+ return num;
+};
+
+/**
+ * @function setInterval
+ * @param {Object} fn
+ * @param {Object} time
+ */
+setInterval = function(fn, time){
+ //console.log('setting interval %s %s', time, fn.toString().substring(0,64));
+ time = Timer.normalize(time);
+ if ( time < 10 ) {
+ time = 10;
+ }
+ if (typeof fn == 'string') {
+ var fnstr = fn;
+ fn = function() {
+ eval(fnstr);
+ };
+ }
+ var num;
+ $timers.lock(function(){
+ num = $timers.length+1;
+ //Envjs.debug("Creating timer number "+num);
+ $timers[num] = new Timer(fn, time);
+ $timers[num].start();
+ });
+ return num;
+};
+
+/**
+ * clearInterval
+ * @param {Object} num
+ */
+clearInterval = clearTimeout = function(num){
+ //console.log("clearing interval "+num);
+ $timers.lock(function(){
+ if ( $timers[num] ) {
+ $timers[num].stop();
+ delete $timers[num];
+ }
+ });
+};
+
+// wait === null/undefined: execute any timers as they fire,
+// waiting until there are none left
+// wait(n) (n > 0): execute any timers as they fire until there
+// are none left waiting at least n ms but no more, even if there
+// are future events/current threads
+// wait(0): execute any immediately runnable timers and return
+// wait(-n): keep sleeping until the next event is more than n ms
+// in the future
+//
+// TODO: make a priority queue ...
+
+Envjs.wait = function(wait) {
+ //console.log('wait %s', wait);
+ var delta_wait,
+ start = Date.now(),
+ was_running = EVENT_LOOP_RUNNING;
+
+ if (wait < 0) {
+ delta_wait = -wait;
+ wait = 0;
+ }
+ EVENT_LOOP_RUNNING = true;
+ if (wait !== 0 && wait !== null && wait !== undefined){
+ wait += Date.now();
+ }
+
+ var earliest,
+ timer,
+ sleep,
+ index,
+ goal,
+ now,
+ nextfn;
+
+ for (;;) {
+ //console.log('timer loop');
+ earliest = sleep = goal = now = nextfn = null;
+ $timers.lock(function(){
+ for(index in $timers){
+ if( isNaN(index*0) ) {
+ continue;
+ }
+ timer = $timers[index];
+ // determine timer with smallest run-at time that is
+ // not already running
+ if( !timer.running && ( !earliest || timer.at < earliest.at) ) {
+ earliest = timer;
+ }
+ }
+ });
+ //next sleep time
+ sleep = earliest && earliest.at - Date.now();
+ if ( earliest && sleep <= 0 ) {
+ nextfn = earliest.fn;
+ try {
+ //console.log('running stack %s', nextfn.toString().substring(0,64));
+ earliest.running = true;
+ nextfn();
+ } catch (e) {
+ console.log('timer error %s %s', nextfn, e);
+ } finally {
+ earliest.running = false;
+ }
+ goal = earliest.at + earliest.interval;
+ now = Date.now();
+ if ( goal < now ) {
+ earliest.at = now;
+ } else {
+ earliest.at = goal;
+ }
+ continue;
+ }
+
+ // bunch of subtle cases here ...
+ if ( !earliest ) {
+ // no events in the queue (but maybe XHR will bring in events, so ...
+ if ( !wait || wait < Date.now() ) {
+ // Loop ends if there are no events and a wait hasn't been
+ // requested or has expired
+ break;
+ }
+ // no events, but a wait requested: fall through to sleep
+ } else {
+ // there are events in the queue, but they aren't firable now
+ /*if ( delta_wait && sleep <= delta_wait ) {
+ //TODO: why waste a check on a tight
+ // loop if it just falls through?
+ // if they will happen within the next delta, fall through to sleep
+ } else */if ( wait === 0 || ( wait > 0 && wait < Date.now () ) ) {
+ // loop ends even if there are events but the user
+ // specifcally asked not to wait too long
+ break;
+ }
+ // there are events and the user wants to wait: fall through to sleep
+ }
+
+ // Related to ajax threads ... hopefully can go away ..
+ var interval = Envjs.WAIT_INTERVAL || 100;
+ if ( !sleep || sleep > interval ) {
+ sleep = interval;
+ }
+ //console.log('sleeping %s', sleep);
+ Envjs.sleep(sleep);
+
+ }
+ EVENT_LOOP_RUNNING = was_running;
+};
+
+
+/**
+ * @author john resig & the envjs team
+ * @uri http://www.envjs.com/
+ * @copyright 2008-2010
+ * @license MIT
+ */
+//CLOSURE_END
+}());
+/*
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ *
+ * This file simply provides the global definitions we need to
+ * be able to correctly implement to core browser DOM HTML interfaces.
+ */
+var HTMLDocument,
+ HTMLElement,
+ HTMLCollection,
+ HTMLAnchorElement,
+ HTMLAreaElement,
+ HTMLBaseElement,
+ HTMLQuoteElement,
+ HTMLBodyElement,
+ HTMLBRElement,
+ HTMLButtonElement,
+ HTMLCanvasElement,
+ HTMLTableColElement,
+ HTMLModElement,
+ HTMLDivElement,
+ HTMLDListElement,
+ HTMLFieldSetElement,
+ HTMLFormElement,
+ HTMLFrameElement,
+ HTMLFrameSetElement,
+ HTMLHeadElement,
+ HTMLHeadingElement,
+ HTMLHRElement,
+ HTMLHtmlElement,
+ HTMLIFrameElement,
+ HTMLImageElement,
+ HTMLInputElement,
+ HTMLLabelElement,
+ HTMLLegendElement,
+ HTMLLIElement,
+ HTMLLinkElement,
+ HTMLMapElement,
+ HTMLMetaElement,
+ HTMLObjectElement,
+ HTMLOListElement,
+ HTMLOptGroupElement,
+ HTMLOptionElement,
+ HTMLParagraphElement,
+ HTMLParamElement,
+ HTMLPreElement,
+ HTMLScriptElement,
+ HTMLSelectElement,
+ HTMLSpanElement,
+ HTMLStyleElement,
+ HTMLTableElement,
+ HTMLTableSectionElement,
+ HTMLTableCellElement,
+ HTMLTableDataCellElement,
+ HTMLTableHeaderCellElement,
+ HTMLTableRowElement,
+ HTMLTextAreaElement,
+ HTMLTitleElement,
+ HTMLUListElement,
+ HTMLUnknownElement,
+ Image,
+ Option,
+ __loadImage__,
+ __loadLink__;
+
+/*
+ * Envjs html.1.2.13
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+//CLOSURE_START
+(function(){
+
+
+
+
+
+/**
+ * @author ariel flesler
+ * http://flesler.blogspot.com/2008/11/fast-trim-function-for-javascript.html
+ * @param {Object} str
+ */
+function __trim__( str ){
+ return (str || "").replace( /^\s+|\s+$/g, "" );
+}
+
+
+/**
+ * @author john resig
+ */
+// Helper method for extending one object with another.
+function __extend__(a,b) {
+ for ( var i in b ) {
+ var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
+ if ( g || s ) {
+ if ( g ) { a.__defineGetter__(i, g); }
+ if ( s ) { a.__defineSetter__(i, s); }
+ } else {
+ a[i] = b[i];
+ }
+ } return a;
+}
+
+/**
+ * @author john resig
+ */
+//from jQuery
+function __setArray__( target, array ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ target.length = 0;
+ Array.prototype.push.apply( target, array );
+}
+
+/**
+ * @class HTMLDocument
+ * The Document interface represents the entire HTML or XML document.
+ * Conceptually, it is the root of the document tree, and provides
+ * the primary access to the document's data.
+ *
+ * @extends Document
+ */
+HTMLDocument = function(implementation, ownerWindow, referrer) {
+ Document.apply(this, arguments);
+ this.referrer = referrer || '';
+ this.baseURI = "about:blank";
+ this.ownerWindow = ownerWindow;
+};
+
+HTMLDocument.prototype = new Document();
+
+__extend__(HTMLDocument.prototype, {
+ createElement: function(tagName){
+ var node;
+ tagName = tagName.toUpperCase();
+ // create Element specifying 'this' as ownerDocument
+ // This is an html document so we need to use explicit interfaces per the
+ //TODO: would be much faster as a big switch
+ switch(tagName){
+ case "A":
+ node = new HTMLAnchorElement(this);break;
+ case "AREA":
+ node = new HTMLAreaElement(this);break;
+ case "BASE":
+ node = new HTMLBaseElement(this);break;
+ case "BLOCKQUOTE":
+ node = new HTMLQuoteElement(this);break;
+ case "CANVAS":
+ node = new HTMLCanvasElement(this);break;
+ case "Q":
+ node = new HTMLQuoteElement(this);break;
+ case "BODY":
+ node = new HTMLBodyElement(this);break;
+ case "BR":
+ node = new HTMLBRElement(this);break;
+ case "BUTTON":
+ node = new HTMLButtonElement(this);break;
+ case "CAPTION":
+ node = new HTMLElement(this);break;
+ case "COL":
+ node = new HTMLTableColElement(this);break;
+ case "COLGROUP":
+ node = new HTMLTableColElement(this);break;
+ case "DEL":
+ node = new HTMLModElement(this);break;
+ case "INS":
+ node = new HTMLModElement(this);break;
+ case "DIV":
+ node = new HTMLDivElement(this);break;
+ case "DL":
+ node = new HTMLDListElement(this);break;
+ case "DT":
+ node = new HTMLElement(this); break;
+ case "FIELDSET":
+ node = new HTMLFieldSetElement(this);break;
+ case "FORM":
+ node = new HTMLFormElement(this);break;
+ case "FRAME":
+ node = new HTMLFrameElement(this);break;
+ case "H1":
+ node = new HTMLHeadingElement(this);break;
+ case "H2":
+ node = new HTMLHeadingElement(this);break;
+ case "H3":
+ node = new HTMLHeadingElement(this);break;
+ case "H4":
+ node = new HTMLHeadingElement(this);break;
+ case "H5":
+ node = new HTMLHeadingElement(this);break;
+ case "H6":
+ node = new HTMLHeadingElement(this);break;
+ case "HEAD":
+ node = new HTMLHeadElement(this);break;
+ case "HR":
+ node = new HTMLHRElement(this);break;
+ case "HTML":
+ node = new HTMLHtmlElement(this);break;
+ case "IFRAME":
+ node = new HTMLIFrameElement(this);break;
+ case "IMG":
+ node = new HTMLImageElement(this);break;
+ case "INPUT":
+ node = new HTMLInputElement(this);break;
+ case "LABEL":
+ node = new HTMLLabelElement(this);break;
+ case "LEGEND":
+ node = new HTMLLegendElement(this);break;
+ case "LI":
+ node = new HTMLLIElement(this);break;
+ case "LINK":
+ node = new HTMLLinkElement(this);break;
+ case "MAP":
+ node = new HTMLMapElement(this);break;
+ case "META":
+ node = new HTMLMetaElement(this);break;
+ case "NOSCRIPT":
+ node = new HTMLElement(this);break;
+ case "OBJECT":
+ node = new HTMLObjectElement(this);break;
+ case "OPTGROUP":
+ node = new HTMLOptGroupElement(this);break;
+ case "OL":
+ node = new HTMLOListElement(this); break;
+ case "OPTION":
+ node = new HTMLOptionElement(this);break;
+ case "P":
+ node = new HTMLParagraphElement(this);break;
+ case "PARAM":
+ node = new HTMLParamElement(this);break;
+ case "PRE":
+ node = new HTMLPreElement(this);break;
+ case "SCRIPT":
+ node = new HTMLScriptElement(this);break;
+ case "SELECT":
+ node = new HTMLSelectElement(this);break;
+ case "SMALL":
+ node = new HTMLElement(this);break;
+ case "SPAN":
+ node = new HTMLSpanElement(this);break;
+ case "STRONG":
+ node = new HTMLElement(this);break;
+ case "STYLE":
+ node = new HTMLStyleElement(this);break;
+ case "TABLE":
+ node = new HTMLTableElement(this);break;
+ case "TBODY":
+ node = new HTMLTableSectionElement(this);break;
+ case "TFOOT":
+ node = new HTMLTableSectionElement(this);break;
+ case "THEAD":
+ node = new HTMLTableSectionElement(this);break;
+ case "TD":
+ node = new HTMLTableDataCellElement(this);break;
+ case "TH":
+ node = new HTMLTableHeaderCellElement(this);break;
+ case "TEXTAREA":
+ node = new HTMLTextAreaElement(this);break;
+ case "TITLE":
+ node = new HTMLTitleElement(this);break;
+ case "TR":
+ node = new HTMLTableRowElement(this);break;
+ case "UL":
+ node = new HTMLUListElement(this);break;
+ default:
+ node = new HTMLUnknownElement(this);
+ }
+ // assign values to properties (and aliases)
+ node.nodeName = tagName;
+ return node;
+ },
+ createElementNS : function (uri, local) {
+ //print('createElementNS :'+uri+" "+local);
+ if(!uri){
+ return this.createElement(local);
+ }else if ("http://www.w3.org/1999/xhtml" == uri) {
+ return this.createElement(local);
+ } else if ("http://www.w3.org/1998/Math/MathML" == uri) {
+ return this.createElement(local);
+ } else {
+ return Document.prototype.createElementNS.apply(this,[uri, local]);
+ }
+ },
+ get anchors(){
+ return new HTMLCollection(this.getElementsByTagName('a'));
+ },
+ get applets(){
+ return new HTMLCollection(this.getElementsByTagName('applet'));
+ },
+ get documentElement(){
+ var html = Document.prototype.__lookupGetter__('documentElement').apply(this,[]);
+ if( html === null){
+ html = this.createElement('html');
+ this.appendChild(html);
+ html.appendChild(this.createElement('head'));
+ html.appendChild(this.createElement('body'));
+ }
+ return html;
+ },
+ //document.head is non-standard
+ get head(){
+ //console.log('get head');
+ if (!this.documentElement) {
+ this.appendChild(this.createElement('html'));
+ }
+ var element = this.documentElement,
+ length = element.childNodes.length,
+ i;
+ //check for the presence of the head element in this html doc
+ for(i=0;i<length;i++){
+ if(element.childNodes[i].nodeType === Node.ELEMENT_NODE){
+ if(element.childNodes[i].tagName.toLowerCase() === 'head'){
+ return element.childNodes[i];
+ }
+ }
+ }
+ //no head? ugh bad news html.. I guess we'll force the issue?
+ var head = element.appendChild(this.createElement('head'));
+ return head;
+ },
+ get title(){
+ //console.log('get title');
+ if (!this.documentElement) {
+ this.appendChild(this.createElement('html'));
+ }
+ var title,
+ head = this.head,
+ length = head.childNodes.length,
+ i;
+ //check for the presence of the title element in this head element
+ for(i=0;i<length;i++){
+ if(head.childNodes[i].nodeType === Node.ELEMENT_NODE){
+ if(head.childNodes[i].tagName.toLowerCase() === 'title'){
+ return head.childNodes[i].textContent;
+ }
+ }
+ }
+ //no title? ugh bad news html.. I guess we'll force the issue?
+ title = head.appendChild(this.createElement('title'));
+ return title.appendChild(this.createTextNode('Untitled Document')).nodeValue;
+ },
+ set title(titleStr){
+ //console.log('set title %s', titleStr);
+ if (!this.documentElement) {
+ this.appendChild(this.createElement('html'));
+ }
+ var title = this.title;
+ title.textContent = titleStr;
+ },
+
+ get body(){
+ //console.log('get body');
+ if (!this.documentElement) {
+ this.appendChild(this.createElement('html'));
+ }
+ var body,
+ element = this.documentElement,
+ length = element.childNodes.length,
+ i;
+ //check for the presence of the head element in this html doc
+ for(i=0;i<length;i++){
+ if(element.childNodes[i].nodeType === Node.ELEMENT_NODE){
+ if(element.childNodes[i].tagName.toLowerCase() === 'body'){
+ return element.childNodes[i];
+ }
+ }
+ }
+ //no head? ugh bad news html.. I guess we'll force the issue?
+ return element.appendChild(this.createElement('body'));
+ },
+ set body(){console.log('set body');/**in firefox this is a benevolent do nothing*/},
+ get cookie(){
+ return Envjs.getCookies(this.location+'');
+ },
+ set cookie(cookie){
+ return Envjs.setCookie(this.location+'', cookie);
+ },
+
+ /**
+ * document.location
+ *
+ * should be identical to window.location
+ *
+ * HTML5:
+ * http://dev.w3.org/html5/spec/Overview.html#the-location-interface
+ *
+ * Mozilla MDC:
+ * https://developer.mozilla.org/en/DOM/document.location
+ *
+ */
+ get location() {
+ if (this.ownerWindow) {
+ return this.ownerWindow.location;
+ } else {
+ return this.baseURI;
+ }
+ },
+ set location(url) {
+ this.baseURI = url;
+ if (this.ownerWindow) {
+ this.ownerWindow.location = url;
+ }
+ },
+
+ /**
+ * document.URL (read-only)
+ *
+ * HTML DOM Level 2:
+ * http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-46183437
+ *
+ * HTML5:
+ * http://dev.w3.org/html5/spec/Overview.html#dom-document-url
+ *
+ * Mozilla MDC:
+ * https://developer.mozilla.org/en/DOM/document.URL
+ */
+ get URL() {
+ return this.location;
+ },
+ set URL(url) {
+ this.location = url;
+ },
+
+ /**
+ * document.domain
+ *
+ * HTML5 Spec:
+ * http://dev.w3.org/html5/spec/Overview.html#dom-document-domain
+ *
+ * Mozilla MDC:
+ * https://developer.mozilla.org/en/DOM/document.domain
+ *
+ */
+ get domain(){
+ var HOSTNAME = new RegExp('\/\/([^\:\/]+)'),
+ matches = HOSTNAME.exec(this.baseURI);
+ return matches&&matches.length>1?matches[1]:"";
+ },
+ set domain(value){
+ var i,
+ domainParts = this.domain.split('.').reverse(),
+ newDomainParts = value.split('.').reverse();
+ if(newDomainParts.length > 1){
+ for(i=0;i<newDomainParts.length;i++){
+ if(!(newDomainParts[i] === domainParts[i])){
+ return;
+ }
+ }
+ this.baseURI = this.baseURI.replace(domainParts.join('.'), value);
+ }
+ },
+
+ get forms(){
+ return new HTMLCollection(this.getElementsByTagName('form'));
+ },
+ get images(){
+ return new HTMLCollection(this.getElementsByTagName('img'));
+ },
+ get lastModified(){
+ /* TODO */
+ return this._lastModified;
+ },
+ get links(){
+ return new HTMLCollection(this.getElementsByTagName('a'));
+ },
+ getElementsByName : function(name){
+ //returns a real Array + the NodeList
+ var retNodes = __extend__([],new NodeList(this, this.documentElement)),
+ node;
+ // loop through all Elements
+ var all = this.getElementsByTagName('*');
+ for (var i=0; i < all.length; i++) {
+ node = all[i];
+ if (node.nodeType === Node.ELEMENT_NODE &&
+ node.getAttribute('name') == name) {
+ retNodes.push(node);
+ }
+ }
+ return retNodes;
+ },
+ toString: function(){
+ return "[object HTMLDocument]";
+ },
+ get innerHTML(){
+ return this.documentElement.outerHTML;
+ }
+});
+
+
+
+Aspect.around({
+ target: Node,
+ method:"appendChild"
+}, function(invocation) {
+ var event,
+ okay,
+ node = invocation.proceed(),
+ doc = node.ownerDocument;
+
+ //console.log('element appended: %s %s %s', node+'', node.nodeName, node.namespaceURI);
+ if((node.nodeType !== Node.ELEMENT_NODE)){
+ //for now we are only handling element insertions. probably
+ //we will need to handle text node changes to script tags and
+ //changes to src attributes
+ return node;
+ }
+ //console.log('appended html element %s %s %s',
+ // node.namespaceURI, node.nodeName, node);
+ switch(doc.parsing){
+ case true:
+ //handled by parser if included
+ //console.log('html document in parse mode');
+ break;
+ case false:
+ switch(node.namespaceURI){
+ case null:
+ //fall through
+ case "":
+ //fall through
+ case "http://www.w3.org/1999/xhtml":
+ switch(node.tagName.toLowerCase()){
+ case 'style':
+ document.styleSheets.push(CSSStyleSheet(node));
+ break;
+ case 'script':
+ if((this.nodeName.toLowerCase() === 'head')){
+ try{
+ okay = Envjs.loadLocalScript(node, null);
+ //console.log('loaded script? %s %s', node.uuid, okay);
+ // only fire event if we actually had something to load
+ if (node.src && node.src.length > 0){
+ event = doc.createEvent('HTMLEvents');
+ event.initEvent( okay ? "load" : "error", false, false );
+ node.dispatchEvent( event, false );
+ }
+ }catch(e){
+ console.log('error loading html element %s %e', node, e.toString());
+ }
+ }
+ break;
+ case 'frame':
+ case 'iframe':
+ node.contentWindow = { };
+ node.contentDocument = new HTMLDocument(new DOMImplementation(), node.contentWindow);
+ node.contentWindow.document = node.contentDocument;
+ try{
+ Window;
+ }catch(e){
+ node.contentDocument.addEventListener('DOMContentLoaded', function(){
+ event = node.contentDocument.createEvent('HTMLEvents');
+ event.initEvent("load", false, false);
+ node.dispatchEvent( event, false );
+ });
+ }
+ try{
+ if (node.src && node.src.length > 0){
+ //console.log("getting content document for (i)frame from %s", node.src);
+ Envjs.loadFrame(node, Envjs.uri(node.src));
+ event = node.contentDocument.createEvent('HTMLEvents');
+ event.initEvent("load", false, false);
+ node.dispatchEvent( event, false );
+ }else{
+ //I dont like this being here:
+ //TODO: better mix-in strategy so the try/catch isnt required
+ try{
+ if(Window){
+ Envjs.loadFrame(node);
+ //console.log('src/html/document.js: triggering frame load');
+ event = node.contentDocument.createEvent('HTMLEvents');
+ event.initEvent("load", false, false);
+ node.dispatchEvent( event, false );
+ }
+ }catch(e){}
+ }
+ }catch(e){
+ console.log('error loading html element %s %e', node, e.toString());
+ }
+ break;
+
+ case 'link':
+ if (node.href && node.href.length > 0) {
+ __loadLink__(node, node.href);
+ }
+ break;
+ /*
+ case 'img':
+ if (node.src && node.src.length > 0){
+ // don't actually load anything, so we're "done" immediately:
+ event = doc.createEvent('HTMLEvents');
+ event.initEvent("load", false, false);
+ node.dispatchEvent( event, false );
+ }
+ break;
+ */
+ case 'option':
+ node._updateoptions();
+ break;
+ default:
+ if(node.getAttribute('onload')){
+ console.log('calling attribute onload %s | %s', node.onload, node.tagName);
+ node.onload();
+ }
+ break;
+ }//switch on name
+ default:
+ break;
+ }//switch on ns
+ break;
+ default:
+ // console.log('element appended: %s %s', node+'', node.namespaceURI);
+ }//switch on doc.parsing
+ return node;
+
+});
+
+Aspect.around({
+ target: Node,
+ method:"removeChild"
+}, function(invocation) {
+ var event,
+ okay,
+ node = invocation.proceed(),
+ doc = node.ownerDocument;
+ if((node.nodeType !== Node.ELEMENT_NODE)){
+ //for now we are only handling element insertions. probably we will need
+ //to handle text node changes to script tags and changes to src
+ //attributes
+ if(node.nodeType !== Node.DOCUMENT_NODE && node.uuid){
+ //console.log('removing event listeners, %s', node, node.uuid);
+ node.removeEventListener('*', null, null);
+ }
+ return node;
+ }
+ //console.log('appended html element %s %s %s', node.namespaceURI, node.nodeName, node);
+
+ switch(doc.parsing){
+ case true:
+ //handled by parser if included
+ break;
+ case false:
+ switch(node.namespaceURI){
+ case null:
+ //fall through
+ case "":
+ //fall through
+ case "http://www.w3.org/1999/xhtml":
+ //this is interesting dillema since our event engine is
+ //storing the registered events in an array accessed
+ //by the uuid property of the node. unforunately this
+ //means listeners hang out way after(forever ;)) the node
+ //has been removed and gone out of scope.
+ //console.log('removing event listeners, %s', node, node.uuid);
+ node.removeEventListener('*', null, null);
+ switch(node.tagName.toLowerCase()){
+ case 'frame':
+ case 'iframe':
+ try{
+ //console.log('removing iframe document');
+ try{
+ Envjs.unloadFrame(node);
+ }catch(e){
+ console.log('error freeing resources from frame %s', e);
+ }
+ node.contentWindow = null;
+ node.contentDocument = null;
+ }catch(e){
+ console.log('error unloading html element %s %e', node, e.toString());
+ }
+ break;
+ default:
+ break;
+ }//switch on name
+ default:
+ break;
+ }//switch on ns
+ break;
+ default:
+ console.log('element appended: %s %s', node+'', node.namespaceURI);
+ }//switch on doc.parsing
+ return node;
+
+});
+
+
+
+/**
+ * Named Element Support
+ *
+ *
+ */
+
+/*
+ *
+ * @returns 'name' if the node has a appropriate name
+ * null if node does not have a name
+ */
+
+var __isNamedElement__ = function(node) {
+ if (node.nodeType !== Node.ELEMENT_NODE) {
+ return null;
+ }
+ var tagName = node.tagName.toLowerCase();
+ var nodename = null;
+
+ switch (tagName) {
+ case 'embed':
+ case 'form':
+ case 'iframe':
+ nodename = node.getAttribute('name');
+ break;
+ case 'applet':
+ nodename = node.id;
+ break;
+ case 'object':
+ // TODO: object needs to be 'fallback free'
+ nodename = node.id;
+ break;
+ case 'img':
+ nodename = node.id;
+ if (!nodename || ! node.getAttribute('name')) {
+ nodename = null;
+ }
+ break;
+ }
+ return (nodename) ? nodename : null;
+};
+
+
+var __addNamedMap__ = function(target, node) {
+ var nodename = __isNamedElement__(node);
+ if (nodename) {
+ target.__defineGetter__(nodename, function() {
+ return node;
+ });
+ }
+};
+
+var __removeNamedMap__ = function(target, node) {
+ if (!node) {
+ return;
+ }
+ var nodename = __isNamedElement__(node);
+ if (nodename) {
+ delete target[nodename];
+ }
+};
+
+/**
+ * @name HTMLEvents
+ * @w3c:domlevel 2
+ * @uri http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html
+ */
+
+var __eval__ = function(script, node){
+ if (!script == ""){
+ // don't assemble environment if no script...
+ try{
+ eval(script);
+ }catch(e){
+ console.log('error evaluating %s', e);
+ }
+ }
+};
+
+var HTMLEvents= function(){};
+HTMLEvents.prototype = {
+ onload: function(event){
+ __eval__(this.getAttribute('onload')||'', this);
+ },
+ onunload: function(event){
+ __eval__(this.getAttribute('onunload')||'', this);
+ },
+ onabort: function(event){
+ __eval__(this.getAttribute('onabort')||'', this);
+ },
+ onerror: function(event){
+ __eval__(this.getAttribute('onerror')||'', this);
+ },
+ onselect: function(event){
+ __eval__(this.getAttribute('onselect')||'', this);
+ },
+ onchange: function(event){
+ __eval__(this.getAttribute('onchange')||'', this);
+ },
+ onsubmit: function(event){
+ if (__eval__(this.getAttribute('onsubmit')||'', this)) {
+ this.submit();
+ }
+ },
+ onreset: function(event){
+ __eval__(this.getAttribute('onreset')||'', this);
+ },
+ onfocus: function(event){
+ __eval__(this.getAttribute('onfocus')||'', this);
+ },
+ onblur: function(event){
+ __eval__(this.getAttribute('onblur')||'', this);
+ },
+ onresize: function(event){
+ __eval__(this.getAttribute('onresize')||'', this);
+ },
+ onscroll: function(event){
+ __eval__(this.getAttribute('onscroll')||'', this);
+ }
+};
+
+//HTMLDocument, HTMLFramesetElement, HTMLObjectElement
+var __load__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("load", false, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//HTMLFramesetElement, HTMLBodyElement
+var __unload__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("unload", false, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//HTMLObjectElement
+var __abort__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("abort", true, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//HTMLFramesetElement, HTMLObjectElement, HTMLBodyElement
+var __error__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("error", true, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//HTMLInputElement, HTMLTextAreaElement
+var __select__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("select", true, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement
+var __change__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("change", true, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//HtmlFormElement
+var __submit__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("submit", true, true);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//HtmlFormElement
+var __reset__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("reset", false, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//LABEL, INPUT, SELECT, TEXTAREA, and BUTTON
+var __focus__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("focus", false, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//LABEL, INPUT, SELECT, TEXTAREA, and BUTTON
+var __blur__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("blur", false, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//Window
+var __resize__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("resize", true, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+//Window
+var __scroll__ = function(element){
+ var event = new Event('HTMLEvents');
+ event.initEvent("scroll", true, false);
+ element.dispatchEvent(event);
+ return event;
+};
+
+/**
+ * @name KeyboardEvents
+ * @w3c:domlevel 2
+ * @uri http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html
+ */
+var KeyboardEvents= function(){};
+KeyboardEvents.prototype = {
+ onkeydown: function(event){
+ __eval__(this.getAttribute('onkeydown')||'', this);
+ },
+ onkeypress: function(event){
+ __eval__(this.getAttribute('onkeypress')||'', this);
+ },
+ onkeyup: function(event){
+ __eval__(this.getAttribute('onkeyup')||'', this);
+ }
+};
+
+
+var __registerKeyboardEventAttrs__ = function(elm){
+ if(elm.hasAttribute('onkeydown')){
+ elm.addEventListener('keydown', elm.onkeydown, false);
+ }
+ if(elm.hasAttribute('onkeypress')){
+ elm.addEventListener('keypress', elm.onkeypress, false);
+ }
+ if(elm.hasAttribute('onkeyup')){
+ elm.addEventListener('keyup', elm.onkeyup, false);
+ }
+ return elm;
+};
+
+//HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement
+var __keydown__ = function(element){
+ var event = new Event('KeyboardEvents');
+ event.initEvent("keydown", false, false);
+ element.dispatchEvent(event);
+};
+
+//HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement
+var __keypress__ = function(element){
+ var event = new Event('KeyboardEvents');
+ event.initEvent("keypress", false, false);
+ element.dispatchEvent(event);
+};
+
+//HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement
+var __keyup__ = function(element){
+ var event = new Event('KeyboardEvents');
+ event.initEvent("keyup", false, false);
+ element.dispatchEvent(event);
+};
+
+/**
+ * @name MaouseEvents
+ * @w3c:domlevel 2
+ * @uri http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html
+ */
+var MouseEvents= function(){};
+MouseEvents.prototype = {
+ onclick: function(event){
+ __eval__(this.getAttribute('onclick')||'', this);
+ },
+ ondblclick: function(event){
+ __eval__(this.getAttribute('ondblclick')||'', this);
+ },
+ onmousedown: function(event){
+ __eval__(this.getAttribute('onmousedown')||'', this);
+ },
+ onmousemove: function(event){
+ __eval__(this.getAttribute('onmousemove')||'', this);
+ },
+ onmouseout: function(event){
+ __eval__(this.getAttribute('onmouseout')||'', this);
+ },
+ onmouseover: function(event){
+ __eval__(this.getAttribute('onmouseover')||'', this);
+ },
+ onmouseup: function(event){
+ __eval__(this.getAttribute('onmouseup')||'', this);
+ }
+};
+
+var __registerMouseEventAttrs__ = function(elm){
+ if(elm.hasAttribute('onclick')){
+ elm.addEventListener('click', elm.onclick, false);
+ }
+ if(elm.hasAttribute('ondblclick')){
+ elm.addEventListener('dblclick', elm.ondblclick, false);
+ }
+ if(elm.hasAttribute('onmousedown')){
+ elm.addEventListener('mousedown', elm.onmousedown, false);
+ }
+ if(elm.hasAttribute('onmousemove')){
+ elm.addEventListener('mousemove', elm.onmousemove, false);
+ }
+ if(elm.hasAttribute('onmouseout')){
+ elm.addEventListener('mouseout', elm.onmouseout, false);
+ }
+ if(elm.hasAttribute('onmouseover')){
+ elm.addEventListener('mouseover', elm.onmouseover, false);
+ }
+ if(elm.hasAttribute('onmouseup')){
+ elm.addEventListener('mouseup', elm.onmouseup, false);
+ }
+ return elm;
+};
+
+
+var __click__ = function(element){
+ var event = new Event('MouseEvents');
+ event.initEvent("click", true, true, null, 0,
+ 0, 0, 0, 0, false, false, false,
+ false, null, null);
+ element.dispatchEvent(event);
+};
+var __mousedown__ = function(element){
+ var event = new Event('MouseEvents');
+ event.initEvent("mousedown", true, true, null, 0,
+ 0, 0, 0, 0, false, false, false,
+ false, null, null);
+ element.dispatchEvent(event);
+};
+var __mouseup__ = function(element){
+ var event = new Event('MouseEvents');
+ event.initEvent("mouseup", true, true, null, 0,
+ 0, 0, 0, 0, false, false, false,
+ false, null, null);
+ element.dispatchEvent(event);
+};
+var __mouseover__ = function(element){
+ var event = new Event('MouseEvents');
+ event.initEvent("mouseover", true, true, null, 0,
+ 0, 0, 0, 0, false, false, false,
+ false, null, null);
+ element.dispatchEvent(event);
+};
+var __mousemove__ = function(element){
+ var event = new Event('MouseEvents');
+ event.initEvent("mousemove", true, true, null, 0,
+ 0, 0, 0, 0, false, false, false,
+ false, null, null);
+ element.dispatchEvent(event);
+};
+var __mouseout__ = function(element){
+ var event = new Event('MouseEvents');
+ event.initEvent("mouseout", true, true, null, 0,
+ 0, 0, 0, 0, false, false, false,
+ false, null, null);
+ element.dispatchEvent(event);
+};
+
+/**
+ * HTMLElement - DOM Level 2
+ */
+
+
+/* Hack for http://www.prototypejs.org/
+ *
+ * Prototype 1.6 (the library) creates a new global Element, which causes
+ * envjs to use the wrong Element.
+ *
+ * http://envjs.lighthouseapp.com/projects/21590/tickets/108-prototypejs-wont-load-due-it-clobbering-element
+ *
+ * Options:
+ * (1) Rename the dom/element to something else
+ * rejected: been done before. people want Element.
+ * (2) merge dom+html and not export Element to global namespace
+ * (meaning we would use a local var Element in a closure, so prototype
+ * can do what ever it wants)
+ * rejected: want dom and html separate
+ * (3) use global namespace (put everything under Envjs = {})
+ * rejected: massive change
+ * (4) use commonjs modules (similar to (3) in spirit)
+ * rejected: massive change
+ *
+ * or
+ *
+ * (5) take a reference to Element during initial loading ("compile
+ * time"), and use the reference instead of "Element". That's
+ * what the next line does. We use __DOMElement__ if we need to
+ * reference the parent class. Only this file explcity uses
+ * Element so this should work, and is the most minimal change I
+ * could think of with no external API changes.
+ *
+ */
+var __DOMElement__ = Element;
+
+HTMLElement = function(ownerDocument) {
+ __DOMElement__.apply(this, arguments);
+};
+
+HTMLElement.prototype = new Element();
+__extend__(HTMLElement.prototype, HTMLEvents.prototype);
+__extend__(HTMLElement.prototype, {
+ get className() {
+ return this.getAttribute("class")||'';
+ },
+ set className(value) {
+ return this.setAttribute("class",__trim__(value));
+ },
+ get dir() {
+ return this.getAttribute("dir")||"ltr";
+ },
+ set dir(val) {
+ return this.setAttribute("dir",val);
+ },
+ get id(){
+ return this.getAttribute('id');
+ },
+ set id(id){
+ this.setAttribute('id', id);
+ },
+ get innerHTML(){
+ var ret = "",
+ i;
+
+ // create string containing the concatenation of the string
+ // values of each child
+ for (i=0; i < this.childNodes.length; i++) {
+ if(this.childNodes[i]){
+ if(this.childNodes[i].nodeType === Node.ELEMENT_NODE){
+ ret += this.childNodes[i].xhtml;
+ } else if (this.childNodes[i].nodeType === Node.TEXT_NODE && i>0 &&
+ this.childNodes[i-1].nodeType === Node.TEXT_NODE){
+ //add a single space between adjacent text nodes
+ ret += " "+this.childNodes[i].xml;
+ }else{
+ ret += this.childNodes[i].xml;
+ }
+ }
+ }
+ return ret;
+ },
+ get lang() {
+ return this.getAttribute("lang");
+ },
+ set lang(val) {
+ return this.setAttribute("lang",val);
+ },
+ get offsetHeight(){
+ return Number((this.style.height || '').replace("px",""));
+ },
+ get offsetWidth(){
+ return Number((this.style.width || '').replace("px",""));
+ },
+ offsetLeft: 0,
+ offsetRight: 0,
+ get offsetParent(){
+ /* TODO */
+ return;
+ },
+ set offsetParent(element){
+ /* TODO */
+ return;
+ },
+ scrollHeight: 0,
+ scrollWidth: 0,
+ scrollLeft: 0,
+ scrollRight: 0,
+ get style(){
+ return this.getAttribute('style')||'';
+ },
+ get title() {
+ return this.getAttribute("title");
+ },
+ set title(value) {
+ return this.setAttribute("title", value);
+ },
+ get tabIndex(){
+ var tabindex = this.getAttribute('tabindex');
+ if(tabindex!==null){
+ return Number(tabindex);
+ } else {
+ return 0;
+ }
+ },
+ set tabIndex(value){
+ if (value === undefined || value === null) {
+ value = 0;
+ }
+ this.setAttribute('tabindex',Number(value));
+ },
+ get outerHTML(){
+ //Not in the specs but I'll leave it here for now.
+ return this.xhtml;
+ },
+ scrollIntoView: function(){
+ /*TODO*/
+ return;
+ },
+ toString: function(){
+ return '[object HTMLElement]';
+ },
+ get xhtml() {
+ // HTMLDocument.xhtml is non-standard
+ // This is exactly like Document.xml except the tagName has to be
+ // lower cased. I dont like to duplicate this but its really not
+ // a simple work around between xml and html serialization via
+ // XMLSerializer (which uppercases html tags) and innerHTML (which
+ // lowercases tags)
+
+ var ret = "",
+ ns = "",
+ name = (this.tagName+"").toLowerCase(),
+ attrs,
+ attrstring = "",
+ i;
+
+ // serialize namespace declarations
+ if (this.namespaceURI){
+ if((this === this.ownerDocument.documentElement) ||
+ (!this.parentNode) ||
+ (this.parentNode &&
+ (this.parentNode.namespaceURI !== this.namespaceURI))) {
+ ns = ' xmlns' + (this.prefix ? (':' + this.prefix) : '') +
+ '="' + this.namespaceURI + '"';
+ }
+ }
+
+ // serialize Attribute declarations
+ attrs = this.attributes;
+ for(i=0;i< attrs.length;i++){
+ attrstring += " "+attrs[i].name+'="'+attrs[i].xml+'"';
+ }
+
+ if(this.hasChildNodes()){
+ // serialize this Element
+ ret += "<" + name + ns + attrstring +">";
+ for(i=0;i< this.childNodes.length;i++){
+ ret += this.childNodes[i].xhtml ?
+ this.childNodes[i].xhtml :
+ this.childNodes[i].xml;
+ }
+ ret += "</" + name + ">";
+ }else{
+ switch(name){
+ case 'script':
+ ret += "<" + name + ns + attrstring +"></"+name+">";
+ break;
+ default:
+ ret += "<" + name + ns + attrstring +"/>";
+ }
+ }
+
+ return ret;
+ },
+
+ /**
+ * setAttribute use a dispatch table that other tags can set to
+ * "listen" to various values being set. The dispatch table
+ * and registration functions are at the end of the file.
+ *
+ */
+
+ setAttribute: function(name, value) {
+ var result = __DOMElement__.prototype.setAttribute.apply(this, arguments);
+ __addNamedMap__(this.ownerDocument, this);
+ var tagname = this.tagName;
+ var callback = HTMLElement.getAttributeCallback('set', tagname, name);
+ if (callback) {
+ callback(this, value);
+ }
+ },
+ setAttributeNS: function(namespaceURI, name, value) {
+ var result = __DOMElement__.prototype.setAttributeNS.apply(this, arguments);
+ __addNamedMap__(this.ownerDocument, this);
+ var tagname = this.tagName;
+ var callback = HTMLElement.getAttributeCallback('set', tagname, name);
+ if (callback) {
+ callback(this, value);
+ }
+
+ return result;
+ },
+ setAttributeNode: function(newnode) {
+ var result = __DOMElement__.prototype.setAttributeNode.apply(this, arguments);
+ __addNamedMap__(this.ownerDocument, this);
+ var tagname = this.tagName;
+ var callback = HTMLElement.getAttributeCallback('set', tagname, newnode.name);
+ if (callback) {
+ callback(this, node.value);
+ }
+ return result;
+ },
+ setAttributeNodeNS: function(newnode) {
+ var result = __DOMElement__.prototype.setAttributeNodeNS.apply(this, arguments);
+ __addNamedMap__(this.ownerDocument, this);
+ var tagname = this.tagName;
+ var callback = HTMLElement.getAttributeCallback('set', tagname, newnode.name);
+ if (callback) {
+ callback(this, node.value);
+ }
+ return result;
+ },
+ removeAttribute: function(name) {
+ __removeNamedMap__(this.ownerDocument, this);
+ return __DOMElement__.prototype.removeAttribute.apply(this, arguments);
+ },
+ removeAttributeNS: function(namespace, localname) {
+ __removeNamedMap__(this.ownerDocument, this);
+ return __DOMElement__.prototype.removeAttributeNS.apply(this, arguments);
+ },
+ removeAttributeNode: function(name) {
+ __removeNamedMap__(this.ownerDocument, this);
+ return __DOMElement__.prototype.removeAttribute.apply(this, arguments);
+ },
+ removeChild: function(oldChild) {
+ __removeNamedMap__(this.ownerDocument, oldChild);
+ return __DOMElement__.prototype.removeChild.apply(this, arguments);
+ },
+ importNode: function(othernode, deep) {
+ var newnode = __DOMElement__.prototype.importNode.apply(this, arguments);
+ __addNamedMap__(this.ownerDocument, newnode);
+ return newnode;
+ },