more comments for js files

This commit is contained in:
2021-09-07 21:50:01 +10:00
parent 1b11fba0a8
commit e25cb9fd02
2 changed files with 168 additions and 150 deletions

View File

@@ -1,3 +1,7 @@
// 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)
@@ -8,6 +12,10 @@
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)
@@ -18,7 +26,9 @@
return im.height*gap / (im.width/window.innerWidth)
}
// Define this once and before it will be called, hence at the top of this file
// 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
@@ -38,7 +48,6 @@
else
$('#throbber').hide();
// show (or not) the whole figcaption with fname in it - based on state of fname_toggle
if( $('#fname_toggle').prop('checked' ) )
{
@@ -123,17 +132,23 @@
}
}
// resize a video based when event calls this -- TODO: is this right for ratios
// where vid is different w/h ratio?
function ResizeVideo()
{
$('#video').height(window.innerHeight*gap)
}
// change faces being shown or not (if not showing faces, then cant set distance on anyway)
// and a face or not, needs to redraw the image to add/remove green box, etc.
function FaceToggle()
{
$('#distance').prop('disabled', function(i, v) { return !v; });
DrawImg()
}
// func to set show/hide the image or video div, and set the URL appropriately
// also deals with fullsecreen if needed
function ViewImageOrVideo()
{
if( objs[current].type == 'Image' )
@@ -142,11 +157,8 @@
$('#video').hide()
$('#figure').show()
if( fullscreen )
{
console.log('going fs on image')
$('#canvas').get(0).requestFullscreen()
}
}
if( objs[current].type == 'Video' )
{
$('#video').prop('src', 'http://mara.ddp.net:5000/' + objs[current].url )
@@ -154,9 +166,6 @@
$('#video').show()
ResizeVideo()
if( fullscreen )
{
console.log('going fs on video')
$('#video').get(0).requestFullscreen()
}
}
}

View File

@@ -1,3 +1,7 @@
// POST to a check URL, that will tell us if the transformation has completed,
// if not, try again in 1 second... If it has finished then reset the thumbnail
// to full colour, put it back to being an entry and reset the thumbnail to the
// newly created one that was sent back in the response to the POST
function CheckTransformJob(id,job_id)
{
$.ajax(
@@ -19,6 +23,11 @@ function CheckTransformJob(id,job_id)
} )
}
// for each highlighted image, POST the transform with amt (90, 180, 270,
// fliph, flipv) which will let the job manager know what to do to this file.
// we also grayscale the thumbnail out, remove the entry class for now, show
// the spinning wheel, and finally kick of the checking for the transform job
// to finish
function Transform(amt)
{
id=$('#current').val()