This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,166 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
(function() { | ||
var cleanDollarInput, defaultPrice, dollarToSliderPos, sliderPosToDollar, updateAmountFromSlider, updatePercentFromInput, updatePercentFromSlider, updateSliderFromAmount; | ||
|
||
defaultPrice = 20.00; | ||
|
||
dollarToSliderPos = function(dollar) { | ||
return dollar * 2; | ||
}; | ||
|
||
sliderPosToDollar = function(sliderPos) { | ||
return sliderPos * .5; | ||
}; | ||
|
||
cleanDollarInput = function(dollarInput) { | ||
var dollarFloat, noDollar; | ||
noDollar = dollarInput.replace('$', ''); | ||
dollarFloat = parseFloat(noDollar).toFixed(2) || defaultPrice; | ||
if (dollarFloat < 0) { | ||
return defaultPrice.toFixed(2); | ||
} else { | ||
return dollarFloat; | ||
} | ||
}; | ||
|
||
updateAmountFromSlider = function(sliderPos) { | ||
var amount, displayAmount, sliderAmount; | ||
amount = document.getElementById('amount'); | ||
displayAmount = document.getElementById('display-amount'); | ||
sliderAmount = sliderPosToDollar(sliderPos).toFixed(2); | ||
displayAmount.setAttribute('value', "$" + sliderAmount); | ||
return amount.setAttribute('value', sliderAmount); | ||
}; | ||
|
||
updateSliderFromAmount = function(newAmount) { | ||
$('#amount').val(newAmount); | ||
$('#slider').slider('value', dollarToSliderPos(newAmount)); | ||
return false; | ||
}; | ||
|
||
updatePercentFromInput = function(percentString) { | ||
var percent; | ||
percent = parseInt(percentString.replace('%', '')) || 5; | ||
if (percent < 0) { | ||
percent = 0; | ||
} else if (percent > 100) { | ||
percent = 100; | ||
} | ||
$('#percent-slider').slider('value', percent); | ||
$('#percent').val(percent); | ||
$('#display-percent').val(percent + '%'); | ||
return false; | ||
}; | ||
|
||
updatePercentFromSlider = function(sliderPos) { | ||
var percentDisplay, percentInput; | ||
percentInput = document.getElementById('percent'); | ||
percentInput.setAttribute('value', sliderPos); | ||
percentDisplay = document.getElementById('display-percent'); | ||
percentDisplay.setAttribute('value', sliderPos + '%'); | ||
return this; | ||
}; | ||
|
||
jQuery(function() { | ||
$('#display-percent').blur(function() { | ||
var raw; | ||
raw = $(this).val() || 5; | ||
return updatePercentFromInput(raw); | ||
}); | ||
$('#display-percent').change(function() { | ||
var raw; | ||
raw = $(this).val() || 5; | ||
return updatePercentFromInput(raw); | ||
}); | ||
$('#display-amount').blur(function() { | ||
var newDollar, raw; | ||
raw = $(this).val() || defaultPrice; | ||
newDollar = cleanDollarInput(raw); | ||
updateSliderFromAmount(newDollar); | ||
return $(this).val('$' + newDollar); | ||
}); | ||
$('#display-amount').change(function(event) { | ||
var newDollar, raw; | ||
raw = $(this).val() || defaultPrice + ''; | ||
newDollar = cleanDollarInput(raw); | ||
updateSliderFromAmount(newDollar); | ||
return $(this).val('$' + newDollar); | ||
}); | ||
$('#percent-slider').slider({ | ||
value: 5, | ||
animate: true, | ||
slide: function(e, ui) { | ||
return updatePercentFromSlider(ui.value); | ||
}, | ||
stop: function(e, ui) { | ||
return updatePercentFromSlider(ui.value); | ||
} | ||
}); | ||
return $('#slider').slider({ | ||
value: dollarToSliderPos(defaultPrice), | ||
animate: true, | ||
create: function() { | ||
return updateAmountFromSlider(dollarToSliderPos(defaultPrice)); | ||
}, | ||
slide: function(e, ui) { | ||
return updateAmountFromSlider(ui.value); | ||
}, | ||
stop: function(e, ui) { | ||
return updateAmountFromSlider(ui.value); | ||
} | ||
}); | ||
}); | ||
|
||
}).call(this); |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Nature Of Code</title> | ||
<link rel="stylesheet" href="/css/natureofcode.css" /> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | ||
<script src="/js/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script> | ||
<script src="/js/index.js"></script> | ||
</head> | ||
<body> | ||
<div id="top"> | ||
<div id="header"> | ||
<h1><a href="/">The <strong>Nature</strong> of Code</a></h1> | ||
<h2>Daniel Shiffman</h2> | ||
</div> | ||
</div> | ||
|
||
<div id="middle"> | ||
<div id="content"> | ||
A book about applying topics from mathematics, physics, and generative algorithms to computational systems. With Processing! | ||
|
||
<div id="purchase-options"> | ||
<div id="purchase-pdf"> | ||
<h3>Buy <strong>The Nature of Code</strong> PDF</h3> | ||
|
||
<p>Download the entire book directly from the author.</p> | ||
|
||
<ul class="description"> | ||
<li>DRM-free</li> | ||
<li>Delivered by email, no login necessary</li> | ||
<li>Receive book updates for free</li> | ||
</ul> | ||
|
||
<form method="POST" action="/order" id="slider-form"> | ||
<p>Name Your Price:</p> | ||
<fieldset> | ||
<div class="slider-holder"> | ||
<div id="slider"></div> | ||
</div> | ||
<input id="amount" type="hidden" name="amount" value="11.00"> | ||
<input type="text" id="display-amount" value="$11.00"> | ||
</fieldset> | ||
|
||
<p>Donate a </p> | ||
<fieldset> | ||
<div class="slider-holder"> | ||
<div id="percent-slider"></div> | ||
</div> | ||
<input type="hidden" id="percent" name="donation" value="5"> | ||
<input type="text" id="display-percent" name="percent" value="5%"> | ||
</fieldset> | ||
<input type="submit" id="buy-now" value="Buy Now"> | ||
</form> | ||
</div> | ||
|
||
<div id="purchase-print"> | ||
<h3>Also available in print!</h3> | ||
<img src="http://farm9.staticflickr.com/8448/7749029626_04c08b4bed.jpg" style="max-width:100%;"> | ||
<a class="block-link" href="#">Buy from Amazon.com</a> | ||
</div> | ||
</div> | ||
|
||
<div id="read"> | ||
<h3>Read the Entire Book Online for Free</h3> | ||
|
||
<p>The complete book is available as HTML with interactive Processing.js examples.</p> | ||
|
||
<a class="block-link" href="/book">Read Now</a> | ||
|
||
<p></p> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div id="bottom"> | ||
<div id="footer"> | ||
|
||
<p>©2012 Daniel Shiffman.</p> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file | ||
# | ||
# To ban all spiders from the entire site uncomment the next two lines: | ||
# User-Agent: * | ||
# Disallow: / |