aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2013-05-14 01:30:34 +0200
committerMatěj Cepl <mcepl@redhat.com>2013-05-14 01:35:09 +0200
commit9831804da870874e6c2e6b37a1ad5a3c47b691ea (patch)
tree88a781d80d06a0451b05bf29fde7c2264033ca05
downloadimportLDIF-9831804da870874e6c2e6b37a1ad5a3c47b691ea.tar.gz
Initial draft of the program.
LDIF data are loaded and parsed, but not inserted into the addressbook.
-rw-r--r--.gitmodules3
-rw-r--r--README.rst3
-rw-r--r--importAddrBook.js46
-rw-r--r--index.html43
m---------libs/parseLDIF0
l---------libs/parseLDIF.js1
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