diff --git a/public/js/index.js b/public/js/index.js index 823dd87669..667f27ce46 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2302,46 +2302,75 @@ function initNavbarContentToggle() { } function initTopicbar() { - var mgrBtn = $("#manage_topic") - var editDiv = $("#topic_edit") - var viewDiv = $("#repo-topic") - var saveBtn = $("#save_topic") + var mgrBtn = $("#manage_topic"), + editDiv = $("#topic_edit"), + viewDiv = $("#repo-topic"), + saveBtn = $("#save_topic"), + topicDropdown = $('#topic_edit .dropdown'), + topicForm = $('#topic_edit.ui.form'), + topicPrompts; mgrBtn.click(function() { viewDiv.hide(); editDiv.show(); - }) + }); + + function getPrompts() { + var hidePrompt = $("div.hide#validate_prompt"), + prompts = { + countPrompt: hidePrompt.children('#count_prompt').text(), + formatPrompt: hidePrompt.children('#format_prompt').text() + }; + hidePrompt.remove(); + return prompts; + } saveBtn.click(function() { var topics = $("input[name=topics]").val(); - $.post($(this).data('link'), { + $.post(saveBtn.data('link'), { "_csrf": csrf, "topics": topics - }).success(function(res){ - if (res["status"] != "ok") { - alert(res.message); - } else { + }, function(data, textStatus, xhr){ + if (xhr.responseJSON.status === 'ok') { viewDiv.children(".topic").remove(); - if (topics.length == 0) { + if (topics.length === 0) { return } var topicArray = topics.split(","); var last = viewDiv.children("a").last(); - for (var i=0;i < topicArray.length; i++) { + for (var i=0; i < topicArray.length; i++) { $('