diff options
Diffstat (limited to 'importAddrBook.js')
-rw-r--r-- | importAddrBook.js | 46 |
1 files changed, 46 insertions, 0 deletions
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); + + }; + +}()); |