Compare commits
8 Commits
558694aa6c
...
v9.29.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1791ec3908 | ||
|
|
3d13f55c35 | ||
|
|
cf1989819a | ||
|
|
b302fb4053 | ||
|
|
32decdd037 | ||
|
|
46cda40d37 | ||
|
|
e71df90144 | ||
|
|
bbcc642fde |
@@ -1068,8 +1068,32 @@ final class CoreLibsCombinedDateTimeTest extends TestCase
|
|||||||
return_named:$return_named,
|
return_named:$return_named,
|
||||||
include_end_date:$include_end_date,
|
include_end_date:$include_end_date,
|
||||||
exclude_start_date:$exclude_start_date
|
exclude_start_date:$exclude_start_date
|
||||||
)
|
),
|
||||||
|
'call calcDaysInterval'
|
||||||
);
|
);
|
||||||
|
if ($return_named) {
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Combined\DateTime::calcDaysIntervalNamedIndex(
|
||||||
|
$input_a,
|
||||||
|
$input_b,
|
||||||
|
include_end_date:$include_end_date,
|
||||||
|
exclude_start_date:$exclude_start_date
|
||||||
|
),
|
||||||
|
'call calcDaysIntervalNamedIndex'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Combined\DateTime::calcDaysIntervalNumIndex(
|
||||||
|
$input_a,
|
||||||
|
$input_b,
|
||||||
|
include_end_date:$include_end_date,
|
||||||
|
exclude_start_date:$exclude_start_date
|
||||||
|
),
|
||||||
|
'call calcDaysIntervalNamedIndex'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ final class CoreLibsConvertByteTest extends TestCase
|
|||||||
4 => '1.00 KB',
|
4 => '1.00 KB',
|
||||||
5 => '1.02KiB',
|
5 => '1.02KiB',
|
||||||
],
|
],
|
||||||
'invalud string number' => [
|
'invalid string number' => [
|
||||||
0 => '1024 MB',
|
0 => '1024 MB',
|
||||||
1 => '1024 MB',
|
1 => '1024 MB',
|
||||||
2 => '1024 MB',
|
2 => '1024 MB',
|
||||||
|
|||||||
@@ -114,6 +114,22 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function hashStandardProvider(): array
|
||||||
|
{
|
||||||
|
$hash_source = 'Some String Text';
|
||||||
|
return [
|
||||||
|
'Long Hash check: ' . \CoreLibs\Create\Hash::STANDARD_HASH => [
|
||||||
|
$hash_source,
|
||||||
|
hash(\CoreLibs\Create\Hash::STANDARD_HASH, $hash_source)
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
@@ -136,9 +152,13 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
|
* phpcs:disable Generic.Files.LineLength
|
||||||
* @covers ::__sha1Short
|
* @covers ::__sha1Short
|
||||||
|
* @covers ::__crc32b
|
||||||
|
* @covers ::sha1Short
|
||||||
* @dataProvider sha1ShortProvider
|
* @dataProvider sha1ShortProvider
|
||||||
* @testdox __sha1Short $input will be $expected (crc32b) and $expected_sha1 (sha1 short) [$_dataName]
|
* @testdox __sha1Short/__crc32b/sha1short $input will be $expected (crc32b) and $expected_sha1 (sha1 short) [$_dataName]
|
||||||
|
* phpcs:enable Generic.Files.LineLength
|
||||||
*
|
*
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
@@ -149,16 +169,29 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
// uses crc32b
|
// uses crc32b
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Create\Hash::__sha1Short($input)
|
\CoreLibs\Create\Hash::__sha1Short($input),
|
||||||
|
'__sha1Short depreacted'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Create\Hash::__sha1Short($input, false)
|
\CoreLibs\Create\Hash::__sha1Short($input, false),
|
||||||
|
'__sha1Short (false) depreacted'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::__crc32b($input),
|
||||||
|
'__crc32b'
|
||||||
);
|
);
|
||||||
// sha1 type
|
// sha1 type
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected_sha1,
|
$expected_sha1,
|
||||||
\CoreLibs\Create\Hash::__sha1Short($input, true)
|
\CoreLibs\Create\Hash::__sha1Short($input, true),
|
||||||
|
'__sha1Short (true) depreacted'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected_sha1,
|
||||||
|
\CoreLibs\Create\Hash::sha1Short($input),
|
||||||
|
'sha1Short'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,8 +199,10 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
* @covers ::__hash
|
* @covers ::__hash
|
||||||
|
* @covers ::hashShort
|
||||||
|
* @covers ::hashShort
|
||||||
* @dataProvider hashProvider
|
* @dataProvider hashProvider
|
||||||
* @testdox __hash $input with $hash_type will be $expected [$_dataName]
|
* @testdox __hash/hashShort/hash $input with $hash_type will be $expected [$_dataName]
|
||||||
*
|
*
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* @param string|null $hash_type
|
* @param string|null $hash_type
|
||||||
@@ -179,12 +214,24 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
if ($hash_type === null) {
|
if ($hash_type === null) {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Create\Hash::__hash($input)
|
\CoreLibs\Create\Hash::__hash($input),
|
||||||
|
'__hash'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hashShort($input),
|
||||||
|
'hashShort'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Create\Hash::__hash($input, $hash_type)
|
\CoreLibs\Create\Hash::__hash($input, $hash_type),
|
||||||
|
'__hash with hash type'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hash($input, $hash_type),
|
||||||
|
'hash with hash type'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,8 +240,9 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
* @covers ::__hashLong
|
* @covers ::__hashLong
|
||||||
|
* @covers ::hashLong
|
||||||
* @dataProvider hashLongProvider
|
* @dataProvider hashLongProvider
|
||||||
* @testdox __hashLong $input will be $expected [$_dataName]
|
* @testdox __hashLong/hashLong $input will be $expected [$_dataName]
|
||||||
*
|
*
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
@@ -206,6 +254,52 @@ final class CoreLibsCreateHashTest extends TestCase
|
|||||||
$expected,
|
$expected,
|
||||||
\CoreLibs\Create\Hash::__hashLong($input)
|
\CoreLibs\Create\Hash::__hashLong($input)
|
||||||
);
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hashLong($input)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::hash
|
||||||
|
* @covers ::hashStd
|
||||||
|
* @dataProvider hashStandardProvider
|
||||||
|
* @testdox hash/hashStd $input will be $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testHashStandard(string $input, string $expected): void
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hashStd($input)
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hash($input)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::hash
|
||||||
|
* @testdox hash with invalid type [$_dataName]
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInvalidHashType(): void
|
||||||
|
{
|
||||||
|
$hash_source = 'Some String Text';
|
||||||
|
$expected = hash(\CoreLibs\Create\Hash::STANDARD_HASH, $hash_source);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Create\Hash::hash($hash_source, 'DOES_NOT_EXIST')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,3 +114,11 @@ Add `.libs` to the master .gitingore
|
|||||||
### Update phpunit
|
### Update phpunit
|
||||||
|
|
||||||
On a version update the old phpunit folder in .libs has to be removed and the new version extracted again
|
On a version update the old phpunit folder in .libs has to be removed and the new version extracted again
|
||||||
|
|
||||||
|
## Javascript
|
||||||
|
|
||||||
|
The original edit.js javascript functions are now in utils.js or utils.min.js.
|
||||||
|
|
||||||
|
The development for thos files is located in a different repository
|
||||||
|
|
||||||
|
https://[service]/CodeBlocks/javascript-utils
|
||||||
|
|||||||
@@ -473,7 +473,10 @@ function intervalStringFormatDeprecated(
|
|||||||
// print "-> V: $value | $part, $time_name | I: " . is_int($value) . " | F: " . is_float($value)
|
// print "-> V: $value | $part, $time_name | I: " . is_int($value) . " | F: " . is_float($value)
|
||||||
// . " | " . ($value != 0 ? 'Not zero' : 'ZERO') . "<br>";
|
// . " | " . ($value != 0 ? 'Not zero' : 'ZERO') . "<br>";
|
||||||
// var_dump($skip_last_zero);
|
// var_dump($skip_last_zero);
|
||||||
if ($value != 0 || $skip_zero === false || $skip_last_zero === false) {
|
if (
|
||||||
|
is_numeric($value) &&
|
||||||
|
($value != 0 || $skip_zero === false || $skip_last_zero === false)
|
||||||
|
) {
|
||||||
if ($part == 'f') {
|
if ($part == 'f') {
|
||||||
if ($truncate_nanoseconds === true) {
|
if ($truncate_nanoseconds === true) {
|
||||||
$value = round($value, 3);
|
$value = round($value, 3);
|
||||||
|
|||||||
@@ -76,41 +76,41 @@ $db->dbResetEncoding();
|
|||||||
|
|
||||||
// empty calls, none of the below should fail
|
// empty calls, none of the below should fail
|
||||||
//
|
//
|
||||||
$db->dbGetCursor();
|
$foo = $db->dbGetCursor();
|
||||||
//
|
//
|
||||||
$db->dbGetCursorExt();
|
$foo = $db->dbGetCursorExt();
|
||||||
//
|
//
|
||||||
$db->dbGetCursorPos('SELECT foo', ['bar']);
|
$foo = $db->dbGetCursorPos('SELECT foo', ['bar']);
|
||||||
//
|
//
|
||||||
$db->dbGetCursorNumRows('SELECT foo', ['bar']);
|
$foo = $db->dbGetCursorNumRows('SELECT foo', ['bar']);
|
||||||
//
|
//
|
||||||
$db->dbGetInsertPKName();
|
$foo = $db->dbGetInsertPKName();
|
||||||
//
|
//
|
||||||
$db->dbGetInsertPK();
|
$foo = $db->dbGetInsertPK();
|
||||||
//
|
//
|
||||||
$db->dbGetReturningExt();
|
$foo = $db->dbGetReturningExt();
|
||||||
$db->dbGetReturningExt('foo');
|
$foo = $db->dbGetReturningExt('foo');
|
||||||
$db->dbGetReturningExt('foo', 0);
|
$foo = $db->dbGetReturningExt('foo', 0);
|
||||||
$db->dbGetReturningExt(pos:0);
|
$foo = $db->dbGetReturningExt(pos:0);
|
||||||
//
|
//
|
||||||
$db->dbGetReturningArray();
|
$foo = $db->dbGetReturningArray();
|
||||||
//
|
//
|
||||||
$db->dbGetNumRows();
|
$foo = $db->dbGetNumRows();
|
||||||
//
|
//
|
||||||
$db->dbGetNumFields();
|
$foo = $db->dbGetNumFields();
|
||||||
//
|
//
|
||||||
$db->dbGetFieldNames();
|
$foo = $db->dbGetFieldNames();
|
||||||
//
|
//
|
||||||
$db->dbGetFieldTypes();
|
$foo = $db->dbGetFieldTypes();
|
||||||
//
|
//
|
||||||
$db->dbGetFieldNameTypes();
|
$foo = $db->dbGetFieldNameTypes();
|
||||||
//
|
//
|
||||||
$db->dbGetFieldName(0);
|
$foo = $db->dbGetFieldName(0);
|
||||||
//
|
//
|
||||||
$db->dbGetFieldType(0);
|
$foo = $db->dbGetFieldType(0);
|
||||||
$db->dbGetFieldType('foo');
|
$foo = $db->dbGetFieldType('foo');
|
||||||
//
|
//
|
||||||
$db->dbGetPrepareCursorValue('foo', 'bar');
|
$foo = $db->dbGetPrepareCursorValue('foo', 'bar');
|
||||||
|
|
||||||
// TEST CACHE READS
|
// TEST CACHE READS
|
||||||
|
|
||||||
|
|||||||
@@ -38,9 +38,11 @@ print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
|||||||
|
|
||||||
$to_crc = 'Some text block';
|
$to_crc = 'Some text block';
|
||||||
// static
|
// static
|
||||||
print "S::__CRC32B: $to_crc: " . $hash_class::__crc32b($to_crc) . "<br>";
|
print "S::__CRC32B: $to_crc: " . Hash::__crc32b($to_crc) . "<br>";
|
||||||
print "S::__SHA1SHORT(off): $to_crc: " . $hash_class::__sha1short($to_crc) . "<br>";
|
// print "S::__SHA1SHORT(off): $to_crc: " . Hash::__sha1short($to_crc) . "<br>";
|
||||||
print "S::__SHA1SHORT(on): $to_crc: " . $hash_class::__sha1short($to_crc, true) . "<br>";
|
print "S::hashShort(__sha1Short replace): $to_crc: " . Hash::hashShort($to_crc) . "<br>";
|
||||||
|
// print "S::__SHA1SHORT(on): $to_crc: " . Hash::__sha1short($to_crc, true) . "<br>";
|
||||||
|
print "S::sha1Short(__sha1Short replace): $to_crc: " . Hash::sha1Short($to_crc) . "<br>";
|
||||||
print "S::__hash(d): " . $to_crc . "/"
|
print "S::__hash(d): " . $to_crc . "/"
|
||||||
. Hash::STANDARD_HASH_SHORT . ": " . $hash_class::__hash($to_crc) . "<br>";
|
. Hash::STANDARD_HASH_SHORT . ": " . $hash_class::__hash($to_crc) . "<br>";
|
||||||
foreach (['adler32', 'fnv132', 'fnv1a32', 'joaat', 'sha512'] as $__hash_c) {
|
foreach (['adler32', 'fnv132', 'fnv1a32', 'joaat', 'sha512'] as $__hash_c) {
|
||||||
@@ -53,13 +55,16 @@ echo "<hr>";
|
|||||||
$text = 'Some String Text';
|
$text = 'Some String Text';
|
||||||
$type = 'crc32b';
|
$type = 'crc32b';
|
||||||
print "Hash: " . $type . ": " . hash($type, $text) . "<br>";
|
print "Hash: " . $type . ": " . hash($type, $text) . "<br>";
|
||||||
print "Class: " . $type . ": " . Hash::__hash($text, $type) . "<br>";
|
// print "Class (old): " . $type . ": " . Hash::__hash($text, $type) . "<br>";
|
||||||
|
print "Class (new): " . $type . ": " . Hash::hash($text, $type) . "<br>";
|
||||||
|
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
print "<br>CURRENT STANDARD_HASH_SHORT: " . Hash::STANDARD_HASH_SHORT . "<br>";
|
print "CURRENT STANDARD_HASH_SHORT: " . Hash::STANDARD_HASH_SHORT . "<br>";
|
||||||
print "<br>CURRENT STANDARD_HASH_LONG: " . Hash::STANDARD_HASH_LONG . "<br>";
|
print "CURRENT STANDARD_HASH_LONG: " . Hash::STANDARD_HASH_LONG . "<br>";
|
||||||
print "HASH SHORT: " . $to_crc . ": " . Hash::__hash($to_crc) . "<br>";
|
print "CURRENT STANDARD_HASH: " . Hash::STANDARD_HASH . "<br>";
|
||||||
print "HASH LONG: " . $to_crc . ": " . Hash::__hashLong($to_crc) . "<br>";
|
print "HASH SHORT: " . $to_crc . ": " . Hash::hashShort($to_crc) . "<br>";
|
||||||
|
print "HASH LONG: " . $to_crc . ": " . Hash::hashLong($to_crc) . "<br>";
|
||||||
|
print "HASH DEFAULT: " . $to_crc . ": " . Hash::hashStd($to_crc) . "<br>";
|
||||||
|
|
||||||
// print "UNIQU ID SHORT : " . Hash::__uniqId() . "<br>";
|
// print "UNIQU ID SHORT : " . Hash::__uniqId() . "<br>";
|
||||||
// print "UNIQU ID LONG : " . Hash::__uniqIdLong() . "<br>";
|
// print "UNIQU ID LONG : " . Hash::__uniqIdLong() . "<br>";
|
||||||
|
|||||||
@@ -86,8 +86,10 @@ if (!isset($_SESSION['counter'])) {
|
|||||||
$_SESSION['counter']++;
|
$_SESSION['counter']++;
|
||||||
print "[READ] A " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
print "[READ] A " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||||
$_SESSION[$var] = $value;
|
$_SESSION[$var] = $value;
|
||||||
|
/** @phpstan-ignore-next-line nullCoalesce.offset */
|
||||||
print "[READ] B " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
print "[READ] B " . $var . ": " . ($_SESSION[$var] ?? '{UNSET}') . "<br>";
|
||||||
print "[READ] Confirm " . $var . " is " . $value . ": "
|
print "[READ] Confirm " . $var . " is " . $value . ": "
|
||||||
|
/** @phpstan-ignore-next-line equal.alwaysTrue, nullCoalesce.offset */
|
||||||
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "<br>";
|
. (($_SESSION[$var] ?? '') == $value ? 'Matching' : 'Not matching') . "<br>";
|
||||||
|
|
||||||
// test set wrappers methods
|
// test set wrappers methods
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
/* general edit javascript */
|
/*
|
||||||
/* jquery version */
|
general edit javascript
|
||||||
|
jquery version
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @deprecated Do not use this anymore, use utils.js or utils.min.js */
|
||||||
|
|
||||||
/* global i18n */
|
/* global i18n */
|
||||||
|
|
||||||
@@ -21,6 +25,7 @@ var GL_OB_BASE = 100;
|
|||||||
* @param {string} el_id Element ID to get
|
* @param {string} el_id Element ID to get
|
||||||
* @returns {HTMLElement}
|
* @returns {HTMLElement}
|
||||||
* @throws Error
|
* @throws Error
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function loadEl(el_id)
|
function loadEl(el_id)
|
||||||
{
|
{
|
||||||
@@ -36,6 +41,7 @@ function loadEl(el_id)
|
|||||||
* @param {String} theURL the url
|
* @param {String} theURL the url
|
||||||
* @param {String} winName window name
|
* @param {String} winName window name
|
||||||
* @param {Object} features popup features
|
* @param {Object} features popup features
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function pop(theURL, winName, features) // eslint-disable-line no-unused-vars
|
function pop(theURL, winName, features) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -46,6 +52,7 @@ function pop(theURL, winName, features) // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* automatically resize a text area based on the amount of lines in it
|
* automatically resize a text area based on the amount of lines in it
|
||||||
* @param {string} ta_id element id
|
* @param {string} ta_id element id
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function expandTA(ta_id) // eslint-disable-line no-unused-vars
|
function expandTA(ta_id) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -71,6 +78,7 @@ function expandTA(ta_id) // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* wrapper to get the real window size for the current browser window
|
* wrapper to get the real window size for the current browser window
|
||||||
* @return {Object} object with width/height
|
* @return {Object} object with width/height
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getWindowSize()
|
function getWindowSize()
|
||||||
{
|
{
|
||||||
@@ -86,6 +94,7 @@ function getWindowSize()
|
|||||||
/**
|
/**
|
||||||
* wrapper to get the correct scroll offset
|
* wrapper to get the correct scroll offset
|
||||||
* @return {Object} object with x/y px
|
* @return {Object} object with x/y px
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getScrollOffset()
|
function getScrollOffset()
|
||||||
{
|
{
|
||||||
@@ -101,6 +110,7 @@ function getScrollOffset()
|
|||||||
/**
|
/**
|
||||||
* wrapper to get the correct scroll offset for opener page (from popup)
|
* wrapper to get the correct scroll offset for opener page (from popup)
|
||||||
* @return {Object} object with x/y px
|
* @return {Object} object with x/y px
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getScrollOffsetOpener() // eslint-disable-line no-unused-vars
|
function getScrollOffsetOpener() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -118,6 +128,7 @@ function getScrollOffsetOpener() // eslint-disable-line no-unused-vars
|
|||||||
* @param {String} id element to center
|
* @param {String} id element to center
|
||||||
* @param {Boolean} left if true centers to the middle from the left
|
* @param {Boolean} left if true centers to the middle from the left
|
||||||
* @param {Boolean} top if true centers to the middle from the top
|
* @param {Boolean} top if true centers to the middle from the top
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function setCenter(id, left, top)
|
function setCenter(id, left, top)
|
||||||
{
|
{
|
||||||
@@ -155,6 +166,7 @@ function setCenter(id, left, top)
|
|||||||
* @param {Number} [offset=0] offset from top, default is 0 (px)
|
* @param {Number} [offset=0] offset from top, default is 0 (px)
|
||||||
* @param {Number} [duration=500] animation time, default 500ms
|
* @param {Number} [duration=500] animation time, default 500ms
|
||||||
* @param {String} [base='body,html'] base element for offset scroll
|
* @param {String} [base='body,html'] base element for offset scroll
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function goToPos(element, offset = 0, duration = 500, base = 'body,html') // eslint-disable-line no-unused-vars
|
function goToPos(element, offset = 0, duration = 500, base = 'body,html') // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -173,6 +185,7 @@ function goToPos(element, offset = 0, duration = 500, base = 'body,html') // esl
|
|||||||
* go to element, scroll
|
* go to element, scroll
|
||||||
* non jquery
|
* non jquery
|
||||||
* @param {string} target
|
* @param {string} target
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function goTo(target) // eslint-disable-line no-unused-vars
|
function goTo(target) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -186,6 +199,7 @@ function goTo(target) // eslint-disable-line no-unused-vars
|
|||||||
* that is filled from gettext in PHP
|
* that is filled from gettext in PHP
|
||||||
* @param {String} string text to translate
|
* @param {String} string text to translate
|
||||||
* @return {String} translated text (based on PHP selected language)
|
* @return {String} translated text (based on PHP selected language)
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function __(string)
|
function __(string)
|
||||||
{
|
{
|
||||||
@@ -202,37 +216,70 @@ function __(string)
|
|||||||
* First, checks if it isn't implemented yet.
|
* First, checks if it isn't implemented yet.
|
||||||
* @param {String} String.prototype.format string with elements to be replaced
|
* @param {String} String.prototype.format string with elements to be replaced
|
||||||
* @return {String} Formated string
|
* @return {String} Formated string
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
if (!String.prototype.format) {
|
if (!String.prototype.format) {
|
||||||
String.prototype.format = function()
|
String.prototype.format = function()
|
||||||
{
|
{
|
||||||
var args = arguments;
|
console.error('[DEPRECATED] use formatString');
|
||||||
return this.replace(/{(\d+)}/g, function(match, number)
|
return formatString(this, arguments);
|
||||||
{
|
};
|
||||||
return typeof args[number] != 'undefined' ?
|
}
|
||||||
args[number] :
|
|
||||||
match
|
/**
|
||||||
;
|
* simple sprintf formater for replace
|
||||||
});
|
* usage: "{0} is cool, {1} is not".format("Alpha", "Beta");
|
||||||
|
* First, checks if it isn't implemented yet.
|
||||||
|
* @param {String} string String with {..} entries
|
||||||
|
* @param {...any} args List of replacement
|
||||||
|
* @returns {String} Escaped string
|
||||||
|
* @deprecated use utils.js
|
||||||
|
*/
|
||||||
|
function formatString(string, ...args)
|
||||||
|
{
|
||||||
|
return string.replace(/{(\d+)}/g, function(match, number)
|
||||||
|
{
|
||||||
|
return typeof args[number] != 'undefined' ?
|
||||||
|
args[number] :
|
||||||
|
match
|
||||||
|
;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* round to digits (float)
|
||||||
|
* @param {Number} Number.prototype.round Float type number to round
|
||||||
|
* @param {Number} prec Precision to round to
|
||||||
|
* @return {Float} Rounded number
|
||||||
|
* @deprecated use utils.js
|
||||||
|
*/
|
||||||
|
if (Number.prototype.round) {
|
||||||
|
Number.prototype.round = function (prec) {
|
||||||
|
console.error('[DEPRECATED] use roundPrecision');
|
||||||
|
return roundPrecision(this, prec);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* round to digits (float)
|
* round to digits (float)
|
||||||
* @param {Float} Number.prototype.round Float type number to round
|
* @param {Number} number Float type number to round
|
||||||
* @param {Number} prec Precision to round to
|
* @param {Number} precision Precision to round to
|
||||||
* @return {Float} Rounded number
|
* @return {Number} Rounded number
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
if (Number.prototype.round) {
|
function roundPrecision(number, precision)
|
||||||
Number.prototype.round = function (prec) {
|
{
|
||||||
return Math.round(this * Math.pow(10, prec)) / Math.pow(10, prec);
|
if (!isNaN(number) || !isNaN(precision)) {
|
||||||
};
|
return number;
|
||||||
|
}
|
||||||
|
return Math.round(number * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* formats flat number 123456 to 123,456
|
* formats flat number 123456 to 123,456
|
||||||
* @param {Number} x number to be formated
|
* @param {Number} x number to be formated
|
||||||
* @return {String} formatted with , in thousands
|
* @return {String} formatted with , in thousands
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function numberWithCommas(x) // eslint-disable-line no-unused-vars
|
function numberWithCommas(x) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -245,6 +292,7 @@ function numberWithCommas(x) // eslint-disable-line no-unused-vars
|
|||||||
* converts line breaks to br
|
* converts line breaks to br
|
||||||
* @param {String} string any string
|
* @param {String} string any string
|
||||||
* @return {String} string with <br>
|
* @return {String} string with <br>
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function convertLBtoBR(string) // eslint-disable-line no-unused-vars
|
function convertLBtoBR(string) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -253,51 +301,78 @@ function convertLBtoBR(string) // eslint-disable-line no-unused-vars
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* escape HTML string
|
* escape HTML string
|
||||||
* @param {String} !String.prototype.escapeHTML HTML data string to be escaped
|
* @param {String} String.prototype.escapeHTML HTML data string to be escaped
|
||||||
* @return {String} escaped string
|
* @return {String} escaped string
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
if (!String.prototype.escapeHTML) {
|
if (!String.prototype.escapeHTML) {
|
||||||
String.prototype.escapeHTML = function() {
|
String.prototype.escapeHTML = function() {
|
||||||
return this.replace(/[&<>"'/]/g, function (s) {
|
console.error('[DEPRECATED] use escapeHtml');
|
||||||
var entityMap = {
|
return escapeHtml(this);
|
||||||
'&': '&',
|
|
||||||
'<': '<',
|
|
||||||
'>': '>',
|
|
||||||
'"': '"',
|
|
||||||
'\'': ''',
|
|
||||||
'/': '/'
|
|
||||||
};
|
|
||||||
|
|
||||||
return entityMap[s];
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unescape a HTML encoded string
|
* unescape a HTML encoded string
|
||||||
* @param {String} !String.prototype.unescapeHTML data with escaped entries
|
* @param {String} String.prototype.unescapeHTML data with escaped entries
|
||||||
* @return {String} HTML formated string
|
* @return {String} HTML formated string
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
if (!String.prototype.unescapeHTML) {
|
if (!String.prototype.unescapeHTML) {
|
||||||
String.prototype.unescapeHTML = function() {
|
String.prototype.unescapeHTML = function() {
|
||||||
return this.replace(/&[#\w]+;/g, function (s) {
|
console.error('[DEPRECATED] use unescapeHtml');
|
||||||
var entityMap = {
|
return unescapeHtml(this);
|
||||||
'&': '&',
|
|
||||||
'<': '<',
|
|
||||||
'>': '>',
|
|
||||||
'"': '"',
|
|
||||||
''': '\'',
|
|
||||||
'/': '/'
|
|
||||||
};
|
|
||||||
|
|
||||||
return entityMap[s];
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escapes HTML in string
|
||||||
|
* @param {String} string Text to escape HTML in
|
||||||
|
* @returns {String}
|
||||||
|
* @deprecated use utils.js
|
||||||
|
*/
|
||||||
|
function escapeHtml(string)
|
||||||
|
{
|
||||||
|
return string.replace(/[&<>"'/]/g, function (s) {
|
||||||
|
var entityMap = {
|
||||||
|
'&': '&',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>',
|
||||||
|
'"': '"',
|
||||||
|
'\'': ''',
|
||||||
|
'/': '/'
|
||||||
|
};
|
||||||
|
|
||||||
|
return entityMap[s];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unescape a HTML encoded string
|
||||||
|
* @param {String} string Text to unescape HTML in
|
||||||
|
* @returns {String}
|
||||||
|
* @deprecated use utils.js
|
||||||
|
*/
|
||||||
|
function unescapeHtml(string)
|
||||||
|
{
|
||||||
|
return string.replace(/&[#\w]+;/g, function (s) {
|
||||||
|
var entityMap = {
|
||||||
|
'&': '&',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>',
|
||||||
|
'"': '"',
|
||||||
|
''': '\'',
|
||||||
|
'/': '/'
|
||||||
|
};
|
||||||
|
|
||||||
|
return entityMap[s];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns current timestamp (unix timestamp)
|
* returns current timestamp (unix timestamp)
|
||||||
* @return {Number} timestamp (in milliseconds)
|
* @return {Number} timestamp (in milliseconds)
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getTimestamp() // eslint-disable-line no-unused-vars
|
function getTimestamp() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -310,6 +385,7 @@ function getTimestamp() // eslint-disable-line no-unused-vars
|
|||||||
* i.e. 0-255 -> '00'-'ff'
|
* i.e. 0-255 -> '00'-'ff'
|
||||||
* @param {Number} dec decimal string
|
* @param {Number} dec decimal string
|
||||||
* @return {String} hex encdoded number
|
* @return {String} hex encdoded number
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function dec2hex(dec)
|
function dec2hex(dec)
|
||||||
{
|
{
|
||||||
@@ -321,6 +397,7 @@ function dec2hex(dec)
|
|||||||
* only works on mondern browsers
|
* only works on mondern browsers
|
||||||
* @param {Number} len length of unique id string
|
* @param {Number} len length of unique id string
|
||||||
* @return {String} random string in length of len
|
* @return {String} random string in length of len
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function generateId(len) // eslint-disable-line no-unused-vars
|
function generateId(len) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -334,6 +411,7 @@ function generateId(len) // eslint-disable-line no-unused-vars
|
|||||||
* works on all browsers
|
* works on all browsers
|
||||||
* after many runs it will create duplicates
|
* after many runs it will create duplicates
|
||||||
* @return {String} not true random string
|
* @return {String} not true random string
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function randomIdF() // eslint-disable-line no-unused-vars
|
function randomIdF() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -347,6 +425,7 @@ function randomIdF() // eslint-disable-line no-unused-vars
|
|||||||
* @param {Number} min minimum int number inclusive
|
* @param {Number} min minimum int number inclusive
|
||||||
* @param {Number} max maximumg int number inclusive
|
* @param {Number} max maximumg int number inclusive
|
||||||
* @return {Number} Random number
|
* @return {Number} Random number
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getRandomIntInclusive(min, max) // eslint-disable-line no-unused-vars
|
function getRandomIntInclusive(min, max) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -360,6 +439,7 @@ function getRandomIntInclusive(min, max) // eslint-disable-line no-unused-vars
|
|||||||
* check if name is a function
|
* check if name is a function
|
||||||
* @param {string} name Name of function to check if exists
|
* @param {string} name Name of function to check if exists
|
||||||
* @return {Boolean} true/false
|
* @return {Boolean} true/false
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function isFunction(name) // eslint-disable-line no-unused-vars
|
function isFunction(name) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -379,6 +459,7 @@ function isFunction(name) // eslint-disable-line no-unused-vars
|
|||||||
* @param {mixed} context context (window or first namespace)
|
* @param {mixed} context context (window or first namespace)
|
||||||
* hidden next are all the arguments
|
* hidden next are all the arguments
|
||||||
* @return {mixed} Return values from functon
|
* @return {mixed} Return values from functon
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function executeFunctionByName(functionName, context /*, args */) // eslint-disable-line no-unused-vars
|
function executeFunctionByName(functionName, context /*, args */) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -395,6 +476,7 @@ function executeFunctionByName(functionName, context /*, args */) // eslint-disa
|
|||||||
* checks if a variable is an object
|
* checks if a variable is an object
|
||||||
* @param {Mixed} val possible object
|
* @param {Mixed} val possible object
|
||||||
* @return {Boolean} true/false if it is an object or not
|
* @return {Boolean} true/false if it is an object or not
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function isObject(val)
|
function isObject(val)
|
||||||
{
|
{
|
||||||
@@ -408,6 +490,7 @@ function isObject(val)
|
|||||||
* get the length of an object (entries)
|
* get the length of an object (entries)
|
||||||
* @param {Object} object object to check
|
* @param {Object} object object to check
|
||||||
* @return {Number} number of entry
|
* @return {Number} number of entry
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getObjectCount(object)
|
function getObjectCount(object)
|
||||||
{
|
{
|
||||||
@@ -419,6 +502,7 @@ function getObjectCount(object)
|
|||||||
* @param {String} key key name
|
* @param {String} key key name
|
||||||
* @param {Object} object object to search key in
|
* @param {Object} object object to search key in
|
||||||
* @return {Boolean} true/false if key exists in object
|
* @return {Boolean} true/false if key exists in object
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function keyInObject(key, object)
|
function keyInObject(key, object)
|
||||||
{
|
{
|
||||||
@@ -430,6 +514,7 @@ function keyInObject(key, object)
|
|||||||
* @param {Object} object object to search value in
|
* @param {Object} object object to search value in
|
||||||
* @param {Mixed} value any value (String, Number, etc)
|
* @param {Mixed} value any value (String, Number, etc)
|
||||||
* @return {String} the key found for the first matching value
|
* @return {String} the key found for the first matching value
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getKeyByValue(object, value) // eslint-disable-line no-unused-vars
|
function getKeyByValue(object, value) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -444,6 +529,7 @@ function getKeyByValue(object, value) // eslint-disable-line no-unused-vars
|
|||||||
* @param {Object} object object to search value in
|
* @param {Object} object object to search value in
|
||||||
* @param {Mixed} value any value (String, Number, etc)
|
* @param {Mixed} value any value (String, Number, etc)
|
||||||
* @return {Boolean} true on value found, false on not found
|
* @return {Boolean} true on value found, false on not found
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function valueInObject(object, value) // eslint-disable-line no-unused-vars
|
function valueInObject(object, value) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -459,6 +545,7 @@ function valueInObject(object, value) // eslint-disable-line no-unused-vars
|
|||||||
* or if JSON.parse(JSON.stringify(obj)) is failing
|
* or if JSON.parse(JSON.stringify(obj)) is failing
|
||||||
* @param {Object} inObject Object to copy
|
* @param {Object} inObject Object to copy
|
||||||
* @return {Object} Copied Object
|
* @return {Object} Copied Object
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function deepCopyFunction(inObject)
|
function deepCopyFunction(inObject)
|
||||||
{
|
{
|
||||||
@@ -482,6 +569,7 @@ function deepCopyFunction(inObject)
|
|||||||
* checks if a DOM element actually exists
|
* checks if a DOM element actually exists
|
||||||
* @param {String} id Element id to check for
|
* @param {String} id Element id to check for
|
||||||
* @return {Boolean} true if element exists, false on failure
|
* @return {Boolean} true if element exists, false on failure
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function exists(id)
|
function exists(id)
|
||||||
{
|
{
|
||||||
@@ -493,6 +581,7 @@ function exists(id)
|
|||||||
* currently precision is fixed, if dynamic needs check for max/min precision
|
* currently precision is fixed, if dynamic needs check for max/min precision
|
||||||
* @param {Number} bytes bytes in int
|
* @param {Number} bytes bytes in int
|
||||||
* @return {String} string in GB/MB/KB
|
* @return {String} string in GB/MB/KB
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function formatBytes(bytes) // eslint-disable-line no-unused-vars
|
function formatBytes(bytes) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -509,6 +598,7 @@ function formatBytes(bytes) // eslint-disable-line no-unused-vars
|
|||||||
* like formatBytes, but returns bytes for <1KB and not 0.n KB
|
* like formatBytes, but returns bytes for <1KB and not 0.n KB
|
||||||
* @param {Number} bytes bytes in int
|
* @param {Number} bytes bytes in int
|
||||||
* @return {String} string in GB/MB/KB
|
* @return {String} string in GB/MB/KB
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function formatBytesLong(bytes) // eslint-disable-line no-unused-vars
|
function formatBytesLong(bytes) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -521,6 +611,7 @@ function formatBytesLong(bytes) // eslint-disable-line no-unused-vars
|
|||||||
* Convert a string with B/K/M/etc into a byte number
|
* Convert a string with B/K/M/etc into a byte number
|
||||||
* @param {String|Number} bytes Any string with B/K/M/etc
|
* @param {String|Number} bytes Any string with B/K/M/etc
|
||||||
* @return {String|Number} A byte number, or original string as is
|
* @return {String|Number} A byte number, or original string as is
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function stringByteFormat(bytes) // eslint-disable-line no-unused-vars
|
function stringByteFormat(bytes) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -551,6 +642,7 @@ function stringByteFormat(bytes) // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* prints out error messages based on data available from the browser
|
* prints out error messages based on data available from the browser
|
||||||
* @param {Object} err error from try/catch block
|
* @param {Object} err error from try/catch block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function errorCatch(err)
|
function errorCatch(err)
|
||||||
{
|
{
|
||||||
@@ -594,6 +686,7 @@ function errorCatch(err)
|
|||||||
* @param {String} loc location name for action indicator
|
* @param {String} loc location name for action indicator
|
||||||
* default empty. for console.log
|
* default empty. for console.log
|
||||||
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function actionIndicator(loc, overlay = true) // eslint-disable-line no-unused-vars
|
function actionIndicator(loc, overlay = true) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -610,6 +703,7 @@ function actionIndicator(loc, overlay = true) // eslint-disable-line no-unused-v
|
|||||||
* @param {String} loc location name for action indicator
|
* @param {String} loc location name for action indicator
|
||||||
* default empty. for console.log
|
* default empty. for console.log
|
||||||
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function actionIndicatorShow(loc, overlay = true)
|
function actionIndicatorShow(loc, overlay = true)
|
||||||
{
|
{
|
||||||
@@ -632,6 +726,7 @@ function actionIndicatorShow(loc, overlay = true)
|
|||||||
* @param {String} loc location name for action indicator
|
* @param {String} loc location name for action indicator
|
||||||
* default empty. for console.log
|
* default empty. for console.log
|
||||||
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
* @param {Boolean} [overlay=true] override the auto hide/show over the overlay div block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function actionIndicatorHide(loc, overlay = true)
|
function actionIndicatorHide(loc, overlay = true)
|
||||||
{
|
{
|
||||||
@@ -644,6 +739,7 @@ function actionIndicatorHide(loc, overlay = true)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* shows the overlay box or if already visible, bumps the zIndex to 100
|
* shows the overlay box or if already visible, bumps the zIndex to 100
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function overlayBoxShow()
|
function overlayBoxShow()
|
||||||
{
|
{
|
||||||
@@ -658,6 +754,7 @@ function overlayBoxShow()
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* hides the overlay box or if zIndex is 100 bumps it down to previous level
|
* hides the overlay box or if zIndex is 100 bumps it down to previous level
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function overlayBoxHide()
|
function overlayBoxHide()
|
||||||
{
|
{
|
||||||
@@ -671,6 +768,7 @@ function overlayBoxHide()
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* position the overlay block box and shows it
|
* position the overlay block box and shows it
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function setOverlayBox() // eslint-disable-line no-unused-vars
|
function setOverlayBox() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -681,6 +779,7 @@ function setOverlayBox() // eslint-disable-line no-unused-vars
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* opposite of set, always hides overlay box
|
* opposite of set, always hides overlay box
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function hideOverlayBox() // eslint-disable-line no-unused-vars
|
function hideOverlayBox() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -691,6 +790,7 @@ function hideOverlayBox() // eslint-disable-line no-unused-vars
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* the abort call, clears the action box and hides it and the overlay box
|
* the abort call, clears the action box and hides it and the overlay box
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function ClearCall() // eslint-disable-line no-unused-vars
|
function ClearCall() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -712,6 +812,7 @@ function ClearCall() // eslint-disable-line no-unused-vars
|
|||||||
* zIndex of 1000
|
* zIndex of 1000
|
||||||
* - indicator is page centered
|
* - indicator is page centered
|
||||||
* @param {String} loc ID string, only used for console log
|
* @param {String} loc ID string, only used for console log
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function showActionIndicator(loc) // eslint-disable-line no-unused-vars
|
function showActionIndicator(loc) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -750,6 +851,7 @@ function showActionIndicator(loc) // eslint-disable-line no-unused-vars
|
|||||||
* the overlayBox is not hidden but the zIndex
|
* the overlayBox is not hidden but the zIndex
|
||||||
* is set to this value
|
* is set to this value
|
||||||
* @param {String} loc ID string, only used for console log
|
* @param {String} loc ID string, only used for console log
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function hideActionIndicator(loc) // eslint-disable-line no-unused-vars
|
function hideActionIndicator(loc) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -773,6 +875,7 @@ function hideActionIndicator(loc) // eslint-disable-line no-unused-vars
|
|||||||
/**
|
/**
|
||||||
* checks if overlayBox exists, if not it is
|
* checks if overlayBox exists, if not it is
|
||||||
* added as hidden item at the body end
|
* added as hidden item at the body end
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function checkOverlayExists()
|
function checkOverlayExists()
|
||||||
{
|
{
|
||||||
@@ -790,6 +893,7 @@ function checkOverlayExists()
|
|||||||
* if not visible show and set zIndex to 10 (GL_OB_BASE)
|
* if not visible show and set zIndex to 10 (GL_OB_BASE)
|
||||||
* if visible, add +1 to the GL_OB_S variable and
|
* if visible, add +1 to the GL_OB_S variable and
|
||||||
* up zIndex by this value
|
* up zIndex by this value
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function showOverlayBoxLayers(el_id) // eslint-disable-line no-unused-vars
|
function showOverlayBoxLayers(el_id) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -822,6 +926,7 @@ function showOverlayBoxLayers(el_id) // eslint-disable-line no-unused-vars
|
|||||||
* and set zIndex and GL_OB_S to 0
|
* and set zIndex and GL_OB_S to 0
|
||||||
* else just set zIndex to the new GL_OB_S value
|
* else just set zIndex to the new GL_OB_S value
|
||||||
* @param {String} el_id Target to hide layer
|
* @param {String} el_id Target to hide layer
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function hideOverlayBoxLayers(el_id='')
|
function hideOverlayBoxLayers(el_id='')
|
||||||
{
|
{
|
||||||
@@ -847,6 +952,7 @@ function hideOverlayBoxLayers(el_id='')
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* only for single action box
|
* only for single action box
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function clearCallActionBox() // eslint-disable-line no-unused-vars
|
function clearCallActionBox() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -864,6 +970,7 @@ function clearCallActionBox() // eslint-disable-line no-unused-vars
|
|||||||
* @param {Array} [css=[]] array for css tags
|
* @param {Array} [css=[]] array for css tags
|
||||||
* @param {Object} [options={}] anything else (value, placeholder, OnClick, style)
|
* @param {Object} [options={}] anything else (value, placeholder, OnClick, style)
|
||||||
* @return {Object} created element as an object
|
* @return {Object} created element as an object
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function cel(tag, id = '', content = '', css = [], options = {})
|
function cel(tag, id = '', content = '', css = [], options = {})
|
||||||
{
|
{
|
||||||
@@ -884,6 +991,7 @@ function cel(tag, id = '', content = '', css = [], options = {})
|
|||||||
* @param {Object} attach the object to be attached
|
* @param {Object} attach the object to be attached
|
||||||
* @param {String} [id=''] optional id, if given search in base for this id and attach there
|
* @param {String} [id=''] optional id, if given search in base for this id and attach there
|
||||||
* @return {Object} "none", technically there is no return needed as it is global attach
|
* @return {Object} "none", technically there is no return needed as it is global attach
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function ael(base, attach, id = '')
|
function ael(base, attach, id = '')
|
||||||
{
|
{
|
||||||
@@ -914,6 +1022,7 @@ function ael(base, attach, id = '')
|
|||||||
* @param {Object} base object to where we attach the elements
|
* @param {Object} base object to where we attach the elements
|
||||||
* @param {...Object} attach attach 1..n: attach directly to the base element those attachments
|
* @param {...Object} attach attach 1..n: attach directly to the base element those attachments
|
||||||
* @return {Object} "none", technically there is no return needed, global attach
|
* @return {Object} "none", technically there is no return needed, global attach
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function aelx(base, ...attach)
|
function aelx(base, ...attach)
|
||||||
{
|
{
|
||||||
@@ -930,6 +1039,7 @@ function aelx(base, ...attach)
|
|||||||
* @param {Object} base object to where we attach the elements
|
* @param {Object} base object to where we attach the elements
|
||||||
* @param {Array} attach array of objects to attach
|
* @param {Array} attach array of objects to attach
|
||||||
* @return {Object} "none", technically there is no return needed, global attach
|
* @return {Object} "none", technically there is no return needed, global attach
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function aelxar(base, attach) // eslint-disable-line no-unused-vars
|
function aelxar(base, attach) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -944,6 +1054,7 @@ function aelxar(base, attach) // eslint-disable-line no-unused-vars
|
|||||||
* resets the sub elements of the base element given
|
* resets the sub elements of the base element given
|
||||||
* @param {Object} base cel created element
|
* @param {Object} base cel created element
|
||||||
* @return {Object} returns reset base element
|
* @return {Object} returns reset base element
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function rel(base) // eslint-disable-line no-unused-vars
|
function rel(base) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -956,6 +1067,7 @@ function rel(base) // eslint-disable-line no-unused-vars
|
|||||||
* @param {Object} _element element to work one
|
* @param {Object} _element element to work one
|
||||||
* @param {String} css style sheet to remove (name)
|
* @param {String} css style sheet to remove (name)
|
||||||
* @return {Object} returns full element
|
* @return {Object} returns full element
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function rcssel(_element, css)
|
function rcssel(_element, css)
|
||||||
{
|
{
|
||||||
@@ -971,6 +1083,7 @@ function rcssel(_element, css)
|
|||||||
* @param {Object} _element element to work on
|
* @param {Object} _element element to work on
|
||||||
* @param {String} css style sheet to add (name)
|
* @param {String} css style sheet to add (name)
|
||||||
* @return {Object} returns full element
|
* @return {Object} returns full element
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function acssel(_element, css)
|
function acssel(_element, css)
|
||||||
{
|
{
|
||||||
@@ -988,6 +1101,7 @@ function acssel(_element, css)
|
|||||||
* @param {String} rcss style to remove (name)
|
* @param {String} rcss style to remove (name)
|
||||||
* @param {String} acss style to add (name)
|
* @param {String} acss style to add (name)
|
||||||
* @return {Object} returns full element
|
* @return {Object} returns full element
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function scssel(_element, rcss, acss) // eslint-disable-line no-unused-vars
|
function scssel(_element, rcss, acss) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1000,6 +1114,7 @@ function scssel(_element, rcss, acss) // eslint-disable-line no-unused-vars
|
|||||||
* that can be inserted into the page
|
* that can be inserted into the page
|
||||||
* @param {Object} tree object tree with dom element declarations
|
* @param {Object} tree object tree with dom element declarations
|
||||||
* @return {String} HTML string that can be used as innerHTML
|
* @return {String} HTML string that can be used as innerHTML
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function phfo(tree)
|
function phfo(tree)
|
||||||
{
|
{
|
||||||
@@ -1106,6 +1221,7 @@ function phfo(tree)
|
|||||||
* Is like tree.sub call
|
* Is like tree.sub call
|
||||||
* @param {Array} list Array of cel created objects
|
* @param {Array} list Array of cel created objects
|
||||||
* @return {String} HTML String
|
* @return {String} HTML String
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function phfa(list) // eslint-disable-line no-unused-vars
|
function phfa(list) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1132,6 +1248,7 @@ function phfa(list) // eslint-disable-line no-unused-vars
|
|||||||
* @param {String} [sort=''] if empty as is, else allowed 'keys',
|
* @param {String} [sort=''] if empty as is, else allowed 'keys',
|
||||||
* 'values' all others are ignored
|
* 'values' all others are ignored
|
||||||
* @return {String} html with build options block
|
* @return {String} html with build options block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function html_options(name, data, selected = '', options_only = false, return_string = false, sort = '') // eslint-disable-line no-unused-vars
|
function html_options(name, data, selected = '', options_only = false, return_string = false, sort = '') // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1159,6 +1276,7 @@ function html_options(name, data, selected = '', options_only = false, return_st
|
|||||||
* 'values' all others are ignored
|
* 'values' all others are ignored
|
||||||
* @param {String} [onchange=''] onchange trigger call, default unset
|
* @param {String} [onchange=''] onchange trigger call, default unset
|
||||||
* @return {String} html with build options block
|
* @return {String} html with build options block
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function html_options_block(
|
function html_options_block(
|
||||||
name, data, selected = '', multiple = 0, options_only = false, return_string = false, sort = '', onchange = ''
|
name, data, selected = '', multiple = 0, options_only = false, return_string = false, sort = '', onchange = ''
|
||||||
@@ -1241,6 +1359,7 @@ function html_options_block(
|
|||||||
* @param {String} name name/id
|
* @param {String} name name/id
|
||||||
* @param {Object} data array of options
|
* @param {Object} data array of options
|
||||||
* @param {String} [sort=''] if empty as is, else allowed 'keys', 'values'
|
* @param {String} [sort=''] if empty as is, else allowed 'keys', 'values'
|
||||||
|
* @deprecated use utils.js
|
||||||
* all others are ignored
|
* all others are ignored
|
||||||
*/
|
*/
|
||||||
function html_options_refill(name, data, sort = '') // eslint-disable-line no-unused-vars
|
function html_options_refill(name, data, sort = '') // eslint-disable-line no-unused-vars
|
||||||
@@ -1289,6 +1408,7 @@ function html_options_refill(name, data, sort = '') // eslint-disable-line no-un
|
|||||||
* @param {String} [return_key=''] if set only returns this key entry
|
* @param {String} [return_key=''] if set only returns this key entry
|
||||||
* or empty for none
|
* or empty for none
|
||||||
* @return {Object|String} parameter entry list
|
* @return {Object|String} parameter entry list
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function parseQueryString(query = '', return_key = '') // eslint-disable-line no-unused-vars
|
function parseQueryString(query = '', return_key = '') // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1343,6 +1463,7 @@ function parseQueryString(query = '', return_key = '') // eslint-disable-line no
|
|||||||
* @return {Object|Array|String} if search is empty, object, if search is set
|
* @return {Object|Array|String} if search is empty, object, if search is set
|
||||||
* and only one entry, then string, else array
|
* and only one entry, then string, else array
|
||||||
* unless single is true
|
* unless single is true
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function getQueryStringParam(search = '', query = '', single = false) // eslint-disable-line no-unused-vars
|
function getQueryStringParam(search = '', query = '', single = false) // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1380,6 +1501,7 @@ function getQueryStringParam(search = '', query = '', single = false) // eslint-
|
|||||||
// *** MASTER logout call
|
// *** MASTER logout call
|
||||||
/**
|
/**
|
||||||
* submits basic data for form logout
|
* submits basic data for form logout
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function loginLogout() // eslint-disable-line no-unused-vars
|
function loginLogout() // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1400,6 +1522,7 @@ function loginLogout() // eslint-disable-line no-unused-vars
|
|||||||
* @param {String} [header_id='mainHeader'] the target for the main element block
|
* @param {String} [header_id='mainHeader'] the target for the main element block
|
||||||
* if not set mainHeader is assumed
|
* if not set mainHeader is assumed
|
||||||
* this is the target div for the "loginRow"
|
* this is the target div for the "loginRow"
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function createLoginRow(login_string, header_id = 'mainHeader') // eslint-disable-line no-unused-vars
|
function createLoginRow(login_string, header_id = 'mainHeader') // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
@@ -1435,6 +1558,7 @@ function createLoginRow(login_string, header_id = 'mainHeader') // eslint-disabl
|
|||||||
* @param {String} [header_id='mainHeader'] the target for the main element block
|
* @param {String} [header_id='mainHeader'] the target for the main element block
|
||||||
* if not set mainHeader is assumed
|
* if not set mainHeader is assumed
|
||||||
* this is the target div for the "menuRow"
|
* this is the target div for the "menuRow"
|
||||||
|
* @deprecated use utils.js
|
||||||
*/
|
*/
|
||||||
function createNavMenu(nav_menu, header_id = 'mainHeader') // eslint-disable-line no-unused-vars
|
function createNavMenu(nav_menu, header_id = 'mainHeader') // eslint-disable-line no-unused-vars
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
/* general edit javascript */
|
/*
|
||||||
/* prototype version */
|
general edit javascript
|
||||||
|
prototype version
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @deprecated Do not use this anymore, use utils.js */
|
||||||
|
|
||||||
|
throw new Error("Prototype Support is deprected, please switch to jquery and utils.js/utils.min.js");
|
||||||
|
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
@@ -25,7 +31,7 @@ function pop(theURL, winName, features) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* automatically resize a text area based on the amount of lines in it
|
* automatically resize a text area based on the amount of lines in it
|
||||||
* @param {[string} ta_id element id
|
* @param {string} ta_id element id
|
||||||
*/
|
*/
|
||||||
function expandTA(ta_id) {
|
function expandTA(ta_id) {
|
||||||
var ta;
|
var ta;
|
||||||
|
|||||||
5
www/admin/layout/javascript/translateTest-ja_JP.UTF-8.js
Normal file
5
www/admin/layout/javascript/translateTest-ja_JP.UTF-8.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
var i18n = {
|
||||||
|
"Original": "Translated"
|
||||||
|
};
|
||||||
|
|
||||||
|
// __END__
|
||||||
1567
www/admin/layout/javascript/utils.js
Normal file
1567
www/admin/layout/javascript/utils.js
Normal file
File diff suppressed because it is too large
Load Diff
3
www/admin/layout/javascript/utils.min.js
vendored
Normal file
3
www/admin/layout/javascript/utils.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
www/admin/layout/javascript/utils.min.js.map
Normal file
7
www/admin/layout/javascript/utils.min.js.map
Normal file
File diff suppressed because one or more lines are too long
37
www/admin/test.javascript.html
Normal file
37
www/admin/test.javascript.html
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<title>JavaScript Test</title>
|
||||||
|
<script type="text/javascript" src="layout/javascript/jquery.min.js"></script>
|
||||||
|
<script type="text/javascript" src="layout/javascript/translateTest-ja_JP.UTF-8.js"></script>
|
||||||
|
<script type="text/javascript" src="layout/javascript/utils.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1>JavaScript tests</h1>
|
||||||
|
<div id="test-div">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script languagae="JavaScript">
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
console.log('MAIN PAGE LOADED');
|
||||||
|
// console.log('Random: %o', mh.randomIdF());
|
||||||
|
console.log('Random: %o', randomIdF());
|
||||||
|
console.log("GW: %o", getWindowSize());
|
||||||
|
let bytes = 1021152;
|
||||||
|
console.log('FB: %o', formatBytes(bytes));
|
||||||
|
console.log('FBL: %o', formatBytesLong(bytes));
|
||||||
|
console.log('TR: %s', l10n.__('Original'));
|
||||||
|
console.log('TR: %s', l10n.__('Not exists'));
|
||||||
|
|
||||||
|
setCenter('test-div', true, true);
|
||||||
|
ClearCall();
|
||||||
|
overlayBoxShow();
|
||||||
|
actionIndicatorShow('testSmarty');
|
||||||
|
setTimeout(function() {
|
||||||
|
console.log('Waiting dummy ...');
|
||||||
|
actionIndicatorHide('testSmarty');
|
||||||
|
ClearCall();
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -1024,8 +1024,12 @@ class Basic
|
|||||||
*/
|
*/
|
||||||
public function __sha1Short(string $string, bool $use_sha = false): string
|
public function __sha1Short(string $string, bool $use_sha = false): string
|
||||||
{
|
{
|
||||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Create\Hash::__sha1Short()', E_USER_DEPRECATED);
|
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Create\Hash::sha1Short() or ::__crc32b()', E_USER_DEPRECATED);
|
||||||
return \CoreLibs\Create\Hash::__sha1Short($string, $use_sha);
|
if ($use_sha) {
|
||||||
|
return \CoreLibs\Create\Hash::sha1Short($string);
|
||||||
|
} else {
|
||||||
|
return \CoreLibs\Create\Hash::__crc32b($string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1040,8 +1044,8 @@ class Basic
|
|||||||
*/
|
*/
|
||||||
public function __hash(string $string, string $hash_type = 'adler32'): string
|
public function __hash(string $string, string $hash_type = 'adler32'): string
|
||||||
{
|
{
|
||||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Create\Hash::__hash()', E_USER_DEPRECATED);
|
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Create\Hash::hash()', E_USER_DEPRECATED);
|
||||||
return \CoreLibs\Create\Hash::__hash($string, $hash_type);
|
return \CoreLibs\Create\Hash::hash($string, $hash_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// *** HASH FUNCTIONS END
|
// *** HASH FUNCTIONS END
|
||||||
|
|||||||
@@ -714,6 +714,66 @@ class DateTime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wrapper for calcDaysInterval with numeric return only
|
||||||
|
*
|
||||||
|
* @param string $start_date valid start date (y/m/d)
|
||||||
|
* @param string $end_date valid end date (y/m/d)
|
||||||
|
* @param bool $include_end_date [default=true] include end date in calc
|
||||||
|
* @param bool $exclude_start_date [default=false] include end date in calc
|
||||||
|
* @return array{0:int,1:int,2:int,3:bool}
|
||||||
|
*/
|
||||||
|
public static function calcDaysIntervalNumIndex(
|
||||||
|
string $start_date,
|
||||||
|
string $end_date,
|
||||||
|
bool $include_end_date = true,
|
||||||
|
bool $exclude_start_date = false
|
||||||
|
): array {
|
||||||
|
$values = self::calcDaysInterval(
|
||||||
|
$start_date,
|
||||||
|
$end_date,
|
||||||
|
false,
|
||||||
|
$include_end_date,
|
||||||
|
$exclude_start_date
|
||||||
|
);
|
||||||
|
return [
|
||||||
|
$values[0] ?? 0,
|
||||||
|
$values[1] ?? 0,
|
||||||
|
$values[2] ?? 0,
|
||||||
|
$values[3] ?? false,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wrapper for calcDaysInterval with named return only
|
||||||
|
*
|
||||||
|
* @param string $start_date valid start date (y/m/d)
|
||||||
|
* @param string $end_date valid end date (y/m/d)
|
||||||
|
* @param bool $include_end_date [default=true] include end date in calc
|
||||||
|
* @param bool $exclude_start_date [default=false] include end date in calc
|
||||||
|
* @return array{overall:int,weekday:int,weekend:int,reverse:bool}
|
||||||
|
*/
|
||||||
|
public static function calcDaysIntervalNamedIndex(
|
||||||
|
string $start_date,
|
||||||
|
string $end_date,
|
||||||
|
bool $include_end_date = true,
|
||||||
|
bool $exclude_start_date = false
|
||||||
|
): array {
|
||||||
|
$values = self::calcDaysInterval(
|
||||||
|
$start_date,
|
||||||
|
$end_date,
|
||||||
|
true,
|
||||||
|
$include_end_date,
|
||||||
|
$exclude_start_date
|
||||||
|
);
|
||||||
|
return [
|
||||||
|
'overall' => $values['overall'] ?? 0,
|
||||||
|
'weekday' => $values['weekday'] ?? 0,
|
||||||
|
'weekend' => $values['weekend'] ?? 0,
|
||||||
|
'reverse' => $values['reverse'] ?? false,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if a weekend day (sat/sun) is in the given date range
|
* check if a weekend day (sat/sun) is in the given date range
|
||||||
* Can have time too, but is not needed
|
* Can have time too, but is not needed
|
||||||
|
|||||||
@@ -10,9 +10,14 @@ namespace CoreLibs\Create;
|
|||||||
|
|
||||||
class Hash
|
class Hash
|
||||||
{
|
{
|
||||||
|
/** @var string default short hash -> deprecated use STANDARD_HASH_SHORT */
|
||||||
public const DEFAULT_HASH = 'adler32';
|
public const DEFAULT_HASH = 'adler32';
|
||||||
|
/** @var string default long hash (40 chars) */
|
||||||
public const STANDARD_HASH_LONG = 'ripemd160';
|
public const STANDARD_HASH_LONG = 'ripemd160';
|
||||||
|
/** @var string default short hash (8 chars) */
|
||||||
public const STANDARD_HASH_SHORT = 'adler32';
|
public const STANDARD_HASH_SHORT = 'adler32';
|
||||||
|
/** @var string this is the standard hash to use hashStd and hash (64 chars) */
|
||||||
|
public const STANDARD_HASH = 'sha256';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks php version and if >=5.2.7 it will flip the string
|
* checks php version and if >=5.2.7 it will flip the string
|
||||||
@@ -20,6 +25,7 @@ class Hash
|
|||||||
* hash returns false
|
* hash returns false
|
||||||
* preg_replace fails for older php version
|
* preg_replace fails for older php version
|
||||||
* Use __hash with crc32b or hash('crc32b', ...) for correct output
|
* Use __hash with crc32b or hash('crc32b', ...) for correct output
|
||||||
|
* For future short hashes use hashShort() instead
|
||||||
*
|
*
|
||||||
* @param string $string string to crc
|
* @param string $string string to crc
|
||||||
* @return string crc32b hash (old type)
|
* @return string crc32b hash (old type)
|
||||||
@@ -43,19 +49,31 @@ class Hash
|
|||||||
* replacement for __crc32b call
|
* replacement for __crc32b call
|
||||||
*
|
*
|
||||||
* @param string $string string to hash
|
* @param string $string string to hash
|
||||||
* @param bool $use_sha use sha instead of crc32b (default false)
|
* @param bool $use_sha use sha1 instead of crc32b (default false)
|
||||||
* @return string hash of the string
|
* @return string hash of the string
|
||||||
|
* @deprecated use __crc32b() for drop in replacement with default, or sha1Short() for use sha true
|
||||||
*/
|
*/
|
||||||
public static function __sha1Short(string $string, bool $use_sha = false): string
|
public static function __sha1Short(string $string, bool $use_sha = false): string
|
||||||
{
|
{
|
||||||
if ($use_sha) {
|
if ($use_sha) {
|
||||||
// return only the first 9 characters
|
return self::sha1Short($string);
|
||||||
return substr(hash('sha1', $string), 0, 9);
|
|
||||||
} else {
|
} else {
|
||||||
return self::__crc32b($string);
|
return self::__crc32b($string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a short sha1
|
||||||
|
*
|
||||||
|
* @param string $string string to hash
|
||||||
|
* @return string hash of the string
|
||||||
|
*/
|
||||||
|
public static function sha1Short(string $string): string
|
||||||
|
{
|
||||||
|
// return only the first 9 characters
|
||||||
|
return substr(hash('sha1', $string), 0, 9);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* replacemend for __crc32b call (alternate)
|
* replacemend for __crc32b call (alternate)
|
||||||
* defaults to adler 32
|
* defaults to adler 32
|
||||||
@@ -65,32 +83,81 @@ class Hash
|
|||||||
* @param string $string string to hash
|
* @param string $string string to hash
|
||||||
* @param string $hash_type hash type (default adler32)
|
* @param string $hash_type hash type (default adler32)
|
||||||
* @return string hash of the string
|
* @return string hash of the string
|
||||||
|
* @deprecated use hashShort() of short hashes with adler 32 or hash() for other hash types
|
||||||
*/
|
*/
|
||||||
public static function __hash(
|
public static function __hash(
|
||||||
string $string,
|
string $string,
|
||||||
string $hash_type = self::DEFAULT_HASH
|
string $hash_type = self::STANDARD_HASH_SHORT
|
||||||
|
): string {
|
||||||
|
return self::hash($string, $hash_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a hash over string if any valid hash given.
|
||||||
|
* if no hash type set use sha256
|
||||||
|
*
|
||||||
|
* @param string $string string to ash
|
||||||
|
* @param string $hash_type hash type (default sha256)
|
||||||
|
* @return string hash of the string
|
||||||
|
*/
|
||||||
|
public static function hash(
|
||||||
|
string $string,
|
||||||
|
string $hash_type = self::STANDARD_HASH
|
||||||
): string {
|
): string {
|
||||||
// if not empty, check if in valid list
|
|
||||||
if (
|
if (
|
||||||
empty($hash_type) ||
|
empty($hash_type) ||
|
||||||
!in_array($hash_type, hash_algos())
|
!in_array($hash_type, hash_algos())
|
||||||
) {
|
) {
|
||||||
// fallback to default hash type if none set or invalid
|
// fallback to default hash type if none set or invalid
|
||||||
$hash_type = self::DEFAULT_HASH;
|
$hash_type = self::STANDARD_HASH;
|
||||||
}
|
}
|
||||||
return hash($hash_type, $string);
|
return hash($hash_type, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper function for standard long hashd
|
* short hash with max length of 8, uses adler32
|
||||||
|
*
|
||||||
|
* @param string $string string to hash
|
||||||
|
* @return string hash of the string
|
||||||
|
*/
|
||||||
|
public static function hashShort(string $string): string
|
||||||
|
{
|
||||||
|
return hash(self::STANDARD_HASH_SHORT, $string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper function for standard long hash
|
||||||
|
*
|
||||||
|
* @param string $string String to be hashed
|
||||||
|
* @return string Hashed string
|
||||||
|
* @deprecated use hashLong()
|
||||||
|
*/
|
||||||
|
public static function __hashLong(string $string): string
|
||||||
|
{
|
||||||
|
return self::hashLong($string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper function for standard long hash, uses ripmd160
|
||||||
*
|
*
|
||||||
* @param string $string String to be hashed
|
* @param string $string String to be hashed
|
||||||
* @return string Hashed string
|
* @return string Hashed string
|
||||||
*/
|
*/
|
||||||
public static function __hashLong(string $string): string
|
public static function hashLong(string $string): string
|
||||||
{
|
{
|
||||||
return hash(self::STANDARD_HASH_LONG, $string);
|
return hash(self::STANDARD_HASH_LONG, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create standard hash basd on STANDAR_HASH, currently sha256
|
||||||
|
*
|
||||||
|
* @param string $string string in
|
||||||
|
* @return string hash of the string
|
||||||
|
*/
|
||||||
|
public static function hashStd(string $string): string
|
||||||
|
{
|
||||||
|
return self::hash($string, self::STANDARD_HASH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -4056,7 +4056,7 @@ class IO
|
|||||||
*/
|
*/
|
||||||
public function dbGetQueryHash(string $query, array $params = []): string
|
public function dbGetQueryHash(string $query, array $params = []): string
|
||||||
{
|
{
|
||||||
return Hash::__hashLong(
|
return Hash::hashLong(
|
||||||
$query . (
|
$query . (
|
||||||
$params !== [] ?
|
$params !== [] ?
|
||||||
'#' . json_encode($params) : ''
|
'#' . json_encode($params) : ''
|
||||||
|
|||||||
@@ -418,9 +418,7 @@ class ProgressBar
|
|||||||
// if this is percent, we ignore anything, it is auto positioned
|
// if this is percent, we ignore anything, it is auto positioned
|
||||||
if ($this->label[$name]['type'] != 'percent') {
|
if ($this->label[$name]['type'] != 'percent') {
|
||||||
foreach (['top', 'left', 'width', 'height'] as $pos_name) {
|
foreach (['top', 'left', 'width', 'height'] as $pos_name) {
|
||||||
if ($$pos_name !== false) {
|
$this->label[$name][$pos_name] = intval($$pos_name);
|
||||||
$this->label[$name][$pos_name] = intval($$pos_name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($align != '') {
|
if ($align != '') {
|
||||||
|
|||||||
Reference in New Issue
Block a user