123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <script src='//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
  <script src='//bonanzapublic.s3.amazonaws.com/assets/burn_bundle.js?20150605'></script>

  <!-- Instantiate burn widget -->
  <script type='text/javascript'>
    var burnWidget = new BONZ.BurnWidget({
      apiKey: 'wvr2tks22d4zkmk',
      userId: 'eric-demo', // A unique id that identifies this user within *your* application
      onIndex: function(jsonResponse) {
        // Callback to be triggered when requesting all burns for this user
        console.log(jsonResponse);
      },
      onShow: function(imageSelector, jsonResponse) {
        // Callback to be triggered after the show/edit burn is popped up
        console.log(imageSelector);
        console.log(jsonResponse);
      },
      onCreate: function(imageSelector, jsonResponse) {
        // Callback to be triggered after a burn is queued/created.
        // We recommend adding your own functionality to save the id and user_id the returned in jsonResponse
        console.log(imageSelector);
        console.log(jsonResponse);
      },
      onSave: function(imageSelector, jsonResponse) {
        // Callback to be triggered after the user selects a final mask
        // We recommend adding your own functionality to save the final_result_url the returned in jsonResponse
        console.log(jsonResponse);
        $(imageSelector).attr('src', jsonResponse.final_result_url);
      },
      onError: function(message) {
        // Callback to be triggered if the API action raises an exception
        console.log(message);
      }
    });
    
    function burn(form) {
      burnWidget.launch({ url: $('input[type=text]', $(form)).val() });
      $('input[type=text]', $(form)).val('');
    }

    function burnImage() {
      // Queues a new burn from the src of the image element
      burnWidget.launch({ image: $('#image1') });
    }
    
    function burnURL(el) {
      // Queues a new burn from a URL
      burnWidget.launch({ url: $(el).attr('href') });
    }
    
    function showBurnByID(id) {
      // Shows the progress of the background burn with the specified id.
      burnWidget.launch({ id: id });
    }
    
    function showBurnByImage() {
      // Gets the id of the background burn from the data-id attribute,
      // and shows the progress of the burn.
      burnWidget.launch({ image: $('#image2') });
    }

    function viewBurns() {
      // Gets all in progress/complete burns for the user identified
      // by the userId parameter when instantiating a new BONZ.BurnWidget.
      burnWidget.launch();
    }
  </script>
</head>
<body>
  <h2>Burn any image accessible via a web browser</h2>
  <p>Enter a URL to an image in the box below.</p>
  <form action='#' method='post' onsubmit='burn(this); return false;'>
    <input type='text' name='remoteUrl' style='width: 400px;' />
    <input type='submit' />
  </form>
  
  <h2>Queue a burn using the <tt>src</tt> attribute of an <tt>img</tt> element.</h2>
  <img id='image1' src='https://bonanzaimagestest.s3.amazonaws.com/uploads/burnees/1432752586-1964-6184.jpg' style='width: 25%' />
  <p><a href='#' onclick='burnImage(); return false;'>Burn image</a></p>
  
  <h2>Queue a burn from a remote URL</h2>
  <p><a href='https://bonanzaimagestest.s3.amazonaws.com/uploads/burnees/1432752586-1964-6184.jpg' onclick='burnURL(this); return false;'>Burn URL</a></p>
  
  <h2>View the progress/edit a previously queued image</h2>
  <p>This example shows the progress of the Background Burn with the ID of 10297598</p>
  <p><a href='#' onclick='showBurnByID(10297598); return false;'>Show burn by ID</a></p>
  
  <p>This example shows the progress of the Background Burn with the ID of 6653207</p>
  <img id='image2' src='http://www.bonanza.com/background_masks/15807159.png?1397051807&composite=1' data-id='6653207' />
  <p><a href='#' onclick='showBurnByImage(); return false;'>Show burn by image</a></p>
  
  <h2>View all burns for a specific user</h2>
  <p><a href='#' onclick='viewBurns(); return false;'>View all burns</a>.</p>
</body>
</html>

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console