From bb2685eed25e1f347188c6dfc32d5756adf3d006 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Wed, 22 May 2013 19:23:18 +0200 Subject: Clean up metadata and small UI improvements. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * rename to 'Import LDIF' * change icon to the Crystal text/x-vcard one * make it clear when the download finishes, and restore the URL form * don't try to import empty LDIF file * remove .appcache … we don’t use it for the packaged app --- Makefile | 13 +- icon-128.png | Bin 8549 -> 9659 bytes importAddrBook.js | 33 ++++- importLDIF.appcache | 5 - manifest.webapp | 4 +- text-x-vcard.svg | 372 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 410 insertions(+), 17 deletions(-) delete mode 100644 importLDIF.appcache create mode 100644 text-x-vcard.svg diff --git a/Makefile b/Makefile index 3ab74fa..d159c7f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ -FILES=icon-128.png importAddrBook.js importLDIF.appcache index.html \ - libs/parseLDIF.js manifest.webapp +FILES=icon-128.png importAddrBook.js index.html libs/parseLDIF.js \ + manifest.webapp -all: importAddrBook.zip +all: importLDIF.zip -importAddrBook.zip: $(FILES) - zip -9vT $@ $(FILES) +importLDIF.zip: $(FILES) + zip -9qT $@ $(FILES) + +clean: + rm -fv *~ importLDIF.zip diff --git a/icon-128.png b/icon-128.png index 836f545..c93b46d 100644 Binary files a/icon-128.png and b/icon-128.png differ diff --git a/importAddrBook.js b/importAddrBook.js index 9a0e6f4..75c45df 100644 --- a/importAddrBook.js +++ b/importAddrBook.js @@ -210,6 +210,7 @@ return null; } + /** * Not used presently and not debugged. */ @@ -252,6 +253,14 @@ } } + function restoreURLForm(url) { + document.getElementById("progress-div").style.display = "none"; + document.getElementById("URL-form").style.display = "block"; + if (url !== undefined) { + document.getElementsByName("URL")[0].value = url; + } + } + function insertData(ldifText) { var progressEl = document.querySelector("#progress-div progress"); @@ -283,21 +292,27 @@ sav_req.onsuccess = function() { progressEl.value += 1; - console.log("Contact added:\n" + add_contact.id); + if (progressEl.value >= records.length) { + window.alert("All contacts have been imported!"); + restoreURLForm(); + } }; sav_req.onerror = function() { - console.error("Cannot save record " + add_contact.id); + console.error("Cannot save record " + add_contact.id + + "\n" + rec.toSource()); }; }); }; } - window.onload = function() { + + window.onload = function() { document.body.addEventListener("submit", function(evt) { + var URL = document.getElementsByName("URL")[0].value; var progressForm = document.getElementById("progress-div"); @@ -316,14 +331,22 @@ }; req.onload = function() { - insertData(req.responseText); + var inText = req.responseText; + if (inText.length > 0) { + insertData(inText); + } + }; + + req.onerror = function() { + window.alert("Cannot load " + URL + "!"); + restoreURLForm(URL); }; + req.send(); evt.stopPropagation(); evt.preventDefault(); }, false); - }; }()); diff --git a/importLDIF.appcache b/importLDIF.appcache deleted file mode 100644 index c7a953f..0000000 --- a/importLDIF.appcache +++ /dev/null @@ -1,5 +0,0 @@ -CACHE MANIFEST -# v1 - 2013-05-14 -importAddrBook.js -index.html -libs/parseLDIF.js diff --git a/manifest.webapp b/manifest.webapp index 4597530..0702d66 100644 --- a/manifest.webapp +++ b/manifest.webapp @@ -1,6 +1,6 @@ { - "version": "0.0.1", - "name": "importLDIF", + "version": "2", + "name": "Import LDIF", "description": "Import LDIF file from the remote URL to Firefox OS Contacts application", "icons": { "128": "/icon-128.png" diff --git a/text-x-vcard.svg b/text-x-vcard.svg new file mode 100644 index 0000000..40cdaed --- /dev/null +++ b/text-x-vcard.svg @@ -0,0 +1,372 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Addess Book + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + address + contact + book + office + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit