Adds support for extra descriptions
This commit is contained in:
parent
48e55aafab
commit
d335fb919b
2 changed files with 36 additions and 15 deletions
26
index.html
26
index.html
|
@ -131,9 +131,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-name {
|
.result-name {
|
||||||
width: 20%;
|
width: 30%;
|
||||||
|
|
||||||
padding-right: 5px 8px;
|
padding: 5px 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-link {
|
.result-link {
|
||||||
|
@ -174,16 +174,19 @@
|
||||||
# You can add a user by adding a line
|
# You can add a user by adding a line
|
||||||
Santa
|
Santa
|
||||||
|
|
||||||
|
# You can add some details if you want to, using parentheses after the name
|
||||||
|
Nicholas (the elf)
|
||||||
|
|
||||||
# You can prevent someone from being paired with someone else
|
# You can prevent someone from being paired with someone else
|
||||||
Maël !Aurélie
|
Maël !Aurélie
|
||||||
Aurélie !Maël
|
Aurélie !Maël
|
||||||
|
|
||||||
# You can also exclude someone from being paired with multiple people
|
# You can also exclude someone from being paired with multiple people
|
||||||
# Careful: too many exclusion rules can make your secret santa less interesting!
|
# Careful: too many exclusion rules can make your secret santa less interesting!
|
||||||
Rudolph !Maël !Santa
|
Rudolph !Santa !Nicholas (the elf)
|
||||||
|
|
||||||
# You can also cheat a bit and force someone to be paired with another
|
# You can also cheat a bit and force someone to be paired with another
|
||||||
Aurélie =Santa
|
Nicholas (the saint) =Nicholas (the elf)
|
||||||
|
|
||||||
...
|
...
|
||||||
</script>
|
</script>
|
||||||
|
@ -271,7 +274,8 @@
|
||||||
|
|
||||||
for ( var t = 0, T = names.length; t < T; ++ t ) {
|
for ( var t = 0, T = names.length; t < T; ++ t ) {
|
||||||
|
|
||||||
var name = names[ t ];
|
var displayName = names[ t ];
|
||||||
|
var name = names[ t ].replace( /\([^)]+\)/g, ' ' ).replace( / +/g, ' ' ).trim();
|
||||||
|
|
||||||
var tr = document.createElement( 'tr' );
|
var tr = document.createElement( 'tr' );
|
||||||
tr.className = 'result-row';
|
tr.className = 'result-row';
|
||||||
|
@ -297,10 +301,10 @@
|
||||||
if ( isAmazonEnabled() )
|
if ( isAmazonEnabled() )
|
||||||
pairingQueryString += '&extra=1';
|
pairingQueryString += '&extra=1';
|
||||||
|
|
||||||
tdName.innerText = name;
|
tdName.innerText = displayName;
|
||||||
|
|
||||||
link.addEventListener( 'click', protect );
|
link.addEventListener( 'click', protect );
|
||||||
link.setAttribute( 'data-name', name );
|
link.setAttribute( 'data-name', displayName );
|
||||||
link.href = window.location.protocol + '//' + window.location.host + pairingPath + pairingQueryString;
|
link.href = window.location.protocol + '//' + window.location.host + pairingPath + pairingQueryString;
|
||||||
link.innerText = link.href;
|
link.innerText = link.href;
|
||||||
|
|
||||||
|
@ -354,8 +358,6 @@
|
||||||
|
|
||||||
var lines = content.split( /\n/g );
|
var lines = content.split( /\n/g );
|
||||||
|
|
||||||
console.log(lines);
|
|
||||||
|
|
||||||
if ( lines.length === 0 || lines.length === 1 && lines[ 0 ].length === 0 )
|
if ( lines.length === 0 || lines.length === 1 && lines[ 0 ].length === 0 )
|
||||||
return reset();
|
return reset();
|
||||||
|
|
||||||
|
@ -363,13 +365,13 @@
|
||||||
|
|
||||||
for ( var t = 0, T = lines.length; t < T; ++ t ) {
|
for ( var t = 0, T = lines.length; t < T; ++ t ) {
|
||||||
|
|
||||||
var match = lines[ t ].match( /^([^ ]+)((?: [!=][^ ]+)*)$/ );
|
var match = lines[ t ].match( /^((?:(?![!=]).)+)((?: [!=](?:(?! [!=]).)+)*)$/ );
|
||||||
|
|
||||||
if ( ! match )
|
if ( ! match )
|
||||||
return error( 'Syntax error: "' + lines[ t ] + '" isn\'t valid' );
|
return error( 'Syntax error: "' + lines[ t ] + '" isn\'t valid' );
|
||||||
|
|
||||||
var name = match[ 1 ];
|
var name = match[ 1 ];
|
||||||
var rules = match[ 2 ] ? match[ 2 ].match(/[^ ]+/) : null;
|
var rules = match[ 2 ] ? match[ 2 ].match(/[!=][^!=]+/) : null;
|
||||||
|
|
||||||
var person = santa.add( name );
|
var person = santa.add( name );
|
||||||
|
|
||||||
|
@ -384,7 +386,7 @@
|
||||||
|
|
||||||
}[ rules[ u ].charAt( 0 ) ];
|
}[ rules[ u ].charAt( 0 ) ];
|
||||||
|
|
||||||
person[ fnName ]( rules[ u ].slice( 1 ) );
|
person[ fnName ]( rules[ u ].slice( 1 ).trim() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
pairing.html
25
pairing.html
|
@ -98,10 +98,16 @@
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pairing {
|
#pairing-name {
|
||||||
font-size: 90px;
|
font-size: 90px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pairing-details {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.affiliate {
|
.affiliate {
|
||||||
display: block;
|
display: block;
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
|
@ -126,7 +132,9 @@
|
||||||
.compact().object().value();
|
.compact().object().value();
|
||||||
|
|
||||||
var name = queryString.name;
|
var name = queryString.name;
|
||||||
|
|
||||||
var pairing = CryptoJS.AES.decrypt( queryString.pairing, queryString.key ).toString(CryptoJS.enc.Utf8);
|
var pairing = CryptoJS.AES.decrypt( queryString.pairing, queryString.key ).toString(CryptoJS.enc.Utf8);
|
||||||
|
var pairingDefinition = pairing.match( /^([^(]+)(?: (\([^)]+\)))?$/ );
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -142,8 +150,19 @@
|
||||||
<div class="title">Hi <span id="name"></span>! You've been paired with</div>
|
<div class="title">Hi <span id="name"></span>! You've been paired with</div>
|
||||||
<script>document.getElementById('name').innerText = name</script>
|
<script>document.getElementById('name').innerText = name</script>
|
||||||
|
|
||||||
<div class="pairing"><span id="pairing"></span></div>
|
<div class="pairing">
|
||||||
<script>document.getElementById('pairing').innerText = pairing</script>
|
<div id="pairing-name"></div>
|
||||||
|
<div id="pairing-details"></div>
|
||||||
|
<script>
|
||||||
|
document.getElementById('pairing-name').innerText = pairingDefinition[1];
|
||||||
|
|
||||||
|
if (pairingDefinition[2]) {
|
||||||
|
document.getElementById('pairing-details').innerText = pairingDefinition[2];
|
||||||
|
} else {
|
||||||
|
document.getElementById('pairing-details').style.display = 'none';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="title">Good luck!</div>
|
<div class="title">Good luck!</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue