From 6b815840c72a9c5567406e5ab4f15f3a11c62cc4 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 3 Mar 2015 13:13:02 +0900 Subject: [PATCH] Work in progress --- client/scripts/profile.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/client/scripts/profile.js b/client/scripts/profile.js index 1aed50a..6bcdf5d 100644 --- a/client/scripts/profile.js +++ b/client/scripts/profile.js @@ -64,17 +64,19 @@ return new Handlebars.SafeString(value == this.value ? 'checked' : ''); }); - categories = { - 0: {description: 'Description1', value: -1}, - 1: {description: 'Description2', value: 0}, - 2: {description: 'Description3', value: 1}, - }; + $.getJSON('/query', _ctx.query, function(results) { + var profile = {}; + for (var i = 0, length = results.length; i < length; ++i) { + var result = results[i]; + profile[result.id] = {description: result.description, value: 0}; + } - $('#addCategory').click(function() { - addCategory($('#newCategory').val()); + $('#addCategory').click(function() { + addCategory($('#newCategory').val()); + }); + + displayCategories(); }); - - displayCategories(); } $(document).on({ @@ -82,4 +84,4 @@ ajaxStop: function() { $('#spinner').hide(); }, ready: onReady() }); -})(window.categories = window.categories || {}); +})();