css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              table.tablesorter
  font-family: arial
  background-color: #CDCDCD
  margin: 10px 0pt 15px
  font-size: 8pt
  width: 100%
  text-align: left
  thead tr th, tfoot tr th
    background-color: #e6EEEE
    border: 1px solid #FFF
    font-size: 8pt
    padding: 4px
  tbody
    td
      color: #3D3D3D
      padding: 4px
      background-color: #FFF
      vertical-align: top
    tr.odd td
      background-color: #F0F0F6

img
  width: 32px
  height: 32px

a
  text-decoration: palegreen
  color: navy

.down
  background-image: url('https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.30.4/css/images/black-desc.gif')
  background-repeat: no-repeat
  text-align: left
  
.unset
  background-image:  none
  
a:hover
  border-color: greenyellow
  cursor: pointer

.shadowbox
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.6), -3px 4px 12px rgba(0, 0, 0, 0.5), -4px 6px 15px rgba(0, 0, 0, 0.4), -5px 8px 18px rgba(0, 0, 0, 0.3)
  margin: 20px
  padding: 10px

.boxshadowinset
  box-shadow: inset -1px -3px 20px 5px rgba(0, 0, 0, 0.75)

h3
  text-shadow: 1px 1px 5px 5px white
  padding: 8px
  font-family: 'Courier New', Courier, monospace
  width: 100%
  height: 50px
  border: 1px solid black
  background-color: darkslateblue
  text-align: center
            
          
!
            
              

class App extends  React.Component {


       state = { data: [],data30: [],dataall: [],
               baseurl : "https://www.freecodecamp.org/" 
             
    }
      
      loadData() {
        fetch('https://fcctop100.herokuapp.com/api/fccusers/top/alltime?Origin=*')
          .then(response => response.json())
          .then(data => {
            this.setState({data: data });
            this.setState({dataall: data });
        })
          .catch(err => console.error(this.props.url, err.toString()));
          fetch('https://fcctop100.herokuapp.com/api/fccusers/top/recent?Origin=*')
          .then(response => response.json())
          .then(data => {
            this.setState({data30: data });
                 })
          .catch(err => console.error(this.props.url, err.toString()));
      }

      componentDidMount() {
        this.loadData();  
        this.setState({styleClassall: 'down'});   
      } 
   
 pick_data(g){
  
   let id = g;
  
let data = this.state.data.slice();
if(id==='30' ){
    this.setState({styleClass30: 'down'})
    this.setState({styleClassall: 'unset'})
  data = this.state.data30;
this.setState({data});
}else if (id==='all'){
   this.setState({styleClassall: 'down'})
   this.setState({styleClass30: 'unset'})
  data = this.state.dataall;
  this.setState({data});

}

}
     
  render() {
  let {data, baseurl}= this.state;
  
    return (
     

      <div className="App">
        <header className="App-header">    
                  
        </header>
     
        <div className=" shadowbox"    >
      <h3 className=" tablecolor boxshadowinset"  >Leaderboard</h3> 
        <table className=" tablesorter"  id="myTable" >
            <thead >
              <tr>
                <th>#</th>
                <th >Campername</th>
                <th  className={this.state.styleClass30} onClick= {(event)=> this.pick_data(event.target.id)}><a id='30' href ='#'>Points in past 30 days</a></th>
                <th  className={this.state.styleClassall} onClick= {(event)=> this.pick_data(event.target.id)} ><a id='all' href ='#'>All time points</a> </th>   
                </tr>
   </thead>
            <tbody> 
           {data.map(function(object, i){   
            let element = data[i];
            let username =element.username;          
                 let x=0;
          x=Number(i)+1;  
         var cnames  = 'even' ;
          if(x%2===0)
          { cnames = 'odd' }    
          var userurl = {baseurl}+  {username};
  return<tr key={i} className={cnames}>
 <td ><p> {x} </p> </td>
    <td><img src={element.img}  alt="" ></img> 
    <a href={userurl} target="_blank">{element.username}  </a></td>
     <td> { element.recent}</td>
   <td> {element.alltime }</td>
  </tr>

          })
          }                     
            </tbody> 
  </table>
          </div>
      </div>
    );
  }
}
ReactDOM.render(
	<App />,
  document.getElementById('root')
);

            
          
!
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.
Loading ..................

Console