lib/pairing_matrix/server/public/index.js in pairing_matrix-0.1.2 vs lib/pairing_matrix/server/public/index.js in pairing_matrix-1.0

- old
+ new

@@ -1,16 +1,34 @@ $(document).ready(function () { var playground = new PlayGround(".area"); var renderMatrix = function (days) { - $.get('/data/' + days, function (data, status) { - if (status == 'success') { - playground.load(JSON.parse(data)); + hideMatrix(); + showLoader(); + $.get('/data/' + days).done(function (data) { + playground.load(JSON.parse(data)); + hideLoader(); + showMatrix(); + }).fail(function () { + alert('error occurred!'); + hideLoader(); + showMatrix(); + }); + }; - } else { - console.log(data); - alert('error occurred!') - } - }) + var hideMatrix = function () { + $('.viz_container').hide(); + }; + + var showMatrix = function () { + $('.viz_container').show(); + }; + + var hideLoader = function () { + $('.loaderContainer').hide(); + }; + + var showLoader = function () { + $('.loaderContainer').show(); }; $('#visualize').on('click', function () { renderMatrix($('#days').val()) });