A Twitch.tv viewer reward and games system.
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.

105 lines
4.8 KiB

  1. doctype html
  2. html(lang="en")
  3. head
  4. title= title
  5. link(rel='stylesheet', href='/lib/uikit/css/uikit.almost-flat.min.css')
  6. link(rel='stylesheet', href='/css/app.css')
  7. script(src='/lib/jquery.js')
  8. script(src='/lib/uikit/js/uikit.min.js')
  9. body
  10. div.uk-grid
  11. div.uk-width-1-1
  12. div.uk-grid
  13. div.uk-width-1-4
  14. img(src='/img/#{logo}')
  15. div.uk-width-2-4
  16. // bigimagelogo
  17. h1.uk-text-center #{title}<br/>#{slogan}
  18. div.uk-width-1-4
  19. img.flip(src='/img/#{logo}')
  20. div.uk-width-1-1
  21. nav.uk-navbar
  22. ul.uk-navbar-nav.uk-navbar-center
  23. li: a(href='http://www.twitch.tv/#{title}'): img(src='/img/twitch.png', alt='Stream')
  24. li: a(href='/') Home
  25. li: a(href='/ladder') Ladder
  26. li: a(href='#') Chat Stats
  27. li: a(href='http://www.twitter.com/#{twitter}'): img(src='/img/twitter.gif', alt='Twitter')
  28. div.uk-width-1-1
  29. div.uk-container.uk-container-center
  30. div.uk-grid
  31. br
  32. br
  33. div.uk-width-1-1
  34. div.uk-panel.uk-panel-box
  35. div.uk-badge.uk-float-right
  36. form.uk-search
  37. input(class='uk-search-field', type='search', placeholder='Search...')
  38. button(class='uk-close', type='reset')
  39. table.uk-table.uk-table-hover.uk-table-striped
  40. caption Potato Farmer Ladder Rankings
  41. thead
  42. tr
  43. th Rank
  44. th Viewer
  45. th Potatoes
  46. tbody
  47. ul.uk-pagination
  48. script.
  49. var perPage = 50,
  50. data = !{JSON.stringify(rows)};
  51. $(document).ready(function(){
  52. // Live search of the ladder listings
  53. $('.uk-search-field').keyup(function() {
  54. var query = $(this).val();
  55. if(query.length > 2) {
  56. var temp = $('.uk-active').attr('page');
  57. $('.uk-active').removeClass('uk-active').empty().append('<a>'+temp+'</a>');
  58. $('table > tbody').empty();
  59. data.forEach(function(element, index, array) {
  60. if(element.user.search(new RegExp(query, 'i')) != -1) {
  61. $('table > tbody').append($('<tr></tr>').append('<td>'+index+'</td><td>'+element.user+'</td><td>'+element.points+'</td>'));
  62. }
  63. });
  64. }
  65. });
  66. // Create pagination buttons
  67. for(var i = 1; i <= Math.ceil(data.length/perPage); i++) {
  68. var button = $('<li page='+i+'></li>').append('<a>'+i+'</a>');
  69. button.on('click', function(){
  70. //get page
  71. var z = $(this).attr('page');
  72. // cleanup
  73. var temp = $('.uk-active').attr('page');
  74. $('.uk-active').removeClass('uk-active').empty().append('<a>'+temp+'</a>');
  75. $('table > tbody').empty();
  76. $(this).addClass('uk-active').empty().append('<span>'+z+'</span>');
  77. // 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)
  78. var a = (perPage*(z-1)),
  79. b = perPage*z;
  80. data.slice(a, b).forEach(function(element, index, array){
  81. $('table > tbody').append($('<tr></tr>').append('<td>'+(a+index+1)+'</td><td>'+element.user+'</td><td>'+element.points+'</td>'));
  82. });
  83. });
  84. $('.uk-pagination').append(button);
  85. }
  86. // When search input is cleared, go back to first page
  87. $('.uk-close').on('click', function(){
  88. $('ul.uk-pagination > li').first().click();
  89. });
  90. // Show the first page when we load up
  91. $('ul.uk-pagination > li').first().click();
  92. });