Uncaught TypeError: Cannot read properties of undefined (reading 'style')
at showSlides(site/
at site/
With what it can be connected?
.\ext\tamit\slideshow\event\main_listener.php
. Pay attention to lines from 87 to 90, and line 105
Code: Select all
87. if ($this->config['tamit_slideshow_mode'] == 0)
88. {
89. $this->template->assign_var('SLIDESHOW_SLIDES', $this->manager->get_enabled_slides());
90. }
Code: Select all
105. $this->template->assign_var('SLIDESHOW_SLIDES', $this->manager->get_newest_topics($forum_id, $this->config['tamit_slideshow_topic_count']));
Code: Select all
<?php
/**
*
* Slideshow Management. An extension for the phpBB Forum Software package.
*
* @copyright (c) 2021 Huynh Buu Tam <https://www.tamit.net>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace tamit\slideshow\event;
/**
* @ignore
*/
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class main_listener implements EventSubscriberInterface
{
/** @var \phpbb\template\template */
protected $template;
/** @var \phpbb\request\request */
protected $request;
/** @var \phpbb\config\config */
protected $config;
/** @var \tamit\slideshow\core\manager */
protected $manager;
/** @var string */
protected $php_ext;
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return array(
'core.user_setup' => 'load_language_on_setup',
'core.page_header_after' => array(array('setup_slides'), array('slideshow_target'))
);
}
/**
* Constructor
*
* @param \phpbb\template\template $template Template object
* @param \phpbb\request\request $request Request object
* @param \phpbb\config\config $config Config object
* @param \tamit\slideshow\core\manager $manager Slideshow manager object
* @param string $php_ext PHP extension
*/
public function __construct(\phpbb\template\template $template, \phpbb\request\request $request, \phpbb\config\config $config, \tamit\slideshow\core\manager $manager, $php_ext)
{
$this->template = $template;
$this->request = $request;
$this->config = $config;
$this->manager = $manager;
$this->php_ext = $php_ext;
}
/**
* Load common language file during user setup
*
* @param \phpbb\event\data $event The event object
* @return void
*/
public function load_language_on_setup($event)
{
$lang_set_ext = $event['lang_set_ext'];
$lang_set_ext[] = array(
'ext_name' => 'tamit/slideshow',
'lang_set' => 'common'
);
$event['lang_set_ext'] = $lang_set_ext;
}
/**
* Displays slides
*
* @return void
*/
public function setup_slides()
{
if ($this->config['tamit_slideshow_mode'] == 0)
{
$this->template->assign_var('SLIDESHOW_SLIDES', $this->manager->get_enabled_slides());
}
else
{
$forum_id = $this->request->variable('f', 0);
if ($forum_id == 0)
{
$forum_id = $this->manager->get_forum_id($this->request->variable('t', 0), false);
}
if ($forum_id == 0)
{
$forum_id = $this->manager->get_forum_id($this->request->variable('p', 0), true);
}
$this->template->assign_var('SLIDESHOW_SLIDES', $this->manager->get_newest_topics($forum_id, $this->config['tamit_slideshow_topic_count']));
}
}
/**
* Assign target page
*
* @return void
*/
public function slideshow_target()
{
$this->template->assign_var('S_SLIDESHOW_PAGE_INDEX', $this->config['tamit_slideshow_page_index']);
$this->template->assign_var('S_SLIDESHOW_PAGE_VIEWFORUM', $this->config['tamit_slideshow_page_viewforum']);
$this->template->assign_var('S_SLIDESHOW_PAGE_VIEWTOPIC', $this->config['tamit_slideshow_page_viewtopic']);
$this->template->assign_var('S_SLIDESHOW_DURATION', $this->config['tamit_slideshow_duration']);
$this->template->assign_var('S_SLIDESHOW_BOX', $this->config['tamit_slideshow_box']);
$this->template->assign_var('S_SLIDESHOW_NAV_IMAGE', $this->config['tamit_slideshow_nav_image']);
$this->template->assign_var('S_SLIDESHOW_NAV_DOT', $this->config['tamit_slideshow_nav_dot']);
}
}
.\ext\tamit\slideshow\styles\all\template\event\overall_footer_after.html
. Pay attention to the first line
Code: Select all
{% if SLIDESHOW_SLIDES|length > 0 %}
<script type="text/javascript">
var slides = document.getElementsByClassName("slideshow-slides");
var slideIndex = Math.floor(Math.random() * slides.length);
var showLoopTime = {{ S_SLIDESHOW_DURATION }};
showSlides(slideIndex);
var slideShowTimer = setInterval(loopSlides, showLoopTime);
function loopSlides() {
slideIndex++;
if (slideIndex > slides.length) {
slideIndex = 1;
}
if (slideIndex < 1) {
slideIndex = slides.length;
}
showSlides(slideIndex);
}
function plusSlides(n) {
showSlides(slideIndex += n);
resetShowTimer();
}
function currentSlide(n) {
slideIndex = n;
showSlides(n);
resetShowTimer();
}
function resetShowTimer() {
clearInterval(slideShowTimer);
slideShowTimer = setInterval(loopSlides, showLoopTime);
}
function showSlides(n) {
var i;
if (n > slides.length) {
slideIndex = 1;
}
if (n < 1) {
slideIndex = slides.length;
}
for (i = 0; i < slides.length; i++) {
slides[i].style.opacity = 0;
slides[i].style.height= 0;
}
slides[slideIndex-1].style.opacity = 1;
slides[slideIndex-1].style.height = "100%";
{% if S_SLIDESHOW_NAV_DOT == 1 %}
/* Dot navigator */
var dotNav = document.getElementsByClassName("slideshow-dot-navigator");
for (i = 0; i < dotNav.length; i++) {
dotNav[i].className = dotNav[i].className.replace(" slideshow-active", "");
}
dotNav[slideIndex-1].className += " slideshow-active";
{% endif %}
{% if S_SLIDESHOW_NAV_IMAGE == 1 %}
/* Image navigator */
var imgNav = document.getElementsByClassName("slideshow-image-navigator");
for (i = 0; i < imgNav.length; i++) {
imgNav[i].className = imgNav[i].className.replace(" slideshow-active", "");
}
imgNav[slideIndex-1].className += " slideshow-active";
imgNav[slideIndex-1].parentElement.scrollTop = imgNav[slideIndex-1].offsetTop;
{% endif %}
}
/* Swipe event */
for (i = 0; i < slides.length; i++) {
slides[i].addEventListener('touchstart', handleTouchStart, false);
slides[i].addEventListener('touchmove', slideShow_handleTouchMove, false);
}
var xDown = null;
var yDown = null;
function getTouches(evt) {
return evt.touches || evt.originalEvent.touches; // jQuery
}
function handleTouchStart(evt) {
const firstTouch = getTouches(evt)[0];
xDown = firstTouch.clientX;
yDown = firstTouch.clientY;
};
function slideShow_handleTouchMove(evt) {
if (!xDown || !yDown) {
return;
}
var xUp = evt.touches[0].clientX;
var yUp = evt.touches[0].clientY;
var xDiff = xDown - xUp;
var yDiff = yDown - yUp;
/* Most significant */
if (Math.abs(xDiff) > Math.abs(yDiff)) {
if (xDiff > 0) {
/* Swipe right */
plusSlides(1);
} else {
/* Swipe left */
plusSlides(-1);
}
} else {
if (yDiff > 0) {
/* Swipe down */
} else {
/* Swipe up */
}
}
/* Reset values */
xDown = null;
yDown = null;
};
</script>
{% endif %}
.\ext\tamit\slideshow\styles\all\template\event\viewtopic_topic_title_before.html
Code: Select all
{% if S_SLIDESHOW_PAGE_VIEWTOPIC == 1 %}
{% INCLUDE 'tamit_slideshow_default.html' %}
{% endif %}
.\ext\tamit\slideshow\styles\all\template\event\viewforum_forum_title_before.html
Code: Select all
{% if S_SLIDESHOW_PAGE_VIEWFORUM == 1 %}
{% INCLUDE 'tamit_slideshow_default.html' %}
{% endif %}