diff options
Diffstat (limited to 'ishtar_common/static/js/ishtar.js')
-rw-r--r-- | ishtar_common/static/js/ishtar.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index fbf1ddc17..126373b94 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -188,6 +188,21 @@ function display_info(msg){ }, 5000); } +function add_message(message, message_type){ + if (!message_type) message_type = 'info'; + + var html = $("#message_list").html(); + html += '<div class="alert alert-' + message_type + ' alert-dismissible fade show"'; + html += ' role="alert">'; + html += message; + html += ' <button type="button" class="close" data-dismiss="alert"'; + html += ' aria-label="Close">'; + html += ' <span aria-hidden="true">×</span>'; + html += ' </button>'; + html += ' </div>'; + $("#message_list").html(html); +} + function load_opened_shortcut_menu(){ load_shortcut_menu(true); } @@ -257,6 +272,39 @@ $(document).on("click", '#to_top_arrow', function(){ $("html, body").animate({ scrollTop: 0}, 1000); }); +var autorefresh = false; +var autorefresh_message_start = ""; +var autorefresh_message_end = ""; + +function startRefresh() { + if (!autorefresh) return; + autorefresh_link = $('#autorefreshpage').attr("data-link"); + autorefresh_div_id = $('#autorefreshpage').attr("data-div"); + $.get(autorefresh_link, function(data) { + $('#' + autorefresh_div_id).html(data); + }); + setTimeout(startRefresh, 10000); +} + +$(document).on("click", '#autorefreshpage', function(){ + autorefresh_div_id = $('#autorefreshpage').attr("data-div"); + if (!$(this).hasClass('disabled')) { + $(this).addClass('disabled'); + autorefresh = false; + display_info(autorefresh_message_end); + $("#" + autorefresh_div_id).find('select').prop('disabled', false); + $("#" + autorefresh_div_id).find('input').prop('disabled', false); + } else { + $(this).removeClass('disabled'); + autorefresh = true; + setTimeout(startRefresh, 10000); + display_info(autorefresh_message_start); + $("#" + autorefresh_div_id).find('select').prop('disabled', true); + $("#" + autorefresh_div_id).find('input').prop('disabled', true); + + } +}); + $(document).on("click", '.check-all', function(){ $(this).closest('table' ).find('input:checkbox' |