news scroller updates

pull/46/head
accius 2 days ago
parent bac64fc86b
commit 933b074461

@ -0,0 +1,14 @@
node_modules
dist
.git
.env
.env.local
*.log
npm-debug.log*
.DS_Store
.vscode
.idea
*.zip
*.tar.gz
dxspider-proxy/node_modules
iturhfprop-service/node_modules

@ -734,16 +734,18 @@ app.get('/api/dxnews', async (req, res) => {
const titleMatch = block.match(/title="([^"]+)"/); const titleMatch = block.match(/title="([^"]+)"/);
// Extract date // Extract date
const dateMatch = block.match(/(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})/); const dateMatch = block.match(/(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})/);
// Extract description - text after the date, before "Views" or next element // Extract description - text after the date, before stats
const descParts = block.split(/\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}/); const descParts = block.split(/\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}/);
let desc = ''; let desc = '';
if (descParts[1]) { if (descParts[1]) {
// Get text content, strip HTML tags // Get text content, strip HTML tags, then remove stats/junk
desc = descParts[1] desc = descParts[1]
.replace(/<[^>]+>/g, ' ') .replace(/<[^>]+>/g, ' ')
.replace(/\s+/g, ' ') .replace(/\s+/g, ' ')
.replace(/Views\d+.*$/, '') .replace(/Views\s*\d+.*/i, '')
.replace(/More\.\.\..*$/, '') .replace(/Comments\s*\d+.*/i, '')
.replace(/\d+%/, '')
.replace(/More\.\.\..*/i, '')
.trim() .trim()
.substring(0, 200); .substring(0, 200);
} }

@ -40,8 +40,8 @@ export const DXNewsTicker = () => {
if (contentRef.current && tickerRef.current) { if (contentRef.current && tickerRef.current) {
const contentWidth = contentRef.current.scrollWidth; const contentWidth = contentRef.current.scrollWidth;
const containerWidth = tickerRef.current.offsetWidth; const containerWidth = tickerRef.current.offsetWidth;
// ~50px per second scroll speed // ~90px per second scroll speed
const duration = Math.max(30, (contentWidth + containerWidth) / 50); const duration = Math.max(20, (contentWidth + containerWidth) / 90);
setAnimDuration(duration); setAnimDuration(duration);
} }
}, [news]); }, [news]);

Loading…
Cancel
Save

Powered by TurnKey Linux.