Nikon Picture Controls showcasing

Starting from NikonPC preview (one by one), I made a little script to automate:

Target is a gallery with ALL the previews in order to choose the preferred/best one for the photo.

Two methods: one to update the preview, another one to force a file download.

The Script


function updatePreview(index)
{    
    
js('imgPreview').onReady('onLoad', function() {
    curve.init();
    curve.initPreviewImage();
    var elmFileList = js('selFileList').elm;
    if (!elmFileList) {
        console.log("elmFileList " + index);
        return false
    }
    elmFileList.selectedIndex = index;
    var src = this.elm.src;
    this.elm = new Image();
    js(this.elm).addEvent('load', function() {
        npc.load();        
        forceDownload(index);
    }, false);
    this.elm.src = src;
});
    
}

function forceDownload(index)
{   
    var link = document.createElement('a');
    link.href = $("#cLutImage")[0].toDataURL("image/png");      
    link.download = 'Download' + index + '.png';    
    document.body.appendChild(link);
    link.click();
}

function main(index)
{       
    updatePreview(index);
}

How to launch: