diff --git a/common/lib/xmodule/xmodule/js/src/word_cloud/word_cloud_main.js b/common/lib/xmodule/xmodule/js/src/word_cloud/word_cloud_main.js index 35df8d5c81..2156a02fb0 100644 --- a/common/lib/xmodule/xmodule/js/src/word_cloud/word_cloud_main.js +++ b/common/lib/xmodule/xmodule/js/src/word_cloud/word_cloud_main.js @@ -6,13 +6,10 @@ define('WordCloudMain', ['logme'], function (logme) { WordCloudMain.prototype = { 'submitAnswer': function () { - var _this, data; - - data = { - 'student_words': [] - }; - - _this = this; + var _this = this, + data = { + 'student_words': [] + }; this.wordCloudEl.find('input.input-cloud').each(function(index, value){ data.student_words.push($(value).val()); @@ -23,13 +20,12 @@ WordCloudMain.prototype = { $.postWithPrefix( _this.ajax_url + '/' + 'submit', $.param(data), function (response) { - if ( - (response.hasOwnProperty('status') !== true) || - (typeof response.status !== 'string') || - (response.status.toLowerCase() !== 'success')) { + if (response.status !== 'success') { + logme('ERROR: ' + response.error); return; } + _this.showWordCloud(response); } ); @@ -44,6 +40,8 @@ WordCloudMain.prototype = { this.wordCloudEl.find('#input-cloud-section').hide(); + console.log('response: ', response); + words = response.top_words; maxSize = 0; @@ -67,7 +65,7 @@ WordCloudMain.prototype = { .fontSize(function (d) { var size; - size = (d.size / maxSize) * 140; + size = (d.size / maxSize) * 100; if (size < 20) { return 0; @@ -82,22 +80,32 @@ WordCloudMain.prototype = { return; function draw(words) { - var el; + var el, firstWord = false; $('#word_cloud_d3_' + _this.hash).remove(); el = $( '
' ); + el.append('