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

              
                <!-- Table freeze http://jsfiddle.net/C8Dtf/81/ -->

<!-- Directions for setting up your own pool: https://codepen.io/terned/post/oscar-pool-2018

2022 form: https://docs.google.com/forms/d/1BknoIPINxY8O2D2oPJT7QiqaZHffLAEDSuCfNOEbQXg/copy

I wrote a blog post about automating the form creation this year!
https://dev.to/idiophonebox/format-copy-and-paste-from-a-webpage-in-the-console-59jn

Data workbook for 2022:
https://docs.google.com/spreadsheets/d/1bR4ncBn5AJzuKoiueort4nUhHqaPeGzq6Iobwe30bE0/edit?usp=sharing
-->

<body data-gsheet="https://docs.google.com/spreadsheets/d/1bR4ncBn5AJzuKoiueort4nUhHqaPeGzq6Iobwe30bE0/edit?usp=sharing" data-sheet="pool">
  <div id="leader"><span class="peeps">Leading: </peeps> </div>
  <div id="vertical_scrolling_div">
  <div id="freeze_container">
        <table id="left_table" class="freeze_table">       
            <th> Prognosticator </th>
        </table>
    </div>
  </div>
  <div id="horizontal_scrolling_div">
  <table id="categories">
  </table>
  </div>
</body>
              
            
!

CSS

              
                html{
  font-family:arial;
  font-weight:300;
  color: #515151;
  font-size:13px;
}

body{
  padding:20px 5px;
}

#leader{
  margin: 0 0 40px 0;
}

.correct{
  background-color: #edd271;
  color:#917308;
}

.incorrect{
  background-color: #f2f2f2;
  color:#9e9e9e;
}

.count{
  position:relative;
  display:block;
  min-height:80px;
  width:30px;
  clear:both;
  margin:0 auto 5px auto;
  background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/152171/oscar-icon.png');
  background-size:contain;
  background-repeat:no-repeat;
  .num{
    color:#fff;
    font-size:15px;
    padding-top:200%;
    width:30px;
    text-align:center;
    display:block;
  }
}

.freeze_table{
  &:first-child{
      text-align:center;
    }
}

#vertical_scrolling_div{
    display:inline-block;
    zoom: 1;
    display:inline;
    width:130px;
    // height:300px;
    overflow-y: auto;
    overflow-x: hidden;
}

#freeze_container{
    display:inline-block;
    zoom: 1;
    // display:inline;
    vertical-align:top;
    width:130px;
}
#horizontal_scrolling_div{
    display:inline-block;
    zoom: 1;
    // display:inline;
    width: 500px;
    overflow-x:scroll;
    vertical-align:top;
}

#categories{
  td{
    padding: 5px 10px;
  }
}

.freeze_table{   
    z-index:2;
  td{
    min-width:120px;
  }
}


table{
  width:auto;
  padding:0 20px;
  margin: 0 0 100px 0;
  border-collapse: collapse; 
  th{
    padding: 10px 0;
  }
  tr{
    border-bottom: 1px solid #ccc;
  }
  td{
    position:relative;
    height:105px;
    min-width:180px;
    padding:5px;
    background-color: #fff;
  }
  
  tr:hover td{
    // color: #e05b18;
  }
  &#categories td:hover{
    cursor:pointer;
    &:before{
      display: block;
      position:absolute;
      content: attr(data-cat);
      font-size:.85em;
      top:0;
      left:0;
      width:100%;
      color:#fff;
      background-color:#444242;
      padding:2px;
    }
    &:after{
      display: block;
      position:absolute;
      content: attr(data-winner);
      font-size:.75em;
      bottom:0;
      left:0;
      width:96%;
      color:#fff;
      background-color:#444242;
      padding:2px 5px;
      text-align:right;
    }
  }

}

#winners{
  display:none;
}


              
            
!

JS

              
                $(document).ready(function() {
  
  //  update this to reflect the number of categories 
  var categoryNumber = 23;
  
  function size(){
    var w = window.innerWidth;
    var hw = w-200;
    function updateheight() {
       var h = $("#horizontal_scrolling_div").height();
       $("#vertical_scrolling_div").css('height',h);
    }
    function updatewidth() {
      $("#horizontal_scrolling_div").css('width',hw);
      updateheight();  
    }
    updatewidth();
  }
  
  var resizeTimer;

  $(window).on('resize', function(e) {
    
    $("#horizontal_scrolling_div").hide();
    clearTimeout(resizeTimer);
    resizeTimer = setTimeout(function() {
      size();
      $("#horizontal_scrolling_div").show();   
    }, 250);
    
    // updatewidth();
    // updateheight();

  });
  
  
  var gsheet = $('body').data("gsheet");
  var tab = $('body').data("sheet");
  var gshort =gsheet.substring(gsheet.lastIndexOf("/d/")+3,gsheet.lastIndexOf("/"));
  var jsondata = 'https://script.google.com/macros/s/AKfycbzGvKKUIaqsMuCj7-A2YRhR-f7GZjl4kSxSN1YyLkS01_CfiyE/exec?id='+gshort+'&sheet='+tab;
            
  $.getJSON(jsondata, function(data) {
    var entry = data.records;
    entry.sort((a, b) => (a.Your_Name > b.Your_Name) ? 1 : -1)
    var entries = entry.length;
    
    var header = entry[0];
    var categoryList = Object.entries(header).slice(3,categoryNumber+3).map(entry => entry[0]);
    var categories = [];
    $(categoryList).each(function(i){
        categories.push('<th>'+categoryList[i]+'</th>');
      });
    var categoryHeader = categories.join().replace(/\_+/g, ' ');
    $("#categories").append(categoryHeader);
    
    var people = '';
    var submissionList = '';
    
    // Compile entries
    $(entry).each(function(i){
      var choices = Object.entries(entry[i]).slice(3,categoryNumber+3).map(entry => entry[1]);
      
      var subid = entry[i].Your_Name;
      subid = subid.replace(/\s+/g, '');
      
      var person = ('<td>'+this.Your_Name+'</td>')
      var categories = [];
      $(choices).each(function(i){
        categories.push('<td>'+choices[i]+'</td>');
      });
      
      var submission = categories.join();
      
      var newperson = '<tr id="'+subid+'" class="submission" data-name="'+this.Your_Name+'">'+person+'</tr>';
      
      var newlist = '<tr id="'+subid+'" class="submission" data-name="'+this.Your_Name+'">'+submission+'</tr>';
      
      people += newperson;
      submissionList += newlist;
    });
    
    // Add all entries to table
    $("#left_table").append(people);
    $("#categories").append(submissionList);
    
    $("#categories td").each(function(){

      var submitted = $(this).text();
      var check = $(this).index();
      var winner = $('#categories #winners td:eq('+check+')').text();
      
         if (winner !== ""){
            if (submitted == winner){
              $(this).addClass("correct");
            }else{
              $(this).addClass("incorrect");
            }
         }
      

        var category = $('#categories th:eq('+check+')').text(); 
        $(this).attr("data-cat", (category));

        if ($('#categories #winners td:eq('+check+')').text() !=="") {
          var winner = $('#categories #winners td:eq('+check+')').text();
          $(this).attr("data-winner", winner);
        }
   

    });
    
    //  count correct
    $(".freeze_table tr").each(function(){
      var id = $(this).attr("ID");
      var count = $('#categories #'+id).find(".correct").length;
      countBlock = '<span class="count"><span class="num">'+count+'</span></span>';
      $('#'+id).find('td:eq(0)').prepend(countBlock);
      
      $('#'+id).attr("data-num", count);
    });
    
    var highestNum = -1;
    var windex = $('#winners').index();

    $("tr").each(function(){
      var check = $(this).index();
      
     if (check == 0 || check == windex){   
     }else{
        var num = +this.getAttribute("data-num") ;
        if (num > highestNum) 
            highestNum = num;
     }
    }).each(function(){
      var check = $(this).index();
      
      var leader = $(this).data("name");
      var number = $(this).data("num");
      var group = '<span>'+leader+' ('+number+') </span>';
        if (highestNum === +this.getAttribute("data-num") && $(this).attr("ID") != 'winners' )
            $("#leader").append(group);
        });
    
        if ($("#winners .num").html() == categoryNumber){
           $("#leader .peeps").html("Winner: ");
         }
    
        if ($("#winners").data("num") == "0"){
           $("#leader").hide();
         }
      
    size();
    
 }); // end get

  
  
});
              
            
!
999px

Console