From 04ce575c0c4204eb13fae2867f94112858144fd9 Mon Sep 17 00:00:00 2001 From: Shaunak Kishore Date: Thu, 10 Sep 2015 23:47:59 -0400 Subject: [PATCH] Hack together fraction-completed bar --- client/controls.js | 8 ++++++++ client/glyph.js | 15 +++++++++++++-- client/index.html | 6 ++++++ client/style.css | 9 ++++++++- server/glyphs.js | 4 ++++ 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/client/controls.js b/client/controls.js index a0a9edb1..b033aad9 100644 --- a/client/controls.js +++ b/client/controls.js @@ -48,6 +48,14 @@ function save_glyphs(glyphs, index) { }); } +Template.navbar.helpers({ + percent: function() { + var value = Session.get('glyph.fraction_verified'); + return Math.round(100*(value === undefined ? 0 : value)); + }, +}); + + Template.progress.helpers({ percent: function() { var value = Session.get('progress.value'); diff --git a/client/glyph.js b/client/glyph.js index 0b097140..5053feed 100644 --- a/client/glyph.js +++ b/client/glyph.js @@ -7,10 +7,12 @@ var COLORS = ['#0074D9', '#2ECC40', '#FFDC00', '#FF4136', '#7FDBFF', function change_glyph(method, glyph) { glyph = glyph || Session.get('glyph.data'); - Meteor.call(method, glyph, function(error, data) { + Meteor.call(method, glyph, function(err, data) { data = fill_glyph_fields(data); Session.set('glyph.data', data); - if (method !== 'save_glyph') { + if (method === 'save_glyph') { + refresh_fraction_verified(); + } else { Session.set('glyph.show_strokes', data.manual.verified); } }); @@ -25,6 +27,14 @@ function fill_glyph_fields(glyph) { return glyph; } +function refresh_fraction_verified() { + Meteor.call('get_fraction_verified', function(err, data) { + if (!err) { + Session.set('glyph.fraction_verified', data); + } + }); +} + window.get_glyph = function(name) { change_glyph('get_glyph', name); } @@ -243,4 +253,5 @@ Meteor.startup(function() { if (!Session.get('glyph.data')) { change_glyph('get_next_glyph'); } + refresh_fraction_verified(); }); diff --git a/client/index.html b/client/index.html index 95b938d1..7d58307d 100644 --- a/client/index.html +++ b/client/index.html @@ -14,6 +14,12 @@ + diff --git a/client/style.css b/client/style.css index b5023e94..c3dad8a6 100644 --- a/client/style.css +++ b/client/style.css @@ -7,12 +7,19 @@ color: #ffffff !important; } +.navbar .progress { + float: right; + margin-top: 21px; + margin-right: -3px; + width: 298px; +} + .btn { outline: 0 !important; padding: 6px 12px !important; } -#progress .progress { +.navbar .progress, #progress .progress { height: 18px; margin-bottom: 0; } diff --git a/server/glyphs.js b/server/glyphs.js index e67a6a5a..e1ddcf19 100644 --- a/server/glyphs.js +++ b/server/glyphs.js @@ -32,6 +32,9 @@ Meteor.methods({ return prev ? prev : Glyphs.findOne( {'manual.verified': {$ne: true}}, {sort: {name: -1}}); }, + get_fraction_verified: function() { + return Glyphs.find({'manual.verified': true}).count()/Glyphs.find().count(); + }, save_glyph: save_glyph, save_glyphs: function(glyphs) { for (var i = 0; i < glyphs.length; i++) { @@ -42,4 +45,5 @@ Meteor.methods({ Meteor.startup(function() { Glyphs._ensureIndex({name: 1}, {unique: true}); + Glyphs._ensureIndex({'manual.verified': 1}); });