From df9e311f2ba9170444c91353e6c5644e6012744c Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 2 Mar 2015 14:24:07 +0900 Subject: [PATCH] Templating work --- client/profile.html | 86 ++++++++++----------------------------- client/scripts/profile.js | 30 ++++++++++++++ 2 files changed, 51 insertions(+), 65 deletions(-) diff --git a/client/profile.html b/client/profile.html index d905c3c..0e2c441 100644 --- a/client/profile.html +++ b/client/profile.html @@ -25,80 +25,36 @@ Rating - - Now is the time for all good men - - - - - - - - Now is the time for all good men - - - - - - + + +
- +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/client/scripts/profile.js b/client/scripts/profile.js index 156c910..7d7c206 100644 --- a/client/scripts/profile.js +++ b/client/scripts/profile.js @@ -20,4 +20,34 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +(function(hscd) { + 'use strict'; + function displayCategories(categories) { + var template = Handlebars.compile($('#template').html()); + $('#categories').empty(); + $('#categories').append(template({categories: categories})); + } + + function onReady() { + Handlebars.registerHelper('checkMatch', function(value, options) { + return new Handlebars.SafeString( + value == this.value ? 'checked' : '' + ); + }); + + var categories = [ + {description: 'Description1', id: 0, value: -1}, + {description: 'Description2', id: 1, value: 0}, + {description: 'Description3', id: 2, value: 1}, + ]; + + displayCategories(categories); + } + + $(document).on({ + ajaxStart: function() { $('#spinner').show(); }, + ajaxStop: function() { $('#spinner').hide(); }, + ready: onReady() + }); +})();