aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2013-05-22 23:52:43 +0200
committerMatěj Cepl <mcepl@redhat.com>2013-05-22 23:53:34 +0200
commitfb35a5e541342cdf9f73961c575c123f00dac79a (patch)
treea5a9d4f32c1be7553106ba599b56cd24f5b3f67a
parentbb2685eed25e1f347188c6dfc32d5756adf3d006 (diff)
downloadimportLDIF-fb35a5e541342cdf9f73961c575c123f00dac79a.tar.gz
Add storage of the last URL to the localStorage.
Fixes #102
-rw-r--r--importAddrBook.js69
-rw-r--r--index.html4
-rw-r--r--manifest.webapp2
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);
};
}());
diff --git a/index.html b/index.html
index 2790ec1..16961c1 100644
--- a/index.html
+++ b/index.html
@@ -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": {