From 9831804da870874e6c2e6b37a1ad5a3c47b691ea Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 14 May 2013 01:30:34 +0200 Subject: Initial draft of the program. LDIF data are loaded and parsed, but not inserted into the addressbook. --- .gitmodules | 3 +++ README.rst | 3 +++ importAddrBook.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ index.html | 43 +++++++++++++++++++++++++++++++++++++++++++ libs/parseLDIF | 1 + libs/parseLDIF.js | 1 + 6 files changed, 97 insertions(+) create mode 100644 .gitmodules create mode 100644 README.rst create mode 100644 importAddrBook.js create mode 100644 index.html create mode 160000 libs/parseLDIF create mode 120000 libs/parseLDIF.js diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2e19c11 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libs/parseLDIF"] + path = libs/parseLDIF + url = https://github.com/mcepl/parseLDIF.git diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..8ced25f --- /dev/null +++ b/README.rst @@ -0,0 +1,3 @@ +This should be a very simple Firefox OS app to load addresbook from +a LDIF file (perhaps exported from the Thunderbird Addressbook) to the +Contacts application. diff --git a/importAddrBook.js b/importAddrBook.js new file mode 100644 index 0000000..8c1894b --- /dev/null +++ b/importAddrBook.js @@ -0,0 +1,46 @@ +(function () { + "use strict"; + + function insertData(ldifText) { + var data = parseLDIF(ldifText.split("\n")); + console.log("loaded " + Object.keys(data).length + " records."); + } + + window.onload = function() { + + document.body.addEventListener("submit", + function(evt) { + var URL = document.getElementsByName("URL")[0].value; + //var login = document.getElementsByName("user-name")[0].value; + //var passwd = document.getElementsByName("password")[0].value; + var progressForm = document.getElementById("progress-div"); + + console.log("URL = " + URL); + //console.log("login = " + login); + //console.log("passwd = " + passwd); + document.getElementById("URL-form").style.display = "none"; + progressForm.style.display = "block"; + + var req = new XMLHttpRequest(); + req.open("GET", URL, true); + var progressEl = progressForm.getElementsByTagName("progress")[0]; + + req.onprogress = function(evt) { + if (evt.lengthComputable) { + progressEl.max = evt.total; + progressEl.value = evt.loaded; + } + }; + + req.onload = function() { + insertData(req.responseText); + }; + req.send(); + + evt.stopPropagation(); + evt.preventDefault(); + }, false); + + }; + +}()); diff --git a/index.html b/index.html new file mode 100644 index 0000000..f37a14f --- /dev/null +++ b/index.html @@ -0,0 +1,43 @@ + + + + + Import LDIF addresbook + + + +

Import LDIF addressbook

+ +
+
+ LDIF location +
+ + +
+ +
+ +
+
+
+ +
+ 0 % +
+ + + + + diff --git a/libs/parseLDIF b/libs/parseLDIF new file mode 160000 index 0000000..cf2b86f --- /dev/null +++ b/libs/parseLDIF @@ -0,0 +1 @@ +Subproject commit cf2b86f588beb9e1964f773e2fbca4ca1174709a diff --git a/libs/parseLDIF.js b/libs/parseLDIF.js new file mode 120000 index 0000000..0df7340 --- /dev/null +++ b/libs/parseLDIF.js @@ -0,0 +1 @@ +parseLDIF/parseLDIF.js \ No newline at end of file -- cgit