PHP 7+ requirements, Travis and other small fixes

This commit is contained in:
Yuriy Pikhtarev 2017-01-18 00:44:35 +03:00
commit 236137b49b
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
49 changed files with 207 additions and 250 deletions

View file

@ -1,7 +1,7 @@
build:
environment:
php:
version: 5.6
version: 7.0.8
filter:
excluded_paths:
@ -29,4 +29,4 @@ coding_style:
use_tabs: true
spaces:
around_operators:
concatenation: true
concatenation: true

View file

@ -7,4 +7,4 @@ finder:
- "*Stub.php"
path:
- "src"
- "tests"
- "tests"

View file

@ -1,13 +1,16 @@
language: php
php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
matrix:
allow_failures:
- php: hhvm
before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction
script: phpunit --configuration phpunit.xml --coverage-text
script: phpunit --configuration phpunit.xml --coverage-text

View file

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

View file

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

View file

@ -125,36 +125,6 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
$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(
'NUMBER_OF_POSTS' => $total_posts,
'NUMBER_OF_TOPICS' => $total_topics,
@ -164,14 +134,11 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
'TOPICS_PER_DAY' => $topics_per_day,
'USERS_PER_DAY' => $users_per_day,
'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_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(
'SHOW_USERS_ONLINE' => true,
));

View file

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

View file

@ -125,7 +125,7 @@ function get_tracks($type)
trigger_error(__FUNCTION__ . ": invalid type '$type'", E_USER_ERROR);
}
$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
* @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;
$is_guest = true;
$is_admin = false;
$auth = $auth_fields = $u_access = array();
$auth = $auth_fields = $u_access = [];
$add_auth_type_desc = ($forum_id != AUTH_LIST_ALL);
//
@ -544,10 +544,9 @@ class Date_Delta
31363200 => 'mday', // 12 months
311040000 => 'mon', // 10 years
);
public $intervals = array();
public $intervals = [];
public $format = '';
// Creates new object.
/**
* Date_Delta constructor.
*/
@ -559,8 +558,9 @@ class Date_Delta
$this->format = $lang['DELTA_TIME']['FORMAT'];
}
// Makes the spellable phrase.
/**
* Makes the spellable phrase.
*
* @param $first
* @param $last
* @param string $from
@ -587,12 +587,12 @@ class Date_Delta
// Solve data delta.
$delta = $this->getDelta($first, $last);
if (!$delta) {
if (empty($delta)) {
return false;
}
// Make spellable phrase.
$parts = array();
$parts = [];
$intervals = $GLOBALS['lang']['DELTA_TIME']['INTERVALS'];
foreach (array_reverse($delta) as $k => $n) {
@ -613,16 +613,17 @@ class Date_Delta
return join(' ', $parts);
}
// returns the associative array with date deltas.
/**
* Returns the associative array with date deltas.
*
* @param $first
* @param $last
* @return bool
* @return array
*/
public function getDelta($first, $last)
{
if ($last < $first) {
return false;
return [];
}
// Solve H:M:S part.
@ -662,8 +663,9 @@ class Date_Delta
return $delta;
}
// Returns the length (in days) of the specified month.
/**
* Returns the length (in days) of the specified month.
*
* @param $year
* @param $mon
* @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; Выбрать ')
{
$select_ary = array();
$select_name = '';
$select_ary = [];
switch ($select) {
case 'groups':
@ -725,10 +728,10 @@ function get_select($select, $selected = null, $return_as = 'html', $first_opt =
class html_common
{
public $options = '';
public $attr = array();
public $attr = [];
public $cur_attr = null;
public $max_length = HTML_SELECT_MAX_LENGTH;
public $selected = array();
public $selected = [];
/**
* @param $name
@ -749,7 +752,7 @@ class html_common
$this->selected = array_flip((array)$selected);
$this->max_length = $max_length;
$this->attr = array();
$this->attr = [];
$this->cur_attr =& $this->attr;
if (isset($params['__attributes'])) {
@ -1019,8 +1022,8 @@ function commify($number)
*/
function humn_size($size, $rounder = null, $min = null, $space = '&nbsp;')
{
static $sizes = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
static $rounders = array(0, 0, 0, 2, 3, 3, 3, 3, 3);
static $sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
static $rounders = [0, 0, 0, 2, 3, 3, 3, 3, 3];
$size = (float)$size;
$ext = $sizes[0];
@ -1152,7 +1155,7 @@ function set_var(&$result, $var, $type, $multibyte = false, $strip = true)
$result = $var;
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)) {
// 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)
{
$key_type = $sub_key_type = $sub_type = '';
if (!$cookie && isset($_COOKIE[$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];
}
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];
@ -1211,7 +1216,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
if (is_array($var)) {
$_var = $var;
$var = array();
$var = [];
foreach ($_var as $k => $v) {
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)
{
if (empty($user_id)) {
return is_array($user_id) ? array() : false;
return is_array($user_id) ? [] : false;
}
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) {
$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)
{
$updates = array();
$updates = [];
foreach ($params as $name => $val) {
$updates[] = array(
'config_name' => $name,
@ -1618,7 +1623,7 @@ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = n
if (is_null($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')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
@ -2571,7 +2576,7 @@ function get_title_match_topics($search)
/** @var \TorrentPier\Di $di */
$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)) : '';
$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);
}
if (PHP_VERSION < '5.5') {
die('TorrentPier requires PHP version 5.5 and above (ZF requirement). Your PHP version is ' . PHP_VERSION);
if (PHP_VERSION < '7.0.8') {
die('TorrentPier requires PHP version 7.0.8 and above (used code and packages requirement). Your PHP version is ' . PHP_VERSION);
}
/** @var \TorrentPier\Di $di */

View file

@ -1589,7 +1589,6 @@ $lang['CREATE_PROFILE'] = 'Create profile';
$lang['TP_VERSION'] = 'TorrentPier version';
$lang['TP_RELEASE_DATE'] = 'Release date';
$lang['ZF_VERSION'] = 'Zend Framework version';
$lang['PHP_INFO'] = 'Information about PHP';
$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['BOARD_STARTED'] = 'Board started';
$lang['AVATAR_DIR_SIZE'] = 'Avatar directory size';
$lang['DATABASE_SIZE'] = 'Database size';
$lang['GZIP_COMPRESSION'] = 'Gzip compression';
$lang['NOT_AVAILABLE'] = 'Not available';
// Clear Cache

View file

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

View file

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

View file

@ -1,6 +1,6 @@
{
"name": "torrentpier",
"version": "2.1.0",
"version": "2.2.0",
"description": "TorrentPier. Bittorrent-tracker engine",
"main": "build/index.js",
"directories": {

View file

@ -91,7 +91,7 @@ BBCode.prototype = {
} else {
return [null, null];
}
if (text == '') text = this.stext;
if (text === '') text = this.stext;
text = "" + text;
text = text.replace("/^\s+|\s+$/g", "");
return [text, range];
@ -134,20 +134,20 @@ BBCode.prototype = {
var rt = this.getSelection();
var text = rt[0];
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
if (range) {
var notEmpty = text != null && text != '';
var notEmpty = text !== null && text !== '';
var newText = open + fTrans(text) + (close ? close : '');
range.text = newText;
range.collapse();
if (text != '') {
if (text !== '') {
// Correction for stupid IE: \r for moveStart is 0 character
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.moveEnd("character", -0);
} else {
@ -163,7 +163,7 @@ BBCode.prototype = {
var sel = fTrans(t.value.substr(start, end - start));
var inner = open + sel + close;
t.value = sel1 + inner + sel2;
if (sel != '') {
if (sel !== '') {
t.setSelectionRange(start, start + inner.length);
notEmpty = true;
} else {
@ -199,21 +199,21 @@ BBCode.prototype = {
// Pressed control key?
if (tag.ctrlKey && !e[tag.ctrlKey + "Key"]) continue;
// Pressed needed key?
if (!tag.key || key.toUpperCase() != tag.key.toUpperCase()) continue;
if (!tag.key || key.toUpperCase() !== tag.key.toUpperCase()) continue;
// Insert
if (e.type == "keydown") this.insertTag(id);
if (e.type === "keydown") this.insertTag(id);
// Reset event
return this._cancelEvent(e);
}
// 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]');
return this._cancelEvent(e);
}
// 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();
return this._cancelEvent(e);
}
@ -221,9 +221,9 @@ BBCode.prototype = {
// Hot keys
var form = this.textarea.form;
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;
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;
if (submitter) {
submitter.click();
@ -249,13 +249,13 @@ BBCode.prototype = {
var elt = tag.elt;
if (elt) {
var th = this;
if (elt.type && elt.type.toUpperCase() == "BUTTON") {
if (elt.type && elt.type.toUpperCase() === "BUTTON") {
addEvent(elt, 'click', function () {
th.insertTag(id);
return false;
});
}
if (elt.tagName && elt.tagName.toUpperCase() == "SELECT") {
if (elt.tagName && elt.tagName.toUpperCase() === "SELECT") {
addEvent(elt, 'change', function () {
th.insertTag(id);
return false;
@ -263,7 +263,7 @@ BBCode.prototype = {
}
}
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?
var op = tag.open;
if (typeof(tag.open) == "function") op = tag.open(tag.elt);
var cl = tag.close != null ? tag.close : "/" + op;
if (typeof(tag.open) === "function") op = tag.open(tag.elt);
var cl = tag.close !== null ? tag.close : "/" + op;
// Use "[" if needed
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 (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;
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);
for (var i = 0; i < apostLink.length; i++) {
var link = apostLink[i];
if (typeof link.href != 'string') {
if (typeof link.href !== 'string') {
continue;
}
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>';
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 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();
ypanel('youtube', {
title: '<b>' + text + '</b>',

View file

@ -2,9 +2,9 @@ function $p() {
var elements = [];
for (var i = 0; i < arguments.length; i++) {
var element = arguments[i];
if (typeof element == 'string')
if (typeof element === 'string')
element = document.getElementById(element);
if (arguments.length == 1)
if (arguments.length === 1)
return element;
elements.push(element);
}
@ -43,7 +43,7 @@ var EventCache = function () {
if (item[0].removeEventListener) {
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];
}
if (item[0].detachEvent) {
@ -60,7 +60,7 @@ if (document.all) {
function imgFit(img, maxW) {
img.title = 'Размеры изображения: ' + img.width + ' x ' + img.height;
if (typeof(img.naturalHeight) == 'undefined') {
if (typeof(img.naturalHeight) === 'undefined') {
img.naturalHeight = img.height;
img.naturalWidth = img.width;
}
@ -71,7 +71,7 @@ function imgFit(img, maxW) {
img.style.cursor = 'move';
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.width = img.naturalWidth;
img.title = 'Размеры изображения: ' + img.naturalWidth + ' x ' + img.naturalHeight;
@ -84,7 +84,7 @@ function imgFit(img, maxW) {
function toggle_block(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) {
@ -107,7 +107,7 @@ function rand(min, max) {
* secure transmission
*/
function setCookie(name, value, days, path, domain, secure) {
if (days != 'SESSION') {
if (days !== 'SESSION') {
var date = new Date();
days = days || 365;
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
@ -183,14 +183,14 @@ var Menu = {
var curTop = parseInt(CSS.top);
var tCorner = $(document).scrollTop() + $(window).height() - 20;
var maxVisibleTop = Math.min(curTop, Math.max(0, tCorner - this.$menu.height()));
if (curTop != maxVisibleTop) {
if (curTop !== maxVisibleTop) {
CSS.top = maxVisibleTop;
}
CSS.left += this.offsetCorrection_X;
var curLeft = parseInt(CSS.left);
var rCorner = $(document).scrollLeft() + $(window).width() - 6;
var maxVisibleLeft = Math.min(curLeft, Math.max(0, rCorner - this.$menu.width()));
if (curLeft != maxVisibleLeft) {
if (curLeft !== maxVisibleLeft) {
CSS.left = maxVisibleLeft;
}
this.$menu.css(CSS);
@ -201,13 +201,13 @@ var Menu = {
var curLeft = parseInt($menu.css('left'));
var rCorner = $(document).scrollLeft() + $(window).width() - 6;
var maxVisibleLeft = Math.min(curLeft, Math.max(0, rCorner - $menu.width()));
if (curLeft != maxVisibleLeft) {
if (curLeft !== maxVisibleLeft) {
$menu.css('left', maxVisibleLeft);
}
var curTop = parseInt($menu.css('top'));
var tCorner = $(document).scrollTop() + $(window).height() - 20;
var maxVisibleTop = Math.min(curTop, Math.max(0, tCorner - $menu.height()));
if (curTop != maxVisibleTop) {
if (curTop !== maxVisibleTop) {
$menu.css('top', maxVisibleTop);
}
},
@ -387,7 +387,7 @@ Ajax.prototype = {
event.stopPropagation();
var params = ajax.params[$(this).attr('id')];
var action = params.action;
if (ajax.state[action] == 'readyToSubmit' || ajax.state[action] == 'error') {
if (ajax.state[action] === 'readyToSubmit' || ajax.state[action] === 'error') {
return false;
} else {
ajax.state[action] = 'readyToSubmit';
@ -408,13 +408,13 @@ Ajax.prototype = {
var inputsHtml = $('#editable-tpl-' + editableType).html();
$editable.hide().after(inputsHtml);
var $inputs = $('.editable-inputs', $root);
if (editableType == 'input' || editableType == 'textarea') {
if (editableType === 'input' || editableType === 'textarea') {
$('.editable-value', $inputs).val($.trim($editable.text()));
}
$('input.editable-submit', $inputs).click(function () {
var params = ajax.params[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;
ajax.init[params.action](params);
});
@ -454,7 +454,7 @@ $(document).ready(function () {
$("#ajax-error").ajaxError(function (req, xml) {
var status = xml.status;
var text = xml.statusText;
if (status == 200) {
if (status === 200) {
status = '';
text = 'неверный формат данных';
}
@ -470,7 +470,7 @@ $(document).ready(function () {
params.event = params.event || 'dblclick';
ajax.params[params.id] = params;
$("#" + 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');
}
});

View file

@ -366,4 +366,4 @@
</form>
<br clear="all" />
<br clear="all" />

View file

@ -162,4 +162,4 @@
</form>
<br clear="all" />
<br clear="all" />

View file

@ -131,4 +131,4 @@
</table>
</form>
<br clear="all" />
<br clear="all" />

View file

@ -225,4 +225,4 @@ tr.hl-tr:hover td { background-color: #CFC !important; }
</table>
</form>
<!-- ENDIF / TPL_CRON_EDIT -->
<!-- ENDIF / TPL_CRON_EDIT -->

View file

@ -27,4 +27,4 @@
</tr>
</table>
</form>
</form>

View file

@ -45,4 +45,4 @@
</tr>
</table>
</form>
</form>

View file

@ -62,4 +62,4 @@
</form>
<!--========================================================================-->
<!-- ENDIF / TPL_EDIT_FORUM_AUTH -->
<!-- ENDIF / TPL_EDIT_FORUM_AUTH -->

View file

@ -89,4 +89,4 @@
</form>
<!--========================================================================-->
<!-- ENDIF / TPL_AUTH_CAT -->
<!-- ENDIF / TPL_AUTH_CAT -->

View file

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

View file

@ -97,4 +97,4 @@
<br /><br /><br /><br />
<!--========================================================================-->
<!-- ENDIF / TPL_GROUP_SELECT -->
<!-- ENDIF / TPL_GROUP_SELECT -->

View file

@ -207,4 +207,4 @@ table.log_filters td {
</tr></table>
</fieldset>
<!-- ENDIF -->
<!-- ENDIF -->

View file

@ -46,4 +46,4 @@ function checkForm(formObj)
return false;
}
}
</script>
</script>

View file

@ -86,4 +86,4 @@
</form>
<!--========================================================================-->
<!-- ENDIF / TPL_RANKS_LIST -->
<!-- ENDIF / TPL_RANKS_LIST -->

View file

@ -18,7 +18,7 @@ function update_clear_search(myselect)
// enable/disable radio buttons
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();
@ -126,7 +126,7 @@ function updateButton()
{
if ( ticker >= 0)
{
if ( ticker == 0 )
if ( ticker === 0 )
{
document.form_rebuild_progress.submit_button.value = label;
document.form_rebuild_progress.submit_button.disabled = true;
@ -253,4 +253,4 @@ function updateButton()
</form>
<!--========================================================================-->
<!-- ENDIF / TPL_REBUILD_SEARCH_PROGRESS -->
<!-- ENDIF / TPL_REBUILD_SEARCH_PROGRESS -->

View file

@ -66,7 +66,7 @@ ajax.sitemap = function(mode) {
});
};
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);
}
</script>
@ -119,4 +119,4 @@ ajax.callback.sitemap = function(data) {
</td>
</tr>
</table>
</form>
</form>

View file

@ -113,4 +113,4 @@ function update_smiley(newimage)
</form>
<!--========================================================================-->
<!-- ENDIF / TPL_SMILE_IMPORT -->
<!-- ENDIF / TPL_SMILE_IMPORT -->

View file

@ -21,4 +21,4 @@
</table>
</form>
<br clear="all"/>
<br clear="all"/>

View file

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

View file

@ -55,4 +55,4 @@
</form>
<p>{L_BAN_EXPLAIN_WARN}</p>
<p>{L_BAN_EXPLAIN_WARN}</p>

View file

@ -160,4 +160,4 @@
</form>
<!--========================================================================-->
<!-- ENDIF / TPL_ADMIN_USER_SEARCH_RESULTS -->
<!-- ENDIF / TPL_ADMIN_USER_SEARCH_RESULTS -->

View file

@ -58,4 +58,4 @@
</table></form>
<!--========================================================================-->
<!-- ENDIF / TPL_ADMIN_WORDS_EDIT -->
<!-- ENDIF / TPL_ADMIN_WORDS_EDIT -->

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="row2"><b>{TP_RELEASE_DATE}</b></td>
</tr>
<tr>
<td class="row1" nowrap="nowrap" width="25%">{L_ZF_VERSION}:</td>
<td class="row2"><b>{ZF_VERSION}</b></td>
</tr>
</table>
<br />
@ -182,12 +178,6 @@ ajax.callback.manage_admin = function(data) {
<td class="row1" nowrap="nowrap">{L_AVATAR_DIR_SIZE}:</td>
<td class="row2"><b>{AVATAR_DIR_SIZE}</b></td>
</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>
<br />
@ -224,4 +214,4 @@ ajax.callback.manage_admin = function(data) {
<!-- ENDIF -->
<!--========================================================================-->
<!-- ENDIF / TPL_ADMIN_MAIN -->
<!-- ENDIF / TPL_ADMIN_MAIN -->

View file

@ -7,7 +7,7 @@ function manage_group(mode, value) {
value : value
});
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);
}
}

View file

@ -20,7 +20,7 @@ function qs_highlight_found ()
this.style.display = '';
var a = $('a:first', this);
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>'));
}
else {

View file

@ -6,16 +6,16 @@
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta property="og:image" content="{SITE_URL}styles/images/logo/logo.png" />
{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="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)" />
<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/main.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"></script>
<!-- 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">
window.BB = {};
window.encURL = encodeURIComponent;
@ -236,7 +236,7 @@ function go_to_page ()
<b>{L_OLD_BROWSER}</b>
</div>
<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 = '';
}
</script>
@ -288,7 +288,7 @@ ajax.callback.index_data = function(data) {};
$(document).ready(function() {
x = new Date();
tz = -x.getTimezoneOffset()/60;
if (tz != {BOARD_TIMEZONE})
if (tz !== {BOARD_TIMEZONE})
{
ajax.index_data(tz);
}
@ -304,7 +304,7 @@ $(document).ready(function() {
</td>
<td style="padding: 3px;">
<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="to" value="1" />
<input id="search-text" type="text" name="nm" placeholder="{L_SEARCH_S}" required />
@ -507,4 +507,4 @@ $(document).ready(function() {
<!-- ENDIF / ERROR_MESSAGE -->
<!-- page_header.tpl END -->
<!-- module_xx.tpl START -->
<!-- module_xx.tpl START -->

View file

@ -122,7 +122,7 @@ function dis_submit_btn ()
function debounce (el_id, time_ms)
{
var $el = $('#'+el_id);
if ( $el.attr('disabled') == false ) {
if ( $el.attr('disabled') === false ) {
$el.attr('disabled', 1);
setTimeout(function(){ $el.attr('disabled', 0); }, time_ms);
}
@ -130,7 +130,7 @@ function debounce (el_id, time_ms)
$('#post-submit-btn').click(function(event){
<!-- IF TOR_REQUIRED -->
if ( $('#file-up-btn').val() == '' ) {
if ( $('#file-up-btn').val() === '' ) {
event.stopPropagation();
alert('Вы забыли прикрепить торрент файл (кликните "загрузить файл")');
$('#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)
{
setTimeout(function() {
if ($('input[name="notify"]').attr('checked') == 'checked') {
if ($('input[name="notify"]').attr('checked') === 'checked') {
var notify = 1;
}

View file

@ -3,7 +3,7 @@ function emoticon(text) {
text = ' ' + text + ' ';
if (opener.document.forms['post'].message.createTextRange && 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();
} else {
opener.document.forms['post'].message.value += text;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -33,8 +33,8 @@
</div>
<!-- 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="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="//code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>