diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..94824ae --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +**/node_modules/ + diff --git a/README.md b/README.md index 20d8b0d..fa7dfb6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # htc-ranking -De live ranking gebruikt voor de Haramvision Team Contest. \ No newline at end of file +De live ranking gebruikt voor de Haramvision Team Contest. + +Before you can use this for yourself you also need to setup your own Pusher channel. For +more information on how to do that go to [https://pusher.com/docs/channels/getting_started/javascript](https://pusher.com/docs/channels/getting_started/javascript). diff --git a/cli/htc-ranking-cli.zip b/cli/htc-ranking-cli.zip new file mode 100644 index 0000000..fd48ba5 Binary files /dev/null and b/cli/htc-ranking-cli.zip differ diff --git a/cli/index.js b/cli/index.js new file mode 100644 index 0000000..25bbed9 --- /dev/null +++ b/cli/index.js @@ -0,0 +1,70 @@ + + +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); +}); diff --git a/cli/package.json b/cli/package.json new file mode 100644 index 0000000..a207894 --- /dev/null +++ b/cli/package.json @@ -0,0 +1,12 @@ +{ + "name": "ranking", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/ranking/index.html b/ranking/index.html new file mode 100644 index 0000000..33dda9d --- /dev/null +++ b/ranking/index.html @@ -0,0 +1,169 @@ + + +