diff options
-rw-r--r-- | importAddrBook.js | 69 | ||||
-rw-r--r-- | index.html | 4 | ||||
-rw-r--r-- | manifest.webapp | 2 |
3 files changed, 43 insertions, 32 deletions
diff --git a/importAddrBook.js b/importAddrBook.js index 75c45df..83256c4 100644 --- a/importAddrBook.js +++ b/importAddrBook.js @@ -307,46 +307,55 @@ } + function submitHandler (evt) { + var URL = document.getElementsByName("URL")[0].value; + var progressForm = document.getElementById("progress-div"); + document.getElementById("URL-form").style.display = "none"; + progressForm.style.display = "block"; - window.onload = function() { - document.body.addEventListener("submit", - function(evt) { + var req = new XMLHttpRequest(); + req.open("GET", URL, true); + var progressEl = progressForm.getElementsByTagName("progress")[0]; - var URL = document.getElementsByName("URL")[0].value; - var progressForm = document.getElementById("progress-div"); + req.onprogress = function(evt) { + if (evt.lengthComputable) { + progressEl.max = evt.total; + progressEl.value = evt.loaded; + } + }; - document.getElementById("URL-form").style.display = "none"; - progressForm.style.display = "block"; + req.onload = function() { + var inText = req.responseText; + if (inText.length > 0) { + insertData(inText); - var req = new XMLHttpRequest(); - req.open("GET", URL, true); - var progressEl = progressForm.getElementsByTagName("progress")[0]; + if (localStorage) { + localStorage.setItem("lastURL", URL); + } - req.onprogress = function(evt) { - if (evt.lengthComputable) { - progressEl.max = evt.total; - progressEl.value = evt.loaded; - } - }; + } + }; - req.onload = function() { - var inText = req.responseText; - if (inText.length > 0) { - insertData(inText); - } - }; + req.onerror = function() { + window.alert("Cannot load " + URL + "!"); + restoreURLForm(URL); + }; - req.onerror = function() { - window.alert("Cannot load " + URL + "!"); - restoreURLForm(URL); - }; + req.send(); + + evt.stopPropagation(); + evt.preventDefault(); + } - req.send(); + window.onload = function() { + if (localStorage && localStorage.lastURL) { + var oldURL = localStorage.getItem('lastURL'); + document.getElementsByName("URL")[0].value = oldURL; + } - evt.stopPropagation(); - evt.preventDefault(); - }, false); + document.body.addEventListener("submit", + submitHandler, false); }; }()); @@ -18,7 +18,9 @@ <legend>LDIF location</legend> <div> <label for="URL">URL of the LDIF file:</label> - <input name="URL" type="url" required autofocus> + <input name="URL" type="url" required autofocus + placeholder="Enter URL of the LDIF file" + mozactionhint="go"> </div> <!--div> <label for="user-name">Username:</label> diff --git a/manifest.webapp b/manifest.webapp index 0702d66..10ccbf5 100644 --- a/manifest.webapp +++ b/manifest.webapp @@ -1,5 +1,5 @@ { - "version": "2", + "version": "3", "name": "Import LDIF", "description": "Import LDIF file from the remote URL to Firefox OS Contacts application", "icons": { |