Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h2>4DMapper API Example Code</h2>
  <p>This example will create a project then upload selected files to that project in your 4dmapper account. If project name already exists it will be used for uploading the files.</p>
  
<p> Open your 4dmapper project in a new tab and see the files being uploaded in real-time!</p>

  <label>Project name to create:</label>
  <input type="text" id="projectName" value="MyNewProject">
 <p><label>Select image files to upload: </label>
  <input type="file" id="imageUploads" accept=".jpg, .jpeg, .png" multiple>
  <p> <button class="uploadButton">Start Uploading</button>
  <div class="status">
    </div></p>

  
              
            
!

CSS

              
                
              
            
!

JS

              
                const myClientID = ""; //paste your account clienID here
const myClientSecret = ""; //paste your account client secret here
//you can get your 4DMapper account clientID and clientSecret from https://app.4dmapper.com/app/admin/apis 
import {createProject,upload} from 'https://4dmapper.com/API/4dm.js';

const status = document.querySelector('.status');
document.querySelector(".uploadButton").addEventListener("click", uploadData);

function uploadData(){
   if (myClientID == 0) {
       status.textContent="Invalid API Credentials, visit https://app.4dmapper.com/app/admin/apis to get your API credentials";
        return;
    };
  var projectName = document.getElementById("projectName").value;
  createProject(projectName,myClientID,myClientSecret);
  const input = document.querySelector("input[type=file]");
  const curFiles = input.files;
  if (curFiles.length === 0) {
    status.textContent = 'No files currently selected for upload';
    } else {
          for (const file of curFiles) {
            upload (file, file.name,file.size,projectName,myClientID,myClientSecret)
            .then(res => { 
              console.log(res);
              status.textContent = res.payload.name +" uploaded.";
                          });
      }}}



              
            
!
999px

Console