You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ombi/Old/Ombi.UI/Content/site.js

112 lines
3.1 KiB

9 years ago
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;
}
8 years ago
$(function () {
$('[data-toggle="tooltip"]').tooltip();
});
var mainBaseUrl = $('#baseUrl').text();
9 years ago
function Humanize(date) {
var mNow = moment();
var mDate = moment(date).local();
return moment.duration(mNow - mDate).humanize() + (mNow.isBefore(mDate) ? ' from now' : ' ago');
}
9 years ago
function utcToLocal(date) {
return moment(date).local();
}
9 years ago
function generateNotify(message, type) {
// type = danger, warning, info, successs
8 years ago
if (!type) {
type = "success";
}
9 years ago
$.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;
}
}
8 years ago
function disableElement(element) {
element.attr("disabled", "disabled");
}
function enableElement(element) {
element.removeAttr("disabled");
}
9 years ago
function loadingButton(elementId, originalCss) {
var $element = $('#' + elementId);
$element.removeClass("btn-" + originalCss + "-outline").addClass("btn-primary-outline").addClass('disabled').html("<i class='fa fa-spinner fa-spin'></i> Loading...");
// handle split-buttons
var $dropdown = $element.next('.dropdown-toggle');
9 years ago
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');
9 years ago
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;
}
8 years ago
8 years ago
function createLocalUrl(url) {
8 years ago
var base = $('#baseUrl').text();
if (base) {
if (url.charAt(0) === "/") {
url = "/" + base + url;
} else {
url = "/" + base + "/" + url;
}
}
return url;
}
9 years ago
var noResultsHtml = "<div class='no-search-results'>" +
"<i class='fa fa-film no-search-results-icon'></i><div class='no-search-results-text'>Sorry, we didn't find any results!</div></div>";
var noResultsMusic = "<div class='no-search-results'>" +
"<i class='fa fa-headphones no-search-results-icon'></i><div class='no-search-results-text'>Sorry, we didn't find any results!</div></div>";