From 02d32ae9023832ea47be6fd64346bf234cd590d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Sat, 12 Dec 2015 16:34:00 +0100 Subject: [PATCH] Fixes line endings --- SecretSanta.js | 156 +++++++++++++++++++------------------- pairing.html | 200 ++++++++++++++++++++++++------------------------- 2 files changed, 178 insertions(+), 178 deletions(-) diff --git a/SecretSanta.js b/SecretSanta.js index ac84de9..b7159f9 100644 --- a/SecretSanta.js +++ b/SecretSanta.js @@ -1,78 +1,78 @@ -var SecretSanta = function () { - - this.names = []; - - this.blacklists = Object.create( null ); -}; - - -SecretSanta.prototype.add = function ( name ) { - - if ( this.names.indexOf( name ) !== -1 ) - throw new Error( 'Cannot redefine ' + name ); - - this.names.push( name ); - - var subapi = { }; - - subapi.blacklist = function ( other ) { - - if ( ! Object.prototype.hasOwnProperty.call( this.blacklists, name ) ) - this.blacklists[ name ] = []; - - if ( this.blacklists[ name ].indexOf( other ) === -1 ) - this.blacklists[ name ].push( other ); - - return subapi; - - }.bind( this ); - - return subapi; - -}; - -SecretSanta.prototype.generate = function () { - - var pairings = Object.create( null ); - var candidatePairings = Object.create( null ); - - this.names.forEach( function ( name ) { - - var candidates = _.difference( this.names, name ); - - if ( Object.prototype.hasOwnProperty.call( this.blacklists, name ) ) - candidates = _.difference( candidates, this.blacklists[ name ] ); - - candidatePairings[ name ] = candidates; - - }, this ); - - var findNextGifter = function () { - - var names = Object.keys( candidatePairings ); - - var minCandidateCount = _.min( names.map( function ( name ) { return candidatePairings[ name ].length; } ) ); - var potentialGifters = names.filter( function ( name ) { return candidatePairings[ name ].length === minCandidateCount; } ); - - return _.sample( potentialGifters ); - - }; - - while ( Object.keys( candidatePairings ).length > 0 ) { - - var name = findNextGifter(); - - var pairing = _.sample( candidatePairings[ name ] ); - delete candidatePairings[ name ]; - - Object.keys( candidatePairings ).forEach( function ( name ) { - candidatePairings[ name ] = _.without( candidatePairings[ name ], pairing ); - } ); - - pairings[ name ] = pairing; - - } - - return pairings; - -}; +var SecretSanta = function () { + + this.names = []; + + this.blacklists = Object.create( null ); +}; + + +SecretSanta.prototype.add = function ( name ) { + + if ( this.names.indexOf( name ) !== -1 ) + throw new Error( 'Cannot redefine ' + name ); + + this.names.push( name ); + + var subapi = { }; + + subapi.blacklist = function ( other ) { + + if ( ! Object.prototype.hasOwnProperty.call( this.blacklists, name ) ) + this.blacklists[ name ] = []; + + if ( this.blacklists[ name ].indexOf( other ) === -1 ) + this.blacklists[ name ].push( other ); + + return subapi; + + }.bind( this ); + + return subapi; + +}; + +SecretSanta.prototype.generate = function () { + + var pairings = Object.create( null ); + var candidatePairings = Object.create( null ); + + this.names.forEach( function ( name ) { + + var candidates = _.difference( this.names, name ); + + if ( Object.prototype.hasOwnProperty.call( this.blacklists, name ) ) + candidates = _.difference( candidates, this.blacklists[ name ] ); + + candidatePairings[ name ] = candidates; + + }, this ); + + var findNextGifter = function () { + + var names = Object.keys( candidatePairings ); + + var minCandidateCount = _.min( names.map( function ( name ) { return candidatePairings[ name ].length; } ) ); + var potentialGifters = names.filter( function ( name ) { return candidatePairings[ name ].length === minCandidateCount; } ); + + return _.sample( potentialGifters ); + + }; + + while ( Object.keys( candidatePairings ).length > 0 ) { + + var name = findNextGifter(); + + var pairing = _.sample( candidatePairings[ name ] ); + delete candidatePairings[ name ]; + + Object.keys( candidatePairings ).forEach( function ( name ) { + candidatePairings[ name ] = _.without( candidatePairings[ name ], pairing ); + } ); + + pairings[ name ] = pairing; + + } + + return pairings; + +}; diff --git a/pairing.html b/pairing.html index 00c7940..5e9ee9c 100755 --- a/pairing.html +++ b/pairing.html @@ -1,100 +1,100 @@ - - - - - - - Secret Santa Pairing - - - - - - - - - - - - -
- -
-

Hi ! You've been paired with

-

-

Good luck!

- - -
- -
- - - - + + + + + + + Secret Santa Pairing + + + + + + + + + + + + +
+ +
+

Hi ! You've been paired with

+

+

Good luck!

+ + +
+ +
+ + + +