// work out new width for canvas. depending on whether width > height of the
// image, then use the width of the image (with the specified gap) otherwise
// the height > width, so scale the new width based on height ratio of
// image to window
function NewWidth()
{
w_r=im.width/(window.innerWidth*gap)
h_r=im.height/(window.innerHeight*gap)
if( w_r > h_r )
return window.innerWidth*gap
else
return im.width*gap / (im.height/window.innerHeight)
}
// work out new height for canvas. depending on whether height > width of the
// image, then use the height of the image (with the specified gap) otherwise
// the width > height, so scale the new height based on width ratio of
// image to window
function NewHeight()
{
w_r=im.width/(window.innerWidth*gap)
h_r=im.height/(window.innerHeight*gap)
if( h_r > w_r )
return window.innerHeight*gap
else
return im.height*gap / (im.width/window.innerWidth)
}
function DrawLabelOnFace(str)
{
// finish face box, need to clear out new settings for // transparent backed-name tag
context.stroke();
context.beginPath()
context.lineWidth = 0.1
context.font = "30px Arial"
context.globalAlpha = 0.6
bbox = context.measureText(str);
f_h=bbox.fontBoundingBoxAscent
if( bbox.fontBoundingBoxDescent )
f_h += bbox.fontBoundingBoxDescent
f_h -= 8
context.rect( x+w/2-bbox.width/2, y-f_h, bbox.width, f_h )
context.fillStyle="white"
context.fill()
context.stroke();
context.beginPath()
context.globalAlpha = 1.0
context.font = "30px Arial"
context.textAlign = "center"
context.fillStyle = context.strokeStyle
context.fillText(str, x+w/2, y-2)
}
// This draws the image, it can be called on resize events, img.src finishing
// loading or explicitly on page load. Will also deal with all state/toggles
// for items like name, grayscale, etc.
function DrawImg()
{
// another call to this func will occur on load, so skip this one
if( im.width == 0 )
return
canvas.width=NewWidth(im)
canvas.height=NewHeight(im)
// actually draw the pixel images to the canvas at the right size
if( grayscale )
context.filter='grayscale(1)'
context.drawImage(im, 0, 0, canvas.width, canvas.height )
// -50 is a straight up hack, no idea why this works, but its good enough for me
if( throbber )
$('#throbber').attr('style', 'display:show; position:absolute; left:'+canvas.width/2+'px; top:'+(canvas.height/2-50)+'px' )
else
$('#throbber').hide();
// show (or not) the whole figcaption with fname in it - based on state of fname_toggle
if( $('#fname_toggle').prop('checked' ) )
{
// reset fname for new image (if navigated left/right to get here)
$('#fname').html(PrettyFname(objs[current].url))
$('.figcaption').show()
}
else
$('.figcaption').hide()
// if we have faces, the enable the toggles, otherwise disable them
// and reset model select too
if( objs[current].faces )
{
$('#faces').attr('disabled', false)
$('#distance').attr('disabled', false)
$('#model').val( Number(objs[current].face_model) )
}
else
{
$('#faces').attr('disabled', true)
$('#distance').attr('disabled', true)
// if no faces, then model is N/A (always 1st element - or 0 in select)
$('#model').val(0)
}
// okay, we want faces drawn so lets do it
if( $('#faces').prop('checked') && objs[current].faces )
{
// draw rect on each face
for( i=0; i '
div+='Face position #' + face_pos
div+='
'
for( var key in data ) {
var person = data[key];
/*
content+= ''+person.firstname+' '+person.surname+' ('+person.tag+')
'
*/
content+= ''+person.firstname+' '+person.surname+' ('+person.tag+')
'
}
$('#search_person_results').html( content )
}
} )
return false
}
function RemoveOverride()
{
d='&face_id='+objs[current].faces[face_pos].id+'&person_tag='+objs[current].faces[face_pos].who+
'&file_eid='+current
$.ajax({ type: 'POST', data: d, url: '/remove_override',
success: function(data) {
if( objs[current].faces[face_pos].old_who )
objs[current].faces[face_pos].who=objs[current].faces[face_pos].old_who
else
delete objs[current].faces[face_pos].who
delete objs[current].faces[face_pos].override
$('#dbox').modal('hide')
DrawImg()
return false
}
} )
return false
}
// function that is called when we click on a face in the viewer and we want to
// potentially override the non-match / match... it shows the face, and then
// based on which menu item got us here, shows appropriate text to do next action
function FaceDBox(key, item)
{
face_pos=item[key]['which_face']
div ='' )
}
} )
div+='
| Log | When | Job | ' + data[i].log + ' | ' + data[i].log_date + ' | ' div+='' + data[i].name + ' #:'+data[i].id+' | ' } div+='
|---|