let Utility = {}; Utility.delay = function(milliseconds) { return new Promise(resolve => setTimeout(resolve, milliseconds)); } Utility.meta = function(key) { return $("meta[name=" + key + "]").attr("content"); } Utility.test_max_width = function(width) { if (!window.matchMedia) { return false; } var mq = window.matchMedia('(max-width: ' + width + 'px)'); return mq.matches; } Utility.notice_timeout_id = undefined; Utility.notice = function(msg, permanent) { $('#notice').addClass("ui-state-highlight").removeClass("ui-state-error").fadeIn("fast").children("span").html(msg); if (Utility.notice_timeout_id !== undefined) { clearTimeout(Utility.notice_timeout_id) } if (!permanent) { Utility.notice_timeout_id = setTimeout(function() { $("#close-notice-link").click(); Utility.notice_timeout_id = undefined; }, 6000); } } Utility.error = function(msg) { $('#notice').removeClass("ui-state-highlight").addClass("ui-state-error").fadeIn("fast").children("span").html(msg); if (Utility.notice_timeout_id !== undefined) { clearTimeout(Utility.notice_timeout_id) } } Utility.dialog = function(title, html) { const $dialog = $(html).dialog({ title: title, width: 700, modal: true, close: function() { // Defer removing the dialog to avoid detaching the