You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.0 KiB
70 lines
2.0 KiB
|
|
|
|
var Pusher = require('pusher');
|
|
|
|
var pusher = new Pusher({
|
|
// Go to https://pusher.com/docs/channels/getting_started/javascript#trigger-events-from-your-server
|
|
// for setting up the variables below.
|
|
appId: 'APP_ID',
|
|
key: 'KEY',
|
|
secret: 'SECRET',
|
|
cluster: 'CLUSTER',
|
|
encrypted: true
|
|
});
|
|
|
|
const readline = require('readline');
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout,
|
|
prompt: '> '
|
|
});
|
|
|
|
rl.prompt();
|
|
|
|
rl.on('line', (line) => {
|
|
words = line.trim().split(' ');
|
|
switch (words[0]) {
|
|
case 'p':
|
|
teamstr = words.slice(2).join(' ');
|
|
if (teamstr.length = 2) {
|
|
teamnr = teamstr.substr(1);
|
|
switch (teamstr.charAt(0)) {
|
|
case 'h':
|
|
teamstr = "Men's " + teamnr;
|
|
break;
|
|
case 'd':
|
|
teamstr = "Ladies " + teamnr;
|
|
break;
|
|
case 'r':
|
|
teamstr = "Recr. " + teamnr;
|
|
break;
|
|
case 'm':
|
|
teamstr = "Mix " + teamnr;
|
|
break;
|
|
default:
|
|
console.log('Incorrect team name: "' + teamstr + '"');
|
|
}
|
|
}
|
|
pusher.trigger('ranking', 'points', {
|
|
'points': parseInt(words[1]),
|
|
'team': teamstr
|
|
});
|
|
console.log('Added ' + words[1] + ' points to "' + teamstr + '"');
|
|
break;
|
|
case 'undo':
|
|
pusher.trigger('ranking', 'undo', {});
|
|
console.log('Triggered undo action.');
|
|
break;
|
|
case 'reset':
|
|
pusher.trigger('ranking', 'reset', {});
|
|
console.log('Triggered reset action.');
|
|
break;
|
|
default:
|
|
console.log(`Incorrect command: '${line.trim()}'`);
|
|
break;
|
|
}
|
|
rl.prompt();
|
|
}).on('close', () => {
|
|
console.log('Exiting...');
|
|
process.exit(0);
|
|
});
|
|
|