Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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 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

              
                <script src="https://sdk.amazonaws.com/js/aws-sdk-2.142.0.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link href="https://s3.amazonaws.com/mturk-public/bs30/css/bootstrap.min.css" rel="stylesheet" />
<section class="container" id="Other" style="margin-bottom:15px; padding: 10px 10px; font-family: Verdana, Geneva, sans-serif; color:#333333; font-size:0.9em;">
<div class="row col-xs-12 col-md-12">
<!-- Instructions -->
<fieldset>
  <label>Read Instruction.</label>
  <div class="panel panel-primary">
    <div class="panel-heading"><strong>Instruction</strong></div>
    <div class="panel-body">
      <b><p>Upload 10 cat pictures. </p></b>
      <ul>
        <!-- We are adding a template variable below which we will replace with an actual link in our code later -->
        <li>Upload .jpg files.</li>
        <li>You cannot submit less than 10 images.</li>
      </ul>
      <br>
    </div>
  </div>
  <!-- End Instructions -->

  <!-- Content Body -->
  <section>
    <div class="checkbox"><label><input name="Check" type="checkbox" value="check_ok" />Have you checked?</label></div>
</fieldset>

<!-- This is new the HTML code to include a file upload -->
<fieldset>
  <label>Upload 10 cat pictures.</label>
  <input type="file" id="uploadFiles" multiple />
  <output id="list"></output>
  <button id="upload_file_button" type="button">Upload file</button>
  <span id="status">&nbsp;</span>
  <span id="fin">&nbsp;</span>
</fieldset>

<style type="text/css">
  fieldset {
    padding: 10px;
    background: #fbfbfb;
    border-radius: 5px;
    margin-bottom: 5px;
  }
</style>
<script>
  var ok_file_cnt = 0;
  let config = {
    region: "リージョン",
    pool: "プール名",
    bucket: "バケット名"
  };
  AWS.config.region = config.region;
  // Configure the credentials provider to use your identity pool
  AWS.config.credentials = new AWS.CognitoIdentityCredentials({
    IdentityPoolId: config.pool
  });

  let s3 = new AWS.S3({
    apiVersion: "2006-03-01",
    params: { Bucket: config.bucket }
  });

  function upload_file(file, hitId, assignmentId, workerId, i) {
    let fileKey = hitId + "-" + assignmentId + "-" + workerId + "-" + file.name;
    let failed_flag = false;

    s3.upload(
      {
        Key: fileKey,
        Body: file,
        ContentType: file.type,
        ACL: "bucket-owner-full-control"
      },
      function(err, data) {
        if (err) {
          alert(
            file.name + ": Failed to upload. Please check your file."
          );
          $("#status").text("");
          failed_flag = true;
          return failed_flag;
        } else {
          ok_file_cnt++;
          $("#status").text(file.name + ": Success.");
          $("#fin").text(ok_file_cnt + " photos are uploaded.");
          return failed_flag;
        }
        $(event.currentTarget).prop("disabled", false);
      }
    );
  }

  do_upload = function(event) {
    // Reset the status indicator and hidden file uploaded flag
    $("#status").text("Uploading...");
    $(event.currentTarget).prop("disabled", false);
    let workerId = turkGetParam("workerId");
    let assignmentId = turkGetParam("assignmentId");
    let hitId = turkGetParam("hitId");
    var $files = $("#uploadFiles").prop("files");
    var len = $files.length;
    var good_file = 0;
    if (len === 10){
        for (var j = 0; j < len; j++) {
            var file = $files[j];
            if (file.name.match(/.jpg/)){
                good_file++;
            }else if(file.name.match(/.JPG/)){
                good_file++;
            }
        }
        if (good_file === 10){
            for (var i = 0; i < len; i++) {
                var file = $files[i];
                $("#status").text(file.name + " is uploading...");
                failed_flag = upload_file(file, hitId, assignmentId, workerId, i);
                if (failed_flag){
                    $("#status").text(file.name + ": Failed to upload. Please check your file.");
                    break;
                }
            }
        }else{
            var miss = 10 - good_file;
            $("#fin").text(miss + " photos are missing. Please check your files.");
        }
        if (i === 10 && good_file === 10){
            $(event.currentTarget).prop("disabled", true);
        }
    }else{
      miss = 10 - len;
      $("#status").text(miss + " photos are missing. Please check your files.");
    }
  };
  
  $("#upload_file_button").on("click", do_upload);
</script>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console