First commit of partial RosettaCode contents.

Pushing this for testing purposes. Lots of work still needed.
This commit is contained in:
Ingy döt Net 2013-04-08 13:02:41 -07:00
commit 1e05ecd7ee
781 changed files with 9080 additions and 0 deletions

View file

@ -0,0 +1,2 @@
// Line breaks are in HTML
var beer; while ((beer = typeof beer === "undefined" ? 99 : beer) > 0) document.write( beer + " bottle" + (beer != 1 ? "s" : "") + " of beer on the wall<br>" + beer + " bottle" + (beer != 1 ? "s" : "") + " of beer<br>Take one down, pass it around<br>" + (--beer) + " bottle" + (beer != 1 ? "s" : "") + " of beer on the wall<br>" );

View file

@ -0,0 +1,21 @@
// Line breaks are in HTML
function Bottles(count){
this.count = (!!count)?count:99;
this.knock = function(){
var c = document.createElement('div');
c.id="bottle-"+this.count;
c.innerHTML = "<p>"+this.count+" bottles of beer on the wall</p>"
+"<p>"+this.count+" bottles of beer!</p>"
+"<p>Take one down,<br>Pass it around</p>"
+"<p>"+(--this.count)+" bottles of beer on the wall</p><p><br></p>";
document.body.appendChild(c);
}
this.sing = function(){
while (this.count>0) { this.knock(); }
}
}
(function(){
var bar = new Bottles(99);
bar.sing();
})();

View file

@ -0,0 +1,18 @@
function bottleSong(n) {
if (!isFinite(Number(n)) || n == 0) n = 100;
var a = '%% bottles of beer',
b = ' on the wall',
c = 'Take one down, pass it around',
r = '<br>'
p = document.createElement('p'),
s = [],
re = /%%/g;
while(n) {
s.push((a+b+r+a+r+c+r).replace(re, n) + (a+b).replace(re, --n));
}
p.innerHTML = s.join(r+r);
document.body.appendChild(p);
}
window.onload = bottleSong;

View file

@ -0,0 +1,10 @@
// Line breaks are in HTML
var beer = 99;
while (beer > 0)
{
document.write( beer + " bottles of beer on the wall<br>" );
document.write( beer + " bottles of beer<br>" );
document.write( "Take one down, pass it around<br>" );
document.write( (beer - 1) + " bottles of beer on the wall<br>" );
beer--;
}