Created
February 16, 2009 21:18
-
-
Save ELLIOTTCABLE/65375 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var Ones = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']; | |
var Teen = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']; | |
var Tens = ['zero', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']; | |
var Mega = | |
['none', 'thousand', 'million', 'billion', 'trillion', 'quadrillion', | |
'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion', | |
'decillion', 'undecillion', 'duodecillion', 'tredecillion', | |
'quattuordecillion', 'quindecillion', 'sexdecillion', 'septendecillion', | |
'octodecillion', 'novemdecillion', 'vigintillion']; | |
var english_numerals = function(number) { | |
var places = number.toString(10).split('').map(function(e){ return parseInt(e) }).reverse(); | |
var name = []; | |
parseInt((places.length + 2) / 3).times(function(j){ | |
var strings = trio(places.slice(j*3, (j*3) + 3)) | |
if(strings.length > 0 && j > 0) | |
name.push(Mega[j]); | |
name = name.concat(strings); | |
}); | |
if(name.length <= 0) | |
name.push(Ones[0]); | |
return name.reverse().join(" ");; | |
}; | |
var trio = function(places) { | |
var strings = []; | |
if (places[1] == 1) { | |
strings.push(Teen[places[0]].toString()); | |
} else if (typeof places[1] != "undefined" && places[1] > 0) { | |
if (places[0] == 0) { | |
var s = Tens[places[1]].toString(); | |
} else { | |
var s = Tens[places[1]].toString() + '-' + Ones[places[0]].toString(); | |
}; | |
strings.push(s); | |
} else if (places[0] > 0) { | |
strings.push(Ones[places[0]].toString()); | |
}; | |
if (typeof places[2] != "undefined" && places[2] > 0) { | |
strings.push("hundred", Ones[places[2]].toString()) | |
}; | |
return strings; | |
} |
This file contains hidden or 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
// evil global | |
var include = function(path) { | |
var includeElement = document.createElement('script'); | |
includeElement.setAttribute('language', 'javascript'); | |
includeElement.setAttribute('type', 'text/javascript'); | |
includeElement.setAttribute('src', path); | |
document.getElementsByTagName('head')[0].appendChild(includeElement); | |
return true; | |
}; | |
var includes = function(){ | |
include("js/C.js"); | |
include("js/english_numerals.js"); | |
include("js/main.js"); | |
}; |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<?xml-stylesheet href="css/main.css" type="text/css" media="screen"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" | |
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | |
<head> | |
<title>This is new thought.</title> | |
<script type="text/javascript" charset="utf-8" | |
src="js/vendor/mootools-1.2.1-core-jm.js"></script> | |
<script type="text/javascript" charset="utf-8" | |
src="js/includes.js"></script> | |
</head> | |
<body onload="includes();"> | |
<div id="article"> | |
<p>1999, in fact. Forty years after he crammed her whole life on a very high rate of speed. Dinos And Noah Just Makes Sense — I love this. Oekaki Is An Advance In Guestbookin — It’s like a ghost. I went to a commercial touting sugar as the monofin speed is that much larger.</p> | |
</div> | |
<ol id="articles"> | |
<li>Something</li> | |
<li>Nothing</li> | |
<li>What?</li> | |
<li>Really?</li> | |
<li>Belief</li> | |
<li>Pain</li> | |
<li>Design</li> | |
<li>Sheepdog</li> | |
<li>Storage</li> | |
<li>Nerf</li> | |
<li>Bottle</li> | |
</ol> | |
</body> | |
</html> |
This file contains hidden or 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
window.addEvent('domready', function() { | |
$$('#articles > li').each(function(el,i){ | |
el.setStyle('list-style-type', 'none') | |
el.set('text', english_numerals(i)); | |
}); | |
}, 'javascript'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment