diff --git a/counter.json b/counter.json new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/counter.json @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/ipsum.js b/ipsum.js index 17f5e80..fed0709 100644 --- a/ipsum.js +++ b/ipsum.js @@ -1,5 +1,13 @@ var express = require('express'), +<<<<<<< HEAD + app = express(), + server = require('http').Server(app), + io = require('socket.io')(server), + fs = require('fs'), + counter = require('./counter.json'); +======= app = express(); +>>>>>>> d16e6fb07eb8765657af0e649b91101ff835a332 app.use(express.static(__dirname + '/client', {maxAge: 60*60*24*7})); @@ -87,6 +95,14 @@ function loremipsum(data) { } } function go(url) { - var req = url.split('/'); - return loremipsum(req.slice(1)); + var ipsum = loremipsum(url.split('/').slice(1)); + counter += ipsum.split(' ').length; + fs.writeFileSync('counter.json', counter); + io.emit('counter', counter); + return ipsum; } + +/* COUNTER */ +io.on('connection', function(socket) { + socket.emit('counter', counter); +}); diff --git a/ipsum/css/main.css b/ipsum/css/main.css index e22a900..2c94c9c 100644 --- a/ipsum/css/main.css +++ b/ipsum/css/main.css @@ -510,3 +510,11 @@ a[href="#"].running { background-color: rgba(255, 255, 255, 0.2); color: white; } + +.counter { + position: absolute; + left: 1rem; + bottom: 1rem; + padding: 1.5rem; + font-size: 2rem; +} diff --git a/ipsum/css/main.less b/ipsum/css/main.less index 619142c..fd7757b 100644 --- a/ipsum/css/main.less +++ b/ipsum/css/main.less @@ -191,3 +191,12 @@ a[href="#"].running { background-color: rgba(255, 255, 255, 0.2); color: white; } + +.counter { + position: absolute; + left: 1rem; + bottom: 1rem; + padding: 1.5rem; + font-size: 2rem; +} + diff --git a/ipsum/index.html b/ipsum/index.html index b38ac21..add1ea8 100644 --- a/ipsum/index.html +++ b/ipsum/index.html @@ -51,9 +51,14 @@ +