aboutsummaryrefslogblamecommitdiffstats
path: root/importAddrBook.js
blob: 8c1894b7101a430a32193b6c2b89f5bd4256ccac (plain) (tree)













































                                                                            
(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);

  };

}());