diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | README.rst | 3 | ||||
-rw-r--r-- | importAddrBook.js | 46 | ||||
-rw-r--r-- | index.html | 43 | ||||
m--------- | libs/parseLDIF | 0 | ||||
l--------- | libs/parseLDIF.js | 1 |
6 files changed, 96 insertions, 0 deletions
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 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <title>Import LDIF addresbook</title> + <style> + #progress-div { + display: none; + } + </style> +</head> +<body> + <h1>Import LDIF addressbook</h1> + + <form id="URL-form" submit="#"> + <fieldset> + <legend>LDIF location</legend> + <div> + <label for="URL">URL of the LDIF file:</label> + <input name="URL" type="url" required autofocus> + </div> + <!--div> + <label for="user-name">Username:</label> + <input name="user-name" type="text" required> + </div> + <div> + <label for="password">Password:</label> + <input name="password" type="password" required> + </div--> + <div> + <input name="login" type="submit" value="Load"> + </div> + </fieldset> + </form> + + <div id="progress-div"> + <progress value="0" max="100">0 %</progress> + </div> + + <script src="libs/parseLDIF.js" type="text/javascript"></script> + <script src="importAddrBook.js" type="text/javascript"></script> +</body> +</html> diff --git a/libs/parseLDIF b/libs/parseLDIF new file mode 160000 +Subproject cf2b86f588beb9e1964f773e2fbca4ca1174709 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 |