Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
183 righe
7.5 KiB
183 righe
7.5 KiB
$(document).ready(function(){ |
|
_attachTopNavMenu(); |
|
_displayMapRead('app'); |
|
}); |
|
function _attachTopNavMenu () { |
|
var adjacentTopNavMenuDOM = "" + |
|
"<nav id='sidebar'>" + |
|
" <div class='sidebar-header'><a href='#'><img src='assets/img/draw.png' height='90px'></a></div> " + |
|
" <ul class='list-unstyled'>" + |
|
<?php if ($_SESSION['STATUS'] == 'true' ) {?> |
|
" <li><a id='home' class='nav-link flat' href='#'><span class='icon'><i class='fal fa-home fa-lg'></i></span>Torna alla mappa</a></li>" + |
|
<?php } else { ?> |
|
" <li><a id='home' class='nav-link flat' href='#'><span class='icon'><i class='fal fa-home fa-lg'></i></span>Home</a></li>" + |
|
<?php } ?> |
|
" <li><a id='leaflet_crud_create' class='nav-link flat' href='#'><span class='icon'><i class='fal fa-object-group fa-lg'></i></span> Crea</a>" + |
|
" <li><a id='leaflet_crud_read' class='nav-link flat' href='#'><span class='icon'><i class='fal fa-map fa-lg'></i></span> Visualizza</a>" + |
|
" <li>" + |
|
" <a href='#homeSubmenu' id='navbarDropdownUpdate' data-toggle='collapse' aria-expanded='false' class='dropdown-toggle collapsed'><span class='icon'><i class='fal fa-edit fa-lg'></i></span>Modifica</a>" + |
|
" <ul class='collapse list-unstyled' id='homeSubmenu'>" + |
|
" <li><a id='leaflet_crud_update_point' class='dropdown-item' href='#'><i class='fal fa-map-marker-alt fa-lg' style='margin-right:10px'></i> Punto</a>" + |
|
" <li><a id='leaflet_crud_update_linestring' class='dropdown-item' href='#'><i class='fal fa-grip-lines fa-lg' style='margin-right:10px'></i> Linea</a>" + |
|
" <li><a id='leaflet_crud_update_polygon' class='dropdown-item' href='#'><i class='fas fa-draw-polygon fa-lg' style='margin-right:10px'></i> Poligono</a></li>" + |
|
" </ul>" + |
|
" </li>" + |
|
" <li><a id='leaflet_crud_delete' class='nav-link flat' href='#'><span class='icon'><i class='fal fa-trash fa-lg'></i></span> Cancella</a></li>" + |
|
" <li><a href='guida.php' class='nav-link flat'><span class='icon'><i class='fas fa-question fa-lg' style='margin-right:10px'></i></span>Guida</a></li>" + |
|
" </ul>" + |
|
"</nav>" + |
|
""; |
|
var baseObject = document.getElementById('app'); |
|
baseObject.insertAdjacentHTML('beforebegin', adjacentTopNavMenuDOM); |
|
_attachTopNavMenuFunction(); |
|
} |
|
function _attachTopNavMenuFunction () { |
|
$('#sidebar a.nav-link.flat').on('click', function(e){ |
|
e.stopImmediatePropagation(); |
|
var menuid = $(this).attr('id'); |
|
$('.navbar-collapse').collapse('hide'); |
|
switch(menuid){ |
|
|
|
<?php if ($_SESSION['STATUS'] == true ) {?> |
|
case 'home': |
|
window.location.href = "detail.php"; |
|
break; |
|
<?php } else { ?> |
|
case 'home': |
|
<?php } ?> |
|
case 'leaflet_crud_read': |
|
_displayMapRead('app'); |
|
break; |
|
case 'leaflet_crud_create': |
|
_displayMapCreate('app'); |
|
break; |
|
case 'leaflet_crud_delete': |
|
_displayMapDelete('app'); |
|
break; |
|
default: |
|
console.log('__undefined__'); |
|
break; |
|
} |
|
return false; |
|
}); |
|
$('#sidebar a.dropdown-item').on('click', function(e){ |
|
e.stopImmediatePropagation(); |
|
var menuid = $(this).attr('id'); |
|
$('.navbar-collapse').collapse('hide'); |
|
$(this).closest('li.nav-item.dropdown').find('.nav-link.dropdown-toggle').dropdown('toggle'); |
|
switch(menuid){ |
|
case 'leaflet_crud_update_point': |
|
_displayMapUpdatePoint('app'); |
|
break; |
|
case 'leaflet_crud_update_linestring': |
|
_displayMapUpdateLinestring('app'); |
|
break; |
|
case 'leaflet_crud_update_polygon': |
|
_displayMapUpdatePolygon('app'); |
|
break; |
|
default: |
|
console.log('__undefined__'); |
|
break; |
|
} |
|
return false; |
|
}); |
|
} |
|
function _buildDigitiseModalBox (targetmodal,context,geometry) { |
|
targetmodal = typeof targetmodal !== 'undefined' ? targetmodal : 'modalbox'; |
|
context = typeof context !== 'undefined' ? context : 'POINT'; |
|
geometry = typeof geometry !== 'undefined' ? geometry : 'POINT (110.21766 -7.459129)'; |
|
|
|
var htmlformcomponent = "" + |
|
"<input type='hidden' id='command' name='command' value='"+context+"'/>" + |
|
"<input type='hidden' id='geometry' name='geometry' value='"+geometry+"'/>" + |
|
"<table id='feature_data' class='table table-condensed table-bordered table-striped'>" + |
|
"<thead>" + |
|
"<tr>" + |
|
"<th colspan='2' class='text-center'>Dati indetificativi</th>" + |
|
"</tr>" + |
|
"</thead>" + |
|
"<tbody>" + |
|
"<tr>" + |
|
"<td class=''>Note alla geometria</td>" + |
|
"<td class='text-center'><textarea id='notes' name='notes' rows='4' class='form-control' value=''/></textarea></td>" + |
|
"</tr>" + |
|
"<!--tr>" + |
|
"<td class=''>Geometry<br/>(in WKT)</td>" + |
|
"<td class='text-center'><textarea rows='5' style='width:100%;' readonly='true'>"+geometry+"</textarea></td>" + |
|
"</tr-->" + |
|
"</tbody>" + |
|
"</table>" + |
|
""; |
|
var modalfooter = "" + |
|
"<button type='button' id='canceldigitize' class='btn btn-default' data-dismiss='modal'><i class='fa fa-power-off'></i> Cancel</button>" + |
|
"<button type='button' id='savegeometrydata' class='btn btn-primary'><i class='fa fa-floppy-o'></i> Save</button>" + |
|
""; |
|
$("#form_modal_body").empty(); |
|
$("#form_modal_footer").empty().html(modalfooter); |
|
$("#form_modal_body").removeClass().addClass('modal-body'); |
|
$("#form_modal_size").removeClass().addClass('modal-dialog'); |
|
$("#form_modal_body").html(htmlformcomponent); |
|
$("#form_modal_label").html("<i class='fa fa-pencil'></i> "+context+""); |
|
|
|
$('#'+targetmodal+'').modal({show:true, backdrop:'static', keyboard:false}); |
|
} |
|
function _activateFeatureSave () { |
|
$("#savegeometrydata").on('click', function(evt){ |
|
evt.stopImmediatePropagation(); |
|
var commandContext = $('#command').val(); |
|
var noteString = $('#notes').val(); |
|
var geometry = $('#geometry').val(); |
|
if (commandContext == "POINT") { |
|
$.ajax({ url: "assets/dataservice/create_point.php", |
|
method: "GET", |
|
dataType: "json", |
|
data: $('#dynamicform').serialize(), |
|
success: function (data) { |
|
if (data.response=="200") { |
|
$("#modalform").modal('hide'); |
|
} else { |
|
$("#modalform").modal('hide'); |
|
console.log('Failed to save.'); |
|
} |
|
}, |
|
username: null, |
|
password: null |
|
}); |
|
} else if (commandContext == "LINESTRING") { |
|
$.ajax({ url: "assets/dataservice/create_linestring.php", |
|
method: "GET", |
|
dataType: "json", |
|
data: $('#dynamicform').serialize(), |
|
success: function (data) { |
|
if (data.response=="200") { |
|
$("#modalform").modal('hide'); |
|
} else { |
|
$("#modalform").modal('hide'); |
|
console.log('Failed to save.'); |
|
} |
|
}, |
|
username: null, |
|
password: null |
|
}); |
|
} else if (commandContext == "POLYGON") { |
|
$.ajax({ url: "assets/dataservice/create_polygon.php", |
|
method: "GET", |
|
dataType: "json", |
|
data: $('#dynamicform').serialize(), |
|
success: function (data) { |
|
if (data.response=="200") { |
|
$("#modalform").modal('hide'); |
|
} else { |
|
$("#modalform").modal('hide'); |
|
console.log('Failed to save.'); |
|
} |
|
}, |
|
username: null, |
|
password: null |
|
}); |
|
} else { |
|
console.log('__undefined__'); |
|
} |
|
return false; |
|
}); |
|
}
|
|
|