examples/browser/resources/browser-demo.js
function(err, imageIdentifier, res) {
        // Remove progress bar
        bar.css('width', '100%');
        progress.animate({ opacity: 0}, {
            duration: 1000,
            complete: function() {
                $(this).remove();
            }
        });

        // Check for any XHR errors (200 means image already exists)
        if (err && res && res.headers && res.headers['X-Imbo-Error-Internalcode'] !== 200) {
            if (err === 'Signature mismatch') {
                err += ' (probably incorrect private key)';
            }

            /* eslint no-alert: 0 */
            return window.alert(err);
        } else if (err) {
            return window.alert(err);
        }

        // Build an Imbo-url
        var result = $('#result').removeClass('hidden');
        var url = client.getImageUrl(imageIdentifier);
        $('#image-identifier').text(imageIdentifier).attr('href', url.toString());
        result.find('img').attr('src', url.maxSize({ width: result.width() }).toString());
        updateUrl(url);

        if (!active) {
            $('#controls [data-transformation="border"]').on('click', function() {
                url.border({ color: 'bf1942', width: 5, height: 5 });
            });

            $('#controls button').on('click', function() {
                var btn = $(this),
                    transformation = btn.data('transformation'),
                    args = btn.data('args'),
                    pass = args ? (args + '').split(',') : [];

                url[transformation].apply(url, pass);

                if (transformation === 'reset') {
                    url.maxSize({ width: result.width() });
                }

                updateUrl(url);

                result.find('img').attr('src', url.toString());
            });
        }
    }
function(err, imageIdentifier, res) {
        // Remove progress bar
        bar.css('width', '100%');
        progress.animate({ opacity: 0}, {
            duration: 1000,
            complete: function() {
                $(this).remove();
            }
        });

        // Check for any XHR errors (200 means image already exists)
        if (err && res && res.headers && res.headers['X-Imbo-Error-Internalcode'] !== 200) {
            if (err === 'Signature mismatch') {
                err += ' (probably incorrect private key)';
            }

            /* eslint no-alert: 0 */
            return window.alert(err);
        } else if (err) {
            return window.alert(err);
        }

        // Build an Imbo-url
        var result = $('#result').removeClass('hidden');
        var url = client.getImageUrl(imageIdentifier);
        $('#image-identifier').text(imageIdentifier).attr('href', url.toString());
        result.find('img').attr('src', url.maxSize({ width: result.width() }).toString());
        updateUrl(url);

        if (!active) {
            $('#controls [data-transformation="border"]').on('click', function() {
                url.border({ color: 'bf1942', width: 5, height: 5 });
            });

            $('#controls button').on('click', function() {
                var btn = $(this),
                    transformation = btn.data('transformation'),
                    args = btn.data('args'),
                    pass = args ? (args + '').split(',') : [];

                url[transformation].apply(url, pass);

                if (transformation === 'reset') {
                    url.maxSize({ width: result.width() });
                }

                updateUrl(url);

                result.find('img').attr('src', url.toString());
            });
        }
    }
function ( err , imageIdentifier , res ) { // Remove progress bar bar . css ( 'width' , '100%' ) ; progress . animate ( { opacity : 0 } , { duration : 1000 , complete : function ( ) { $ ( this ) . remove ( ) ; } } ) ; // Check for any XHR errors (200 means image already exists) if ( err && res && res . headers && res . headers [ 'X-Imbo-Error-Internalcode' ] !== 200 ) { if ( err === 'Signature mismatch' ) { err += ' (probably incorrect private key)' ; } /* eslint no-alert: 0 */ return window . alert ( err ) ; } else if ( err ) { return window . alert ( err ) ; } // Build an Imbo-url var result = $ ( '#result' ) . removeClass ( 'hidden' ) ; var url = client . getImageUrl ( imageIdentifier ) ; $ ( '#image-identifier' ) . text ( imageIdentifier ) . attr ( 'href' , url . toString ( ) ) ; result . find ( 'img' ) . attr ( 'src' , url . maxSize ( { width : result . width ( ) } ) . toString ( ) ) ; updateUrl ( url ) ; if ( ! active ) { $ ( '#controls [data-transformation="border"]' ) . on ( 'click' , function ( ) { url . border ( { color : 'bf1942' , width : 5 , height : 5 } ) ; } ) ; $ ( '#controls button' ) . on ( 'click' , function ( ) { var btn = $ ( this ) , transformation = btn . data ( 'transformation' ) , args = btn . data ( 'args' ) , pass = args ? ( args + '' ) . split ( ',' ) : [ ] ; url [ transformation ] . apply ( url , pass ) ; if ( transformation === 'reset' ) { url . maxSize ( { width : result . width ( ) } ) ; } updateUrl ( url ) ; result . find ( 'img' ) . attr ( 'src' , url . toString ( ) ) ; } ) ; } }
Callback for when the image is uploaded
Callback for when the image is uploaded