Commit a2d08a30 authored by CardBook's avatar CardBook

version 29.9

parent 615e5cba
......@@ -18,7 +18,6 @@ if ("undefined" == typeof(wdw_cardEdition)) {
panel : 0,
currentAdrId : [],
emailToAdd : [],
listOfCategories : [],
cardbookeditlists : {},
workingCard : {},
......@@ -368,11 +367,7 @@ if ("undefined" == typeof(wdw_cardEdition)) {
loadCategories: function (aCategoryList) {
var categoryPanel = document.getElementById("categoriesPanel");
var itemsList = [];
for (var i = 0; i < wdw_cardEdition.listOfCategories.length; i++) {
itemsList.push([wdw_cardEdition.listOfCategories[i], wdw_cardEdition.listOfCategories[i]]);
}
categoryPanel.loadItems("", itemsList, aCategoryList, false);
categoryPanel.loadItems("category", "0", cardbookRepository.cardbookAccountsCategories[wdw_cardEdition.workingCard.dirPrefId], aCategoryList, "category");
cardbookUtils.updatePanelMenulist("category", categoryPanel);
},
......@@ -381,11 +376,6 @@ if ("undefined" == typeof(wdw_cardEdition)) {
return categoryPanel.itemsLabel;
},
loadSourceCategories: function (aDirPrefId) {
wdw_cardEdition.listOfCategories = JSON.parse(JSON.stringify(cardbookRepository.cardbookAccountsCategories[aDirPrefId]));
wdw_cardEdition.listOfCategories = cardbookUtils.cleanCategories(wdw_cardEdition.listOfCategories);
},
display40: function (aCardVersion, aReadOnly) {
if (aCardVersion == "4.0") {
document.getElementById('birthplaceLabel').removeAttribute('hidden');
......@@ -449,8 +439,10 @@ if ("undefined" == typeof(wdw_cardEdition)) {
var strBundle = document.getElementById("cardbook-strings");
document.title=strBundle.getString("wdw_cardEdition" + window.arguments[0].editionMode + "Title");
if (window.arguments[0].editionMode == "ViewResult") {
document.getElementById('addressbookMenulistReadWriteGroupbox').removeAttribute('hidden');
document.getElementById('addressbookMenulist').disabled = false;
document.getElementById('addressbookMenulistLabel').label = strBundle.getString("addToAddressbook");
document.getElementById('addressbookMenulistReadOnlyGroupbox').setAttribute('hidden', 'true');
document.getElementById('existingDataGroupbox').setAttribute('hidden', 'true');
document.getElementById('contactMenulist').setAttribute('hidden', 'true');
document.getElementById('categoriesReadOnlyGroupbox').setAttribute('hidden', 'true');
......@@ -463,9 +455,8 @@ if ("undefined" == typeof(wdw_cardEdition)) {
document.getElementById('readOnlyClassicalVbox').setAttribute('hidden', 'true');
document.getElementById('readOnlyModernVbox').setAttribute('hidden', 'true');
} else if (window.arguments[0].editionMode == "ViewResultHideCreate") {
document.getElementById('addressbookMenulist').setAttribute('hidden', 'true');
document.getElementById('addressbookMenulistLabel').setAttribute('hidden', 'true');
document.getElementById('addressbookMenulistGroupbox').setAttribute('hidden', 'true');
document.getElementById('addressbookMenulistReadWriteGroupbox').setAttribute('hidden', 'true');
document.getElementById('addressbookMenulistReadOnlyGroupbox').setAttribute('hidden', 'true');
document.getElementById('existingDataGroupbox').setAttribute('hidden', 'true');
document.getElementById('contactMenulist').setAttribute('hidden', 'true');
document.getElementById('categoriesReadOnlyGroupbox').setAttribute('hidden', 'true');
......@@ -484,8 +475,9 @@ if ("undefined" == typeof(wdw_cardEdition)) {
document.getElementById('readOnlyClassicalVbox').setAttribute('hidden', 'true');
document.getElementById('readOnlyModernVbox').setAttribute('hidden', 'true');
} else if (window.arguments[0].editionMode == "ViewContact" || window.arguments[0].editionMode == "ViewList") {
document.getElementById('addressbookMenulist').disabled = true;
document.getElementById('addressbookMenulistLabel').label = strBundle.getString("ABLabel");
document.getElementById('addressbookMenulistReadWriteGroupbox').setAttribute('hidden', 'true');
document.getElementById('addressbookMenulistReadOnlyGroupbox').removeAttribute('hidden');
document.getElementById('addressbookLabel').label = strBundle.getString("ABLabel");
document.getElementById('existingDataGroupbox').setAttribute('hidden', 'true');
document.getElementById('contactMenulist').setAttribute('hidden', 'true');
document.getElementById('categoriesReadOnlyGroupbox').removeAttribute('hidden');
......@@ -511,8 +503,10 @@ if ("undefined" == typeof(wdw_cardEdition)) {
}
document.getElementById('readWriteVbox').setAttribute('hidden', 'true');
} else if (window.arguments[0].editionMode == "EditContact" || window.arguments[0].editionMode == "EditList") {
document.getElementById('addressbookMenulistReadWriteGroupbox').removeAttribute('hidden');
document.getElementById('addressbookMenulist').disabled = false;
document.getElementById('addressbookMenulistLabel').label = strBundle.getString("ABLabel");
document.getElementById('addressbookMenulistReadOnlyGroupbox').setAttribute('hidden', 'true');
document.getElementById('existingDataGroupbox').setAttribute('hidden', 'true');
document.getElementById('contactMenulist').setAttribute('hidden', 'true');
document.getElementById('categoriesReadOnlyGroupbox').setAttribute('hidden', 'true');
......@@ -524,8 +518,10 @@ if ("undefined" == typeof(wdw_cardEdition)) {
document.getElementById('readOnlyClassicalVbox').setAttribute('hidden', 'true');
document.getElementById('readOnlyModernVbox').setAttribute('hidden', 'true');
} else if (window.arguments[0].editionMode == "CreateContact" || window.arguments[0].editionMode == "CreateList") {
document.getElementById('addressbookMenulistReadWriteGroupbox').removeAttribute('hidden');
document.getElementById('addressbookMenulist').disabled = false;
document.getElementById('addressbookMenulistLabel').label = strBundle.getString("addToAddressbook");
document.getElementById('addressbookMenulistReadOnlyGroupbox').setAttribute('hidden', 'true');
document.getElementById('existingDataGroupbox').setAttribute('hidden', 'true');
document.getElementById('contactMenulist').setAttribute('hidden', 'true');
document.getElementById('categoriesReadOnlyGroupbox').setAttribute('hidden', 'true');
......@@ -538,8 +534,10 @@ if ("undefined" == typeof(wdw_cardEdition)) {
document.getElementById('readOnlyModernVbox').setAttribute('hidden', 'true');
} else if (window.arguments[0].editionMode == "AddEmail") {
wdw_cardEdition.emailToAdd = wdw_cardEdition.workingCard.email[0];
document.getElementById('addressbookMenulistReadWriteGroupbox').removeAttribute('hidden');
document.getElementById('addressbookMenulist').disabled = false;
document.getElementById('addressbookMenulistLabel').label = strBundle.getString("addToAddressbook");
document.getElementById('addressbookMenulistReadOnlyGroupbox').setAttribute('hidden', 'true');
document.getElementById('existingDataGroupbox').removeAttribute('hidden');
document.getElementById('contactMenulist').removeAttribute('hidden');
document.getElementById('categoriesReadOnlyGroupbox').setAttribute('hidden', 'true');
......@@ -612,7 +610,6 @@ if ("undefined" == typeof(wdw_cardEdition)) {
changeAddressbook: function () {
wdw_cardEdition.removeContacts();
document.getElementById('dirPrefIdTextBox').value = document.getElementById('addressbookMenulist').selectedItem.value;
wdw_cardEdition.loadSourceCategories(document.getElementById('addressbookMenulist').selectedItem.value);
wdw_cardEdition.workingCard = null;
wdw_cardEdition.workingCard = new cardbookCardParser();
cardbookUtils.cloneCard(window.arguments[0].cardIn, wdw_cardEdition.workingCard);
......@@ -774,6 +771,7 @@ if ("undefined" == typeof(wdw_cardEdition)) {
cardbookUtils.displayCard(aCard, aReadOnly, aFollowLink);
// specific
document.getElementById('addressbookTextBox').value = cardbookPreferences.getName(aCard.dirPrefId);
document.getElementById('categoriesTextBox').value = cardbookUtils.formatCategories(aCard.categories);
wdw_cardEdition.loadCategories(aCard.categories);
......@@ -1007,7 +1005,6 @@ if ("undefined" == typeof(wdw_cardEdition)) {
(window.arguments[0].editionMode == "ViewContact" || window.arguments[0].editionMode == "ViewList"), false, false);
// the dirPrefId may be different from the one loaded in case of a complex search
wdw_cardEdition.workingCard.dirPrefId = document.getElementById('addressbookMenulist').selectedItem.value;
wdw_cardEdition.loadSourceCategories(wdw_cardEdition.workingCard.dirPrefId);
cardbookElementTools.loadGender("genderMenupopup", "genderMenulist", wdw_cardEdition.workingCard.gender);
......@@ -1143,7 +1140,8 @@ if ("undefined" == typeof(wdw_cardEdition)) {
aCard[typesList[i]] = cardbookTypes.getAllTypes(typesList[i], true);
}
aCard.impp = cardbookTypes.getIMPPTypes();
cardbookTypes.rebuildAllPGs(aCard);
var othersTemp1 = [];
for (var i in cardbookRepository.customFields) {
for (var j = 0; j < cardbookRepository.customFields[i].length; j++) {
......
......@@ -92,7 +92,11 @@
<vbox flex="1">
<hbox flex="1">
<vbox flex="1">
<groupbox id="addressbookMenulistGroupbox" flex="1">
<groupbox id="addressbookMenulistReadOnlyGroupbox">
<caption id="addressbookLabel" class="header"/>
<textbox id="addressbookTextBox" flex="1" style="min-height:36px;" readonly="true"/>
</groupbox>
<groupbox id="addressbookMenulistReadWriteGroupbox" flex="1">
<caption id="addressbookMenulistLabel" class="header"/>
<hbox align="center" flex="1" style="min-height:36px;">
<menulist id="addressbookMenulist" flex="1" oncommand="wdw_cardEdition.changeAddressbook();">
......
......@@ -182,7 +182,9 @@ if ("undefined" == typeof(cardbookElementTools)) {
var defaultIndex = 0;
var j = 0;
var myResult = [["", ""]];
myResult = myResult.concat(cardbookPreferences.getAllTypesByType("gender"));
for (var type in cardbookRepository.cardbookGenderLookup) {
myResult.push([type, cardbookRepository.cardbookGenderLookup[type]]);
}
for (var i = 0; i < myResult.length; i++) {
var menuItem = document.createElement("menuitem");
menuItem.setAttribute("label", myResult[i][1]);
......@@ -543,7 +545,7 @@ if ("undefined" == typeof(cardbookElementTools)) {
return aPrefButton;
},
addMenuTypelist: function (aParent, aType, aIndex, aArray, aCheckedArray) {
addMenuTypelist: function (aParent, aType, aIndex, aCheckedArray) {
var aMenulist = document.createElement('menulist');
aParent.appendChild(aMenulist);
aMenulist.setAttribute('id', aType + '_' + aIndex + '_MenulistType');
......@@ -554,7 +556,7 @@ if ("undefined" == typeof(cardbookElementTools)) {
aMenulist.appendChild(aPanel);
// need to wait this end of load to populate
aPanel.addEventListener("load", function() {
this.loadItems(aType + '_' + aIndex, aArray, aCheckedArray, true);
this.loadItems(aType, aIndex, [], aCheckedArray, 'type');
cardbookUtils.updatePanelMenulist("type", this);
}, false);
function firePopuphiding(event) {
......
......@@ -43,7 +43,35 @@ var cardbookRepository = {
typesSeed : {"adr": ["HOME", "WORK"], "email": ["HOME", "WORK"], "impp": ["HOME", "WORK"], "tel": ["CELL", "FAX", "HOME","WORK"], "url": ["HOME", "WORK"],
"gender": ["F", "M", "N", "O", "U"]},
currentTypes : {},
cardbookGenderLookup : { "F": "", "M": "", "N": "", "O": "", "U": "" },
cardbookCoreTypes : { "GOOGLE": { "adr" : [ ["hometype", "HOME"], ["worktype", "WORK"] ],
"email" : [ ["hometype", "HOME"], ["worktype", "WORK"] ],
"tel" : [ ["hometype", "HOME"], ["worktype", "WORK"], ["celltype", "CELL"], ["faxtype", "FAX"], ["pagertype", "PAGER"], ["workfaxtype", "FAX,WORK"], ["homefaxtype", "FAX,HOME"] ],
"url" : [ ["hometype", "HOME"], ["worktype", "WORK"], ["blogtype", "BLOG", "PG"], ["homepagetype", "HOMEPAGE", "PG"], ["profiletype", "PROFILE", "PG"] ],
"impp" : [ ["hometype", "HOME"], ["worktype", "WORK"] ],
"addnew" : true },
"APPLE": { "adr" : [ ["hometype", "HOME"], ["worktype", "WORK"] ],
"email" : [ ["hometype", "HOME;HOME,INTERNET"], ["worktype", "WORK;WORK,INTERNET"], ["othertype", "OTHER;OTHER,INTERNET"] ],
"tel" : [ ["hometype", "HOME;HOME,VOICE"], ["worktype", "WORK;WORK,VOICE"], ["celltype", "CELL;CELL,VOICE"], ["faxtype", "FAX;FAX,VOICE"], ["pagertype", "PAGER"],
["workfaxtype", "FAX,WORK;FAX,WORK,VOICE"], ["homefaxtype", "FAX,HOME;FAX,HOME,VOICE"],
["othertype", "OTHER;OTHER,VOICE"], ["maintype", "MAIN"], ["iphonetype", "CELL,IPHONE;CELL,IPHONE,VOICE"] ],
"url" : [ ["hometype", "HOME"], ["worktype", "WORK"], ["othertype", "OTHER"] ],
"impp" : [ ["hometype", "HOME"], ["worktype", "WORK"] ],
"addnew" : true },
"YAHOO": { "adr" : [ ["hometype", "HOME;HOME,POSTAL,PARCEL,WORK"], ["worktype", "WORK;WORK,POSTAL,PARCEL"] ],
"email" : [ ["hometype", "HOME;HOME,INTERNET"], ["worktype", "WORK;WORK,INTERNET"] ],
"tel" : [ ["hometype", "HOME"], ["worktype", "WORK"], ["faxtype", "FAX"], ["pagertype", "PAGER"] ],
"url" : [ ["hometype", "HOME"], ["worktype", "WORK"] ],
"impp" : [ ["hometype", "HOME"], ["worktype", "WORK"] ],
"addnew" : false },
"CARDDAV": { "adr" : [ ["hometype", "HOME"], ["worktype", "WORK"] ],
"email" : [ ["hometype", "HOME"], ["worktype", "WORK"], ["othertype", "OTHER"] ],
"tel" : [ ["hometype", "HOME"], ["worktype", "WORK"], ["celltype", "CELL;CELL,IPHONE"], ["faxtype", "FAX"], ["pagertype", "PAGER"], ["workfaxtype", "FAX,WORK"], ["homefaxtype", "FAX,HOME"],
["othertype", "OTHER"], ["maintype", "MAIN"] ],
"url" : [ ["hometype", "HOME"], ["worktype", "WORK"], ["othertype", "OTHER"] ],
"impp" : [ ["hometype", "HOME"], ["worktype", "WORK"] ],
"addnew" : true } },
supportedVersion : ["3.0", "4.0"],
......@@ -274,132 +302,6 @@ var cardbookRepository = {
}
},
setTypes: function () {
var myTypes = [];
var myOldTypes = [];
myTypes = cardbookPreferences.getAllTypesCategory();
// for file opened with version <= 4.0
for (var i = 0; i < myTypes.length; i++) {
if (!myTypes[i].includes(".")) {
myOldTypes.push(cardbookPreferences.getTypes(myTypes[i]));
cardbookPreferences.delTypes(myTypes[i]);
myTypes.splice(i,1);
i--;
}
}
for (var i = 0; i < myOldTypes.length; i++) {
cardbookPreferences.setTypes("adr", i, myOldTypes[i]);
cardbookPreferences.setTypes("email", i, myOldTypes[i]);
cardbookPreferences.setTypes("tel", i, myOldTypes[i]);
cardbookPreferences.setTypes("impp", i, myOldTypes[i]);
cardbookPreferences.setTypes("url", i, myOldTypes[i]);
}
// for file opened with version <= 4.8
var myPhoneTypes = [];
myTypes = cardbookPreferences.getAllTypesCategory();
for (var i = 0; i < myTypes.length; i++) {
if (myTypes[i].includes("phone.")) {
myPhoneTypes.push(cardbookPreferences.getTypes(myTypes[i]));
cardbookPreferences.delTypes(myTypes[i]);
myTypes.splice(i,1);
i--;
}
}
for (var i = 0; i < myPhoneTypes.length; i++) {
cardbookPreferences.setTypes("tel", i, myPhoneTypes[i]);
}
// for file opened with version <= 4.8
var notfound = true;
myTypes = cardbookPreferences.getAllTypesCategory();
for (var i = 0; i < myTypes.length; i++) {
if (myTypes[i].includes("url.")) {
notfound = false;
break;
}
}
if (notfound) {
for (var i = 0; i < cardbookRepository.typesSeed.url.length; i++) {
cardbookPreferences.setTypes("url", i, cardbookRepository.typesSeed.url[i]);
}
}
// for file opened with version <= 4.8
var notfound = true;
myTypes = cardbookPreferences.getAllTypesCategory();
for (var i = 0; i < myTypes.length; i++) {
if (myTypes[i].includes("tel.")) {
notfound = false;
break;
}
}
if (notfound) {
for (var i = 0; i < cardbookRepository.typesSeed.tel.length; i++) {
cardbookPreferences.setTypes("tel", i, cardbookRepository.typesSeed.tel[i]);
}
}
// for file opened with version <= 4.8
var notfound = true;
myTypes = cardbookPreferences.getAllTypesCategory();
for (var i = 0; i < myTypes.length; i++) {
if (myTypes[i].includes("impp.")) {
notfound = false;
break;
}
}
if (notfound) {
for (var i = 0; i < cardbookRepository.typesSeed.impp.length; i++) {
cardbookPreferences.setTypes("impp", i, cardbookRepository.typesSeed.impp[i]);
}
}
// for file opened with version <= 4.8
var notfound = true;
myTypes = cardbookPreferences.getAllTypesCategory();
for (var i = 0; i < myTypes.length; i++) {
if (myTypes[i].includes("email.")) {
notfound = false;
break;
}
}
if (notfound) {
for (var i = 0; i < cardbookRepository.typesSeed.email.length; i++) {
cardbookPreferences.setTypes("email", i, cardbookRepository.typesSeed.email[i]);
}
}
// for file opened with version <= 11.6
var notfound = true;
myTypes = cardbookPreferences.getAllTypesCategory();
for (var i = 0; i < myTypes.length; i++) {
if (myTypes[i].includes("adr.")) {
notfound = false;
break;
}
}
if (notfound) {
for (var i = 0; i < cardbookRepository.typesSeed.adr.length; i++) {
cardbookPreferences.setTypes("adr", i, cardbookRepository.typesSeed.adr[i]);
}
}
// for file opened with version <= 15.3
var myIMPPs = [];
myIMPPs = cardbookPreferences.getAllIMPPs();
if (myIMPPs.length == 0) {
cardbookPreferences.insertIMPPsSeed();
}
// for file opened with version <= 23.4
var notfound = true;
myTypes = cardbookPreferences.getAllTypesCategory();
for (var i = 0; i < myTypes.length; i++) {
if (myTypes[i].includes("gender.")) {
notfound = false;
break;
}
}
if (notfound) {
for (var i = 0; i < cardbookRepository.typesSeed.gender.length; i++) {
cardbookPreferences.setTypes("gender", i, cardbookRepository.typesSeed.gender[i]);
}
}
},
setCalendarEntryAlarm: function() {
try {
// for file opened with version <= 24.2
......@@ -478,6 +380,13 @@ var cardbookRepository = {
}
},
setGenderLookup: function() {
var strBundle = Services.strings.createBundle("chrome://cardbook/locale/cardbook.properties");
for (var type in cardbookRepository.cardbookGenderLookup) {
cardbookRepository.cardbookGenderLookup[type] = strBundle.GetStringFromName("types.gender." + type.toLowerCase());
}
},
getLocalDirectory: function() {
let directoryService = Services.dirsvc;
// this is a reference to the profile dir (ProfD) now.
......@@ -1708,6 +1617,20 @@ var cardbookRepository = {
return aType;
},
getABTypeFormat: function (aType) {
switch(aType) {
case "CACHE":
case "DIRECTORY":
case "FILE":
case "LOCALDB":
case "CARDDAV":
case "SEARCH":
return "CARDDAV";
break;
};
return aType;
},
getABStatusType: function (aDirPrefId) {
if (cardbookUtils.isMyAccountSyncing(aDirPrefId)) {
return "syncing";
......
......@@ -40,7 +40,7 @@ if ("undefined" == typeof(cardbookSynchronization)) {
cardbookRepository.cardbookComplexSearchResponse[aPrefId] = 0;
cardbookRepository.cardbookComplexSearchReloadRequest[aPrefId] = 0;
cardbookRepository.cardbookComplexSearchReloadResponse[aPrefId] = 0;
cardbookRepository.filesFromCacheDB[aPrefId] = [];
cardbookRepository.filesFromCacheDB[aPrefId] = {};
cardbookRepository.cardbookServerDiscoveryRequest[aPrefId] = 0;
cardbookRepository.cardbookServerDiscoveryResponse[aPrefId] = 0;
cardbookRepository.cardbookServerDiscoveryError[aPrefId] = 0;
......@@ -1020,13 +1020,16 @@ if ("undefined" == typeof(cardbookSynchronization)) {
getCacheFiles: function (aPrefId) {
if (!(cardbookRepository.filesFromCacheDB[aPrefId])) {
cardbookRepository.filesFromCacheDB[aPrefId] = [];
cardbookRepository.filesFromCacheDB[aPrefId] = {};
}
var length = 0;
if (cardbookRepository.cardbookFileCacheCards[aPrefId]) {
for (var i in cardbookRepository.cardbookFileCacheCards[aPrefId]) {
cardbookRepository.filesFromCacheDB[aPrefId].push(i);
cardbookRepository.filesFromCacheDB[aPrefId][i] = "1";
length++;
}
}
return length;
},
getFilesFromDir: function (aDirName) {
......@@ -1126,14 +1129,14 @@ if ("undefined" == typeof(cardbookSynchronization)) {
handleRemainingCache: function (aPrefIdType, aConnection, aMode) {
if (cardbookRepository.filesFromCacheDB[aConnection.connPrefId]) {
for (var i = 0; i < cardbookRepository.filesFromCacheDB[aConnection.connPrefId].length; i++) {
for (var i in cardbookRepository.filesFromCacheDB[aConnection.connPrefId]) {
var params = {};
params["showError"] = true;
params["aConnection"] = aConnection;
params["aMode"] = aMode;
params["aPrefIdType"] = aPrefIdType;
params["aDirPrefId"] = aConnection.connPrefId;
cardbookIndexedDB.getItemByCacheuri(cardbookRepository.filesFromCacheDB[aConnection.connPrefId][i], cardbookSynchronization.handleRemainingCacheAsync, params);
cardbookIndexedDB.getItemByCacheuri(i, cardbookSynchronization.handleRemainingCacheAsync, params);
}
}
},
......@@ -1330,8 +1333,8 @@ if ("undefined" == typeof(cardbookSynchronization)) {
cardbookRepository.cardbookServerSyncResponse[aConnection.connPrefId]++;
} else if (response && response["multistatus"] && (status > 199 && status < 400)) {
try {
cardbookSynchronization.getCacheFiles(aConnection.connPrefId);
cardbookRepository.cardbookServerSyncHandleRemainingTotal[aConnection.connPrefId] = cardbookRepository.filesFromCacheDB[aConnection.connPrefId].length;
var length = cardbookSynchronization.getCacheFiles(aConnection.connPrefId);
cardbookRepository.cardbookServerSyncHandleRemainingTotal[aConnection.connPrefId] = length;
let jsonResponses = response["multistatus"][0]["response"];
for (var prop in jsonResponses) {
var jsonResponse = jsonResponses[prop];
......@@ -1355,11 +1358,10 @@ if ("undefined" == typeof(cardbookSynchronization)) {
var myFileName = cardbookUtils.getFileNameFromUrl(myUrl);
var aCardConnection = {accessToken: aConnection.accessToken, connPrefId: aConnection.connPrefId, connUrl: myUrl, connDescription: aConnection.connDescription};
cardbookSynchronization.compareServerCardWithCache(aCardConnection, aConnection, aMode, aPrefIdType, myUrl, etag, myFileName);
function filterFileName(element) {
return (element != myFileName);
if (cardbookRepository.filesFromCacheDB[aConnection.connPrefId][myFileName]) {
delete cardbookRepository.filesFromCacheDB[aConnection.connPrefId][myFileName];
cardbookRepository.cardbookServerSyncHandleRemainingTotal[aConnection.connPrefId]--;
}
cardbookRepository.filesFromCacheDB[aConnection.connPrefId] = cardbookRepository.filesFromCacheDB[aConnection.connPrefId].filter(filterFileName);
cardbookRepository.cardbookServerSyncHandleRemainingTotal[aConnection.connPrefId] = cardbookRepository.filesFromCacheDB[aConnection.connPrefId].length;
}
}
}
......@@ -1413,8 +1415,8 @@ if ("undefined" == typeof(cardbookSynchronization)) {
cardbookRepository.cardbookServerSyncResponse[aConnection.connPrefId]++;
} else if (response && response["multistatus"] && (status > 199 && status < 400)) {
try {
cardbookSynchronization.getCacheFiles(aConnection.connPrefId);
cardbookRepository.cardbookServerSyncHandleRemainingTotal[aConnection.connPrefId] = cardbookRepository.filesFromCacheDB[aConnection.connPrefId].length;
var length = cardbookSynchronization.getCacheFiles(aConnection.connPrefId);
cardbookRepository.cardbookServerSyncHandleRemainingTotal[aConnection.connPrefId] = length;
let jsonResponses = response["multistatus"][0]["response"];
for (var prop in jsonResponses) {
var jsonResponse = jsonResponses[prop];
......@@ -1450,11 +1452,10 @@ if ("undefined" == typeof(cardbookSynchronization)) {
cardbookRepository.cardbookServerSyncCompareWithCacheTotal[aConnection.connPrefId]++;
var aCardConnection = {connPrefId: aConnection.connPrefId, connUrl: myUrl, connDescription: aConnection.connDescription};
cardbookSynchronization.compareServerCardWithCache(aCardConnection, aConnection, aMode, aPrefIdType, myUrl, etag, myFileName);
function filterFileName(element) {
return (element != myFileName);
if (cardbookRepository.filesFromCacheDB[aConnection.connPrefId][myFileName]) {
delete cardbookRepository.filesFromCacheDB[aConnection.connPrefId][myFileName];
cardbookRepository.cardbookServerSyncHandleRemainingTotal[aConnection.connPrefId]--;
}
cardbookRepository.filesFromCacheDB[aConnection.connPrefId] = cardbookRepository.filesFromCacheDB[aConnection.connPrefId].filter(filterFileName);
cardbookRepository.cardbookServerSyncHandleRemainingTotal[aConnection.connPrefId] = cardbookRepository.filesFromCacheDB[aConnection.connPrefId].length;
}
}
}
......
This diff is collapsed.
......@@ -91,29 +91,6 @@ if ("undefined" == typeof(cardbookUtils)) {
return cardbookUtils.cleanArray(myAdrResultArray).join("\n");
},
// Due to this fucking Property Group, this is not easy
addTypeToCard: function (aCard, aType, aTypeArray) {
var myMaxPg = 0;
var typesList = [ 'email', 'tel', 'impp', 'url', 'adr' ];
for (var i in typesList) {
for (var j = 0; j < aCard[typesList[i]].length; j++) {
var myTempString = aCard[typesList[i]][j][2];
if (myTempString.startsWith("ITEM")) {
var myNumber = parseInt(myTempString.replace("ITEM", ""));
if (myNumber > myMaxPg) {
myMaxPg = myNumber;
}
}
}
}
if (myMaxPg == 0) {
aCard[aType].push(aTypeArray);
} else {
myMaxPg++;
aCard[aType].push([aTypeArray[0], aTypeArray[1], "ITEM" + myMaxPg, aTypeArray[3]]);
}
},
// allow the keyboard navigation for the type and category panel
enterPanelMenulist: function (aType, aEvent, aMenulist) {
let myPanel = document.getElementById(aMenulist.id.replace("Menulist", "Panel"));
......@@ -140,10 +117,6 @@ if ("undefined" == typeof(cardbookUtils)) {
} else if (aEvent.key == "Tab" && aEvent.shiftKey) {
if (myTextBox.hasAttribute("focused")) {
myPanel.hidePopup();
} else {
if (aType === "type") {
myPanel.hidePopup();
}
}
} else if (aEvent.key == "Escape") {
aMenulist.focus();
......@@ -166,8 +139,12 @@ if ("undefined" == typeof(cardbookUtils)) {
let found = false;
// first try to find if there is a matching entry
for (var i = 0; i < myListBox.itemCount; i++) {
if (myListBox.getItemAtIndex(i).getAttribute("label").substr(0,1).toLowerCase() == aEvent.key.toLowerCase()) {
myListBox.getItemAtIndex(i).checked = !myListBox.getItemAtIndex(i).checked;
var myItem = myListBox.getItemAtIndex(i);
if (myItem.getAttribute("label").substr(0,1).toLowerCase() == aEvent.key.toLowerCase()) {
myItem.checked = !myListBox.getItemAtIndex(i).checked;
if (myItem.checked) {
myPanel.validateCheckboxes(myItem.getAttribute("id"));
}
myListBox.selectedItem = myListBox.getItemAtIndex(i);
found = true;
break;
......@@ -265,7 +242,7 @@ if ("undefined" == typeof(cardbookUtils)) {
function compare3(a, b) { return collator.compareString(0, cardbookUtils.getName(a), cardbookUtils.getName(b))*aInvert; };
function compare4(a, b) { return ((a.isAList === b.isAList)? 0 : a.isAList? -1 : 1)*aInvert; };
function compare5(a, b) { return collator.compareString(0, cardbookUtils.getCardValueByField(a, aIndex), cardbookUtils.getCardValueByField(b, aIndex))*aInvert; };
function compare6(a, b) { return collator.compareString(0, cardbookRepository.currentTypes.gender[a.gender], cardbookRepository.currentTypes.gender[b.gender])*aInvert; };
function compare6(a, b) { return collator.compareString(0, cardbookRepository.cardbookGenderLookup[a.gender], cardbookRepository.cardbookGenderLookup[b.gender])*aInvert; };
function compare7(a, b) { return (cardbookDates.getDateForCompare(a, aIndex)*aInvert > cardbookDates.getDateForCompare(b, aIndex)*aInvert); };
function compare8(a, b) { return (cardbookUtils.getCardValueByField(a, aIndex) - cardbookUtils.getCardValueByField(b, aIndex))*aInvert; };
if (aIndex != -1) {
......@@ -922,7 +899,7 @@ if ("undefined" == typeof(cardbookUtils)) {
}
}
if (aCard.gender != "") {
document.getElementById('genderTextBox').value = cardbookRepository.currentTypes.gender[aCard.gender];
document.getElementById('genderTextBox').value = cardbookRepository.cardbookGenderLookup[aCard.gender];
}
var myRemainingOthers = [];
......@@ -957,7 +934,7 @@ if ("undefined" == typeof(cardbookUtils)) {
for (var i in typesList) {
if (aReadOnly) {
if (aCard[typesList[i]].length > 0) {
cardbookTypes.constructStaticRows(typesList[i], aCard[typesList[i]], aCard.version, aFollowLink);
cardbookTypes.constructStaticRows(aCard.dirPrefId, typesList[i], aCard[typesList[i]], aCard.version, aFollowLink);
} else {
cardbookElementTools.deleteRowsAllTypes(typesList[i]);
}
......@@ -1227,15 +1204,21 @@ if ("undefined" == typeof(cardbookUtils)) {
}
} else {
if (aCard[myField]) {
var ABType = cardbookPreferences.getType(aCard.dirPrefId);
var ABTypeFormat = cardbookRepository.getABTypeFormat(ABType);
for (var i = 0; i < aCard[myField].length; i++) {
if (aCard[myField][i][1].length == 0 && myType == "notype") {
result.push(aCard[myField][i][0][myPosition]);
if (myType == "notype") {
if (aCard[myField][i][1].length == 0 && aCard[myField][i][3].length == 0 && aCard[myField][i][2] == "") {
result.push(aCard[myField][i][0][myPosition]);
}
} else {
for (var j = 0; j < aCard[myField][i][1].length; j++) {
if (aCard[myField][i][1][j].toLowerCase() == "type=" + myType.toLowerCase()) {
result.push(aCard[myField][i][0][myPosition]);
break;
}
if (aCard[myField][i][3].length != 0 && aCard[myField][i][2] != "") {
var myInputTypes = [ aCard[myField][i][3][0] ];
} else {
var myInputTypes = cardbookUtils.getOnlyTypesFromTypes(aCard[myField][i][1]);
}
if (cardbookTypes.isMyCodePresent(myField, myType, ABTypeFormat, myInputTypes)) {
result.push(aCard[myField][i][0][myPosition]);
}
}
}
......@@ -1421,14 +1404,17 @@ if ("undefined" == typeof(cardbookUtils)) {
var result = [];
for (var i = 0; i < aArray.length; i++) {
var upperElement = aArray[i].toUpperCase();
if (upperElement === "PREF" || upperElement === "TYPE=PREF") {
if (upperElement == "PREF" || upperElement == "TYPE=PREF") {
continue;
} else if (upperElement === "HOME" || upperElement === "FAX" || upperElement === "CELL" || upperElement === "WORK" || upperElement === "PHONE" || upperElement === "BUSINESS"
|| upperElement === "VOICE"|| upperElement === "OTHER") {
} else if (upperElement == "HOME" || upperElement == "FAX" || upperElement == "CELL" || upperElement == "WORK" || upperElement == "PHONE" || upperElement == "BUSINESS"
|| upperElement == "OTHER") {
result.push(aArray[i]);
} else if (upperElement.replace(/^TYPE=/i,"") !== upperElement) {
var tmpArray = aArray[i].replace(/^TYPE=/ig,"").split(",").filter(deletePrefs);