1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 02:39:46 +02:00

Performance and javascript improvement

This commit is contained in:
DanieL 2022-07-23 15:12:31 -03:00
parent 18547db1c7
commit 6155b4ca1f
2 changed files with 17 additions and 11 deletions

View file

@ -519,17 +519,17 @@ class Layout extends PluginAbstract {
$html = preg_replace('/<script.*><\/script>/i', '', $html); $html = preg_replace('/<script.*><\/script>/i', '', $html);
//return $html; //return $html;
if (!empty(self::$tags['tagcss'])) { if (!empty(self::$tags['tagcss'])) {
$html = str_replace('</head>', implode(PHP_EOL, array_unique(self::$tags['tagcss'])).'</head>', $html); $html = str_replace('</head>', implode('', array_unique(self::$tags['tagcss'])).'</head>', $html);
} }
//return $html; //return $html;
if (!empty(self::$tags['style'])) { if (!empty(self::$tags['style'])) {
$html = str_replace('</head>', '<style>'.implode(PHP_EOL, array_unique(self::$tags['style'])).'</style></head>', $html); $html = str_replace('</head>', '<style>'.implode(' ', array_unique(self::$tags['style'])).'</style></head>', $html);
} }
if (!empty(self::$tags['tagscript'])) { if (!empty(self::$tags['tagscript'])) {
$html = str_replace('</body>', implode(PHP_EOL, array_unique(self::$tags['tagscript'])).'</body>', $html); $html = str_replace('</body>', implode('', array_unique(self::$tags['tagscript'])).'</body>', $html);
} }
if (!empty(self::$tags['script'])) { if (!empty(self::$tags['script'])) {
$html = str_replace('</body>', '<script>'.implode(PHP_EOL, array_unique(self::$tags['script'])).'</script></body>', $html); $html = str_replace('</body>', '<script>'.implode(' ', array_unique(self::$tags['script'])).'</script></body>', $html);
} }
$html = self::removeExtraSpacesFromHead($html); $html = self::removeExtraSpacesFromHead($html);
$html = self::removeExtraSpacesFromScript($html); $html = self::removeExtraSpacesFromScript($html);
@ -546,9 +546,11 @@ class Layout extends PluginAbstract {
} }
static function removeExtraSpacesFromScript($html) { static function removeExtraSpacesFromScript($html) {
preg_match('/(<script>.+<\/script>)/Usi', $html, $matches); preg_match_all('/(<script>.+<\/script>)/Usi', $html, $matches);
$str = preg_replace('/ +/', ' ', $matches[0]); foreach ($matches as $value) {
$html = str_replace($matches[0], $str, $html); $str = preg_replace('/ +/', ' ', $value);
$html = str_replace($value, $str, $html);
}
return $html; return $html;
} }

View file

@ -2056,17 +2056,21 @@ function getCroppie(uploadCropObject, callback, width, height) {
} }
async function setToolTips() { async function setToolTips() {
if (!$('[data-toggle="tooltip"]').not('.alreadyTooltip').length) {
var selettor = 'a[data-toggle="tooltip"],div[data-toggle="tooltip"],button[data-toggle="tooltip"],span[data-toggle="tooltip"]';
if (!$(selettor).not('.alreadyTooltip').length) {
return false; return false;
} }
$('[data-toggle="tooltip"]').not('.alreadyTooltip').tooltip({container: 'body', html: true}); $(selettor).not('.alreadyTooltip').tooltip({container: 'body', html: true});
$('[data-toggle="tooltip"]').not('.alreadyTooltip').on('click', function () { $(selettor).not('.alreadyTooltip').on('click', function () {
var t = this; var t = this;
setTimeout(function () { setTimeout(function () {
$(t).tooltip('hide'); $(t).tooltip('hide');
}, 2000); }, 2000);
}); });
$('[data-toggle="tooltip"]').addClass('alreadyTooltip'); $(selettor).addClass('alreadyTooltip');
} }
function avideoSocketIsActive() { function avideoSocketIsActive() {