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 xmlns='http://www.w3.org/1999/xhtml'>

<head>
	<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />

<title>Movie Insticts</title>

	<link rel='stylesheet' type='text/css' href='css/application.css' />
	<link href='https://fonts.googleapis.com/css?family=Denk+One|Paytone+One|Anton|Racing+Sans+One|Changa+One|Squada+One|Luckiest+Guy' rel='stylesheet' type='text/css'>
	<link href='https://fonts.googleapis.com/css?family=Kite+One' rel='stylesheet' type='text/css'>
	<link href='https://fonts.googleapis.com/css?family=Voltaire' rel='stylesheet' type='text/css'>

</head>

<body>
    <img class="spinner" src="https://d13yacurqjgara.cloudfront.net/users/82092/screenshots/1073359/spinner.gif">
		<div id='content'>
       <div class='resultsBarContainer'>
         <div class='resultsBar'></div>
         <div class="percent">0%</div>
      </div>
      
			<div id='heading'>
				<h2>How Good Are Your</h2><br>
				<h1>MOVIE INSTINCTS?</h1><br><br>
  			<h3>Select movies on your "to see" list and get a combined score.</h3>
         <div class="credit">Credit
           <div>The Rotten Tomatoes <a href="http://developer.rottentomatoes.com/" target="_blank">API</a> is what makes this application possible</div>
         </div>
			</div>
        	<div id='clear'>Clear</div>
		</div>

	<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
	<script>window.jQuery || document.write('<script src='js/jquery.js'><\/script>')</script>
	<script type='text/javascript' src='js/application.js'></script>
</body>
</html>

              
            
!

CSS

              
                body {
  background: #fff; /* Old browsers */
}
h1 {
	font-family: 'Racing Sans One', sans-serif;
	font-size: 3.1em;
	line-height: .9;
	/*color: #B72516;*/
	color: #444;
	margin: -21px 0 -40px -2px;
	padding: 0;
}
h2 {
	font-family: 'Arial', sans-serif;
	font-size: 1.2em;
	font-weight: normal;
	color: #444;
	margin: 0px 0 0 0;
	padding: 0;
	display: block;
}
h3 {
	font-family: 'Arial', sans-serif;
	font-size: 1.1em;
	font-weight: normal;
	color: #444;
	margin: 3px 0 10px 0;
	padding: 0;
	display: inline-block;
}
.credit {
	font: 10px/20px'Arial', sans-serif;
  color: #555;
  float: right;
  margin: 0px 10px 0 0;
  display: inline-block;
  cursor: pointer;
  position: relative;
  
  > div {
      font: 13px/15px "Arial", sans-serif;
      color: #555;
      width: 200px;
      opacity: 0;
      position: absolute;
      top: -50px;
      right: -6px;
      cursor: default;
      background: #fff;
      border-radius: 2px;
      padding: 8px;
      box-shadow: -1px 1px 1px 1px #aaa;
      -webkit-transition: opacity .25s ease-in;
      -moz-transition: opacity .25s ease-in;
      transition: opacity .25s ease-in;
    
    	a {
        color: #777;
        text-decoration: none;
      }
  }
}
.credit:hover {
  > div {
    opacity: 1;
  }
}
#info {
	display: inline-block;
}
#heading {
   border-bottom: 2px solid #000;
	margin: 0;
	padding-left: 20px;
}
.spinner {
  width: 400px;
  height: 300px;
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -150px 0 0 -200px;
}
#content {
	border-radius: 5px;
	background: #ffffff;
	width: 90%;
  max-width: 780px;
  min-width: 745px;
	margin: 20px auto 0 auto;
	padding: 0px 0px 0px 0px;
  position: relative;
  display: none;
}
.unselected {
	border-bottom: 1px solid #ccc;
  width: auto;
	height: auto;
	margin:  0px auto 0px auto;
	background: #fff;
	transition: background-color .5s linear;
	padding: 10px 0px 10px 0px;
	font-family: 'Arial', sans-serif;
	font-size: 1.3em;
	font-weight: normal;
	color: #555;
	text-align: center;
	border-radius: 0px;
	cursor: pointer;
	display: block;
	text-transform: uppercase;
}
.unselected:nth-child(odd) {
  /*background-color: #f5f5f5;*/
  background-color: #fafafa;
}
.unselected:hover {
	background-color: #ebebeb;
	/*box-shadow: 0 0 12px #eee;*/
	color: #222;
}
.selected {
	border-bottom: 1px solid #fff;
	/*box-shadow: 0 0 12px #41FF2A;*/
  width: auto;
	height: auto;
	margin:  0px auto 0px auto;
	background: #8DCF22;
	padding: 10px 0px 10px 0px;
	font-family: 'Arial', sans-serif;
	font-size: 1.3em;
	font-weight: normal;
	text-align: center;
   color: #222;
	border-radius: 0px;
	cursor: pointer;
	display: block;
	text-transform: uppercase;
}
.moviePoster {
	display: none;
}
.cRating {
	display: none;
}
.cScore {
	display: none;
}
#clear {
	border: 0px solid #376FD1;
	width: 100%;
	height: 20px;
	margin: 0px auto 10px auto;
	background: #D9624F;
	padding: 17px 0 26px 0;
	font-family: 'Arial', sans-serif;
	font-size: 1.5em;
	color: #ffffff;
	text-align: center;
	border-radius: 0px;
	text-transform: uppercase;
	display: inline-block;
  
  &:hover {
    background: #c95746;
    //box-shadow: 0 0 12px #dd2222;
    cursor: pointer;
  }
}
.resultsBarContainer {
    background: #333;
    //border: 2px solid #666;
    width: 10px;
    height: 785px;
    position: absolute;
    bottom: 10px;
    left: -10px;
  
 .resultsBar {
    background: #8DCF22;
    //border: 2px solid #666;
    width: 100%;
    height: 0%;
    position: absolute;
    bottom: 0px;
    left: 0px;
  }
  .percent {
     height: 50px;
     width: 100%;
     position: absolute;
     top: 50%;
     margin-top: -25px;
     text-align: center;
     font-family: 'Arial', sans-serif;
     font-size: 20px;
     color: #fff;
     content: '0%';
     display: none;
   }
}
              
            
!

JS

              
                // Have the percentage in the pop-up add up quickly to the total 
// Get rid of the alert and place the alert message in the pop-up

var arr = [];

// ----- Access Rotten Tomatoes API and inject HTML ----- //
$(document).ready(function () {
  var sf = $('#searchField').val(),
      apiKey = 'a9axph6dk884n4yu97b923p7';
  $.ajax({
    type: 'GET',
    url: 'http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json?apikey='+apiKey,
    dataType: 'jsonp',
    success: function (data) {
      $(data.movies).each(function (idx, val){
        var info = ''
            +'<div id="'+data.movies[idx].title+'" class="unselected">'+data.movies[idx].title+'</div>'
            //+'<div class="moviePoster"><img src='+data.movies[idx].posters.detailed+' width="75"></div>'
            +'<div class="cRating">'+data.movies[idx].ratings.critics_rating+'</div>' // audience_rating can also be used
            +'<div class="cScore">'+data.movies[idx].ratings.critics_score+'</div>' // audience_score can also be used
          $(info).insertBefore('#clear');
          $('#content').fadeIn(500);
          $('.spinner').fadeOut(500);
        });
      },
    error: function () {
      console.log('The ajax call to the JSON file has failed');
    }
  });
});

// Reveal lightbox containing results
function results(sel, per) {
   $('.percent').html("").append(per > 0 ? per + "%" : "0%");
   $('.resultsBar').animate(per > 0 ? {height: per + "%"} : {height: "0%"}, 1000);  
}

// Change the clicked button class of unselected to selected
$('.unselected').live('click', function(){
  $(this).removeClass('unselected').addClass('selected');
  score = $(this).nextAll('div.cScore')[0].innerHTML;
  arr.push(score);
});

// Change the clicked button class of selected back to unselected
$('.selected').live('click', function(){
  $(this).removeClass('selected').addClass('unselected');
  $(this).children('div.movieTitle').text(this.id)
  score = $(this).nextAll('div.cScore')[0].innerHTML;
  indx = arr.indexOf(score);
  arr.splice(indx, 1);
});

// On click of movie title the movie's scores will be combined for a total percentage and be displayed by results bar
var numSelected, percent;

$('.unselected, .selected').live('click', function(){
  var sum, numSelected, percent;
  sum = 0;
  numSelected = arr.length;
  for (var i=0;i<numSelected;i++) {
    sum += parseInt(arr[i]);
  }
  percent = Math.ceil(sum / numSelected);
  numSelected > 0 ? results(numSelected, percent) : results(0, 0);
});

var rbcWidth,
    rbcMarginLeft;

$('.resultsBarContainer').mouseenter(function() {
  rbcWidth = $(this).css('width'),
  rbcMarginLeft = $(this).css('marginLeft');
  console.log(rbcWidth);
  $(this).animate({width: '70px', 'margin-left': '-60px'}, 300);
  $('.percent').fadeIn(300);
}).mouseleave(function() {
  $(this).animate({width: rbcWidth, 'margin-left': rbcMarginLeft}, 300);
  $('.percent').fadeOut(300);
});

$('#clear').live('click', function() {
  $('.selected').removeClass('selected').addClass('unselected');
  arr = [];
  results(numSelected, percent);  
});
              
            
!
999px

Console