Skip to content

TagSpaces is an offline, open source, document manager with tagging support

update

kristiyandd80aaf60cb22c
diff --git a/data/index.html b/data/index.html
index 54d3b6eac..d9e15d2dd 100644
--- a/data/index.html
+++ b/data/index.html
@@ -662,7 +662,8 @@
</div>
<div class="tab-pane" id="geoLocation">
<div class="form-group">
- <div id="mapTag" style="width: 100%; height: 400px;"></div>
+ <div id="mapTag" style="width: 100%; height: 350px;"></div>
+ <input type="text" id="coordinateMap" style="width: 100%;">
</div>
</div>
</div>
diff --git a/data/js/core.ui.js b/data/js/core.ui.js
index 425c3a429..e64442eec 100644
--- a/data/js/core.ui.js
+++ b/data/js/core.ui.js
@@ -329,6 +329,10 @@ define(function(require, exports, module) {
TSCORE.IO.openFile($(this).attr('href'));
});
+ $('#dialogEditTag').on('shown.bs.modal', function() {
+ parseTag(TSCORE.selectedTag);
+ });
+
// Hide drop downs by click and drag
$(document).click(function() {
TSCORE.hideAllDropDownMenus();
@@ -718,6 +722,27 @@ define(function(require, exports, module) {
TSCORE.MAP.initMap();
}
+ function parseTag(dataTag) {
+ var geoLocationRegExp = /^([-+]?)([\d]{1,2})(((\.)(\d+)(,)))(\s*)(([-+]?)([\d]{1,3})((\.)(\d+))?)$/g;
+ var currentCoordinate = dataTag.indexOf("-") !== -1 ? dataTag.split("-") : dataTag.split("+");
+
+ var dataYearRegExp = /^\d\d\d\d-(0?[1-9]|1[0-2])-(0?[1-9]|[12][0-9]|3[01])$/g;
+ var dataTimeRegExp = /^\d\d\d\d-(00|[0-9]|1[0-9]|2[0-3]):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9])$/g;
+ var currentDateTime = dataTag;
+
+ if (geoLocationRegExp.exec(currentCoordinate)) {
+ $('.nav-tabs a[href="#geoLocation"]').tab('show');
+ } else if (currentDateTime.match(dataTimeRegExp) || currentDateTime.match(dataYearRegExp)) {
+ $('.nav-tabs a[href="#dateTimeTab"]').tab('show');
+ } else if (!geoLocationRegExp.exec(currentCoordinate)
+ && !currentDateTime.match(dataTimeRegExp)
+ && !currentDateTime.match(dataYearRegExp)) {
+ $('.nav-tabs a[href="#formEditTag"]').tab('show');
+ } else {
+ throw new TypeError("Invalid data.");
+ }
+ }
+
function showRenameFileDialog() {
if (TSCORE.selectedFiles[0]) {
$('#renamedFileName').val(TSCORE.selectedFiles[0]);
diff --git a/data/js/map.ui.js b/data/js/map.ui.js
index f6a26d680..9fd68c596 100644
--- a/data/js/map.ui.js
+++ b/data/js/map.ui.js
@@ -97,10 +97,17 @@ define(function(require, exports, module) {
function onMapClick(e) {
addMarker(e);
+ parseCoordinateMap(e);
lat = e.latlng.lat;
lng = e.latlng.lng;
}
+ function parseCoordinateMap(e) {
+ var date = $('#coordinateMap')[0];
+ var long = lng >= 0 ? '+' + lng : lng;
+ date.value = e.latlng.lat + long;
+ }
+
function tagYourself() {
tagSpacesMap.locate({
setView: true,
@@ -137,11 +144,15 @@ define(function(require, exports, module) {
});
}
});
-
tagSpacesMap.on('resize', function() {
tagSpacesMap.invalidateSize();
});
+ $('#dialogEditTag').on('shown.bs.modal', function() {
+ var date = $('#coordinateMap')[0];
+ date.value = TSCORE.selectedTag;
+ });
+
tagSpacesMap.on('click', onMapClick);
showGeoLocation(TSCORE.selectedTag);