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

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

              
                <html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>
    <div class="navbar">
      <div class="navName">
        <h3>Innovative.co</h3>
        <span>Hello, <span loggedInUser>Name</span>!</span>
      </div>
    </div>
  
      <div class="headerText">
      <h1 projectName>Project Name</h1>
        <h2 projectQuote>Project Quote</h2>
        <br>
        <h3><u>Creator:</u></h3>
        <h2 projectCreator>Project Creator</h2>
        <br>
        <h5><i>Help this project reaches its goal by:</i></h5><h4 projectEndDate>End Date</h4>
      </div>
  
 <div class="projectInfo">
   <div class="videoArea">
     <div class="video-container">
       <iframe src="https://www.youtube.com/embed/Z2U9WhAAroY?rel=0@amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
     </div>
   </div>
   <div class="statsArea">
     <div class="backerStats">
       <div>
       <h1 numberOfBackers>Count</h1>
         <p>Total <span>Backers</span></p>
       </div>
       <div>
         <h1 fundsRaised>$$$$$</h1>
            <p>of <span>$15,000</span></p>
          </div>
          <div>
            <h1 countDown>Time</h1>
            <p>Remaining <span>Time</span></p>
          </div>
        </div>
      </div>
    </div>
    
    
  </body>
</html>
              
            
!

CSS

              
                body{
  font-family: "Courier New", Courier, monospace;
  margin: 0;
  background: #F6F6F6;
  background-image: url("https://s-media-cache-ak0.pinimg.com/736x/fa/9a/ba/fa9abaff0d85489d9e2b180560c45110.jpg");
   background-size: 150px 300px;
  background-repeat: repeat;
}
.navbar{
  height: 64px;
  width: 100%;
  background: #000000;
  /*box-shadow: 1px 6px 5px -2px rgba(0,0,0,0.1);*/
  border-bottom: 2px solid white;
  display: flex;
}
.navName{
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.navName > h3{
  padding-left: 2em;
  font-family: "Courier";
  color: #FF007F;
}
.navName > span{
  padding-right: 2em;
  margin-top: 1.2em;
  font-style: italic;
  color: #ffffff;
  font-weight: 600;
}
/* Project Header text */
.headerText{
  display: flex;
  flex-direction: column;
  text-align: center;
    background: #ffffff;
  border-bottom: 3px solid black;
  /* border-bottom: 1px solid #efefef;
  -webkit-box-shadow: 1px 6px 5px -2px rgba(0,0,0,0.1);
-moz-box-shadow: 1px 6px 5px -2px rgba(0,0,0,0.1);
box-shadow: 1px 6px 5px -2px rgba(0,0,0,0.1); */
  width: 100%;
  margin: 0 auto;
}

.headerText > h1, h2, h3, h4, h5{
  padding-bottom: 0px;
  margin-bottom: 0px;
}

.headerText > h1{
  font-size: 3em;
  color: #FF007F;
  border: 4px solid #FF007F;
  margin: auto;
  width: 270px;
  margin-top: 50px;
}

.headerText > h2{
  padding-top: 0px;
  margin-top: 15px;
  color: #413444;
}

.headerText > h3{
  padding-top: 0px;
  margin-top: 15px;
  color: #413444;
}

.headerText > h4, span{
  font-weight: 400;
  padding-top: 0px;
  margin-top: 0px;
  margin-bottom: 30px;
  color: #FF007F;
}

.projectInfo{
  display: flex;
  flex-direction: row;
  width: 80%;
  border: 3px solid black;
  background: #ffffff;
  margin: 0 auto;
  max-width: 1500px;
  margin-top: 50px;
  margin-bottom: 30px;
}

.videoArea{
  width: 65%;
}

/* Responsive Video Embed time */
.video-container{
  position: relative;
  padding-bottom: 56.25%; /* based on 16:9 ratio */
  padding-top: 30px;
  height: 0;
  overflow: hidden;
}

.video-container iframe,
.video-container object,
.video-container embed {
  position: absolute;
  /* top: 0;
  left: 0;
  width: 100%;
  height: 100%; */
  top: 30px;
  left: 30px;
  width: 90%;
  height: 90%;
}
/* End of Responsive Video */

              
            
!

JS

              
                ////////////////DATA//////////////////////
class Data {
  constructor() {
    this.backers={
      "uid1": {
        firstName: "Lily",
        lastName: "Le"
      },
      "uid2": {
        firstName: "Lenny",
        lastName: "Minion"
      },
      "uid3": {
        firstName: "Tim",
        lastName: "Bot"
      },
      "uid4": {
        firstName: "J",
        lastName: "Marlo"
      },
      "uid5": {
        firstName: "Bobby",
        lastName: "G"
      }
    }
    this.pledges={
      "uid1":{
        "Feb2":{
        "amount": 603
        },
        "Feb10":{ 
        "amount": 100
        }
      },
      "uid2":{
        "Feb1":{
        "amount": 10
        },
        "Feb12":{
          "amount": 28
        }
      },
      "uid3":{
        "Mar5":{
        "amount": 400
        },
        "Mar6":{ 
        "amount": 950
        }
      },
      "uid4":{
        "Feb15":{
        "amount": 50
        },
        "Jan30":{ 
        "amount": 10
        }
      },
      "uid5":{
        "Feb8":{
        "amount": 700
        },
        "Mar7":{ 
        "amount": 369
        }
      }
    }
    this.loggedInUser = {
      "id": "uid1",
      loggedIn: true
    }
    this.projectInfo = {
      projectName: "PLA-INK",
      projectQuote: "The world's first 3D ink made from  plastic.",
      projectCreator: "Smith LAB",
      projectStartDate: "29 Jan, 2017",
      projectEndDate: "1 Apr, 2017"
    }
  };///end of constructor
  
  
  /////////////////API////////////////////
  getAllBackers(){
    return this.backers;
  }
  getTotalNumberOfBackers(){
    return Object.keys( this.getAllBackers() ).length;
  }
  getLoggedInBacker(){
    return this.loggedInUser;
  }
  getLoggedInUserInfo(){
    let allBackers = this.getAllBackers();
    let currentBackerId = this.getLoggedInBacker().id;
    return(allBackers[currentBackerId]);
  }
  getProjectInfo(){
    return this.projectInfo;
  }
  ////////Pledge API
  getAllPledges(){
    return this.pledges;
  }
  getPledgesForBackerByUID(uid){
    return this.getAllPledges()[uid];
  }
  getTotalPledgedForBackerByUID(uid){
    let pledges = this.getPledgesForBackerByUID(uid);
    let pledgesTotal=0;
    Object.keys(pledges).forEach(key =>{
      pledgesTotal += pledges[key].amount;
    })
    return pledgesTotal;
  }
  getTotalFundsRaised(){
    let backers=this.getAllBackers();
    let totalBacked=Object.keys(backers).reduce((prev,curr) =>{
      prev += Number(this.getTotalPledgedForBackerByUID(curr));
      return Number (prev);
    },0)
    return totalBacked;
  }
///////////////////////////////////////////
}

const myAppData = new Data();

console.log(myAppData.getLoggedInUserInfo() );
console.log(myAppData.getProjectInfo() )



////////////////////HELPERS/////////////////////
class CurrencyConvert{
  static formatToCurrency(money){
    return '$'+money;
  }
}

////////////////////LOGIC/////////////////////

class Levels{
  static get starter (){
    return{
      "description": "Starter",
      "url": "https:///somestarterimg.jpg",
      "link": "http://linktostarterpage",
      "amt": 0
    }  
  }
  static get bronze (){
    return{
      "description": "Bronze",
      "url": "https:///somebronzerimg.jpg",
      "link": "http://linktobronzepage",
      "amt": 100
    }  
  }
  static get silver(){
    return{
      "description":"Silver",
      "url": "https:///somesilverimg.jpg",
      "link": "http://linktosilverpage",
      "amt": 500
    }
  }
  static get gold(){
    return{
      "description":"Gold",
      "url": "https:///someggoldimg.jpg",
      "link": "http://linktogoldpage",
      "amt": 1000
    }
  }
  static get diamond(){
    return{
      "description":"Diamond",
      "url": "https:///somediamondimg.jpg",
      "link": "http://linktodiamondpage",
      "amt": 5000
    }
  }
}

////Determine rewards for backers///
class BackerLevelLogic{
  constructor(data){
    this.data=data; //to remember the data class
  }
  determineLevelOfBackerByUID(uid){  
    let total=this.data.getTotalPledgedForBackerByUID(uid);
    //return total;
    
    ///higher value on top first///
    if(total >= Levels.diamond.amt){ ///check for diamond
      return Levels.diamond.description;
    }
    if(total >= Levels.gold.amt){ ///check for gold
      return Levels.gold.description;
    }
    if(total >= Levels.silver.amt){ ///check for silver
      return Levels.silver.description;
    }
    if(total >= Levels.bronze.amt){ ///check for bronze
      return Levels.bronze.description;
    }
    if(total >= Levels.starter.amt){ ///check for starter
      return Levels.starter.description;
    }
  }
}


/////////////////////VIEW///////////////////////
class Renderer{
  printLoggedInUser(loggedInUser){
    //console.log(loggedInUser);
    document.querySelector('span[loggedInUser]').innerHTML=loggedInUser.firstName;
  }
  printProjectInfo(projectInfo){
    console.log(projectInfo);
    document.querySelector('h1[projectName]').innerHTML=projectInfo.projectName;  document.querySelector('h2[projectQuote]').innerHTML=projectInfo.projectQuote;  document.querySelector('h2[projectCreator]').innerHTML=projectInfo.projectCreator;
 document.querySelector('h4[projectEndDate]').innerHTML=projectInfo.projectEndDate;

////////Time countdown///////
 // Sets end date.
 const countDownDate = new Date(projectInfo.projectEndDate).getTime();

 // Updates the count down every 1 second.
 const x = setInterval( ()=> {

 // Get today's date and time.
 const now = new Date().getTime();

 // Find the distance between now an the count down date.
 let distance = countDownDate - now;

 // Time calculations for days, hours, minutes and seconds.
 let days = Math.floor(distance / (1000 * 60 * 60 * 24));
 let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
 let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
 let seconds = Math.floor((distance % (1000 * 60)) / 1000);

 // Output result.
 document.querySelector('h1[countdown]').innerHTML = days + "d " + hours + "h "
 + minutes + "m " + seconds + "s ";
 }, 1000);
 }
////////End of Time countdown///////
  
 printNumberOfBackers(backers){
 document.querySelector('h1[numberOfBackers]').innerHTML=backers;
 }
printFundsRaised(funds){
  document.querySelector('h1[fundsRaised]').innerHTML=funds;
}
}

//////initiate objects/////
const appRenderer = new Renderer();

//////render loop/////
appRenderer.printLoggedInUser( myAppData.getLoggedInUserInfo() );
appRenderer.printProjectInfo( myAppData.getProjectInfo() );
appRenderer.printNumberOfBackers( myAppData.getTotalNumberOfBackers() );
appRenderer.printFundsRaised( myAppData.getTotalFundsRaised() );
appRenderer.printFundsRaised(CurrencyConvert.formatToCurrency(myAppData.getTotalFundsRaised()) );

let myLogic=new BackerLevelLogic(myAppData);

////
console.log(Levels.bronze.url);
console.log(Levels.gold.description);
console.log(myLogic.determineLevelOfBackerByUID("uid2"));
              
            
!
999px

Console