PHP 7+ and some notices fix in admin control panel

This commit is contained in:
Yuriy Pikhtarev 2017-01-13 00:29:08 +03:00
commit e3f4a8a445
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
52 changed files with 3581 additions and 262 deletions

2
.gitignore vendored
View file

@ -2,7 +2,6 @@
.idea .idea
bower_components bower_components
composer.phar composer.phar
composer.lock
configs/local.php configs/local.php
data/avatars data/avatars
data/torrent_files data/torrent_files
@ -21,7 +20,6 @@ vendor
*.zip *.zip
*.rar *.rar
*.tar *.tar
*.gz
*.torrent *.torrent
### Windows ### ### Windows ###

View file

@ -43,7 +43,7 @@ TorrentPier - движок торрент-трекера, написанный
## Необходимая версия php ## Необходимая версия php
Минимально поддерживаемой версией в настоящий момент является 5.5. Существует поддержка вплоть до версии 7.0. Минимально поддерживаемой версией в настоящий момент является 7.0. Существует поддержка вплоть до версии 7.1.
## Необходимые настройки php ## Необходимые настройки php

View file

@ -73,7 +73,7 @@ foreach ($forum_auth_fields as $auth_type) {
$forum_auth_levels = ['ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN']; $forum_auth_levels = ['ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN'];
$forum_auth_const = [AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN]; $forum_auth_const = [AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN];
if ($_REQUEST[POST_FORUM_URL]) { if (isset($_REQUEST[POST_FORUM_URL])) {
$forum_id = (int)$_REQUEST[POST_FORUM_URL]; $forum_id = (int)$_REQUEST[POST_FORUM_URL];
$forum_sql = "WHERE forum_id = $forum_id"; $forum_sql = "WHERE forum_id = $forum_id";
} else { } else {

View file

@ -56,7 +56,7 @@ $default_forum_auth = [
'auth_download' => AUTH_REG, 'auth_download' => AUTH_REG,
]; ];
$mode = ($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : ''; $mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
$cat_forums = get_cat_forums(); $cat_forums = get_cat_forums();

View file

@ -53,7 +53,7 @@ $last_session_id = (int)$last_session_data['rebuild_session_id'];
$max_post_id = get_latest_post_id(); $max_post_id = get_latest_post_id();
$start_time = TIMENOW; $start_time = TIMENOW;
$mode = (string)$_REQUEST['mode']; $mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
// check if the user has choosen to stop processing // check if the user has choosen to stop processing
if (isset($_REQUEST['cancel_button'])) { if (isset($_REQUEST['cancel_button'])) {
@ -70,7 +70,7 @@ if (isset($_REQUEST['cancel_button'])) {
} }
// from which post to start processing // from which post to start processing
$start = abs(intval($_REQUEST['start'])); $start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0;
// get the total number of posts in the db // get the total number of posts in the db
$total_posts = get_total_posts(); $total_posts = get_total_posts();
@ -86,7 +86,7 @@ $session_posts_processed = ($mode == 'refresh') ? get_processed_posts('session')
$total_posts_processing = $total_posts - $total_posts_processed; $total_posts_processing = $total_posts - $total_posts_processed;
// how many posts to process in this session // how many posts to process in this session
if ($session_posts_processing = intval($_REQUEST['session_posts_processing'])) { if (isset($_REQUEST['session_posts_processing']) && $session_posts_processing = intval($_REQUEST['session_posts_processing'])) {
if ($mode == 'submit') { if ($mode == 'submit') {
// check if we passed over total_posts just after submitting // check if we passed over total_posts just after submitting
if ($session_posts_processing + $total_posts_processed > $total_posts) { if ($session_posts_processing + $total_posts_processed > $total_posts) {

View file

@ -41,6 +41,7 @@ if (isset($_POST['mode']) || isset($_GET['mode'])) {
} }
$delimeter = '=+:'; $delimeter = '=+:';
$s_hidden_fields = '';
// Read a listing of uploaded smilies for use in the add or edit smliey code // Read a listing of uploaded smilies for use in the add or edit smliey code
$dir = opendir(BB_ROOT . $di->config->get('smilies_path')); $dir = opendir(BB_ROOT . $di->config->get('smilies_path'));

View file

@ -37,10 +37,10 @@ require(INC_DIR . 'functions_group.php');
$yes_sign = '√'; $yes_sign = '√';
$no_sign = 'x'; $no_sign = 'x';
$group_id = (int)$_REQUEST['g']; $group_id = isset($_REQUEST['g']) ? (int)$_REQUEST['g'] : null;
$user_id = (int)$_REQUEST['u']; $user_id = isset($_REQUEST['u']) ? (int)$_REQUEST['u'] : null;
$cat_id = (int)$_REQUEST['c']; $cat_id = isset($_REQUEST['c']) ? (int)$_REQUEST['c'] : null;
$mode = (string)$_REQUEST['mode']; $mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
$submit = isset($_POST['submit']); $submit = isset($_POST['submit']);
$group_data = array(); $group_data = array();

View file

@ -125,36 +125,6 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$users_per_day = $total_users; $users_per_day = $total_users;
} }
// DB size ... MySQL only
$sql = "SELECT VERSION() AS mysql_version";
if ($result = DB()->sql_query($sql)) {
$row = DB()->sql_fetchrow($result);
$version = $row['mysql_version'];
if (preg_match('/^(3\.23|4\.|5\.|10\.)/', $version)) {
$dblist = array();
foreach ($di->config->get('db') as $name => $row) {
$sql = "SHOW TABLE STATUS FROM {$row[1]}";
if ($result = DB()->sql_query($sql)) {
$tabledata_ary = DB()->sql_fetchrowset($result);
$dbsize = 0;
for ($i = 0; $i < count($tabledata_ary); $i++) {
if ($tabledata_ary[$i]['Type'] != 'MRG_MYISAM') {
$dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length'];
}
}
$dblist[] = '<span title="' . $name . '">' . humn_size($dbsize) . '</span>';
}
}
$dbsize = implode('&nbsp;|&nbsp;', $dblist);
} else {
$dbsize = $lang['NOT_AVAILABLE'];
}
} else {
$dbsize = $lang['NOT_AVAILABLE'];
}
$template->assign_vars(array( $template->assign_vars(array(
'NUMBER_OF_POSTS' => $total_posts, 'NUMBER_OF_POSTS' => $total_posts,
'NUMBER_OF_TOPICS' => $total_topics, 'NUMBER_OF_TOPICS' => $total_topics,
@ -164,14 +134,11 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
'TOPICS_PER_DAY' => $topics_per_day, 'TOPICS_PER_DAY' => $topics_per_day,
'USERS_PER_DAY' => $users_per_day, 'USERS_PER_DAY' => $users_per_day,
'AVATAR_DIR_SIZE' => $avatar_dir_size, 'AVATAR_DIR_SIZE' => $avatar_dir_size,
'DB_SIZE' => $dbsize,
'GZIP_COMPRESSION' => ($di->config->get('gzip_compress')) ? $lang['ON'] : $lang['OFF'],
'TP_VERSION' => $di->config->get('tp_version') . (!empty($di->config->get('tp_release_state')) ? ' :: ' . $di->config->get('tp_release_state') : ''), 'TP_VERSION' => $di->config->get('tp_version') . (!empty($di->config->get('tp_release_state')) ? ' :: ' . $di->config->get('tp_release_state') : ''),
'TP_RELEASE_DATE' => $di->config->get('tp_release_date'), 'TP_RELEASE_DATE' => $di->config->get('tp_release_date'),
'ZF_VERSION' => Zend\Version\Version::VERSION,
)); ));
if ($_GET['users_online']) { if (isset($_GET['users_online'])) {
$template->assign_vars(array( $template->assign_vars(array(
'SHOW_USERS_ONLINE' => true, 'SHOW_USERS_ONLINE' => true,
)); ));

View file

@ -20,7 +20,7 @@
"docs": "https://faq.torrentpier.me/" "docs": "https://faq.torrentpier.me/"
}, },
"require": { "require": {
"php": "^5.5 || ^7.0", "php": "^7.0",
"google/recaptcha": "^1.0", "google/recaptcha": "^1.0",
"monolog/monolog": "^1.18", "monolog/monolog": "^1.18",
"pimple/pimple": "^3.0", "pimple/pimple": "^3.0",
@ -44,8 +44,8 @@
"doctrine/cache": "^1.6" "doctrine/cache": "^1.6"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "4.8.*", "phpunit/phpunit": "^5.0",
"squizlabs/php_codesniffer": "2.5.*", "squizlabs/php_codesniffer": "2.6.*",
"sebastian/phpcpd": "2.0.*" "sebastian/phpcpd": "2.0.*"
}, },
"autoload": { "autoload": {

3369
composer.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -209,11 +209,10 @@ function generate_smilies($mode)
} }
/** /**
* Strips away [quote] tags and their contents from the specified string * Strips away [quote] tags and their contents from the specified string.
* *
* @param string Text to be stripped of quote tags * @param string $text Text to be stripped of quote tags
* * @return string
* @return string
*/ */
function strip_quotes($text) function strip_quotes($text)
{ {
@ -293,17 +292,16 @@ function strip_quotes($text)
} }
/** /**
* Strips away bbcode from a given string, leaving plain text * Strips away bbcode from a given string, leaving plain text.
* *
* @param string Text to be stripped of bbcode tags * @param string $message Text to be stripped of bbcode tags
* @param bool $stripquotes * @param bool $stripquotes
* @param bool $fast_and_dirty * @param bool $fast_and_dirty
* @param bool $showlinks * @param bool $showlinks
* *
* @return string * @return mixed|string
* @internal param \If $boolean true, strip away quote tags AND their contents * @internal param \If $boolean true, strip away quote tags AND their contents
* @internal param \If $boolean true, use the fast-and-dirty method rather than the shiny and nice method * @internal param \If $boolean true, use the fast-and-dirty method rather than the shiny and nice method
*
*/ */
function strip_bbcode($message, $stripquotes = true, $fast_and_dirty = false, $showlinks = true) function strip_bbcode($message, $stripquotes = true, $fast_and_dirty = false, $showlinks = true)
{ {

View file

@ -125,7 +125,7 @@ function get_tracks($type)
trigger_error(__FUNCTION__ . ": invalid type '$type'", E_USER_ERROR); trigger_error(__FUNCTION__ . ": invalid type '$type'", E_USER_ERROR);
} }
$tracks = !empty($_COOKIE[$c_name]) ? unserialize($_COOKIE[$c_name]) : false; $tracks = !empty($_COOKIE[$c_name]) ? unserialize($_COOKIE[$c_name]) : false;
return ($tracks) ? $tracks : array(); return ($tracks) ? $tracks : [];
} }
/** /**
@ -358,13 +358,13 @@ function setbit(&$int, $bit_num, $on)
* @param int $group_perm * @param int $group_perm
* @return array|mixed * @return array|mixed
*/ */
function auth($type, $forum_id, $ug_data, $f_access = array(), $group_perm = UG_PERM_BOTH) function auth($type, $forum_id, $ug_data, $f_access = [], $group_perm = UG_PERM_BOTH)
{ {
global $lang, $bf, $datastore; global $lang, $bf, $datastore;
$is_guest = true; $is_guest = true;
$is_admin = false; $is_admin = false;
$auth = $auth_fields = $u_access = array(); $auth = $auth_fields = $u_access = [];
$add_auth_type_desc = ($forum_id != AUTH_LIST_ALL); $add_auth_type_desc = ($forum_id != AUTH_LIST_ALL);
// //
@ -544,10 +544,9 @@ class Date_Delta
31363200 => 'mday', // 12 months 31363200 => 'mday', // 12 months
311040000 => 'mon', // 10 years 311040000 => 'mon', // 10 years
); );
public $intervals = array(); public $intervals = [];
public $format = ''; public $format = '';
// Creates new object.
/** /**
* Date_Delta constructor. * Date_Delta constructor.
*/ */
@ -559,8 +558,9 @@ class Date_Delta
$this->format = $lang['DELTA_TIME']['FORMAT']; $this->format = $lang['DELTA_TIME']['FORMAT'];
} }
// Makes the spellable phrase.
/** /**
* Makes the spellable phrase.
*
* @param $first * @param $first
* @param $last * @param $last
* @param string $from * @param string $from
@ -587,12 +587,12 @@ class Date_Delta
// Solve data delta. // Solve data delta.
$delta = $this->getDelta($first, $last); $delta = $this->getDelta($first, $last);
if (!$delta) { if (empty($delta)) {
return false; return false;
} }
// Make spellable phrase. // Make spellable phrase.
$parts = array(); $parts = [];
$intervals = $GLOBALS['lang']['DELTA_TIME']['INTERVALS']; $intervals = $GLOBALS['lang']['DELTA_TIME']['INTERVALS'];
foreach (array_reverse($delta) as $k => $n) { foreach (array_reverse($delta) as $k => $n) {
@ -613,16 +613,17 @@ class Date_Delta
return join(' ', $parts); return join(' ', $parts);
} }
// returns the associative array with date deltas.
/** /**
* Returns the associative array with date deltas.
*
* @param $first * @param $first
* @param $last * @param $last
* @return bool * @return array
*/ */
public function getDelta($first, $last) public function getDelta($first, $last)
{ {
if ($last < $first) { if ($last < $first) {
return false; return [];
} }
// Solve H:M:S part. // Solve H:M:S part.
@ -662,8 +663,9 @@ class Date_Delta
return $delta; return $delta;
} }
// Returns the length (in days) of the specified month.
/** /**
* Returns the length (in days) of the specified month.
*
* @param $year * @param $year
* @param $mon * @param $mon
* @return int * @return int
@ -698,7 +700,8 @@ function delta_time($timestamp_1, $timestamp_2 = TIMENOW, $granularity = 'auto')
*/ */
function get_select($select, $selected = null, $return_as = 'html', $first_opt = '&raquo;&raquo; Выбрать ') function get_select($select, $selected = null, $return_as = 'html', $first_opt = '&raquo;&raquo; Выбрать ')
{ {
$select_ary = array(); $select_name = '';
$select_ary = [];
switch ($select) { switch ($select) {
case 'groups': case 'groups':
@ -725,10 +728,10 @@ function get_select($select, $selected = null, $return_as = 'html', $first_opt =
class html_common class html_common
{ {
public $options = ''; public $options = '';
public $attr = array(); public $attr = [];
public $cur_attr = null; public $cur_attr = null;
public $max_length = HTML_SELECT_MAX_LENGTH; public $max_length = HTML_SELECT_MAX_LENGTH;
public $selected = array(); public $selected = [];
/** /**
* @param $name * @param $name
@ -749,7 +752,7 @@ class html_common
$this->selected = array_flip((array)$selected); $this->selected = array_flip((array)$selected);
$this->max_length = $max_length; $this->max_length = $max_length;
$this->attr = array(); $this->attr = [];
$this->cur_attr =& $this->attr; $this->cur_attr =& $this->attr;
if (isset($params['__attributes'])) { if (isset($params['__attributes'])) {
@ -1019,8 +1022,8 @@ function commify($number)
*/ */
function humn_size($size, $rounder = null, $min = null, $space = '&nbsp;') function humn_size($size, $rounder = null, $min = null, $space = '&nbsp;')
{ {
static $sizes = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); static $sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
static $rounders = array(0, 0, 0, 2, 3, 3, 3, 3, 3); static $rounders = [0, 0, 0, 2, 3, 3, 3, 3, 3];
$size = (float)$size; $size = (float)$size;
$ext = $sizes[0]; $ext = $sizes[0];
@ -1152,7 +1155,7 @@ function set_var(&$result, $var, $type, $multibyte = false, $strip = true)
$result = $var; $result = $var;
if ($type == 'string') { if ($type == 'string') {
$result = trim(htmlspecialchars(str_replace(array("\r\n", "\r"), array("\n", "\n"), $result))); $result = trim(htmlspecialchars(str_replace(["\r\n", "\r"], ["\n", "\n"], $result)));
if (!empty($result)) { if (!empty($result)) {
// Make sure multibyte characters are wellformed // Make sure multibyte characters are wellformed
@ -1181,15 +1184,17 @@ function set_var(&$result, $var, $type, $multibyte = false, $strip = true)
*/ */
function request_var($var_name, $default, $multibyte = false, $cookie = false) function request_var($var_name, $default, $multibyte = false, $cookie = false)
{ {
$key_type = $sub_key_type = $sub_type = '';
if (!$cookie && isset($_COOKIE[$var_name])) { if (!$cookie && isset($_COOKIE[$var_name])) {
if (!isset($_GET[$var_name]) && !isset($_POST[$var_name])) { if (!isset($_GET[$var_name]) && !isset($_POST[$var_name])) {
return (is_array($default)) ? array() : $default; return (is_array($default)) ? [] : $default;
} }
$_REQUEST[$var_name] = isset($_POST[$var_name]) ? $_POST[$var_name] : $_GET[$var_name]; $_REQUEST[$var_name] = isset($_POST[$var_name]) ? $_POST[$var_name] : $_GET[$var_name];
} }
if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name]))) { if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name]))) {
return (is_array($default)) ? array() : $default; return (is_array($default)) ? [] : $default;
} }
$var = $_REQUEST[$var_name]; $var = $_REQUEST[$var_name];
@ -1211,7 +1216,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
if (is_array($var)) { if (is_array($var)) {
$_var = $var; $_var = $var;
$var = array(); $var = [];
foreach ($_var as $k => $v) { foreach ($_var as $k => $v) {
set_var($k, $k, $key_type); set_var($k, $k, $key_type);
@ -1244,10 +1249,10 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
function get_username($user_id) function get_username($user_id)
{ {
if (empty($user_id)) { if (empty($user_id)) {
return is_array($user_id) ? array() : false; return is_array($user_id) ? [] : false;
} }
if (is_array($user_id)) { if (is_array($user_id)) {
$usernames = array(); $usernames = [];
foreach (DB()->fetch_rowset("SELECT user_id, username FROM " . BB_USERS . " WHERE user_id IN(" . get_id_csv($user_id) . ")") as $row) { foreach (DB()->fetch_rowset("SELECT user_id, username FROM " . BB_USERS . " WHERE user_id IN(" . get_id_csv($user_id) . ")") as $row) {
$usernames[$row['user_id']] = $row['username']; $usernames[$row['user_id']] = $row['username'];
} }
@ -1421,7 +1426,7 @@ function bb_get_config($table, $from_db = false, $update_cache = true)
*/ */
function bb_update_config($params, $table = BB_CONFIG) function bb_update_config($params, $table = BB_CONFIG)
{ {
$updates = array(); $updates = [];
foreach ($params as $name => $val) { foreach ($params as $name => $val) {
$updates[] = array( $updates[] = array(
'config_name' => $name, 'config_name' => $name,
@ -1618,7 +1623,7 @@ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = n
if (is_null($max_length)) { if (is_null($max_length)) {
$max_length = HTML_SELECT_MAX_LENGTH; $max_length = HTML_SELECT_MAX_LENGTH;
} }
$select = is_null($all_forums_option) ? array() : array($lang['ALL_AVAILABLE'] => $all_forums_option); $select = is_null($all_forums_option) ? [] : array($lang['ALL_AVAILABLE'] => $all_forums_option);
if (!$forums = $datastore->get('cat_forums')) { if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums'); $datastore->update('cat_forums');
$forums = $datastore->get('cat_forums'); $forums = $datastore->get('cat_forums');
@ -2571,7 +2576,7 @@ function get_title_match_topics($search)
/** @var \TorrentPier\Di $di */ /** @var \TorrentPier\Di $di */
$di = \TorrentPier\Di::getInstance(); $di = \TorrentPier\Di::getInstance();
$where_ids = array(); $where_ids = [];
$forum_ids = (isset($search['ids']) && is_array($search['ids'])) ? array_diff($search['ids'], array(0 => 0)) : ''; $forum_ids = (isset($search['ids']) && is_array($search['ids'])) ? array_diff($search['ids'], array(0 => 0)) : '';
$title_match_sql = encode_text_match($search['query']); $title_match_sql = encode_text_match($search['query']);

View file

@ -33,8 +33,8 @@ if (!defined('BB_CFG_LOADED')) {
trigger_error('File config.php not loaded', E_USER_ERROR); trigger_error('File config.php not loaded', E_USER_ERROR);
} }
if (PHP_VERSION < '5.5') { if (PHP_VERSION < '7.0') {
die('TorrentPier requires PHP version 5.5 and above (ZF requirement). Your PHP version is ' . PHP_VERSION); die('TorrentPier requires PHP version 7.0 and above (new code technique and packages requirement). Your PHP version is ' . PHP_VERSION);
} }
/** @var \TorrentPier\Di $di */ /** @var \TorrentPier\Di $di */

View file

@ -1589,7 +1589,6 @@ $lang['CREATE_PROFILE'] = 'Create profile';
$lang['TP_VERSION'] = 'TorrentPier version'; $lang['TP_VERSION'] = 'TorrentPier version';
$lang['TP_RELEASE_DATE'] = 'Release date'; $lang['TP_RELEASE_DATE'] = 'Release date';
$lang['ZF_VERSION'] = 'Zend Framework version';
$lang['PHP_INFO'] = 'Information about PHP'; $lang['PHP_INFO'] = 'Information about PHP';
$lang['CLICK_RETURN_ADMIN_INDEX'] = 'Click %sHere%s to return to the Admin Index'; $lang['CLICK_RETURN_ADMIN_INDEX'] = 'Click %sHere%s to return to the Admin Index';
@ -1602,8 +1601,6 @@ $lang['NUMBER_USERS'] = 'Number of users';
$lang['USERS_PER_DAY'] = 'Users per day'; $lang['USERS_PER_DAY'] = 'Users per day';
$lang['BOARD_STARTED'] = 'Board started'; $lang['BOARD_STARTED'] = 'Board started';
$lang['AVATAR_DIR_SIZE'] = 'Avatar directory size'; $lang['AVATAR_DIR_SIZE'] = 'Avatar directory size';
$lang['DATABASE_SIZE'] = 'Database size';
$lang['GZIP_COMPRESSION'] = 'Gzip compression';
$lang['NOT_AVAILABLE'] = 'Not available'; $lang['NOT_AVAILABLE'] = 'Not available';
// Clear Cache // Clear Cache

View file

@ -1589,7 +1589,6 @@ $lang['CREATE_PROFILE'] = 'Создать аккаунт';
$lang['TP_VERSION'] = 'Версия TorrentPier'; $lang['TP_VERSION'] = 'Версия TorrentPier';
$lang['TP_RELEASE_DATE'] = 'Дата выпуска'; $lang['TP_RELEASE_DATE'] = 'Дата выпуска';
$lang['ZF_VERSION'] = 'Версия Zend Framework';
$lang['PHP_INFO'] = 'Информация о PHP'; $lang['PHP_INFO'] = 'Информация о PHP';
$lang['CLICK_RETURN_ADMIN_INDEX'] = '%sВернуться на главную страницу администраторского раздела%s'; $lang['CLICK_RETURN_ADMIN_INDEX'] = '%sВернуться на главную страницу администраторского раздела%s';
@ -1602,8 +1601,6 @@ $lang['NUMBER_USERS'] = 'Кол-во пользователей';
$lang['USERS_PER_DAY'] = 'Пользователей в день'; $lang['USERS_PER_DAY'] = 'Пользователей в день';
$lang['BOARD_STARTED'] = 'Дата запуска'; $lang['BOARD_STARTED'] = 'Дата запуска';
$lang['AVATAR_DIR_SIZE'] = 'Размер директории с аватарами'; $lang['AVATAR_DIR_SIZE'] = 'Размер директории с аватарами';
$lang['DATABASE_SIZE'] = 'Объем БД';
$lang['GZIP_COMPRESSION'] = 'сжатие Gzip';
$lang['NOT_AVAILABLE'] = 'Недоступно'; $lang['NOT_AVAILABLE'] = 'Недоступно';
// Clear Cache // Clear Cache

View file

@ -1589,7 +1589,6 @@ $lang['CREATE_PROFILE'] = 'Створити акаунт';
$lang['TP_VERSION'] = 'Версія TorrentPier'; $lang['TP_VERSION'] = 'Версія TorrentPier';
$lang['TP_RELEASE_DATE'] = 'Дата випуску'; $lang['TP_RELEASE_DATE'] = 'Дата випуску';
$lang['ZF_VERSION'] = 'Версія Zend Framework';
$lang['PHP_INFO'] = 'Інформація про PHP'; $lang['PHP_INFO'] = 'Інформація про PHP';
$lang['CLICK_RETURN_ADMIN_INDEX'] = '%sВернуться на головну сторінку адміністраторського розділу%s'; $lang['CLICK_RETURN_ADMIN_INDEX'] = '%sВернуться на головну сторінку адміністраторського розділу%s';
@ -1602,8 +1601,6 @@ $lang['NUMBER_USERS'] = 'Кількість користувачів';
$lang['USERS_PER_DAY'] = 'Користувачів'; $lang['USERS_PER_DAY'] = 'Користувачів';
$lang['BOARD_STARTED'] = 'Дата запуску'; $lang['BOARD_STARTED'] = 'Дата запуску';
$lang['AVATAR_DIR_SIZE'] = 'Розмір директорії з аватарами'; $lang['AVATAR_DIR_SIZE'] = 'Розмір директорії з аватарами';
$lang['DATABASE_SIZE'] = "Об'єм БД";
$lang['GZIP_COMPRESSION'] = 'стискання Gzip';
$lang['NOT_AVAILABLE'] = 'Недоступне'; $lang['NOT_AVAILABLE'] = 'Недоступне';
// Clear Cache // Clear Cache

View file

@ -91,7 +91,7 @@ BBCode.prototype = {
} else { } else {
return [null, null]; return [null, null];
} }
if (text == '') text = this.stext; if (text === '') text = this.stext;
text = "" + text; text = "" + text;
text = text.replace("/^\s+|\s+$/g", ""); text = text.replace("/^\s+|\s+$/g", "");
return [text, range]; return [text, range];
@ -134,20 +134,20 @@ BBCode.prototype = {
var rt = this.getSelection(); var rt = this.getSelection();
var text = rt[0]; var text = rt[0];
var range = rt[1]; var range = rt[1];
if (text == null) return false; if (text === null) return false;
var notEmpty = text != null && text != ''; var notEmpty = text !== null && text !== '';
// Surround // Surround
if (range) { if (range) {
var notEmpty = text != null && text != ''; var notEmpty = text !== null && text !== '';
var newText = open + fTrans(text) + (close ? close : ''); var newText = open + fTrans(text) + (close ? close : '');
range.text = newText; range.text = newText;
range.collapse(); range.collapse();
if (text != '') { if (text !== '') {
// Correction for stupid IE: \r for moveStart is 0 character // Correction for stupid IE: \r for moveStart is 0 character
var delta = 0; var delta = 0;
for (var i = 0; i < newText.length; i++) if (newText.charAt(i) == '\r') delta++; for (var i = 0; i < newText.length; i++) if (newText.charAt(i) === '\r') delta++;
range.moveStart("character", -close.length - text.length - open.length + delta); range.moveStart("character", -close.length - text.length - open.length + delta);
range.moveEnd("character", -0); range.moveEnd("character", -0);
} else { } else {
@ -163,7 +163,7 @@ BBCode.prototype = {
var sel = fTrans(t.value.substr(start, end - start)); var sel = fTrans(t.value.substr(start, end - start));
var inner = open + sel + close; var inner = open + sel + close;
t.value = sel1 + inner + sel2; t.value = sel1 + inner + sel2;
if (sel != '') { if (sel !== '') {
t.setSelectionRange(start, start + inner.length); t.setSelectionRange(start, start + inner.length);
notEmpty = true; notEmpty = true;
} else { } else {
@ -199,21 +199,21 @@ BBCode.prototype = {
// Pressed control key? // Pressed control key?
if (tag.ctrlKey && !e[tag.ctrlKey + "Key"]) continue; if (tag.ctrlKey && !e[tag.ctrlKey + "Key"]) continue;
// Pressed needed key? // Pressed needed key?
if (!tag.key || key.toUpperCase() != tag.key.toUpperCase()) continue; if (!tag.key || key.toUpperCase() !== tag.key.toUpperCase()) continue;
// Insert // Insert
if (e.type == "keydown") this.insertTag(id); if (e.type === "keydown") this.insertTag(id);
// Reset event // Reset event
return this._cancelEvent(e); return this._cancelEvent(e);
} }
// Tab // Tab
if (type == 'press' && e.keyCode == this.VK_TAB && !e.shiftKey && !e.ctrlKey && !e.altKey) { if (type === 'press' && e.keyCode === this.VK_TAB && !e.shiftKey && !e.ctrlKey && !e.altKey) {
this.insertAtCursor('[tab]'); this.insertAtCursor('[tab]');
return this._cancelEvent(e); return this._cancelEvent(e);
} }
// Ctrl+Tab // Ctrl+Tab
if (e.keyCode == this.VK_TAB && !e.shiftKey && e.ctrlKey && !e.altKey) { if (e.keyCode === this.VK_TAB && !e.shiftKey && e.ctrlKey && !e.altKey) {
this.textarea.form.post.focus(); this.textarea.form.post.focus();
return this._cancelEvent(e); return this._cancelEvent(e);
} }
@ -221,9 +221,9 @@ BBCode.prototype = {
// Hot keys // Hot keys
var form = this.textarea.form; var form = this.textarea.form;
var submitter = null; var submitter = null;
if (e.keyCode == this.VK_ENTER && !e.shiftKey && !e.ctrlKey && e.altKey) if (e.keyCode === this.VK_ENTER && !e.shiftKey && !e.ctrlKey && e.altKey)
submitter = form.preview; submitter = form.preview;
if (e.keyCode == this.VK_ENTER && !e.shiftKey && e.ctrlKey && !e.altKey) if (e.keyCode === this.VK_ENTER && !e.shiftKey && e.ctrlKey && !e.altKey)
submitter = form.post; submitter = form.post;
if (submitter) { if (submitter) {
submitter.click(); submitter.click();
@ -249,13 +249,13 @@ BBCode.prototype = {
var elt = tag.elt; var elt = tag.elt;
if (elt) { if (elt) {
var th = this; var th = this;
if (elt.type && elt.type.toUpperCase() == "BUTTON") { if (elt.type && elt.type.toUpperCase() === "BUTTON") {
addEvent(elt, 'click', function () { addEvent(elt, 'click', function () {
th.insertTag(id); th.insertTag(id);
return false; return false;
}); });
} }
if (elt.tagName && elt.tagName.toUpperCase() == "SELECT") { if (elt.tagName && elt.tagName.toUpperCase() === "SELECT") {
addEvent(elt, 'change', function () { addEvent(elt, 'change', function () {
th.insertTag(id); th.insertTag(id);
return false; return false;
@ -263,7 +263,7 @@ BBCode.prototype = {
} }
} }
else { else {
if (id && id.indexOf('_') != 0) return alert("addTag('" + id + "'): no such element in the form"); if (id && id.indexOf('_') !== 0) return alert("addTag('" + id + "'): no such element in the form");
} }
}, },
@ -275,12 +275,12 @@ BBCode.prototype = {
// Open tag is generated by callback? // Open tag is generated by callback?
var op = tag.open; var op = tag.open;
if (typeof(tag.open) == "function") op = tag.open(tag.elt); if (typeof(tag.open) === "function") op = tag.open(tag.elt);
var cl = tag.close != null ? tag.close : "/" + op; var cl = tag.close !== null ? tag.close : "/" + op;
// Use "[" if needed // Use "[" if needed
if (op.charAt(0) != this.BRK_OP) op = this.BRK_OP + op + this.BRK_CL; if (op.charAt(0) !== this.BRK_OP) op = this.BRK_OP + op + this.BRK_CL;
if (cl && cl.charAt(0) != this.BRK_OP) cl = this.BRK_OP + cl + this.BRK_CL; if (cl && cl.charAt(0) !== this.BRK_OP) cl = this.BRK_OP + cl + this.BRK_CL;
this.surround(op, cl, !tag.multiline ? null : tag.multiline === true ? this._prepareMultiline : tag.multiline); this.surround(op, cl, !tag.multiline ? null : tag.multiline === true ? this._prepareMultiline : tag.multiline);
}, },
@ -440,7 +440,7 @@ function initMedia(context) {
var apostLink = $('a.postLink', context); var apostLink = $('a.postLink', context);
for (var i = 0; i < apostLink.length; i++) { for (var i = 0; i < apostLink.length; i++) {
var link = apostLink[i]; var link = apostLink[i];
if (typeof link.href != 'string') { if (typeof link.href !== 'string') {
continue; continue;
} }
if (/^http(?:s|):\/\/www.youtube.com\/watch\?(.*)?(&?v=([a-z0-9\-_]+))(.*)?|http:\/\/youtu.be\/.+/i.test(link.href)) { if (/^http(?:s|):\/\/www.youtube.com\/watch\?(.*)?(&?v=([a-z0-9\-_]+))(.*)?|http:\/\/youtu.be\/.+/i.test(link.href)) {
@ -449,7 +449,7 @@ function initMedia(context) {
a.innerHTML = '<span title="' + bbl['play_on'] + '" class="YTLinkButton">&#9658;</span>'; a.innerHTML = '<span title="' + bbl['play_on'] + '" class="YTLinkButton">&#9658;</span>';
window.addEvent(a, 'click', function (e) { window.addEvent(a, 'click', function (e) {
var vhref = e.target.nextSibling.href.replace(/^http(?:s|):\/\/www.youtube.com\/watch\?(.*)?(&?v=([a-z0-9\-_]+))(.*)?|http:\/\/youtu.be\//ig, "http://www.youtube.com/embed/$3"); var vhref = e.target.nextSibling.href.replace(/^http(?:s|):\/\/www.youtube.com\/watch\?(.*)?(&?v=([a-z0-9\-_]+))(.*)?|http:\/\/youtu.be\//ig, "http://www.youtube.com/embed/$3");
var text = e.target.nextSibling.innerText != "" ? e.target.nextSibling.innerText : e.target.nextSibling.href; var text = e.target.nextSibling.innerText !== "" ? e.target.nextSibling.innerText : e.target.nextSibling.href;
$('#Panel_youtube').remove(); $('#Panel_youtube').remove();
ypanel('youtube', { ypanel('youtube', {
title: '<b>' + text + '</b>', title: '<b>' + text + '</b>',

View file

@ -2,9 +2,9 @@ function $p() {
var elements = []; var elements = [];
for (var i = 0; i < arguments.length; i++) { for (var i = 0; i < arguments.length; i++) {
var element = arguments[i]; var element = arguments[i];
if (typeof element == 'string') if (typeof element === 'string')
element = document.getElementById(element); element = document.getElementById(element);
if (arguments.length == 1) if (arguments.length === 1)
return element; return element;
elements.push(element); elements.push(element);
} }
@ -43,7 +43,7 @@ var EventCache = function () {
if (item[0].removeEventListener) { if (item[0].removeEventListener) {
item[0].removeEventListener(item[1], item[2], item[3]); item[0].removeEventListener(item[1], item[2], item[3]);
} }
if (item[1].substring(0, 2) != "on") { if (item[1].substring(0, 2) !== "on") {
item[1] = "on" + item[1]; item[1] = "on" + item[1];
} }
if (item[0].detachEvent) { if (item[0].detachEvent) {
@ -60,7 +60,7 @@ 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;
} }
@ -71,7 +71,7 @@ function imgFit(img, maxW) {
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;
@ -84,7 +84,7 @@ function imgFit(img, maxW) {
function toggle_block(id) { function toggle_block(id) {
var el = document.getElementById(id); var el = document.getElementById(id);
el.style.display = (el.style.display == 'none') ? '' : 'none'; el.style.display = (el.style.display === 'none') ? '' : 'none';
} }
function toggle_disabled(id, val) { function toggle_disabled(id, val) {
@ -107,7 +107,7 @@ function rand(min, max) {
* secure transmission * secure transmission
*/ */
function setCookie(name, value, days, path, domain, secure) { function setCookie(name, value, days, path, domain, secure) {
if (days != 'SESSION') { if (days !== 'SESSION') {
var date = new Date(); var 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);
@ -183,14 +183,14 @@ var Menu = {
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;
} }
this.$menu.css(CSS); this.$menu.css(CSS);
@ -201,13 +201,13 @@ 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);
} }
}, },
@ -387,7 +387,7 @@ Ajax.prototype = {
event.stopPropagation(); event.stopPropagation();
var params = ajax.params[$(this).attr('id')]; var params = ajax.params[$(this).attr('id')];
var action = params.action; var action = params.action;
if (ajax.state[action] == 'readyToSubmit' || ajax.state[action] == 'error') { if (ajax.state[action] === 'readyToSubmit' || ajax.state[action] === 'error') {
return false; return false;
} else { } else {
ajax.state[action] = 'readyToSubmit'; ajax.state[action] = 'readyToSubmit';
@ -408,13 +408,13 @@ Ajax.prototype = {
var inputsHtml = $('#editable-tpl-' + editableType).html(); var inputsHtml = $('#editable-tpl-' + editableType).html();
$editable.hide().after(inputsHtml); $editable.hide().after(inputsHtml);
var $inputs = $('.editable-inputs', $root); var $inputs = $('.editable-inputs', $root);
if (editableType == 'input' || editableType == 'textarea') { if (editableType === 'input' || editableType === 'textarea') {
$('.editable-value', $inputs).val($.trim($editable.text())); $('.editable-value', $inputs).val($.trim($editable.text()));
} }
$('input.editable-submit', $inputs).click(function () { $('input.editable-submit', $inputs).click(function () {
var params = ajax.params[rootElementId]; var params = ajax.params[rootElementId];
var $val = $('.editable-value', '#' + rootElementId); var $val = $('.editable-value', '#' + rootElementId);
params.value = ($val.size() == 1) ? $val.val() : $val.filter(':checked').val(); params.value = ($val.size() === 1) ? $val.val() : $val.filter(':checked').val();
params.submit = true; params.submit = true;
ajax.init[params.action](params); ajax.init[params.action](params);
}); });
@ -454,7 +454,7 @@ $(document).ready(function () {
$("#ajax-error").ajaxError(function (req, xml) { $("#ajax-error").ajaxError(function (req, xml) {
var status = xml.status; var status = xml.status;
var text = xml.statusText; var text = xml.statusText;
if (status == 200) { if (status === 200) {
status = ''; status = '';
text = 'неверный формат данных'; text = 'неверный формат данных';
} }
@ -470,7 +470,7 @@ $(document).ready(function () {
params.event = params.event || 'dblclick'; params.event = params.event || 'dblclick';
ajax.params[params.id] = params; ajax.params[params.id] = params;
$("#" + params.id).bind(params.event, ajax.callInitFn); $("#" + params.id).bind(params.event, ajax.callInitFn);
if (params.event == 'click' || params.event == 'dblclick') { if (params.event === 'click' || params.event === 'dblclick') {
$("#" + params.id).addClass('editable-container'); $("#" + params.id).addClass('editable-container');
} }
}); });

View file

@ -4,7 +4,7 @@
<script type="text/javascript"> <script type="text/javascript">
function toggle_cat_list (val) function toggle_cat_list (val)
{ {
if (val == -1) { if (val === -1) {
$p('cat_list').className = ''; $p('cat_list').className = '';
$p('show_on_index').className = 'hidden'; $p('show_on_index').className = 'hidden';
} }
@ -172,7 +172,7 @@ table.forumline + table.forumline { border-top-width: 0; }
<script type="text/javascript"> <script type="text/javascript">
function hl (id, on) function hl (id, on)
{ {
$p(id).style.color = (on == 1) ? '#FF4500' : ''; $p(id).style.color = (on === 1) ? '#FF4500' : '';
} }
</script> </script>

View file

@ -18,7 +18,7 @@ function update_clear_search(myselect)
// enable/disable radio buttons // enable/disable radio buttons
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
document.rebuild.clear_search[i].disabled = ( myselect.options[myselect.selectedIndex].value != 0 ); document.rebuild.clear_search[i].disabled = ( myselect.options[myselect.selectedIndex].value !== 0 );
} }
swap_values(); swap_values();
@ -126,7 +126,7 @@ function updateButton()
{ {
if ( ticker >= 0) if ( ticker >= 0)
{ {
if ( ticker == 0 ) if ( ticker === 0 )
{ {
document.form_rebuild_progress.submit_button.value = label; document.form_rebuild_progress.submit_button.value = label;
document.form_rebuild_progress.submit_button.disabled = true; document.form_rebuild_progress.submit_button.disabled = true;

View file

@ -66,7 +66,7 @@ ajax.sitemap = function(mode) {
}); });
}; };
ajax.callback.sitemap = function(data) { ajax.callback.sitemap = function(data) {
if(data.mode == 'create') $('#mess_time').html(data.html); if(data.mode === 'create') $('#mess_time').html(data.html);
else $('#sitemap').html(data.html); else $('#sitemap').html(data.html);
} }
</script> </script>

View file

@ -202,7 +202,7 @@ function flip_perm (f_id, acl_id)
var cb = $p('cb_' + id); var cb = $p('cb_' + id);
var td = $p('td_' + id); var td = $p('td_' + id);
if (cb.value == 1) { if (cb.value === 1) {
cb.value = 0; cb.value = 0;
td.className = 'no'; td.className = 'no';
td.innerHTML = '{NO_SIGN}'; td.innerHTML = '{NO_SIGN}';
@ -221,7 +221,7 @@ function flip_mod (f_id, acl_id)
var cb = $p('cb_' + id); var cb = $p('cb_' + id);
var td = $p('td_' + id); var td = $p('td_' + id);
if (cb.value == 1) { if (cb.value === 1) {
cb.value = 0; cb.value = 0;
td.className = 'noMOD'; td.className = 'noMOD';
td.innerHTML = '{L_NO}'; td.innerHTML = '{L_NO}';
@ -239,7 +239,7 @@ function hl (f_id, acl_id, on)
var ac = $p('type_' + acl_id); var ac = $p('type_' + acl_id);
var fn = $p('fname_' + f_id); var fn = $p('fname_' + f_id);
if (on == 1) { if (on === 1) {
ac.style.color = fn.style.color = '#FF4500'; ac.style.color = fn.style.color = '#FF4500';
} else { } else {
ac.style.color = fn.style.color = '#000000'; ac.style.color = fn.style.color = '#000000';

View file

@ -142,10 +142,6 @@ ajax.callback.manage_admin = function(data) {
<td class="row1" nowrap="nowrap" width="25%">{L_TP_RELEASE_DATE}:</td> <td class="row1" nowrap="nowrap" width="25%">{L_TP_RELEASE_DATE}:</td>
<td class="row2"><b>{TP_RELEASE_DATE}</b></td> <td class="row2"><b>{TP_RELEASE_DATE}</b></td>
</tr> </tr>
<tr>
<td class="row1" nowrap="nowrap" width="25%">{L_ZF_VERSION}:</td>
<td class="row2"><b>{ZF_VERSION}</b></td>
</tr>
</table> </table>
<br /> <br />
@ -182,12 +178,6 @@ ajax.callback.manage_admin = function(data) {
<td class="row1" nowrap="nowrap">{L_AVATAR_DIR_SIZE}:</td> <td class="row1" nowrap="nowrap">{L_AVATAR_DIR_SIZE}:</td>
<td class="row2"><b>{AVATAR_DIR_SIZE}</b></td> <td class="row2"><b>{AVATAR_DIR_SIZE}</b></td>
</tr> </tr>
<tr>
<td class="row1" nowrap="nowrap">{L_DATABASE_SIZE}:</td>
<td class="row2"><b>{DB_SIZE}</b></td>
<td class="row1" nowrap="nowrap">{L_GZIP_COMPRESSION}:</td>
<td class="row2"><b>{GZIP_COMPRESSION}</b></td>
</tr>
</table> </table>
<br /> <br />

View file

@ -7,7 +7,7 @@ function manage_group(mode, value) {
value : value value : value
}); });
ajax.callback.manage_group = function(data) { ajax.callback.manage_group = function(data) {
if (data.act == 0) $('div#avatar').hide(100); if (data.act === 0) $('div#avatar').hide(100);
console.log(data); console.log(data);
} }
} }

View file

@ -20,7 +20,7 @@ function qs_highlight_found ()
this.style.display = ''; this.style.display = '';
var a = $('a:first', this); var a = $('a:first', this);
var q = $('#q-search').val().toLowerCase(); var q = $('#q-search').val().toLowerCase();
if (q != '' && a.text().toLowerCase().indexOf(q) != -1) { if (q !== '' && a.text().toLowerCase().indexOf(q) !== -1) {
a.html(a.text().replace(q, '<b style="color:#1515ff">' + q + '</b>')); a.html(a.text().replace(q, '<b style="color:#1515ff">' + q + '</b>'));
} }
else { else {

View file

@ -6,16 +6,16 @@
<meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Style-Type" content="text/css" />
<meta property="og:image" content="{SITE_URL}styles/images/logo/logo.png" /> <meta property="og:image" content="{SITE_URL}styles/images/logo/logo.png" />
{META} {META}
<link rel="stylesheet" href="{STYLESHEET}?v={$di->config->get('css_ver')}" type="text/css"> <link rel="stylesheet" href="{STYLESHEET}" type="text/css">
<link rel="shortcut icon" href="{SITE_URL}favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="{SITE_URL}favicon.ico" type="image/x-icon">
<link rel="search" type="application/opensearchdescription+xml" href="{SITE_URL}opensearch_desc.xml" title="{SITENAME} (Forum)" /> <link rel="search" type="application/opensearchdescription+xml" href="{SITE_URL}opensearch_desc.xml" title="{SITENAME} (Forum)" />
<link rel="search" type="application/opensearchdescription+xml" href="{SITE_URL}opensearch_desc_bt.xml" title="{SITENAME} (Tracker)" /> <link rel="search" type="application/opensearchdescription+xml" href="{SITE_URL}opensearch_desc_bt.xml" title="{SITENAME} (Tracker)" />
<script type="text/javascript" src="{SITE_URL}styles/js/jquery.pack.js?v={$di->config->get('js_ver')}"></script> <script type="text/javascript" src="{SITE_URL}styles/js/jquery.pack.js"></script>
<script type="text/javascript" src="{SITE_URL}styles/js/main.js?v={$di->config->get('js_ver')}"></script> <script type="text/javascript" src="{SITE_URL}styles/js/main.js"></script>
<!-- IF INCLUDE_BBCODE_JS --> <!-- IF INCLUDE_BBCODE_JS -->
<script type="text/javascript" src="{SITE_URL}styles/js/bbcode.js?v={$di->config->get('js_ver')}"></script> <script type="text/javascript" src="{SITE_URL}styles/js/bbcode.js"></script>
<script type="text/javascript"> <script type="text/javascript">
window.BB = {}; window.BB = {};
window.encURL = encodeURIComponent; window.encURL = encodeURIComponent;
@ -236,7 +236,7 @@ function go_to_page ()
<b>{L_OLD_BROWSER}</b> <b>{L_OLD_BROWSER}</b>
</div> </div>
<script> <script>
if ( (typeof(window.opera) != "undefined" && window.opera.version() < 12) || (window.attachEvent && !window.addEventListener) /* IE < 9 */ ) { if ( (typeof(window.opera) !== "undefined" && window.opera.version() < 12) || (window.attachEvent && !window.addEventListener) /* IE < 9 */ ) {
document.getElementById('old-browser-warn').style.display = ''; document.getElementById('old-browser-warn').style.display = '';
} }
</script> </script>
@ -288,7 +288,7 @@ ajax.callback.index_data = function(data) {};
$(document).ready(function() { $(document).ready(function() {
x = new Date(); x = new Date();
tz = -x.getTimezoneOffset()/60; tz = -x.getTimezoneOffset()/60;
if (tz != {BOARD_TIMEZONE}) if (tz !== {BOARD_TIMEZONE})
{ {
ajax.index_data(tz); ajax.index_data(tz);
} }
@ -304,7 +304,7 @@ $(document).ready(function() {
</td> </td>
<td style="padding: 3px;"> <td style="padding: 3px;">
<div> <div>
<form id="quick-search" action="" method="get" onsubmit="$(this).attr('action', $('#search-action').val()); if($('#search-action option:selected').attr('class') == 'hash') $('#search-text').attr('name', 'hash');"> <form id="quick-search" action="" method="get" onsubmit="$(this).attr('action', $('#search-action').val()); if($('#search-action option:selected').attr('class') === 'hash') $('#search-text').attr('name', 'hash');">
<input type="hidden" name="max" value="1" /> <input type="hidden" name="max" value="1" />
<input type="hidden" name="to" value="1" /> <input type="hidden" name="to" value="1" />
<input id="search-text" type="text" name="nm" placeholder="{L_SEARCH_S}" required /> <input id="search-text" type="text" name="nm" placeholder="{L_SEARCH_S}" required />

View file

@ -122,7 +122,7 @@ function dis_submit_btn ()
function debounce (el_id, time_ms) function debounce (el_id, time_ms)
{ {
var $el = $('#'+el_id); var $el = $('#'+el_id);
if ( $el.attr('disabled') == false ) { if ( $el.attr('disabled') === false ) {
$el.attr('disabled', 1); $el.attr('disabled', 1);
setTimeout(function(){ $el.attr('disabled', 0); }, time_ms); setTimeout(function(){ $el.attr('disabled', 0); }, time_ms);
} }
@ -130,7 +130,7 @@ function debounce (el_id, time_ms)
$('#post-submit-btn').click(function(event){ $('#post-submit-btn').click(function(event){
<!-- IF TOR_REQUIRED --> <!-- IF TOR_REQUIRED -->
if ( $('#file-up-btn').val() == '' ) { if ( $('#file-up-btn').val() === '' ) {
event.stopPropagation(); event.stopPropagation();
alert('Вы забыли прикрепить торрент файл (кликните "загрузить файл")'); alert('Вы забыли прикрепить торрент файл (кликните "загрузить файл")');
$('#file-up-a').removeClass('med').addClass('adm').animate({fontSize: '24px'}, 200).animate({fontSize: '16px'}, 200); $('#file-up-a').removeClass('med').addClass('adm').animate({fontSize: '24px'}, 200).animate({fontSize: '16px'}, 200);
@ -162,7 +162,7 @@ function checkForm(form) {
if(form.message.value.length < 100 && submitted) if(form.message.value.length < 100 && submitted)
{ {
setTimeout(function() { setTimeout(function() {
if ($('input[name="notify"]').attr('checked') == 'checked') { if ($('input[name="notify"]').attr('checked') === 'checked') {
var notify = 1; var notify = 1;
} }

View file

@ -3,7 +3,7 @@ function emoticon(text) {
text = ' ' + text + ' '; text = ' ' + text + ' ';
if (opener.document.forms['post'].message.createTextRange && opener.document.forms['post'].message.caretPos) { if (opener.document.forms['post'].message.createTextRange && opener.document.forms['post'].message.caretPos) {
var caretPos = opener.document.forms['post'].message.caretPos; var caretPos = opener.document.forms['post'].message.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) === ' ' ? text + ' ' : text;
opener.document.forms['post'].message.focus(); opener.document.forms['post'].message.focus();
} else { } else {
opener.document.forms['post'].message.value += text; opener.document.forms['post'].message.value += text;

View file

@ -131,17 +131,17 @@ var FSN = {
$('#fs-sel-cat').bind('change', function(){ $('#fs-sel-cat').bind('change', function(){
var i = $(this).val(); var i = $(this).val();
if (FSN.sel_width == null) { if (FSN.sel_width === null) {
FSN.sel_width = $select.width() + 4; FSN.sel_width = $select.width() + 4;
} }
if (i == 'all') { if (i === 'all') {
var fs_html = FSN.fs_all; var fs_html = FSN.fs_all;
} }
else { else {
var fs_html = '<optgroup label="'+ FSN.fs_lb[i] +'">'+ FSN.fs_og[i] +'</optgroup>'; var fs_html = '<optgroup label="'+ FSN.fs_lb[i] +'">'+ FSN.fs_og[i] +'</optgroup>';
} }
$select.html(fs_html).focus(); $select.html(fs_html).focus();
if (i == 'all') { if (i === 'all') {
$('#fs-nav-menu').show(); $('#fs-nav-menu').show();
} }
else { else {
@ -486,7 +486,7 @@ $(function(){
$('#fs-main').bind('change', function(){ $('#fs-main').bind('change', function(){
var fs_val = $('#fs-main').val(); var fs_val = $('#fs-main').val();
if (fs_val != null) { if (fs_val !== null) {
if (fs_val.length > {MAX_FS}) { if (fs_val.length > {MAX_FS}) {
alert('{L_MAX_FS}'); alert('{L_MAX_FS}');
$('#fs-main').val( fs_last_val ); $('#fs-main').val( fs_last_val );
@ -513,7 +513,7 @@ function get_fs_link ()
var fs_url = '{TRACKER_URL}'; var fs_url = '{TRACKER_URL}';
var fs_val = $('#fs-main').val(); var fs_val = $('#fs-main').val();
if (fs_val == null) { if (fs_val === null) {
alert('{L_NOT_SEL_CHAPTERS}'); alert('{L_NOT_SEL_CHAPTERS}');
} }
else { else {

View file

@ -89,7 +89,7 @@ function tte_submit (mode)
var $tt_td = $('#tte-'+topic_id); var $tt_td = $('#tte-'+topic_id);
var topic_title = $('.tt-edit-input', $tt_td).val(); var topic_title = $('.tt-edit-input', $tt_td).val();
if (mode == 'save') { if (mode === 'save') {
ajax.edit_topic_title(topic_id, topic_title); ajax.edit_topic_title(topic_id, topic_title);
} }
else { else {
@ -119,9 +119,9 @@ function mod_action (mode)
alert('{L_NONE_SELECTED}'); alert('{L_NONE_SELECTED}');
return false; return false;
} }
if(mode == 'tor_status'){ if(mode === 'tor_status'){
status = $('#st option:selected').val(); status = $('#st option:selected').val();
if(status == '-1'){ if(status === '-1'){
alert('{L_TOR_STATUS_NOT_SELECT}'); alert('{L_TOR_STATUS_NOT_SELECT}');
return false; return false;
} }

View file

@ -17,7 +17,7 @@
<script type="text/javascript"> <script type="text/javascript">
ajax.open_edit = false; ajax.open_edit = false;
function edit_post(post_id, type, text) { function edit_post(post_id, type, text) {
if(ajax.open_edit && ajax.open_edit != post_id) { if(ajax.open_edit && ajax.open_edit !== post_id) {
alert('{L_AJAX_EDIT_OPEN}'); alert('{L_AJAX_EDIT_OPEN}');
} else{ } else{
if(ajax.open_edit && !text){ if(ajax.open_edit && !text){
@ -49,7 +49,7 @@ ajax.callback.posts = function(data) {
} }
if(data.redirect) document.location.href = data.redirect; if(data.redirect) document.location.href = data.redirect;
if(data.hide) { if(data.hide) {
if(ajax.open_edit == data.post_id) ajax.open_edit = false; if(ajax.open_edit === data.post_id) ajax.open_edit = false;
$('tbody#post_'+ data.post_id).hide(); $('tbody#post_'+ data.post_id).hide();
} }
if(data.quote) $('textarea#message').attr('value', $('textarea#message').val() + data.message +' ').focus(); if(data.quote) $('textarea#message').attr('value', $('textarea#message').val() + data.message +' ').focus();
@ -71,7 +71,7 @@ function set_hid_chbox (id)
$('#del_split_row').show(); $('#del_split_row').show();
// set checkbox value // set checkbox value
$('#cb_'+id).val( $('#cb_'+id).val() == id ? 0 : id ); $('#cb_'+id).val( $('#cb_'+id).val() === id ? 0 : id );
// highlight selected post // highlight selected post
$('#post_'+id+' td').toggleClass('hl-selected-post'); $('#post_'+id+' td').toggleClass('hl-selected-post');
@ -89,14 +89,14 @@ function set_hid_chbox (id)
var $tt_td = $('.maintitle'); var $tt_td = $('.maintitle');
function edit_topic_title (mode) function edit_topic_title (mode)
{ {
if (mode == 'edit') { if (mode === 'edit') {
var tt_text = $tt_td.find('.tt-text').text(); var tt_text = $tt_td.find('.tt-text').text();
ajax.tte_orig_html = $tt_td.html(); ajax.tte_orig_html = $tt_td.html();
$tt_td.html( $('#tt-edit-tpl').html() ); $tt_td.html( $('#tt-edit-tpl').html() );
$('.tt-edit-input', $tt_td).val(tt_text).focus(); $('.tt-edit-input', $tt_td).val(tt_text).focus();
} }
else if (mode == 'save') { else if (mode === 'save') {
var topic_title = $('.tt-edit-input', $tt_td).val(); var topic_title = $('.tt-edit-input', $tt_td).val();
ajax.edit_topic_title(topic_title); ajax.edit_topic_title(topic_title);
@ -126,7 +126,7 @@ ajax.post_mod_comment = function(post_id, mc_text, mc_type) {
}); });
}; };
ajax.callback.post_mod_comment = function(data) { ajax.callback.post_mod_comment = function(data) {
if (data.mc_type == 0) { if (data.mc_type === 0) {
$('#mc_text_'+ data.post_id).attr('value', ''); $('#mc_text_'+ data.post_id).attr('value', '');
$('#pc_'+ data.post_id).hide(); $('#pc_'+ data.post_id).hide();
} }
@ -190,7 +190,7 @@ ajax.callback.post_mod_comment = function(data) {
// заполняет #poll-form и отправляет запрос // заполняет #poll-form и отправляет запрос
function poll_manage (mode, confirm_msg) function poll_manage (mode, confirm_msg)
{ {
if (confirm_msg != null && !window.confirm( confirm_msg )) { if (confirm_msg !== null && !window.confirm( confirm_msg )) {
return false; return false;
} }
$('#poll-mode').val(mode); $('#poll-mode').val(mode);

View file

@ -11,7 +11,7 @@ $(function(){
var vote_text = vote_data[0]; var vote_text = vote_data[0];
var vote_result = parseInt(vote_data[1]); var vote_result = parseInt(vote_data[1]);
if (vote_id == 0) { if (vote_id === 0) {
bb_poll.title = vote_text; bb_poll.title = vote_text;
} }
else { else {
@ -64,7 +64,7 @@ function submit_vote ()
{ {
var $voted_id = $('input.vote-inp:checked'); var $voted_id = $('input.vote-inp:checked');
if ($voted_id.length == 0) { if ($voted_id.length === 0) {
alert('{L_NEW_POLL_U_NOSEL}'); alert('{L_NEW_POLL_U_NOSEL}');
} }
else { else {

View file

@ -166,7 +166,7 @@
i++; i++;
} }
size = String(size); size = String(size);
if (size.indexOf('.') != -1) { if (size.indexOf('.') !== -1) {
size = size.substring(0, size.indexOf('.') + 3); size = size.substring(0, size.indexOf('.') + 3);
} }
return size + ' ' + units[i]; return size + ' ' + units[i];

View file

@ -56,7 +56,7 @@ $(function(){
if ( /^<\-.*\->$/.test(v) ) { if ( /^<\-.*\->$/.test(v) ) {
v = v.substring(2, v.length-2); v = v.substring(2, v.length-2);
} }
if (k == 13 /* Enter */) { if (k === 13 /* Enter */) {
TPL.build_tpl_form( '<-'+ v +' ->', 'tpl-row-preview' ); TPL.build_tpl_form( '<-'+ v +' ->', 'tpl-row-preview' );
$('#tpl-row-src').val(v); $('#tpl-row-src').val(v);
} }
@ -66,10 +66,10 @@ $(function(){
$('#tpl-src-form').bind('mouseup keyup focus', function(e){ $('#tpl-src-form').bind('mouseup keyup focus', function(e){
if (!$('#rel-preview:visible')[0]) return; if (!$('#rel-preview:visible')[0]) return;
if (e.keyCode) { if (e.keyCode) {
if ( !(e.keyCode == 38 /*up*/ || e.keyCode == 40 /*down*/) ) return; if ( !(e.keyCode === 38 /*up*/ || e.keyCode === 40 /*down*/) ) return;
} }
var ss = this.selectionStart; var ss = this.selectionStart;
if (ss == null) return; if (ss === null) return;
var v = this.value; var v = this.value;
var v = v.substring(0, ss).match(/.*$/)[0] + v.substring(ss, v.length).match(/^.*/)[0]; // текущая строка под курсором var v = v.substring(0, ss).match(/.*$/)[0] + v.substring(ss, v.length).match(/^.*/)[0]; // текущая строка под курсором
v = v.substring(2, v.length-2); v = v.substring(2, v.length-2);
@ -84,7 +84,7 @@ $(function(){
var el = $sel.val(); var el = $sel.val();
var src = $.trim( $('#tpl-row-src').val() ); var src = $.trim( $('#tpl-row-src').val() );
if (src == '') { if (src === '') {
src += str_pad(el, 15); src += str_pad(el, 15);
} }
src += ' '+ TPL.el_attr[el][0] +'['+ el +'] '; src += ' '+ TPL.el_attr[el][0] +'['+ el +'] ';
@ -159,15 +159,15 @@ var TPL = {
TPL.el_titles = {}; TPL.el_titles = {};
$.each(TPL.match_rows(str), function(i,row){ $.each(TPL.match_rows(str), function(i,row){
if (row == null || row == '') return true; // continue if (row === null || row === '') return true; // continue
TPL.rows[i] = $.trim(row); TPL.rows[i] = $.trim(row);
}); });
$.each(TPL.rows, function(i,row){ $.each(TPL.rows, function(i,row){
var mr = TPL.match_cols(row); var mr = TPL.match_cols(row);
if (mr[2] == null) return true; // continue if (mr[2] === null) return true; // continue
var title_id = mr[1]; // id элемента для подстановки его названия или {произвольное название} var title_id = mr[1]; // id элемента для подстановки его названия или {произвольное название}
var input_els = mr[2]; var input_els = mr[2];
var row_title = (TPL.el_attr[title_id] != null) ? TPL.el_attr[title_id][1] : TPL.trim_brackets(title_id); var row_title = (TPL.el_attr[title_id] !== null) ? TPL.el_attr[title_id][1] : TPL.trim_brackets(title_id);
var $tr = $('<tr><td class="rel-title">'+ row_title +':</td><td class="rel-inputs"></td></tr>'); var $tr = $('<tr><td class="rel-title">'+ row_title +':</td><td class="rel-inputs"></td></tr>');
var $td = $('td.rel-inputs', $tr); var $td = $('td.rel-inputs', $tr);
@ -176,7 +176,7 @@ var TPL = {
var el_html = ''; var el_html = '';
var me = TPL.match_el_attrs(el); var me = TPL.match_el_attrs(el);
// вставка шаблонного элемента типа TYPE[attr] // вставка шаблонного элемента типа TYPE[attr]
if (me[2] != null) { if (me[2] !== null) {
var at = me[2].split(','); var at = me[2].split(',');
var nm = at[0]; var nm = at[0];
@ -184,7 +184,7 @@ var TPL = {
{ {
case 'E': case 'E':
if ( $('#'+ nm +'-hid').length ) { if ( $('#'+ nm +'-hid').length ) {
if (res_id == 'tpl-row-preview') { if (res_id === 'tpl-row-preview') {
el_html = '<span class="rel-el hid-el">'+ $('#'+ nm +'-hid').html() +'</span>'; // скрытый элемент el_html = '<span class="rel-el hid-el">'+ $('#'+ nm +'-hid').html() +'</span>'; // скрытый элемент
} }
} }
@ -197,14 +197,14 @@ var TPL = {
break; break;
case 'INP': case 'INP':
var id = TPL.build_el_id_title(nm); var id = TPL.build_el_id_title(nm);
var def = (TPL.el_attr[id] != null) ? TPL.el_attr[id][2].split(',') : [200,80]; var def = (TPL.el_attr[id] !== null) ? TPL.el_attr[id][2].split(',') : [200,80];
var mlem = at[1] || def[0]; var mlem = at[1] || def[0];
var size = at[2] || def[1]; var size = at[2] || def[1];
el_html = '<input class="rel-el rel-input" type="text" id="'+ id +'" maxlength="'+ mlem +'" size="'+ size +'" />'; el_html = '<input class="rel-el rel-input" type="text" id="'+ id +'" maxlength="'+ mlem +'" size="'+ size +'" />';
break; break;
case 'TXT': case 'TXT':
var id = TPL.build_el_id_title(nm); var id = TPL.build_el_id_title(nm);
var def = (TPL.el_attr[id] != null) ? TPL.el_attr[id][2].split(',') : [3]; var def = (TPL.el_attr[id] !== null) ? TPL.el_attr[id][2].split(',') : [3];
var rows = at[1] || def[0]; var rows = at[1] || def[0];
var cols = 100; var cols = 100;
el_html = '<textarea class="rel-el rel-input" id="'+ id +'" rows="'+ rows +'" cols="'+ cols +'" />'; el_html = '<textarea class="rel-el rel-input" id="'+ id +'" rows="'+ rows +'" cols="'+ cols +'" />';
@ -217,7 +217,7 @@ var TPL = {
} }
// вставка нешаблонного элемента // вставка нешаблонного элемента
else { else {
if (el == 'BR') { if (el === 'BR') {
el_html = '<br />'; el_html = '<br />';
} }
else { else {
@ -225,7 +225,7 @@ var TPL = {
} }
} }
// добавление элемента в td.rel-inputs // добавление элемента в td.rel-inputs
if (el_html != '') { if (el_html !== '') {
$td.append(el_html); $td.append(el_html);
} }
}); });
@ -248,7 +248,7 @@ var TPL = {
}, },
build_el_id_title: function(nm) { build_el_id_title: function(nm) {
if (TPL.el_attr[nm] != null) { if (TPL.el_attr[nm] !== null) {
var id = nm; var id = nm;
TPL.el_titles[id] = TPL.el_attr[id][1]; TPL.el_titles[id] = TPL.el_attr[id][1];
} }
@ -259,16 +259,16 @@ var TPL = {
return id; return id;
}, },
get_el_id: function(el) { get_el_id: function(el) {
return (TPL.el_attr[el] != null || TPL.el_id[el] != null) ? el : $P.md5(el); return (TPL.el_attr[el] !== null || TPL.el_id[el] !== null) ? el : $P.md5(el);
}, },
build_select_el: function(name) { build_select_el: function(name) {
var sel_id = TPL.get_el_id(name); var sel_id = TPL.get_el_id(name);
if (TPL.selects[sel_id] == null) return ''; if (TPL.selects[sel_id] === null) return '';
var s = '<select class="rel-el rel-input" id="'+sel_id+'">'; var s = '<select class="rel-el rel-input" id="'+sel_id+'">';
var q = /"/g; //" var q = /"/g; //"
$.each(TPL.selects[sel_id], function(i,v){ $.each(TPL.selects[sel_id], function(i,v){
s += '<option value="'+(i==0 ? '' : v.replace(q, '&quot;'))+'">'+(v=='' ? '&raquo; Выбрать' : v)+'</option>'; s += '<option value="'+(i===0 ? '' : v.replace(q, '&quot;'))+'">'+(v==='' ? '&raquo; Выбрать' : v)+'</option>';
}); });
s += '</select>'; s += '</select>';
return s; return s;
@ -282,7 +282,7 @@ var TPL = {
$.each(str.split('\n'), function(i,v){ $.each(str.split('\n'), function(i,v){
if (!(v = $.trim(v))) return true; // continue if (!(v = $.trim(v))) return true; // continue
var m = v.match(/^(\w+|\{.+\})\[(.*)\]$/); var m = v.match(/^(\w+|\{.+\})\[(.*)\]$/);
if (m == null) return true; // continue if (m === null) return true; // continue
if (parse_attr) { if (parse_attr) {
res[ m[1] ] = m[2].split(','); res[ m[1] ] = m[2].split(',');
} }
@ -302,16 +302,16 @@ var TPL = {
var m; var m;
var t = $('#tpl-src-form').val(); var t = $('#tpl-src-form').val();
var r = /(?:INP|TXT|SEL)(?:\[)(\w+|\{.+?\})/g; var r = /(?:INP|TXT|SEL)(?:\[)(\w+|\{.+?\})/g;
while((m = r.exec(t)) != null) { while((m = r.exec(t)) !== null) {
r_gen.push(m[1]); r_gen.push(m[1]);
} }
// создание нового (старые значения сохраняются без именений, новые добавляются, отсутствующие в форме удаляются) // создание нового (старые значения сохраняются без именений, новые добавляются, отсутствующие в форме удаляются)
$.each(r_gen, function(i,v){ $.each(r_gen, function(i,v){
if (r_old[v] != null) { if (r_old[v] !== null) {
r_new.push( r_old[v] ); r_new.push( r_old[v] );
} }
else { else {
var def_attr = (TPL.el_attr[v] != null) ? TPL.el_attr[v][3] : ''; var def_attr = (TPL.el_attr[v] !== null) ? TPL.el_attr[v][3] : '';
r_new.push( v +'['+ def_attr +']' ); r_new.push( v +'['+ def_attr +']' );
} }
}); });
@ -330,7 +330,7 @@ var TPL = {
}, },
// подсветка ошибок // подсветка ошибок
hl_form_err: function(el, hint_id) { hl_form_err: function(el, hint_id) {
if (TPL.el_attr[el] != null) { if (TPL.el_attr[el] !== null) {
var el_id = el; var el_id = el;
var el_title = TPL.el_attr[el][1]; var el_title = TPL.el_attr[el][1];
} }
@ -344,7 +344,7 @@ var TPL = {
.parent('td').append('<div class="tpl-err-hint">'+hint+'</asd>') .parent('td').append('<div class="tpl-err-hint">'+hint+'</asd>')
.parent('tr').addClass('tpl-err-hl-tr') .parent('tr').addClass('tpl-err-hl-tr')
; ;
if (TPL.f_errors_cnt == 0) $('#'+el_id).focus(); if (TPL.f_errors_cnt === 0) $('#'+el_id).focus();
TPL.f_errors_cnt++; TPL.f_errors_cnt++;
}, },
// сообщения об ошибках при валидации заполнения формы // сообщения об ошибках при валидации заполнения формы
@ -396,24 +396,24 @@ var TPL = {
var el_val = $('#'+el_id).val() || ''; var el_val = $('#'+el_id).val() || '';
// требуемые поля // требуемые поля
if (el_val == '') { if (el_val === '') {
if ($.inArray('req', at) != -1) { if ($.inArray('req', at) !== -1) {
var el_type = (TPL.el_attr[el] != null) ? TPL.el_attr[el][0] : 'INP'; var el_type = (TPL.el_attr[el] !== null) ? TPL.el_attr[el][0] : 'INP';
TPL.hl_form_err(el, 'empty_'+ el_type); TPL.hl_form_err(el, 'empty_'+ el_type);
} }
return true; // continue return true; // continue
} }
// валидация значений // валидация значений
if ($.inArray('num', at) != -1 && !TPL.reg['num'].test(el_val)) { if ($.inArray('num', at) !== -1 && !TPL.reg['num'].test(el_val)) {
TPL.hl_form_err(el, 'not_num'); TPL.hl_form_err(el, 'not_num');
return true; // continue return true; // continue
} }
if ($.inArray('URL', at) != -1 && !TPL.reg['URL'].test(el_val)) { if ($.inArray('URL', at) !== -1 && !TPL.reg['URL'].test(el_val)) {
TPL.hl_form_err(el, 'not_url'); TPL.hl_form_err(el, 'not_url');
return true; // continue return true; // continue
} }
if ($.inArray('img', at) != -1 && !TPL.reg['img'].test(el_val)) { if ($.inArray('img', at) !== -1 && !TPL.reg['img'].test(el_val)) {
TPL.hl_form_err(el, 'not_img'); TPL.hl_form_err(el, 'not_img');
return true; // continue return true; // continue
} }
@ -422,44 +422,44 @@ var TPL = {
el_val = TPL.normalize_val(el, el_val); el_val = TPL.normalize_val(el, el_val);
// заголовок // заголовок
if ($.inArray('HEAD', at) != -1) { if ($.inArray('HEAD', at) !== -1) {
msg_header.push( el_val ); msg_header.push( el_val );
return true; // continue return true; // continue
} }
// постер // постер
if ($.inArray('POSTER', at) != -1) { if ($.inArray('POSTER', at) !== -1) {
msg_poster = el_val; msg_poster = el_val;
return true; // continue return true; // continue
} }
// новая строка после названия // новая строка после названия
if ($.inArray('br2', at) != -1) { if ($.inArray('br2', at) !== -1) {
el_val = '\n'+ el_val; el_val = '\n'+ el_val;
} }
// спойлер // спойлер
if ($.inArray('spoiler', at) != -1) { if ($.inArray('spoiler', at) !== -1) {
msg_body.push( TPL.build_spoiler(el_id, el_val) ); msg_body.push( TPL.build_spoiler(el_id, el_val) );
return true; // continue return true; // continue
} }
// pre // pre
if ($.inArray('pre', at) != -1) { if ($.inArray('pre', at) !== -1) {
msg_body.push( TPL.build_pre(el_id, el_val) ); msg_body.push( TPL.build_pre(el_id, el_val) );
return true; // continue return true; // continue
} }
// inline // inline
if ($.inArray('inline', at) != -1) { if ($.inArray('inline', at) !== -1) {
msg_body.push( TPL.build_inline(el_id, el_val) ); msg_body.push( TPL.build_inline(el_id, el_val) );
return true; // continue return true; // continue
} }
// только в заголовке // только в заголовке
if ($.inArray('headonly', at) != -1) { if ($.inArray('headonly', at) !== -1) {
return true; // continue return true; // continue
} }
// обычный элемент // обычный элемент
msg_body.push( TPL.build_msg_el(el_id, el_val) ); msg_body.push( TPL.build_msg_el(el_id, el_val) );
// новая строка после элемента // новая строка после элемента
if ($.inArray('BR', at) != -1) { if ($.inArray('BR', at) !== -1) {
msg_body.push('\n'); msg_body.push('\n');
} }
}); });
@ -520,18 +520,18 @@ var TPL = {
var g; // группа элементов <-el1 el2->[,] var g; // группа элементов <-el1 el2->[,]
var t = $('#tpl-src-title').val().replace(/\n/g, ' '); // формат var t = $('#tpl-src-title').val().replace(/\n/g, ' '); // формат
var r = /<-([^>]+)->(\S*)/g; var r = /<-([^>]+)->(\S*)/g;
while((g = r.exec(t)) != null) { while((g = r.exec(t)) !== null) {
var g_els = g[1].match(/(\w+|\{.+?\})/g); var g_els = g[1].match(/(\w+|\{.+?\})/g);
if (g_els == null) return true; // continue if (g_els === null) return true; // continue
var g_start_char = ' '; var g_start_char = ' ';
var g_delim_char = ' '; var g_delim_char = ' ';
var g_end_char = ' '; var g_end_char = ' ';
if (g[2].length == 1) { if (g[2].length === 1) {
g_delim_char = ' '+ g[2]; g_delim_char = ' '+ g[2];
} }
else if (g[2].length == 3) { else if (g[2].length === 3) {
g_start_char = g[2].charAt(0); g_start_char = g[2].charAt(0);
trim_after_chars[ g_start_char ] = true; trim_after_chars[ g_start_char ] = true;
@ -545,11 +545,11 @@ var TPL = {
$.each(g_els, function(i,el){ $.each(g_els, function(i,el){
var el_id = TPL.get_el_id(el); var el_id = TPL.get_el_id(el);
var v = $('#'+el_id).val(); var v = $('#'+el_id).val();
if (v == undefined || $.trim(v) == '') return true; // continue if (v === undefined || $.trim(v) === '') return true; // continue
v = TPL.normalize_val(el_id, v); v = TPL.normalize_val(el_id, v);
g_vals.push(' '+ v +' '); g_vals.push(' '+ v +' ');
}); });
if (g_vals.length != 0) { if (g_vals.length !== 0) {
title.push(' '+ g_start_char +' '); title.push(' '+ g_start_char +' ');
title.push( g_vals.join(' '+g_delim_char+' ') ); title.push( g_vals.join(' '+g_delim_char+' ') );
title.push(' '+ g_end_char); title.push(' '+ g_end_char);
@ -4357,7 +4357,7 @@ TPL.build_el_attr_select = function(){
var q = /"/g; //" var q = /"/g; //"
$.each(TPL.el_attr, function(name,at){ $.each(TPL.el_attr, function(name,at){
var v = at[1].replace(q, '&quot;'); var v = at[1].replace(q, '&quot;');
if (v == '') return true; // continue if (v === '') return true; // continue
s += '<option value="'+ name +'">'+ v +'</option>'; s += '<option value="'+ name +'">'+ v +'</option>';
}); });
s += '</select>'; s += '</select>';
@ -4371,7 +4371,7 @@ TPL.build_el_id_select = function(){
var q = /"/g; var q = /"/g;
$.each(TPL.el_id, function(id,desc){ $.each(TPL.el_id, function(id,desc){
var v = desc.replace(q, '&quot;'); var v = desc.replace(q, '&quot;');
if (v == '') return true; // continue if (v === '') return true; // continue
s += '<option value="E['+ id +']">'+ desc +'</option>'; s += '<option value="E['+ id +']">'+ desc +'</option>';
}); });
s += '</select>'; s += '</select>';
@ -4415,7 +4415,7 @@ ajax.topic_tpl = function(mode, params) {
break; break;
case 'assign': case 'assign':
if (params.tpl_id == -1) { if (params.tpl_id === -1) {
if (!window.confirm('Отключить шаблоны в этом форуме?')) { if (!window.confirm('Отключить шаблоны в этом форуме?')) {
return false; return false;
} }
@ -4512,9 +4512,9 @@ function tpl_fill_form ()
$.each($('.rel-input'), function(i,el){ $.each($('.rel-input'), function(i,el){
var $el = $(el); var $el = $(el);
var id = $el.attr('id'); var id = $el.attr('id');
if ($el.val() != '') return true; // continue if ($el.val() !== '') return true; // continue
if (TPL.el_attr[id] != null) { if (TPL.el_attr[id] !== null) {
if (TPL.el_attr[id][0] == 'SEL') { if (TPL.el_attr[id][0] === 'SEL') {
$el[0].selectedIndex = 1; $el[0].selectedIndex = 1;
} }
else { else {
@ -4548,10 +4548,10 @@ function tpl_build_msg (scroll)
} }
function str_pad ( input, pad_length, pad_string, pad_type ) { function str_pad ( input, pad_length, pad_string, pad_type ) {
if (pad_string == null) { if (pad_string === null) {
pad_string = ' '; pad_string = ' ';
} }
if (pad_type == null) { if (pad_type === null) {
pad_type = 'STR_PAD_RIGHT'; pad_type = 'STR_PAD_RIGHT';
} }
var half = '', pad_to_go; var half = '', pad_to_go;
@ -4567,11 +4567,11 @@ function str_pad ( input, pad_length, pad_string, pad_type ) {
input += ''; input += '';
if (pad_type != 'STR_PAD_LEFT' && pad_type != 'STR_PAD_RIGHT' && pad_type != 'STR_PAD_BOTH') { pad_type = 'STR_PAD_RIGHT'; } if (pad_type !== 'STR_PAD_LEFT' && pad_type !== 'STR_PAD_RIGHT' && pad_type !== 'STR_PAD_BOTH') { pad_type = 'STR_PAD_RIGHT'; }
if ((pad_to_go = pad_length - input.length) > 0) { if ((pad_to_go = pad_length - input.length) > 0) {
if (pad_type == 'STR_PAD_LEFT') { input = str_pad_repeater(pad_string, pad_to_go) + input; } if (pad_type === 'STR_PAD_LEFT') { input = str_pad_repeater(pad_string, pad_to_go) + input; }
else if (pad_type == 'STR_PAD_RIGHT') { input = input + str_pad_repeater(pad_string, pad_to_go); } else if (pad_type === 'STR_PAD_RIGHT') { input = input + str_pad_repeater(pad_string, pad_to_go); }
else if (pad_type == 'STR_PAD_BOTH') { else if (pad_type === 'STR_PAD_BOTH') {
half = str_pad_repeater(pad_string, Math.ceil(pad_to_go/2)); half = str_pad_repeater(pad_string, Math.ceil(pad_to_go/2));
input = half + input + half; input = half + input + half;
input = input.substr(0, pad_length); input = input.substr(0, pad_length);
@ -4942,7 +4942,7 @@ $(function(){
$(function(){ $(function(){
$.each(TPL.el_id, function(el,desc){ $.each(TPL.el_id, function(el,desc){
var m = el.match(/^(.*)(_abr)$/); var m = el.match(/^(.*)(_abr)$/);
if (m == null) { if (m === null) {
return true; // continue return true; // continue
} }
var el_abr = m[0]; var el_abr = m[0];

View file

@ -33,8 +33,8 @@
</div> </div>
<!-- Latest compiled and minified JavaScript --> <!-- Latest compiled and minified JavaScript -->
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script> <script src="//code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body> </body>