mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
get headroom from bower
This commit is contained in:
parent
77e3111ad1
commit
27c3bdc042
58 changed files with 1224 additions and 3803 deletions
|
@ -1,53 +1,4 @@
|
|||
// Regular Expressions for parsing tags and attributes
|
||||
var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
|
||||
// Match everything outside of normal chars and " (quote character)
|
||||
NON_ALPHANUMERIC_REGEXP = /([^\#-~| |!])/g;
|
||||
|
||||
var hiddenPre = document.createElement("pre");
|
||||
/**
|
||||
* decodes all entities into regular string
|
||||
* @param value
|
||||
* @returns {string} A string with decoded entities.
|
||||
*/
|
||||
function htmlDecode(value) {
|
||||
if (!value) { return ''; }
|
||||
|
||||
hiddenPre.innerHTML = value.replace(/</g, "<");
|
||||
// innerText depends on styling as it doesn't display hidden elements.
|
||||
// Therefore, it's better to use textContent not to cause unnecessary reflows.
|
||||
return hiddenPre.textContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes all potentially dangerous characters, so that the
|
||||
* resulting string can be safely inserted into attribute or
|
||||
* element text.
|
||||
* @param value
|
||||
* @returns {string} escaped text
|
||||
*/
|
||||
function htmlEncode(value) {
|
||||
return value.
|
||||
replace(/&/g, '&').
|
||||
replace(SURROGATE_PAIR_REGEXP, function (value) {
|
||||
var hi = value.charCodeAt(0);
|
||||
var low = value.charCodeAt(1);
|
||||
return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';';
|
||||
}).
|
||||
replace(NON_ALPHANUMERIC_REGEXP, function (value) {
|
||||
return '&#' + value.charCodeAt(0) + ';';
|
||||
}).
|
||||
replace(/</g, '<').
|
||||
replace(/>/g, '>');
|
||||
}
|
||||
|
||||
// Array Remove - By John Resig (MIT Licensed)
|
||||
Array.prototype.remove = function (from, to) {
|
||||
var rest = this.slice((to || from) + 1 || this.length);
|
||||
this.length = from < 0 ? this.length + from : from;
|
||||
return this.push.apply(this, rest);
|
||||
};
|
||||
|
||||
$.fn.checked = function (value) {
|
||||
$.fn.checked = function (value) {
|
||||
if (value === true || value === false) {
|
||||
// Set the value of the checkbox
|
||||
return $(this).each(function () {
|
||||
|
@ -59,99 +10,6 @@ $.fn.checked = function (value) {
|
|||
}
|
||||
};
|
||||
|
||||
$.fn.buttonEnabled = function (enabled) {
|
||||
|
||||
return enabled ? this.attr('disabled', '').removeAttr('disabled') : this.attr('disabled', 'disabled');
|
||||
};
|
||||
|
||||
if (!Array.prototype.filter) {
|
||||
Array.prototype.filter = function (fun /*, thisp*/) {
|
||||
"use strict";
|
||||
|
||||
if (this == null)
|
||||
throw new TypeError();
|
||||
|
||||
var t = Object(this);
|
||||
var len = t.length >>> 0;
|
||||
if (typeof fun != "function")
|
||||
throw new TypeError();
|
||||
|
||||
var res = [];
|
||||
var thisp = arguments[1];
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (i in t) {
|
||||
var val = t[i]; // in case fun mutates this
|
||||
if (fun.call(thisp, val, i, t))
|
||||
res.push(val);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* Javascript Humane Dates
|
||||
* Copyright (c) 2008 Dean Landolt (deanlandolt.com)
|
||||
* Re-write by Zach Leatherman (zachleat.com)
|
||||
*
|
||||
* Adopted from the John Resig's pretty.js
|
||||
* at http://ejohn.org/blog/javascript-pretty-date
|
||||
* and henrah's proposed modification
|
||||
* at http://ejohn.org/blog/javascript-pretty-date/#comment-297458
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
function humane_date(date_str) {
|
||||
var time_formats = [[90, 'a minute'], // 60*1.5
|
||||
[3600, 'minutes', 60], // 60*60, 60
|
||||
[5400, 'an hour'], // 60*60*1.5
|
||||
[86400, 'hours', 3600], // 60*60*24, 60*60
|
||||
[129600, 'a day'], // 60*60*24*1.5
|
||||
[604800, 'days', 86400], // 60*60*24*7, 60*60*24
|
||||
[907200, 'a week'], // 60*60*24*7*1.5
|
||||
[2628000, 'weeks', 604800], // 60*60*24*(365/12), 60*60*24*7
|
||||
[3942000, 'a month'], // 60*60*24*(365/12)*1.5
|
||||
[31536000, 'months', 2628000], // 60*60*24*365, 60*60*24*(365/12)
|
||||
[47304000, 'a year'], // 60*60*24*365*1.5
|
||||
[3153600000, 'years', 31536000] // 60*60*24*365*100, 60*60*24*365
|
||||
];
|
||||
|
||||
var dt = new Date;
|
||||
var date = parseISO8601Date(date_str, { toLocal: true });
|
||||
|
||||
var seconds = ((dt - date) / 1000);
|
||||
var token = ' ago';
|
||||
var i = 0;
|
||||
var format;
|
||||
|
||||
if (seconds < 0) {
|
||||
seconds = Math.abs(seconds);
|
||||
token = '';
|
||||
}
|
||||
|
||||
while (format = time_formats[i++]) {
|
||||
if (seconds < format[0]) {
|
||||
if (format.length == 2) {
|
||||
return format[1] + token;
|
||||
} else {
|
||||
return Math.round(seconds / format[2]) + ' ' + format[1] + token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// overflow for centuries
|
||||
if (seconds > 4730400000)
|
||||
return Math.round(seconds / 4730400000) + ' centuries' + token;
|
||||
|
||||
return date_str;
|
||||
}
|
||||
|
||||
function getWindowUrl(win) {
|
||||
return (win || window).location.href;
|
||||
}
|
||||
|
||||
function getWindowLocationSearch(win) {
|
||||
|
||||
var search = (win || window).location.search;
|
||||
|
@ -252,13 +110,4 @@ function parseISO8601Date(s, options) {
|
|||
}
|
||||
|
||||
return new Date(ms);
|
||||
}
|
||||
|
||||
// This only exists because the polymer elements get distorted when using regular jquery show/hide
|
||||
$.fn.visible = function (visible) {
|
||||
|
||||
if (visible) {
|
||||
return this.removeClass('hide');
|
||||
}
|
||||
return this.addClass('hide');
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue