@ -1,27 +1,25 @@
function new _location _entry ( ) {
function new _location _entry ( ) {
$ ( '#location-name-input' ) . text ( '' ) ;
$ ( '#location-name-input' ) . show ( ) ;
$ ( '#mapfile-input' ) . show ( ) ;
init _Location _edit ( - 1 ) ;
overlay _in ( ) ;
}
function init _Location _edit ( locationID ) {
$ ( 'table#details tr#datasheet td input' ) . show ( ) ;
}
function init _Location _edit ( locationID , name , containerID ) {
var newButton = '<div class="round-button-left"><a href="#" onclick="saveLocation(' + locationID + ')"><i class="fa fa-check" aria-hidden="true"></i></a></div>' ;
var newButton = '<div class="round-button-left"><a href="#" onclick="saveLocation(' + locationID + ')"><i class="fa fa-check" aria-hidden="true"></i></a></div>' ;
$ ( '.round-button-left' ) . replaceWith ( newButton ) ;
$ ( '#save-button' ) . attr ( "onclick" , "saveLocation(" + locationID + ")" ) ;
$ ( '#location-name-input' ) . val ( name ) ;
if ( containerID > 0 ) {
$ ( "#container-input" ) . val ( containerID ) ;
}
overlay _in ( ) ;
}
}
function update _clickable _map ( ) {
function update _ map( ) {
var selected _map _file = $ ( '#mapfile-input' ) . val ( ) ;
var selected _map _file = $ ( '# container -input') . val ( ) ;
$ ( '#clickablemap' ) . attr ( 'src' , 'map/' + selected _map _file ) ;
$ ( '# map') . attr ( 'src' , 'map/' + selected _map _file ) ;
}
}
function saveLocation ( locationID ) {
function saveLocation ( locationID ) {
var map_v = $ ( '#clickablemap' ) . attr ( 'src' ) . substring ( 4 ) ;
var container_v = $ ( '#container-input' ) . val ( ) ;
var name _v = $ ( '#location-name-input' ) . val ( ) ;
var name _v = $ ( '#location-name-input' ) . val ( ) ;
if ( name _v . length > 100 ) {
if ( name _v . length > 100 ) {
@ -30,7 +28,7 @@ function saveLocation(locationID) {
}
}
var data = new FormData ( ) ;
var data = new FormData ( ) ;
data . append ( ' map', map _v ) ;
data . append ( ' container', container _v ) ;
data . append ( 'name' , name _v )
data . append ( 'name' , name _v )
$ . ajax ( {
$ . ajax ( {
@ -54,7 +52,41 @@ function saveLocation(locationID) {
} ) ;
} ) ;
}
}
function end _edit ( ) {
//intentionally left blank
}
function show _location _info ( locationID ) {
$ . getJSON ( rootURL + 'getpartinfo/' + partID , function ( data ) {
$ ( 'table#details tr#location td p' ) . text ( text _filter ( data . location _descriptor ) ) ; // name is the location friendly name
$ ( '#location-dropdown' ) . val ( data . location _id ) ;
$ ( '#container-dropdown' ) . val ( data . container _id ) ;
$ ( 'table#details tr#partno td p' ) . text ( text _filter ( data . partno ) ) ;
$ ( 'table#details tr#partno td input' ) . val ( text _filter ( data . partno ) ) ;
$ ( 'table#details tr#description td p' ) . text ( text _filter ( data . description ) ) ;
$ ( 'table#details tr#description td input' ) . val ( text _filter ( data . description ) ) ;
container _onchange ( ) ;
if ( data . datasheet != null ) {
$ ( 'tr#datasheet-head' ) . html ( $ ( '<td>DATASHEET: <a href="parts/getfile/' + data . datasheet + '"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>' ) ) ;
$ ( '#datasheet-input' ) . val ( data . datasheet ) ;
}
else
$ ( 'tr#datasheet-head td' ) . text ( 'DATASHEET: ' ) ;
$ ( '#edit-button' ) . click ( function ( ) {
init _edit ( partID ) ;
} ) ;
$ ( '#delete-button' ) . click ( function ( ) {
delete _entry ( partID ) ;
} ) ;
overlay _in ( ) ;
} ) . fail ( function ( ) {
console . log ( "Fetching part info failed" ) ;
} ) ;
}
function placeMarker ( locationID ) {
function placeMarker ( locationID ) {
//temporarily not used
var $img = $ ( '#clickablemap' ) ;
var $img = $ ( '#clickablemap' ) ;
var currentClickPosX = event . pageX - $img . offset ( ) . left ;
var currentClickPosX = event . pageX - $img . offset ( ) . left ;
var currentClickPosY = event . pageY - $img . offset ( ) . top ;
var currentClickPosY = event . pageY - $img . offset ( ) . top ;