String.prototype.format = String.prototype.f = function () { var s = this, i = arguments.length; while (i--) { s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]); } return s; } var mainBaseUrl = $('#baseUrl').text(); function Humanize(date) { var mNow = moment(); var mDate = moment(date).local(); return moment.duration(mNow - mDate).humanize() + (mNow.isBefore(mDate) ? ' from now' : ' ago'); } function utcToLocal(date) { return moment(date).local(); } function generateNotify(message, type) { // type = danger, warning, info, successs $.notify({ // options message: message }, { // settings type: type, animate: { enter: 'animated bounceInDown', exit: 'animated bounceOutUp' }, newest_on_top: true }); } function checkJsonResponse(response) { if (response.result === true) { return true; } else { generateNotify(response.message, "warning"); return false; } } function loadingButton(elementId, originalCss) { var $element = $('#' + elementId); $element.removeClass("btn-" + originalCss + "-outline").addClass("btn-primary-outline").addClass('disabled').html(" Loading..."); // handle split-buttons var $dropdown = $element.next('.dropdown-toggle'); if ($dropdown.length > 0) { $dropdown.removeClass("btn-" + originalCss + "-outline").addClass("btn-primary-outline").addClass('disabled'); } } function finishLoading(elementId, originalCss, html) { var $element = $('#' + elementId); $element.removeClass("btn-primary-outline").removeClass('disabled').addClass("btn-" + originalCss + "-outline").html(html); // handle split-buttons var $dropdown = $element.next('.dropdown-toggle'); if ($dropdown.length > 0) { $dropdown.removeClass("btn-primary-outline").removeClass('disabled').addClass("btn-" + originalCss + "-outline"); } } function createBaseUrl(base, url) { if (base) { if (url.charAt(0) === "/") { url = "/" + base + url; } else { url = "/" + base + "/" + url; } } return url; } var noResultsHtml = "