diff --git a/lib/currency.js b/lib/currency.js index ec7ae4c..144101e 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -264,7 +264,8 @@ Currency.prototype.commands = function (data) { break; } } - + + /* // add currency if (data[4] === 'add') { if(parseInt(data[5], 10) > 0 && data[6]) { @@ -285,6 +286,7 @@ Currency.prototype.commands = function (data) { __self.adjust_currency('push', data[5], data[6]); } } + */ } // moderator commands @@ -594,9 +596,6 @@ Currency.prototype.query_rank = function(data, callback) { callback(ranks, total); }); - - var file = require('fs'); - file.appendFile('./../logs/error-log.txt', sql+'\n', function(d){}); }; Currency.prototype.query_top = function (data, callback) { @@ -738,6 +737,7 @@ Currency.prototype.handout_coins = function () { // trigger coin handout function insert_coins() { __self.give_coins = __self.streaming; + console.log('DATA - Inserting coins'); if (__self.give_coins) { var time = utils.make_interval(__self.give_coins_timer); if (time === 0) { @@ -762,7 +762,7 @@ Currency.prototype.handout_coins = function () { } // execute query - __self.db.execute(sql, function () {}); + __self.db.execute(sql, function () { console.log('DATA - Completed adding coins to ' + __self.viewer_list.length + ' viewers'); }); setTimeout(insert_coins, 1000); } else { setTimeout(insert_coins, time); @@ -781,6 +781,7 @@ Currency.prototype.handout_coins = function () { if(name.charAt(0) === ':') name = name.slice(1); if (__self.viewer_list.indexOf(name) < 0 && __self.config.ignorelist.indexOf(name) < 0) { __self.viewer_list.push(name); + console.log("[*ADD NAME*] "+name+" from /names"); } }); } @@ -794,6 +795,7 @@ Currency.prototype.handout_coins = function () { } if (__self.viewer_list.indexOf(viewer) < 0 && __self.config.ignorelist.indexOf(viewer) < 0) { __self.viewer_list.push(viewer); + console.log("[*ADD NAME*] "+viewer+" from JOIN"); } } @@ -807,6 +809,7 @@ Currency.prototype.handout_coins = function () { var viewer_idx = __self.viewer_list.indexOf(viewer); if (viewer_idx >= 0) { __self.viewer_list.splice(viewer_idx); + console.log("[*DEL NAME*] "+viewer+" from PART"); } } @@ -819,6 +822,7 @@ Currency.prototype.handout_coins = function () { } if (__self.viewer_list.indexOf(viewer) < 0 && __self.config.ignorelist.indexOf(viewer) < 0) { __self.viewer_list.push(viewer); + console.log("[*ADD NAME*] "+viewer+" from CHAT"); } if (__self.active_list.indexOf(viewer) < 0) { __self.active_list.push(viewer); diff --git a/lib/web.js b/lib/web.js index 05c36b5..669527c 100644 --- a/lib/web.js +++ b/lib/web.js @@ -46,8 +46,21 @@ WEB.prototype.start = function () { slogan: __self.slogan, logo: __self.logo, twitter: __self.twitter, - rows: rows + rows: rows, + }); + }); + }); + __self.srv.get('/api/test', function(req, res) { + res.send("Hey, its Potatr. This data was pulled from the web."); + }); + __self.srv.all('/api/data', function(req, res) { + sql = 'SELECT * FROM viewers ORDER BY points DESC;'; + __self.db.execute(sql, function(rows) { + ladder_data = new Object(); + rows.forEach(function(element, index, array){ + ladder_data[element.user] = element.points; }); + res.send(ladder_data); }); }); diff --git a/web/public/css/app.css b/web/public/css/app.css index f005eb1..813a1d1 100644 --- a/web/public/css/app.css +++ b/web/public/css/app.css @@ -12,3 +12,6 @@ filter: FlipH; -ms-filter: "FlipH"; } +.uk-search-field, .uk-search-field::-moz-placeholder { + color: #FFFFFF; +} diff --git a/web/templates/index.jade b/web/templates/index.jade old mode 100644 new mode 100755 diff --git a/web/templates/ladder.jade b/web/templates/ladder.jade old mode 100644 new mode 100755 index 676d30a..42ba720 --- a/web/templates/ladder.jade +++ b/web/templates/ladder.jade @@ -32,6 +32,10 @@ html(lang="en") br div.uk-width-1-1 div.uk-panel.uk-panel-box + div.uk-badge.uk-float-right + form.uk-search + input(class='uk-search-field', type='search', placeholder='Search...') + button(class='uk-close', type='reset') table.uk-table.uk-table-hover.uk-table-striped caption Potato Farmer Ladder Rankings thead @@ -47,6 +51,24 @@ html(lang="en") data = !{JSON.stringify(rows)}; $(document).ready(function(){ + + // Live search of the ladder listings + $('.uk-search-field').keyup(function() { + var query = $(this).val(); + + if(query.length > 2) { + var temp = $('.uk-active').attr('page'); + $('.uk-active').removeClass('uk-active').empty().append(''+temp+''); + $('table > tbody').empty(); + + data.forEach(function(element, index, array) { + if(element.user.search(new RegExp(query, 'i')) != -1) { + $('table > tbody').append($('').append(''+index+''+element.user+''+element.points+'')); + } + }); + } + }); + // Create pagination buttons for(var i = 1; i <= Math.ceil(data.length/perPage); i++) { var button = $('
  • ').append(''+i+''); @@ -63,8 +85,7 @@ html(lang="en") // slice(a, b): a = (n*(x-1))+1, b = n*x where n = perPage and x=curerntPage (skip +1 at end of a for splice) var a = (perPage*(z-1)), - b = perPage*z, - pstart = z-1; + b = perPage*z; data.slice(a, b).forEach(function(element, index, array){ $('table > tbody').append($('').append(''+(a+index+1)+''+element.user+''+element.points+'')); @@ -74,10 +95,11 @@ html(lang="en") $('.uk-pagination').append(button); } + // When search input is cleared, go back to first page + $('.uk-close').on('click', function(){ + $('ul.uk-pagination > li').first().click(); + }); + + // Show the first page when we load up $('ul.uk-pagination > li').first().click(); }); - - function createPaginationButton(button) { - } - -