Skip to content
Snippets Groups Projects
Commit 930de270 authored by Karl Hasselbring's avatar Karl Hasselbring
Browse files

Added last missing functionalities

parent 372061b4
Branches
No related tags found
1 merge request!13Offline funktionalitaet
......@@ -48,7 +48,7 @@
font-size: 12px;
}
#offline-addon .area-selection #download-information {
#offline-addon .area-selection .download-information {
padding: 0 10px;
}
......
......@@ -8,7 +8,6 @@ function OfflineModule(interactiveMap) {
this.initializeInterface(this);
this.addListeners(this);
this.status = "overview";
this.androidConnector = new OfflineModuleAndroidConnector();
}
......@@ -23,11 +22,6 @@ OfflineModule.prototype.addListeners = function(offlineModule) {
$("#offline-addon .add-area").click(function() {
offlineModule.startAreaSelection(offlineModule);
});
$("#start-download").off();
$("#start-download").click(function() {
offlineModule.startDownload(offlineModule);
});
};
function androidHasFunction(functionName) {
......@@ -37,14 +31,22 @@ function androidHasFunction(functionName) {
}
OfflineModule.prototype.loadExtractList = function(offlineModule) {
$("#offline-addon .exit").off();
$("#offline-addon .exit").click(function() {
offlineModule.interactiveMap.switchModule("search");
});
$("#offline-addon .add-area").show("slow");
$(".loading-areas").show();
$(".downloaded-areas > .area")
.not("#area-template")
.remove();
if (androidHasFunction("getExtractList")) {
var extractListJSON = offlineModule.androidConnector.getExtractList();
var extracts = JSON.parse(extractListJSON);
$(".loading-areas").hide();
if (extracts.length == 0) {
$("#offline-addon .no-areas").show();
return;
......@@ -82,33 +84,29 @@ OfflineModule.prototype.loadExtractList = function(offlineModule) {
$(".downloaded-areas").append(extractDomElement);
}, offlineModule);
} else {
$("#offline-addon .no-areas").show();
}
$("#offline-addon .loading-areas").hide();
};
OfflineModule.prototype.renameExtract = function(offlineModule, oldName) {
var newName = prompt("Geben Sie einen neuen Namen für dieses Gebiet ein:");
if (
newName != null &&
offlineModule.androidConnector.renameExtract(oldName, newName)
) {
$("#offline-addon .exit").off();
$("#offline-addon .exit").click(function() {
offlineModule.interactiveMap.switchModule("search");
});
$("#offline-addon .add-area").show("slow");
if (newName != null) {
if (!offlineModule.androidConnector.renameExtract(oldName, newName)) {
// TODO
}
offlineModule.clearBoundingBoxes(offlineModule);
offlineModule.loadExtractList(offlineModule);
}
};
OfflineModule.prototype.removeExtract = function(offlineModule, name) {
if (
confirm("Soll das ausgewählte Gebiet wirklich gelöscht werden?") &&
offlineModule.androidConnector.removeExtract(name)
) {
if (confirm("Soll das ausgewählte Gebiet wirklich gelöscht werden?")) {
if (!offlineModule.androidConnector.removeExtract(name)) {
// TODO
}
offlineModule.clearBoundingBoxes(offlineModule);
$("#offline-addon .exit").off();
$("#offline-addon .exit").click(function() {
offlineModule.interactiveMap.switchModule("search");
......@@ -299,10 +297,7 @@ OfflineModule.prototype.startAreaSelection = function(offlineModule) {
$("#offline-addon .downloaded-areas").hide("slow");
$("#offline-addon .area-selection").show("slow");
$("#offline-addon .exit").off();
$("#offline-addon .exit").click(function() {
offlineModule.stopAreaSelection(offlineModule);
});
$("#start-download").show();
offlineModule.interactiveMap.map.on("touchend", function() {
offlineModule.selectedAreaChanged(offlineModule);
......@@ -311,18 +306,31 @@ OfflineModule.prototype.startAreaSelection = function(offlineModule) {
offlineModule.selectedAreaChanged(offlineModule);
});
offlineModule.selectedAreaChanged(offlineModule);
$("#offline-addon .exit").off();
$("#offline-addon .exit").click(function() {
$(offlineModule.interactiveMap.map).off("touchend");
$(offlineModule.interactiveMap.map).off("mouseup");
offlineModule.stopAreaSelection(offlineModule);
});
$("#start-download").off();
$("#start-download").click(function() {
$(offlineModule.interactiveMap.map).off("touchend");
$(offlineModule.interactiveMap.map).off("mouseup");
offlineModule.startDownload(offlineModule);
});
offlineModule.status = "area-selection";
offlineModule.selectedAreaChanged(offlineModule);
};
OfflineModule.prototype.stopAreaSelection = function(offlineModule) {
$("#offline-addon .downloaded-areas").show("slow");
$("#offline-addon .area-selection").hide("slow");
offlineModule.loadExtractList(offlineModule);
offlineModule.addListeners(offlineModule);
$(offlineModule.interactiveMap.map).off("moveEnd");
offlineModule.status = "overview";
$(offlineModule.interactiveMap.map).off("touchend");
$(offlineModule.interactiveMap.map).off("mouseup");
};
OfflineModule.prototype.selectedAreaChanged = function(offlineModule) {
......@@ -338,9 +346,9 @@ OfflineModule.prototype.updateDownloadSizeExpectation = function(
);
if (expectedDownloadSize >= 0) {
expectedDownloadSizeString = filesizeToString(expectedDownloadSize);
$("#download-information > .size").html(expectedDownloadSizeString);
$(".download-information > .size").html(expectedDownloadSizeString);
} else {
$("#download-information > .size").html("Error");
$(".download-information > .size").html("Error");
}
};
......@@ -355,17 +363,14 @@ OfflineModule.prototype.startDownload = function(offlineModule, selectedArea) {
}
$(".exit").hide("fast");
$("#start-download").hide("fast");
$(".area-selection > div.text").html("Downloading...");
$(".area-selection").hide();
$(".area-downloading").show();
$(".download-progress").show();
$("#offline-addon .progress-bar").attr("aria-valuenow", 0);
$("#offline-addon .progress-bar").css("width", "0%");
$("#offline-addon .progress-label").html("0%");
$(".download-progress").show(
"slow",
$.proxy(function() {
var boundingBox = offlineModule.getBoundingBoxFromMap(offlineModule);
var downloadStarted = offlineModule.androidConnector.downloadTilesInBoundingBox(
boundingBox,
......@@ -383,8 +388,6 @@ OfflineModule.prototype.startDownload = function(offlineModule, selectedArea) {
} else {
offlineModule.cancelDownload(offlineModule);
}
})
);
};
OfflineModule.prototype.askForExtractName = function(offlineModule) {
......@@ -398,7 +401,7 @@ OfflineModule.prototype.reassureDownloadIfNoWireless = function(offlineModule) {
} else {
var prompt =
"Die Download-Größe beträgt " +
$("#download-information > .size").html() +
$(".download-information > .size").html() +
". Ohne WLan fortfahren?";
var confirmation = confirm(prompt);
return confirmation;
......@@ -419,8 +422,6 @@ OfflineModule.prototype.getBoundingBoxFromMap = function(offlineModule) {
OfflineModule.prototype.updateDownloadStatus = function(offlineModule) {
var error;
if ((error = offlineModule.androidConnector.getError()) != "") {
// TODO adjust to new version
$("#offline-addon .download-progress").before(
$('\
<div class="download-failed alert alert-danger">' + error + "</div>")
......@@ -460,19 +461,16 @@ OfflineModule.prototype.updateDownloadStatus = function(offlineModule) {
}
};
OfflineModule.prototype.cancelDownload = function(offlineModule, abort) {
OfflineModule.prototype.cancelDownload = function(offlineModule) {
offlineModule.androidConnector.cancelDownload();
this.exitDownload(offlineModule);
offlineModule.exitDownload(offlineModule);
};
OfflineModule.prototype.exitDownload = function(offlineModule) {
// TODO
$(".exit").show("fast");
$(".area-selection > div.text").html(offlineModule.areaSelectionText);
$(".download-progress").hide("slow");
$(".exit").click();
$(".area-selection").show();
$(".area-downloading").hide();
$(".download-progress").hide();
};
OfflineModule.prototype.initializeInterface = function(offlineModule) {
......
......@@ -23,7 +23,7 @@ OfflineModuleAndroidConnector.prototype.removeExtract = function(name) {
typeof android != "undefined" &&
typeof android["removeExtract"] == "function"
) {
return android.removeExtract();
return android.removeExtract(name);
} else {
throw 'Android does not have function "removeExtract"';
}
......
......@@ -34,7 +34,7 @@
font-weight: bold;
font-size: 12px;
#download-information {
.download-information {
padding: 0 10px;
}
......
......@@ -20,6 +20,7 @@
<div class="add-area placeholder">
<a href="#">+ Gebiet für Download hinzufügen</a>
</div>
<!--
<div class="auto-updates palceholder inactive">
<div class="option">
<label class="switch">
......@@ -31,6 +32,7 @@
<span>Automatische Updates</span>
</div>
</div>
-->
<div id="area-template" class="area">
<div>
<div class="size"></div>
......@@ -52,7 +54,7 @@
</div>
</div>
<div class="area-selection inactive">
<div id="download-information">
<div class="download-information">
<div class="size"></div>
</div>
<div class="text">
......@@ -63,6 +65,14 @@
<span class="glyphicon glyphicon-download-alt"></span>
</div>
</div>
<div class="area-downloading inactive">
<div id="download-information">
<div class="size"></div>
</div>
<div class="text">
<p>Lädt Karte ...</p>
</div>
</div>
<div class="download-progress inactive">
<span class="progress-label">0%</span>
<div class="progress">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment