justoverclockl / justoverclockl/thread-read-time

Fix Not wordking in Page/detail Blog

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

My CHECK : const progressBar = document.querySelector('#progress-bar'); #progress-bar << check not found in html page

```

index.js:38 Uncaught TypeError: Cannot read properties of null (reading 'style')
at index.js:38:19
```

index.js:38 >>>> progressBar.style.width = value + '%';

```
/*
* This file is part of justoverclock/thread-read-time extension.
*
* Copyright (c) 2021 Marco Colia.
* https://flarum.it
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

import app from 'flarum/forum/app';
import { extend } from 'flarum/common/extend';
import PostStream from 'flarum/forum/components/PostStream';
import PostStreamScrubber from 'flarum/forum/components/PostStreamScrubber';

app.initializers.add('justoverclock/thread-read-time', () => {
extend(PostStreamScrubber.prototype, 'view', function (vdom) {
if (vdom.children && vdom.children.splice) {
const insert = (





);
vdom.children.splice(0, 0, insert);
}
});
extend(PostStream.prototype, ['oncreate', 'onupdate'], function () {
const progressBar = document.querySelector('#progress-bar');
const section = document.querySelector('div#app');
const readTime = document.querySelector('#readPerc');

const getScrollValue = () => {
let distance = -section.getBoundingClientRect().top;
let progressWidth = (distance / (section.getBoundingClientRect().height - document.documentElement.clientHeight)) * 100;
let value = Math.min(Math.max(parseInt(progressWidth), 0), 100);

progressBar.style.width = value + '%';
readTime.innerText =
app.translator.trans('justoverclock-thread-read-time.forum.reading') + ' ' +
value + '%' + ' ' + app.translator.trans('justoverclock-thread-read-time.forum.ofThread');
};

window.addEventListener('scroll', getScrollValue);
});
});
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.