mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-19 21:03:54 -07:00
Reformated JS (#754)
This commit is contained in:
parent
243ddf337c
commit
cbbd2ebcc6
1 changed files with 26 additions and 14 deletions
|
@ -65,20 +65,24 @@ if (document.all) {
|
||||||
|
|
||||||
function imgFit(img, maxW) {
|
function imgFit(img, maxW) {
|
||||||
img.title = 'Размеры изображения: ' + img.width + ' x ' + img.height;
|
img.title = 'Размеры изображения: ' + img.width + ' x ' + img.height;
|
||||||
|
|
||||||
if (typeof (img.naturalHeight) === 'undefined') {
|
if (typeof (img.naturalHeight) === 'undefined') {
|
||||||
img.naturalHeight = img.height;
|
img.naturalHeight = img.height;
|
||||||
img.naturalWidth = img.width;
|
img.naturalWidth = img.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (img.width > maxW) {
|
if (img.width > maxW) {
|
||||||
img.height = Math.round((maxW / img.width) * img.height);
|
img.height = Math.round((maxW / img.width) * img.height);
|
||||||
img.width = maxW;
|
img.width = maxW;
|
||||||
img.title = 'Нажмите на изображение, чтобы посмотреть его в полный размер';
|
img.title = 'Нажмите на изображение, чтобы посмотреть его в полный размер';
|
||||||
img.style.cursor = 'move';
|
img.style.cursor = 'move';
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else if (img.width === maxW && img.width < img.naturalWidth) {
|
} else if (img.width === maxW && img.width < img.naturalWidth) {
|
||||||
img.height = img.naturalHeight;
|
img.height = img.naturalHeight;
|
||||||
img.width = img.naturalWidth;
|
img.width = img.naturalWidth;
|
||||||
img.title = 'Размеры изображения: ' + img.naturalWidth + ' x ' + img.naturalHeight;
|
img.title = 'Размеры изображения: ' + img.naturalWidth + ' x ' + img.naturalHeight;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -110,13 +114,16 @@ function rand(min, max) {
|
||||||
* secure transmission
|
* secure transmission
|
||||||
*/
|
*/
|
||||||
function setCookie(name, value, days, path, domain, secure) {
|
function setCookie(name, value, days, path, domain, secure) {
|
||||||
|
let expires;
|
||||||
|
|
||||||
if (days !== 'SESSION') {
|
if (days !== 'SESSION') {
|
||||||
var date = new Date();
|
let date = new Date();
|
||||||
|
|
||||||
days = days || 365;
|
days = days || 365;
|
||||||
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||||
var expires = date.toGMTString();
|
expires = date.toGMTString();
|
||||||
} else {
|
} else {
|
||||||
var expires = '';
|
expires = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
document.cookie = name + '=' + encodeURI(value) + ((expires) ? '; expires=' + expires : '') + ((path) ? '; path=' + path : ((cookiePath) ? '; path=' + cookiePath : '')) + ((domain) ? '; domain=' + domain : ((cookieDomain) ? '; domain=' + cookieDomain : '')) + ((secure) ? '; secure' : ((cookieSecure) ? '; secure' : ''));
|
document.cookie = name + '=' + encodeURI(value) + ((expires) ? '; expires=' + expires : '') + ((path) ? '; path=' + path : ((cookiePath) ? '; path=' + cookiePath : '')) + ((domain) ? '; domain=' + domain : ((cookieDomain) ? '; domain=' + cookieDomain : '')) + ((secure) ? '; secure' : ((cookieSecure) ? '; secure' : ''));
|
||||||
|
@ -127,7 +134,7 @@ function setCookie(name, value, days, path, domain, secure) {
|
||||||
* or null if cookie does not exist.
|
* or null if cookie does not exist.
|
||||||
*/
|
*/
|
||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
var c, RE = new RegExp('(^|;)\\s*' + name + '\\s*=\\s*([^\\s;]+)', 'g');
|
let c, RE = new RegExp('(^|;)\\s*' + name + '\\s*=\\s*([^\\s;]+)', 'g');
|
||||||
return (c = RE.exec(document.cookie)) ? c[2] : null;
|
return (c = RE.exec(document.cookie)) ? c[2] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,17 +182,21 @@ var Menu = {
|
||||||
|
|
||||||
setLocation: function () {
|
setLocation: function () {
|
||||||
var CSS = this.$root.offset();
|
var CSS = this.$root.offset();
|
||||||
|
|
||||||
CSS.top += this.$root.height() + this.offsetCorrection_Y;
|
CSS.top += this.$root.height() + this.offsetCorrection_Y;
|
||||||
var curTop = parseInt(CSS.top);
|
var curTop = parseInt(CSS.top);
|
||||||
var tCorner = $(document).scrollTop() + $(window).height() - 20;
|
var tCorner = $(document).scrollTop() + $(window).height() - 20;
|
||||||
var maxVisibleTop = Math.min(curTop, Math.max(0, tCorner - this.$menu.height()));
|
var maxVisibleTop = Math.min(curTop, Math.max(0, tCorner - this.$menu.height()));
|
||||||
|
|
||||||
if (curTop !== maxVisibleTop) {
|
if (curTop !== maxVisibleTop) {
|
||||||
CSS.top = maxVisibleTop;
|
CSS.top = maxVisibleTop;
|
||||||
}
|
}
|
||||||
CSS.left += this.offsetCorrection_X;
|
CSS.left += this.offsetCorrection_X;
|
||||||
|
|
||||||
var curLeft = parseInt(CSS.left);
|
var curLeft = parseInt(CSS.left);
|
||||||
var rCorner = $(document).scrollLeft() + $(window).width() - 6;
|
var rCorner = $(document).scrollLeft() + $(window).width() - 6;
|
||||||
var maxVisibleLeft = Math.min(curLeft, Math.max(0, rCorner - this.$menu.width()));
|
var maxVisibleLeft = Math.min(curLeft, Math.max(0, rCorner - this.$menu.width()));
|
||||||
|
|
||||||
if (curLeft !== maxVisibleLeft) {
|
if (curLeft !== maxVisibleLeft) {
|
||||||
CSS.left = maxVisibleLeft;
|
CSS.left = maxVisibleLeft;
|
||||||
}
|
}
|
||||||
|
@ -197,12 +208,15 @@ var Menu = {
|
||||||
var curLeft = parseInt($menu.css('left'));
|
var curLeft = parseInt($menu.css('left'));
|
||||||
var rCorner = $(document).scrollLeft() + $(window).width() - 6;
|
var rCorner = $(document).scrollLeft() + $(window).width() - 6;
|
||||||
var maxVisibleLeft = Math.min(curLeft, Math.max(0, rCorner - $menu.width()));
|
var maxVisibleLeft = Math.min(curLeft, Math.max(0, rCorner - $menu.width()));
|
||||||
|
|
||||||
if (curLeft !== maxVisibleLeft) {
|
if (curLeft !== maxVisibleLeft) {
|
||||||
$menu.css('left', maxVisibleLeft);
|
$menu.css('left', maxVisibleLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
var curTop = parseInt($menu.css('top'));
|
var curTop = parseInt($menu.css('top'));
|
||||||
var tCorner = $(document).scrollTop() + $(window).height() - 20;
|
var tCorner = $(document).scrollTop() + $(window).height() - 20;
|
||||||
var maxVisibleTop = Math.min(curTop, Math.max(0, tCorner - $menu.height()));
|
var maxVisibleTop = Math.min(curTop, Math.max(0, tCorner - $menu.height()));
|
||||||
|
|
||||||
if (curTop !== maxVisibleTop) {
|
if (curTop !== maxVisibleTop) {
|
||||||
$menu.css('top', maxVisibleTop);
|
$menu.css('top', maxVisibleTop);
|
||||||
}
|
}
|
||||||
|
@ -463,9 +477,7 @@ $(document).ready(function () {
|
||||||
**/
|
**/
|
||||||
var array_for_rand_pass = ["a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F", "g", "G", "h", "H", "i", "I", "j", "J", "k", "K", "l", "L", "m", "M", "n", "N", "o", "O", "p", "P", "q", "Q", "r", "R", "s", "S", "t", "T", "u", "U", "v", "V", "w", "W", "x", "X", "y", "Y", "z", "Z", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
var array_for_rand_pass = ["a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F", "g", "G", "h", "H", "i", "I", "j", "J", "k", "K", "l", "L", "m", "M", "n", "N", "o", "O", "p", "P", "q", "Q", "r", "R", "s", "S", "t", "T", "u", "U", "v", "V", "w", "W", "x", "X", "y", "Y", "z", "Z", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||||
var array_rand = function (array) {
|
var array_rand = function (array) {
|
||||||
var array_length = array.length;
|
return Math.floor(Math.random() * array.length);
|
||||||
var result = Math.random() * array_length;
|
|
||||||
return Math.floor(result);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var autocomplete = function (noCenter) {
|
var autocomplete = function (noCenter) {
|
||||||
|
@ -474,8 +486,8 @@ var autocomplete = function (noCenter) {
|
||||||
string_result += array_for_rand_pass[array_rand(array_for_rand_pass)];
|
string_result += array_for_rand_pass[array_rand(array_for_rand_pass)];
|
||||||
}
|
}
|
||||||
|
|
||||||
var _popup_left = (Math.ceil(window.screen.availWidth / 2) - 150);
|
let _popup_left = (Math.ceil(window.screen.availWidth / 2) - 150);
|
||||||
var _popup_top = (Math.ceil(window.screen.availHeight / 2) - 50);
|
let _popup_top = (Math.ceil(window.screen.availHeight / 2) - 50);
|
||||||
|
|
||||||
if (!noCenter) {
|
if (!noCenter) {
|
||||||
$("div#autocomplete_popup").css({
|
$("div#autocomplete_popup").css({
|
||||||
|
@ -496,8 +508,8 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
// перемещение окна
|
// перемещение окна
|
||||||
var _X, _Y;
|
let _X, _Y;
|
||||||
var _bMoveble = false;
|
let _bMoveble = false;
|
||||||
|
|
||||||
$("div#autocomplete_popup div.title").mousedown(function (event) {
|
$("div#autocomplete_popup div.title").mousedown(function (event) {
|
||||||
_bMoveble = true;
|
_bMoveble = true;
|
||||||
|
@ -506,9 +518,9 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
$("div#autocomplete_popup div.title").mousemove(function (event) {
|
$("div#autocomplete_popup div.title").mousemove(function (event) {
|
||||||
var jFrame = $("div#autocomplete_popup");
|
let jFrame = $("div#autocomplete_popup");
|
||||||
var jFLeft = parseInt(jFrame.css("left"));
|
let jFLeft = parseInt(jFrame.css("left"));
|
||||||
var jFTop = parseInt(jFrame.css("top"));
|
let jFTop = parseInt(jFrame.css("top"));
|
||||||
|
|
||||||
if (_bMoveble) {
|
if (_bMoveble) {
|
||||||
if (event.clientX < _X) {
|
if (event.clientX < _X) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue